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
@@ -1,393 +0,0 @@
1
- import { createHash } from 'node:crypto';
2
- const invalid = () => new Error('invalid_protocol_json');
3
- const whitespace = (char) => char === ' ' || char === '\t' || char === '\r' || char === '\n';
4
- const ownObject = () => Object.create(null);
5
- /** Coalesce escape-heavy strings without one retained array entry per escape.
6
- * Ambiguous echo positions stay lossless inside the bounded worker until the
7
- * enclosing discriminators prove they are unused echoes. */
8
- class StringValue {
9
- #parts = [];
10
- #partial = [];
11
- #length = 0;
12
- #flush() {
13
- if (!this.#length)
14
- return;
15
- this.#parts.push(this.#partial.join(''));
16
- this.#partial = [];
17
- this.#length = 0;
18
- }
19
- append(value) {
20
- if (!value)
21
- return;
22
- if (value.length >= 8192) {
23
- this.#flush();
24
- this.#parts.push(value);
25
- return;
26
- }
27
- this.#partial.push(value);
28
- this.#length += value.length;
29
- if (this.#length >= 8192)
30
- this.#flush();
31
- }
32
- finish() { this.#flush(); return this.#parts.join(''); }
33
- }
34
- function lookup(value, path) {
35
- for (const key of path) {
36
- if (!value || typeof value !== 'object')
37
- return undefined;
38
- value = value[key];
39
- }
40
- return value;
41
- }
42
- /** Candidate generated 0.167.1 output positions, never request arguments,
43
- * agentMessage.text or errors. Unknown enclosing variants must be retained. */
44
- function echoText(path) {
45
- return path.length === 5 && path[0] === 'params' && path[1] === 'item' && path[2] === 'contentItems' &&
46
- typeof path[3] === 'number' && path[4] === 'text' ||
47
- path.length === 7 && path[0] === 'params' && path[1] === 'turn' && path[2] === 'items' &&
48
- typeof path[3] === 'number' && path[4] === 'contentItems' && typeof path[5] === 'number' && path[6] === 'text';
49
- }
50
- const itemPathFor = (path) => path[1] === 'item' ? ['params', 'item'] : path.slice(0, 4);
51
- function provenEcho(method, item, content, path) {
52
- return typeof method === 'string' &&
53
- (path[1] === 'item' ? ['item/completed', 'item/started'].includes(method) : method === 'turn/completed') &&
54
- item?.type === 'dynamicToolCall' && content?.type === 'inputText';
55
- }
56
- /** Incremental strict JSON parser. Echo candidates are hashed incrementally.
57
- * Ambiguous variants stay lossless until final correspondence is known;
58
- * already-proven unused echoes need no retained text. JSON field order cannot
59
- * bypass correspondence. Unknown terminal fields are preserved unchanged.
60
- * Depth is an explicit operational resource bound, not an artifact schema cap. */
61
- class JsonProjection {
62
- maxDepth;
63
- projectEchoes;
64
- #stack = [];
65
- #token;
66
- #value;
67
- #done = false;
68
- #candidates = [];
69
- echoes = [];
70
- constructor(maxDepth = 256, projectEchoes = true) {
71
- this.maxDepth = maxDepth;
72
- this.projectEchoes = projectEchoes;
73
- }
74
- #knownEcho(path) {
75
- const container = (target) => this.#stack.find(value => value.path.length === target.length &&
76
- value.path.every((key, index) => key === target[index]))?.value;
77
- const root = this.#stack[0];
78
- return root?.kind === 'object' && provenEcho(root.value.method, container(itemPathFor(path)), container(path.slice(0, -1)), path);
79
- }
80
- #path() {
81
- const parent = this.#stack.at(-1);
82
- return parent ? [...parent.path, parent.kind === 'object' ? parent.key : parent.value.length] : [];
83
- }
84
- #accept(value) {
85
- const parent = this.#stack.at(-1);
86
- if (!parent) {
87
- if (this.#done)
88
- throw invalid();
89
- this.#value = value;
90
- this.#done = true;
91
- }
92
- else if (parent.kind === 'object') {
93
- if (parent.state !== 'value' || parent.key === undefined)
94
- throw invalid();
95
- parent.value[parent.key] = value;
96
- delete parent.key;
97
- parent.state = 'comma';
98
- }
99
- else {
100
- if (parent.state !== 'value' && parent.state !== 'value_or_end')
101
- throw invalid();
102
- parent.value.push(value);
103
- parent.state = 'comma';
104
- }
105
- }
106
- #append(token, value, final = false) {
107
- if (!token.echo || token.echo.retain)
108
- token.parts.append(value);
109
- if (!token.echo)
110
- return;
111
- const echo = token.echo;
112
- let text = echo.pending + value;
113
- echo.pending = '';
114
- if (!final && text && text.charCodeAt(text.length - 1) >= 0xd800 && text.charCodeAt(text.length - 1) <= 0xdbff) {
115
- echo.pending = text.at(-1);
116
- text = text.slice(0, -1);
117
- }
118
- if (text) {
119
- echo.bytes += Buffer.byteLength(text);
120
- echo.hash.update(text);
121
- }
122
- if (!Number.isSafeInteger(echo.bytes))
123
- throw new Error('protocol_resource_limit');
124
- }
125
- #endString(token) {
126
- this.#token = undefined;
127
- if (token.echo) {
128
- this.#append(token, '', true);
129
- const summary = { path: token.echo.path, utf8Bytes: token.echo.bytes, sha256: token.echo.hash.digest('hex') };
130
- this.#candidates.push({ summary, ...(token.echo.retain ? { text: token.parts } : {}) });
131
- this.#accept(undefined);
132
- return;
133
- }
134
- const value = token.parts.finish();
135
- if (!token.key) {
136
- this.#accept(value);
137
- return;
138
- }
139
- const parent = this.#stack.at(-1);
140
- if (!parent || parent.kind !== 'object' || parent.keys.has(value))
141
- throw invalid();
142
- parent.keys.add(value);
143
- parent.key = value;
144
- parent.state = 'colon';
145
- }
146
- #endNumber(token) {
147
- if (!/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(token.value))
148
- throw invalid();
149
- const value = Number(token.value);
150
- if (!Number.isFinite(value))
151
- throw invalid();
152
- this.#token = undefined;
153
- this.#accept(value);
154
- }
155
- write(input) {
156
- let index = 0;
157
- while (index < input.length) {
158
- const token = this.#token, char = input[index];
159
- if (token?.kind === 'string') {
160
- if (token.unicode !== undefined) {
161
- if (!/^[\da-f]$/i.test(char))
162
- throw invalid();
163
- token.unicode += char;
164
- index++;
165
- if (token.unicode.length === 4) {
166
- this.#append(token, String.fromCharCode(parseInt(token.unicode, 16)));
167
- token.unicode = undefined;
168
- }
169
- }
170
- else if (token.escaped) {
171
- token.escaped = false;
172
- index++;
173
- const escape = { '"': '"', '\\': '\\', '/': '/', b: '\b', f: '\f', n: '\n', r: '\r', t: '\t' };
174
- if (char === 'u')
175
- token.unicode = '';
176
- else if (Object.hasOwn(escape, char))
177
- this.#append(token, escape[char]);
178
- else
179
- throw invalid();
180
- }
181
- else {
182
- const rest = input.slice(index), special = rest.search(/["\\\u0000-\u001f]/u);
183
- if (special === -1) {
184
- this.#append(token, rest);
185
- return;
186
- }
187
- if (special) {
188
- this.#append(token, rest.slice(0, special));
189
- index += special;
190
- }
191
- const current = input[index++];
192
- if (current === '"')
193
- this.#endString(token);
194
- else if (current === '\\')
195
- token.escaped = true;
196
- else
197
- throw invalid();
198
- }
199
- continue;
200
- }
201
- if (token?.kind === 'number') {
202
- if (/^[\d.eE+-]$/.test(char)) {
203
- if (token.value.length >= 1024)
204
- throw new Error('protocol_resource_limit');
205
- token.value += char;
206
- index++;
207
- continue;
208
- }
209
- this.#endNumber(token);
210
- continue;
211
- }
212
- if (token?.kind === 'literal') {
213
- if (char !== token.expected[token.index++])
214
- throw invalid();
215
- index++;
216
- if (token.index === token.expected.length) {
217
- this.#token = undefined;
218
- this.#accept(token.value);
219
- }
220
- continue;
221
- }
222
- if (whitespace(char)) {
223
- index++;
224
- continue;
225
- }
226
- const parent = this.#stack.at(-1);
227
- if (parent?.kind === 'object' && (parent.state === 'key' || parent.state === 'key_or_end')) {
228
- if (char === '}' && parent.state === 'key_or_end') {
229
- this.#stack.pop();
230
- this.#accept(parent.value);
231
- index++;
232
- continue;
233
- }
234
- if (char !== '"')
235
- throw invalid();
236
- this.#token = { kind: 'string', key: true, parts: new StringValue(), escaped: false, unicode: undefined };
237
- index++;
238
- continue;
239
- }
240
- if (parent?.kind === 'object' && parent.state === 'colon') {
241
- if (char !== ':')
242
- throw invalid();
243
- parent.state = 'value';
244
- index++;
245
- continue;
246
- }
247
- if (parent?.state === 'comma') {
248
- if (char === (parent.kind === 'object' ? '}' : ']')) {
249
- this.#stack.pop();
250
- this.#accept(parent.value);
251
- index++;
252
- continue;
253
- }
254
- if (char !== ',')
255
- throw invalid();
256
- parent.state = parent.kind === 'object' ? 'key' : 'value';
257
- index++;
258
- continue;
259
- }
260
- if (parent?.kind === 'array' && parent.state === 'value_or_end' && char === ']') {
261
- this.#stack.pop();
262
- this.#accept(parent.value);
263
- index++;
264
- continue;
265
- }
266
- if (!parent && this.#done)
267
- throw invalid();
268
- if (char === '{' || char === '[') {
269
- if (this.#stack.length >= this.maxDepth)
270
- throw new Error('protocol_resource_limit');
271
- const path = this.#path();
272
- this.#stack.push(char === '{' ? { kind: 'object', value: ownObject(), path, state: 'key_or_end', keys: new Set() } :
273
- { kind: 'array', value: [], path, state: 'value_or_end' });
274
- }
275
- else if (char === '"') {
276
- const path = this.#path();
277
- this.#token = { kind: 'string', key: false, parts: new StringValue(), escaped: false, unicode: undefined,
278
- ...(this.projectEchoes && echoText(path) ? { echo: { path, hash: createHash('sha256'), bytes: 0, pending: '', retain: !this.#knownEcho(path) } } : {}) };
279
- }
280
- else if (char === '-' || /^\d$/.test(char))
281
- this.#token = { kind: 'number', value: char };
282
- else if (char === 't' || char === 'f' || char === 'n')
283
- this.#token = {
284
- kind: 'literal', expected: char === 't' ? 'true' : char === 'f' ? 'false' : 'null', index: 1,
285
- value: char === 't' ? true : char === 'f' ? false : null,
286
- };
287
- else
288
- throw invalid();
289
- index++;
290
- }
291
- }
292
- finishDocument() {
293
- if (this.#token?.kind === 'number')
294
- this.#endNumber(this.#token);
295
- if (!this.#done || this.#stack.length || this.#token)
296
- throw invalid();
297
- return this.#value;
298
- }
299
- finish() {
300
- const value = this.finishDocument();
301
- if (!value || typeof value !== 'object' || Array.isArray(value))
302
- throw invalid();
303
- const message = value;
304
- const id = message.id, method = message.method, hasResult = Object.hasOwn(message, 'result'), hasError = Object.hasOwn(message, 'error');
305
- if (id !== undefined && typeof id !== 'number' && typeof id !== 'string' ||
306
- method !== undefined && (typeof method !== 'string' || !method) ||
307
- method === undefined && (id === undefined || hasResult === hasError) ||
308
- method !== undefined && (hasResult || hasError) ||
309
- hasError && (!message.error || typeof message.error !== 'object' || typeof message.error.code !== 'number' || typeof message.error.message !== 'string'))
310
- throw new Error('invalid_protocol_envelope');
311
- for (const candidate of this.#candidates) {
312
- const summary = candidate.summary;
313
- const item = lookup(message, itemPathFor(summary.path));
314
- const content = lookup(message, summary.path.slice(0, -1));
315
- if (!provenEcho(message.method, item, content, summary.path)) {
316
- if (!candidate.text || !content)
317
- throw new Error('unproven_protocol_echo_projection');
318
- content.text = candidate.text.finish();
319
- continue;
320
- }
321
- this.echoes.push(summary);
322
- // Other fields are untouched, including future/unknown terminal fields.
323
- delete content.text;
324
- if (!Object.hasOwn(content, 'streamedText'))
325
- content.streamedText = { utf8Bytes: summary.utf8Bytes, sha256: summary.sha256 };
326
- }
327
- return message;
328
- }
329
- }
330
- /** Worker-only strict JSON without protocol-envelope rules or projection.
331
- * Byte decoding and parsing both stay off the coordinator event loop. */
332
- export function decodeStrictJsonBytes(bytes) {
333
- const decoder = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }), json = new JsonProjection(256, false);
334
- for (let offset = 0; offset < bytes.length; offset += 65_536)
335
- json.write(decoder.decode(bytes.subarray(offset, offset + 65_536), { stream: true }));
336
- json.write(decoder.decode());
337
- return json.finishDocument();
338
- }
339
- /** Pure worker-side byte framing. There is NO whole-line or artifact text cap.
340
- * UTF-8 and JSON are validated incrementally before a frame is delivered. */
341
- export class ProtocolProjection {
342
- maxDepth;
343
- #decoder = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
344
- #json;
345
- #bytes = 0;
346
- #hash = createHash('sha256');
347
- #failure;
348
- constructor(maxDepth = 256) {
349
- this.maxDepth = maxDepth;
350
- this.#json = new JsonProjection(maxDepth);
351
- }
352
- get atBoundary() { return this.#bytes === 0; }
353
- write(chunk) {
354
- if (this.#failure)
355
- throw this.#failure;
356
- const bytes = Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength), frames = [];
357
- try {
358
- let offset = 0;
359
- while (offset < bytes.length) {
360
- const newline = bytes.indexOf(10, offset), end = newline === -1 ? bytes.length : newline + 1, segment = bytes.subarray(offset, end);
361
- this.#bytes += segment.length;
362
- this.#hash.update(segment);
363
- this.#json.write(this.#decoder.decode(segment, { stream: true }));
364
- if (newline !== -1) {
365
- const message = this.#json.finish();
366
- frames.push({ message, bytes: this.#bytes, sha256: this.#hash.digest('hex'), echoes: this.#json.echoes });
367
- this.#json = new JsonProjection(this.maxDepth);
368
- this.#hash = createHash('sha256');
369
- this.#bytes = 0;
370
- }
371
- offset = end;
372
- }
373
- return frames;
374
- }
375
- catch (error) {
376
- this.#failure = error instanceof Error ? error : invalid();
377
- throw this.#failure;
378
- }
379
- }
380
- finish() {
381
- if (this.#failure)
382
- throw this.#failure;
383
- try {
384
- this.#decoder.decode();
385
- if (!this.atBoundary)
386
- throw new Error('truncated_protocol_frame');
387
- }
388
- catch (error) {
389
- this.#failure = error instanceof Error ? error : invalid();
390
- throw this.#failure;
391
- }
392
- }
393
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,18 +0,0 @@
1
- import { parentPort, workerData } from 'node:worker_threads';
2
- import { ProtocolProjection } from './protocol-projection.js';
3
- const parser = new ProtocolProjection(workerData.maxDepth);
4
- parentPort.on('message', (message) => {
5
- try {
6
- if (message.type === 'finish') {
7
- parser.finish();
8
- parentPort.postMessage({ type: 'finished' });
9
- parentPort.close();
10
- }
11
- else
12
- parentPort.postMessage({ type: 'frames', frames: parser.write(message.chunk), atBoundary: parser.atBoundary });
13
- }
14
- catch (error) {
15
- parentPort.postMessage({ type: 'failed', code: error instanceof Error && /^[a-z_]+$/.test(error.message) ? error.message : 'invalid_protocol_utf8' });
16
- parentPort.close();
17
- }
18
- });