feat: show workspace key and observer URL in agent-relay status#740
Conversation
- Add workspace_key from getSession() to status output - Add full observer URL: https://agentrelay.com/observer?key=<workspace_key>
The status test's SDK client mock was missing getSession, so the new await client.getSession() call in runStatusCommand threw and skipped past disconnect(). Add getSession to the mock, assert the new log lines, and add an omission case for when workspace_key is empty. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| const session = await client.getSession(); | ||
| if (session.workspace_key) { | ||
| deps.log(`Workspace Key: ${session.workspace_key}`); | ||
| deps.log(`Observer: https://agentrelay.com/observer?key=${session.workspace_key}`); | ||
| } | ||
| client.disconnect(); |
There was a problem hiding this comment.
🟡 client.disconnect() skipped when getSession() throws, leaking transport resources
The new client.getSession() call at line 1302 is placed before client.disconnect() at line 1307, both inside the try block. If getSession() throws (e.g., the broker doesn't support the endpoint, times out, or returns an error), execution jumps to the empty catch block and disconnect() is never called. This leaves the BrokerTransport un-cleaned (timers, open WebSocket if any). Before this PR, only getStatus() could throw before disconnect(), but the addition of getSession() introduces a new failure point after status info has already been successfully retrieved and logged — making the resource leak more likely in practice.
| const session = await client.getSession(); | |
| if (session.workspace_key) { | |
| deps.log(`Workspace Key: ${session.workspace_key}`); | |
| deps.log(`Observer: https://agentrelay.com/observer?key=${session.workspace_key}`); | |
| } | |
| client.disconnect(); | |
| const session = await client.getSession(); | |
| if (session.workspace_key) { | |
| deps.log(`Workspace Key: ${session.workspace_key}`); | |
| deps.log(`Observer: https://agentrelay.com/observer?key=${session.workspace_key}`); | |
| } | |
| client.disconnect(); | |
| } catch { | |
| // PID-based status is enough when broker query fails. | |
| } finally { | |
| client.disconnect(); |
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Focused replacement for #739 (which accumulated unrelated commits through merges). Rebased on latest main with only the status-command change.
Workspace Key:andObserver:lines toagent-relay statusoutputhttps://agentrelay.com/observer?key=<workspace_key>client.getSession()to fetchworkspace_keyfrom the brokerExample output
Diff
Single file, +5 lines in
src/cli/lib/broker-lifecycle.ts.Test plan
agent-relay statusagainst a running broker shows the two new linesagent-relay statuswhengetSession()has noworkspace_keyomits them gracefullyReplaces #739.