code60-transmission-server 0.1.0-staging.2 → 0.1.0-staging.20

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 (94) hide show
  1. package/INTENT.md +47 -0
  2. package/README.md +58 -253
  3. package/dist/src/acp.js +115 -0
  4. package/dist/src/contract.js +108 -0
  5. package/dist/src/engine.js +596 -0
  6. package/dist/src/main.js +72 -22
  7. package/dist/src/repository.js +94 -0
  8. package/dist/src/service.js +188 -0
  9. package/package.json +16 -32
  10. package/reference/openapi.json +834 -0
  11. package/README.engine.md +0 -401
  12. package/dist/src/broker/filesystem.js +0 -385
  13. package/dist/src/broker/index.js +0 -734
  14. package/dist/src/broker/native/README.md +0 -192
  15. package/dist/src/broker/native/build.js +0 -43
  16. package/dist/src/broker/native/fs-helper.c +0 -529
  17. package/dist/src/broker/native/git-helper.c +0 -205
  18. package/dist/src/broker/policy.js +0 -149
  19. package/dist/src/broker/startup-lock.js +0 -14
  20. package/dist/src/broker/types.js +0 -11
  21. package/dist/src/cli/daemon.js +0 -365
  22. package/dist/src/cli/helpers.js +0 -104
  23. package/dist/src/cli/main.js +0 -180
  24. package/dist/src/config/deployment.js +0 -163
  25. package/dist/src/config/documents.js +0 -29
  26. package/dist/src/config/profile-validation.js +0 -123
  27. package/dist/src/config/schema-graph.js +0 -237
  28. package/dist/src/config/schema-loader.js +0 -185
  29. package/dist/src/config/validation-pool.js +0 -105
  30. package/dist/src/config/validation-protocol.js +0 -1
  31. package/dist/src/config/validation-worker.js +0 -106
  32. package/dist/src/config/workflow-language.js +0 -9
  33. package/dist/src/config/workflow-schema.json +0 -534
  34. package/dist/src/config/workflow-types.js +0 -1
  35. package/dist/src/config/workflow-validation.js +0 -95
  36. package/dist/src/engine/budgets.js +0 -50
  37. package/dist/src/engine/clocks.js +0 -27
  38. package/dist/src/engine/commands.js +0 -441
  39. package/dist/src/engine/contracts.js +0 -11
  40. package/dist/src/engine/drain-state.js +0 -31
  41. package/dist/src/engine/effective-permissions.js +0 -120
  42. package/dist/src/engine/instruction-pins.js +0 -205
  43. package/dist/src/engine/retries.js +0 -50
  44. package/dist/src/engine/state.js +0 -1
  45. package/dist/src/engine/timing.js +0 -23
  46. package/dist/src/engine/tool-observations.js +0 -87
  47. package/dist/src/engine/workflow-engine.js +0 -1807
  48. package/dist/src/mcp/catalog.js +0 -71
  49. package/dist/src/mcp/main.js +0 -24
  50. package/dist/src/mcp/server.js +0 -104
  51. package/dist/src/runtime/codex-app-server.js +0 -91
  52. package/dist/src/runtime/containment.js +0 -82
  53. package/dist/src/runtime/engine-driver.js +0 -212
  54. package/dist/src/runtime/json-line-writer.js +0 -192
  55. package/dist/src/runtime/pinned-instruction-sources.js +0 -24
  56. package/dist/src/runtime/protocol-client.js +0 -264
  57. package/dist/src/runtime/protocol-pool.js +0 -183
  58. package/dist/src/runtime/protocol-projection.js +0 -393
  59. package/dist/src/runtime/protocol-types.js +0 -1
  60. package/dist/src/runtime/protocol-worker.js +0 -18
  61. package/dist/src/runtime/provider-bridge.js +0 -288
  62. package/dist/src/runtime/provider-credentials.js +0 -41
  63. package/dist/src/runtime/provider-transport.js +0 -404
  64. package/dist/src/runtime/runtime-broker.js +0 -213
  65. package/dist/src/runtime/workspace-instructions.js +0 -120
  66. package/dist/src/runtime/workspace-view.js +0 -74
  67. package/dist/src/server/api-contract.json +0 -11078
  68. package/dist/src/server/api-types.js +0 -1
  69. package/dist/src/server/application.js +0 -38
  70. package/dist/src/server/auth.js +0 -67
  71. package/dist/src/server/broker-handlers.js +0 -242
  72. package/dist/src/server/control-plane.js +0 -50
  73. package/dist/src/server/deployment.js +0 -237
  74. package/dist/src/server/errors.js +0 -22
  75. package/dist/src/server/history-handlers.js +0 -113
  76. package/dist/src/server/http.js +0 -124
  77. package/dist/src/server/paging.js +0 -56
  78. package/dist/src/server/publication.js +0 -119
  79. package/dist/src/server/tool-event-handler.js +0 -77
  80. package/dist/src/server/workspace-handlers.js +0 -34
  81. package/dist/src/storage/coordinator.js +0 -224
  82. package/dist/src/storage/startup-lock.js +0 -71
  83. package/dist/src/storage/store.js +0 -167
  84. package/dist/src/tools/check-worker.js +0 -81
  85. package/dist/src/tools/checks.js +0 -106
  86. package/dist/src/tools/dns.js +0 -248
  87. package/dist/src/tools/http-contract.js +0 -38
  88. package/dist/src/tools/http.js +0 -358
  89. package/dist/src/tools/index.js +0 -177
  90. package/dist/src/tools/worker-check.js +0 -73
  91. package/dist/src/workspaces/git.js +0 -227
  92. package/dist/src/workspaces/index.js +0 -715
  93. package/examples/deployment.local.json +0 -22
  94. package/scripts/postinstall.mjs +0 -25
