chore: initial scaffolding for SynthesisAgent.ClaudePlugin

Stdio MCP server registered as a Claude Code --channels source. Receives
inbound events from SynthesisAgent.OpenclawPlugin and emits
notifications/claude/channel to push them into the running Claude turn loop.
Forwards tools/call requests back to OpenClaw for execution.

Capability declaration uses experimental.claude/channel — required nesting
discovered 2026-05-14 against the official Anthropic discord plugin source.
This commit is contained in:
zhi
2026-05-14 09:41:14 +00:00
commit cb94464060
7 changed files with 340 additions and 0 deletions

58
README.md Normal file
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".