Repository navigation
fix(sdk): expose camelCase types for agent exit and node status - #505
willwashburn wants to merge 1 commit into
Conversation
…vents agent.exited, node.status.online, and node.status.offline are valid ServerEvent/WsClientEvent members that the engine emits, but @relaycast/sdk exposed no Camelize<Raw.X> type or on.* handler for any of them. Since @relaycast/types is a runtime dependency of the SDK, the only reachable type named AgentExitedEvent was the raw snake_case one, which type-checks against code but silently reads undefined against the camelized payload the WsClient actually delivers. Add the missing camelCase types and on.agentExited/on.nodeOnline/ on.nodeOffline handlers, plus regression tests that round-trip real captured snake_case frames through the typed handlers. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47fc500d64
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| nodeOnline: (handler: (e: NodeStatusOnlineEvent) => void): (() => void) => this.onEvent('node.status.online', handler), | ||
| nodeOffline: (handler: (e: NodeStatusOfflineEvent) => void): (() => void) => this.onEvent('node.status.offline', handler), |
There was a problem hiding this comment.
Route node status events to AgentClient
When consumers register these callbacks on AgentClient, they can never fire in production: AgentClient connects exclusively through /v1/node/ws, while the canonical engine's emitNodeStatusEffects sends node.status.online and node.status.offline only to the workspace stream and webhook outbox, with no node/agent audience. The new test bypasses that routing by injecting a synthetic node frame directly. Either route these events to the direct-node client or expose these handlers only on RelayCast; otherwise the advertised agent.on.nodeOnline/nodeOffline API silently does nothing.
AGENTS.md reference: AGENTS.md:L10-L12
Useful? React with 👍 / 👎.
| nodeOnline: (handler: (e: NodeStatusOnlineEvent) => void): (() => void) => this.onEvent('node.status.online', handler), | ||
| nodeOffline: (handler: (e: NodeStatusOfflineEvent) => void): (() => void) => this.onEvent('node.status.offline', handler), |
There was a problem hiding this comment.
🟡 Agent node-status handlers never fire
AgentClient.on.nodeOnline and nodeOffline listen on the direct-node socket. emitNodeStatusEffects sends these events only to workspace observers and webhooks, so both callbacks remain silent.
Learn more
Node-status transitions are workspace-wide events. AgentClient connects through /v1/node/ws, which carries node control frames and events explicitly delivered to an agent. The engine's emitNodeStatusEffects publishes each transition to the workspace stream and webhook queue, but never calls sendNodeDeliveriesToAgents. The test injects a workspace-stream event directly into the node socket, a frame the engine does not produce on that transport.
Example: A node times out and the engine emits node.status.offline. RelayCast.on.nodeOffline can receive it through /v1/ws, but an AgentClient.on.nodeOffline callback never runs.
Recommended fix: Remove nodeOnline and nodeOffline from AgentClient.on, or add an intentional server delivery path for node-status events to defined agent recipients. If these remain workspace-only, move their runtime coverage to RelayCast tests using /v1/ws.
Was this helpful? React with 👍 or 👎 to provide feedback.
AgentExitedEvent,NodeStatusOnlineEvent, andNodeStatusOfflineEventare the camelCase SDK types foragent.exited,node.status.online, andnode.status.offline.on.agentExited,on.nodeOnline, andon.nodeOfflinedeliver those payloads. Wire event type strings stay snake_case.Stacks on #504.
Fixes #491
Replaces draft #496.
Checks
npm run test:typesinpackages/sdk-typescript— passnpx vitest run src/__tests__/agent-ws.test.tsinpackages/sdk-typescript— 42 passedNote
Low Risk
Additive SDK types and event handlers with tests; no server or auth changes.
Overview
Fixes a TypeScript SDK gap where
agent.exited,node.status.online, andnode.status.offlineWebSocket frames were delivered with camelCase fields but had no matching SDK surface—callers who typed handlers with snake_case@relaycast/typesaliases could compile yet readundefinedon every property.The PR adds camelCase exports
AgentExitedEvent,NodeStatusOnlineEvent, andNodeStatusOfflineEvent, pluson.agentExited,on.nodeOnline, andon.nodeOfflineon bothAgentClientandRelayCast. Wire event type strings stay snake_case. Changelog entries document the fix, andagent-ws.test.tsasserts camelization against captured wire shapes.Reviewed by Cursor Bugbot for commit 47fc500. Bugbot is set up for automated code reviews on this repo. Configure here.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.