feat(desktop): clawcodex serve — the desktop gateway backend + boot rewire (stage 2) - #803
Merged
Merged
Conversation
…ewire (stage 2)
Python gains the serve surface the desktop shell expects, and the shell's
boot ladder now resolves real clawcodex runtimes end-to-end.
Server (new):
- src/entrypoints/serve_cli.py: `clawcodex serve` — loopback HTTP+WS on one
OS-assigned port, CLAWCODEX_BACKEND_READY stdout announce + ready-file,
token via flag/env/generated, agent-server-grade permission plumbing
(bypass sanitization + safety, flags-only availability on this
multi-session transport).
- src/server/desktop_serve.py: Starlette app — /api/health (open),
/api/status + /api/config (token; config served through redact_secrets so
the env block and key-bearing fields never cross REST), token-carrying /,
/api/ws.
- src/server/desktop_gateway*.py: JSON-RPC gateway — number/string ids echoed,
{method:'event'} pushes; sessions run the in-process agent core
(make_spawn_agent) with a pump translating frames to renderer events
(message.delta/interim/complete with usage mapping, reasoning.delta,
tool.start/complete from SDK envelopes, session.info from init);
approval round-trip parks can_use_tool asks and maps
approval.respond{once|session|always|deny} onto permission replies with
suggestion-scoped grants; resume = fresh spawn + resume control (spawn's
third arg is a permission mode, not a resume id); interrupt control;
model.options/get_settings bridging; unknown methods error without
dropping the socket; unsupported ask subtypes deny instead of hanging.
- serve added to the CLI sieve; starlette/uvicorn promoted from transitive
(via mcp) to declared deps.
Desktop shell:
- backend-command: no more legacy dashboard fallback (never existed here);
serve support sniffed from src/cli.py's sieve.
- main: probe reads src/cli.py; a runtime without serve is an actionable
update-required boot error; python -m src.cli everywhere;
source-root check = src/cli.py; managed venv is .venv
(~/.clawcodex/clawcodex/.venv, install.sh layout); About version from
pyproject.toml.
Verification: 18 new pytest tests (fake-agent tier + real-spawn tier incl. a
real permission round-trip where the tool executes), full suite 9,830 passed;
live smoke against a real serve process (uvicorn WS handshake, session
create/close, auth matrix, wrong-token rejection); ui-desktop typecheck
green, lint 0 errors/88 warnings (= reference), electron vitest 78 files
green.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stage 2 of the Desktop port: the Python side gains
clawcodex serve— the backend the desktop shell spawns — and the shell's boot ladder now resolves real clawcodex runtimes.Server (new)
clawcodex serve(src/entrypoints/serve_cli.py): loopback HTTP+WS on one OS-assigned port,CLAWCODEX_BACKEND_READY port=Nstdout announce + ready-file contract, token via flag/env/generated, agent-server-grade permission plumbing (bypass sanitization + safety; flags-only availability on this multi-session transport).src/server/desktop_serve.py):/api/health(open),/api/status+/api/config(token-gated; config passes throughredact_secretsso theenvblock and key-bearing fields never cross REST), token-carrying/page for backend adoption,/api/ws.src/server/desktop_gateway*.py): sessions run the in-process agent core (make_spawn_agent); a pump translates agent frames into the renderer's event vocabulary (message.delta/interim/completewith usage mapping,reasoning.delta,tool.start/completefrom SDK envelopes,session.info); approval round-trip parkscan_use_toolasks and mapsapproval.respond {once|session|always|deny}onto permission replies with suggestion-scoped grants; resume = fresh spawn +resumecontrol; interrupt;model.options/get_settingsbridging; unknown methods error without dropping the socket.serveadded to the CLI sieve; starlette/uvicorn promoted to declared deps (were transitive via mcp).Desktop shell
src/cli.py's sieve, and a too-old runtime is now an actionable update-required boot error.python -m src.cliacross the resolver ladder; source-root check =src/cli.py; managed venv.venv(~/.clawcodex/clawcodex/.venv, install.sh layout); About-panel version frompyproject.toml.Verification
tests/server/test_desktop_{serve,gateway}.py)serveprocess)Next stage: sessions/fs/git REST subset for the sidebar + transcript hydration, and the
clawcodex desktoplauncher.🤖 Generated with Claude Code