code60-transmission-server 0.1.0 → 0.1.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 (95) hide show
  1. package/INTENT.md +47 -0
  2. package/README.md +87 -240
  3. package/dist/src/acp.js +130 -0
  4. package/dist/src/contract.js +133 -0
  5. package/dist/src/engine.js +650 -0
  6. package/dist/src/linux.js +84 -0
  7. package/dist/src/main.js +81 -22
  8. package/dist/src/repository.js +94 -0
  9. package/dist/src/service.js +196 -0
  10. package/package.json +19 -33
  11. package/reference/openapi.json +1073 -0
  12. package/README.engine.md +0 -401
  13. package/dist/src/broker/filesystem.js +0 -385
  14. package/dist/src/broker/index.js +0 -734
  15. package/dist/src/broker/native/README.md +0 -192
  16. package/dist/src/broker/native/build.js +0 -43
  17. package/dist/src/broker/native/fs-helper.c +0 -529
  18. package/dist/src/broker/native/git-helper.c +0 -176
  19. package/dist/src/broker/policy.js +0 -149
  20. package/dist/src/broker/startup-lock.js +0 -14
  21. package/dist/src/broker/types.js +0 -11
  22. package/dist/src/cli/daemon.js +0 -365
  23. package/dist/src/cli/helpers.js +0 -104
  24. package/dist/src/cli/main.js +0 -180
  25. package/dist/src/config/deployment.js +0 -163
  26. package/dist/src/config/documents.js +0 -29
  27. package/dist/src/config/profile-validation.js +0 -123
  28. package/dist/src/config/schema-graph.js +0 -237
  29. package/dist/src/config/schema-loader.js +0 -185
  30. package/dist/src/config/validation-pool.js +0 -105
  31. package/dist/src/config/validation-protocol.js +0 -1
  32. package/dist/src/config/validation-worker.js +0 -106
  33. package/dist/src/config/workflow-language.js +0 -9
  34. package/dist/src/config/workflow-schema.json +0 -534
  35. package/dist/src/config/workflow-types.js +0 -1
  36. package/dist/src/config/workflow-validation.js +0 -95
  37. package/dist/src/engine/budgets.js +0 -50
  38. package/dist/src/engine/clocks.js +0 -27
  39. package/dist/src/engine/commands.js +0 -441
  40. package/dist/src/engine/contracts.js +0 -11
  41. package/dist/src/engine/drain-state.js +0 -31
  42. package/dist/src/engine/effective-permissions.js +0 -120
  43. package/dist/src/engine/instruction-pins.js +0 -205
  44. package/dist/src/engine/retries.js +0 -50
  45. package/dist/src/engine/state.js +0 -1
  46. package/dist/src/engine/timing.js +0 -23
  47. package/dist/src/engine/tool-observations.js +0 -87
  48. package/dist/src/engine/workflow-engine.js +0 -1807
  49. package/dist/src/mcp/catalog.js +0 -71
  50. package/dist/src/mcp/main.js +0 -24
  51. package/dist/src/mcp/server.js +0 -103
  52. package/dist/src/runtime/codex-app-server.js +0 -91
  53. package/dist/src/runtime/containment.js +0 -82
  54. package/dist/src/runtime/engine-driver.js +0 -212
  55. package/dist/src/runtime/json-line-writer.js +0 -192
  56. package/dist/src/runtime/pinned-instruction-sources.js +0 -24
  57. package/dist/src/runtime/protocol-client.js +0 -264
  58. package/dist/src/runtime/protocol-pool.js +0 -183
  59. package/dist/src/runtime/protocol-projection.js +0 -393
  60. package/dist/src/runtime/protocol-types.js +0 -1
  61. package/dist/src/runtime/protocol-worker.js +0 -18
  62. package/dist/src/runtime/provider-bridge.js +0 -288
  63. package/dist/src/runtime/provider-credentials.js +0 -41
  64. package/dist/src/runtime/provider-transport.js +0 -404
  65. package/dist/src/runtime/runtime-broker.js +0 -213
  66. package/dist/src/runtime/workspace-instructions.js +0 -120
  67. package/dist/src/runtime/workspace-view.js +0 -74
  68. package/dist/src/server/api-contract.json +0 -11078
  69. package/dist/src/server/api-types.js +0 -1
  70. package/dist/src/server/application.js +0 -38
  71. package/dist/src/server/auth.js +0 -67
  72. package/dist/src/server/broker-handlers.js +0 -242
  73. package/dist/src/server/control-plane.js +0 -50
  74. package/dist/src/server/deployment.js +0 -237
  75. package/dist/src/server/errors.js +0 -22
  76. package/dist/src/server/history-handlers.js +0 -113
  77. package/dist/src/server/http.js +0 -124
  78. package/dist/src/server/paging.js +0 -56
  79. package/dist/src/server/publication.js +0 -119
  80. package/dist/src/server/tool-event-handler.js +0 -77
  81. package/dist/src/server/workspace-handlers.js +0 -34
  82. package/dist/src/storage/coordinator.js +0 -224
  83. package/dist/src/storage/startup-lock.js +0 -71
  84. package/dist/src/storage/store.js +0 -167
  85. package/dist/src/tools/check-worker.js +0 -81
  86. package/dist/src/tools/checks.js +0 -106
  87. package/dist/src/tools/dns.js +0 -248
  88. package/dist/src/tools/http-contract.js +0 -38
  89. package/dist/src/tools/http.js +0 -358
  90. package/dist/src/tools/index.js +0 -177
  91. package/dist/src/tools/worker-check.js +0 -73
  92. package/dist/src/workspaces/git.js +0 -163
  93. package/dist/src/workspaces/index.js +0 -715
  94. package/examples/deployment.local.json +0 -22
  95. package/scripts/postinstall.mjs +0 -25