package/INTENT.md ADDED
@@ -0,0 +1,47 @@
1
+ # Transmission intent
2
+
3
+ Transmission gives a calling orchestrator a deterministic outer loop for long-running work. Each task starts in a fresh harness session to reduce context rot. A separate verifier evaluates the worker’s result. The orchestrator can rely on a small set of outcomes even when an individual task takes several attempts.
4
+
5
+ ## Priorities, in order
6
+
7
+ 1. Extremely low-friction setup for the user.
8
+ 2. Extremely low-friction setup for the user. The repetition is intentional.
9
+ 3. Autonomy over long runs. Failed tests, verifier feedback, and retries are ordinary parts of the work.
10
+ 4. Reasonable recovery from interruptions a developer encounters on one machine.
11
+ 5. Reasonably secure defaults within Transmission’s own sphere of responsibility.
12
+
13
+ ## From request to running workflow
14
+
15
+ The user describes what they want to accomplish. The calling orchestrator, acting through the harness, uses the MCP tool’s guidance to design a workflow. The caller defines the tasks, their order, and their completion criteria. The harness presents the workflow and asks the user to confirm it. Ordinary coding tasks should require no project-specific Transmission setup or knowledge of its orchestration API from the user.
16
+
17
+ That confirmation authorizes autonomous execution of the agreed scope. Transmission owns session lifecycle and workflow decisions. Automatic approval of decisions during execution is configurable and enabled by default. Return to the user only when their intent needs clarification, the scope needs to change, or the workflow genuinely cannot proceed.
18
+
19
+ ## Implementation and verification
20
+
21
+ Workers use the harness’s normal tools, command execution, and permissions. Transmission starts a fresh worker session for each task and keeps verification separate from implementation. The workflow can express the verifier’s criteria as a prompt.
22
+
23
+ When verification calls for repairs, the original worker receives the feedback and can try again up to a configured limit. At that limit, restart the task in a fresh session, subject to the configured retry limit. A failed test or a request for repair can be handled inside this loop without involving the user.
24
+
25
+ ## Recovery on one machine
26
+
27
+ | Interruption | Expected behavior |
28
+ | --- | --- |
29
+ | The MCP client closes | The approved workflow keeps running. |
30
+ | The machine reboots | Resume from the last completed task and continue with the first unfinished task. |
31
+ | The harness dies mid-task | Retry that task in a fresh session within the configured retry limit. |
32
+
33
+ ## What the caller can rely on
34
+
35
+ | Workflow status | Information returned |
36
+ | --- | --- |
37
+ | Running | Which task is running. |
38
+ | Completed | The result and the verifier’s verdict. |
39
+ | Needs input | The specific decision the user needs to make. |
40
+ | Failed | Why the workflow failed and what it tried. |
41
+ | Cancelled | Confirmation that the workflow was cancelled. |
42
+
43
+ ## Architectural limits
44
+
45
+ The harness owns development permissions and their enforcement. Transmission has no additional protection mandate. A new security layer on top of the harness is outside the project’s scope.
46
+
47
+ The recovery target is an individual developer’s machine and the interruptions described above. Rebuilding Temporal is outside the project’s scope. When architectural choices compete, the priorities above govern the trade-off.
package/README.md CHANGED
@@ -1,292 +1,97 @@
1
- # Code60 Transmission Server
1
+ # Transmission
2
2
 
3
- A local workflow server for running bounded coding-agent steps against a Git
4
- workspace. It stores workflow state, approvals and tool authority in SQLite,
5
- brokers file/network access, and accepts evaluated results as Git commits.
3
+ Transmission runs an approved coding workflow in an existing Git project. The calling assistant designs the tasks and asks you to confirm them. Each task gets a fresh worker. A separate verifier inspects the project, runs checks, and returns a verdict. Rejected work goes back to the same worker with the verifier’s feedback.
6
4
 
7
- ## Run with npx (MCP)
5
+ ## Connect your assistant
8
6
 
9
- On macOS with Node.js **24.22.0 or newer in the 24.x line** and Xcode Command
10
- Line Tools (`/usr/bin/clang` and Git), any MCP client can start and connect to
11
- the server directly via `npx` — no separate daemon startup is required:
7
+ On macOS with Node 24.22 or later in the 24.x series, add this stdio MCP server to your assistant. Sign in to Codex once using your usual Codex login.
12
8
 
13
9
  ```json
14
10
  {
15
11
  "mcpServers": {
16
- "code60": {
12
+ "transmission": {
17
13
  "command": "npx",
18
- "args": ["-y", "code60-transmission-server"]
14
+ "args": ["-y", "code60-transmission-server", "mcp"]
19
15
  }
20
16
  }
21
17
  }
22
18
  ```
