code60-transmission-server 0.1.0-staging.6 → 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 (104) hide show
  1. package/INTENT.md +47 -0
  2. package/README.md +87 -308
  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 -25
  8. package/dist/src/repository.js +94 -0
  9. package/dist/src/service.js +196 -0
  10. package/package.json +19 -35
  11. package/reference/openapi.json +1073 -0
  12. package/README.engine.md +0 -463
  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 -207
  16. package/dist/src/broker/native/build.js +0 -46
  17. package/dist/src/broker/native/command-helper.c +0 -93
  18. package/dist/src/broker/native/fs-helper.c +0 -529
  19. package/dist/src/broker/native/git-helper.c +0 -205
  20. package/dist/src/broker/policy.js +0 -149
  21. package/dist/src/broker/startup-lock.js +0 -14
  22. package/dist/src/broker/types.js +0 -11
  23. package/dist/src/cli/configure.js +0 -193
  24. package/dist/src/cli/daemon.js +0 -369
  25. package/dist/src/cli/helpers.js +0 -112
  26. package/dist/src/cli/main.js +0 -189
  27. package/dist/src/cli/runtime-build.js +0 -38
  28. package/dist/src/config/coding-policy.js +0 -4
  29. package/dist/src/config/deployment.js +0 -182
  30. package/dist/src/config/documents.js +0 -29
  31. package/dist/src/config/profile-validation.js +0 -123
  32. package/dist/src/config/schema-graph.js +0 -237
  33. package/dist/src/config/schema-loader.js +0 -185
  34. package/dist/src/config/validation-pool.js +0 -105
  35. package/dist/src/config/validation-protocol.js +0 -1
  36. package/dist/src/config/validation-worker.js +0 -106
  37. package/dist/src/config/workflow-language.js +0 -9
  38. package/dist/src/config/workflow-schema.json +0 -545
  39. package/dist/src/config/workflow-types.js +0 -1
  40. package/dist/src/config/workflow-validation.js +0 -95
  41. package/dist/src/engine/budgets.js +0 -50
  42. package/dist/src/engine/clocks.js +0 -27
  43. package/dist/src/engine/commands.js +0 -472
  44. package/dist/src/engine/contracts.js +0 -11
  45. package/dist/src/engine/drain-state.js +0 -31
  46. package/dist/src/engine/effective-permissions.js +0 -120
  47. package/dist/src/engine/instruction-pins.js +0 -205
  48. package/dist/src/engine/retries.js +0 -50
  49. package/dist/src/engine/state.js +0 -1
  50. package/dist/src/engine/timing.js +0 -23
  51. package/dist/src/engine/tool-observations.js +0 -87
  52. package/dist/src/engine/workflow-engine.js +0 -1862
  53. package/dist/src/mcp/catalog.js +0 -71
  54. package/dist/src/mcp/main.js +0 -26
  55. package/dist/src/mcp/server.js +0 -147
  56. package/dist/src/runtime/codex-app-server.js +0 -91
  57. package/dist/src/runtime/containment.js +0 -82
  58. package/dist/src/runtime/engine-driver.js +0 -221
  59. package/dist/src/runtime/json-line-writer.js +0 -192
  60. package/dist/src/runtime/pinned-instruction-sources.js +0 -24
  61. package/dist/src/runtime/protocol-client.js +0 -264
  62. package/dist/src/runtime/protocol-pool.js +0 -183
  63. package/dist/src/runtime/protocol-projection.js +0 -393
  64. package/dist/src/runtime/protocol-types.js +0 -1
  65. package/dist/src/runtime/protocol-worker.js +0 -18
  66. package/dist/src/runtime/provider-bridge.js +0 -290
  67. package/dist/src/runtime/provider-credentials.js +0 -41
  68. package/dist/src/runtime/provider-transport.js +0 -406
  69. package/dist/src/runtime/runtime-broker.js +0 -213
  70. package/dist/src/runtime/workspace-instructions.js +0 -120
  71. package/dist/src/runtime/workspace-view.js +0 -74
  72. package/dist/src/server/api-contract.json +0 -11614
  73. package/dist/src/server/api-types.js +0 -1
  74. package/dist/src/server/application.js +0 -44
  75. package/dist/src/server/auth.js +0 -67
  76. package/dist/src/server/broker-handlers.js +0 -242
  77. package/dist/src/server/coding.js +0 -254
  78. package/dist/src/server/control-plane.js +0 -50
  79. package/dist/src/server/deployment.js +0 -249
  80. package/dist/src/server/errors.js +0 -22
  81. package/dist/src/server/history-handlers.js +0 -127
  82. package/dist/src/server/http.js +0 -124
  83. package/dist/src/server/paging.js +0 -56
  84. package/dist/src/server/publication.js +0 -119
  85. package/dist/src/server/tool-event-handler.js +0 -77
  86. package/dist/src/server/workspace-handlers.js +0 -34
  87. package/dist/src/storage/coordinator.js +0 -224
  88. package/dist/src/storage/startup-lock.js +0 -71
  89. package/dist/src/storage/store.js +0 -167
  90. package/dist/src/tools/check-worker.js +0 -81
  91. package/dist/src/tools/checks.js +0 -117
  92. package/dist/src/tools/command-check.js +0 -34
  93. package/dist/src/tools/commands.js +0 -310
  94. package/dist/src/tools/developer.js +0 -351
  95. package/dist/src/tools/dns.js +0 -248
  96. package/dist/src/tools/http-contract.js +0 -38
  97. package/dist/src/tools/http.js +0 -358
  98. package/dist/src/tools/index.js +0 -194
  99. package/dist/src/tools/worker-check.js +0 -73
  100. package/dist/src/workspaces/git.js +0 -227
  101. package/dist/src/workspaces/index.js +0 -937
  102. package/dist/src/workspaces/source.js +0 -295
  103. package/examples/deployment.local.json +0 -22
  104. package/scripts/postinstall.mjs +0 -26
