Unify TUI runtime commands with gateway and harden gateway restart
This commit is contained in:
@@ -38,6 +38,7 @@ The gateway serialises agent work **per session**, not per WebSocket connection:
|
||||
- Session-local overrides can be managed at runtime via `agent.send` commands: `/queue`, `/queue set ...`, `/queue reset`.
|
||||
- Backend selection for a turn is server-side (`native` by default, optional external backends per config: `claude_code`, `opencode`, `codex`, `gemini`, `pi_embedded`) and does not change JSON-RPC method signatures.
|
||||
- Runtime backend mode overrides are available via `agent.send` command fast-path: `/runtime status`, `/runtime activate pi`, `/runtime deactivate pi`, `/runtime use config` (`/backend ...` remains a compatibility alias).
|
||||
- The gateway `agent.send` command path and channel-router path use the same runtime backend-mode command service; `flynn tui` forwards `/runtime ...` through this gateway path for parity.
|
||||
- Backend routing and fallback outcomes are emitted to audit logs (`backend.route`, `backend.success`, `backend.fallback`) for rollout evaluation; this telemetry is outside JSON-RPC response payloads.
|
||||
|
||||
This is implemented via a per-lane queue (`LaneQueue`) in the gateway server, and used by `agent.send` and `agent.cancel`.
|
||||
|
||||
@@ -100,6 +100,7 @@ ChannelAdapter -> ChannelRegistry
|
||||
| |
|
||||
| +----> Runtime backend mode overrides
|
||||
| (/runtime status|activate pi|deactivate pi|use config)
|
||||
| (TUI `/runtime` is forwarded via gateway/daemon command path)
|
||||
| |
|
||||
| v
|
||||
| SessionManager
|
||||
|
||||
@@ -12,6 +12,7 @@ If you only want the protocol surface, see `docs/api/PROTOCOL.md`.
|
||||
- Sessions persist in SQLite via `SessionManager` even if clients disconnect.
|
||||
- Once dequeued, message routing may execute the native orchestrator path or an optional external backend path (`claude_code`, `opencode`, `codex`, `gemini`, `pi_embedded`) depending on agent/backend config.
|
||||
- Runtime backend mode can be overridden manually via `/runtime` command fast-path (`status`, `activate pi`, `deactivate pi`, `use config`) and is persisted in preferences (`/backend` remains a compatibility alias).
|
||||
- `flynn tui` now attaches to this same gateway command path for `/runtime ...` and auto-starts/attaches daemon+gateway when needed.
|
||||
- Backend routing outcomes are auditable via `backend.route` / `backend.success` / `backend.fallback`, which enables offline canary evaluation without changing gateway protocol methods.
|
||||
|
||||
## Component Map
|
||||
@@ -24,6 +25,7 @@ flowchart LR
|
||||
end
|
||||
|
||||
subgraph GW[Gateway Process]
|
||||
TUI[TUI client\n(runtime command forwarding)]
|
||||
WS[WebSocket connection\n(connectionId)]
|
||||
GS[GatewayServer]
|
||||
LQ[LaneQueue\nper-session FIFO]
|
||||
@@ -37,6 +39,7 @@ flowchart LR
|
||||
AO[AgentOrchestrator / External Backends]
|
||||
end
|
||||
|
||||
TUI --> WS
|
||||
WS --> GS
|
||||
QP --> GS
|
||||
BM --> GS
|
||||
|
||||
+52
-2
@@ -53,6 +53,54 @@
|
||||
],
|
||||
"test_status": "pnpm test:run src/daemon/routing.test.ts + pnpm typecheck passing"
|
||||
},
|
||||
"openclaw-gateway-first-tui-runtime-unification": {
|
||||
"status": "completed",
|
||||
"date": "2026-02-24",
|
||||
"updated": "2026-02-24",
|
||||
"summary": "Unified runtime backend mode control across channel router, gateway, and TUI by extracting a shared backend-mode command service, wiring gateway `agent.send` to that shared service, and forwarding minimal/fullscreen TUI `/runtime` through a gateway bridge. `flynn tui` now auto-attaches to gateway and auto-starts local daemon+gateway when unavailable while preserving TUI-local `/backend [provider]` switching.",
|
||||
"files_modified": [
|
||||
"src/commands/runtimeBackendMode.ts",
|
||||
"src/commands/index.ts",
|
||||
"src/daemon/routing.ts",
|
||||
"src/daemon/index.ts",
|
||||
"src/daemon/services.ts",
|
||||
"src/gateway/server.ts",
|
||||
"src/gateway/handlers/agent.ts",
|
||||
"src/gateway/handlers/agent.test.ts",
|
||||
"src/cli/tuiRuntimeGateway.ts",
|
||||
"src/cli/tuiRuntimeGateway.test.ts",
|
||||
"src/cli/tui.ts",
|
||||
"src/frontends/tui/fullscreen.ts",
|
||||
"src/frontends/tui/components/App.tsx",
|
||||
"src/frontends/tui/minimal.ts",
|
||||
"src/frontends/tui/minimal.test.ts",
|
||||
"src/frontends/tui/commands.ts",
|
||||
"README.md",
|
||||
"docs/architecture/AGENT_DIAGRAM.md",
|
||||
"docs/architecture/GATEWAY_SESSIONS_AND_QUEUE.md",
|
||||
"docs/api/PROTOCOL.md",
|
||||
"docs/plans/state.json"
|
||||
],
|
||||
"test_status": "pnpm test:run src/cli/tuiRuntimeGateway.test.ts src/frontends/tui/commands.test.ts src/frontends/tui/minimal.test.ts src/gateway/handlers/agent.test.ts src/daemon/routing.test.ts src/commands/builtin/index.test.ts + pnpm typecheck passing"
|
||||
},
|
||||
"gateway-startup-eaddrinuse-hardening": {
|
||||
"status": "completed",
|
||||
"date": "2026-02-24",
|
||||
"updated": "2026-02-24",
|
||||
"summary": "Hardened gateway startup bind-failure handling so port collisions (`EADDRINUSE`) are rejected deterministically instead of surfacing as an unhandled WebSocketServer error event. Added clearer daemon startup error text, reordered startup to bind gateway before channel adapters (avoiding noisy channel teardown on bind failures), added bounded bind-retry logic for short restart races, made TUI auto-start treat `EADDRINUSE` as an attach race (retry connect) rather than immediate failure, and updated `make daemon-start`/`make daemon-restart` to rebuild before service start/restart so runtime fixes are always reflected in `dist`.",
|
||||
"files_modified": [
|
||||
"Makefile",
|
||||
"README.md",
|
||||
"src/gateway/server.ts",
|
||||
"src/gateway/server.test.ts",
|
||||
"src/daemon/services.ts",
|
||||
"src/daemon/startServices.test.ts",
|
||||
"src/cli/tuiRuntimeGateway.ts",
|
||||
"src/cli/tuiRuntimeGateway.test.ts",
|
||||
"docs/plans/state.json"
|
||||
],
|
||||
"test_status": "pnpm test:run src/gateway/server.test.ts src/cli/tuiRuntimeGateway.test.ts src/daemon/startServices.test.ts src/daemon/services.test.ts src/daemon/routing.test.ts src/frontends/tui/minimal.test.ts + pnpm typecheck passing"
|
||||
},
|
||||
"pi-embedded-backend-canary-evaluation-phase": {
|
||||
"status": "completed",
|
||||
"date": "2026-02-24",
|
||||
@@ -6510,7 +6558,7 @@
|
||||
}
|
||||
},
|
||||
"overall_progress": {
|
||||
"total_test_count": 1996,
|
||||
"total_test_count": 2009,
|
||||
"all_tests_passing": true,
|
||||
"p0_completion": "3/3 (100%)",
|
||||
"p1_completion": "4/4 (100%)",
|
||||
@@ -6543,7 +6591,9 @@
|
||||
"next_up": "Track OpenClaw evolution regularly for inspiration and feature ideas",
|
||||
"pi_embedded_canary_spike": "completed — added optional pi_embedded backend adapter, canary-safe no-tools routing guard, backend success/fallback latency audit events, and docs/diagram updates while native remains default",
|
||||
"pi_embedded_evaluation_phase": "completed — final decision rollback (applied in runtime config): Window A failed latency/fallback gates (p50 +259ms, p95 +5695ms, fallback 25%, categories: pi_module_interface/empty_assistant_text); Window B remained sample-insufficient; controlled probes verified guard coverage (pi_no_tools_mode/capability_query/attachments_present each hit once)",
|
||||
"pi_embedded_manual_mode": "completed — added persisted runtime backend controls for manual Pi activation/deactivation (`/runtime` preferred, `/backend` alias; `status`, `activate pi`, `deactivate pi`, `use config`) while keeping config-driven default routing"
|
||||
"pi_embedded_manual_mode": "completed — added persisted runtime backend controls for manual Pi activation/deactivation (`/runtime` preferred, `/backend` alias; `status`, `activate pi`, `deactivate pi`, `use config`) while keeping config-driven default routing",
|
||||
"openclaw_gateway_first_tui_runtime_unification": "completed — shared `/runtime` backend-mode command service across channel router + gateway, plus TUI `/runtime` forwarding through a gateway bridge with daemon/gateway auto-start attach",
|
||||
"gateway_startup_eaddrinuse_hardening": "completed — gateway bind collisions now fail deterministically with explicit error handling and TUI auto-start treats EADDRINUSE as attach race with connect retry"
|
||||
},
|
||||
"soul_md_and_cron_create": {
|
||||
"date": "2026-02-11",
|
||||
|
||||
Reference in New Issue
Block a user