23
19
 
24
- Or print the ready-to-paste client entry from Terminal:
20
+ For an unpublished candidate, install the tarball and run `code60 mcp-config` for the exact local server entry. A first connection starts the local engine. Describe the outcome you want, review the caller’s proposed tasks and verification criteria, and confirm the workflow.
25
21
 
26
- ```sh
27
- npx -y code60-transmission-server mcp-config
28
- ```
29
-
30
- On first connection, the launcher compiles the native macOS containment helpers
31
- (during install or on demand into a private user-owned directory), creates a
32
- private `0700` state directory at
33
- `~/Library/Application Support/Code60 Transmission/state` with `0600`
34
- `configuration.json` and `operator.token`, and starts one shared detached
35
- background engine for that state directory. Multiple MCP clients share the same
36
- engine, and closing an MCP client leaves the engine running so active runs are
37
- not interrupted. Pass `--state-directory /absolute/path` to isolate an
38
- independent state directory.
39
-
40
- Inspect or stop the background engine at any time:
41
-
42
- ```sh
43
- npx -y code60-transmission-server status
44
- npx -y code60-transmission-server stop
45
- ```
46
-
47
- The default state directory and port (`31260`) are shared cleanly with the
48
- macOS `.pkg` installer below. Before changing `configuration.json` or upgrading
49
- to a new package version, let active runs finish, run `stop`, and reconnect.
50
- Registered workspaces must be standalone Git repositories prepared normally on
51
- disk (with a real `.git` directory, at least one commit, and no hardlinked
52
- `.git/objects` files—do not initialize repositories inside a sandbox that
53
- forbids deleting files, and use `git clone --no-hardlinks` for local clones).
54
-
55
- ## Install on macOS
56
-
57
- Open the Code60 Transmission `.pkg` for your Mac's architecture. It installs
58
- the engine, stdio MCP bridge, Node.js, SQLite binding, and both native helpers
59
- for your macOS account. Both the engine and bridge use the bundled Node runtime.
60
- The package targets macOS 14 or newer.
61
-
62
- To get the connection settings for your desktop MCP client, run this command in Terminal.
63
-
64
- ```sh
65
- "$HOME/Library/Application Support/Code60 Transmission/app/code60" mcp-config
66
- ```
67
-
68
- Copy the printed server entry into your client's MCP settings. For a client
69
- with separate fields, use the printed absolute path as its stdio command and
70
- leave the arguments empty. The first connection creates a private operator
71
- token and configuration and starts one engine in your macOS login session.
72
- Each client gets its own bridge. The engine stays running after clients close.
73
-
74
- Private configuration, token, database, and engine log live together in
75
- `~/Library/Application Support/Code60 Transmission/state/`, outside the installed
76
- `app/` directory. The default API port is `31260`. If that port is in use,
77
- set `listenPort` in `state/configuration.json` to a free port and reconnect.
78
- The bridge reads the same setting. The initial deployment supports operator
79
- setup. To run coding-agent steps, configure the Codex CLI and a model provider
80
- as described in [Configure and run](#configure-and-run). Git workspace operations
81
- use Apple's Command Line Tools Git and your configured author identity.
82
-
83
- Before an upgrade or a configuration reload, let active runs finish, disconnect
84
- the clients, and stop the loaded engine.
85
-
86
- ```sh
87
- launchctl bootout "gui/$(id -u)/com.codemanufactory.code60.transmission"
88
- ```
89
-
90
- Install the new package or edit the private configuration, then reconnect.
91
- Reinstalling updates the application and preserves the private state.
92
-
93
- ## Build the macOS installer
94
-
95
- On a build Mac of the target architecture, use the official unpacked Node
96
- 24.22.0 or newer 24.x distribution (including its `LICENSE`), npm, and Apple's
97
- Command Line Tools.
98
-
99
- ```sh
100
- npm ci
101
- npm run package:macos
102
- ```
103
-
104
- The output is `dist/installers/Code60-Transmission-<version>-<arch>.pkg`.
105
- The build stages a fresh TypeScript compilation, native helpers, and locked
106
- production dependencies. It checks architecture, deployment targets, dynamic
107
- library paths, and the bundled SQLite binding. The default build is unsigned
108
- for local testing. For a public release, set `APPLICATION_SIGN_IDENTITY` and
109
- `INSTALLER_SIGN_IDENTITY` to your Developer ID Application and Installer
110
- identities, and set `NOTARY_PROFILE` to your notarytool Keychain profile.
111
- The same build command then signs the native code and package, submits it to
112
- Apple, staples the ticket, and checks Gatekeeper acceptance.
113
-
114
- In a separate macOS login account with port 31260 available and no installed
115
- Transmission engine, run `node scripts/smoke-macos-package.mjs /absolute/path/to/the.pkg`.
116
- It checks the installer domain and exercises the extracted payload with two MCP
117
- clients and a real per-user engine, then removes its temporary service and files.
118
-
119
- ## Requirements for building from source
22
+ ## Execution
120
23
 
121
- - macOS, for the native containment used by the runtime and helpers.
122
- - Node.js **24.22.0 or newer in the 24.x line**, and npm.
123
- - An installed Codex CLI with `app-server` support.
124
- - Xcode Command Line Tools (`/usr/bin/clang`), including a C toolchain, and Git
125
- with your existing author identity available for workspace commits.
24
+ The MCP caller sends the approved workflow to `start_workflow`. Project paths are absolute. The caller can load the same input from a saved JSON definition.
126
25
 
127
- ## Install and build
128
-
129
- From the checkout:
130
-
131
- ```sh
132
- npm ci
133
- npm run build
26
+ ```json
27
+ {
28
+ "repository": "/absolute/path/to/project",
29
+ "confirmed": true,
30
+ "idempotencyKey": "my-project-duration-parser-1",
31
+ "tasks": [{
32
+ "name": "Repair duration parsing",
33
+ "instructions": "Reproduce the fractional-duration bug, fix the parser, and add regression coverage.",
34
+ "verify": "Exercise positive and negative fractional durations against the public API. Explain the observed behavior.",
35
+ "checks": ["npm test"]
36
+ }]
37
+ }
134
38
  ```
135
39
 
136
- The build emits TypeScript **and compiles both C helpers** into
137
- `dist/src/broker/native/.build/`. Starting the server does not build them.
138
-
139
- ## Configure and run
40
+ The engine uses a single ACP client implementation and the maintained `@agentclientprotocol/codex-acp` package, which includes a compatible Codex executable. Codex owns development tools, configuration, authentication, filesystem access and command execution. The project folder is the session working directory. The ACP adapter supports normal Codex configuration and the optional `CODEX_PATH` override. Transmission advertises no client terminal or filesystem services.
140
41
 
141
- For a complete first run with a real model, follow
142
- [the hello-world example](examples/hello-world/README.md). After building and
143
- setting `OPENROUTER_API_KEY`, run `npm run example:hello-world`. It creates its
144
- own disposable Git workspace and private configuration, runs the workflow,
145
- checks the artifact and acceptance commit, and stops the server.
42
+ Each worker submission is tied to a Git tree snapshot. Workers receive the task instructions and requested commands. Verifiers receive the independent verification prompt and the candidate summary in a separate session. Put shared requirements in the task instructions. Optional explicit checks run in the verifier’s harness and their reported results are included in the verdict. Acceptance requires a valid affirmative verdict on the same source tree. A verifier can tell the original worker exactly what to repair. By default a worker gets two repairs before replacement and a task gets two fresh-session retries. The workflow can override `repairs` and `retries`.
146
43
 
147
- Start with [examples/deployment.local.json](examples/deployment.local.json).
148
- It contains no secrets, leaves the runtime disabled, and denies all tool access.
149
- Uppercase `REPLACE_WITH_...` values are placeholders. Before enabling the runtime,
150
- set your Codex executable's absolute path, the local model ID/effort, and an unused
151
- loopback model port served by an owned Responses-compatible synthetic provider.
152
- No model provider is started for you.
44
+ The initial worktree, including existing staged, unstaged and nonignored untracked source, is the diff baseline. Transmission uses a disposable index and private Git objects. Ordinary results remain uncommitted. Use one active workflow per checkout and avoid simultaneous external source edits if you need attribution of the final patch.
153
45
 
154
- Keep state and private files outside the checkout. For a **new** state directory:
46
+ ## Decisions, results and recovery
155
47
 
156
- ```sh
157
- ROOT="$(pwd -P)"
158
- STATE="$HOME/code60-engine-state"
159
- mkdir -m 700 "$STATE" &&
160
- install -m 600 examples/deployment.local.json "$STATE/configuration.json" &&
161
- node --input-type=module -e 'import { randomBytes } from "node:crypto"; import { writeFileSync } from "node:fs"; writeFileSync(process.argv[1], randomBytes(32).toString("base64url") + "\n", { mode: 0o600, flag: "wx" });' "$STATE/operator.token"
162
- ```
48
+ | Status | What the caller receives |
49
+ | --- | --- |
50
+ | running | Current task and role |
51
+ | pausing | Current task while active agents are stopping |
52
+ | paused | Preserved progress, waiting for an explicit resume |
53
+ | needs_input | A decision with a question ID and, for a permission request, the choices offered by the harness |
54
+ | completed | The result, verifier verdict, and ordered accepted task records |
55
+ | failed | The reason and attempt history |
56
+ | cancelled | Confirmation and the accepted tasks so far |
163
57
 
164
- Edit that private configuration copy. Keep it and the token owned by your user,
165
- mode `0600`, without symlinks or hardlinks. The state directory must be `0700`.
166
- Never put the token in configuration JSON, command arguments or Git.
58
+ The MCP tools include status, paginated events, the paginated accepted diff, answering questions, steering, pause, resume and cancellation. `autoApprove` defaults to true and selects a one-time allowance when the harness offers one. Set it to false to receive those decisions yourself. Requirements and scope questions always go to the caller. The harness enforces its effective permissions.
167
59
 
168
- ```sh
169
- npm start -- \
170
- --state-directory "$STATE" \
171
- --fs-helper "$ROOT/dist/src/broker/native/.build/fs-helper" \
172
- --git-helper "$ROOT/dist/src/broker/native/.build/git-helper" \
173
- --configuration "$STATE/configuration.json" \
174
- --operator-token-file "$STATE/operator.token"
175
- ```
60
+ Call `pause_workflow` with `{"runId":"<workflow ID>"}` to interrupt the active worker or verifier immediately. The workflow enters `pausing` before agent shutdown and returns `paused` once its agents and execution loop have stopped. Working files, HEAD, staging, accepted tasks, guidance and spent allowances are preserved. A paused workflow still reserves its checkout. Repeating pause returns the current pause outcome; cancellation can supersede an in-flight pause.
176
61
 
177
- All five paths must be absolute. With the example ports, the authenticated API
178
- is at `http://127.0.0.1:31260/api/v1`. There is no unauthenticated health route or
179
- automatic login. Read the private token in your API client, then follow the
180
- [operator walkthrough and recovery rules](README.engine.md#operator-api-walkthrough)
181
- to register an explicitly authorized Git workspace, publish profiles/workflows,
182
- and start a run. The disabled example supports API setup, not agent execution.
62
+ Call `resume_workflow` with the same run ID to continue. The first unfinished task starts with fresh worker and verifier sessions, including when verification was interrupted. Pause does not spend a fresh-session retry or replenish repair/retry allowances. The new worker is instructed to inspect partial work before repeating consequential actions. Unanswered scope questions survive pause and still require an answer; an answer given while paused is saved without starting work. Permission questions for stopped sessions are withdrawn and must be requested again by the fresh harness. Resume during `pausing` is rejected. Repeated resume after continuation returns the current snapshot; ended workflows reject pause and resume.
183
63
 
184
- ## Connect an agent over MCP
64
+ The engine stays up when the MCP client disconnects. Approved tasks, questions, verdicts, and attempts are stored in SQLite. On restart, the engine continues with the first unfinished task and retains partial working-tree changes. Explicitly paused workflows stay paused until `resume_workflow`; a restart during `pausing` also leaves the workflow paused. Restarting the engine preserves the task’s retry allowance. A lost harness consumes a fresh-session retry. Completed tasks stay accepted. Cancellation leaves the files available for review.
185
65
 
186
- Start the Transmission Server with your private deployment configuration, then
187
- configure your MCP client to launch the built stdio bridge. For clients that use
188
- an `mcpServers` configuration, replace both absolute paths and use the engine's
189
- configured port.
66
+ A client can render the ordered tasks by calling `get_workflow` with only the run ID. For example, during verification the response can look like this:
190
67
 
191
68
  ```json
192
69
  {
193
- "mcpServers": {
194
- "code60": {
195
- "command": "node",
196
- "args": [
197
- "/absolute/path/to/code60-transmission-server/dist/src/mcp/main.js",
198
- "--port", "31260",
199
- "--operator-token-file", "/absolute/path/to/private/operator.token"
200
- ]
201
- }
202
- }
70
+ "runId": "6ef301cf-b89e-4c11-af33-e11b1171a6b8",
71
+ "status": "running",
72
+ "task": "Implement the fix",
73
+ "phase": "verifier",
74
+ "tasks": [
75
+ { "index": 0, "name": "Implement the fix", "state": "verifying" },
76
+ { "index": 1, "name": "Document it", "state": "pending" }
77
+ ],
78
+ "activeTaskIndex": 0,
79
+ "eventCursor": 37,
80
+ "accepted": [],
81
+ "attempts": []
203
82
  }
204
83
  ```
205
84
 
206
- The client launches one bridge per connection. The bridge reads the private token
207
- file on startup and authenticates to the engine on IPv4 loopback. The agent can
208
- exercise the configured operator’s authority, including approval decisions and
209
- recovery. Workspace registration requires an unrestricted operator. To execute
210
- agent steps, enable and configure the deployment runtime.
211
-
212
- 1. Discover runtimes and named checks, then register an authorized worktree with
213
- `create_workspace`. Publish a worker with `create_agent_profile`.
214
- 2. Read the MCP resources `code60://workflow/schema` and
215
- `code60://workflow/example`. Replace the example’s worker placeholder with
216
- the profile’s `latestVersionId`. Pass the YAML or JSON source and any bundled
217
- resources to `validate_workflow`, then publish with `create_workflow`.
218
- 3. Call `create_run` with a unique `idempotencyKey` and a `body` containing
219
- `workspaceId` and the workflow’s `latestVersionId` as `workflowVersionId`.
220
- Save the returned `body.id`. A 202 response means the engine admitted the run.
221
- 4. Read `get_run` or call `list_run_events` with `runId`, `follow: true`,
222
- and `waitSeconds: 30`. Reuse each `body.nextCursor` as `cursor` on the next
223
- poll, including after reconnecting. Inspect approvals, blocks, and artifacts
224
- through their list and get tools. Closing the MCP client leaves the engine
225
- running.
226
-
227
- Tools return the HTTP `status` and engine `body` in structured content and text,
228
- plus `etag`, `location`, and `idempotentReplay` when available. All POST tools
229
- take `body` and `idempotencyKey`. Reuse the same arguments after a lost response.
230
- For a conditional command, pass the target read’s `etag` as `ifMatch`. On a
231
- stale-version error, reread the target before making a new decision. Poll
232
- `get_operation` for asynchronous operator commands.
233
-
234
- ## Workflow examples
235
-
236
- - [Hello world](examples/hello-world/README.md): run a real agent, validate its
237
- artifact, and verify the accepted Git commit. Run `npm run example:hello-world`.
238
- - [Pull request lifecycle](examples/pull-request/README.md): clone the disposable
239
- GitHub repository, create a worktree, make an agent change, push/open/merge a
240
- PR, and delete the worktree. Run `npm run example:pull-request`.
241
-
242
- ## Browse the API specification
243
-
244
- With Docker running, start Swagger UI:
245
-
246
- ```sh
247
- npm run docs:api
248
- ```
249
-
250
- Open [http://localhost:8080](http://localhost:8080) to browse the OpenAPI specification.
251
- The API server does not need to be running. Press Ctrl+C to stop the viewer and
252
- remove its container. The first run downloads the Swagger UI image.
253
-
254
- ## Tests
255
-
256
- ```sh
257
- npm run typecheck
258
- npm test -- --maxWorkers=1
259
- ```
85
+ Each task keeps its zero-based index even when names repeat. The active row can be `implementing`, `verifying`, `repairing`, `needs_input`, `pausing`, or `paused`. Pausing and paused runs retain their active index. A terminal run has a null active index. Previously accepted rows stay `accepted`, the interrupted row records `failed` or `cancelled`, and unstarted rows stay `pending`.
260
86
 
261
- `npm test` builds its own native helpers before running the suite, including the
262
- normal-entrypoint and restart tests. Installed-runtime tests use
263
- `CODE60_CODEX_EXECUTABLE` (an explicit absolute executable path) first, otherwise
264
- look for `codex` on `PATH`; absence is a clear test failure, not a silent skip.
265
- No Codex configuration or credentials are read by that lookup. To run just the
266
- runtime pilot, use `npm run test:pilot -- --maxWorkers=1`. Run native builds/tests
267
- serially. Preserved-image mode is optional, not needed for a fresh clone.
268
- See [validation details](README.engine.md#validation) for focused checks.
87
+ For subsequent activity, call `get_workflow_events` with the same run ID and `after` set to the snapshot’s `eventCursor`. Use the last returned sequence for the next page. Sequence numbers can have gaps between events for a run. Use `after: 0` for earlier history, or refresh `get_workflow` for another complete snapshot.
269
88
 
270
- ## Limits
89
+ Private state defaults to `~/Library/Application Support/Code60 Transmission/workflows`. The first ordinary connection registers a per-user LaunchAgent to restart the engine at login. Keep Node and the installed package available at their original paths for login restart. Credentials supplied only through transient shell environment variables need to be available again after login. For an isolated engine, set `TRANSMISSION_STATE_DIR` to a new absolute directory. Isolated engines skip login registration. Use `code60 status` and `code60 stop` with the same state directory.
271
90
 
272
- - The [hello-world example](examples/hello-world/README.md) has live validation
273
- through OpenRouter with GPT-5.3-Codex. Other provider/model combinations need
274
- their own validation; the normal automated suite uses synthetic providers.
275
- - Single host, one coordinator per state directory, loopback API only. No
276
- multi-host service, public ingress or browser login is supplied.
277
- - Initial broker tools: `read_file`, `write_file`, `list_files`, `search_files`,
278
- `move_file`, `delete_file`, and `http_request`, subject to profile and outer
279
- deployment policy. No shell/process tool, arbitrary Git commands, browser/UI
280
- tools, directory move/delete, or unrestricted host/network access.
281
- - Containment is macOS-only. Preserved-image test success does not establish
282
- clean-build, sanitizer or cross-platform support.
91
+ ## Development and validation
283
92
 
284
- See [README.engine.md](README.engine.md) for configuration, API, authorization,
285
- instruction pinning, deadlines and recovery details.
93
+ Run `npm ci`, `npm run typecheck`, and `npm test`. The HTTP contract is generated from the same schemas used by MCP and the engine. Run `npm run contracts:check` after changing the interface.
286
94
 
287
- ## Repository skills
95
+ For the installed-package live test, run `npm pack` followed by `npm run acceptance:installed -- /absolute/path/to/candidate.tgz /absolute/path/to/new-evidence-directory`. This uses the normal Codex login and real model calls. It installs the package, clones a pinned upstream repository, and exercises rejection, same-session repair, fresh verification, and a second task over MCP. Pass `--agent-caller` to have a real Codex caller design the workflow and submit it over MCP after the test supplies confirmation. The default caller uses the MCP SDK. An independent grader runs the upstream suite and additional public-API assertions and checks the dirty baseline, index and HEAD. The script saves the report, diff, events and uncommitted checkout, then stops the isolated engine.
288
96
 
289
- Use `$add-workflow-example` to add or revise a runnable example with setup
290
- instructions and end-to-end verification. The
291
- [repository skill](.agents/skills/add-workflow-example/SKILL.md) describes the
292
- required implementation and evidence.
97
+ See [project intent](INTENT.md) and the [HTTP contract](reference/openapi.json).
@@ -0,0 +1,115 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { Readable, Writable } from 'node:stream';
4
+ import { ClientApp, ndJsonStream, PROTOCOL_VERSION, } from '@agentclientprotocol/sdk';
5
+ export class AcpHarness {
6
+ child;
7
+ connection;
8
+ ready;
9
+ active = '';
10
+ output = '';
11
+ messageId;
12
+ exited;
13
+ constructor(hooks, cwd) {
14
+ const executable = fileURLToPath(import.meta.resolve('@agentclientprotocol/codex-acp'));
15
+ this.child = spawn(process.execPath, [executable], {
16
+ cwd,
17
+ stdio: 'pipe',
18
+ detached: true,
19
+ });
20
+ this.exited = new Promise((resolve) => this.child.once('close', () => resolve()));
21
+ // Adapter stderr may contain user configuration. Drain it without persisting secrets.
22
+ this.child.stderr.resume();
23
+ const app = new ClientApp()
24
+ .onRequest('session/request_permission', async ({ params }) => {
25
+ const optionId = params.sessionId === this.active
26
+ ? await hooks.permission(params)
27
+ : undefined;
28
+ return {
29
+ outcome: optionId
30
+ ? { outcome: 'selected', optionId }
31
+ : { outcome: 'cancelled' },
32
+ };
33
+ })
34
+ .onNotification('session/update', ({ params: { sessionId, update } }) => {
35
+ if (sessionId !== this.active)
36
+ return;
37
+ if (update.sessionUpdate === 'agent_message_chunk' &&
38
+ update.content.type === 'text') {
39
+ if (update.messageId && this.messageId !== update.messageId)
40
+ this.output = '';
41
+ this.messageId = update.messageId;
42
+ this.output = (this.output + update.content.text).slice(-256 * 1024);
43
+ }
44
+ if (update.sessionUpdate === 'tool_call' ||
45
+ (update.sessionUpdate === 'tool_call_update' && update.status)) {
46
+ hooks.tool(sessionId, [update.toolCallId, update.kind, update.title, update.status]
47
+ .filter(Boolean)
48
+ .join(' ')
49
+ .slice(0, 1600));
50
+ }
51
+ });
52
+ this.connection = app.connect(ndJsonStream(Writable.toWeb(this.child.stdin), Readable.toWeb(this.child.stdout)));
53
+ this.child.on('error', (error) => this.connection.close(error));
54
+ this.ready = this.connection.agent.request('initialize', {
55
+ protocolVersion: PROTOCOL_VERSION,
56
+ clientCapabilities: {},
57
+ clientInfo: { name: 'transmission', version: '1' },
58
+ }, {
59
+ cancellationSignal: AbortSignal.timeout(60000),
60
+ stopWaitingOnCancel: true,
61
+ });
62
+ }
63
+ async session(cwd) {
64
+ const init = await this.ready;
65
+ if (init.protocolVersion !== PROTOCOL_VERSION)
66
+ throw new Error('The installed ACP adapter negotiated an incompatible protocol.');
67
+ const session = await this.connection.agent.request('session/new', { cwd, mcpServers: [] }, {
68
+ cancellationSignal: AbortSignal.timeout(120000),
69
+ stopWaitingOnCancel: true,
70
+ });
71
+ return session.sessionId;
72
+ }
73
+ async prompt(sessionId, text) {
74
+ this.output = '';
75
+ this.messageId = undefined;
76
+ this.active = sessionId;
77
+ try {
78
+ const result = await this.connection.agent.request('session/prompt', {
79
+ sessionId,
80
+ prompt: [{ type: 'text', text }],
81
+ });
82
+ if (result.stopReason !== 'end_turn')
83
+ throw new Error('Agent stopped: ' + result.stopReason);
84
+ return this.output;
85
+ }
86
+ finally {
87
+ this.active = '';
88
+ }
89
+ }
90
+ async close() {
91
+ if (this.active)
92
+ void this.connection.agent
93
+ .notify('session/cancel', { sessionId: this.active })
94
+ .catch(() => { });
95
+ this.connection.close();
96
+ this.child.stdin.end();
97
+ const pid = this.child.pid;
98
+ if (!pid)
99
+ return;
100
+ const signal = (sig) => {
101
+ try {
102
+ process.kill(-pid, sig);
103
+ }
104
+ catch { }
105
+ };
106
+ signal('SIGTERM');
107
+ const kill = setTimeout(() => signal('SIGKILL'), 1500);
108
+ try {
109
+ await this.exited;
110
+ }
111
+ finally {
112
+ clearTimeout(kill);
113
+ }
114
+ }
115
+ }
@@ -0,0 +1,108 @@
1
+ import { z } from 'zod';
2
+ const text = z.string().trim().min(1).max(65536);
3
+ export const task = z.strictObject({
4
+ name: text,
5
+ instructions: text,
6
+ verify: text,
7
+ checks: z.array(text).max(30).optional(),
8
+ });
9
+ export const start = z.strictObject({
10
+ repository: text,
11
+ tasks: z.array(task).min(1).max(100),
12
+ confirmed: z.literal(true),
13
+ idempotencyKey: z.string().min(1).max(256),
14
+ repairs: z.number().int().min(0).max(30).default(2),
15
+ retries: z.number().int().min(0).max(30).default(2),
16
+ autoApprove: z.boolean().default(true),
17
+ });
18
+ export const runId = z.uuid();
19
+ const id = z.strictObject({ runId });
20
+ export const operations = {
21
+ start_workflow: start,
22
+ get_workflow: id,
23
+ get_workflow_events: id.extend({
24
+ after: z.number().int().nonnegative().default(0),
25
+ }),
26
+ get_workflow_diff: id.extend({
27
+ offset: z.number().int().nonnegative().default(0),
28
+ }),
29
+ answer_workflow_question: id.extend({ questionId: z.uuid(), answer: text }),
30
+ send_workflow_message: id.extend({ message: text }),
31
+ pause_workflow: id,
32
+ resume_workflow: id,
33
+ cancel_workflow: id,
34
+ };
35
+ export const descriptions = {
36
+ start_workflow: 'Run the exact workflow confirmed by the user. Design ordered tasks, each with implementation instructions and an independent verification prompt. Show the project, tasks and criteria to the user and obtain confirmation before calling. Reuse the same key on reconnect.',
37
+ get_workflow: 'Read an ordered task snapshot by run ID, including the active task index, decision, accepted results, and event cursor. Pass eventCursor as after to get_workflow_events for subsequent activity.',
38
+ get_workflow_events: 'Read the next page of progress, sessions, native tools and verifier feedback. Use the last sequence number as after.',
39
+ get_workflow_diff: 'Read a page of the accepted patch relative to the initial working tree. Offset is in bytes; content is base64.',
40
+ answer_workflow_question: 'Answer the outstanding decision by ID. For a permission question select an offered option ID.',
41
+ send_workflow_message: 'Deliver new guidance before the current task is accepted.',
42
+ pause_workflow: 'Interrupt active agents and pause the workflow, preserving files and accepted tasks. Returns paused after agents stop. Pause survives engine restart.',
43
+ resume_workflow: 'Resume a paused workflow with fresh sessions for the first unfinished task without spending a retry. An unanswered scope question still requires an answer.',
44
+ cancel_workflow: 'Stop the workflow and its active agent sessions. Leave working files available for review.',
45
+ };
46
+ export const terminal = (status) => ['completed', 'failed', 'cancelled'].includes(status);
47
+ const status = z.enum(['running', 'pausing', 'paused', 'completed', 'needs_input', 'failed', 'cancelled']);
48
+ const checkEvidence = z.object({
49
+ command: text,
50
+ passed: z.boolean(),
51
+ evidence: text,
52
+ });
53
+ const verdict = z.object({
54
+ decision: z.enum(['accept', 'reject']),
55
+ reason: z.string(),
56
+ checks: z.array(checkEvidence).optional(),
57
+ });
58
+ const accepted = z.object({
59
+ name: z.string(),
60
+ result: z.string(),
61
+ verdict,
62
+ worker: z.string(),
63
+ verifier: z.string(),
64
+ revision: z.string(),
65
+ });
66
+ const question = z.object({
67
+ id: z.uuid(),
68
+ text: z.string(),
69
+ options: z.array(z.object({ id: z.string(), name: z.string() })).optional(),
70
+ });
71
+ const taskState = z.enum([
72
+ 'pending', 'implementing', 'verifying', 'repairing',
73
+ 'needs_input', 'accepted', 'failed', 'cancelled',
74
+ 'pausing', 'paused',
75
+ ]);
76
+ const nonnegativeInteger = z.int().nonnegative();
77
+ export const workflowSnapshot = z.object({
78
+ runId,
79
+ status,
80
+ tasks: z.array(z.object({ index: nonnegativeInteger, name: z.string(), state: taskState })),
81
+ activeTaskIndex: nonnegativeInteger.nullable(),
82
+ eventCursor: nonnegativeInteger,
83
+ task: z.string().optional(),
84
+ phase: z.enum(['worker', 'verifier']).optional(),
85
+ decision: question.optional(),
86
+ reason: z.string().optional(),
87
+ attempts: z.array(z.string()),
88
+ accepted: z.array(accepted),
89
+ result: z.string().optional(),
90
+ verdict: verdict.optional(),
91
+ });
92
+ export const snapshotOperations = new Set([
93
+ 'start_workflow', 'get_workflow', 'answer_workflow_question',
94
+ 'send_workflow_message', 'pause_workflow', 'resume_workflow', 'cancel_workflow',
95
+ ]);
96
+ export const workerReply = z.discriminatedUnion('kind', [
97
+ z.object({ kind: z.literal('result'), summary: text }),
98
+ z.object({ kind: z.literal('question'), question: text }),
99
+ ]);
100
+ export const verifierReply = z.discriminatedUnion('kind', [
101
+ z.object({
102
+ kind: z.literal('verdict'),
103
+ decision: z.enum(['accept', 'reject']),
104
+ reason: text,
105
+ checks: z.array(checkEvidence).optional(),
106
+ }),
107
+ z.object({ kind: z.literal('question'), question: text }),
108
+ ]);