code60-transmission-server 0.0.0-stage → 0.1.0-staging.3

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 (88) hide show
  1. package/LICENSE +180 -0
  2. package/README.engine.md +401 -0
  3. package/README.md +294 -2
  4. package/dist/src/broker/filesystem.js +385 -0
  5. package/dist/src/broker/index.js +734 -0
  6. package/dist/src/broker/native/README.md +192 -0
  7. package/dist/src/broker/native/build.js +43 -0
  8. package/dist/src/broker/native/fs-helper.c +529 -0
  9. package/dist/src/broker/native/git-helper.c +205 -0
  10. package/dist/src/broker/policy.js +149 -0
  11. package/dist/src/broker/startup-lock.js +14 -0
  12. package/dist/src/broker/types.js +11 -0
  13. package/dist/src/cli/daemon.js +365 -0
  14. package/dist/src/cli/helpers.js +104 -0
  15. package/dist/src/cli/main.js +180 -0
  16. package/dist/src/config/deployment.js +166 -0
  17. package/dist/src/config/documents.js +29 -0
  18. package/dist/src/config/profile-validation.js +123 -0
  19. package/dist/src/config/schema-graph.js +237 -0
  20. package/dist/src/config/schema-loader.js +185 -0
  21. package/dist/src/config/validation-pool.js +105 -0
  22. package/dist/src/config/validation-protocol.js +1 -0
  23. package/dist/src/config/validation-worker.js +106 -0
  24. package/dist/src/config/workflow-language.js +9 -0
  25. package/dist/src/config/workflow-schema.json +534 -0
  26. package/dist/src/config/workflow-types.js +1 -0
  27. package/dist/src/config/workflow-validation.js +95 -0
  28. package/dist/src/engine/budgets.js +50 -0
  29. package/dist/src/engine/clocks.js +27 -0
  30. package/dist/src/engine/commands.js +441 -0
  31. package/dist/src/engine/contracts.js +11 -0
  32. package/dist/src/engine/drain-state.js +31 -0
  33. package/dist/src/engine/effective-permissions.js +120 -0
  34. package/dist/src/engine/instruction-pins.js +205 -0
  35. package/dist/src/engine/retries.js +50 -0
  36. package/dist/src/engine/state.js +1 -0
  37. package/dist/src/engine/timing.js +23 -0
  38. package/dist/src/engine/tool-observations.js +87 -0
  39. package/dist/src/engine/workflow-engine.js +1807 -0
  40. package/dist/src/main.js +25 -0
  41. package/dist/src/mcp/catalog.js +71 -0
  42. package/dist/src/mcp/main.js +24 -0
  43. package/dist/src/mcp/server.js +116 -0
  44. package/dist/src/runtime/codex-app-server.js +91 -0
  45. package/dist/src/runtime/containment.js +82 -0
  46. package/dist/src/runtime/engine-driver.js +212 -0
  47. package/dist/src/runtime/json-line-writer.js +192 -0
  48. package/dist/src/runtime/pinned-instruction-sources.js +24 -0
  49. package/dist/src/runtime/protocol-client.js +264 -0
  50. package/dist/src/runtime/protocol-pool.js +183 -0
  51. package/dist/src/runtime/protocol-projection.js +393 -0
  52. package/dist/src/runtime/protocol-types.js +1 -0
  53. package/dist/src/runtime/protocol-worker.js +18 -0
  54. package/dist/src/runtime/provider-bridge.js +288 -0
  55. package/dist/src/runtime/provider-credentials.js +41 -0
  56. package/dist/src/runtime/provider-transport.js +404 -0
  57. package/dist/src/runtime/runtime-broker.js +213 -0
  58. package/dist/src/runtime/workspace-instructions.js +120 -0
  59. package/dist/src/runtime/workspace-view.js +74 -0
  60. package/dist/src/server/api-contract.json +11086 -0
  61. package/dist/src/server/api-types.js +1 -0
  62. package/dist/src/server/application.js +38 -0
  63. package/dist/src/server/auth.js +67 -0
  64. package/dist/src/server/broker-handlers.js +242 -0
  65. package/dist/src/server/control-plane.js +50 -0
  66. package/dist/src/server/deployment.js +237 -0
  67. package/dist/src/server/errors.js +22 -0
  68. package/dist/src/server/history-handlers.js +113 -0
  69. package/dist/src/server/http.js +124 -0
  70. package/dist/src/server/paging.js +56 -0
  71. package/dist/src/server/publication.js +119 -0
  72. package/dist/src/server/tool-event-handler.js +77 -0
  73. package/dist/src/server/workspace-handlers.js +34 -0
  74. package/dist/src/storage/coordinator.js +224 -0
  75. package/dist/src/storage/startup-lock.js +71 -0
  76. package/dist/src/storage/store.js +167 -0
  77. package/dist/src/tools/check-worker.js +81 -0
  78. package/dist/src/tools/checks.js +106 -0
  79. package/dist/src/tools/dns.js +248 -0
  80. package/dist/src/tools/http-contract.js +38 -0
  81. package/dist/src/tools/http.js +358 -0
  82. package/dist/src/tools/index.js +177 -0
  83. package/dist/src/tools/worker-check.js +73 -0
  84. package/dist/src/workspaces/git.js +227 -0
  85. package/dist/src/workspaces/index.js +715 -0
  86. package/examples/deployment.local.json +22 -0
  87. package/package.json +68 -4
  88. package/scripts/postinstall.mjs +25 -0
