Skip to content

fix: history and inbox work without RELAY_API_KEY env var#722

Merged
khaliqgant merged 26 commits intomainfrom
miya/relay-fix-workflow
Apr 12, 2026
Merged

fix: history and inbox work without RELAY_API_KEY env var#722
khaliqgant merged 26 commits intomainfrom
miya/relay-fix-workflow

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

@khaliqgant khaliqgant commented Apr 12, 2026

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

  • Workflow test: history and inbox return results after fix
  • Unit tests: all messaging tests pass

Open with Devin

Miya and others added 24 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.
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 7 additional findings.

Open in Devin Review

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-ai-integration[bot]

This comment was marked as resolved.

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 khaliqgant merged commit 5c270fa into main Apr 12, 2026
44 checks passed
@khaliqgant khaliqgant deleted the miya/relay-fix-workflow branch April 12, 2026 07:04
@khaliqgant khaliqgant restored the miya/relay-fix-workflow branch April 13, 2026 08:16
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>
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