agentcorp-broker 0.1.0-alpha.1

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 (71) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/CONTRIBUTING.md +20 -0
  3. package/LICENSE +201 -0
  4. package/README.md +250 -0
  5. package/SECURITY.md +23 -0
  6. package/dist/audit.d.ts +25 -0
  7. package/dist/audit.js +203 -0
  8. package/dist/audit.js.map +1 -0
  9. package/dist/broker.d.ts +103 -0
  10. package/dist/broker.js +805 -0
  11. package/dist/broker.js.map +1 -0
  12. package/dist/cli.d.ts +2 -0
  13. package/dist/cli.js +712 -0
  14. package/dist/cli.js.map +1 -0
  15. package/dist/config.d.ts +3 -0
  16. package/dist/config.js +41 -0
  17. package/dist/config.js.map +1 -0
  18. package/dist/console/console.css +794 -0
  19. package/dist/console/console.js +802 -0
  20. package/dist/console/index.html +309 -0
  21. package/dist/credentials.d.ts +16 -0
  22. package/dist/credentials.js +72 -0
  23. package/dist/credentials.js.map +1 -0
  24. package/dist/database.d.ts +119 -0
  25. package/dist/database.js +1356 -0
  26. package/dist/database.js.map +1 -0
  27. package/dist/diagnostics.d.ts +44 -0
  28. package/dist/diagnostics.js +357 -0
  29. package/dist/diagnostics.js.map +1 -0
  30. package/dist/errors.d.ts +5 -0
  31. package/dist/errors.js +14 -0
  32. package/dist/errors.js.map +1 -0
  33. package/dist/index.d.ts +23 -0
  34. package/dist/index.js +15 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/mcp.d.ts +3 -0
  37. package/dist/mcp.js +215 -0
  38. package/dist/mcp.js.map +1 -0
  39. package/dist/migrations.d.ts +13 -0
  40. package/dist/migrations.js +266 -0
  41. package/dist/migrations.js.map +1 -0
  42. package/dist/policy.d.ts +22 -0
  43. package/dist/policy.js +33 -0
  44. package/dist/policy.js.map +1 -0
  45. package/dist/server.d.ts +49 -0
  46. package/dist/server.js +529 -0
  47. package/dist/server.js.map +1 -0
  48. package/dist/stdio-adapter.d.ts +230 -0
  49. package/dist/stdio-adapter.js +406 -0
  50. package/dist/stdio-adapter.js.map +1 -0
  51. package/dist/tui.d.ts +26 -0
  52. package/dist/tui.js +291 -0
  53. package/dist/tui.js.map +1 -0
  54. package/dist/types.d.ts +355 -0
  55. package/dist/types.js +85 -0
  56. package/dist/types.js.map +1 -0
  57. package/docs/ARCHITECTURE.md +119 -0
  58. package/docs/README.md +37 -0
  59. package/docs/RELEASING.md +228 -0
  60. package/docs/ROADMAP.md +112 -0
  61. package/docs/cli-reference.md +133 -0
  62. package/docs/dogfooding-report.md +83 -0
  63. package/docs/getting-started.md +228 -0
  64. package/docs/guides/antigravity-setup.md +84 -0
  65. package/docs/guides/claude-cursor-setup.md +76 -0
  66. package/docs/guides/codex-setup.md +75 -0
  67. package/docs/guides/human-console.md +177 -0
  68. package/docs/mcp-tools-reference.md +235 -0
  69. package/docs/policy-guide.md +105 -0
  70. package/examples/org.toml +65 -0
  71. package/package.json +68 -0