@@ -0,0 +1,84 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { randomUUID } from 'node:crypto';
3
+ import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
4
+ import { homedir } from 'node:os';
5
+ import { dirname, isAbsolute, join } from 'node:path';
6
+ export function stateDirectory(env = process.env, os = process.platform, home = homedir()) {
7
+ if (env.TRANSMISSION_STATE_DIR)
8
+ return env.TRANSMISSION_STATE_DIR;
9
+ if (os !== 'linux')
10
+ return join(home, 'Library/Application Support/Code60 Transmission/workflows');
11
+ const base = env.XDG_STATE_HOME;
12
+ return join(base && isAbsolute(base) ? base : join(home, '.local/state'), 'code60-transmission/workflows');
13
+ }
14
+ export function assertLinuxRuntime(arch, glibc) {
15
+ if (arch !== 'x64' || typeof glibc !== 'string' || !glibc)
16
+ throw Error('Linux support requires x86-64 with glibc (Debian 12 or Ubuntu 24.04).');
17
+ }
18
+ function unitArgument(value, exec = false) {
19
+ if (/[\u0000-\u001f\u007f]/u.test(value))
20
+ throw Error('Invalid control character in login service configuration');
21
+ const escaped = value
22
+ .replaceAll('\\', '\\\\')
23
+ .replaceAll('"', '\\"')
24
+ .replaceAll('%', '%%');
25
+ return '"' + (exec ? escaped.replaceAll('$', () => '$$') : escaped) + '"';
26
+ }
27
+ export function loginUnit(node, entry, state, env = process.env) {
28
+ const environment = Object.entries({
29
+ PATH: env.PATH,
30
+ CODEX_HOME: env.CODEX_HOME,
31
+ CODEX_PATH: env.CODEX_PATH,
32
+ TRANSMISSION_STATE_DIR: state,
33
+ })
34
+ .filter((pair) => !!pair[1])
35
+ .map(([key, value]) => 'Environment=' + unitArgument(key + '=' + value));
36
+ return [
37
+ '[Unit]',
38
+ 'Description=Code60 Transmission workflow engine',
39
+ '[Service]',
40
+ 'Type=simple',
41
+ 'UMask=0077',
42
+ ...environment,
43
+ 'ExecStart=' +
44
+ [node, entry, 'engine'].map((arg) => unitArgument(arg, true)).join(' '),
45
+ '[Install]',
46
+ 'WantedBy=default.target',
47
+ '',
48
+ ].join('\n');
49
+ }
50
+ export function installLinuxLoginService(entry, state) {
51
+ const systemctl = (...args) => spawnSync('systemctl', ['--user', ...args], {
52
+ timeout: 5000,
53
+ stdio: 'ignore',
54
+ });
55
+ if (systemctl('show-environment').status !== 0) {
56
+ console.error('No systemd user manager is available. The detached engine will recover unfinished work on the next MCP connection after login.');
57
+ return;
58
+ }
59
+ const base = process.env.XDG_CONFIG_HOME;
60
+ const unit = 'code60-transmission.service';
61
+ const path = join(base && isAbsolute(base) ? base : join(homedir(), '.config'), 'systemd/user', unit);
62
+ const contents = loginUnit(process.execPath, entry, state);
63
+ let previous;
64
+ try {
65
+ previous = readFileSync(path, 'utf8');
66
+ }
67
+ catch (error) {
68
+ if (error.code !== 'ENOENT')
69
+ throw error;
70
+ }
71
+ if (contents !== previous) {
72
+ mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
73
+ const temp = path + '.' + randomUUID();
74
+ writeFileSync(temp, contents, { mode: 0o600, flag: 'wx' });
75
+ renameSync(temp, path);
76
+ }
77
+ // Registration takes effect on the next login. Reloading a live manager on
78
+ // every MCP connection serializes unrelated clients behind service startup.
79
+ if (systemctl('is-enabled', '--quiet', unit).status === 0)
80
+ return;
81
+ if (systemctl('--no-reload', 'enable', unit).status !== 0 &&
82
+ systemctl('is-enabled', '--quiet', unit).status !== 0)
83
+ throw Error('Cannot enable the Code60 Transmission systemd user service for login recovery.');
84
+ }
package/dist/src/main.js CHANGED
@@ -1,25 +1,84 @@
1
- import { pathToFileURL } from 'node:url';
2
- import { openDeployment, parseStartupArguments } from './server/deployment.js';
3
- /** No environment/home discovery, ambient credentials, shell, auto-build, or
4
- * automatic provider login. Every input path must be explicitly supplied. */
5
- export async function main(argv = process.argv.slice(2)) {
6
- const deployment = await openDeployment(parseStartupArguments(argv));
7
- let stopping;
8
- const stop = () => {
9
- stopping ??= deployment.close().catch(() => { process.stderr.write('Engine shutdown requires reconciliation.\n'); process.exitCode = 1; });
10
- };
11
- process.once('SIGINT', stop);
12
- process.once('SIGTERM', stop);
13
- try {
14
- await deployment.listen();
1
+ #!/usr/bin/env node
2
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
5
+ import { z } from 'zod';
6
+ import { operations, descriptions, operationResponses, responseSchemas } from './contract.js';
7
+ import { call, ensure, serve } from './service.js';
8
+ import { assertLinuxRuntime } from './linux.js';
9
+ const cmd = process.argv[2] ?? 'mcp';
10
+ async function main() {
11
+ if (process.platform === 'linux') {
12
+ const { header } = process.report.getReport();
13
+ assertLinuxRuntime(process.arch, header.glibcVersionRuntime);
15
14
  }
16
- catch (error) {
17
- process.removeListener('SIGINT', stop);
18
- process.removeListener('SIGTERM', stop);
19
- await deployment.close();
20
- throw error;
15
+ if (cmd === 'engine') {
16
+ await serve();
17
+ return;
21
18
  }
19
+ if (cmd === 'status' || cmd === 'stop') {
20
+ console.log(await call(cmd === 'status' ? 'health' : 'stop'));
21
+ return;
22
+ }
23
+ if (cmd === 'mcp-config') {
24
+ console.log(JSON.stringify({
25
+ mcpServers: {
26
+ transmission: {
27
+ command: process.execPath,
28
+ args: [process.argv[1], 'mcp'],
29
+ },
30
+ },
31
+ }, null, 2));
32
+ return;
33
+ }
34
+ if (cmd !== 'mcp') {
35
+ throw new Error('Usage: code60 [mcp | mcp-config | status | stop]');
36
+ }
37
+ await ensure();
38
+ const server = new Server({ name: 'transmission', version: '1' }, {
39
+ capabilities: { tools: {} },
40
+ instructions: 'Design ordered tasks with independent verification criteria from the user’s goal. Present the workflow, obtain confirmation, then submit it once with start_workflow. Follow the same run. Ordinary repairs and retries run autonomously. To change unfinished work, pause the workflow, read get_workflow_plan, present the revised tasks and criteria and obtain confirmation, then call revise_workflow and resume_workflow.',
41
+ });
42
+ const outputSchemas = Object.fromEntries(Object.entries(responseSchemas)
43
+ .map(([name, schema]) => [name, z.toJSONSchema(schema)]));
44
+ server.setRequestHandler(ListToolsRequestSchema, () => ({
45
+ tools: Object.entries(operations).map(([name, schema]) => {
46
+ const response = operationResponses[name];
47
+ return {
48
+ name,
49
+ ...(response ? { outputSchema: outputSchemas[response] } : {}),
50
+ description: descriptions[name],
51
+ inputSchema: z.toJSONSchema(schema, { io: 'input' }),
52
+ };
53
+ }),
54
+ }));
55
+ server.setRequestHandler(CallToolRequestSchema, async ({ params }) => {
56
+ try {
57
+ if (!Object.hasOwn(operations, params.name))
58
+ throw new Error('Unknown workflow tool.');
59
+ const data = await call(params.name, params.arguments ?? {});
60
+ return {
61
+ structuredContent: data,
62
+ content: [{ type: 'text', text: JSON.stringify(data) }],
63
+ };
64
+ }
65
+ catch (error) {
66
+ return {
67
+ isError: true,
68
+ content: [
69
+ {
70
+ type: 'text',
71
+ text: error instanceof Error
72
+ ? error.message
73
+ : 'Workflow request failed.',
74
+ },
75
+ ],
76
+ };
77
+ }
78
+ });
79
+ await server.connect(new StdioServerTransport());
22
80
  }
23
- if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
24
- void main().catch(() => { process.stderr.write('Engine startup failed. Check the explicit private deployment configuration and writer barrier.\n'); process.exitCode = 1; });
25
- }
81
+ main().catch((error) => {
82
+ console.error(error.message);
83
+ process.exitCode = 1;
84
+ });
@@ -0,0 +1,94 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { copyFileSync, existsSync, mkdirSync, realpathSync, rmSync, } from 'node:fs';
3
+ import { join, isAbsolute } from 'node:path';
4
+ import { randomUUID } from 'node:crypto';
5
+ // A caller may itself be running inside a Git hook or a linked worktree.
6
+ function gitEnvironment() {
7
+ const env = { ...process.env };
8
+ for (const key of [
9
+ 'GIT_DIR',
10
+ 'GIT_COMMON_DIR',
11
+ 'GIT_WORK_TREE',
12
+ 'GIT_INDEX_FILE',
13
+ 'GIT_OBJECT_DIRECTORY',
14
+ 'GIT_ALTERNATE_OBJECT_DIRECTORIES',
15
+ 'GIT_PREFIX',
16
+ ])
17
+ delete env[key];
18
+ return env;
19
+ }
20
+ function git(root, args, env = gitEnvironment()) {
21
+ return execFileSync('git', [
22
+ '-C',
23
+ root,
24
+ '-c',
25
+ 'core.hooksPath=/dev/null',
26
+ '-c',
27
+ 'core.fsmonitor=false',
28
+ ...args,
29
+ ], {
30
+ env,
31
+ encoding: 'utf8',
32
+ timeout: 120000,
33
+ maxBuffer: 8 * 1024 * 1024,
34
+ stdio: ['ignore', 'pipe', 'pipe'],
35
+ }).trimEnd();
36
+ }
37
+ export function repository(path) {
38
+ if (!isAbsolute(path))
39
+ throw new Error('Supply the absolute path of the existing project.');
40
+ return realpathSync(git(path, ['rev-parse', '--show-toplevel']));
41
+ }
42
+ function environment(root, dir) {
43
+ const objects = join(dir, 'objects');
44
+ mkdirSync(objects, { recursive: true });
45
+ return {
46
+ ...gitEnvironment(),
47
+ GIT_OBJECT_DIRECTORY: objects,
48
+ GIT_ALTERNATE_OBJECT_DIRECTORIES: JSON.stringify(git(root, [
49
+ 'rev-parse',
50
+ '--path-format=absolute',
51
+ '--git-path',
52
+ 'objects',
53
+ ])),
54
+ };
55
+ }
56
+ // Compare worktrees with Git's own ignore, mode, symlink and binary semantics.
57
+ // A disposable index and private objects leave staging and HEAD untouched.
58
+ export function snapshot(root, dir) {
59
+ const env = {
60
+ ...environment(root, dir),
61
+ GIT_INDEX_FILE: join(dir, randomUUID() + '.index'),
62
+ };
63
+ const index = git(root, [
64
+ 'rev-parse',
65
+ '--path-format=absolute',
66
+ '--git-path',
67
+ 'index',
68
+ ]);
69
+ try {
70
+ if (existsSync(index))
71
+ copyFileSync(index, env.GIT_INDEX_FILE);
72
+ git(root, ['add', '-A', '--', '.'], env);
73
+ return git(root, ['write-tree'], env);
74
+ }
75
+ finally {
76
+ rmSync(env.GIT_INDEX_FILE, { force: true });
77
+ }
78
+ }
79
+ export function writePatch(root, dir, baseline, revision, fd) {
80
+ execFileSync('git', [
81
+ '-C',
82
+ root,
83
+ 'diff',
84
+ '--no-ext-diff',
85
+ '--no-textconv',
86
+ '--binary',
87
+ baseline,
88
+ revision,
89
+ ], {
90
+ env: environment(root, dir),
91
+ stdio: ['ignore', fd, 'pipe'],
92
+ timeout: 120000,
93
+ });
94
+ }
@@ -0,0 +1,196 @@
1
+ import { DatabaseSync } from 'node:sqlite';
2
+ import { createServer } from 'node:http';
3
+ import { randomBytes, randomUUID } from 'node:crypto';
4
+ import { execFileSync, spawn } from 'node:child_process';
5
+ import { closeSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, writeFileSync, } from 'node:fs';
6
+ import { homedir } from 'node:os';
7
+ import { dirname, join } from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+ import { setTimeout as delay } from 'node:timers/promises';
10
+ import {} from './engine.js';
11
+ import { operations } from './contract.js';
12
+ import { installLinuxLoginService, stateDirectory } from './linux.js';
13
+ const main = fileURLToPath(new URL('./main.js', import.meta.url));
14
+ export const state = stateDirectory();
15
+ const addressFile = join(state, 'endpoint.json');
16
+ function atomic(path, content) {
17
+ const temp = path + '.' + randomUUID();
18
+ writeFileSync(temp, content, { mode: 0o600 });
19
+ renameSync(temp, path);
20
+ }
21
+ function address() {
22
+ return JSON.parse(readFileSync(addressFile, 'utf8'));
23
+ }
24
+ export async function call(op, args = {}, endpoint = address()) {
25
+ const resp = await fetch('http://127.0.0.1:' + endpoint.port + '/' + op, {
26
+ method: 'POST',
27
+ headers: { authorization: 'Bearer ' + endpoint.token },
28
+ body: JSON.stringify(args),
29
+ signal: AbortSignal.timeout(op === 'health' ? 2000 : 180000),
30
+ });
31
+ const body = await resp.json();
32
+ if (!resp.ok)
33
+ throw new Error(body.error ?? 'Transmission request failed.');
34
+ return body;
35
+ }
36
+ export async function dispatch(engine, op, args) {
37
+ switch (op) {
38
+ case 'start_workflow':
39
+ return engine.start(operations.start_workflow.parse(args));
40
+ case 'get_workflow':
41
+ return engine.status(operations.get_workflow.parse(args).runId);
42
+ case 'get_workflow_plan':
43
+ return engine.plan(operations.get_workflow_plan.parse(args).runId);
44
+ case 'revise_workflow':
45
+ return engine.revise(operations.revise_workflow.parse(args));
46
+ case 'get_workflow_events': {
47
+ const a = operations.get_workflow_events.parse(args);
48
+ return { events: engine.events(a.runId, a.after) };
49
+ }
50
+ case 'get_workflow_diff': {
51
+ const a = operations.get_workflow_diff.parse(args);
52
+ return engine.diff(a.runId, a.offset);
53
+ }
54
+ case 'answer_workflow_question': {
55
+ const a = operations.answer_workflow_question.parse(args);
56
+ return engine.answer(a.runId, a.questionId, a.answer);
57
+ }
58
+ case 'send_workflow_message': {
59
+ const a = operations.send_workflow_message.parse(args);
60
+ return engine.message(a.runId, a.message);
61
+ }
62
+ case 'cancel_workflow':
63
+ return engine.cancel(operations.cancel_workflow.parse(args).runId);
64
+ case 'pause_workflow':
65
+ return engine.pause(operations.pause_workflow.parse(args).runId);
66
+ case 'resume_workflow':
67
+ return engine.resume(operations.resume_workflow.parse(args).runId);
68
+ default:
69
+ throw new Error('Unknown operation.');
70
+ }
71
+ }
72
+ export async function serve() {
73
+ process.umask(0o077);
74
+ mkdirSync(state, { recursive: true, mode: 0o700 });
75
+ // The OS releases the writer lock on process death. Startup races never create two execution owners.
76
+ const lock = new DatabaseSync(join(state, 'owner.sqlite'));
77
+ try {
78
+ // A reserved writer lock is sufficient and coexists with other starters'
79
+ // transient read locks. An exclusive lock can make both starters lose.
80
+ lock.exec('BEGIN IMMEDIATE');
81
+ }
82
+ catch (error) {
83
+ lock.close();
84
+ if (error.errcode === 5)
85
+ return;
86
+ throw error;
87
+ }
88
+ const { Engine } = await import('./engine.js');
89
+ const engine = new Engine(state), token = randomBytes(32).toString('hex');
90
+ let stopping = false;
91
+ async function stop() {
92
+ if (stopping)
93
+ return;
94
+ stopping = true;
95
+ server.close();
96
+ await engine.close();
97
+ rmSync(addressFile, { force: true });
98
+ lock.close();
99
+ }
100
+ const server = createServer(async (req, res) => {
101
+ res.setHeader('Content-Type', 'application/json');
102
+ if (stopping) {
103
+ res.writeHead(503).end(JSON.stringify({ error: 'Engine is stopping.' }));
104
+ return;
105
+ }
106
+ if (req.method !== 'POST' ||
107
+ req.headers.authorization !== 'Bearer ' + token) {
108
+ res.writeHead(403).end('{}');
109
+ return;
110
+ }
111
+ try {
112
+ let s = '', size = 0;
113
+ req.setEncoding('utf8');
114
+ for await (const chunk of req) {
115
+ size += Buffer.byteLength(chunk);
116
+ if (size > 16 * 1024 * 1024)
117
+ throw new Error('Workflow request too large.');
118
+ s += chunk;
119
+ }
120
+ const op = req.url?.slice(1) ?? '';
121
+ const result = op === 'health'
122
+ ? { ready: true, pid: process.pid }
123
+ : op === 'stop'
124
+ ? { stopping: true }
125
+ : await dispatch(engine, op, JSON.parse(s));
126
+ res.end(JSON.stringify(result));
127
+ if (op === 'stop')
128
+ await stop();
129
+ }
130
+ catch (error) {
131
+ res.writeHead(400).end(JSON.stringify({
132
+ error: error instanceof Error ? error.message : 'Request failed.',
133
+ }));
134
+ }
135
+ });
136
+ await new Promise((resolve, reject) => {
137
+ server.once('error', reject);
138
+ server.listen(0, '127.0.0.1', resolve);
139
+ });
140
+ const bound = server.address();
141
+ if (!bound || typeof bound === 'string')
142
+ throw new Error('Missing listener.');
143
+ atomic(addressFile, JSON.stringify({ port: bound.port, token }));
144
+ process.once('SIGTERM', () => void stop());
145
+ process.once('SIGINT', () => void stop());
146
+ }
147
+ function installLoginAgent() {
148
+ if (process.env.TRANSMISSION_STATE_DIR)
149
+ return;
150
+ if (process.platform === 'linux')
151
+ return installLinuxLoginService(main, state);
152
+ if (process.platform !== 'darwin')
153
+ return;
154
+ const file = join(homedir(), 'Library/LaunchAgents/com.codemanufactory.transmission.workflows.plist');
155
+ const env = Object.fromEntries(['PATH', 'CODEX_HOME', 'CODEX_PATH'].flatMap((key) => process.env[key] ? [[key, process.env[key]]] : []));
156
+ const spec = {
157
+ Label: 'com.codemanufactory.transmission.workflows',
158
+ ProgramArguments: [process.execPath, main, 'engine'],
159
+ RunAtLoad: true,
160
+ EnvironmentVariables: env,
161
+ StandardErrorPath: join(state, 'engine.log'),
162
+ };
163
+ const data = execFileSync('/usr/bin/plutil', ['-convert', 'xml1', '-o', '-', '--', '-'], { input: JSON.stringify(spec) });
164
+ mkdirSync(dirname(file), { recursive: true });
165
+ atomic(file, data);
166
+ }
167
+ export async function ensure() {
168
+ mkdirSync(state, { recursive: true, mode: 0o700 });
169
+ installLoginAgent();
170
+ try {
171
+ await call('health');
172
+ return;
173
+ }
174
+ catch { }
175
+ const log = openSync(join(state, 'engine.log'), 'a', 0o600);
176
+ try {
177
+ spawn(process.execPath, [main, 'engine'], {
178
+ detached: true,
179
+ stdio: ['ignore', log, log],
180
+ }).unref();
181
+ }
182
+ finally {
183
+ closeSync(log);
184
+ }
185
+ const until = Date.now() + 20000;
186
+ while (Date.now() < until) {
187
+ try {
188
+ await call('health');
189
+ return;
190
+ }
191
+ catch {
192
+ await delay(100);
193
+ }
194
+ }
195
+ throw new Error('Engine did not start. See ' + join(state, 'engine.log'));
196
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "code60-transmission-server",
3
- "version": "0.1.0",
4
- "description": "Local workflow server and stdio MCP launcher for bounded coding-agent steps against Git workspaces.",
3
+ "version": "0.1.1",
4
+ "description": "Run user-approved workflows with independent coding agents over ACP.",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
7
7
  "mcp",
@@ -13,58 +13,44 @@
13
13
  ],
14
14
  "type": "module",
15
15
  "os": [
16
- "darwin"
16
+ "darwin",
17
+ "linux"
17
18
  ],
18
19
  "engines": {
19
20
  "node": ">=24.22.0 <25"
20
21
  },
21
22
  "bin": {
22
- "code60-transmission-server": "dist/src/cli/main.js",
23
- "code60": "dist/src/cli/main.js"
23
+ "code60": "dist/src/main.js",
24
+ "code60-transmission-server": "dist/src/main.js"
24
25
  },
25
26
  "files": [
26
- "dist/src/**/*.js",
27
- "dist/src/**/*.json",
28
- "dist/src/broker/native/fs-helper.c",
29
- "dist/src/broker/native/git-helper.c",
30
- "dist/src/broker/native/README.md",
31
- "!dist/src/broker/native/.build",
32
- "!dist/src/broker/native/.build/**",
33
- "examples/deployment.local.json",
34
- "scripts/postinstall.mjs",
27
+ "dist/src",
28
+ "reference/openapi.json",
35
29
  "LICENSE",
36
30
  "README.md",
37
- "README.engine.md"
31
+ "INTENT.md"
38
32
  ],
39
33
  "scripts": {
40
- "start": "node dist/src/main.js",
41
- "build": "tsc -p tsconfig.build.json && node scripts/build-native.mjs",
34
+ "build": "tsc -p tsconfig.build.json",
42
35
  "prepack": "npm run build",
43
- "postinstall": "node scripts/postinstall.mjs",
44
- "package:macos": "bash scripts/package-macos.sh",
45
- "docs:api": "docker run --rm -p 127.0.0.1:8080:8080 -e SWAGGER_JSON=/spec/openapi.yaml -v \"$PWD/reference/workflow-engine/api:/spec:ro\" docker.swagger.io/swaggerapi/swagger-ui",
46
- "example:hello-world": "node examples/hello-world/run.mjs",
47
- "example:pull-request": "node examples/pull-request/run.mjs",
48
- "smoke:native": "node scripts/smoke-native.mjs",
49
36
  "typecheck": "tsc --noEmit",
50
37
  "test": "npm run build && vitest run",
51
- "test:pilot": "npm run build && vitest run tests/pilot"
38
+ "acceptance:installed": "node scripts/acceptance/installed.mjs",
39
+ "package:macos": "bash scripts/package-macos.sh",
40
+ "contracts": "npm run build && node scripts/contracts.mjs",
41
+ "contracts:check": "npm run build && node scripts/contracts.mjs --check",
42
+ "prebuild": "node -e \"require('node:fs').rmSync('dist/src',{recursive:true,force:true})\""
52
43
  },
53
44
  "dependencies": {
54
- "@agentclientprotocol/sdk": "2.7.0",
45
+ "@agentclientprotocol/codex-acp": "2.9.0",
46
+ "@agentclientprotocol/sdk": "2.9.1",
55
47
  "@modelcontextprotocol/sdk": "1.32.2",
56
- "ajv": "8.20.0",
57
- "ajv-formats": "3.0.1",
58
- "better-sqlite3": "13.2.0",
59
- "fastify": "5.12.8",
60
- "yaml": "2.9.1"
48
+ "zod": "^4.0.0",
49
+ "@openai/codex": "0.171.0"
61
50
  },
62
51
  "devDependencies": {
63
- "@types/better-sqlite3": "9.6.0",
64
52
  "@types/node": "26.6.6",
65
- "eslint": "10.15.0",
66
53
  "typescript": "6.0.3",
67
- "typescript-eslint": "8.73.0",
68
54
  "vitest": "5.1.0"
69
55
  }
70
56
  }