cli-agent-orchestrator 2.1.1__py3-none-any.whl

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 (84) hide show
  1. cli_agent_orchestrator/__init__.py +0 -0
  2. cli_agent_orchestrator/agent_store/code_supervisor.md +66 -0
  3. cli_agent_orchestrator/agent_store/developer.md +55 -0
  4. cli_agent_orchestrator/agent_store/reviewer.md +60 -0
  5. cli_agent_orchestrator/api/__init__.py +1 -0
  6. cli_agent_orchestrator/api/main.py +947 -0
  7. cli_agent_orchestrator/cli/__init__.py +1 -0
  8. cli_agent_orchestrator/cli/commands/__init__.py +1 -0
  9. cli_agent_orchestrator/cli/commands/env.py +60 -0
  10. cli_agent_orchestrator/cli/commands/flow.py +102 -0
  11. cli_agent_orchestrator/cli/commands/info.py +57 -0
  12. cli_agent_orchestrator/cli/commands/init.py +45 -0
  13. cli_agent_orchestrator/cli/commands/install.py +317 -0
  14. cli_agent_orchestrator/cli/commands/launch.py +243 -0
  15. cli_agent_orchestrator/cli/commands/mcp_server.py +12 -0
  16. cli_agent_orchestrator/cli/commands/session.py +260 -0
  17. cli_agent_orchestrator/cli/commands/shutdown.py +59 -0
  18. cli_agent_orchestrator/cli/commands/skills.py +99 -0
  19. cli_agent_orchestrator/cli/main.py +36 -0
  20. cli_agent_orchestrator/clients/database.py +415 -0
  21. cli_agent_orchestrator/clients/tmux.py +516 -0
  22. cli_agent_orchestrator/constants.py +145 -0
  23. cli_agent_orchestrator/mcp_server/__init__.py +1 -0
  24. cli_agent_orchestrator/mcp_server/models.py +14 -0
  25. cli_agent_orchestrator/mcp_server/server.py +653 -0
  26. cli_agent_orchestrator/mcp_server/utils.py +15 -0
  27. cli_agent_orchestrator/models/__init__.py +1 -0
  28. cli_agent_orchestrator/models/agent_profile.py +37 -0
  29. cli_agent_orchestrator/models/copilot_agent.py +15 -0
  30. cli_agent_orchestrator/models/flow.py +23 -0
  31. cli_agent_orchestrator/models/inbox.py +33 -0
  32. cli_agent_orchestrator/models/kiro_agent.py +28 -0
  33. cli_agent_orchestrator/models/opencode_agent.py +23 -0
  34. cli_agent_orchestrator/models/provider.py +14 -0
  35. cli_agent_orchestrator/models/q_agent.py +28 -0
  36. cli_agent_orchestrator/models/session.py +21 -0
  37. cli_agent_orchestrator/models/skill.py +19 -0
  38. cli_agent_orchestrator/models/terminal.py +37 -0
  39. cli_agent_orchestrator/plugins/__init__.py +24 -0
  40. cli_agent_orchestrator/plugins/base.py +52 -0
  41. cli_agent_orchestrator/plugins/events.py +75 -0
  42. cli_agent_orchestrator/plugins/registry.py +87 -0
  43. cli_agent_orchestrator/providers/__init__.py +0 -0
  44. cli_agent_orchestrator/providers/base.py +186 -0
  45. cli_agent_orchestrator/providers/claude_code.py +434 -0
  46. cli_agent_orchestrator/providers/codex.py +497 -0
  47. cli_agent_orchestrator/providers/copilot_cli.py +502 -0
  48. cli_agent_orchestrator/providers/gemini_cli.py +764 -0
  49. cli_agent_orchestrator/providers/kimi_cli.py +649 -0
  50. cli_agent_orchestrator/providers/kiro_cli.py +548 -0
  51. cli_agent_orchestrator/providers/manager.py +181 -0
  52. cli_agent_orchestrator/providers/opencode_cli.py +369 -0
  53. cli_agent_orchestrator/providers/q_cli.py +176 -0
  54. cli_agent_orchestrator/services/cleanup_service.py +58 -0
  55. cli_agent_orchestrator/services/flow_service.py +235 -0
  56. cli_agent_orchestrator/services/inbox_service.py +172 -0
  57. cli_agent_orchestrator/services/plugin_dispatch.py +42 -0
  58. cli_agent_orchestrator/services/session_service.py +141 -0
  59. cli_agent_orchestrator/services/settings_service.py +78 -0
  60. cli_agent_orchestrator/services/terminal_service.py +475 -0
  61. cli_agent_orchestrator/skills/__init__.py +1 -0
  62. cli_agent_orchestrator/skills/cao-session-management/SKILL.md +106 -0
  63. cli_agent_orchestrator/skills/cao-supervisor-protocols/SKILL.md +84 -0
  64. cli_agent_orchestrator/skills/cao-worker-protocols/SKILL.md +60 -0
  65. cli_agent_orchestrator/utils/__init__.py +1 -0
  66. cli_agent_orchestrator/utils/agent_profiles.py +241 -0
  67. cli_agent_orchestrator/utils/env.py +41 -0
  68. cli_agent_orchestrator/utils/logging.py +25 -0
  69. cli_agent_orchestrator/utils/opencode_config.py +169 -0
  70. cli_agent_orchestrator/utils/opencode_permissions.py +109 -0
  71. cli_agent_orchestrator/utils/skill_injection.py +240 -0
  72. cli_agent_orchestrator/utils/skills.py +129 -0
  73. cli_agent_orchestrator/utils/template.py +30 -0
  74. cli_agent_orchestrator/utils/terminal.py +145 -0
  75. cli_agent_orchestrator/utils/tool_mapping.py +158 -0
  76. cli_agent_orchestrator/web_ui/assets/index-BXMLhBau.css +32 -0
  77. cli_agent_orchestrator/web_ui/assets/index-BpPHwanT.js +275 -0
  78. cli_agent_orchestrator/web_ui/index.html +13 -0
  79. cli_agent_orchestrator-2.1.1.dist-info/METADATA +681 -0
  80. cli_agent_orchestrator-2.1.1.dist-info/RECORD +84 -0
  81. cli_agent_orchestrator-2.1.1.dist-info/WHEEL +4 -0
  82. cli_agent_orchestrator-2.1.1.dist-info/entry_points.txt +4 -0
  83. cli_agent_orchestrator-2.1.1.dist-info/licenses/LICENSE +175 -0
  84. cli_agent_orchestrator-2.1.1.dist-info/licenses/NOTICE +1 -0
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Agent Orchestrator</title>
7
+ <script type="module" crossorigin src="/assets/index-BpPHwanT.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-BXMLhBau.css">
9
+ </head>
10
+ <body>
11
+ <div id="root"></div>
12
+ </body>
13
+ </html>
@@ -0,0 +1,681 @@
1
+ Metadata-Version: 2.4
2
+ Name: cli-agent-orchestrator
3
+ Version: 2.1.1
4
+ Summary: CLI Agent Orchestrator
5
+ Project-URL: Homepage, https://github.com/awslabs/cli-agent-orchestrator
6
+ Project-URL: Repository, https://github.com/awslabs/cli-agent-orchestrator
7
+ Project-URL: Issues, https://github.com/awslabs/cli-agent-orchestrator/issues
8
+ Project-URL: Documentation, https://github.com/awslabs/cli-agent-orchestrator#readme
9
+ Author: AWS Labs
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Keywords: agents,ai,claude-code,cli,codex,gemini,kimi,kiro,mcp,multi-agent,orchestration,tmux
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Topic :: Software Development :: Libraries
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: aiofiles>=24.1.0
26
+ Requires-Dist: apscheduler>=3.10.4
27
+ Requires-Dist: click>=8.0.0
28
+ Requires-Dist: fastapi>=0.104.0
29
+ Requires-Dist: fastmcp>=2.14.0
30
+ Requires-Dist: libtmux>=0.51.0
31
+ Requires-Dist: mcp>=1.23.0
32
+ Requires-Dist: pydantic>=2.10.6
33
+ Requires-Dist: python-dotenv>=1.2.2
34
+ Requires-Dist: python-frontmatter>=1.1.0
35
+ Requires-Dist: requests>=2.32.0
36
+ Requires-Dist: sqlalchemy>=2.0.0
37
+ Requires-Dist: uvicorn[standard]>=0.24.0
38
+ Requires-Dist: watchdog==6.0.0
39
+ Requires-Dist: websockets>=12.0
40
+ Description-Content-Type: text/markdown
41
+
42
+ # CLI Agent Orchestrator
43
+
44
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/awslabs/cli-agent-orchestrator)
45
+
46
+ CLI Agent Orchestrator(CAO, pronounced as "kay-oh"), is a lightweight orchestration system for managing multiple AI agent sessions in tmux terminals. Enables Multi-agent collaboration via MCP server.
47
+
48
+ ## Hierarchical Multi-Agent System
49
+
50
+ CLI Agent Orchestrator (CAO) implements a hierarchical multi-agent system that enables complex problem-solving through specialized division of CLI Developer Agents.
51
+
52
+ ![CAO Architecture](./docs/assets/cao_architecture.png)
53
+
54
+ ### Key Features
55
+
56
+ * **Hierarchical orchestration** – CAO's supervisor agent coordinates workflow management and task delegation to specialized worker agents. The supervisor maintains overall project context while agents focus on their domains of expertise.
57
+ * **Session-based isolation** – Each agent operates in isolated tmux sessions, ensuring proper context separation while enabling seamless communication through Model Context Protocol (MCP) servers. This provides both coordination and parallel processing capabilities.
58
+ * **Intelligent task delegation** – CAO automatically routes tasks to appropriate specialists based on project requirements, expertise matching, and workflow dependencies. The system adapts between individual agent work and coordinated team efforts through three orchestration patterns:
59
+ - **Handoff** - Synchronous task transfer with wait-for-completion
60
+ - **Assign** - Asynchronous task spawning for parallel execution
61
+ - **Send Message** - Direct communication with existing agents
62
+ * **Flexible workflow patterns** – CAO supports both sequential coordination for dependent tasks and parallel processing for independent work streams. This allows optimization of both development speed and quality assurance processes.
63
+ * **Flow - Scheduled runs** – Automated execution of workflows at specified intervals using cron-like scheduling, enabling routine tasks and monitoring workflows to run unattended.
64
+ * **Context preservation** – The supervisor agent provides only necessary context to each worker agent, avoiding context pollution while maintaining workflow coherence.
65
+ * **Direct worker interaction and steering** – Users can interact directly with worker agents to provide additional steering, distinguishing from sub-agents features by allowing real-time guidance and course correction.
66
+ * **Tool restrictions** – Control what each agent can do through `role` and `allowedTools`. Built-in roles (`supervisor`, `developer`, `reviewer`) provide sensible defaults, while `allowedTools` gives fine-grained control. CAO translates restrictions to each provider's native enforcement mechanism. See [Tool Restrictions](#tool-restrictions-allowedtools).
67
+ * **Advanced CLI integration** – CAO agents have full access to advanced features of the developer CLI, such as the [sub-agents](https://docs.claude.com/en/docs/claude-code/sub-agents) feature of Claude Code, [Custom Agent](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-custom-agents.html) of Amazon Q Developer for CLI and so on.
68
+
69
+ For detailed project structure and architecture, see [CODEBASE.md](CODEBASE.md).
70
+
71
+ ## Installation
72
+
73
+ ### Requirements
74
+
75
+ - **curl** and **git** — For downloading installers and cloning the repo
76
+ - **Python 3.10 or higher** — CAO requires Python >=3.10 (see [pyproject.toml](pyproject.toml))
77
+ - **tmux 3.3+** — Used for agent session isolation
78
+ - **[uv](https://docs.astral.sh/uv/)** — Fast Python package installer and virtual environment manager
79
+
80
+ ### 1. Install Python 3.10+
81
+
82
+ If you don't have Python 3.10+ installed, use your platform's package manager:
83
+
84
+ ```bash
85
+ # macOS (Homebrew)
86
+ brew install python@3.12
87
+
88
+ # Ubuntu/Debian
89
+ sudo apt update && sudo apt install python3.12 python3.12-venv
90
+
91
+ # Amazon Linux 2023 / Fedora
92
+ sudo dnf install python3.12
93
+ ```
94
+
95
+ Verify your Python version:
96
+
97
+ ```bash
98
+ python3 --version # Should be 3.10 or higher
99
+ ```
100
+
101
+ > **Note:** We recommend using [uv](https://docs.astral.sh/uv/) to manage Python environments instead of system-wide installations like Anaconda. `uv` automatically handles virtual environments and Python version resolution per-project.
102
+
103
+ ### 2. Install tmux (version 3.3 or higher required)
104
+
105
+ ```bash
106
+ bash <(curl -s https://raw.githubusercontent.com/awslabs/cli-agent-orchestrator/refs/heads/main/tmux-install.sh)
107
+ ```
108
+
109
+ ### 3. Install uv
110
+
111
+ ```bash
112
+ curl -LsSf https://astral.sh/uv/install.sh | sh
113
+ source $HOME/.local/bin/env # Add uv to PATH (or restart your shell)
114
+ ```
115
+
116
+ ### 4. Install CLI Agent Orchestrator
117
+
118
+ ```bash
119
+ uv tool install git+https://github.com/awslabs/cli-agent-orchestrator.git@main --upgrade
120
+ ```
121
+
122
+ ### Development Setup
123
+
124
+ For local development, clone the repo and install with `uv sync`:
125
+
126
+ ```bash
127
+ git clone https://github.com/awslabs/cli-agent-orchestrator.git
128
+ cd cli-agent-orchestrator/
129
+ uv sync # Creates .venv/ and installs all dependencies
130
+ uv run cao --help # Verify installation
131
+ ```
132
+
133
+ For development workflow, testing, code quality checks, and project structure, see [DEVELOPMENT.md](DEVELOPMENT.md).
134
+
135
+ ## Prerequisites
136
+
137
+ Before using CAO, install at least one supported CLI agent tool:
138
+
139
+ | Provider | Documentation | Authentication |
140
+ |----------|---------------|----------------|
141
+ | **Kiro CLI** (default) | [Provider docs](docs/kiro-cli.md) · [Installation](https://kiro.dev/docs/kiro-cli) | AWS credentials |
142
+ | **Claude Code** | [Provider docs](docs/claude-code.md) · [Installation](https://docs.anthropic.com/en/docs/claude-code/getting-started) | Anthropic API key |
143
+ | **Codex CLI** | [Provider docs](docs/codex-cli.md) · [Installation](https://github.com/openai/codex) | OpenAI API key |
144
+ | **Gemini CLI** | [Provider docs](docs/gemini-cli.md) · [Installation](https://github.com/google-gemini/gemini-cli) | Google AI API key |
145
+ | **Kimi CLI** | [Provider docs](docs/kimi-cli.md) · [Installation](https://platform.moonshot.cn/docs/kimi-cli) | Moonshot API key |
146
+ | **GitHub Copilot CLI** | [Provider docs](docs/copilot-cli.md) · [Installation](https://github.com/features/copilot/cli) | GitHub auth |
147
+ | **OpenCode CLI** *(experimental — single-agent only, [#203](https://github.com/awslabs/cli-agent-orchestrator/issues/203))* | [Provider docs](docs/opencode-cli.md) · [Installation](https://opencode.ai) | Per-model API key |
148
+ | **Q CLI** | [Installation](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line.html) | AWS credentials |
149
+
150
+ ## Quick Start
151
+
152
+ ### 1. Install Agent Profiles
153
+
154
+ Install the supervisor agent (the orchestrator that delegates to other agents):
155
+
156
+ ```bash
157
+ cao install code_supervisor
158
+ ```
159
+
160
+ Optionally install additional worker agents:
161
+
162
+ ```bash
163
+ cao install developer
164
+ cao install reviewer
165
+ ```
166
+
167
+ You can also install agents from local files or URLs:
168
+
169
+ ```bash
170
+ cao install ./my-custom-agent.md
171
+ cao install https://example.com/agents/custom-agent.md
172
+ ```
173
+
174
+ For details on creating custom agent profiles, see [docs/agent-profile.md](docs/agent-profile.md).
175
+
176
+ ### 2. Start the Server
177
+
178
+ ```bash
179
+ cao-server
180
+ ```
181
+
182
+ ### 3. Launch the Supervisor
183
+
184
+ In another terminal, launch the supervisor agent:
185
+
186
+ ```bash
187
+ cao launch --agents code_supervisor
188
+
189
+ # Or specify a provider
190
+ cao launch --agents code_supervisor --provider kiro_cli
191
+ cao launch --agents code_supervisor --provider claude_code
192
+ cao launch --agents code_supervisor --provider codex
193
+ cao launch --agents code_supervisor --provider gemini_cli
194
+ cao launch --agents code_supervisor --provider kimi_cli
195
+ cao launch --agents code_supervisor --provider copilot_cli
196
+ cao launch --agents code_supervisor --provider opencode_cli
197
+ # Unrestricted access + skip confirmation (DANGEROUS)
198
+ cao launch --agents code_supervisor --yolo
199
+ ```
200
+
201
+ The supervisor will coordinate and delegate tasks to worker agents (developer, reviewer, etc.) as needed using the orchestration patterns.
202
+
203
+ ### 4. Shutdown
204
+
205
+ ```bash
206
+ # Shutdown all cao sessions
207
+ cao shutdown --all
208
+
209
+ # Shutdown specific session
210
+ cao shutdown --session cao-my-session
211
+ ```
212
+
213
+ ### Working with tmux Sessions
214
+
215
+ All agent sessions run in tmux. Useful commands:
216
+
217
+ ```bash
218
+ # List all sessions
219
+ tmux list-sessions
220
+
221
+ # Attach to a session
222
+ tmux attach -t <session-name>
223
+
224
+ # Detach from session (inside tmux)
225
+ Ctrl+b, then d
226
+
227
+ # Switch between windows (inside tmux)
228
+ Ctrl+b, then n # Next window
229
+ Ctrl+b, then p # Previous window
230
+ Ctrl+b, then <number> # Go to window number (0-9)
231
+ Ctrl+b, then w # List all windows (interactive selector)
232
+
233
+ # Delete a session
234
+ cao shutdown --session <session-name>
235
+ ```
236
+
237
+ **List all windows (Ctrl+b, w):**
238
+
239
+ ![Tmux Window Selector](./docs/assets/tmux_all_windows.png)
240
+
241
+
242
+ ## Session Management
243
+
244
+ CAO provides CLI commands for managing sessions programmatically — useful for scripting, CI pipelines, or headless operation.
245
+
246
+ ### Commands
247
+
248
+ | Command | Description |
249
+ |---------|-------------|
250
+ | `cao session list` | List active sessions |
251
+ | `cao session status <name>` | Show conductor status and last output |
252
+ | `cao session status <name> --workers` | Include worker terminal statuses |
253
+ | `cao session send <name> "msg"` | Send message and wait for completion |
254
+ | `cao session send <name> "msg" --async` | Fire-and-forget without waiting |
255
+ | `cao session send <name> "msg" --timeout N` | Wait up to N seconds |
256
+ | `cao shutdown --session <name>` | Shut down a session |
257
+
258
+ ### Headless Launch
259
+
260
+ ```bash
261
+ cao launch --agents supervisor --headless --yolo \
262
+ --session-name my-task --working-directory '/path/to/project' "Your task here"
263
+ ```
264
+
265
+ Add `--async` to send the message and return immediately without waiting for completion:
266
+
267
+ ```bash
268
+ cao launch --agents supervisor --headless --async --yolo \
269
+ --session-name my-task --working-directory '/path/to/project' "Your task here"
270
+ ```
271
+
272
+ > **Note:** Session names are automatically prefixed with `cao-`. Use the prefixed form (e.g., `cao-my-task`) when referencing sessions in commands like `cao session send` and `cao shutdown`.
273
+
274
+ For full details, see the [Session Management skill](skills/cao-session-management/SKILL.md).
275
+
276
+ ## Web UI
277
+
278
+ CAO includes a web dashboard for managing agents, terminals, and flows from the browser.
279
+
280
+ ![CAO Web UI](https://github.com/user-attachments/assets/e7db9261-62b1-4422-b9f5-6fe5f65bdea4)
281
+
282
+ ### Additional Requirements
283
+
284
+ - **Node.js 18+** — Required for the frontend dev server and Codex CLI
285
+
286
+ ```bash
287
+ # macOS (Homebrew)
288
+ brew install node
289
+
290
+ # Ubuntu/Debian
291
+ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -
292
+ sudo apt-get install -y nodejs
293
+
294
+ # Amazon Linux 2023 / Fedora
295
+ sudo dnf install nodejs20
296
+
297
+ # Verify
298
+ node --version # Should be 18 or higher
299
+ ```
300
+
301
+ ### Starting the Web UI
302
+
303
+ **Option A: Development mode** (hot-reload, two terminals needed)
304
+
305
+ ```bash
306
+ # Terminal 1 — start the backend server
307
+ cao-server
308
+
309
+ # Terminal 2 — start the frontend dev server
310
+ cd web/
311
+ npm install # First time only
312
+ npm run dev # Starts on http://localhost:5173
313
+ ```
314
+
315
+ Open http://localhost:5173 in your browser.
316
+
317
+ **Option B: Production mode** (single server, no Vite needed)
318
+
319
+ The built Web UI is bundled into the CAO wheel, so a plain `uv tool install` ships everything you need. Just start the server:
320
+
321
+ ```bash
322
+ cao-server
323
+ ```
324
+
325
+ To rebuild the frontend from source:
326
+
327
+ ```bash
328
+ cd web/
329
+ npm install && npm run build # Outputs to src/cli_agent_orchestrator/web_ui/
330
+ uv tool install . --reinstall
331
+ ```
332
+
333
+ Open http://localhost:9889 in your browser.
334
+
335
+ > **Custom host/port:** `cao-server --host 0.0.0.0 --port 9889` exposes the server to the network — see Security note below.
336
+
337
+ **Remote machine access** — If you're running CAO on a remote host (e.g. dev desktop), set up an SSH tunnel:
338
+
339
+ ```bash
340
+ # Dev mode (proxy both frontend and backend)
341
+ ssh -L 5173:localhost:5173 -L 9889:localhost:9889 your-remote-host
342
+
343
+ # Production mode (backend serves UI directly)
344
+ ssh -L 9889:localhost:9889 your-remote-host
345
+ ```
346
+
347
+ Then open the same URLs (localhost:5173 or localhost:9889) in your local browser.
348
+
349
+ ### Features
350
+
351
+ Manage sessions, spawn agents, create scheduled flows, configure agent directories, and interact with live terminals — all from the browser. Includes live status badges, an inbox for agent-to-agent messaging, output viewer, and provider auto-detection.
352
+
353
+ For frontend architecture and component details, see [web/README.md](web/README.md). For agent directory configuration, see [docs/settings.md](docs/settings.md).
354
+
355
+ ## MCP Server Tools and Orchestration Modes
356
+
357
+ CAO provides a local HTTP server that processes orchestration requests. CLI agents can interact with this server through MCP tools to coordinate multi-agent workflows.
358
+
359
+ ### How It Works
360
+
361
+ Each agent terminal is assigned a unique `CAO_TERMINAL_ID` environment variable. The server uses this ID to:
362
+
363
+ - Route messages between agents
364
+ - Track terminal status (IDLE, PROCESSING, COMPLETED, ERROR)
365
+ - Manage terminal-to-terminal communication via inbox
366
+ - Coordinate orchestration operations
367
+
368
+ When an agent calls an MCP tool, the server identifies the caller by their `CAO_TERMINAL_ID` and orchestrates accordingly.
369
+
370
+ ### Orchestration Modes
371
+
372
+ CAO supports three orchestration patterns:
373
+
374
+ > **Note:** All orchestration modes support optional `working_directory` parameter when enabled via `CAO_ENABLE_WORKING_DIRECTORY=true`. See [Working Directory Support](#working-directory-support) for details.
375
+
376
+ **1. Handoff** - Transfer control to another agent and wait for completion
377
+
378
+ - Creates a new terminal with the specified agent profile
379
+ - Sends the task message and waits for the agent to finish
380
+ - Returns the agent's output to the caller
381
+ - Automatically exits the agent after completion
382
+ - Use when you need **synchronous** task execution with results
383
+
384
+ Example: Sequential code review workflow
385
+
386
+ ![Handoff Workflow](./docs/assets/handoff-workflow.png)
387
+
388
+ **2. Assign** - Spawn an agent to work independently (async)
389
+
390
+ - Creates a new terminal with the specified agent profile
391
+ - Sends the task message with callback instructions
392
+ - Returns immediately with the terminal ID
393
+ - Agent continues working in the background
394
+ - Assigned agent sends results back to supervisor via `send_message` when complete
395
+ - Messages are queued for delivery if the supervisor is busy (common in parallel workflows)
396
+ - Use for **asynchronous** task execution or fire-and-forget operations
397
+
398
+ Example: A supervisor assigns parallel data analysis tasks to multiple analysts while using handoff to sequentially generate a report template, then combines all results.
399
+
400
+ See [examples/assign](examples/assign) for the complete working example.
401
+
402
+ ![Parallel Data Analysis](./docs/assets/parallel-data-analysis.png)
403
+
404
+ **3. Send Message** - Communicate with an existing agent
405
+
406
+ - Sends a message to a specific terminal's inbox
407
+ - Messages are queued and delivered when the terminal is idle
408
+ - Enables ongoing collaboration between agents
409
+ - Common for **swarm** operations where multiple agents coordinate dynamically
410
+ - Use for iterative feedback or multi-turn conversations
411
+
412
+ Example: Multi-role feature development
413
+
414
+ ![Multi-role Feature Development](./docs/assets/multi-role-feature-development.png)
415
+
416
+ ### Custom Orchestration
417
+
418
+ The `cao-server` runs on `http://localhost:9889` by default and exposes REST APIs for session management, terminal control, and messaging. The CLI commands (`cao launch`, `cao shutdown`) and MCP server tools (`handoff`, `assign`, `send_message`) are just examples of how these APIs can be packaged together.
419
+
420
+ You can combine the three orchestration modes above into custom workflows, or create entirely new orchestration patterns using the underlying APIs to fit your specific needs.
421
+
422
+ For complete API documentation, see [docs/api.md](docs/api.md).
423
+
424
+ ## Flows - Scheduled Agent Sessions
425
+
426
+ Flows allow you to schedule agent sessions to run automatically based on cron expressions.
427
+
428
+ ### Prerequisites
429
+
430
+ Install the agent profile you want to use:
431
+
432
+ ```bash
433
+ cao install developer
434
+ ```
435
+
436
+ ### Quick Start
437
+
438
+ The example flow asks a simple world trivia question every morning at 7:30 AM.
439
+
440
+ ```bash
441
+ # 1. Start the cao server
442
+ cao-server
443
+
444
+ # 2. In another terminal, add a flow
445
+ cao flow add examples/flow/morning-trivia.md
446
+
447
+ # 3. List flows to see schedule and status
448
+ cao flow list
449
+
450
+ # 4. Manually run a flow (optional - for testing)
451
+ cao flow run morning-trivia
452
+
453
+ # 5. View flow execution (after it runs)
454
+ tmux list-sessions
455
+ tmux attach -t <session-name>
456
+
457
+ # 6. Cleanup session when done
458
+ cao shutdown --session <session-name>
459
+ ```
460
+
461
+ **IMPORTANT:** The `cao-server` must be running for flows to execute on schedule.
462
+
463
+ ### Example 1: Simple Scheduled Task
464
+
465
+ A flow that runs at regular intervals with a static prompt (no script needed):
466
+
467
+ **File: `daily-standup.md`**
468
+
469
+ ```yaml
470
+ ---
471
+ name: daily-standup
472
+ schedule: "0 9 * * 1-5" # 9am weekdays
473
+ agent_profile: developer
474
+ provider: kiro_cli # Optional, defaults to kiro_cli
475
+ ---
476
+
477
+ Review yesterday's commits and create a standup summary.
478
+ ```
479
+
480
+ ### Example 2: Conditional Execution with Health Check
481
+
482
+ A flow that monitors a service and only executes when there's an issue:
483
+
484
+ **File: `monitor-service.md`**
485
+
486
+ ```yaml
487
+ ---
488
+ name: monitor-service
489
+ schedule: "*/5 * * * *" # Every 5 minutes
490
+ agent_profile: developer
491
+ script: ./health-check.sh
492
+ ---
493
+
494
+ The service at [[url]] is down (status: [[status_code]]).
495
+ Please investigate and triage the issue:
496
+ 1. Check recent deployments
497
+ 2. Review error logs
498
+ 3. Identify root cause
499
+ 4. Suggest remediation steps
500
+ ```
501
+
502
+ **Script: `health-check.sh`**
503
+
504
+ ```bash
505
+ #!/bin/bash
506
+ URL="https://api.example.com/health"
507
+ STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$URL")
508
+
509
+ if [ "$STATUS" != "200" ]; then
510
+ # Service is down - execute flow
511
+ echo "{\"execute\": true, \"output\": {\"url\": \"$URL\", \"status_code\": \"$STATUS\"}}"
512
+ else
513
+ # Service is healthy - skip execution
514
+ echo "{\"execute\": false, \"output\": {}}"
515
+ fi
516
+ ```
517
+
518
+ ### Flow Commands
519
+
520
+ ```bash
521
+ # Add a flow
522
+ cao flow add daily-standup.md
523
+
524
+ # List all flows (shows schedule, next run time, enabled status)
525
+ cao flow list
526
+
527
+ # Enable/disable a flow
528
+ cao flow enable daily-standup
529
+ cao flow disable daily-standup
530
+
531
+ # Manually run a flow (ignores schedule)
532
+ cao flow run daily-standup
533
+
534
+ # Remove a flow
535
+ cao flow remove daily-standup
536
+ ```
537
+
538
+ ## Working Directory Support
539
+
540
+ CAO supports specifying working directories for agent handoff/delegation operations. By default this is disabled to prevent agents from hallucinating directory paths.
541
+
542
+ All paths are canonicalized via `realpath` and validated against a security policy:
543
+
544
+ - **Allowed:** any real directory that is not a blocked system path — including `~/`, external volumes (e.g., `/Volumes/workplace`), and custom paths like `/opt/projects`
545
+ - **Blocked:** system directories (`/`, `/etc`, `/var`, `/tmp`, `/proc`, `/sys`, `/root`, `/boot`, `/bin`, `/sbin`, `/usr/bin`, `/usr/sbin`, `/lib`, `/lib64`, `/dev`)
546
+
547
+ For configuration and usage details, see [docs/working-directory.md](docs/working-directory.md).
548
+
549
+ ## Cross-Provider Orchestration
550
+
551
+ By default, worker agents inherit the provider of the terminal that spawned them. To run specific agents on different providers, add a `provider` key to the agent profile frontmatter:
552
+
553
+ ```markdown
554
+ ---
555
+ name: developer
556
+ description: Developer Agent
557
+ provider: claude_code
558
+ ---
559
+ ```
560
+
561
+ Valid values: `kiro_cli`, `claude_code`, `codex`, `q_cli`, `gemini_cli`, `kimi_cli`, `copilot_cli`.
562
+
563
+ When a supervisor calls `assign` or `handoff`, CAO reads the worker's agent profile and uses the declared provider if present. If the key is missing or invalid, the worker falls back to the supervisor's provider.
564
+
565
+ The `cao launch --provider` flag always takes precedence — it is treated as an explicit override and the profile's `provider` key is not consulted for the initial session.
566
+
567
+ For ready-to-use examples, see [`examples/cross-provider/`](examples/cross-provider/).
568
+
569
+ ## Tool Restrictions
570
+
571
+ CAO controls what tools each agent can use through `role` in the agent profile. Built-in roles (`supervisor`, `developer`, `reviewer`) map to sensible defaults, and `allowedTools` provides fine-grained override when needed. CAO translates restrictions to each provider's native enforcement mechanism — 5 of 7 providers support hard enforcement.
572
+
573
+ ```yaml
574
+ ---
575
+ name: my_agent
576
+ role: supervisor # @cao-mcp-server, fs_read, fs_list
577
+ ---
578
+ ```
579
+
580
+ ```bash
581
+ cao launch --agents code_supervisor # Uses role defaults (confirmation prompt shown)
582
+ cao launch --agents code_supervisor --auto-approve # Skip prompt (restrictions still enforced)
583
+ cao launch --agents code_supervisor --yolo # Unrestricted access (WARNING shown)
584
+ ```
585
+
586
+ For the full reference — roles, tool vocabulary, custom roles, launch prompts, provider enforcement, and known limitations — see [docs/tool-restrictions.md](docs/tool-restrictions.md).
587
+
588
+ ## Skills
589
+
590
+ Skills are portable, structured guides (following the universal [SKILL.md](https://github.com/anthropics/skills) format) that encode domain knowledge for AI agents. They work across AI coding assistants (Claude Code, Kiro CLI, Gemini CLI, Codex CLI, Kimi CLI, GitHub Copilot, Cursor, OpenCode, LobeHub), agent frameworks ([Strands Agents SDK](https://strandsagents.com/docs/user-guide/concepts/plugins/skills/), [Microsoft Agent Framework](https://devblogs.microsoft.com/agent-framework/give-your-agents-domain-expertise-with-agent-skills-in-microsoft-agent-framework/)), and other tools that support the SKILL.md format — allowing any agent to follow the same expert playbook regardless of provider.
591
+
592
+ CAO includes the following built-in skills:
593
+
594
+ | Skill | Description |
595
+ |-------|-------------|
596
+ | **[cao-provider](skills/cao-provider/SKILL.md)** | Scaffold a new CLI agent provider for CAO. Guides through the full implementation: ProviderType enum, provider class with regex patterns and status detection, ProviderManager registration, tool restriction wiring, unit/e2e tests, and documentation. Includes 20 lessons learnt from building 7 existing providers. |
597
+
598
+ ### Loading Skills
599
+
600
+ Each AI coding tool loads skills from a different location. Copy or symlink the skill directory to the appropriate path for your tool:
601
+
602
+ | Tool | Skill Location | Command |
603
+ |------|---------------|---------|
604
+ | **Claude Code** | `.claude/skills/` | `cp -r skills/cao-provider .claude/skills/` |
605
+ | **Kiro CLI** | `.kiro/skills/` | `cp -r skills/cao-provider .kiro/skills/` |
606
+ | **Amazon Q CLI** | `.amazonq/skills/` | `cp -r skills/cao-provider .amazonq/skills/` |
607
+ | **Other tools** | Check your tool's docs for skill/prompt loading conventions |
608
+
609
+ Then ask your AI coding assistant to create a new provider:
610
+
611
+ ```
612
+ > I want to add support for Aider CLI as a new CAO provider
613
+ ```
614
+
615
+ The assistant will follow the skill's step-by-step guide, reference the provider template, and apply lessons learnt from existing providers.
616
+
617
+ ### Managed Skills
618
+
619
+ CAO also manages skills that are shared across all agent sessions. Builtin skills (`cao-supervisor-protocols`, `cao-worker-protocols`) are auto-seeded when the `cao-server` starts — no `cao init` required.
620
+
621
+ ```bash
622
+ # List installed skills
623
+ cao skills list
624
+
625
+ # Install a custom skill from a local folder
626
+ cao skills add ./my-coding-standards
627
+
628
+ # Update an existing skill (overwrite)
629
+ cao skills add ./my-coding-standards --force
630
+
631
+ # Remove a skill
632
+ cao skills remove my-coding-standards
633
+ ```
634
+
635
+ Skills are delivered to each provider automatically:
636
+
637
+ | Provider | Delivery Method |
638
+ |----------|----------------|
639
+ | Kiro CLI | Native `skill://` resources (progressive loading) |
640
+ | Claude Code, Codex, Gemini CLI, Kimi CLI | Runtime prompt injection (every terminal creation) |
641
+ | Copilot CLI | Baked into `.agent.md` at install time |
642
+
643
+ When you add or remove a skill, all providers pick up the change automatically. Copilot agent files are refreshed immediately; other providers pick up changes on the next terminal creation.
644
+
645
+ **Updating skills:** Use `cao skills add ./my-skill --force` to overwrite an existing skill. Without `--force`, the command errors if the skill already exists. Builtin skills are auto-seeded on server startup but are never overwritten — to update a builtin after a CAO upgrade, remove it first with `cao skills remove` then restart the server.
646
+
647
+ For full details, see [docs/skills.md](docs/skills.md).
648
+
649
+ ## Plugins
650
+
651
+ Plugins are observer-only extensions that react to server-side events inside `cao-server` — session and terminal lifecycle changes, and message delivery between agents. Typical uses include forwarding inter-agent messages to external chat (Discord, Slack), audit logging, and observability/metrics export.
652
+
653
+ Plugins are standard Python packages discovered automatically via the `cao.plugins` entry-point group at server startup. Install a plugin into the same environment as `cao-server`, configure it, and restart the server — no registration step required.
654
+
655
+ - **Installation, events, and troubleshooting:** [docs/plugins.md](docs/plugins.md)
656
+ - **Ready-to-run example:** [examples/plugins/cao-discord/](examples/plugins/cao-discord/)
657
+ - **Author your own plugin:** use the [cao-plugin skill](skills/cao-plugin/SKILL.md)
658
+
659
+ ## Security
660
+
661
+ The server is designed for **localhost-only use**. The WebSocket terminal endpoint (`/terminals/{id}/ws`) provides full PTY access and will reject connections from non-loopback addresses. Do not expose the server to untrusted networks without adding authentication.
662
+
663
+ ### DNS Rebinding Protection
664
+
665
+ The CAO server validates HTTP `Host` headers to prevent [DNS rebinding attacks](https://owasp.org/www-community/attacks/DNS_Rebinding). Only `localhost` and `127.0.0.1` are accepted by default — requests with other hostnames are rejected with `400 Bad Request`.
666
+
667
+ **Note:** If you need to expose the server on a network (not recommended for development use), be aware that the Host header validation will reject requests unless the hostname matches the allowed list.
668
+
669
+ See [SECURITY.md](SECURITY.md) for vulnerability reporting, security scanning, and best practices.
670
+
671
+ ## Contributing
672
+
673
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on contributing to this project.
674
+
675
+ ## Releases
676
+
677
+ CAO publishes to [PyPI](https://pypi.org/project/cli-agent-orchestrator/) via an OIDC-authenticated GitHub Actions pipeline (TestPyPI → smoke test → maintainer-approved prod). See [docs/RELEASING.md](docs/RELEASING.md) for the cut-a-release runbook, one-time setup, and troubleshooting.
678
+
679
+ ## License
680
+
681
+ This project is licensed under the Apache-2.0 License.