package/README.md CHANGED
@@ -1,3 +1,295 @@
1
- # Temporary Holding Version
1
+ # Code60 Transmission Server
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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.
6
+
7
+ ## Run with npx (MCP)
8
+
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:
12
+
13
+ ```json
14
+ {
15
+ "mcpServers": {
16
+ "code60": {
17
+ "command": "npx",
18
+ "args": ["-y", "code60-transmission-server"]
19
+ }
20
+ }
21
+ }
22
+ ```
23
+
24
+ Or print the ready-to-paste client entry from Terminal:
25
+
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
120
+
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.
126
+
127
+ ## Install and build
128
+
129
+ From the checkout:
130
+
131
+ ```sh
132
+ npm ci
133
+ npm run build
134
+ ```
135
+
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
140
+
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.
146
+
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.
153
+
154
+ Keep state and private files outside the checkout. For a **new** state directory:
155
+
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
+ ```
163
+
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.
167
+
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
+ ```
176
+
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.
183
+
184
+ ## Connect an agent over MCP
185
+
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.
190
+
191
+ ```json
192
+ {
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
+ }
203
+ }
204
+ ```
205
+
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`. Use the selected provider's `credentialReferences`
214
+ from `get_runtime_configuration` as `credentialRefs.provider` when publishing
215
+ a worker with `create_agent_profile`.
216
+ 2. Call `get_workflow_schema` and `get_workflow_example`, or read the MCP
217
+ resources `code60://workflow/schema` and `code60://workflow/example`.
218
+ Replace the example’s worker placeholder with
219
+ the profile’s `latestVersionId`. Pass the YAML or JSON source and any bundled
220
+ resources to `validate_workflow`, then publish with `create_workflow`.
221
+ 3. Call `create_run` with a unique `idempotencyKey` and a `body` containing
222
+ `workspaceId` and the workflow’s `latestVersionId` as `workflowVersionId`.
223
+ Save the returned `body.id`. A 202 response means the engine admitted the run.
224
+ 4. Read `get_run` or call `list_run_events` with `runId`, `follow: true`,
225
+ and `waitSeconds: 30`. Reuse each `body.nextCursor` as `cursor` on the next
226
+ poll, including after reconnecting. Inspect approvals, blocks, and artifacts
227
+ through their list and get tools. Closing the MCP client leaves the engine
228
+ running.
229
+
230
+ Tools return the HTTP `status` and engine `body` in structured content and text,
231
+ plus `etag`, `location`, and `idempotentReplay` when available. All POST tools
232
+ take `body` and `idempotencyKey`. Reuse the same arguments after a lost response.
233
+ For a conditional command, pass the target read’s `etag` as `ifMatch`. On a
234
+ stale-version error, reread the target before making a new decision. Poll
235
+ `get_operation` for asynchronous operator commands.
236
+
237
+ ## Workflow examples
238
+
239
+ - [Hello world](examples/hello-world/README.md): run a real agent, validate its
240
+ artifact, and verify the accepted Git commit. Run `npm run example:hello-world`.
241
+ - [Pull request lifecycle](examples/pull-request/README.md): clone the disposable
242
+ GitHub repository, create a worktree, make an agent change, push/open/merge a
243
+ PR, and delete the worktree. Run `npm run example:pull-request`.
244
+
245
+ ## Browse the API specification
246
+
247
+ With Docker running, start Swagger UI:
248
+
249
+ ```sh
250
+ npm run docs:api
251
+ ```
252
+
253
+ Open [http://localhost:8080](http://localhost:8080) to browse the OpenAPI specification.
254
+ The API server does not need to be running. Press Ctrl+C to stop the viewer and
255
+ remove its container. The first run downloads the Swagger UI image.
256
+
257
+ ## Tests
258
+
259
+ ```sh
260
+ npm run typecheck
261
+ npm test -- --maxWorkers=1
262
+ ```
263
+
264
+ `npm test` builds its own native helpers before running the suite, including the
265
+ normal-entrypoint and restart tests. Installed-runtime tests use
266
+ `CODE60_CODEX_EXECUTABLE` (an explicit absolute executable path) first, otherwise
267
+ look for `codex` on `PATH`; absence is a clear test failure, not a silent skip.
268
+ No Codex configuration or credentials are read by that lookup. To run just the
269
+ runtime pilot, use `npm run test:pilot -- --maxWorkers=1`. Run native builds/tests
270
+ serially. Preserved-image mode is optional, not needed for a fresh clone.
271
+ See [validation details](README.engine.md#validation) for focused checks.
272
+
273
+ ## Limits
274
+
275
+ - The [hello-world example](examples/hello-world/README.md) has live validation
276
+ through OpenRouter with GPT-5.3-Codex. Other provider/model combinations need
277
+ their own validation; the normal automated suite uses synthetic providers.
278
+ - Single host, one coordinator per state directory, loopback API only. No
279
+ multi-host service, public ingress or browser login is supplied.
280
+ - Initial broker tools: `read_file`, `write_file`, `list_files`, `search_files`,
281
+ `move_file`, `delete_file`, and `http_request`, subject to profile and outer
282
+ deployment policy. No shell/process tool, arbitrary Git commands, browser/UI
283
+ tools, directory move/delete, or unrestricted host/network access.
284
+ - Containment is macOS-only. Preserved-image test success does not establish
285
+ clean-build, sanitizer or cross-platform support.
286
+
287
+ See [README.engine.md](README.engine.md) for configuration, API, authorization,
288
+ instruction pinning, deadlines and recovery details.
289
+
290
+ ## Repository skills
291
+
292
+ Use `$add-workflow-example` to add or revise a runnable example with setup
293
+ instructions and end-to-end verification. The
294
+ [repository skill](.agents/skills/add-workflow-example/SKILL.md) describes the
295
+ required implementation and evidence.