♻️ refactor: add WebSocket gateway support to CLI agent run#13608
♻️ refactor: add WebSocket gateway support to CLI agent run#13608
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@nekomeowww - This PR adds WebSocket gateway support to the CLI agent run command and introduces a new GatewayStreamNotifier backend module. Please review the server-side AgentRuntime changes and CLI integration. |
There was a problem hiding this comment.
💡 Codex Review
lobehub/apps/cli/src/settings/index.ts
Lines 63 to 66 in 4d50229
resolveAgentGatewayUrl() now depends on loadSettings()?.agentGatewayUrl, but loadSettings() reconstructs normalized without that field, so persisted agentGatewayUrl is silently discarded. Combined with saveSettings() also omitting it, custom gateway configuration cannot survive across CLI runs.
ℹ️ 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".
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## canary #13608 +/- ##
==========================================
- Coverage 66.68% 66.68% -0.01%
==========================================
Files 1997 1997
Lines 165873 165873
Branches 16854 16090 -764
==========================================
- Hits 110612 110610 -2
- Misses 55137 55139 +2
Partials 124 124
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
CLI `agent run` now connects to Agent Gateway via WebSocket by default, falling back to SSE when `--sse` is passed. After auth, sends `resume` to fetch buffered events (covers race between exec and WS connect). - Add `streamAgentEventsViaWebSocket` in agentStream.ts - Add `resolveAgentGatewayUrl` in settings - Add `OFFICIAL_AGENT_GATEWAY_URL` constant - Support `AGENT_GATEWAY_SERVICE_TOKEN` env for gateway auth - Add `--sse` flag for forced SSE fallback Fixes LOBE-6800 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Cover auth flow, resume, event rendering, JSON mode, auth failure, heartbeat_ack, URL construction, and a multi-step tool-call scenario. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e62523d to
b155305
Compare
saveSettings and loadSettings now handle agentGatewayUrl so custom gateway configuration survives across CLI runs. Default URL is stripped like serverUrl to keep the settings file minimal. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…n WS stream 1. Remove AGENT_GATEWAY_SERVICE_TOKEN env var — gateway auth should only use Oidc-Auth / X-API-Key from the existing auth flow. 2. Fix --json mode printing duplicate JSON arrays: agent_runtime_end, session_complete, and onclose all called console.log independently. Add jsonPrinted guard so only the first path outputs JSON. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
# 🚀 release: 20260407 This release includes **148 commits**. Key updates are below. - **Response API tool execution is more capable and reliable** — Added hosted builtin tools + client-side function tools and improved tool-call streaming/completion behavior. [#13406](#13406) [#13414](#13414) [#13506](#13506) [#13555](#13555) - **Input and composition UX upgraded** — Added AI input auto-completion and multiple chat-input stability fixes. [#13458](#13458) [#13551](#13551) [#13481](#13481) - **Model/provider compatibility improved** — Better Gemini/Google tool schema handling and additional model updates. [#13429](#13429) [#13465](#13465) [#13613](#13613) - **Desktop and CLI reliability improved** — Gateway WebSocket support and desktop runtime upgrades. [#13608](#13608) [#13550](#13550) [#13557](#13557) - **Security hardening continued** — Fixed auth and sanitization risks and upgraded vulnerable dependencies. [#13535](#13535) [#13529](#13529) [#13479](#13479) ### Models & Providers - Added/updated support for `glm-5v-turbo`, GLM-5.1 updates, and qwen3.5-omni series. [#13487](#13487) [#13405](#13405) [#13422](#13422) - Added additional ImageGen providers/models (Wanxiang 2.7 and Keling from Qwen). [#13478](#13478) - Improved Gemini/Google tool schema and compatibility handling across runtime paths. [#13429](#13429) [#13465](#13465) [#13613](#13613) ### Response API & Runtime - Added hosted builtin tools in Response API and client-side function tool execution support. [#13406](#13406) [#13414](#13414) - Improved stream tool-call argument handling and `response.completed` output correctness. [#13506](#13506) [#13555](#13555) - Improved runtime error/context handling for intervention and provider edge cases. [#13420](#13420) [#13607](#13607) ### Desktop App - Bumped desktop dependencies and runtime integrations (`agent-browser`, `electron`). [#13550](#13550) [#13557](#13557) - Simplified desktop release channel setup by removing nightly release flow. [#13480](#13480) ### CLI - Added OpenClaw migration command. [#13566](#13566) - Added local device binding support for `lh agent run`. [#13277](#13277) - Added WebSocket gateway support and reconnect reliability improvements. [#13608](#13608) [#13418](#13418) ### Security - Removed risky `apiKey` fallback behavior in webapi auth path to prevent bypass risk. [#13535](#13535) - Sanitized HTML artifact rendering and iframe sandboxing to reduce XSS-to-RCE risk. [#13529](#13529) - Upgraded nodemailer to v8 to address SMTP command injection advisory. [#13479](#13479) ### Bug Fixes - Fixed image generation model default switch issues. [#13587](#13587) - Fixed subtopic re-fork message scope behavior and agent panel reset edge cases. [#13606](#13606) [#13556](#13556) - Fixed chat-input freeze on paste and mention plugin behavior. [#13551](#13551) [#13415](#13415) - Fixed auth/social sign-in and settings UX edge cases. [#13368](#13368) [#13392](#13392) [#13338](#13338) ### Credits Huge thanks to these contributors: @chriszf @hardy-one @Innei @lijian @neko @OctopusNote @rdmclin2 @rivertwilight @RylanCai @suyua9 @sxjeru @Tsuki @wangyk @WindSpiritSR @yizhuo @YuTengjing @hezhijie0327 @arvinxx
Summary
lh agent runnow connects to Agent Gateway via WebSocket by default for real-time event streaming--sseflagresumeto fetch buffered events (handles race between agent exec and WS connect)AGENT_GATEWAY_SERVICE_TOKENenv var for gateway authenticationChanges
apps/cli/src/utils/agentStream.ts— newstreamAgentEventsViaWebSocket()with heartbeat, resume, and full event renderingapps/cli/src/commands/agent.ts— WebSocket-first with--ssefallbackapps/cli/src/settings/index.ts—resolveAgentGatewayUrl()from settings/envapps/cli/src/constants/urls.ts—OFFICIAL_AGENT_GATEWAY_URLTest plan
lh agent runvia WebSocket gateway — events stream correctlylh agent run --sse— falls back to SSE stream--jsonmode works with WebSocketresumeafter authDepends on #13603
Fixes LOBE-6800
🤖 Generated with Claude Code