Add AI Gateway WebSocket client with reconnect and draining support#1609
Conversation
Implements multiplexed request/response handling, draining-aware reconnect, and AIGatewayClient.createWebSocket() for shared auth configuration. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 35 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds AI Gateway WebSocket protocol definitions, a WebSocket client with streaming and drain handling, ChangesAI Gateway WebSocket Support
Sequence Diagram(s)sequenceDiagram
participant Caller
participant AIGatewayClient
participant AIGatewayWebSocketClient
participant WebSocketServer
Caller->>AIGatewayClient: createWebSocket(options)
AIGatewayClient->>AIGatewayClient: validate apiKey/orgId
AIGatewayClient->>AIGatewayWebSocketClient: createAIGatewayWebSocketClient(...)
Caller->>AIGatewayWebSocketClient: stream(requestOptions)
AIGatewayWebSocketClient->>WebSocketServer: send(requestFrame)
WebSocketServer-->>AIGatewayWebSocketClient: delta / thinking_delta frames
WebSocketServer-->>AIGatewayWebSocketClient: complete frame
AIGatewayWebSocketClient-->>Caller: yield events / resolve result
Metadata 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
Comment |
📦 Canary Packages Publishedversion: PackagesInstallAdd to your {
"dependencies": {
"@agentuity/hono": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-hono-3.1.7-53d1e0b.tgz",
"@agentuity/postgres": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-postgres-3.1.7-53d1e0b.tgz",
"@agentuity/storage": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-storage-3.1.7-53d1e0b.tgz",
"@agentuity/genesis": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-genesis-3.1.7-53d1e0b.tgz",
"@agentuity/queue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-queue-3.1.7-53d1e0b.tgz",
"@agentuity/core": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-core-3.1.7-53d1e0b.tgz",
"create-agentuity": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/create-agentuity-3.1.7-53d1e0b.tgz",
"@agentuity/migrate": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-migrate-3.1.7-53d1e0b.tgz",
"@agentuity/sandbox": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-sandbox-3.1.7-53d1e0b.tgz",
"@agentuity/keyvalue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-keyvalue-3.1.7-53d1e0b.tgz",
"@agentuity/config": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-config-3.1.7-53d1e0b.tgz",
"@agentuity/drizzle": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-drizzle-3.1.7-53d1e0b.tgz",
"@agentuity/telemetry": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-telemetry-3.1.7-53d1e0b.tgz",
"@agentuity/schema": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-schema-3.1.7-53d1e0b.tgz",
"@agentuity/cli": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-cli-3.1.7-53d1e0b.tgz",
"@agentuity/aigateway": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-aigateway-3.1.7-53d1e0b.tgz",
"@agentuity/task": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-task-3.1.7-53d1e0b.tgz",
"@agentuity/webhook": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-webhook-3.1.7-53d1e0b.tgz",
"@agentuity/analytics": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-analytics-3.1.7-53d1e0b.tgz",
"@agentuity/api": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-api-3.1.7-53d1e0b.tgz",
"@agentuity/email": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-email-3.1.7-53d1e0b.tgz",
"@agentuity/pi": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-pi-3.1.7-53d1e0b.tgz",
"@agentuity/vector": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-vector-3.1.7-53d1e0b.tgz",
"@agentuity/client": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-client-3.1.7-53d1e0b.tgz",
"@agentuity/claude-code": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-claude-code-3.1.7-53d1e0b.tgz",
"@agentuity/opencode": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-opencode-3.1.7-53d1e0b.tgz",
"@agentuity/skills": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-skills-3.1.7-53d1e0b.tgz",
"@agentuity/runtime": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-runtime-3.1.7-53d1e0b.tgz",
"@agentuity/db": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-db-3.1.7-53d1e0b.tgz",
"@agentuity/stream": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-stream-3.1.7-53d1e0b.tgz",
"@agentuity/schedule": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-schedule-3.1.7-53d1e0b.tgz",
"@agentuity/coder-tui": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-coder-tui-3.1.7-53d1e0b.tgz",
"@agentuity/vite": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-vite-3.1.7-53d1e0b.tgz",
"@agentuity/adapter": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-adapter-3.1.7-53d1e0b.tgz",
"@agentuity/coder": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-coder-3.1.7-53d1e0b.tgz",
"@agentuity/server": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-server-3.1.7-53d1e0b.tgz"
}
}Or install directly: bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-hono-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-postgres-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-storage-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-genesis-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-queue-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-core-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/create-agentuity-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-migrate-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-sandbox-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-keyvalue-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-config-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-drizzle-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-telemetry-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-schema-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-cli-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-aigateway-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-task-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-webhook-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-analytics-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-api-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-email-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-pi-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-vector-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-client-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-claude-code-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-opencode-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-skills-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-runtime-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-db-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-stream-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-schedule-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-coder-tui-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-vite-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-adapter-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-coder-3.1.7-53d1e0b.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/3.1.7-53d1e0b/agentuity-server-3.1.7-53d1e0b.tgz |
…work. On server drain, keep the old connection alive for pending requests and route new requests to a replacement active socket. Co-authored-by: Cursor <cursoragent@cursor.com>
Use .ts extension in websocket protocol import so Node can resolve dist/protocol.js, and gate WebSocket orgId on ck_* API keys. Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest Agentuity deployment details.
View deployment logs with the Agentuity CLI: |
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Nitpick comments (2)
packages/aigateway/src/websocket.ts (1)
297-306: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDebug logging ignores the injected
loggerand re-resolves env each call.
#logDebugusesconsole.logdirectly even thoughAIGatewayWebSocketOptions.loggeris accepted, and it re-invokesresolveDebugEnabled(this.#options)on every call (re-reading env) despite#debugEnabledalready being cached. Prefer the provided logger and drop the redundant re-resolution.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/aigateway/src/websocket.ts` around lines 297 - 306, The `#logDebug` helper in AIGatewayWebSocket is bypassing the injected logger and redundantly re-checking debug state on every call. Update `#logDebug` to use this.#logger from AIGatewayWebSocketOptions instead of console.log, and rely on the cached `#debugEnabled` flag without calling resolveDebugEnabled(this.#options) again. Keep the same message/detail behavior while routing output through the configured logger.packages/aigateway/src/protocol.ts (1)
30-48: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer
z.looseObject({...})here —.passthrough()is deprecated in Zod 4.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/aigateway/src/protocol.ts` around lines 30 - 48, The AIGatewayWSServerResponseSchema definition is using a deprecated object handling pattern. Replace the current z.object(...).passthrough() in protocol.ts with z.looseObject(...) while keeping the same fields and schema behavior, so the AIGatewayWSServerResponseSchema remains permissive without relying on deprecated Zod 4 API.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/aigateway/src/index.ts`:
- Around line 88-109: `createWebSocket` currently throws plain `Error` in its
API key and org ID guard clauses, which breaks the error contract used by
WebSocket failures. Update the guard logic in `AIGatewayClient.createWebSocket`
to throw `AIGatewayWebSocketError` (the same structured error used by
`resolveOrgId` in `websocket.ts`), with the appropriate `code:
'connection_error'` and consistent message/details, so callers can reliably
catch all WebSocket-related validation failures.
In `@packages/aigateway/src/websocket.ts`:
- Around line 422-432: The timeout callback in websocket.ts can throw before the
pending request is rejected because cancel(id) may fail inside `#sendJsonOnLane`
when the socket is not OPEN. Update the timeout handler around this.cancel(id)
in the websocket request flow so it safely guards or catches cancel failures,
then always call `#rejectPending` for the same id with the request_timeout error.
Keep the fix localized to the timeout setup in the request path and the
cancel/#sendJsonOnLane interaction.
- Around line 283-290: The options merge in the websocket constructor is letting
explicit undefined values from `...options` override the computed defaults, so
move the spread to the start of the `this.#options` assignment and apply the
defaulted fields afterward. Update the `WebSocket` setup that builds `#options`
so `autoReconnect`, `reconnectDelayMs`, `maxReconnectDelayMs`,
`maxReconnectAttempts`, and `defaultTimeoutMs` are resolved after spreading
`options`, preserving defaults when callers pass undefined.
- Line 1: The websocket module is importing StructuredError from the wrong
package, so update the import in websocket.ts to use `@agentuity/core` instead of
`@agentuity/adapter`. Keep the change limited to the import statement and verify
any references to StructuredError in the websocket logic still resolve correctly
after the source swap.
- Around line 444-463: The stream iterator in websocket.ts can miss a pending
streamError once the queue drains and the loop exits after a complete event.
Update the async generator logic around the queue processing and notify handling
so streamError is checked again before termination, or rethrown after the loop,
ensuring the error is surfaced even when reject() happens after the last queued
item. Use the existing queue, done, notify, and streamError flow in the iterator
to locate the fix.
- Around line 777-784: The retiring lane cleanup in `#clearRetiringLaneIfIdle`
only clears the lane after the WebSocket is already CLOSED, so an idle retiring
socket can remain open indefinitely. Update `#clearRetiringLaneIfIdle` to actively
close this.#retiringLane.ws with a normal close code once requestIds.size is 0,
and then clear `#retiringLane` when the socket is closed or after initiating the
close, keeping the existing guard for active requests intact.
In `@packages/aigateway/test/index.test.ts`:
- Around line 285-300: The test setup is leaking AGENTUITY_AIGATEWAY_URL because
`beforeEach` assigns it but `afterEach` only restores values from
`ORIGINAL_ENV`. Update the `beforeEach`/`afterEach` block in
`packages/aigateway/test/index.test.ts` so this env var is either not set at all
(since the tests pass `url` explicitly) or is captured in `ORIGINAL_ENV` and
restored alongside the other environment variables.
---
Nitpick comments:
In `@packages/aigateway/src/protocol.ts`:
- Around line 30-48: The AIGatewayWSServerResponseSchema definition is using a
deprecated object handling pattern. Replace the current
z.object(...).passthrough() in protocol.ts with z.looseObject(...) while keeping
the same fields and schema behavior, so the AIGatewayWSServerResponseSchema
remains permissive without relying on deprecated Zod 4 API.
In `@packages/aigateway/src/websocket.ts`:
- Around line 297-306: The `#logDebug` helper in AIGatewayWebSocket is bypassing
the injected logger and redundantly re-checking debug state on every call.
Update `#logDebug` to use this.#logger from AIGatewayWebSocketOptions instead of
console.log, and rely on the cached `#debugEnabled` flag without calling
resolveDebugEnabled(this.#options) again. Keep the same message/detail behavior
while routing output through the configured logger.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 81b1c3cc-aec8-488f-860b-b3220775cb07
📒 Files selected for processing (5)
packages/aigateway/src/index.tspackages/aigateway/src/protocol.tspackages/aigateway/src/websocket.tspackages/aigateway/test/index.test.tspackages/aigateway/test/websocket.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
- GitHub Check: Package Installation & Usage Test (node)
- GitHub Check: Framework Demo Tests
- GitHub Check: Build
- GitHub Check: Agentuity - docs-docs
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Run
bun run formatusing Biome with tabs (width 3), single quotes, semicolons, lineWidth 100, and trailingCommas es5
Files:
packages/aigateway/test/index.test.tspackages/aigateway/src/protocol.tspackages/aigateway/src/index.tspackages/aigateway/test/websocket.test.tspackages/aigateway/src/websocket.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use TypeScript in strict mode with ESNext target and bundler moduleResolution
UseStructuredErrorfrom@agentuity/corefor error handling
Files:
packages/aigateway/test/index.test.tspackages/aigateway/src/protocol.tspackages/aigateway/src/index.tspackages/aigateway/test/websocket.test.tspackages/aigateway/src/websocket.ts
**/packages/*/test/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/packages/*/test/**/*.{ts,tsx}: Place tests intest/folder parallel tosrc/directory, never insidesrc/or under__tests__/
Import from../src/in test files
Use@agentuity/test-utilsfor shared mocks in tests
Files:
packages/aigateway/test/index.test.tspackages/aigateway/test/websocket.test.ts
**/packages/*/src/index.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use named exports from package
index.tsfiles
Files:
packages/aigateway/src/index.ts
🧠 Learnings (2)
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.
Applied to files:
packages/aigateway/test/index.test.tspackages/aigateway/src/protocol.tspackages/aigateway/src/index.tspackages/aigateway/test/websocket.test.tspackages/aigateway/src/websocket.ts
📚 Learning: 2026-02-21T02:05:57.982Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 1010
File: packages/drizzle/test/proxy.test.ts:594-603
Timestamp: 2026-02-21T02:05:57.982Z
Learning: Do not rely on StructuredError from agentuity/core in test files or simple error handling paths. In tests and straightforward error handling, use plain Error objects to represent failures, reserving StructuredError for more complex error scenarios in application logic.
Applied to files:
packages/aigateway/test/index.test.tspackages/aigateway/test/websocket.test.ts
🔇 Additional comments (5)
packages/aigateway/src/protocol.ts (1)
94-98: LGTM!packages/aigateway/src/index.ts (1)
2-3: LGTM!Also applies to: 29-34, 62-86
packages/aigateway/test/index.test.ts (1)
302-331: LGTM!packages/aigateway/test/websocket.test.ts (2)
1-10: LGTM!Also applies to: 56-571
11-55: 📐 Maintainability & Code QualityNo shared WebSocket mock to reuse
packages/test-utilsonly exports fetch/logger/adapter/postgres mocks, and the other WebSocket tests use local doubles too, so this localMockWebSocketis not duplicating an existing shared helper.> Likely an incorrect or invalid review comment.
- Use AIGatewayWebSocketError in createWebSocket guard clauses - Guard cancel() in timeout handler to always reject pending - Fix options spread order to preserve defaults - Import StructuredError from @agentuity/core - Check streamError after async generator loop exits - Close idle retiring lane instead of waiting for CLOSED - Remove leaking AGENTUITY_AIGATEWAY_URL from test setup - Replace deprecated .passthrough() with z.looseObject() - Route #logDebug through configured logger
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/aigateway/src/websocket.ts`:
- Line 1: The websocket.ts import of StructuredError from `@agentuity/core` is
using a package that is not declared in packages/aigateway, so add
`@agentuity/core` to the packages/aigateway package.json dependencies. Update the
package manifest for the aigateway package so its declared workspace
dependencies match the import used by websocket.ts and the build/typecheck can
resolve StructuredError reliably.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9282bd6d-44e5-49ae-9694-a377ad687f2d
📒 Files selected for processing (4)
packages/aigateway/src/index.tspackages/aigateway/src/protocol.tspackages/aigateway/src/websocket.tspackages/aigateway/test/index.test.ts
💤 Files with no reviewable changes (1)
- packages/aigateway/test/index.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/aigateway/src/index.ts
- packages/aigateway/src/protocol.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: Agentuity - docs-docs
⚠️ CI failures not shown inline (17)
GitHub Actions: NPM Pack & Upload / Pack & Upload: Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run bun scripts/canary.ts
�[36;1mbun scripts/canary.ts�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
AWS_ACCESS_KEY_ID: ***
AWS_SECRET_ACCESS_KEY: ***
AWS_ENDPOINT_URL_S3: https://t3.storage.dev
AWS_ENDPOINT_URL_IAM: https://iam.storage.dev
AWS_REGION: auto
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 1194
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1152
GITHUB_REPO_NAME: agentuity/sdk
##[endgroup]
🚀 NPM Pack & Upload Workflow
Mode: LIVE UPLOAD
Revert: NO (keeping changes)
Build: YES
CI: YES
📌 Version Info:
Base version: 3.1.7
Short SHA: 53168af
Prerelease version: 3.1.7-53168af
🔍 Discovering packages...
⊘ Skipping private package: vscode
⊘ Skipping private package: test-utils
Found 36 publishable packages
📦 Updating package versions to 3.1.7-53168af...
✓ Updated root package.json
✓ Updated `@agentuity/hono`
✓ Updated `@agentuity/coder`
✓ Updated `@agentuity/drizzle`
✓ Updated `@agentuity/analytics`
✓ Updated `@agentuity/db`
✓ Updated `@agentuity/queue`
✓ Updated `@agentuity/client`
✓ Updated `@agentuity/core`
✓ Updated create-agentuity
✓ Updated `@agentuity/pi`
✓ Updated `@agentuity/genesis`
✓ Updated `@agentuity/migrate`
✓ Updated `@agentuity/sandbox`
✓ Updated `@agentuity/adapter`
✓ Updated `@agentuity/claude-code`
✓ Updated `@agentuity/email`
✓ Updated `@agentuity/aigateway`
✓ Updated `@agentuity/webhook`
✓ Updated `@agentuity/stream`
✓ Updated `@agentuity/telemetry`
✓ Updated `@agentuity/server`
✓ Updated `@agentuity/opencode`
✓ Updated `@agentuity/runtime`
✓ Updated `@agentuity/schema`
✓ Updated `@agentuity/task`
✓ Updated `@agentuity/storage`
✓ Updated `@agentuity/vite`
✓ Updated `@agentuity/postgres`
✓ Updated `@agentuity/cli`
✓ Updated `@agentuity/api`
✓ Updated `@agentuity/coder-tui`
✓ Updated `@agentuity/vector`
✓ Updated `@agentuity/skills`
✓ Updated `@agentuity/schedule`
✓ Updated `@agentuity/keyvalue`
✓ Updated @...
GitHub Actions: NPM Pack & Upload / 0_Pack & Upload.txt: Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run bun scripts/canary.ts
�[36;1mbun scripts/canary.ts�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
AWS_ACCESS_KEY_ID: ***
AWS_SECRET_ACCESS_KEY: ***
AWS_ENDPOINT_URL_S3: https://t3.storage.dev
AWS_ENDPOINT_URL_IAM: https://iam.storage.dev
AWS_REGION: auto
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 1194
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1152
GITHUB_REPO_NAME: agentuity/sdk
##[endgroup]
🚀 NPM Pack & Upload Workflow
Mode: LIVE UPLOAD
Revert: NO (keeping changes)
Build: YES
CI: YES
📌 Version Info:
Base version: 3.1.7
Short SHA: 53168af
Prerelease version: 3.1.7-53168af
🔍 Discovering packages...
⊘ Skipping private package: vscode
⊘ Skipping private package: test-utils
Found 36 publishable packages
📦 Updating package versions to 3.1.7-53168af...
✓ Updated root package.json
✓ Updated `@agentuity/hono`
✓ Updated `@agentuity/coder`
✓ Updated `@agentuity/drizzle`
✓ Updated `@agentuity/analytics`
✓ Updated `@agentuity/db`
✓ Updated `@agentuity/queue`
✓ Updated `@agentuity/client`
✓ Updated `@agentuity/core`
✓ Updated create-agentuity
✓ Updated `@agentuity/pi`
✓ Updated `@agentuity/genesis`
✓ Updated `@agentuity/migrate`
✓ Updated `@agentuity/sandbox`
✓ Updated `@agentuity/adapter`
✓ Updated `@agentuity/claude-code`
✓ Updated `@agentuity/email`
✓ Updated `@agentuity/aigateway`
✓ Updated `@agentuity/webhook`
✓ Updated `@agentuity/stream`
✓ Updated `@agentuity/telemetry`
✓ Updated `@agentuity/server`
✓ Updated `@agentuity/opencode`
✓ Updated `@agentuity/runtime`
✓ Updated `@agentuity/schema`
✓ Updated `@agentuity/task`
✓ Updated `@agentuity/storage`
✓ Updated `@agentuity/vite`
✓ Updated `@agentuity/postgres`
✓ Updated `@agentuity/cli`
✓ Updated `@agentuity/api`
✓ Updated `@agentuity/coder-tui`
✓ Updated `@agentuity/vector`
✓ Updated `@agentuity/skills`
✓ Updated `@agentuity/schedule`
✓ Updated `@agentuity/keyvalue`
✓ Updated @...
GitHub Actions: Build Packages & Test / Build: Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run set -eou pipefail
�[36;1mset -eou pipefail�[0m
�[36;1mbun run build�[0m
�[36;1m# Smoke-test the BUILT CLI under both runtimes. The CLI is�[0m
�[36;1m# runtime-agnostic; CI proves both invocations produce the�[0m
�[36;1m# same result.�[0m
�[36;1mbun run whoami�[0m
�[36;1mbun run whoami:bun�[0m
�[36;1mnode packages/cli/bin/cli.js profile show --json�[0m
�[36;1mbun packages/cli/bin/cli.js profile show --json�[0m
�[36;1m# Run all checks. Integration apps under tests/integration/�[0m
�[36;1m# are exercised by package-smoke-test.yaml in their own job.�[0m
�[36;1mbun format�[0m
�[36;1mbun lint�[0m
�[36;1mbun typecheck�[0m
�[36;1mbun run test:unit�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
AGENTUITY_API_URL: https://api.agentuity.com
AGENTUITY_APP_URL: https://app.agentuity.com
AGENTUITY_TRANSPORT_URL: https://catalyst-usc.agentuity.cloud
AGENTUITY_CATALYST_URL: https://catalyst-usc.agentuity.cloud
AGENTUITY_STREAM_URL: https://streams-usc.agentuity.cloud
AGENTUITY_KEYVALUE_URL: https://catalyst-usc.agentuity.cloud
AGENTUITY_OBJECTSTORE_URL: https://catalyst-usc.agentuity.cloud
AGENTUITY_VECTOR_URL: https://catalyst-usc.agentuity.cloud
AGENTUITY_LOG_LEVEL: info
AGENTUITY_REGION: usc
AGENTUITY_USER_ID: user_2sjCBqYDWaCNMiLDBPDhhHSIM32
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 1531
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1236
GITHUB_REPO_NAME: agentuity/sdk
AGENTUITY_CLI_***REDACTED***
##[endgroup]
$ bunx tsc --build && bun run build:assets
##[error]packages/aigateway/src/websocket.ts(1,33): error TS2307: Cannot find module '`@agentuity/core`' or its corresponding type declarations.
GitHub Actions: Build Packages & Test / 0_Build.txt: Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run set -eou pipefail
�[36;1mset -eou pipefail�[0m
�[36;1mbun run build�[0m
�[36;1m# Smoke-test the BUILT CLI under both runtimes. The CLI is�[0m
�[36;1m# runtime-agnostic; CI proves both invocations produce the�[0m
�[36;1m# same result.�[0m
�[36;1mbun run whoami�[0m
�[36;1mbun run whoami:bun�[0m
�[36;1mnode packages/cli/bin/cli.js profile show --json�[0m
�[36;1mbun packages/cli/bin/cli.js profile show --json�[0m
�[36;1m# Run all checks. Integration apps under tests/integration/�[0m
�[36;1m# are exercised by package-smoke-test.yaml in their own job.�[0m
�[36;1mbun format�[0m
�[36;1mbun lint�[0m
�[36;1mbun typecheck�[0m
�[36;1mbun run test:unit�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
AGENTUITY_API_URL: https://api.agentuity.com
AGENTUITY_APP_URL: https://app.agentuity.com
AGENTUITY_TRANSPORT_URL: https://catalyst-usc.agentuity.cloud
AGENTUITY_CATALYST_URL: https://catalyst-usc.agentuity.cloud
AGENTUITY_STREAM_URL: https://streams-usc.agentuity.cloud
AGENTUITY_KEYVALUE_URL: https://catalyst-usc.agentuity.cloud
AGENTUITY_OBJECTSTORE_URL: https://catalyst-usc.agentuity.cloud
AGENTUITY_VECTOR_URL: https://catalyst-usc.agentuity.cloud
AGENTUITY_LOG_LEVEL: info
AGENTUITY_REGION: usc
AGENTUITY_USER_ID: user_2sjCBqYDWaCNMiLDBPDhhHSIM32
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 1531
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1236
GITHUB_REPO_NAME: agentuity/sdk
AGENTUITY_CLI_***REDACTED***
##[endgroup]
$ bunx tsc --build && bun run build:assets
##[error]packages/aigateway/src/websocket.ts(1,33): error TS2307: Cannot find module '`@agentuity/core`' or its corresponding type declarations.
GitHub Actions: Package Smoke Test / Service Client Smoke Tests: Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run bun run build
�[36;1mbun run build�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
AGENTUITY_API_URL: https://api.agentuity.com
AGENTUITY_REGION: usc
AGENTUITY_ORG_ID: ***
AGENTUITY_DB_DATABASE: testdb
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 1166
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1350
GITHUB_REPO_NAME: agentuity/sdk
##[endgroup]
$ bunx tsc --build && bun run build:assets
##[error]packages/aigateway/src/websocket.ts(1,33): error TS2307: Cannot find module '`@agentuity/core`' or its corresponding type declarations.
GitHub Actions: Package Smoke Test / Package Installation & Usage Test (node): Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run bash scripts/test-package-install.sh
�[36;1mbash scripts/test-package-install.sh�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 1375
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1270
GITHUB_REPO_NAME: agentuity/sdk
CLI_RUNTIME: node
##[endgroup]
�[0;34mℹ SDK root: /home/runner/_work/sdk/sdk�[0m
�[0;34mℹ Packages dir: /tmp/test-packages-1783305142�[0m
�[0;34mℹ Test project dir: /tmp/test-project-1783305142�[0m
�[0;34mℹ Step 1 & 2: Building and packing SDK packages...�[0m
╔════════════════════════════════════════════════╗
║ Preparing SDK for Testing ║
╚════════════════════════════════════════════════╝
Step 1/2: Building SDK packages...
🔨 Building SDK Packages
=======================
Discovering packages...
Found 35 packages with build scripts:
• adapter
$ bunx tsc --build && bun run build:assets
• aigateway
• analytics
• api
• claude-code
• cli
• client
• coder
• coder-tui
• config
• core
• create-agentuity
• db
• drizzle
• email
• genesis
• hono
• keyvalue
• migrate
• opencode
• pi
• postgres
• queue
• runtime
• sandbox
• schedule
• schema
• server
• storage
• stream
• task
• telemetry
• vector
• vite
• webhook
Skipped 3 source-only packages:
• skills (source-only)
• test-utils (source-only)
• vscode (vscode extension)
Building packages...
##[error]packages/aigateway/src/websocket.ts(1,33): error TS2307: Cannot find module '`@agentuity/core`' or its corresponding type declarations.
GitHub Actions: Package Smoke Test / Migrate Chain (v1 → v2 → v3): Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run bash scripts/prepare-sdk-for-testing.sh
�[36;1mbash scripts/prepare-sdk-for-testing.sh�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 1068
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1251
GITHUB_REPO_NAME: agentuity/sdk
##[endgroup]
╔════════════════════════════════════════════════╗
║ Preparing SDK for Testing ║
╚════════════════════════════════════════════════╝
Step 1/2: Building SDK packages...
🔨 Building SDK Packages
=======================
Discovering packages...
Found 35 packages with build scripts:
• adapter
• aigateway
• analytics
• api
• claude-code
• cli
• client
• coder
• coder-tui
• config
• core
• create-agentuity
• db
• drizzle
• email
• genesis
• hono
• keyvalue
• migrate
• opencode
$ bunx tsc --build && bun run build:assets
• pi
• postgres
• queue
• runtime
• sandbox
• schedule
• schema
• server
• storage
• stream
• task
• telemetry
• vector
• vite
• webhook
Skipped 3 source-only packages:
• skills (source-only)
• test-utils (source-only)
• vscode (vscode extension)
Building packages...
##[error]packages/aigateway/src/websocket.ts(1,33): error TS2307: Cannot find module '`@agentuity/core`' or its corresponding type declarations.
GitHub Actions: Package Smoke Test / Postgres SSL Integration Test: Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run bun run build
�[36;1mbun run build�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 1469
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1231
GITHUB_REPO_NAME: agentuity/sdk
##[endgroup]
$ bunx tsc --build && bun run build:assets
##[error]packages/aigateway/src/websocket.ts(1,33): error TS2307: Cannot find module '`@agentuity/core`' or its corresponding type declarations.
GitHub Actions: Package Smoke Test / Framework Demo Tests: Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run bun run build
�[36;1mbun run build�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
AGENTUITY_API_URL: https://api.agentuity.com
AGENTUITY_USER_ID: user_2sjCBqYDWaCNMiLDBPDhhHSIM32
AGENTUITY_CLOUD_ORG_ID: org_38uEd1JNXIe89KMPaOwx1WJW43o
AGENTUITY_REGION: usc
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 1024
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1241
GITHUB_REPO_NAME: agentuity/sdk
##[endgroup]
$ bunx tsc --build && bun run build:assets
##[error]packages/aigateway/src/websocket.ts(1,33): error TS2307: Cannot find module '`@agentuity/core`' or its corresponding type declarations.
GitHub Actions: Package Smoke Test / 0_Service Client Smoke Tests.txt: Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run bun run build
�[36;1mbun run build�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
AGENTUITY_API_URL: https://api.agentuity.com
AGENTUITY_REGION: usc
AGENTUITY_ORG_ID: ***
AGENTUITY_DB_DATABASE: testdb
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 1166
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1350
GITHUB_REPO_NAME: agentuity/sdk
##[endgroup]
$ bunx tsc --build && bun run build:assets
##[error]packages/aigateway/src/websocket.ts(1,33): error TS2307: Cannot find module '`@agentuity/core`' or its corresponding type declarations.
GitHub Actions: Package Smoke Test / Package Installation & Usage Test (bun): Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run bash scripts/test-package-install.sh
�[36;1mbash scripts/test-package-install.sh�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 900
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1168
GITHUB_REPO_NAME: agentuity/sdk
CLI_RUNTIME: bun
##[endgroup]
�[0;34mℹ SDK root: /home/runner/_work/sdk/sdk�[0m
�[0;34mℹ Packages dir: /tmp/test-packages-1783305138�[0m
�[0;34mℹ Test project dir: /tmp/test-project-1783305138�[0m
�[0;34mℹ Step 1 & 2: Building and packing SDK packages...�[0m
╔════════════════════════════════════════════════╗
║ Preparing SDK for Testing ║
╚════════════════════════════════════════════════╝
Step 1/2: Building SDK packages...
🔨 Building SDK Packages
=======================
Discovering packages...
Found 35 packages with build scripts:
• adapter
• aigateway
• analytics
• api
• claude-code
• cli
• client
$ bunx tsc --build && bun run build:assets
• coder
• coder-tui
• config
• core
• create-agentuity
• db
• drizzle
• email
• genesis
• hono
• keyvalue
• migrate
• opencode
• pi
• postgres
• queue
• runtime
• sandbox
• schedule
• schema
• server
• storage
• stream
• task
• telemetry
• vector
• vite
• webhook
Skipped 3 source-only packages:
• skills (source-only)
• test-utils (source-only)
• vscode (vscode extension)
Building packages...
##[error]packages/aigateway/src/websocket.ts(1,33): error TS2307: Cannot find module '`@agentuity/core`' or its corresponding type declarations.
GitHub Actions: Package Smoke Test / 2_Testing Apps (local tests).txt: Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run bun run build
�[36;1mbun run build�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 1150
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1309
GITHUB_REPO_NAME: agentuity/sdk
##[endgroup]
$ bunx tsc --build && bun run build:assets
##[error]packages/aigateway/src/websocket.ts(1,33): error TS2307: Cannot find module '`@agentuity/core`' or its corresponding type declarations.
GitHub Actions: Package Smoke Test / 5_Postgres SSL Integration Test.txt: Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run bun run build
�[36;1mbun run build�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 1469
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1231
GITHUB_REPO_NAME: agentuity/sdk
##[endgroup]
$ bunx tsc --build && bun run build:assets
##[error]packages/aigateway/src/websocket.ts(1,33): error TS2307: Cannot find module '`@agentuity/core`' or its corresponding type declarations.
GitHub Actions: Package Smoke Test / 6_Queue CLI Tests (node).txt: Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run bun run build
�[36;1mbun run build�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
AGENTUITY_API_URL: https://api.agentuity.com
AGENTUITY_USER_ID: user_2sjCBqYDWaCNMiLDBPDhhHSIM32
AGENTUITY_CLOUD_ORG_ID: org_38uEd1JNXIe89KMPaOwx1WJW43o
AGENTUITY_REGION: usc
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 1222
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1226
GITHUB_REPO_NAME: agentuity/sdk
##[endgroup]
$ bunx tsc --build && bun run build:assets
##[error]packages/aigateway/src/websocket.ts(1,33): error TS2307: Cannot find module '`@agentuity/core`' or its corresponding type declarations.
GitHub Actions: Package Smoke Test / 8_Queue CLI Tests (bun).txt: Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run bun run build
�[36;1mbun run build�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
AGENTUITY_API_URL: https://api.agentuity.com
AGENTUITY_USER_ID: user_2sjCBqYDWaCNMiLDBPDhhHSIM32
AGENTUITY_CLOUD_ORG_ID: org_38uEd1JNXIe89KMPaOwx1WJW43o
AGENTUITY_REGION: usc
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 1005
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1247
GITHUB_REPO_NAME: agentuity/sdk
##[endgroup]
$ bunx tsc --build && bun run build:assets
##[error]packages/aigateway/src/websocket.ts(1,33): error TS2307: Cannot find module '`@agentuity/core`' or its corresponding type declarations.
GitHub Actions: Package Smoke Test / 4_Migrate Chain (v1 → v2 → v3).txt: Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run bash scripts/prepare-sdk-for-testing.sh
�[36;1mbash scripts/prepare-sdk-for-testing.sh�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 1068
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1251
GITHUB_REPO_NAME: agentuity/sdk
##[endgroup]
╔════════════════════════════════════════════════╗
║ Preparing SDK for Testing ║
╚════════════════════════════════════════════════╝
Step 1/2: Building SDK packages...
🔨 Building SDK Packages
=======================
Discovering packages...
Found 35 packages with build scripts:
• adapter
• aigateway
• analytics
• api
• claude-code
• cli
• client
• coder
• coder-tui
• config
• core
• create-agentuity
• db
• drizzle
• email
• genesis
• hono
• keyvalue
• migrate
• opencode
$ bunx tsc --build && bun run build:assets
• pi
• postgres
• queue
• runtime
• sandbox
• schedule
• schema
• server
• storage
• stream
• task
• telemetry
• vector
• vite
• webhook
Skipped 3 source-only packages:
• skills (source-only)
• test-utils (source-only)
• vscode (vscode extension)
Building packages...
##[error]packages/aigateway/src/websocket.ts(1,33): error TS2307: Cannot find module '`@agentuity/core`' or its corresponding type declarations.
GitHub Actions: Package Smoke Test / 9_Package Installation & Usage Test (bun).txt: Add AI Gateway WebSocket client with reconnect and draining support
Conclusion: failure
##[group]Run bash scripts/test-package-install.sh
�[36;1mbash scripts/test-package-install.sh�[0m
shell: /usr/bin/bash -e {0}
env:
CI: true
GITHUB_***REDACTED*** true
BLACKSMITH_RUNNER_MESSAGE_WAIT_MS: 900
BLACKSMITH_RUNNER_ACQUIRE_JOB_MS: 1168
GITHUB_REPO_NAME: agentuity/sdk
CLI_RUNTIME: bun
##[endgroup]
�[0;34mℹ SDK root: /home/runner/_work/sdk/sdk�[0m
�[0;34mℹ Packages dir: /tmp/test-packages-1783305138�[0m
�[0;34mℹ Test project dir: /tmp/test-project-1783305138�[0m
�[0;34mℹ Step 1 & 2: Building and packing SDK packages...�[0m
╔════════════════════════════════════════════════╗
║ Preparing SDK for Testing ║
╚════════════════════════════════════════════════╝
Step 1/2: Building SDK packages...
🔨 Building SDK Packages
=======================
Discovering packages...
Found 35 packages with build scripts:
• adapter
• aigateway
• analytics
• api
• claude-code
• cli
• client
$ bunx tsc --build && bun run build:assets
• coder
• coder-tui
• config
• core
• create-agentuity
• db
• drizzle
• email
• genesis
• hono
• keyvalue
• migrate
• opencode
• pi
• postgres
• queue
• runtime
• sandbox
• schedule
• schema
• server
• storage
• stream
• task
• telemetry
• vector
• vite
• webhook
Skipped 3 source-only packages:
• skills (source-only)
• test-utils (source-only)
• vscode (vscode extension)
Building packages...
##[error]packages/aigateway/src/websocket.ts(1,33): error TS2307: Cannot find module '`@agentuity/core`' or its corresponding type declarations.
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Run
bun run formatusing Biome with tabs (width 3), single quotes, semicolons, lineWidth 100, and trailingCommas es5
Files:
packages/aigateway/src/websocket.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use TypeScript in strict mode with ESNext target and bundler moduleResolution
UseStructuredErrorfrom@agentuity/corefor error handling
Files:
packages/aigateway/src/websocket.ts
🧠 Learnings (1)
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.
Applied to files:
packages/aigateway/src/websocket.ts
🪛 GitHub Actions: Build Packages & Test / 0_Build.txt
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript (tsc --build) failed with TS2307: Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Build Packages & Test / Build
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript build failed. Error TS2307: Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: NPM Pack & Upload / 0_Pack & Upload.txt
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript build failed (TS2307): Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: NPM Pack & Upload / Pack & Upload
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript build failed (TS2307): Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / 0_Service Client Smoke Tests.txt
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript (tsc) failed: TS2307 Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / 1_Package Installation & Usage Test (node).txt
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript build failed (TS2307): Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / 2_Testing Apps (local tests).txt
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript (tsc) failed with TS2307: Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / 4_Migrate Chain (v1 → v2 → v3).txt
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript build failed (TS2307): Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / 5_Postgres SSL Integration Test.txt
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript (tsc --build) failed: TS2307 Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / 6_Queue CLI Tests (node).txt
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript (tsc) build failed. TS2307: Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / 7_Framework Demo Tests.txt
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript (tsc) failed with TS2307: Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / 8_Queue CLI Tests (bun).txt
packages/aigateway/src/websocket.ts
[error] 1-1: tsc failed (TS2307): Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / 9_Package Installation & Usage Test (bun).txt
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript (tsc) failed with TS2307: Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / Framework Demo Tests
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript (tsc) failed with TS2307: Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / Migrate Chain (v1 → v2 → v3)
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript build failed (tsc --build). TS2307: Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / Package Installation & Usage Test (bun)
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript compilation failed (TS2307): Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / Package Installation & Usage Test (node)
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript build failed (TS2307): Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / Postgres SSL Integration Test
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript build failed (bunx tsc --build). TS2307: Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / Queue CLI Tests (bun)
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript (tsc) failed: TS2307 Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / Queue CLI Tests (node)
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript (tsc) failed with TS2307: Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / Service Client Smoke Tests
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript (tsc --build) failed: TS2307 Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Actions: Package Smoke Test / Testing Apps (local tests)
packages/aigateway/src/websocket.ts
[error] 1-1: TypeScript (tsc) failed with TS2307: Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Check: Build
packages/aigateway/src/websocket.ts
[failure] 1-1:
Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Check: Framework Demo Tests
packages/aigateway/src/websocket.ts
[failure] 1-1:
Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Check: Migrate Chain (v1 → v2 → v3)
packages/aigateway/src/websocket.ts
[failure] 1-1:
Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Check: Package Installation & Usage Test (bun)
packages/aigateway/src/websocket.ts
[failure] 1-1:
Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Check: Package Installation & Usage Test (node)
packages/aigateway/src/websocket.ts
[failure] 1-1:
Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Check: Postgres SSL Integration Test
packages/aigateway/src/websocket.ts
[failure] 1-1:
Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Check: Queue CLI Tests (bun)
packages/aigateway/src/websocket.ts
[failure] 1-1:
Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Check: Queue CLI Tests (node)
packages/aigateway/src/websocket.ts
[failure] 1-1:
Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Check: Service Client Smoke Tests
packages/aigateway/src/websocket.ts
[failure] 1-1:
Cannot find module '@agentuity/core' or its corresponding type declarations.
🪛 GitHub Check: Testing Apps (local tests)
packages/aigateway/src/websocket.ts
[failure] 1-1:
Cannot find module '@agentuity/core' or its corresponding type declarations.
🔇 Additional comments (5)
packages/aigateway/src/websocket.ts (5)
283-290: LGTM!
428-442: LGTM!
454-476: LGTM!
790-799: LGTM!
563-567: 🩺 Stability & Availability1001 does not suppress reconnect.
isTerminalCloseCode()explicitly excludes1001, so#intentionallyClosedstays false and#scheduleReconnect()still runs whenautoReconnectis enabled.> Likely an incorrect or invalid review comment.
Summary
@agentuity/aigatewayWebSocket client for the v1/v1/wsprotocol with compact request/response frames, streaming deltas, and cancel support.draininghandling (block new requests, finish in-flight, reconnect on 1001), and multiplexed concurrent requests keyed byid.AIGatewayClient.createWebSocket()so HTTP and WebSocket clients share apiKey, orgId, and base URL configuration.Test plan
bun test packages/aigateway/test/websocket.test.tsbun test packages/aigatewaybun run typecheckinpackages/aigatewaybun run buildinpackages/aigatewayMade with Cursor
Summary by CodeRabbit
stream) and one-shot (complete) request support, including request cancellation.AIGatewayClient.createWebSocket()to create and configure the WebSocket client with validated API key/org requirements.