Commit Graph

3 Commits

Author SHA1 Message Date
zhi
3229fbd024 fix: end-to-end working after laptop integration test
Discovered during smoke-testing on hzhang's laptop:

1. `--channels server:X --dangerously-load-development-channels server:X`
   makes Claude Code list the channel twice and the second copy never
   inherits dev-mode, leaving "server: entries need
   --dangerously-load-development-channels" stuck in the status panel.
   Fix: pass channel ONLY via --dangerously-load-development-channels.

2. Without a controlling TTY, Claude Code's dev-mode confirmation dialog
   blocks forever waiting for keystrokes that never arrive. Fix: spawn
   claude wrapped in `script -q -c CMD PTYLOG` so it gets a PTY, then
   write "\r" to stdin at several timeouts (cheap to over-send).

3. process-manager.markReady was matching on PID, but the PID in the
   bridge hello frame is the ClaudePlugin (bun) process's pid, not the
   script-wrapped claude process's pid we tracked. Fix: match on
   openclaw-session-key, which is consistent on both sides.

4. First spawn for a new session can't use --resume (no transcript exists
   yet) — claude errors out. Fix: probe
   ~/.claude/projects/<workspace-slug>/<uuid>.jsonl for existence and use
   --session-id on fresh sessions, --resume after a process restart.

5. Add --debug-file per session so future debugging has the gating logs.

6. Local definePluginEntry shim (no openclaw runtime dependency) so
   `bun index.ts` works standalone for laptop smoke tests.

End-to-end verified twice on laptop: curl POST -> SSE delta with the
exact reply text. Average cold-start ~10s, hot path 2-3s.
2026-05-14 14:00:32 +00:00
zhi
0324a47d13 feat: HTTP /v1/chat/completions + WS bridge + process manager
Real first cut. OpenClaw routes agent turns via /v1/chat/completions
(OpenAI-compatible SSE) into our bridge. Bridge ensures a long-lived
claude process per session-key, pushes the user message as
notifications/claude/channel into the running Claude Code, awaits a
reply via the WS connection, streams the reply back as SSE deltas.

- core/process-manager: spawn / track / reap claude processes, auto-confirm
  the --dangerously-load-development-channels dev-mode prompt by piping
  "1\n" to stdin shortly after spawn
- web/bridge-server: unified HTTP + WS server, per-session FIFO queue,
  SSE heartbeat (empty content delta — SSE comments don't reset OpenClaw's
  idle watchdog), reply buffering for streaming progress chunks
- index.ts: definePluginEntry for OpenClaw runtime + standalone-mode main
  for laptop smoke testing (just `bun index.ts`)

Same-machine simplifications: no bridge token, no permission_request
reverse channel. Session key = agent_id::chat_id (contractor-agent
convention).
2026-05-14 13:28:00 +00:00
zhi
38ac6d20b7 chore: initial scaffolding for SynthesisAgent.OpenclawPlugin
OpenClaw plugin that manages long-lived interactive Claude Code processes
per OpenClaw session. Process manager + session-mapping persistence +
bridge WebSocket server skeleton.

Will be rewritten to follow the contractor-agent HTTP model-provider pattern
(register as `synthesis-claude-bridge` provider, receive /v1/chat/completions,
dispatch to channel notification on the bound Claude process). See parent
repo's STATUS.md for the punch list.
2026-05-14 09:41:18 +00:00