@linzumi/cli 1.0.272 → 1.0.274

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 (44) hide show
  1. package/README.md +1 -1
  2. package/dist/impl-res/cloud-supervisor.mjs +69 -69
  3. package/dist/impl-res/index.js +355 -314
  4. package/dist/impl-res/mcp-server.mjs +34 -34
  5. package/dist/impl-ts/cloud-supervisor.mjs +69 -69
  6. package/dist/impl-ts/index.js +495 -495
  7. package/dist/impl-ts/mcp-server.mjs +1 -1
  8. package/dist/mcp-server.mjs +1 -1
  9. package/package.json +3 -2
  10. package/scripts/check-package-size-budget.mjs +9 -0
  11. package/scripts/build-auth-parity-oracle.mjs +0 -709
  12. package/scripts/build-canonical-codex-transpiler-oracle.mjs +0 -93
  13. package/scripts/build-config-identity-parity-oracle.mjs +0 -526
  14. package/scripts/build-core-commander-seams-parity-oracle.mjs +0 -799
  15. package/scripts/build-core-daemon-parity-oracle.mjs +0 -573
  16. package/scripts/build-core-dispatch-input-queue-parity-oracle.mjs +0 -225
  17. package/scripts/build-core-fate-ladder-parity-oracle.mjs +0 -350
  18. package/scripts/build-core-generation-overlap-parity-oracle.mjs +0 -292
  19. package/scripts/build-core-integration-parity-oracle.mjs +0 -453
  20. package/scripts/build-core-lifecycle-guards-parity-oracle.mjs +0 -443
  21. package/scripts/build-core-lock-parity-oracle.mjs +0 -462
  22. package/scripts/build-core-reconnect-resume-parity-oracle.mjs +0 -365
  23. package/scripts/build-core-startup-resume-scan-parity-oracle.mjs +0 -296
  24. package/scripts/build-core-supervisor-parity-oracle.mjs +0 -781
  25. package/scripts/build-cross-harness-failover-oracle.mjs +0 -349
  26. package/scripts/build-editor-parity-oracle.mjs +0 -1525
  27. package/scripts/build-forwarding-parity-oracle.mjs +0 -1390
  28. package/scripts/build-harness-claude-parity-oracle.mjs +0 -407
  29. package/scripts/build-harness-codex-parity-oracle.mjs +0 -479
  30. package/scripts/build-mcp-parity-oracle.mjs +0 -412
  31. package/scripts/build-mcp-selector-parity-oracle.mjs +0 -65
  32. package/scripts/build-onboarding-discovery-parity-oracle.mjs +0 -388
  33. package/scripts/build-onboarding-flow-parity-oracle.mjs +0 -562
  34. package/scripts/build-onboarding-gateway-parity-oracle.mjs +0 -313
  35. package/scripts/build-onboarding-support-parity-oracle.mjs +0 -519
  36. package/scripts/build-pipeline-parity-oracle.mjs +0 -614
  37. package/scripts/build-protocol-parity-oracle.mjs +0 -398
  38. package/scripts/build-queue-parity-oracle.mjs +0 -1012
  39. package/scripts/build-session-registry-parity-oracle.mjs +0 -582
  40. package/scripts/build-transport-parity-oracle.mjs +0 -694
  41. package/scripts/build-tui-parity-oracle.mjs +0 -577
  42. package/scripts/build-vm-sandbox-parity-oracle.mjs +0 -1281
  43. package/scripts/build-worker-entry-parity-oracle.mjs +0 -424
  44. package/scripts/build-worker-spawn-parity-oracle.mjs +0 -823
