@enderfga/claw-orchestrator 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +218 -0
  3. package/assets/banner.jpg +0 -0
  4. package/configs/council-reviewer-prompt.md +82 -0
  5. package/configs/council-system-prompt.md +141 -0
  6. package/dist/bin/cli.d.ts +13 -0
  7. package/dist/bin/cli.js +460 -0
  8. package/dist/bin/cli.js.map +1 -0
  9. package/dist/src/base-oneshot-session.d.ts +87 -0
  10. package/dist/src/base-oneshot-session.js +228 -0
  11. package/dist/src/base-oneshot-session.js.map +1 -0
  12. package/dist/src/circuit-breaker.d.ts +21 -0
  13. package/dist/src/circuit-breaker.js +49 -0
  14. package/dist/src/circuit-breaker.js.map +1 -0
  15. package/dist/src/consensus.d.ts +20 -0
  16. package/dist/src/consensus.js +52 -0
  17. package/dist/src/consensus.js.map +1 -0
  18. package/dist/src/constants.d.ts +129 -0
  19. package/dist/src/constants.js +138 -0
  20. package/dist/src/constants.js.map +1 -0
  21. package/dist/src/council.d.ts +67 -0
  22. package/dist/src/council.js +914 -0
  23. package/dist/src/council.js.map +1 -0
  24. package/dist/src/embedded-server.d.ts +25 -0
  25. package/dist/src/embedded-server.js +360 -0
  26. package/dist/src/embedded-server.js.map +1 -0
  27. package/dist/src/inbox-manager.d.ts +38 -0
  28. package/dist/src/inbox-manager.js +111 -0
  29. package/dist/src/inbox-manager.js.map +1 -0
  30. package/dist/src/index.d.ts +63 -0
  31. package/dist/src/index.js +973 -0
  32. package/dist/src/index.js.map +1 -0
  33. package/dist/src/logger.d.ts +16 -0
  34. package/dist/src/logger.js +44 -0
  35. package/dist/src/logger.js.map +1 -0
  36. package/dist/src/models.d.ts +69 -0
  37. package/dist/src/models.js +299 -0
  38. package/dist/src/models.js.map +1 -0
  39. package/dist/src/openai-compat.d.ts +224 -0
  40. package/dist/src/openai-compat.js +756 -0
  41. package/dist/src/openai-compat.js.map +1 -0
  42. package/dist/src/persistent-codex-app-session.d.ts +108 -0
  43. package/dist/src/persistent-codex-app-session.js +465 -0
  44. package/dist/src/persistent-codex-app-session.js.map +1 -0
  45. package/dist/src/persistent-codex-session.d.ts +37 -0
  46. package/dist/src/persistent-codex-session.js +208 -0
  47. package/dist/src/persistent-codex-session.js.map +1 -0
  48. package/dist/src/persistent-cursor-session.d.ts +21 -0
  49. package/dist/src/persistent-cursor-session.js +241 -0
  50. package/dist/src/persistent-cursor-session.js.map +1 -0
  51. package/dist/src/persistent-custom-session.d.ts +78 -0
  52. package/dist/src/persistent-custom-session.js +938 -0
  53. package/dist/src/persistent-custom-session.js.map +1 -0
  54. package/dist/src/persistent-gemini-session.d.ts +21 -0
  55. package/dist/src/persistent-gemini-session.js +216 -0
  56. package/dist/src/persistent-gemini-session.js.map +1 -0
  57. package/dist/src/persistent-session.d.ts +80 -0
  58. package/dist/src/persistent-session.js +745 -0
  59. package/dist/src/persistent-session.js.map +1 -0
  60. package/dist/src/proxy/anthropic-adapter.d.ts +136 -0
  61. package/dist/src/proxy/anthropic-adapter.js +392 -0
  62. package/dist/src/proxy/anthropic-adapter.js.map +1 -0
  63. package/dist/src/proxy/handler.d.ts +39 -0
  64. package/dist/src/proxy/handler.js +365 -0
  65. package/dist/src/proxy/handler.js.map +1 -0
  66. package/dist/src/proxy/schema-cleaner.d.ts +11 -0
  67. package/dist/src/proxy/schema-cleaner.js +34 -0
  68. package/dist/src/proxy/schema-cleaner.js.map +1 -0
  69. package/dist/src/proxy/thought-cache.d.ts +19 -0
  70. package/dist/src/proxy/thought-cache.js +53 -0
  71. package/dist/src/proxy/thought-cache.js.map +1 -0
  72. package/dist/src/session-manager.d.ts +317 -0
  73. package/dist/src/session-manager.js +1528 -0
  74. package/dist/src/session-manager.js.map +1 -0
  75. package/dist/src/types.d.ts +513 -0
  76. package/dist/src/types.js +8 -0
  77. package/dist/src/types.js.map +1 -0
  78. package/dist/src/validation.d.ts +31 -0
  79. package/dist/src/validation.js +104 -0
  80. package/dist/src/validation.js.map +1 -0
  81. package/openclaw.plugin.json +122 -0
  82. package/package.json +84 -0
  83. package/skills/SKILL.md +184 -0
  84. package/skills/references/claude-cli-tracking.md +25 -0
  85. package/skills/references/cli.md +187 -0
  86. package/skills/references/council.md +210 -0
  87. package/skills/references/getting-started.md +133 -0
  88. package/skills/references/inbox.md +81 -0
  89. package/skills/references/multi-engine.md +382 -0
  90. package/skills/references/openai-compat.md +203 -0
  91. package/skills/references/sessions.md +191 -0
  92. package/skills/references/tools.md +418 -0
  93. package/skills/references/ultra.md +126 -0
