chore: initial scaffolding for SynthesisAgent

Bridge between OpenClaw (multi-channel hub) and interactive Claude Code,
keeping autonomous agent usage on the subscription quota after the
2026-06-15 Agent SDK credit split.

Initial scaffolding only — two submodules with skeletons:

- SynthesisAgent.ClaudePlugin: stdio MCP server registered as a --channels
  source. Declares experimental.claude/channel capability (verified 2026-05-14
  against the official Anthropic discord plugin) and emits
  notifications/claude/channel to push OpenClaw inbound messages into the
  Claude turn loop.

- SynthesisAgent.OpenclawPlugin: process manager + session mapping +
  bridge WebSocket. Currently shaped around a custom ws protocol; will be
  rewritten as a model-provider HTTP server (contractor-agent pattern) so
  OpenClaw routes inbound channel messages through it via /v1/chat/completions.

See STATUS.md for the open punch list and docs/wire-protocol.md for the
(soon-to-change) inter-plugin frame schema.
This commit is contained in:
zhi
2026-05-14 09:39:02 +00:00
commit 0fb46e318e
20 changed files with 1285 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
# SynthesisAgent.ClaudePlugin
The **Claude Code side** of SynthesisAgent. A stdio MCP server that registers as a `--channels` plugin and bridges to `SynthesisAgent.OpenclawPlugin`.
## What it does
- Receives inbound messages from OpenClaw and emits `notifications/claude/channel` so Claude Code starts a new turn.
- Receives the OpenClaw tool catalog at `hello_ack` time and exposes them as MCP tools.
- Forwards every `tools/call` over the bridge for OpenClaw to execute.
- Forwards Claude's `permission_request` notifications to OpenClaw, and surfaces the user's reply back.
## Required env vars
Set by OpenclawPlugin when it spawns Claude:
| Var | Example | Meaning |
|-----|---------|---------|
| `SYNTHESIS_BRIDGE_URL` | `ws://127.0.0.1:18801/bridge` | Where to connect |
| `SYNTHESIS_BRIDGE_TOKEN` | `...` | Shared secret |
| `SYNTHESIS_OPENCLAW_SESSION` | `discord:alice` | This Claude process serves *this* session |
| `SYNTHESIS_CLAUDE_SESSION` | `<uuid>` | The Claude session UUID, for traceability |
## Spawn shape (done by OpenclawPlugin)
```bash
claude \
--channels plugin:synthesis-claude@local \
--resume "$SYNTHESIS_CLAUDE_SESSION" \
--allowed-tools "Read Edit Bash mcp__synthesis__*" \
--append-system-prompt-file ./session-context.md
```
## TODO
- [ ] Verify exact semantics of `--channels plugin:foo@bar` against the running Claude Code build.
- [ ] Verify `mcp.notification('notifications/claude/channel', ...)` triggers a new turn (vs being silently accepted). May need to first land on `claude/channel` capability declaration.
- [ ] Implement attachment download flow (`download_attachment` style) — currently passthrough.
- [ ] Implement `fetch_messages` to query OpenClaw history.
- [ ] Wire `bun-types` install in `package.json`.
## Manual test (once OpenclawPlugin is wired up)
```bash
# Terminal 1: start OpenclawPlugin bridge server
openclaw # with SynthesisAgent.OpenclawPlugin loaded
# Terminal 2: simulate the spawn manually
SYNTHESIS_BRIDGE_URL=ws://127.0.0.1:18801/bridge \
SYNTHESIS_BRIDGE_TOKEN=local-dev \
SYNTHESIS_OPENCLAW_SESSION=test:1 \
SYNTHESIS_CLAUDE_SESSION=$(uuidgen) \
claude --channels plugin:synthesis-claude@local
# Terminal 3: push a fake inbound message via OpenclawPlugin admin CLI
openclaw synthesis push --session test:1 --content "hello"
```
A successful run: Claude Code visibly starts a new turn in Terminal 2 reacting to "hello".