@@ -1,310 +0,0 @@
1
- import { spawn } from 'node:child_process';
2
- import { randomUUID } from 'node:crypto';
3
- import { closeSync, constants, existsSync, mkdirSync, openSync, readSync, realpathSync, statSync, writeFileSync, writeSync } from 'node:fs';
4
- import { basename, dirname, join } from 'node:path';
5
- import { SourceRepository, within } from '../workspaces/source.js';
6
- import { BrokerError } from '../broker/types.js';
7
- import { digest } from '../broker/policy.js';
8
- import { isTrustedHelper } from '../cli/helpers.js';
9
- export const DEFAULT_COMMAND_SETTINGS = { enabled: false, network: 'outbound', toolchainPaths: [], generatedPaths: ['node_modules', 'dist', 'build', 'coverage', '.cache', '.next', 'target', '.venv', 'tsconfig.tsbuildinfo', '.eslintcache'], timeoutMs: 600_000, maxOutputBytes: 67_108_864 };
10
- /** A trusted refusal before any command intent, source gate, or process exists. */
11
- export class CommandAdmissionError extends BrokerError {
12
- }
13
- const quote = (s) => JSON.stringify(s);
14
- const groupAlive = (pid) => { try {
15
- process.kill(-pid, 0);
16
- return true;
17
- }
18
- catch (e) {
19
- if (e.code === 'ESRCH')
20
- return false;
21
- throw e;
22
- } };
23
- export function assertCommandScope(binding, readOnly) {
24
- const operations = readOnly ? ['read'] : ['read', 'write', 'delete'];
25
- for (const policy of [binding.permissions, binding.deploymentPermissions]) {
26
- const rules = policy.rules.filter(r => r.kind === 'filesystem' && r.root === 'workspace');
27
- for (const operation of operations) {
28
- if (!rules.some(r => r.kind === 'filesystem' && r.path === '.' && r.recursive && r.effect !== 'deny' && r.operations.includes(operation)) ||
29
- rules.some(r => r.kind === 'filesystem' && r.operations.includes(operation) && (r.effect === 'deny' || r.path !== '.' && r.effect === 'require_approval')))
30
- throw new CommandAdmissionError('command_requires_whole_workspace_scope', 403);
31
- }
32
- }
33
- }
34
- /** All process work remains owned until the process group and output writers settle. */
35
- export class CommandRunner {
36
- options;
37
- running = new Map();
38
- settings;
39
- constructor(options) {
40
- this.options = options;
41
- this.settings = { ...DEFAULT_COMMAND_SETTINGS, ...options.settings };
42
- mkdirSync(options.directory, { recursive: true, mode: 0o700 });
43
- options.store.coordinator.atomic(() => { options.store.coordinator.db.prepare("UPDATE engine_private SET body=json_set(body,'$.state','uncertain','$.error','process_lost_requires_reconciliation') WHERE scope='command' AND json_extract(body,'$.state')='running'").run(); });
44
- }
45
- save(record) { this.options.store.setPrivate('command', record.id, record); }
46
- get(id, binding) {
47
- const record = this.options.store.private('command', id);
48
- if (!record || binding && (record.runId !== binding.runId || record.sessionId !== binding.sessionId || record.epoch !== binding.epoch))
49
- throw new BrokerError('command_not_assigned', 404);
50
- return record;
51
- }
52
- records(runId) { return this.options.store.coordinator.db.prepare("SELECT body FROM engine_private WHERE scope='command' AND json_extract(body,'$.runId')=? ORDER BY rowid").all(runId).map(r => JSON.parse(r.body)); }
53
- activeWork(runId) { return this.records(runId).filter(r => r.state === 'running' || r.state === 'uncertain').length; }
54
- profile(repository, state, readOnly, allowGenerated, id) {
55
- const nodeDirectory = dirname(realpathSync(process.execPath)), nodeRoot = basename(nodeDirectory) === 'bin' ? dirname(nodeDirectory) : nodeDirectory;
56
- const toolchains = [...new Set(['/usr', '/bin', '/sbin', '/System', '/Library/Developer/CommandLineTools', '/Library/Apple', nodeRoot, ...this.settings.toolchainPaths.map(p => realpathSync(p))])];
57
- const generated = (allowGenerated ? this.settings.generatedPaths : []).map(p => repository.safePath(p, true));
58
- if (this.options.protectedPaths.some(p => within(repository.root, p) || within(p, repository.root)))
59
- throw new BrokerError('protected_command_workspace', 403);
60
- const protectedPaths = [...this.options.protectedPaths, repository.gitDirectory, repository.commonDirectory, join(repository.root, '.git')];
61
- const rules = ['(version 1)', '(deny default)', '(allow process-fork)', '(allow process-info* (target same-sandbox))', '(allow signal (target same-sandbox))', '(allow sysctl-read)', '(allow mach-lookup (global-name "com.apple.system.opendirectoryd.libinfo"))',
62
- `(allow mach-lookup (global-name ${quote(`code60.command.${id}.allow`)}))`, `(deny mach-lookup (global-name ${quote(`code60.command.${id}.deny`)}))`,
63
- `(allow file-read* process-exec (literal ${quote(this.options.workspaces.commandHelperPath)}))`,
64
- ...(this.settings.network === 'outbound' ? ['(allow mach-lookup (global-name "com.apple.mDNSResponder") (global-name "com.apple.trustd") (global-name "com.apple.trustd.agent"))'] : []),
65
- '(allow file-read-metadata file-test-existence)',
66
- `(allow file-read* (literal "/") (subpath ${quote(repository.root)}) (subpath ${quote(repository.gitDirectory)}) (subpath ${quote(repository.commonDirectory)}) (subpath ${quote(state)}) ${toolchains.map(p => `(subpath ${quote(p)})`).join(' ')} (subpath "/private/var/db/dyld") (literal "/dev/null") (literal "/dev/urandom") (literal "/dev/random") (subpath "/etc") (subpath "/private/etc"))`,
67
- `(allow process-exec ${[repository.root, ...toolchains].map(p => `(subpath ${quote(p)})`).join(' ')})`,
68
- `(allow file-write* (subpath ${quote(state)}) (literal "/dev/null") ${readOnly ? generated.map(p => `(subpath ${quote(p)})`).join(' ') : `(subpath ${quote(repository.root)})`})`,
69
- ...protectedPaths.map(p => `(deny file-write* (require-all (subpath ${quote(p)}) (require-not (subpath ${quote(state)}))))`),
70
- ...this.options.protectedPaths.map(p => `(deny file-read-data (require-all (subpath ${quote(p)}) (require-not (subpath ${quote(state)})) (require-not (literal ${quote(this.options.workspaces.commandHelperPath)}))))`),
71
- ...(this.settings.network === 'outbound' ? ['(allow network-outbound)', '(allow network-bind (local ip "localhost:*"))', '(allow network-inbound (local ip "localhost:*"))'] : [])];
72
- if (readOnly)
73
- for (const entry of repository.sourceEntries())
74
- rules.push(`(deny file-write* (literal ${quote(join(repository.root, entry.path))}))`);
75
- return rules.join('\n');
76
- }
77
- async start(binding, request) {
78
- if (binding.role !== 'worker' && !request.readOnly)
79
- throw new CommandAdmissionError('project_read_only', 403);
80
- if (!this.settings.enabled)
81
- throw new CommandAdmissionError('commands_not_configured', 422);
82
- if (!isTrustedHelper(this.options.workspaces.commandHelperPath))
83
- throw new CommandAdmissionError('command_supervisor_unavailable', 422);
84
- assertCommandScope(binding, request.readOnly ?? false);
85
- if (typeof request.command !== 'string' || !request.command.trim() || request.command.length > 65_536 || request.command.includes('\0'))
86
- throw new CommandAdmissionError('invalid_command', 400);
87
- const timeoutMs = request.timeoutMs ?? this.settings.timeoutMs;
88
- if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 86_400_000)
89
- throw new CommandAdmissionError('invalid_command_timeout', 400);
90
- if (request.env && Object.entries(request.env).some(([k, v]) => !/^[A-Za-z_][A-Za-z0-9_]*$/.test(k) || typeof v !== 'string' || v.includes('\0') || /^(HOME|CODEX_HOME|XDG_.*|TMPDIR|DYLD_.*|LD_.*|PATH|GIT_.*)$/i.test(k)))
91
- throw new CommandAdmissionError('invalid_command_environment', 400);
92
- const repository = this.options.workspaces.sourceRepository(binding.runId);
93
- if (!repository)
94
- throw new CommandAdmissionError('source_tracking_required', 422);
95
- let cwd;
96
- try {
97
- cwd = repository.safePath(request.cwd ?? '.', false, true);
98
- if (!statSync(cwd).isDirectory())
99
- throw new CommandAdmissionError('command_cwd_not_directory', 422);
100
- }
101
- catch (error) {
102
- if (['ENOENT', 'ENOTDIR'].includes(error.code ?? ''))
103
- throw new CommandAdmissionError('command_cwd_not_found', 422);
104
- if (['EACCES', 'EPERM'].includes(error.code ?? ''))
105
- throw new CommandAdmissionError('command_cwd_forbidden', 403);
106
- throw error;
107
- }
108
- const readOnly = request.readOnly ?? false;
109
- if (this.records(binding.runId).some(r => r.state === 'running' && (!readOnly || !r.readOnly)))
110
- throw new CommandAdmissionError('workspace_command_active');
111
- const id = randomUUID(), state = join(this.options.directory, id);
112
- mkdirSync(state, { mode: 0o700 });
113
- mkdirSync(join(state, 'tmp'), { mode: 0o700 });
114
- mkdirSync(join(state, 'cache'), { mode: 0o700 });
115
- let allowGenerated = binding.role === 'worker';
116
- try {
117
- assertCommandScope(binding, false);
118
- }
119
- catch {
120
- allowGenerated = false;
121
- }
122
- const profile = join(state, 'sandbox.sb');
123
- writeFileSync(profile, this.profile(repository, state, readOnly, allowGenerated, id), { mode: 0o600 });
124
- const before = this.options.workspaces.beginCommand(binding.runId, !readOnly);
125
- const record = { id, runId: binding.runId, sessionId: binding.sessionId, epoch: binding.epoch, command: request.command, cwd: request.cwd ?? '.', readOnly, state: 'running', beforeRevisionId: before.id,
126
- executionConfigurationDigest: digest({ settings: this.settings, environment: request.env ?? {}, shell: '/bin/sh' }),
127
- stdoutBytes: 0, stderrBytes: 0, truncated: false, startedAt: new Date().toISOString() };
128
- this.save(record);
129
- const stdout = openSync(join(state, 'stdout'), constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY, 0o600), stderr = openSync(join(state, 'stderr'), constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY, 0o600);
130
- let child;
131
- try {
132
- child = spawn(this.options.workspaces.commandHelperPath, [id, '/usr/bin/sandbox-exec', '-f', profile, this.options.workspaces.commandHelperPath, '--worker', '/bin/sh', '-c', request.command], { cwd, detached: true,
133
- env: { HOME: state, TMPDIR: join(state, 'tmp'), XDG_CACHE_HOME: join(state, 'cache'), npm_config_cache: join(state, 'cache'), PATH: [...this.settings.toolchainPaths, dirname(realpathSync(process.execPath)), '/usr/bin', '/bin', '/usr/sbin', '/sbin'].join(':'), LANG: 'en_US.UTF-8', CI: '1', ...request.env },
134
- stdio: ['pipe', 'pipe', 'pipe', this.options.startupLockFd ?? 'ignore', 'pipe'] });
135
- }
136
- catch (e) {
137
- closeSync(stdout);
138
- closeSync(stderr);
139
- record.state = 'failed';
140
- record.error = 'command_spawn_failed';
141
- this.options.workspaces.settleCommand(binding.runId, !readOnly, before.id);
142
- this.save(record);
143
- throw e;
144
- }
145
- if (child.pid) {
146
- record.pid = child.pid;
147
- this.save(record);
148
- }
149
- let stopState, supervisedReady = false;
150
- const signalStop = () => { if (child.pid)
151
- try {
152
- process.kill(-child.pid, 'SIGTERM');
153
- }
154
- catch (e) {
155
- if (e.code !== 'ESRCH')
156
- throw e;
157
- } };
158
- const stop = (state = 'cancelled') => {
159
- stopState ??= state;
160
- if (supervisedReady)
161
- signalStop();
162
- };
163
- const spool = (fd, key, chunk) => {
164
- try {
165
- const remaining = Math.max(0, this.settings.maxOutputBytes - record.stdoutBytes - record.stderrBytes), bytes = chunk.subarray(0, remaining);
166
- let offset = 0;
167
- while (offset < bytes.length)
168
- offset += writeSync(fd, bytes, offset, bytes.length - offset);
169
- record[key] += bytes.length;
170
- if (bytes.length !== chunk.length)
171
- record.truncated = true;
172
- }
173
- catch {
174
- record.error = 'command_output_write_failed';
175
- stop();
176
- }
177
- };
178
- child.stdout.on('data', (b) => spool(stdout, 'stdoutBytes', b));
179
- child.stderr.on('data', (b) => spool(stderr, 'stderrBytes', b));
180
- child.stdin.on('error', () => { });
181
- let proofText = '', proof;
182
- const proofPipe = child.stdio[4];
183
- proofPipe.on('data', (b) => {
184
- if (proofText.length + b.length > 4096)
185
- return;
186
- proofText += b.toString('utf8');
187
- let newline;
188
- while ((newline = proofText.indexOf('\n')) >= 0) {
189
- const line = proofText.slice(0, newline);
190
- proofText = proofText.slice(newline + 1);
191
- try {
192
- const entry = JSON.parse(line);
193
- if (entry.ready) {
194
- supervisedReady = true;
195
- if (stopState)
196
- signalStop();
197
- }
198
- else
199
- proof = entry;
200
- }
201
- catch { /* Missing valid settlement proof retains the lease. */ }
202
- }
203
- });
204
- const signal = this.options.signal(binding.runId), abort = () => stop();
205
- signal.addEventListener('abort', abort, { once: true });
206
- if (signal.aborted)
207
- stop();
208
- const timer = setTimeout(() => stop('timed_out'), timeoutMs);
209
- const done = new Promise(resolveDone => {
210
- child.once('error', () => { record.error = 'command_spawn_failed'; });
211
- child.once('close', (code, signalName) => {
212
- clearTimeout(timer);
213
- signal.removeEventListener('abort', abort);
214
- closeSync(stdout);
215
- closeSync(stderr);
216
- const finish = () => {
217
- try {
218
- if (record.error === 'command_spawn_failed') {
219
- this.options.workspaces.settleCommand(binding.runId, !readOnly, before.id);
220
- record.state = 'failed';
221
- }
222
- else if (!proof?.settled) {
223
- record.state = 'uncertain';
224
- record.error = 'command_process_proof_unavailable';
225
- }
226
- else if (child.pid && groupAlive(child.pid)) {
227
- record.state = 'uncertain';
228
- record.error = 'command_descendants_unsettled';
229
- }
230
- else {
231
- const after = this.options.workspaces.settleCommand(binding.runId, !readOnly, before.id);
232
- record.afterRevisionId = after.id;
233
- record.state = stopState ?? (proof.exitCode === 0 && !record.error ? 'completed' : 'failed');
234
- code = proof.exitCode;
235
- }
236
- }
237
- catch {
238
- record.state = 'uncertain';
239
- record.error = 'command_source_reconciliation_failed';
240
- }
241
- record.exitCode = code;
242
- record.signal = signalName;
243
- record.completedAt = new Date().toISOString();
244
- this.save(record);
245
- this.running.delete(id);
246
- this.options.wake(binding.runId);
247
- resolveDone(record);
248
- };
249
- if (child.pid && groupAlive(child.pid)) {
250
- try {
251
- process.kill(-child.pid, 'SIGKILL');
252
- }
253
- catch { /* uncertainty is retained */ }
254
- setTimeout(finish, 100);
255
- }
256
- else
257
- finish();
258
- });
259
- });
260
- this.running.set(id, { record, child, done, stop });
261
- return request.background ? { ...record } : done;
262
- }
263
- output(id, stream = 'stdout', cursor = 0, limit = 65_536, binding) {
264
- const record = this.get(id, binding);
265
- if (!['stdout', 'stderr'].includes(stream) || !Number.isSafeInteger(cursor) || cursor < 0 || !Number.isSafeInteger(limit) || limit < 1 || limit > 262_144)
266
- throw new BrokerError('invalid_output_cursor', 400);
267
- const path = join(this.options.directory, id, stream);
268
- if (!existsSync(path))
269
- return { text: '', nextCursor: null, record };
270
- const fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW), bytes = Buffer.alloc(limit);
271
- let count;
272
- try {
273
- count = readSync(fd, bytes, 0, bytes.length, cursor);
274
- }
275
- finally {
276
- closeSync(fd);
277
- }
278
- // Cursor counts bytes, so splitting a multibyte sequence is visible and never loses bytes.
279
- return { text: bytes.subarray(0, count).toString('utf8'), dataBase64: bytes.subarray(0, count).toString('base64'), nextCursor: count ? cursor + count : null, record: this.running.get(id)?.record ?? record };
280
- }
281
- input(id, text, binding, end = false) { this.get(id, binding); const running = this.running.get(id); if (!running || running.child.stdin.destroyed || running.child.stdin.writableEnded || Buffer.byteLength(text) > 65_536)
282
- throw new BrokerError('command_not_running'); running.child.stdin.write(text); if (end)
283
- running.child.stdin.end(); }
284
- async stop(id, binding) { this.get(id, binding); const running = this.running.get(id); if (!running)
285
- return this.get(id, binding); running.stop(); return running.done; }
286
- recoveryRequired(runId) { return this.records(runId).some(r => r.state === 'uncertain'); }
287
- reconcile(runId) {
288
- const uncertain = this.records(runId).filter(r => r.state === 'uncertain');
289
- if (!uncertain.length)
290
- return;
291
- if (uncertain.some(r => r.error === 'command_process_proof_unavailable'))
292
- throw new BrokerError('command_process_proof_unavailable', 409);
293
- if (uncertain.some(r => this.running.has(r.id) || r.pid && groupAlive(r.pid)))
294
- throw new BrokerError('command_descendants_unsettled');
295
- const resolution = this.options.store.private('command_resolution', runId);
296
- if (!resolution)
297
- throw new BrokerError('command_resolution_required');
298
- const writer = uncertain.find(r => !r.readOnly) ?? uncertain[0];
299
- this.options.workspaces.resolveStoppedCommand(runId, writer.beforeRevisionId, resolution);
300
- for (const record of uncertain) {
301
- record.state = 'failed';
302
- record.error = 'interrupted_command_explicitly_reconciled';
303
- record.completedAt = new Date().toISOString();
304
- record.afterRevisionId = this.options.workspaces.lease(runId).knownRevisionId;
305
- this.save(record);
306
- }
307
- }
308
- async close() { await Promise.all([...this.running.keys()].map(id => this.stop(id))); if ([...this.options.store.coordinator.db.prepare("SELECT id FROM engine_private WHERE scope='command' AND json_extract(body,'$.state')='uncertain'").all()].length)
309
- throw new Error('command_work_requires_reconciliation'); }
310
- }