@@ -1,398 +0,0 @@
1
- // Spec: kandan/plans/2026-07-10-compute-nodes-rescript-commander-zero-ts-program.md
2
- // (M3 cluster 1, protocol-types).
3
- // Relationship: Builds the TS-side PARITY ORACLE for the protocol/type
4
- // cluster of the ReScript commander port. The oracle bundles the REAL TS
5
- // protocol modules (protocol.ts, json.ts, localCodexMessageState.ts,
6
- // terminalFailureRetry.ts, localConfig.ts) behind a one-shot batch driver:
7
- // it reads a JSON array of cases on stdin and writes a JSON array of
8
- // results on stdout. The ReScript package's parity conformance
9
- // (packages/linzumi-cli-rescript/src/parity/ProtocolParityConformance.res)
10
- // drives the SAME inputs through the sury schemas/functions and asserts
11
- // accept/reject/normalized-output equivalence - so the two protocol layers
12
- // cannot drift silently.
13
- // Native Commander catalog extension spec:
14
- // plans/2026-09-08-rescript-commander-native-model-catalog.spec.md
15
- //
16
- // Like build-differential-entry.mjs, the output is a local test artifact
17
- // (.differential/ is gitignored, never published) and stays unminified for
18
- // debuggability.
19
- import { mkdir } from 'node:fs/promises';
20
- import { dirname, join } from 'node:path';
21
- import { fileURLToPath } from 'node:url';
22
- import { build } from 'esbuild';
23
-
24
- const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
25
-
26
- const driverSource = `
27
- import { mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
28
- import { tmpdir } from 'node:os';
29
- import { join } from 'node:path';
30
- import {
31
- isJsonObject,
32
- parseJsonObject,
33
- requireString,
34
- requirePositiveInteger,
35
- extractCodexIds,
36
- terminalStartupFailureHeartbeatPayload,
37
- } from './src/protocol';
38
- import {
39
- objectValue,
40
- arrayValue,
41
- stringValue,
42
- integerValue,
43
- stringListValue,
44
- parseJsonObjectOrUndefined,
45
- } from './src/json';
46
- import {
47
- approvalRequestKey,
48
- codexApprovalMessageState,
49
- compactingConversationHistoryReason,
50
- fleetBreakerHoldReason,
51
- parkedAsOwnTurnQueuedReason,
52
- parkedAsOwnTurnReasonDetail,
53
- processingReasonForCodexNotification,
54
- queuedBehindEarlierMessagesReason,
55
- queuedBehindRunningTurnReason,
56
- queuedBehindReasonPrefix,
57
- queuedBehindRunningTurnReasonPrefix,
58
- resumingAfterStreamStallReason,
59
- steeredIntoRunningTurnReason,
60
- } from './src/localCodexMessageState';
61
- import { parseFleetBreakerPayload } from './src/fleetBreaker';
62
- import {
63
- fateRetryable,
64
- isTerminalFailureFate,
65
- terminalFailureClasses,
66
- terminalFailureFate,
67
- terminalFailureFates,
68
- terminalFailureRetryableStamp,
69
- } from './src/terminalFailureRetry';
70
- import { readLocalConfig, readLocalSignupAuth } from './src/localConfig';
71
- import {
72
- ADT_BINDING_ACK_EVENT,
73
- ADT_FRAME_ENTRY_KIND,
74
- ADT_FRAME_EVENT,
75
- ADT_STREAM_BINDING_KEY,
76
- ADT_STREAM_V1_CAPABILITY,
77
- adoptAdtStreamBinding,
78
- adtBindingRefusalMessage,
79
- adtFrameContentDigest,
80
- adtFrameEntryData,
81
- adtFrameTelemetry,
82
- adtFrameWirePayload,
83
- adtObserveOutboxEntry,
84
- adtRejectionTelemetry,
85
- classifyAdtAppendRejection,
86
- fenceAdtEmitter,
87
- finishAdtStream,
88
- makeAdtFrameEmitter,
89
- parseAdtStreamBinding,
90
- pollAdtInterval,
91
- pushAdtDelta,
92
- utf8ByteLength,
93
- } from './src/pipeline/contracts';
94
- import { discoverCodexModelCatalog } from './src/channelSession';
95
- import { discoverClaudeCodeModelCatalog } from './src/claudeCodeSession';
96
- import { claudeCodeRoutedProxyModel } from './src/claudeModelTransportLane';
97
-
98
- const jsonHelpers = {
99
- isJsonObject,
100
- parseJsonObject,
101
- requireString,
102
- requirePositiveInteger,
103
- extractCodexIds,
104
- objectValue,
105
- arrayValue,
106
- stringValue,
107
- integerValue,
108
- stringListValue,
109
- parseJsonObjectOrUndefined,
110
- };
111
-
112
- const messageStateFns = {
113
- approvalRequestKey,
114
- codexApprovalMessageState,
115
- parkedAsOwnTurnQueuedReason,
116
- parkedAsOwnTurnReasonDetail,
117
- processingReasonForCodexNotification,
118
- queuedBehindEarlierMessagesReason,
119
- queuedBehindRunningTurnReason,
120
- };
121
-
122
- // Encode a call outcome so undefined stays distinguishable from null after
123
- // JSON serialization.
124
- function outcome(run) {
125
- try {
126
- const value = run();
127
- return value === undefined ? { defined: false } : { defined: true, value };
128
- } catch (error) {
129
- return { threw: true, message: error instanceof Error ? error.message : String(error) };
130
- }
131
- }
132
-
133
- async function outcomeAsync(run) {
134
- try {
135
- const value = await run();
136
- return value === undefined ? { defined: false } : { defined: true, value };
137
- } catch (error) {
138
- return { threw: true, message: error instanceof Error ? error.message : String(error) };
139
- }
140
- }
141
-
142
- // --- adt_stream_v1 (Part C CLI-first leg): the adt protocol core rides
143
- // THIS oracle (its charter: the TS protocol modules; the zero-raw-JS
144
- // ratchet forbids a new sibling .mjs). Case ops are namespaced 'adt*'
145
- // where they would collide.
146
- const adtRowEntryKinds = {
147
- postStreamedRow: 'pipeline.post_streamed_row',
148
- streamSnapshot: 'pipeline.stream_snapshot',
149
- finalizeRow: 'pipeline.finalize_row',
150
- postCompletedRow: 'pipeline.post_completed_row',
151
- messageState: 'pipeline.message_state',
152
- };
153
-
154
- const adtFrameOut = (frame) =>
155
- frame === null
156
- ? null
157
- : {
158
- entryData: adtFrameEntryData(frame),
159
- wirePayload: adtFrameWirePayload(frame),
160
- telemetry: adtFrameTelemetry(frame),
161
- };
162
-
163
- async function handle(testCase) {
164
- switch (testCase.op) {
165
- case 'jsonHelper': {
166
- const fn = jsonHelpers[testCase.fn];
167
- if (fn === undefined) {
168
- return { threw: true, message: 'unknown jsonHelper ' + testCase.fn };
169
- }
170
- return outcome(() => fn(...testCase.args));
171
- }
172
- case 'messageState': {
173
- const fn = messageStateFns[testCase.fn];
174
- if (fn === undefined) {
175
- return { threw: true, message: 'unknown messageState fn ' + testCase.fn };
176
- }
177
- return outcome(() => fn(...testCase.args));
178
- }
179
- case 'terminalStartupFailureHeartbeatPayload':
180
- return outcome(() => terminalStartupFailureHeartbeatPayload(testCase.controlSeqs));
181
- case 'constants':
182
- return {
183
- compactingConversationHistoryReason,
184
- resumingAfterStreamStallReason,
185
- steeredIntoRunningTurnReason,
186
- queuedBehindReasonPrefix,
187
- queuedBehindRunningTurnReasonPrefix,
188
- fleetBreakerHoldReason,
189
- };
190
- case 'fleetBreakerParse':
191
- return outcome(() => parseFleetBreakerPayload(testCase.value));
192
- case 'fateTables': {
193
- const retryableByFate = {};
194
- for (const fate of terminalFailureFates) {
195
- retryableByFate[fate] = fateRetryable(fate);
196
- }
197
- const fateByClass = {};
198
- const stampByClass = {};
199
- for (const failureClass of terminalFailureClasses) {
200
- fateByClass[failureClass] = terminalFailureFate(failureClass);
201
- stampByClass[failureClass] = terminalFailureRetryableStamp(failureClass);
202
- }
203
- return {
204
- fates: [...terminalFailureFates],
205
- retryableByFate,
206
- classes: [...terminalFailureClasses],
207
- fateByClass,
208
- stampByClass,
209
- };
210
- }
211
- case 'isFate':
212
- return outcome(() => isTerminalFailureFate(testCase.value));
213
- case 'localConfig': {
214
- const dir = mkdtempSync(join(tmpdir(), 'linzumi-protocol-parity-'));
215
- const path = join(dir, 'config.json');
216
- writeFileSync(path, testCase.contents, 'utf8');
217
- const config = outcome(() => readLocalConfig(path));
218
- const signupAuth = outcome(() => readLocalSignupAuth(path));
219
- return { config, signupAuth };
220
- }
221
- case 'adtConstants':
222
- return {
223
- capability: ADT_STREAM_V1_CAPABILITY,
224
- bindingKey: ADT_STREAM_BINDING_KEY,
225
- frameEvent: ADT_FRAME_EVENT,
226
- bindingAckEvent: ADT_BINDING_ACK_EVENT,
227
- frameEntryKind: ADT_FRAME_ENTRY_KIND,
228
- };
229
- case 'parseBinding': {
230
- const parsed = parseAdtStreamBinding(testCase.value);
231
- return parsed.ok
232
- ? { ok: true, binding: parsed.binding }
233
- : { ok: false, reason: parsed.reason };
234
- }
235
- case 'refusalMessage':
236
- return { message: adtBindingRefusalMessage(testCase.reason) };
237
- case 'adopt': {
238
- const adoption = adoptAdtStreamBinding(
239
- testCase.binding,
240
- testCase.sourceSeq,
241
- testCase.nowMs ?? 0
242
- );
243
- if (adoption.kind === 'accepted') {
244
- return {
245
- kind: 'accepted',
246
- ackPayload: adoption.ackPayload,
247
- sourceSeq: adoption.session.sourceSeq,
248
- };
249
- }
250
- if (adoption.kind === 'refused') {
251
- return { kind: 'refused', reason: adoption.reason, message: adoption.message };
252
- }
253
- return { kind: 'absent' };
254
- }
255
- case 'emitterRun': {
256
- const parsed = parseAdtStreamBinding(testCase.binding);
257
- if (!parsed.ok) {
258
- return { refused: parsed.reason };
259
- }
260
- const emitter = makeAdtFrameEmitter(parsed.binding, testCase.startMs ?? 0);
261
- const results = [];
262
- for (const step of testCase.steps) {
263
- switch (step.op) {
264
- case 'delta':
265
- results.push(adtFrameOut(pushAdtDelta(emitter, step.chunk, step.nowMs)));
266
- break;
267
- case 'poll':
268
- results.push(adtFrameOut(pollAdtInterval(emitter, step.nowMs)));
269
- break;
270
- case 'finish':
271
- results.push(adtFrameOut(finishAdtStream(emitter, step.nowMs)));
272
- break;
273
- case 'fence':
274
- fenceAdtEmitter(emitter);
275
- results.push(null);
276
- break;
277
- default:
278
- results.push({ unknownStep: String(step.op) });
279
- }
280
- }
281
- return {
282
- results,
283
- final: {
284
- cumulative: emitter.cumulative,
285
- nextFrameIndex: emitter.nextFrameIndex,
286
- emittedFrameCount: emitter.emittedFrameCount,
287
- terminalEmitted: emitter.terminalEmitted,
288
- fenced: emitter.fenced,
289
- },
290
- };
291
- }
292
- case 'tapRun': {
293
- const adoption = adoptAdtStreamBinding(
294
- testCase.binding,
295
- testCase.sourceSeq,
296
- testCase.startMs ?? 0
297
- );
298
- if (adoption.kind !== 'accepted') {
299
- return { adoption: adoption.kind };
300
- }
301
- const session = adoption.session;
302
- const results = testCase.entries.map((entry) =>
303
- adtObserveOutboxEntry(
304
- session,
305
- entry.kind,
306
- entry.data,
307
- entry.nowMs ?? 0,
308
- adtRowEntryKinds
309
- ).map((frame) => adtFrameOut(frame))
310
- );
311
- return {
312
- results,
313
- final: {
314
- trackedItemKey: session.trackedItemKey ?? null,
315
- trackedItemRank: session.trackedItemRank,
316
- lastBody: session.lastBody,
317
- done: session.done,
318
- },
319
- };
320
- }
321
- case 'classifyRejection':
322
- return { reason: classifyAdtAppendRejection(testCase.value) };
323
- case 'rejectionTelemetry':
324
- return adtRejectionTelemetry(testCase.frame, testCase.reason);
325
- case 'digest':
326
- return {
327
- digest: adtFrameContentDigest(testCase.frame),
328
- byteLen: utf8ByteLength(testCase.frame.body),
329
- };
330
- case 'nativeCodexModelCatalog':
331
- return outcomeAsync(() =>
332
- discoverCodexModelCatalog({
333
- request: async (method, params) => {
334
- if (method !== 'model/list') throw new Error('unexpected Codex method ' + method);
335
- const cursor = typeof params?.cursor === 'string' ? params.cursor : null;
336
- const page = testCase.pages.find((candidate) => candidate.cursor === cursor);
337
- if (page === undefined) throw new Error('missing Codex fixture page ' + String(cursor));
338
- return { jsonrpc: '2.0', id: 1, result: page.result };
339
- },
340
- })
341
- );
342
- case 'nativeClaudeModelCatalog': {
343
- let closeCount = 0;
344
- const outcomeValue = await outcomeAsync(() =>
345
- discoverClaudeCodeModelCatalog({
346
- close: () => undefined,
347
- query: () => ({
348
- supportedModels: async () => testCase.models,
349
- return: async () => {
350
- closeCount += 1;
351
- return { done: true, value: undefined };
352
- },
353
- }),
354
- })
355
- );
356
- return { outcome: outcomeValue, closeCount };
357
- }
358
- case 'claudeCodeRoutedProxyModel':
359
- return outcome(() =>
360
- claudeCodeRoutedProxyModel(testCase.model, testCase.nativeModelCatalog)
361
- );
362
- default:
363
- return { threw: true, message: 'unknown op ' + String(testCase.op) };
364
- }
365
- }
366
-
367
- const stdin = process.argv[2] ?? readFileSync(0, 'utf8');
368
- const cases = JSON.parse(stdin);
369
- writeFileSync(1, JSON.stringify(await Promise.all(cases.map(handle))));
370
- `;
371
-
372
- await mkdir(join(packageRoot, '.differential'), { recursive: true });
373
-
374
- await build({
375
- stdin: {
376
- contents: driverSource,
377
- resolveDir: packageRoot,
378
- sourcefile: 'protocol-parity-driver.ts',
379
- loader: 'ts',
380
- },
381
- bundle: true,
382
- // Spec: plans/2026-09-09-ts-native-account-continuation.md. Match the
383
- // production/auth-oracle ESM bridge for reachable CJS runtime dependencies;
384
- // the distinct banner binding cannot collide with bundled createRequire.
385
- banner: {
386
- js: "import { createRequire as __protocolOracleCreateRequire } from 'node:module';\nconst require = __protocolOracleCreateRequire(import.meta.url);",
387
- },
388
- platform: 'node',
389
- target: 'node20',
390
- format: 'esm',
391
- outfile: join(packageRoot, '.differential/protocol-parity-oracle.mjs'),
392
- minify: false,
393
- sourcemap: false,
394
- legalComments: 'none',
395
- // The protocol modules are dependency-light; anything that leaks in from
396
- // the wider commander graph stays external exactly like the entry build.
397
- external: ['ws', 'undici', 'blessed', '@anthropic-ai/claude-agent-sdk'],
398
- });