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
package/dist/types.js ADDED
@@ -0,0 +1,85 @@
1
+ import { z } from "zod";
2
+ export const MessageTypeSchema = z.enum([
3
+ "proposal",
4
+ "question",
5
+ "answer",
6
+ "report",
7
+ "review",
8
+ "verdict",
9
+ "status_update",
10
+ ]);
11
+ export const MessageStatusSchema = z.enum([
12
+ "draft",
13
+ "pending_approval",
14
+ "approved",
15
+ "edited",
16
+ "rejected",
17
+ "delivered",
18
+ "acknowledged",
19
+ ]);
20
+ export const TaskStatusSchema = z.enum([
21
+ "proposed",
22
+ "assigned",
23
+ "in_progress",
24
+ "blocked",
25
+ "awaiting_review",
26
+ "completed",
27
+ "failed",
28
+ "cancelled",
29
+ ]);
30
+ export const PolicyActionSchema = z.enum([
31
+ "auto_approve",
32
+ "require_human",
33
+ "delegate_to_role",
34
+ ]);
35
+ export const PolicySubjectSchema = z.enum(["message", "task"]);
36
+ export const RoleSchema = z.object({
37
+ id: z.string().min(1).regex(/^[a-z][a-z0-9_-]*$/),
38
+ display_name: z.string().min(1).optional(),
39
+ model: z.string().min(1).optional(),
40
+ interface: z.literal("mcp").default("mcp"),
41
+ capabilities: z.array(z.string().min(1)).default([]),
42
+ allowed_peers: z.array(z.string().min(1)).default([]),
43
+ artifact_visibility: z.union([z.literal("all"), z.array(z.string().min(1))]),
44
+ });
45
+ export const InitialPolicySchema = z.object({
46
+ id: z.string().min(1).optional(),
47
+ subject: PolicySubjectSchema,
48
+ priority: z.number().int().default(0),
49
+ from_role: z.string().min(1).optional(),
50
+ to_role: z.string().min(1).optional(),
51
+ message_type: MessageTypeSchema.optional(),
52
+ risk_tags: z.array(z.string().min(1)).optional(),
53
+ from_status: TaskStatusSchema.optional(),
54
+ to_status: TaskStatusSchema.optional(),
55
+ action: PolicyActionSchema,
56
+ delegate_role: z.string().min(1).optional(),
57
+ });
58
+ export const LimitsConfigSchema = z
59
+ .object({
60
+ max_request_body_bytes: z.number().int().positive().optional(),
61
+ max_message_payload_bytes: z.number().int().positive().optional(),
62
+ max_artifact_bytes: z.number().int().positive().optional(),
63
+ max_payload_size_bytes: z.number().int().positive().optional(),
64
+ max_artifact_size_bytes: z.number().int().positive().optional(),
65
+ default_page_size: z.number().int().positive().optional(),
66
+ max_page_size: z.number().int().positive().optional(),
67
+ max_audit_payload_bytes: z.number().int().positive().optional(),
68
+ })
69
+ .refine((data) => {
70
+ if (data.default_page_size && data.max_page_size) {
71
+ return data.default_page_size <= data.max_page_size;
72
+ }
73
+ return true;
74
+ }, {
75
+ message: "default_page_size cannot be greater than max_page_size",
76
+ path: ["default_page_size"],
77
+ });
78
+ export const DEFAULT_MAX_AUDIT_PAYLOAD_BYTES = 65536; // 64 KB
79
+ export const OrgConfigSchema = z.object({
80
+ company: z.object({ name: z.string().min(1) }),
81
+ roles: z.array(RoleSchema).min(1),
82
+ policies: z.array(InitialPolicySchema).default([]),
83
+ limits: LimitsConfigSchema.optional(),
84
+ });
85
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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DAAwD;IACjE,IAAI,EAAE,CAAC,mBAAmB,CAAC;CAC5B,CACF,CAAC;AAEJ,MAAM,CAAC,MAAM,+BAA+B,GAAG,KAAK,CAAC,CAAC,QAAQ;AA2B9D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9C,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACjC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAClD,MAAM,EAAE,kBAAkB,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAC"}
@@ -0,0 +1,119 @@
1
+ # AgentCorp Architecture Specification
2
+
3
+ This document details the architectural topology, security boundaries, domain invariants, and runtime mechanics of AgentCorp.
4
+
5
+ ---
6
+
7
+ ## 1. System Topology & Process Boundaries
8
+
9
+ ![AgentCorp Architecture Blueprint](./images/architecture.jpg)
10
+
11
+ AgentCorp follows a **single-writer local daemon** model designed to bridge heterogeneous AI clients while enforcing strict role boundaries and transactional data integrity:
12
+
13
+ ```text
14
+ ┌─────────────────────────────────────────────────────────────┐
15
+ │ Heterogeneous Agents │
16
+ │ ┌───────────────────────┐ ┌───────────────────────┐ │
17
+ │ │ Antigravity / IDE │ │ Codex / Extension │ │
18
+ │ │ (Role: developer) │ │ (Role: architect) │ │
19
+ │ └───────────┬───────────┘ └───────────┬───────────┘ │
20
+ └──────────────┼───────────────────────────────┼──────────────┘
21
+ │ stdio │ stdio
22
+ ┌──────────────▼───────────────────────────────▼──────────────┐
23
+ │ Role-Bound Stdio Adapters │
24
+ │ (agentcorp mcp --role developer / architect) │
25
+ │ • Auto-spawns daemon if offline │
26
+ │ • Binds identity via local bearer token │
27
+ └──────────────┬───────────────────────────────┬──────────────┘
28
+ │ Streamable HTTP │ Streamable HTTP
29
+ │ (Bearer <roleToken>) │ (Bearer <roleToken>)
30
+ ┌──────────────▼───────────────────────────────▼──────────────┐
31
+ │ AgentCorp Central Daemon (localhost, dynamic port) │
32
+ │ │
33
+ │ ┌──────────────────┐ ┌────────────────┐ ┌─────────────┐ │
34
+ │ │ Streamable HTTP │ │ Admin REST API │ │ SSE Stream │ │
35
+ │ │ MCP Transport │ │ (/api/*) │ │ /api/events │ │
36
+ │ └────────┬─────────┘ └────────┬───────┘ └──────┬──────┘ │
37
+ │ │ │ │ │
38
+ │ ┌────────▼─────────────────────▼─────────────────▼──────┐ │
39
+ │ │ AgentCorp Broker Engine │ │
40
+ │ │ • Connection-enforced identity │ │
41
+ │ │ • Deterministic policy evaluator (priority/subset) │ │
42
+ │ │ • EventEmitter domain pipeline │ │
43
+ │ └──────────────────────────┬────────────────────────────┘ │
44
+ │ │ │
45
+ │ ┌──────────────────────────▼────────────────────────────┐ │
46
+ │ │ Transactional SQLite Engine (WAL Mode) │ │
47
+ │ │ • Versioned migrations (schema_migrations) │ │
48
+ │ │ • Durable messages, tasks, approvals, and artifacts │ │
49
+ │ └───────────────────────────────────────────────────────┘ │
50
+ └─────────────────────────────▲───────────────────────────────┘
51
+ │
52
+ ┌─────────────────────────────┴───────────────────────────────┐
53
+ │ Human Oversight Consoles │
54
+ │ │
55
+ │ ┌─────────────────────────────┐ ┌─────────────────────┐ │
56
+ │ │ Terminal Review Loop (TUI) │ │ Web Dashboard (SSE) │ │
57
+ │ │ (agentcorp review) │ │ (GET /console) │ │
58
+ │ └─────────────────────────────┘ └─────────────────────┘ │
59
+ └─────────────────────────────────────────────────────────────┘
60
+ ```
61
+
62
+ ---
63
+
64
+ ## 2. Authentication & Identity Enforcement
65
+
66
+ 1. **Role Tokens**:
67
+ - Each role configured in `org.toml` is assigned a high-entropy cryptographically random bearer token stored in `.agentcorp/credentials.json` (`mode 0600`).
68
+ - Tokens never live in `org.toml` or git-tracked directories.
69
+ 2. **Connection-Enforced Identity**:
70
+ - The caller's role is established strictly during HTTP handshake via `Authorization: Bearer <roleToken>`.
71
+ - Tool arguments like `sender` or `caller` are **never** accepted from the client; identity spoofing is impossible.
72
+ 3. **Admin Token**:
73
+ - Administrative endpoints (`/api/approvals`, `/api/policies`, `/api/events`, `/api/audit/export`) require the separate `adminToken`.
74
+
75
+ ---
76
+
77
+ ## 3. Policy Evaluation & Human-in-the-Loop (HITL)
78
+
79
+ AgentCorp operates on a **safe-by-default** security posture:
80
+
81
+ ```text
82
+ Incoming Request (Message / Task Transition)
83
+ │
84
+ ├── 1. Verify Allowed Peers (is recipient in sender.allowed_peers?)
85
+ │ └── NO ──> REJECT (NOT_AN_ALLOWED_PEER)
86
+ │
87
+ ├── 2. Evaluate Runtime Policies (Ordered by DESC priority)
88
+ │ ├── Match Subject ("message" / "task")
89
+ │ ├── Match Optional Criteria (from_role, to_role, message_type, to_status)
90
+ │ └── Match Risk Tags (Subset matching: all rule tags must be present)
91
+ │
92
+ ├── 3. Decision
93
+ │ ├── Match found with action="auto_approve" ──> PROCEED (Delivered / Updated)
94
+ │ └── NO match found OR action="require_human"
95
+ │ └── QUEUE in pending_approval
96
+ │ ├── Recipient cannot see message
97
+ │ ├── Event emitted over SSE
98
+ │ └── Awaits Human Sign-off in Terminal / Web Console
99
+ ```
100
+
101
+ ---
102
+
103
+ ## 4. Real-Time Event Architecture (SSE)
104
+
105
+ The broker daemon maintains an event-driven pub/sub architecture:
106
+ * **Domain Events**: `message_created`, `message_delivered`, `approval_created`, `approval_decided`, `task_status_changed`, `policy_changed`.
107
+ * **Server-Sent Events (`/api/events`)**: Pushes events to connected terminal observers and web consoles in real-time.
108
+ * **Resilience**: Includes automatic 15-second keep-alive heartbeats and clean connection teardown on client disconnect.
109
+ * **Agent work discovery**: `get_work_queue` projects unread messages, active tasks, and prioritized next actions from the same transactional state, avoiding client-side reconciliation races.
110
+ * **Approved handoffs**: An intended assignee cannot observe a proposed task until its linked proposal is delivered. Proposal approval activates the assignment; `accept_handoff` then acknowledges and starts it idempotently.
111
+
112
+ ---
113
+
114
+ ## 5. Storage & Persistence
115
+
116
+ * **Database Engine**: Built-in `node:sqlite` in WAL (Write-Ahead Logging) mode.
117
+ * **Zero Native Dependencies**: No native compilation (`node-gyp`), ensuring universal cross-platform execution on Windows, macOS, and Linux.
118
+ * **Migrations**: Automated forward schema migrations tracked in `schema_migrations`.
119
+ * **Git Observability**: Complete state can be exported at any time into human-readable Markdown (`coord/audit.md`) and structured JSON (`coord/audit.json`).
package/docs/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # AgentCorp Documentation
2
+
3
+ Welcome to the official AgentCorp documentation. AgentCorp is an open-source, local-first coordination broker designed to orchestrate teams of heterogeneous AI agents (such as Google Antigravity/Gemini, OpenAI Codex/ChatGPT, Anthropic Claude, Cursor, and more) over the Model Context Protocol (MCP) with Human-in-the-Loop (HITL) oversight.
4
+
5
+ ---
6
+
7
+ ## Documentation Navigation
8
+
9
+ ### Start Here
10
+
11
+ * **[Beginner Setup & First Workflow](getting-started.md)**: Install AgentCorp, configure two agents, approve a handoff, and troubleshoot the connection without assuming prior MCP experience.
12
+
13
+ ### 1. Architecture & Design
14
+ * **[Architecture Blueprint](ARCHITECTURE.md)**: Single-writer local daemon topology, Streamable HTTP MCP transport, role-bound stdio proxy adapters, transactional SQLite persistence, deterministic policy engine, and Server-Sent Events (SSE).
15
+ * **[Build Roadmap](ROADMAP.md)**: Milestones, completed phases, and upcoming capabilities.
16
+
17
+ ### 2. Integration & Setup Guides
18
+ * **[Google Antigravity Setup Guide](guides/antigravity-setup.md)**: Step-by-step guide to configuring Google Antigravity IDE as an AgentCorp role (e.g. Developer / Implementer).
19
+ * **[OpenAI Codex Setup Guide](guides/codex-setup.md)**: Step-by-step guide to configuring OpenAI Codex desktop and extension as an AgentCorp role (e.g. Planner & Reviewer).
20
+ * **[Claude Code & Cursor Setup Guide](guides/claude-cursor-setup.md)**: Universal instructions for connecting Claude Desktop, Claude Code, Cursor, Windsurf, and VS Code.
21
+ * **[Human Oversight Console Guide](guides/human-console.md)**: Operating the terminal-native interactive review loop (`agentcorp review`) and the dark glassmorphic web dashboard (`agentcorp console --browser`).
22
+
23
+ ### 3. Core References
24
+ * **[MCP Tools Reference](mcp-tools-reference.md)**: Exhaustive reference for all 15 MCP tools exposed to agents, including the prioritized `get_work_queue` view and idempotent `accept_handoff` operation.
25
+ * **[CLI Reference](cli-reference.md)**: Complete command-line interface manual (`init`, `validate`, `start`, `stop`, `status`, `console`, `review`, `approvals`, `policies`, `audit`, `mcp`).
26
+ * **[Policy & Safety Guide](policy-guide.md)**: Authoring safety rules, priority cascades, subset risk tag matching, and approval enforcement.
27
+ * **[Release Guide](RELEASING.md)**: Prepare GitHub and npm, publish a preview safely, verify it, and recover from release mistakes.
28
+ * **[Dogfooding Report](dogfooding-report.md)**: Findings from using AgentCorp itself for Codex-Gemini collaboration and the proposed direction for agent invocation.
29
+
30
+ ---
31
+
32
+ ## Core Principles
33
+
34
+ 1. **Heterogeneous Interoperability**: AI agents from different providers (Google Gemini, OpenAI GPT, Anthropic Claude) collaborate seamlessly without custom glue code or vendor lock-in.
35
+ 2. **Local-First & Single-Writer**: All coordination runs entirely on your local machine using SQLite with WAL mode. Agent state never leaves your workstation without your consent.
36
+ 3. **Safe by Default (HITL)**: Any message or task transition not explicitly granted an auto-approve policy is halted in a pending state until a human signs off.
37
+ 4. **Terminal-Native Workflow**: Designed by and for developers who live in the terminal, featuring instantaneous interactive keyboard reviews and live status summaries.
@@ -0,0 +1,228 @@
1
+ # AgentCorp Maintainer Release Guide
2
+
3
+ This is the maintainer runbook for publishing `agentcorp-broker` to GitHub and
4
+ npm. Publishing is intentionally a human-owned action. CI and agents may verify
5
+ a release, but they must not create a public repository, push tags, or publish
6
+ the package without explicit maintainer authorization.
7
+
8
+ AgentCorp is currently an alpha developer preview. A GitHub repository is the
9
+ source project; npm distributes the installable package built from it. A GitHub
10
+ release and an npm release normally point to the same Git tag and version.
11
+
12
+ ## 1. One-time account and repository setup
13
+
14
+ 1. Create a public GitHub repository without adding a README, license, or
15
+ `.gitignore`; those files already exist locally.
16
+ 2. Decide whether it belongs to your personal account or an organization.
17
+ 3. Replace every placeholder project URL in `package.json` and `SECURITY.md`
18
+ with that repository's exact URL.
19
+ 4. Add the remote and use the conventional `main` branch:
20
+
21
+ ```sh
22
+ git remote add origin https://github.com/<owner>/AgentCorp.git
23
+ git branch -M main
24
+ git push -u origin main
25
+ ```
26
+
27
+ 5. Enable GitHub branch protection after the first push: require the CI checks
28
+ and prevent accidental force pushes to `main`.
29
+ 6. Create an npm account, verify its email address, and enable two-factor
30
+ authentication for publishing and account changes.
31
+ 7. Log in locally and confirm the account:
32
+
33
+ ```sh
34
+ npm login
35
+ npm whoami
36
+ ```
37
+
38
+ GitHub's official instructions for an existing local repository are
39
+ [here](https://docs.github.com/en/migrations/importing-source-code/using-the-command-line-to-import-source-code/adding-locally-hosted-code-to-github).
40
+
41
+ ## 2. Choose and verify the npm package name
42
+
43
+ The manifest currently uses the unscoped name `agentcorp-broker`. Check the
44
+ registry immediately before publication:
45
+
46
+ ```sh
47
+ npm view agentcorp-broker name version dist-tags --json
48
+ ```
49
+
50
+ An npm `E404` means no package is currently returned for that name, but it does
51
+ not reserve the name. If the name is unavailable or you want ownership tied to
52
+ your npm account or organization, use a scope such as
53
+ `@<npm-account>/agentcorp` and update all install examples. A scoped public
54
+ package is published with `--access public`.
55
+
56
+ Do not rename the package after users depend on it unless you are prepared to
57
+ publish a migration release. npm package scope guidance is
58
+ [here](https://docs.npmjs.com/misc/scope/).
59
+
60
+ ## 3. Automated release gates
61
+
62
+ Run these commands from a clean release branch:
63
+
64
+ ```sh
65
+ npm ci
66
+ npm run check
67
+ npm run build
68
+ npm test
69
+ node dist/cli.js validate --config org.toml
70
+ node dist/cli.js validate --config examples/org.toml
71
+ npm audit --omit=dev
72
+ npm pack --dry-run --ignore-scripts
73
+ node dist/cli.js doctor --config org.toml
74
+ git status --short
75
+ ```
76
+
77
+ On Windows PowerShell, use `npm.cmd` if script execution policy blocks
78
+ `npm.ps1`. The last command must print nothing. CI repeats the build and test
79
+ gates on Ubuntu, Windows, and macOS with supported Node versions.
80
+
81
+ Inspect the dry-run package listing. It should contain compiled `dist/` files,
82
+ the public documentation, examples, license, changelog, security policy, and
83
+ contribution guide. It must not contain `.agentcorp/`, `coord/`, `scratch/`,
84
+ source tests, credentials, databases, logs, internal design notes, or binary
85
+ documentation images.
86
+
87
+ For the strongest install check, the test suite packs the project, installs it
88
+ into a temporary directory outside the checkout, and runs the CLI there.
89
+
90
+ ## 4. Prepare the release commit
91
+
92
+ Use [Semantic Versioning](https://docs.npmjs.com/about-semantic-versioning/).
93
+ During the preview, versions look like `0.1.0-alpha.1`,
94
+ `0.1.0-alpha.2`, and then `0.1.0-beta.1`. Once the API is stable, use regular
95
+ major, minor, and patch versions.
96
+
97
+ 1. Choose a version that has never been published. npm does not allow the same
98
+ package name and version to be reused, even after unpublishing.
99
+ 2. Update `package.json` and `package-lock.json` together:
100
+
101
+ ```sh
102
+ npm version 0.1.0-alpha.1 --no-git-tag-version
103
+ ```
104
+
105
+ 3. Change the matching changelog heading from `Unreleased` to the publication
106
+ date and add a new `Unreleased` section for future work.
107
+ 4. Run every release gate again.
108
+ 5. Commit the exact candidate:
109
+
110
+ ```sh
111
+ git add --all
112
+ git commit -m "release: prepare v0.1.0-alpha.1"
113
+ ```
114
+
115
+ ## 5. Create and push the tag
116
+
117
+ Create a signed tag if a signing identity is configured:
118
+
119
+ ```sh
120
+ git tag -s v0.1.0-alpha.1 -m "Release v0.1.0-alpha.1"
121
+ ```
122
+
123
+ Otherwise use an annotated, non-cryptographic tag:
124
+
125
+ ```sh
126
+ git tag -a v0.1.0-alpha.1 -m "Release v0.1.0-alpha.1"
127
+ ```
128
+
129
+ Push the release commit and that exact tag:
130
+
131
+ ```sh
132
+ git push origin main
133
+ git push origin v0.1.0-alpha.1
134
+ ```
135
+
136
+ Avoid `--tags`; pushing only the intended tag reduces accidental publication
137
+ of local tags.
138
+
139
+ ## 6. Publish the npm preview
140
+
141
+ First inspect the final tarball without running lifecycle scripts:
142
+
143
+ ```sh
144
+ npm pack --dry-run --ignore-scripts
145
+ ```
146
+
147
+ Publish an alpha under the `alpha` distribution tag:
148
+
149
+ ```sh
150
+ npm publish --access public --tag alpha
151
+ ```
152
+
153
+ The tag matters. Without `--tag alpha`, npm assigns the release to `latest`,
154
+ which makes ordinary installs select an unstable preview. npm's publish and
155
+ distribution-tag behavior is documented in the
156
+ [publish command](https://docs.npmjs.com/cli/commands/npm-publish/) and
157
+ [dist-tag guide](https://docs.npmjs.com/adding-dist-tags-to-packages/).
158
+
159
+ Complete the one-time-password prompt yourself. Never place an npm password,
160
+ token, recovery code, or `.agentcorp/credentials.json` in the repository or an
161
+ agent message.
162
+
163
+ For later automated releases, prefer npm
164
+ [trusted publishing](https://docs.npmjs.com/trusted-publishers/) from a tightly
165
+ protected GitHub Actions environment. It uses short-lived OIDC credentials
166
+ instead of a long-lived npm token and can add provenance for a public package
167
+ from a public repository. Follow npm's current Node/npm version requirements,
168
+ configure the exact repository and workflow filename in npm, and keep the
169
+ release environment protected. Do not claim provenance for a local 2FA publish.
170
+
171
+ ## 7. Verify before announcing
172
+
173
+ Read the registry metadata:
174
+
175
+ ```sh
176
+ npm view agentcorp-broker@0.1.0-alpha.1 name version dist-tags repository --json
177
+ ```
178
+
179
+ Then install into a new temporary directory or clean machine:
180
+
181
+ ```sh
182
+ npm install --global agentcorp-broker@alpha
183
+ agentcorp --version
184
+ agentcorp --help
185
+ ```
186
+
187
+ Initialize a disposable project and verify the actual first-run path:
188
+
189
+ ```sh
190
+ mkdir agentcorp-release-check
191
+ cd agentcorp-release-check
192
+ agentcorp init
193
+ agentcorp validate
194
+ agentcorp start --daemon
195
+ agentcorp doctor
196
+ agentcorp stop
197
+ ```
198
+
199
+ Finally, create a GitHub release for `v0.1.0-alpha.1`, copy the matching
200
+ changelog entry into the notes, and mark it as a **pre-release**. GitHub releases
201
+ are based on Git tags; see GitHub's
202
+ [release documentation](https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases).
203
+
204
+ Announce the package only after both the npm installation and GitHub release
205
+ are visible.
206
+
207
+ ## 8. Recovery rules
208
+
209
+ - If publication fails before npm accepts it, fix the cause and retry the same
210
+ version only after confirming it is absent with `npm view`.
211
+ - If npm accepted a broken release, do not overwrite it. Fix the code, increment
212
+ the prerelease number, rerun all gates, and publish the new version.
213
+ - If the wrong dist-tag was used, correct the tag with npm dist-tag commands;
214
+ do not republish identical contents under the same version.
215
+ - If credentials may have leaked, revoke or rotate them before any other work.
216
+ - Never rewrite a public release tag. Add a new version and tag so users can
217
+ reproduce what was published.
218
+
219
+ ## 9. Release safety invariants
220
+
221
+ - Policy evaluation and errors remain fail closed.
222
+ - Artifact access checks are enforced by the authenticated broker role.
223
+ - Runtime credentials, databases, logs, and audit exports are never packaged.
224
+ - `package.json`, the Git tag, the changelog, GitHub release, and npm registry
225
+ all report the same version.
226
+ - Alpha limitations are stated plainly: local trusted-user deployment, no shell
227
+ sandbox, no independent security audit, and no automatic wake-up of idle IDE
228
+ agents.
@@ -0,0 +1,112 @@
1
+ # AgentCorp build roadmap
2
+
3
+ This roadmap turns the v0.1 design specification into small, independently
4
+ releasable vertical slices. Security and interoperability gates are release
5
+ criteria, not follow-up polish.
6
+
7
+ ## Milestone 0 — repository foundation (complete)
8
+
9
+ - Publishable TypeScript package and global CLI shape
10
+ - Strict configuration validation for roles and role graphs
11
+ - Transactional SQLite schema
12
+ - Broker domain API for tasks, messages, approvals, policies, and artifacts
13
+ - Role-bound stdio MCP server
14
+ - Human approval CLI
15
+ - Core behavior tests and open-source contribution files
16
+
17
+ ## Milestone 1 — central local broker (complete)
18
+
19
+ Goal: match the design spec's single-writer topology without losing the easy
20
+ stdio integration.
21
+
22
+ - Long-lived broker daemon over MCP Streamable HTTP
23
+ - Thin role-bound stdio adapter for hosts that only spawn local commands
24
+ - Per-role credentials stored outside `org.toml`
25
+ - Admin credential and separate approval endpoints
26
+ - Database migrations with schema version enforcement
27
+ - Graceful shutdown, health check, structured logs, and audit export
28
+ - End-to-end MCP client tests using two simultaneous role connections
29
+
30
+ Exit criteria met: agents cannot access the database directly through the
31
+ AgentCorp package path; two real MCP clients exchange an approved message
32
+ through one broker process; restart preserves all state.
33
+
34
+ ## Milestone 2 — seamless human console (complete)
35
+
36
+ Goal: provide developer-first human oversight with terminal-native workflows
37
+ and a real-time dark glassmorphic web dashboard.
38
+
39
+ - Real-time event-driven broker domain events (`EventEmitter` over mutations)
40
+ - Long-lived Server-Sent Events stream (`GET /api/events`) with live push updates
41
+ - Terminal-native console (`agentcorp console`) and interactive review loop (`agentcorp review`, `agentcorp approvals review`)
42
+ - Single-page dark glassmorphic web dashboard (`/console`) with no external framework dependencies
43
+ - Side-by-side JSON diff viewer & payload editor with live validation
44
+ - Role inboxes, task threads, artifact viewer, and runtime policy toggle controls
45
+ - Prioritized per-role work queue and idempotent approved-handoff acceptance
46
+ - Approval-bound assignment visibility so agents cannot act on proposed work early
47
+ - Zero extra runtime dependencies, preserving ultra-fast startup
48
+
49
+ Exit criteria met: A user can operate, monitor, and sign off multi-agent workflows
50
+ either completely inside their terminal or via an intuitive live web dashboard without raw SQL.
51
+
52
+ ## Milestone 2.5 — bounded storage, self-healing sessions & observability (complete)
53
+
54
+ Goal: ensure bounded memory and disk usage, auto-recovering stdio adapters, and complete operational transparency.
55
+
56
+ - Hard memory & disk bounds: 2 MB HTTP body, 1 MB message payload, 5 MB artifact content, configurable 64 KB audit payload budget
57
+ - Opaque cursor pagination across tasks, messages, inboxes, artifacts, and approvals
58
+ - Safe history pruning (`agentcorp prune`) with dry-run simulation, foreign-key reply chain detachment, and SQLite WAL compaction (`agentcorp compact`)
59
+ - Resilient Stdio MCP Proxy with auto-reconnection and bounded exponential backoff across daemon crashes/restarts
60
+ - Cross-process startup locking with active PID checking and stale lock recovery
61
+ - Working directory isolation automatically deriving project-scoped runtime paths from `org.toml`
62
+ - Mutation idempotency keys (`idempotency_key`) and operation lookup (`get_operation`) guaranteeing zero duplicate mutations
63
+ - Role presence tracking (`online`, `idle`, `offline`) and activity freshness telemetry (`fresh`, `idle`, `stale`) across `get_work_queue`, `/health`, and Web Console
64
+ - Bounded rotating daemon logs (`.agentcorp/daemon.log`, 5 MB max with 3 backups) and crash forensics (`.agentcorp/crash.log`)
65
+ - Diagnostic tool `agentcorp doctor` for comprehensive subsystem verification
66
+ - Audit export explicit semantics distinguishing row-limit truncation from field-level clipping
67
+
68
+ Exit criteria met: Chaos E2E kills daemon mid-session and proves same client recovery, durable state, zero duplicate mutation, bounded logs, clean package smoke test outside checkout, and verified doctor diagnostics.
69
+
70
+ ## Release Candidate 0.1.0-alpha.1 (complete)
71
+
72
+ Goal: deliver a reproducible, high-standard open-source developer preview release candidate.
73
+
74
+ - Cross-platform GitHub CI across Ubuntu, Windows, and macOS on supported Node 22 and 24 releases
75
+ - Outside-checkout temporary-install package smoke test leaving zero workspace debris
76
+ - Curated npm package manifest (< 200 KB packed) retaining declarations, source maps, console assets, and docs while excluding binary images and internal design specs
77
+ - Open source community templates (Contributor Covenant Code of Conduct, GitHub Issue & PR templates)
78
+ - Complete maintainer release guide (`docs/RELEASING.md`) separating automated checks from maintainer-owned npm publishing
79
+ - Beginner setup and first-workflow guide plus a public dogfooding report
80
+ - Strict typechecking for production and test sources with a production-only build configuration
81
+ - Package-boundary regression assertions for the npm tarball
82
+
83
+ ## Milestone 3 — adapters and interoperability (next)
84
+
85
+ - Tested setup guides for Codex, Gemini, Claude Code, VS Code, and Cursor
86
+ - Agent Card export and an A2A compatibility adapter
87
+ - HTTP artifact content store with size limits and streaming
88
+ - Pluggable policy match dimensions
89
+ - OpenTelemetry traces and metrics
90
+ - Host-specific notification or runner adapters that can wake idle agents when approved work arrives
91
+
92
+ Exit criteria: three vendor-distinct agents complete the same workflow without
93
+ custom broker code.
94
+
95
+ ## Milestone 4 — stable public release
96
+
97
+ - Threat model and independent security review
98
+ - Protocol conformance suite
99
+ - Backward-compatible database and API migration policy
100
+ - Signed releases, SBOM, provenance, and automated npm publishing
101
+ - Performance tests for concurrent roles and large task histories
102
+ - `1.0.0` API stability commitment
103
+
104
+ ## Decisions to resolve before v0.2
105
+
106
+ 1. Authentication: local bearer tokens versus OS-bound credentials.
107
+ 2. Transport: HTTP-only daemon versus HTTP plus a local socket.
108
+ 3. Package identity: retain `agentcorp-broker` or publish under an owned npm
109
+ scope. The unscoped `agentcorp` package is already occupied.
110
+ 4. Task model: retain separate task/message records until A2A adapter work
111
+ produces evidence that unification reduces complexity.
112
+ 5. Artifact storage: maximum inline content size and URI scheme allowlist.