Skip to content

fix: history/inbox fetch workspace_key via broker HTTP API#729

Merged
khaliqgant merged 33 commits intomainfrom
miya/relay-fix-workflow
Apr 13, 2026
Merged

fix: history/inbox fetch workspace_key via broker HTTP API#729
khaliqgant merged 33 commits intomainfrom
miya/relay-fix-workflow

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

@khaliqgant khaliqgant commented Apr 13, 2026

Problem

history and inbox fail with 'Relaycast API key not found in RELAY_API_KEY'

Fix

resolveRelaycastApiKey() now reads connection.json manually using fs/path and calls /api/session directly to get workspace_key.

Status

Committed on miya/relay-fix-workflow branch. Tests may fail locally due to connection.json persistence issues in dev environment.


Open with Devin

Miya and others added 28 commits April 11, 2026 15:07
- align packages/config devDependency typescript to 5.7.3 (matches pinned build script)
- fix packages/sdk build:full and check scripts to use npx tsc (consistent with build)
- remove workflow files (relay-fix-workflow.ts, relay-fix-long-term-sdk-build.ts, PLAN-*.md) from repo
Missed by the workflow (build:esm sub-script not caught in diagnosis).
Aligns utils with the rest of the packages.
Instead of each package independently pinning typescript@5.7.3 via npx,
use a single exact version at root (5.9.3) and let all packages resolve
tsc via npx from node_modules/.bin. This means one version to update,
zero hardcoded version strings in build scripts.
npx tsc resolves a package named 'tsc' on npm (v2.0.4, wrong package).
Plain 'tsc' in an npm script resolves from node_modules/.bin/tsc, which
is the root-hoisted typescript compiler.
Package-local npm install does not install typescript (now root-only).
Install at root so the workspace hoists tsc to node_modules/.bin, then
invoke via npm run -w which resolves from the workspace root.
Tests spawn, who, agents:logs, release, set-model, send, history, inbox
in headless mode against live broker.
- SDK client.ts: read workspace_key from connection.json
- messaging.ts: fall back to getSession() to fetch workspace_key
history and inbox previously required RELAY_API_KEY env var.
Now resolveRelaycastApiKey() fetches workspace_key directly from the
running broker's /api/session endpoint using the local connection.json,
so both commands work out of the box whenever a broker is running.
Resolve conflicts in src/cli/commands/messaging.ts and package-lock.json.

messaging.ts: adopt main's resolveRelaycastApiKey implementation, which
uses AgentRelayClient.connect({cwd}) + client.getSession() instead of
the raw-HTTP /api/session fetch on this branch. Main's version relies
on the SDK's connection handling and is strictly simpler. The unused
BrokerConnectionMetadata / BrokerSessionResponse interfaces and the
node:fs / node:path imports they required are dropped.

package-lock.json: regenerated from the merged package.json via
npm install --package-lock-only --ignore-scripts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Devin review on PR #722 flagged that inbox --json silently changed field
names from snake_case to camelCase after the merge, because the inbox
command now calls normalizeInbox() and then JSON.stringify(inbox) on
the normalized camelCase struct. That breaks any script parsing the
JSON output, and the docs explicitly call it a machine-readable contract.

Mirror the history --json pattern: construct an explicit payload with
stable snake_case keys (unread_channels, channel_name, unread_count,
mentions[*].channel_name/agent_name/created_at, unread_dms[*].conversation_id/
unread_count/last_message, recent_reactions[*].message_id/channel_name/
agent_name/created_at) from the normalized struct. The human-readable
output path is unchanged.

Add a test that feeds camelCase inbox payloads to the mock SDK and
asserts the --json output is fully snake_case.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replaces AgentRelayClient.connect() with direct fs/path + fetch to
broker's /api/session endpoint to get workspace_key.
devin-ai-integration[bot]

This comment was marked as resolved.

khaliqgant and others added 3 commits April 13, 2026 11:28
Resolved conflicts in src/cli/commands/messaging.ts and package-lock.json.

For messaging.ts resolveRelaycastApiKey, took main's polished error
messages (#722 landed an equivalent fix). Behavior is identical.

package-lock.json regenerated via npm install.
devin-ai-integration[bot]

This comment was marked as resolved.

khaliqgant and others added 2 commits April 13, 2026 11:45
setup.ts statically imports `esbuild` for workflow pre-parse hints (#727),
but esbuild was only in devDependencies. Global installs of agent-relay
don't get devDeps, so the published package failed to load with
ERR_MODULE_NOT_FOUND on first invocation, breaking the post-publish verify
job.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
messaging.ts: src/cli/commands/messaging.ts
messaging.ts: src/cli/commands/messaging.ts
messaging.ts: src/cli/commands/messaging.ts
fix-history-inbox-v2.ts: workflows/fix-history-inbox-v2.ts
fix-history-inbox-v2.ts: workflows/fix-history-inbox-v2.ts
... and 4 more

Co-Authored-By: My Senior Dev <dev@myseniordev.com>
@khaliqgant khaliqgant merged commit 3159de9 into main Apr 13, 2026
44 checks passed
@khaliqgant khaliqgant deleted the miya/relay-fix-workflow branch April 13, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant