fix: history and inbox work without RELAY_API_KEY env var#722
Merged
khaliqgant merged 26 commits intomainfrom Apr 12, 2026
Merged
fix: history and inbox work without RELAY_API_KEY env var#722khaliqgant merged 26 commits intomainfrom
khaliqgant merged 26 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>
khaliqgant
added a commit
that referenced
this pull request
Apr 13, 2026
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.
khaliqgant
added a commit
that referenced
this pull request
Apr 13, 2026
* feat: add workflow for relay bootstrap and messaging fixes * fix: harden relay fix workflow execution * fix: run relay workflow validations from the active checkout * fix: split relay rebuild workflow into explicit build steps * fix: make sdk build use repo-local TypeScript * fix: add typescript to sdk build dependencies * fix: make sdk workflow build use explicit TypeScript package * chore: add follow-up workflow for long-term sdk build fix * fix: pin sdk workflow compiler to TypeScript 5.7.3 * fix: make config build use explicit TypeScript compiler * fix: add missing deterministic plan file for relay workflow * fix: keep relay workflow agents scoped to active checkout * fix: improve local bootstrap and messaging workflow outcomes * fix: resolve Devin review comments and remove committed workflow files - 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 * fix: pin typescript to 5.7.3 in utils package Missed by the workflow (build:esm sub-script not caught in diagnosis). Aligns utils with the rest of the packages. * fix: consolidate TypeScript to root toolchain, drop per-package pins 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. * trajectories * fix: use plain tsc in package build scripts, not npx tsc 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. * fix: run sdk type check via workspace npm install, not package-local 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. * feat: add TDD workflow for agent-relay CLI commands Tests spawn, who, agents:logs, release, set-model, send, history, inbox in headless mode against live broker. * fix: add workspace_key support to connection.json and SDK - SDK client.ts: read workspace_key from connection.json - messaging.ts: fall back to getSession() to fetch workspace_key * feat: add workflow to test and fix history/inbox workspace_key resolution * feat: update history/inbox fix workflow with deterministic commit+PR step * fix: resolve workspace_key from broker API for history/inbox 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. * fix: keep inbox --json output snake_case for downstream tools 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> * feat: add v2 workflow to fix history/inbox * fix: fetch workspace_key from broker HTTP API for history/inbox Replaces AgentRelayClient.connect() with direct fs/path + fetch to broker's /api/session endpoint to get workspace_key. * Merge origin/main into miya/relay-fix-workflow 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. * fix issue * fix(cli): move esbuild to runtime dependencies 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> * fix: address 9 review finding(s) 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> --------- Co-authored-by: Miya <miya@openclaw.local> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.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
and failed with:
...even when a broker was running with a valid workspace key.
Root Cause
only checked the env var and then tried which reads — but that file was not reliably present when the broker is managed by the workflow runner.
Fix
Fetch directly from the running broker's HTTP endpoint using the and from . This is always available when the broker is running.
Verified