Skip to content

feat: show workspace key and observer URL in agent-relay status#739

Closed
khaliqgant wants to merge 32 commits into
mainfrom
miya/relay-fix-workflow
Closed

feat: show workspace key and observer URL in agent-relay status#739
khaliqgant wants to merge 32 commits into
mainfrom
miya/relay-fix-workflow

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

@khaliqgant khaliqgant commented Apr 14, 2026

Summary

Example output

Status: RUNNING
Mode: broker (stdio)
PID: 52432
Project: /Users/khaliqgant/Projects/AgentWorkforce/relay
Agents: 0
Workspace Key: rk_live_0b4133c4853b0d266042401691f3dbf8
Observer: https://agentrelay.com/observer?key=rk_live_0b4133c4853b0d266042401691f3dbf8

Implementation

  • Calls client.getSession() to fetch workspace_key from the broker
  • Logs workspace key and constructs observer URL

Open with Devin

Miya and others added 30 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.
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 and others added 2 commits April 13, 2026 11:35
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>
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 found 1 potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

Comment on lines +103 to +122
command: `set -e
agent-relay down --force 2>/dev/null || true
sleep 2
rm -rf .agent-relay
sleep 1
agent-relay up 2>&1 &
sleep 15

echo "=== RETEST HISTORY ==="
agent-relay history --limit 3 2>&1
HISTORY_EXIT=$?

echo ""
echo "=== RETEST INBOX ==="
agent-relay inbox 2>&1
INBOX_EXIT=$?

echo ""
if [ $HISTORY_EXIT -eq 0 ] && [ $INBOX_EXIT -eq 0 ]; then echo "RETEST_PASSED"
else echo "RETEST_FAILED: history=$HISTORY_EXIT inbox=$INBOX_EXIT"; exit 1; fi`,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 set -e prevents exit code capture in workflow retest step

The retest step shell script uses set -e at line 103 but then tries to capture exit codes from agent-relay history and agent-relay inbox using $? (lines 113, 118). With set -e active, if either command returns a non-zero exit code, the shell will terminate immediately at the failing command line — HISTORY_EXIT=$? or INBOX_EXIT=$? will never execute, and the diagnostic summary at lines 121-122 (RETEST_FAILED: history=X inbox=Y) will never be printed. The intent is clearly to run both commands and summarize results, but set -e defeats this pattern.

Suggested change
command: `set -e
agent-relay down --force 2>/dev/null || true
sleep 2
rm -rf .agent-relay
sleep 1
agent-relay up 2>&1 &
sleep 15
echo "=== RETEST HISTORY ==="
agent-relay history --limit 3 2>&1
HISTORY_EXIT=$?
echo ""
echo "=== RETEST INBOX ==="
agent-relay inbox 2>&1
INBOX_EXIT=$?
echo ""
if [ $HISTORY_EXIT -eq 0 ] && [ $INBOX_EXIT -eq 0 ]; then echo "RETEST_PASSED"
else echo "RETEST_FAILED: history=$HISTORY_EXIT inbox=$INBOX_EXIT"; exit 1; fi`,
command: `set -e
agent-relay down --force 2>/dev/null || true
sleep 2
rm -rf .agent-relay
sleep 1
agent-relay up 2>&1 &
sleep 15
echo "=== RETEST HISTORY ==="
agent-relay history --limit 3 2>&1 || true
HISTORY_EXIT=$?
echo ""
echo "=== RETEST INBOX ==="
agent-relay inbox 2>&1 || true
INBOX_EXIT=$?
echo ""
if [ $HISTORY_EXIT -eq 0 ] && [ $INBOX_EXIT -eq 0 ]; then echo "RETEST_PASSED"
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@khaliqgant khaliqgant closed this Apr 14, 2026
@willwashburn willwashburn deleted the miya/relay-fix-workflow branch May 15, 2026 13:09
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