@@ -0,0 +1,133 @@
1
+ # CLI Reference Manual
2
+
3
+ AgentCorp provides a comprehensive CLI for daemon management, role-bound stdio proxying, policy administration, and terminal-native human oversight.
4
+
5
+ ---
6
+
7
+ ## Global Options
8
+
9
+ All commands accept the following global flags:
10
+
11
+ * `--config <path>`: Path to organization configuration file (default: `org.toml`).
12
+ * `--db <path>`: Path to SQLite broker database (default: `.agentcorp/agentcorp.db`).
13
+ * `--credentials <path>`: Optional credentials-file override. By default, AgentCorp uses `.agentcorp/credentials.json` beside the selected configuration.
14
+
15
+ ---
16
+
17
+ ## 1. Setup & Daemon Lifecycle
18
+
19
+ ### `agentcorp init`
20
+ Creates a starter `org.toml` and initializes credentials under `.agentcorp/credentials.json`.
21
+
22
+ * **Options**:
23
+ * `--force`: Overwrite existing files.
24
+
25
+ ### `agentcorp validate`
26
+ Validates `org.toml` syntax, role graphs, peer connectivity, and policy schemas.
27
+
28
+ ### `agentcorp start`
29
+ Starts the central broker daemon hosting Streamable HTTP MCP (`/mcp`), Admin REST API (`/api/*`), and real-time SSE (`/api/events`).
30
+
31
+ * **Options**:
32
+ * `--port <number>`: HTTP port to listen on. The default `0` asks the operating system for an available local port and records the selection in `.agentcorp/daemon.json`.
33
+ * `--host <string>`: Host address to bind to (default: `127.0.0.1`).
34
+ * `--daemon`: Runs detached in the background.
35
+ * `--daemon-file <path>`: Overrides the daemon control-file location.
36
+
37
+ ### `agentcorp stop`
38
+ Sends a graceful termination signal (`SIGTERM`) to the running background daemon.
39
+
40
+ ### `agentcorp status`
41
+ Checks whether the central broker daemon is running, healthy, and reports active roles and uptime.
42
+
43
+ The daemon health response includes its live process ID and start time. If the
44
+ local control file is stale, `status` repairs it from that live identity. The
45
+ `stop` command refuses to signal an unreachable or unverifiable PID, preventing
46
+ an old control file from terminating an unrelated process.
47
+
48
+ ---
49
+
50
+ ## 2. Human Oversight & Console
51
+
52
+ ### `agentcorp console`
53
+ Launches the human oversight console.
54
+
55
+ * **Default**: Renders the terminal-native ANSI status summary and queues pending approvals for interactive review.
56
+ * **Options**:
57
+ * `--browser`, `--web`: Opens the dark glassmorphic web dashboard in your default browser.
58
+
59
+ ### `agentcorp review`
60
+ Top-level alias for `agentcorp approvals review`. Directly launches the interactive terminal keyboard sign-off loop (`[a]`, `[e]`, `[r]`, `[s]`, `[q]`).
61
+
62
+ ### `agentcorp approvals list`
63
+ Outputs all pending approvals in structured JSON.
64
+
65
+ ### `agentcorp approvals approve <approval-id>`
66
+ Signs off on a pending approval.
67
+
68
+ * **Options**:
69
+ * `--note <text>`: Reviewer decision note.
70
+ * `--payload <json>`: Edited message payload as JSON (delivering modified content).
71
+
72
+ ### `agentcorp approvals reject <approval-id>`
73
+ Rejects a pending approval.
74
+
75
+ * **Options**:
76
+ * `--note <text>`: Rejection reason or feedback for the agent.
77
+
78
+ ---
79
+
80
+ ## 3. Runtime Policies
81
+
82
+ ### `agentcorp policies list`
83
+ Lists all active and disabled runtime policies.
84
+
85
+ ### `agentcorp policies set <json>`
86
+ Creates or updates a policy rule from a JSON definition.
87
+
88
+ ### `agentcorp policies enable <policy-id>`
89
+ Enables a disabled policy rule.
90
+
91
+ ### `agentcorp policies disable <policy-id>`
92
+ Disables a policy rule without deleting its audit history.
93
+
94
+ ---
95
+
96
+ ## 4. MCP Stdio Proxy
97
+
98
+ ### `agentcorp mcp --role <role-id>`
99
+ Runs a role-bound stdio MCP server for agent hosts that only spawn local commands (e.g. Antigravity IDE, Codex, Claude Code, Cursor).
100
+
101
+ * **Options**:
102
+ * `--role <id>` *(required)*: Role identity to bind to this process.
103
+ * `--no-spawn`: Disables automatic background spawning of the daemon if not running.
104
+ * `--daemon-url <url>`: Explicit daemon URL to connect to.
105
+
106
+ ---
107
+
108
+ ## 5. Audit & Compliance
109
+
110
+ ### `agentcorp audit export`
111
+ Generates human-readable Markdown (`coord/audit.md`) and structured JSON (`coord/audit.json`) snapshots of broker state for operational review. These files are ignored by default because they can contain project conversation metadata; store or share them only after review.
112
+
113
+ * **Options**:
114
+ * `--out <dir>`: Output directory (default: `coord`).
115
+ * `--limit <number>`: Limit the number of exported items per category (most recent).
116
+ * `--since <iso-date>`: Only include records created or updated since the specified ISO timestamp.
117
+
118
+ ---
119
+
120
+ ## 6. Storage Maintenance & Bounding
121
+
122
+ ### `agentcorp prune`
123
+ Prunes terminal, resolved history (completed/failed/cancelled tasks, associated messages, events, and resolved approvals) older than a specified retention threshold. Active tasks and pending approvals are always preserved.
124
+
125
+ * **Options**:
126
+ * `--older-than <days>`: Age threshold in days for terminal records to prune (default: `30`).
127
+ * With no execution flag, reports the count of eligible records without modifying or deleting database rows (safe default).
128
+ * `--execute`: Performs the deletion described by the preview.
129
+ * `--delete-artifacts`: Deletes associated artifacts instead of detaching them.
130
+ * `--compact`: Automatically runs a SQLite WAL checkpoint (`TRUNCATE`) and `VACUUM` after successful pruning.
131
+
132
+ ### `agentcorp compact`
133
+ Executes an immediate SQLite WAL checkpoint (`PRAGMA wal_checkpoint(TRUNCATE)`) and compaction (`VACUUM`) to reclaim disk space from pruned records and truncate write-ahead logs.
@@ -0,0 +1,83 @@
1
+ # AgentCorp Dogfooding Report
2
+
3
+ Date: 2026-09-05
4
+ Scenario: Codex acting as architect/reviewer and Gemini in Antigravity acting as
5
+ developer while improving AgentCorp itself.
6
+
7
+ ## Executive assessment
8
+
9
+ AgentCorp was useful as a durable, policy-controlled coordination ledger. It
10
+ made task ownership, human approval, implementation evidence, and review
11
+ decisions more explicit than ordinary copy-and-paste chat. The core broker is a
12
+ credible developer-preview tool.
13
+
14
+ The experience was not yet autonomous. AgentCorp reliably stored and exposed
15
+ work, but the human repeatedly had to tell an idle agent that new work was
16
+ available. At one point the Gemini host entered a goal-verification loop and
17
+ showed an MCP error. These are host-lifecycle failures rather than lost broker
18
+ state, but they are central to the user's experience and must be treated as
19
+ product requirements.
20
+
21
+ ## What worked well
22
+
23
+ - Stable task, message, artifact, and approval IDs made handoffs auditable.
24
+ - Human approval gates prevented an eager implementer from receiving an
25
+ unreviewed proposal and prevented automatic final completion.
26
+ - `get_work_queue` reduced several reconciliation calls to one prioritized view.
27
+ - `accept_handoff` plus idempotency keys reduced duplicate execution risk.
28
+ - The central SQLite daemon preserved coordination state across client and
29
+ daemon restarts.
30
+ - Concise reports and on-demand artifacts kept the coordination database and
31
+ model context smaller than copying whole files through chat.
32
+ - Independent architectural review found real reliability and release defects,
33
+ and the developer could return targeted evidence against them.
34
+
35
+ ## Friction observed
36
+
37
+ - MCP exposes tools but has no standard operation for starting a new model turn.
38
+ - IDE integrations can retain an older stdio adapter until their MCP connection
39
+ is restarted.
40
+ - Presence indicates recent tool activity, not that a host can accept work now.
41
+ - A host-side agent loop can continue even when the broker considers its task
42
+ complete; AgentCorp currently cannot interrupt it.
43
+ - Manual “Gemini replied” and “check AgentCorp” prompts were still needed.
44
+ - Reports can become verbose or repetitive unless agents are instructed to send
45
+ IDs, summaries, and bounded evidence.
46
+
47
+ ## Practical verdict
48
+
49
+ The coordination and safety layer is effective enough for an **alpha developer
50
+ preview**, especially for local two-agent workflows with an engaged human. It
51
+ is not yet a hands-off orchestration platform, a hostile multi-tenant security
52
+ boundary, or a guarantee that every IDE agent will resume automatically.
53
+
54
+ ## Autonomous invocation direction
55
+
56
+ Autonomous invocation should be an adapter capability above the broker, not a
57
+ special case embedded into the task database.
58
+
59
+ Proposed shape:
60
+
61
+ 1. The broker commits an approved-work event to a transactional outbox.
62
+ 2. A runner service claims the event with a time-limited lease and a stable
63
+ idempotency key.
64
+ 3. A host adapter translates the generic request into something that host
65
+ supports: subprocess launch, IDE extension command, webhook, notification,
66
+ or “not supported”.
67
+ 4. The adapter reports accepted, started, heartbeat, completed, failed, or
68
+ timed-out state back to AgentCorp.
69
+ 5. Retries use bounded backoff, deduplication, attempt limits, and a circuit
70
+ breaker. Human stop and pause controls always win.
71
+
72
+ Each role should declare invocation capabilities such as `manual`, `notify`, or
73
+ `managed_runner`. A policy should separately decide whether approved work may
74
+ be invoked automatically. This keeps approval and invocation distinct: an
75
+ approved task is authorized work, but it is not automatically permission to
76
+ spawn an unrestricted process.
77
+
78
+ The first implementation should be a narrow feasibility spike for one host,
79
+ with a fake adapter for deterministic tests. The general interface should be
80
+ extracted only after a second, meaningfully different host proves which parts
81
+ are portable. Essential safeguards are workspace isolation, command allowlists,
82
+ resource and token budgets, lease expiry, deduplication, observable attempt
83
+ history, and a global kill switch.
@@ -0,0 +1,228 @@
1
+ # AgentCorp Beginner Setup and First Workflow
2
+
3
+ This guide takes you from an empty terminal to two AI agents collaborating on
4
+ one project. You do not need prior Model Context Protocol (MCP) experience.
5
+
6
+ AgentCorp is a local coordination service. It records tasks and messages,
7
+ checks who may communicate, pauses sensitive actions for human approval, and
8
+ keeps an audit trail. It does **not** choose an AI model, provide an AI
9
+ subscription, sandbox an agent's shell access, or wake an idle agent inside an
10
+ IDE.
11
+
12
+ ## 1. Install the prerequisites
13
+
14
+ Install:
15
+
16
+ - Node.js 22.13 or newer from [nodejs.org](https://nodejs.org/).
17
+ - Two MCP-capable agent hosts if you want to test collaboration, such as Codex
18
+ and Antigravity, Claude, or Cursor.
19
+ - Git if you are installing from source.
20
+
21
+ Confirm Node and npm are available:
22
+
23
+ ```sh
24
+ node --version
25
+ npm --version
26
+ ```
27
+
28
+ The Node version must be `v22.13.0` or newer.
29
+
30
+ ## 2. Install AgentCorp
31
+
32
+ Before the first npm publication, clone the repository and build it:
33
+
34
+ ```sh
35
+ git clone <AGENTCORP_REPOSITORY_URL>
36
+ cd AgentCorp
37
+ npm install
38
+ npm run build
39
+ ```
40
+
41
+ Use `node /absolute/path/to/AgentCorp/dist/cli.js` wherever the examples below
42
+ say `agentcorp`.
43
+
44
+ After the package is published, install it globally instead:
45
+
46
+ ```sh
47
+ npm install --global agentcorp-broker@alpha
48
+ agentcorp --version
49
+ ```
50
+
51
+ The `alpha` tag is intentional while AgentCorp is a developer preview.
52
+
53
+ ## 3. Initialize AgentCorp in your project
54
+
55
+ Open a terminal in the software project where the agents will collaborate. Do
56
+ not run this in the AgentCorp source directory unless AgentCorp itself is the
57
+ project being coordinated.
58
+
59
+ ```sh
60
+ cd /path/to/your-project
61
+ agentcorp init
62
+ agentcorp validate
63
+ ```
64
+
65
+ Initialization creates:
66
+
67
+ ```text
68
+ your-project/
69
+ |-- org.toml team roles and approval policies
70
+ `-- .agentcorp/
71
+ `-- credentials.json private local role and admin tokens
72
+ ```
73
+
74
+ Add `.agentcorp/` to that project's `.gitignore`. Never commit or paste the
75
+ credentials file into an issue, prompt, chat, or audit artifact.
76
+
77
+ The starter `org.toml` defines:
78
+
79
+ - `architect`: plans and reviews work.
80
+ - `developer`: implements and reports work.
81
+ - Human approval for proposals and final task completion.
82
+ - Automatic delivery for narrowly tagged read-only reports and status updates.
83
+
84
+ Edit the display names, models, capabilities, and allowed peers as needed, then
85
+ run `agentcorp validate` again. Policies fail closed: if no enabled rule
86
+ matches, AgentCorp asks a human to approve the operation.
87
+
88
+ ## 4. Start and inspect the daemon
89
+
90
+ Start the local broker in the background:
91
+
92
+ ```sh
93
+ agentcorp start --daemon
94
+ agentcorp status
95
+ agentcorp doctor
96
+ ```
97
+
98
+ By default it listens only on `127.0.0.1` and asks the operating system for an
99
+ available port. The selected address is recorded in `.agentcorp/daemon.json`,
100
+ so agents and the console discover it automatically. This avoids collisions
101
+ with applications and Windows reserved port ranges. Keep the loopback binding
102
+ for normal local use. Runtime data, logs, and the SQLite database stay in the
103
+ project's `.agentcorp/` directory.
104
+
105
+ ## 5. Connect the first agent
106
+
107
+ Every agent receives its own role-bound MCP process. Use the absolute path to
108
+ the collaboration project's `org.toml`; IDEs do not always start MCP processes
109
+ from the project directory.
110
+
111
+ After npm installation, the generic command is:
112
+
113
+ ```text
114
+ agentcorp --config /absolute/path/to/your-project/org.toml mcp --role architect
115
+ ```
116
+
117
+ For the developer connection, change only the final role:
118
+
119
+ ```text
120
+ agentcorp --config /absolute/path/to/your-project/org.toml mcp --role developer
121
+ ```
122
+
123
+ If you are running from source, replace `agentcorp` with `node` and put the
124
+ absolute path to `dist/cli.js` before the other arguments.
125
+
126
+ The exact configuration-file format differs by host. Copy the relevant guide:
127
+
128
+ - [Codex setup](guides/codex-setup.md)
129
+ - [Antigravity setup](guides/antigravity-setup.md)
130
+ - [Claude and Cursor setup](guides/claude-cursor-setup.md)
131
+
132
+ Restart each host's MCP connection after editing its configuration. Ask each
133
+ agent to call `whoami`. One response should say `architect` and the other
134
+ `developer`. If both roles are correct, ask each to call `get_work_queue`.
135
+
136
+ ## 6. Complete the first collaboration
137
+
138
+ Give both agents this standing instruction:
139
+
140
+ > At session start and after every handoff or status change, call
141
+ > `get_work_queue`. Follow the highest-priority applicable next action. Use
142
+ > concise task and message IDs instead of copying large histories.
143
+
144
+ Then use this workflow:
145
+
146
+ 1. Tell the architect the goal and ask it to create a task for `developer` and
147
+ send a linked `proposal` message.
148
+ 2. Run `agentcorp review`. Inspect the proposed instructions, then approve,
149
+ edit and approve, reject with feedback, or skip them.
150
+ 3. Tell the developer to call `get_work_queue`. It should now see the approved
151
+ proposal and task.
152
+ 4. The developer calls `accept_handoff`, implements the work, runs tests, sends
153
+ a concise `report`, and requests the `awaiting_review` task state.
154
+ 5. The architect reviews the code and evidence, then returns a verdict.
155
+ 6. When completion is requested, use `agentcorp review` again for final human
156
+ sign-off.
157
+
158
+ The web console provides the same operational view:
159
+
160
+ ```sh
161
+ agentcorp console --browser
162
+ ```
163
+
164
+ MCP is passive: an approved message becomes available immediately, but
165
+ AgentCorp cannot make an idle IDE model start a new turn. Until host adapters
166
+ are added, you may need to prompt the receiving agent to check its work queue.
167
+
168
+ ## 7. Keep storage bounded
169
+
170
+ Preview old resolved history without deleting it:
171
+
172
+ ```sh
173
+ agentcorp prune --older-than 30
174
+ ```
175
+
176
+ After checking the preview, execute the deletion and compact the database:
177
+
178
+ ```sh
179
+ agentcorp prune --older-than 30 --execute --compact
180
+ ```
181
+
182
+ Export only the recent audit window you need:
183
+
184
+ ```sh
185
+ agentcorp audit export --limit 100
186
+ ```
187
+
188
+ Audit exports go to the ignored `coord/` directory and can contain project
189
+ metadata. Review them before sharing. Back up `org.toml` and, if you need to
190
+ preserve coordination history, the entire `.agentcorp/` directory while the
191
+ daemon is stopped.
192
+
193
+ ## 8. Troubleshooting
194
+
195
+ If an IDE shows an MCP error:
196
+
197
+ 1. Run `agentcorp status` and `agentcorp doctor` in the collaboration project.
198
+ 2. Confirm the MCP entry uses an absolute `org.toml` path.
199
+ 3. Confirm the configured role exists in `org.toml`.
200
+ 4. Run `agentcorp validate`.
201
+ 5. Restart the daemon with `agentcorp stop`, then `agentcorp start --daemon`.
202
+ 6. Restart the IDE's MCP connection so it loads the installed adapter version.
203
+ 7. Inspect `.agentcorp/daemon.log` locally. Remove secrets before sharing any
204
+ excerpt.
205
+
206
+ If a proposal is missing from the developer queue, check `agentcorp review`.
207
+ Pending proposals are deliberately invisible to the assignee until approved.
208
+
209
+ If npm reports `agentcorp: command not found`, either reopen the terminal after
210
+ global installation or use `npx agentcorp-broker@alpha --version` to verify the
211
+ package without depending on the global executable path.
212
+
213
+ ## 9. Stop or remove AgentCorp
214
+
215
+ Stop the project daemon:
216
+
217
+ ```sh
218
+ agentcorp stop
219
+ ```
220
+
221
+ Uninstall the global CLI without deleting project data:
222
+
223
+ ```sh
224
+ npm uninstall --global agentcorp-broker
225
+ ```
226
+
227
+ Only delete `.agentcorp/` when you intentionally want to erase that project's
228
+ credentials, messages, tasks, approvals, and audit history.
@@ -0,0 +1,84 @@
1
+ # Google Antigravity Setup Guide
2
+
3
+ This guide walks you through configuring **Google Antigravity IDE** (the Gemini-powered agent) to act as a coordinated member of your AgentCorp team (such as the **`developer`** role).
4
+
5
+ ---
6
+
7
+ ## 1. Overview
8
+
9
+ Google Antigravity is an AI-first IDE equipped with agentic capabilities that natively support the Model Context Protocol (MCP). By registering AgentCorp in Antigravity's configuration, the Antigravity agent can:
10
+ - Inspect unread messages, assigned tasks, and the next recommended action in one call (`get_work_queue`).
11
+ - Accept an approved proposal and start its task atomically from the agent's perspective (`accept_handoff`).
12
+ - Send implementation diffs, status updates, and test results (`send_message`).
13
+ - Publish versioned, access-controlled code artifacts (`create_artifact`).
14
+
15
+ ---
16
+
17
+ ## 2. Configuration (`mcp_config.json`)
18
+
19
+ Antigravity IDE reads global MCP server configurations from:
20
+
21
+ * **Windows**: `C:\Users\<username>\.gemini\config\mcp_config.json`
22
+ * **macOS / Linux**: `~/.gemini/config/mcp_config.json`
23
+
24
+ ### Step 1: Open Configuration File
25
+ Open `C:\Users\<username>\.gemini\config\mcp_config.json` in your editor.
26
+
27
+ ### Step 2: Add AgentCorp Server Definition
28
+ Add the `agentcorp` server entry to the `mcpServers` object, binding it to the `developer` role:
29
+
30
+ ```json
31
+ {
32
+ "mcpServers": {
33
+ "agentcorp": {
34
+ "command": "node",
35
+ "args": [
36
+ "C:\\Users\\<username>\\Desktop\\AgentCorp\\dist\\cli.js",
37
+ "mcp",
38
+ "--role",
39
+ "developer",
40
+ "--config",
41
+ "C:\\Users\\<username>\\Desktop\\AgentCorp\\org.toml",
42
+ "--db",
43
+ "C:\\Users\\<username>\\Desktop\\AgentCorp\\.agentcorp\\agentcorp.db"
44
+ ]
45
+ }
46
+ }
47
+ }
48
+ ```
49
+
50
+ > [!TIP]
51
+ > Use an absolute path for `--config` so that Antigravity reaches the broker regardless of your editor's current working directory. AgentCorp automatically derives `--db`, `--credentials`, and daemon control files relative to the config directory. Explicit `--db` arguments are optional overrides. On Windows, use double backslashes (`\\`) in JSON.
52
+
53
+ ---
54
+
55
+ ## 3. How the Connection Works
56
+
57
+ 1. **Auto-Spawning**: When Antigravity initializes, the stdio adapter checks if the AgentCorp daemon is active. If not, it automatically spawns the central daemon in the background.
58
+ 2. **Identity Lockdown**: The adapter automatically loads the `developer` bearer token from `.agentcorp/credentials.json`. Antigravity's agent identity is cryptographically enforced and cannot be spoofed.
59
+ 3. **Tool Injection**: Antigravity automatically registers the 15 AgentCorp tools, including:
60
+ - `whoami`, `register_role`
61
+ - `list_tasks`, `create_task`, `update_task_status`
62
+ - `get_inbox`, `send_message`, `acknowledge_message`, `accept_handoff`, `get_thread`
63
+ - `get_work_queue` (combines active tasks, unread messages, presence, and next actions)
64
+ - `create_artifact`, `list_artifacts`, `get_artifact`
65
+ - `get_operation` (lookup results of idempotent operations)
66
+ 4. **Self-Healing Proxy**: The stdio proxy features auto-reconnection with bounded exponential backoff. If the central broker restarts, Antigravity's in-flight session recovers seamlessly.
67
+ 5. **Idempotency & Zero Duplication**: Mutations accept `idempotency_key`. Retried network requests replay the exact cached outcome without creating duplicate tasks, messages, or approvals.
68
+
69
+ ---
70
+
71
+ ## 4. Example Agent Prompt & Handoff Best Practices
72
+
73
+ Once configured, you can prompt the Antigravity agent in the sidebar chat:
74
+
75
+ > *"Call `get_work_queue` and follow the highest-priority applicable next action. Use `accept_handoff` for an approved task proposal."*
76
+
77
+ ### Coordination Guidelines:
78
+ - **Standing Instructions**: Add the prompt above as a standing instruction at session start. MCP cannot wake an idle agent model autonomously.
79
+ - **Lightweight Handoffs**: Coordinate using concise IDs and summaries (`taskId`, `messageId`, diff summary). Do not dump large file trees or bulk artifacts into chat prompts; read artifacts on demand with `get_artifact`.
80
+
81
+ After upgrading AgentCorp or changing authentication settings, rebuild the
82
+ package (`npm run build`), restart the daemon (`agentcorp stop && agentcorp start`),
83
+ and restart the IDE's MCP connection if new tools are added. Existing
84
+ stdio processes continue running their previously loaded adapter code.
@@ -0,0 +1,76 @@
1
+ # Claude Code, Cursor, and VS Code Setup Guide
2
+
3
+ AgentCorp is fully vendor-agnostic and interoperates with any host that implements the Model Context Protocol (MCP). This guide covers configuring **Claude Desktop**, **Claude Code**, **Cursor**, **Windsurf**, and **VS Code**.
4
+
5
+ ---
6
+
7
+ ## 1. Claude Desktop / Claude Code
8
+
9
+ Claude reads its MCP servers from `claude_desktop_config.json`:
10
+
11
+ * **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
12
+ * **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
13
+
14
+ ### Configuration Snippet
15
+ Add the following to your `mcpServers` object:
16
+
17
+ ```json
18
+ {
19
+ "mcpServers": {
20
+ "agentcorp": {
21
+ "command": "node",
22
+ "args": [
23
+ "/path/to/AgentCorp/dist/cli.js",
24
+ "mcp",
25
+ "--role",
26
+ "architect",
27
+ "--config",
28
+ "/path/to/AgentCorp/org.toml",
29
+ "--db",
30
+ "/path/to/AgentCorp/.agentcorp/agentcorp.db"
31
+ ]
32
+ }
33
+ }
34
+ }
35
+ ```
36
+
37
+ ---
38
+
39
+ ## 2. Cursor
40
+
41
+ Cursor supports workspace-level and user-level MCP servers.
42
+
43
+ ### Workspace Setup (`.cursor/mcp.json`)
44
+ Create or edit `.cursor/mcp.json` in your repository root:
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "agentcorp-developer": {
50
+ "command": "node",
51
+ "args": [
52
+ "./dist/cli.js",
53
+ "mcp",
54
+ "--role",
55
+ "developer",
56
+ "--config",
57
+ "./org.toml",
58
+ "--db",
59
+ "./.agentcorp/agentcorp.db"
60
+ ]
61
+ }
62
+ }
63
+ }
64
+ ```
65
+
66
+ ---
67
+
68
+ ## 3. Windsurf & Generic VS Code Extensions
69
+
70
+ For Windsurf or any VS Code MCP extension supporting stdio:
71
+
72
+ 1. Specify `node` as the executable.
73
+ 2. Pass arguments:
74
+ `["<absolute-path-to-agentcorp>/dist/cli.js", "mcp", "--role", "<role-id>", "--config", "<path-to-org.toml>", "--db", "<path-to-db>"]`.
75
+ 3. The adapter will handle daemon auto-spawning, role authentication, and tool routing transparently.
76
+ 4. Specifying `--config` automatically derives `--db`, credentials, and daemon control files relative to the config file's directory. Providing `--db` is an optional override for custom database paths.
@@ -0,0 +1,75 @@
1
+ # OpenAI Codex Setup Guide
2
+
3
+ This guide walks you through configuring **OpenAI Codex** (Desktop App or Extension, powered by models like **ChatGPT 5.6-sol**) to act as a coordinated member of your AgentCorp team (such as the **`architect`** / **Planner & Reviewer** role).
4
+
5
+ ---
6
+
7
+ ## 1. Overview
8
+
9
+ OpenAI Codex provides reasoning and planning capabilities. When bound to AgentCorp as the **`architect`**, Codex can:
10
+ - Decompose system goals into milestone tasks (`create_task`).
11
+ - Prepare tasks for peer implementers (`create_task`) and send linked proposals (`send_message`).
12
+ - Inspect one prioritized coordination view at session start (`get_work_queue`).
13
+ - Dispatch typed architecture proposals and reviews (`send_message`).
14
+ - Review code diffs and artifacts submitted by the developer (`list_artifacts`, `get_artifact`).
15
+
16
+ ---
17
+
18
+ ## 2. Configuration (`config.toml`)
19
+
20
+ Codex reads MCP server definitions from its global TOML configuration file:
21
+
22
+ * **Windows**: `C:\Users\<username>\.codex\config.toml`
23
+ * **macOS / Linux**: `~/.codex/config.toml`
24
+
25
+ ### Step 1: Open Configuration File
26
+ Open `C:\Users\<username>\.codex\config.toml` in your editor.
27
+
28
+ ### Step 2: Add AgentCorp Server Definition
29
+ Add the `[mcp_servers.agentcorp]` block to your `config.toml`, binding Codex to the `architect` role:
30
+
31
+ ```toml
32
+ [mcp_servers.agentcorp]
33
+ command = "node"
34
+ args = [
35
+ "C:\\Users\\<username>\\Desktop\\AgentCorp\\dist\\cli.js",
36
+ "mcp",
37
+ "--role",
38
+ "architect",
39
+ "--config",
40
+ "C:\\Users\\<username>\\Desktop\\AgentCorp\\org.toml",
41
+ "--db",
42
+ "C:\\Users\\<username>\\Desktop\\AgentCorp\\.agentcorp\\agentcorp.db"
43
+ ]
44
+ ```
45
+
46
+ > [!NOTE]
47
+ > On Windows, ensure path backslashes are escaped (`\\`) in TOML strings, or use forward slashes (`/`). Providing `--config` automatically derives the project-scoped database (`.agentcorp/agentcorp.db`), credentials, and daemon files; `--db` is optional.
48
+
49
+ ---
50
+
51
+ ## 3. How the Connection Works
52
+
53
+ 1. **Role Enforcement**: Codex connects through a role-bound stdio adapter that enforces the `architect` identity using the credentials stored in `.agentcorp/credentials.json`.
54
+ 2. **Peer Isolation**: In `org.toml`, the `architect` is configured with `allowed_peers = ["developer"]`. Codex can only communicate with authorized roles.
55
+ 3. **Approval Gating**: When Codex sends a `proposal` to the developer, AgentCorp's policy engine intercepts it and queues it for human review before it reaches Antigravity's inbox.
56
+
57
+ ---
58
+
59
+ ## 4. Example Codex Prompt
60
+
61
+ In the Codex extension or desktop app, you can issue commands like:
62
+
63
+ > *"Check the tasks in AgentCorp, create a new task for 'Implement SQLite Index Optimization', and send a proposal message to the developer role with the architectural specification."*
64
+
65
+ Codex will automatically call `create_task` and `send_message`, which will appear in your Human Console for approval.
66
+
67
+ Add this standing instruction to the Codex project guidance:
68
+
69
+ > At the start of each session and after every coordination mutation, call
70
+ > `get_work_queue`. Follow its highest-priority applicable next action before
71
+ > creating duplicate tasks or messages.
72
+
73
+ Creating a task with `assigned_to` records the intended assignee but does not
74
+ expose actionable work to that role. The linked proposal's approval activates
75
+ the assignment.