@@ -0,0 +1,187 @@
1
+ # CLI Reference
2
+
3
+ The CLI is an HTTP client that talks to the Claw Orchestrator embedded server. In plugin mode, the server auto-starts. In standalone mode, run `clawo serve` first.
4
+
5
+ > **v2.x → v3.0:** The binary was renamed from `claude-code-skill` to `clawo`. The old binary is still installed as an alias for the duration of v3.0.x and will be removed in v3.1. Update scripts to use `clawo` before upgrading.
6
+
7
+ ## Server
8
+
9
+ ```bash
10
+ clawo serve [-p, --port <port>]
11
+ ```
12
+
13
+ Start standalone embedded server (default port 18796). Set `CLAUDE_CODE_API_URL` to override the base URL.
14
+
15
+ ### Rate Limiting
16
+
17
+ The embedded server enforces a sliding-window rate limit of 100 requests per minute per IP address. Requests exceeding the limit receive HTTP 429 (Too Many Requests). This prevents accidental runaway scripts from overwhelming the server.
18
+
19
+ ### OpenAI-Compatible API
20
+
21
+ The server exposes an OpenAI-compatible chat completions endpoint, enabling any webchat frontend to use it as a backend.
22
+
23
+ **Endpoints:**
24
+
25
+ | Endpoint | Method | Description |
26
+ |----------|--------|-------------|
27
+ | `/v1/chat/completions` | POST | Chat completions (streaming + non-streaming) |
28
+ | `/v1/models` | GET | List available models |
29
+
30
+ **Request format** (same as OpenAI):
31
+ ```json
32
+ {
33
+ "model": "claude-sonnet-4-6",
34
+ "messages": [{"role": "user", "content": "Hello!"}],
35
+ "stream": true
36
+ }
37
+ ```
38
+
39
+ **Session routing:** Each conversation maps to a persistent session for prompt cache reuse. Session key resolved from (in priority order):
40
+ 1. `X-Session-Id` header
41
+ 2. `user` field in the request body
42
+ 3. Default singleton session
43
+
44
+ **Model routing:** The `model` field auto-routes to the correct engine:
45
+ - `claude-*`, `opus`, `sonnet`, `haiku` → Claude engine
46
+ - `gpt-*` → Codex engine
47
+ - `composer-*` → Cursor engine
48
+ - `gemini-*` → Gemini engine
49
+
50
+ **CORS:** `/v1/` paths allow cross-origin requests by default. Set `OPENCLAW_CORS_ORIGINS=*` to allow all origins on all paths.
51
+
52
+ **Auto-compact:** When a session's context utilization exceeds 80%, the endpoint automatically compacts the session before sending the next message.
53
+
54
+ ## Session Management
55
+
56
+ ### session-start
57
+
58
+ ```bash
59
+ clawo session-start [name] [options]
60
+ ```
61
+
62
+ | Flag | Description |
63
+ |------|-------------|
64
+ | `-d, --cwd <dir>` | Working directory |
65
+ | `-e, --engine <engine>` | Engine: `claude` (default), `codex`, or `gemini` |
66
+ | `-m, --model <model>` | Model name or alias |
67
+ | `--permission-mode <mode>` | `acceptEdits`, `plan`, `auto`, `bypassPermissions` |
68
+ | `--effort <level>` | `low`, `medium`, `high`, `max`, `auto` |
69
+ | `--allowed-tools <tools>` | Comma-separated tool whitelist |
70
+ | `--max-turns <n>` | Max agent loop turns |
71
+ | `--max-budget <usd>` | API cost ceiling |
72
+ | `--system-prompt <text>` | Replace system prompt |
73
+ | `--append-system-prompt <text>` | Append to system prompt |
74
+ | `--agents <json>` | Custom sub-agents JSON |
75
+ | `--agent <name>` | Default agent |
76
+ | `--bare` | No CLAUDE.md, no git context |
77
+ | `-w, --worktree [name]` | Git worktree |
78
+ | `--fallback-model <model>` | Fallback model |
79
+ | `--json-schema <schema>` | JSON Schema for structured output |
80
+ | `--mcp-config <paths>` | MCP config files (comma-separated) |
81
+ | `--settings <path>` | Settings.json path |
82
+ | `--skip-persistence` | Disable session persistence |
83
+ | `--betas <headers>` | Beta headers (comma-separated) |
84
+ | `--enable-agent-teams` | Enable agent teams |
85
+ | `--include-hook-events` | Stream hook lifecycle events (PreToolUse/PostToolUse) |
86
+ | `--permission-prompt-tool <tool>` | Delegate permission prompts to an MCP tool (non-interactive use) |
87
+ | `--exclude-dynamic-system-prompt-sections` | Move cwd/env/git context to user message for better prompt cache hits (auto-enabled with `--bare`) |
88
+ | `--debug <categories>` | Enable targeted debug output by category (e.g. `"api,mcp"`) |
89
+ | `--debug-file <path>` | Write debug output to file |
90
+ | `--from-pr <n>` | Resume a session linked to a GitHub PR number or URL |
91
+ | `--channels <spec>` | MCP channel subscription (research preview) |
92
+ | `--dangerously-load-development-channels <spec>` | Development MCP channel subscriptions (research preview) |
93
+ | `ENABLE_PROMPT_CACHING_1H=1` (env var) | Enable 1-hour prompt cache TTL (auto-set with `--bare`) |
94
+
95
+ ### session-send
96
+
97
+ ```bash
98
+ clawo session-send <name> <message> [options]
99
+ ```
100
+
101
+ | Flag | Description |
102
+ |------|-------------|
103
+ | `--effort <level>` | Override effort for this message |
104
+ | `--plan` | Enable plan mode |
105
+ | `-s, --stream` | Collect streaming chunks |
106
+ | `-t, --timeout <ms>` | Timeout (default 300000) |
107
+
108
+ ### session-stop
109
+
110
+ ```bash
111
+ clawo session-stop <name>
112
+ ```
113
+
114
+ ### session-list
115
+
116
+ ```bash
117
+ clawo session-list
118
+ ```
119
+
120
+ ### session-status
121
+
122
+ ```bash
123
+ clawo session-status <name>
124
+ ```
125
+
126
+ ### session-grep
127
+
128
+ ```bash
129
+ clawo session-grep <name> <pattern> [-n, --limit <n>]
130
+ ```
131
+
132
+ ### session-compact
133
+
134
+ ```bash
135
+ clawo session-compact <name> [--summary <text>]
136
+ ```
137
+
138
+ ## Agent Management
139
+
140
+ ```bash
141
+ clawo agents-list [-d, --cwd <dir>]
142
+ clawo agents-create <name> [--description <desc>] [--prompt <prompt>]
143
+ ```
144
+
145
+ ## Skills Management
146
+
147
+ ```bash
148
+ clawo skills-list [-d, --cwd <dir>]
149
+ clawo skills-create <name> [--description <desc>] [--prompt <prompt>] [--trigger <t>]
150
+ ```
151
+
152
+ ## Rules Management
153
+
154
+ ```bash
155
+ clawo rules-list [-d, --cwd <dir>]
156
+ clawo rules-create <name> [--description <desc>] [--content <text>] [--paths <glob>] [--condition <expr>]
157
+ ```
158
+
159
+ ## Agent Teams
160
+
161
+ ```bash
162
+ clawo session-team-list <name>
163
+ clawo session-team-send <name> <teammate> <message>
164
+ ```
165
+
166
+ ## SDK-Only Tools (No CLI Wrapper)
167
+
168
+ The following tools are available through the OpenClaw plugin SDK and TypeScript API but do not have CLI commands. Use the SDK directly or call them via OpenClaw's tool system.
169
+
170
+ | Tool | Description |
171
+ |------|-------------|
172
+ | `sessions_overview` | Aggregate dashboard of all active sessions |
173
+ | `session_update_tools` | Hot-swap allowed/disallowed tools via `--resume` |
174
+ | `session_switch_model` | Switch model mid-session via `--resume` |
175
+ | `council_start` | Start multi-agent council with worktree isolation |
176
+ | `council_status` | Poll council progress and agent responses |
177
+ | `council_abort` | Abort a running council |
178
+ | `council_inject` | Inject a message into the next council round |
179
+ | `session_send_to` | Cross-session messaging (immediate or queued) |
180
+ | `session_inbox` | Read inbox messages for a session |
181
+ | `session_deliver_inbox` | Deliver queued messages to an idle session |
182
+ | `ultraplan_start` | Start background Opus planning session |
183
+ | `ultraplan_status` | Poll ultraplan progress |
184
+ | `ultrareview_start` | Start fleet of parallel reviewer agents |
185
+ | `ultrareview_status` | Poll ultrareview findings |
186
+
187
+ See [Tools Reference](./tools.md) for full parameter documentation.
@@ -0,0 +1,210 @@
1
+ # Council
2
+
3
+ The council system orchestrates multiple AI agents working in parallel on the same codebase, using git worktree isolation, round-based execution, and consensus voting.
4
+
5
+ Ported from [three-minds](https://github.com/Enderfga/three-minds) and adapted to run directly through `SessionManager` + `ISession`.
6
+
7
+ ## How It Works
8
+
9
+ ```
10
+ ┌──────────────────────────────────────────────┐
11
+ │ Council │
12
+ │ │
13
+ │ Round 1 (Planning): │
14
+ │ Agent 1 ──┐ │
15
+ │ Agent 2 ──┼── parallel ── plan.md │
16
+ │ Agent 3 ──┘ │
17
+ │ │
18
+ │ Round 2+ (Execution): │
19
+ │ Agent 1 ──┐ │
20
+ │ Agent 2 ──┼── parallel ── code + tests │
21
+ │ Agent 3 ──┘ │
22
+ │ │
23
+ │ Vote: all YES? ─── yes ──→ Review │
24
+ │ │ │ │
25
+ │ no ──→ next round ├─ Accept ──→ Cleanup & Done
26
+ │ └─ Reject ──→ Rewrite plan.md
27
+ └──────────────────────────────────────────────┘
28
+ ```
29
+
30
+ ### Two-Phase Protocol
31
+
32
+ **Round 1 — Planning**: All agents create `plan.md` in parallel. No business code allowed. Each agent works in its own git worktree, merges plan to `main`.
33
+
34
+ **Rounds 2+ — Execution**: Agents claim tasks from `plan.md`, write code, run tests, merge to `main`, and review each other's work.
35
+
36
+ ### Git Worktree Isolation
37
+
38
+ Each agent gets a physically isolated working directory:
39
+
40
+ ```
41
+ project/
42
+ ├── .worktrees/
43
+ │ ├── Architect/ ← council/Architect branch
44
+ │ ├── Engineer/ ← council/Engineer branch
45
+ │ └── Reviewer/ ← council/Reviewer branch
46
+ └── (main branch)
47
+ ```
48
+
49
+ Agents cannot interfere with each other's files. All integration happens via `git merge` to `main`.
50
+
51
+ ### Consensus Voting
52
+
53
+ Every agent must include `[CONSENSUS: YES]` or `[CONSENSUS: NO]` at the end of each round's response. The council continues until:
54
+ - **All agents vote YES** — consensus reached
55
+ - **Max rounds reached** — timeout
56
+ - **Aborted** — user intervention
57
+
58
+ ## Quick Start
59
+
60
+ ### Via Tool
61
+
62
+ ```json
63
+ {
64
+ "tool": "council_start",
65
+ "args": {
66
+ "task": "Build a REST API with authentication and rate limiting",
67
+ "projectDir": "/tmp/my-api-project",
68
+ "maxRounds": 10
69
+ }
70
+ }
71
+ ```
72
+
73
+ This starts a 3-agent council (Planner, Generator, Evaluator) with default settings.
74
+
75
+ ### Via TypeScript
76
+
77
+ ```typescript
78
+ import { SessionManager } from '@enderfga/claw-orchestrator';
79
+
80
+ const manager = new SessionManager();
81
+
82
+ const session = manager.councilStart(
83
+ 'Build a REST API with authentication',
84
+ {
85
+ agents: [
86
+ { name: 'Planner', emoji: '🟠', persona: 'Technical planner focused on requirements decomposition and architecture' },
87
+ { name: 'Generator', emoji: '🟢', persona: 'Implementation engineer focused on shipping correct code per plan' },
88
+ { name: 'Evaluator', emoji: '🔵', persona: 'Independent quality gate focused on verification and acceptance' },
89
+ ],
90
+ maxRounds: 10,
91
+ projectDir: '/tmp/my-api-project',
92
+ }
93
+ );
94
+
95
+ console.log(`Council started: ${session.id}`);
96
+ // Poll for status
97
+ const status = manager.councilStatus(session.id);
98
+ ```
99
+
100
+ ### Mixed Engines
101
+
102
+ Agents can use different engines and models:
103
+
104
+ ```json
105
+ {
106
+ "agents": [
107
+ { "name": "Claude", "emoji": "🎭", "engine": "claude", "model": "opus", "persona": "Deep reasoning" },
108
+ { "name": "Codex", "emoji": "🧠", "engine": "codex", "model": "gpt-5.4", "persona": "Fast implementation" },
109
+ { "name": "Gemini", "emoji": "💎", "engine": "gemini", "model": "gemini-3.1-pro-preview", "persona": "Creative solutions" }
110
+ ]
111
+ }
112
+ ```
113
+
114
+ ## Council Tools
115
+
116
+ | Tool | Description |
117
+ |------|-------------|
118
+ | `council_start` | Start a council. Runs in background, returns session ID immediately. |
119
+ | `council_status` | Get current status (running/consensus/max_rounds/error), responses, votes. |
120
+ | `council_abort` | Stop all agent sessions and terminate the council. |
121
+ | `council_inject` | Inject a user message into all agents' prompts in the next round. |
122
+ | `council_review` | Review completed council output: changed files, branches, plan status, agent summaries. |
123
+ | `council_accept` | Accept work and clean up: remove worktrees, branches, plan.md, reviews/. |
124
+ | `council_reject` | Reject work: rewrite plan.md with feedback for the council to retry. |
125
+
126
+ ## Post-Processing Lifecycle
127
+
128
+ After a council reaches consensus or hits max rounds, use the review/accept/reject tools to finalize the work.
129
+
130
+ ### 1. Review
131
+
132
+ ```json
133
+ { "tool": "council_review", "args": { "id": "<council-id>" } }
134
+ ```
135
+
136
+ Returns a structured report:
137
+ - **changedFiles**: all files modified by the council with insertion/deletion counts
138
+ - **branches**: remaining `council/*` branches
139
+ - **worktrees**: remaining council worktrees
140
+ - **planContent**: full plan.md text (check for unchecked tasks)
141
+ - **reviews**: review files in `reviews/` directory
142
+ - **agentSummaries**: final-round output preview from each agent
143
+
144
+ ### 2. Accept
145
+
146
+ ```json
147
+ { "tool": "council_accept", "args": { "id": "<council-id>" } }
148
+ ```
149
+
150
+ Cleans up all council scaffolding:
151
+ - Removes all `council/*` worktrees and `.worktrees/` directory
152
+ - Deletes all `council/*` branches
153
+ - Removes `plan.md` and `reviews/` directory
154
+ - Sets council status to `accepted`
155
+
156
+ ### 3. Reject
157
+
158
+ ```json
159
+ { "tool": "council_reject", "args": { "id": "<council-id>", "feedback": "..." } }
160
+ ```
161
+
162
+ Rewrites `plan.md` with rejection feedback and commits it. All worktrees and branches are preserved so the council can be restarted to address the feedback.
163
+
164
+ ## Configuration
165
+
166
+ | Parameter | Default | Description |
167
+ |-----------|---------|-------------|
168
+ | `maxRounds` | 15 | Maximum collaboration rounds |
169
+ | `agentTimeoutMs` | 1,800,000 (30 min) | Per-agent timeout per round |
170
+ | `maxTurnsPerAgent` | 30 | Max tool turns per agent per round |
171
+ | `maxBudgetUsd` | — | API spend limit per agent |
172
+
173
+ ### defaultPermissionMode
174
+
175
+ Optional. Sets the default permission mode for council agents when individual agents don't specify one. Defaults to `bypassPermissions`.
176
+
177
+ ```typescript
178
+ manager.councilStart('task', {
179
+ agents: [...],
180
+ maxRounds: 10,
181
+ projectDir: '/project',
182
+ defaultPermissionMode: 'acceptEdits', // override the bypassPermissions default
183
+ });
184
+ ```
185
+
186
+ Permission priority: agent-level `permissionMode` > `defaultPermissionMode` > `'bypassPermissions'`
187
+
188
+ > **Note (Claude CLI 2.1.121+):** When agent personas are persisted as Claude agent files with frontmatter, the `permissionMode`, `tools`, and `disallowedTools` fields are now **enforced** by `--agent` and `--print` modes (previously advisory). If you write agent files with restrictive `tools` lists, expect those agents to refuse calls to other tools at runtime.
189
+
190
+ ## System Prompt
191
+
192
+ The council system prompt is loaded from `configs/council-system-prompt.md` and supports hot-editing. It includes 9 charter sections tuned through extensive multi-agent collaboration testing:
193
+
194
+ | Section | Purpose |
195
+ |---------|---------|
196
+ | §0 No Hallucination | Agents must use tools, never fabricate results |
197
+ | §1 Plan First | Two-phase protocol with plan.md |
198
+ | §2 Parallel Coordination | Claim/done protocol for concurrent work |
199
+ | §3 Truth in Git | Git state over conversation memory |
200
+ | §4 Merge to Main | Local only, never push |
201
+ | §5 Cross-Review | Structured APPROVE/REQUEST_CHANGES |
202
+ | §6 Auto-Conflict Resolution | Never stop on merge conflicts |
203
+ | §7 Action Over Words | Never ask permission, just work |
204
+ | §8 Efficient Tool Use | Minimum necessary principle |
205
+
206
+ Placeholders: `{{emoji}}`, `{{name}}`, `{{persona}}`, `{{workDir}}`, `{{otherBranches}}`
207
+
208
+ ## Transcript Logging
209
+
210
+ All council sessions save transcripts to `~/.openclaw/council-logs/council-<timestamp>.md`. Completed councils remain queryable via `council_status` for 30 minutes after completion.
@@ -0,0 +1,133 @@
1
+ # Getting Started
2
+
3
+ ## Installation
4
+
5
+ ### Standalone CLI
6
+
7
+ ```bash
8
+ npm install -g @enderfga/claw-orchestrator
9
+
10
+ # Start the embedded server
11
+ clawo serve
12
+
13
+ # Drive sessions from the command line
14
+ clawo session-start myproject -d ~/project
15
+ clawo session-send myproject "fix the auth bug"
16
+ clawo session-stop myproject
17
+ ```
18
+
19
+ > **Migrating from v2.x?** The legacy binary `claude-code-skill` is still installed alongside `clawo` for the duration of the v3.0.x line; both invoke the same script. Plan to migrate scripts to `clawo` before upgrading to v3.1.
20
+
21
+ ### As OpenClaw Plugin
22
+
23
+ ```bash
24
+ openclaw plugins install @enderfga/claw-orchestrator --dangerously-force-unsafe-install
25
+ openclaw gateway restart
26
+ ```
27
+
28
+ > **Why `--dangerously-force-unsafe-install`?** Claw Orchestrator spawns Claude Code / Codex / Gemini / Cursor Agent CLI subprocesses via `child_process`, which OpenClaw's security scanner flags by design. The flag is required — there is no way to drive coding CLIs without process spawning.
29
+
30
+ Agents automatically get access to all session, council, and management tools.
31
+
32
+ ### TypeScript Library
33
+
34
+ ```typescript
35
+ import { SessionManager } from '@enderfga/claw-orchestrator';
36
+
37
+ const manager = new SessionManager({ defaultModel: 'claude-sonnet-4-6' });
38
+
39
+ const session = await manager.startSession({
40
+ name: 'backend-fix',
41
+ cwd: '/path/to/project',
42
+ permissionMode: 'acceptEdits',
43
+ });
44
+
45
+ const result = await manager.sendMessage('backend-fix', 'Fix the failing tests');
46
+ console.log(result.output);
47
+
48
+ await manager.stopSession('backend-fix');
49
+ ```
50
+
51
+ ## Requirements
52
+
53
+ - **Node.js >= 22**
54
+ - **Claude Code CLI >= 2.1** — `npm install -g @anthropic-ai/claude-code`
55
+ - **OpenClaw >= 2026.3.0** — for plugin mode (optional)
56
+ - **OpenAI Codex CLI >= 0.112** — `npm install -g @openai/codex` (optional, for codex engine)
57
+ - **Gemini CLI >= 0.35** — `npm install -g @google/gemini-cli` (optional, for gemini engine)
58
+
59
+ ### Engine Authentication
60
+
61
+ Each engine requires its own authentication before use:
62
+
63
+ - **Claude Code** — run `claude /login` or set `ANTHROPIC_API_KEY`
64
+ - **Codex** — run `codex login` or set `OPENAI_API_KEY`
65
+ - **Gemini** — run `gemini login` or set `GEMINI_API_KEY`
66
+
67
+ The plugin does not manage authentication — it expects each CLI to be ready to run.
68
+
69
+ ### Embedded Server Authentication
70
+
71
+ The embedded HTTP server (used by CLI and standalone mode) optionally supports bearer token authentication:
72
+
73
+ | Variable | Purpose |
74
+ |----------|---------|
75
+ | `OPENCLAW_SERVER_TOKEN` | Set to enable bearer token auth. All requests (except `/health`) must include `Authorization: Bearer <token>` |
76
+
77
+ When set, the token is also written to `~/.openclaw/server-token` for the CLI to read automatically. Default: no auth (localhost binding is the primary security boundary).
78
+
79
+ ### OpenAI-Compatible Endpoint
80
+
81
+ The server exposes an OpenAI-compatible API at `/v1/chat/completions`. It serves both kinds of clients as first-class citizens:
82
+
83
+ - **Upstream agents** (OpenClaw main loop, cron, subagents) that maintain their own transcript and only forward the latest user turn — uses default mode.
84
+ - **Webchat / labeling tools** (ChatGPT-Next-Web, Open WebUI, LobeChat) that re-send the full transcript every turn — set `OPENAI_COMPAT_NEW_CONVO_HEURISTIC=1`.
85
+
86
+ Quick config for any client:
87
+
88
+ | Setting | Value |
89
+ |---------|-------|
90
+ | API Base URL | `http://127.0.0.1:18796/v1` |
91
+ | API Key | The value of `OPENCLAW_SERVER_TOKEN`, or any string if auth is disabled |
92
+ | Model | `claude-opus-4-6`, `claude-sonnet-4-6`, `gpt-5.4`, `gemini-3.1-pro-preview`, etc. |
93
+
94
+ See [openai-compat.md](./openai-compat.md) for the full session-keying rules, `X-Session-Reset` semantics, the legacy-heuristic env var, and the `/v1/sessions` inspection endpoint.
95
+
96
+ ## Configuration
97
+
98
+ In `~/.openclaw/openclaw.json`:
99
+
100
+ ```jsonc
101
+ {
102
+ "plugins": {
103
+ "entries": {
104
+ "claw-orchestrator": {
105
+ "enabled": true,
106
+ "config": {
107
+ "claudeBin": "claude",
108
+ "defaultModel": "claude-opus-4-6",
109
+ "defaultPermissionMode": "acceptEdits",
110
+ "defaultEffort": "auto",
111
+ "maxConcurrentSessions": 5,
112
+ "sessionTtlMinutes": 120,
113
+ "proxy": {
114
+ "enabled": false,
115
+ "bigModel": "gemini-3.1-pro-preview",
116
+ "smallModel": "gemini-3-flash-preview"
117
+ }
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }
123
+ ```
124
+
125
+ ## Next Steps
126
+
127
+ - [Sessions](./sessions.md) — persistent session lifecycle and management
128
+ - [Session Inbox](./inbox.md) — cross-session messaging
129
+ - [Multi-Engine](./multi-engine.md) — using Claude Code and Codex side by side
130
+ - [Council](./council.md) — multi-agent collaboration with consensus voting
131
+ - [Ultraplan & Ultrareview](./ultra.md) — deep planning and fleet code review
132
+ - [Tools Reference](./tools.md) — complete tool API reference (27 tools)
133
+ - [CLI Reference](./cli.md) — command-line interface
@@ -0,0 +1,81 @@
1
+ # Session Inbox
2
+
3
+ Cross-session messaging allows different sessions to communicate with each other. Inspired by Claude Code's UDS Inbox feature.
4
+
5
+ ## How It Works
6
+
7
+ ```
8
+ Session A (planner) SessionManager Session B (coder)
9
+ │ │ │
10
+ ├── sendTo(B, "do X") ──────►│ │
11
+ │ ├── B idle? ─── yes ────►│ deliver immediately
12
+ │ │ │ │
13
+ │ │ no │
14
+ │ │ │ │
15
+ │ │ queue in inbox │
16
+ │ │ │ │
17
+ │ │ ... B becomes idle │
18
+ │ ├── deliverInbox(B) ────►│ deliver queued msgs
19
+ ```
20
+
21
+ - **Idle sessions** receive messages immediately as a new user turn
22
+ - **Busy sessions** have messages queued in an inbox (max 200 messages)
23
+ - Messages are wrapped in `<cross-session-message>` XML tags
24
+ - Supports broadcast to all sessions via `to: "*"`
25
+
26
+ ## Usage
27
+
28
+ ### Send a Message
29
+
30
+ ```typescript
31
+ // Direct message
32
+ await manager.sessionSendTo('planner', 'coder', 'The auth module needs rate limiting', 'auth rate limit');
33
+
34
+ // Broadcast to all sessions
35
+ await manager.sessionSendTo('monitor', '*', 'Build failed on main!', 'build failure');
36
+ ```
37
+
38
+ ### Read Inbox
39
+
40
+ ```typescript
41
+ // Unread messages only (default)
42
+ const unread = manager.sessionInbox('coder');
43
+
44
+ // All messages
45
+ const all = manager.sessionInbox('coder', false);
46
+ ```
47
+
48
+ ### Deliver Queued Messages
49
+
50
+ When a session finishes a task and becomes idle, deliver its queued messages:
51
+
52
+ ```typescript
53
+ const count = await manager.sessionDeliverInbox('coder');
54
+ console.log(`Delivered ${count} queued messages`);
55
+ ```
56
+
57
+ ## Tools
58
+
59
+ | Tool | Description |
60
+ |------|-------------|
61
+ | `claude_session_send_to` | Send message between sessions |
62
+ | `claude_session_inbox` | Read inbox messages |
63
+ | `claude_session_deliver_inbox` | Deliver queued messages to idle session |
64
+
65
+ ## Message Format
66
+
67
+ Messages delivered to sessions are wrapped in XML:
68
+
69
+ ```xml
70
+ <cross-session-message from="planner" summary="auth rate limit">
71
+ The auth module needs rate limiting. Please add a token bucket...
72
+ </cross-session-message>
73
+ ```
74
+
75
+ Attributes are properly escaped to prevent XML injection.
76
+
77
+ ## Inbox Limits
78
+
79
+ - **Max size**: 200 messages per session
80
+ - **Eviction**: oldest read messages dropped first, then oldest unread
81
+ - **No TTL**: messages persist until read or evicted (in-memory only, not persisted to disk)