fix: history/inbox fetch workspace_key via broker HTTP API#729
Merged
khaliqgant merged 33 commits intomainfrom Apr 13, 2026
Merged
fix: history/inbox fetch workspace_key via broker HTTP API#729khaliqgant merged 33 commits intomainfrom
khaliqgant merged 33 commits intomainfrom
Conversation
- 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.
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.
# Conflicts: # CHANGELOG.md
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.