@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,407 +0,0 @@
1
- // Spec: kandan/plans/2026-07-10-compute-nodes-rescript-commander-zero-ts-program.md
2
- // (M3 cluster 8, harness-claude-adapter / workstream H.3).
3
- // Relationship: Builds the TS-side PARITY ORACLE for the claude-adapter
4
- // cluster of the ReScript commander port, the sibling of
5
- // build-harness-codex-parity-oracle.mjs (cluster 7). The oracle runs the
6
- // REAL TS claude session driver (startClaudeCodeSession + the resume
7
- // validation + the canUseTool bridge) with '@anthropic-ai/claude-agent-sdk'
8
- // ALIASED to the M2.3 scripted stub
9
- // (packages/commander-harness/src/scripted/ScriptedClaudeAgentSdk.res.mjs)
10
- // - the exact import-seam substitution the stub was built for - and prints
11
- // the stub recorder's transcript for one named scenario. The dual-impl
12
- // differential in @linzumi/commander-harness
13
- // (HarnessClaudeDifferentialConformance) runs the same scenario through
14
- // the ReScript adapter in-process and requires the two double transcripts
15
- // byte-identical.
16
- //
17
- // Determinism: the scenarios are scripted data, the driver's only waits
18
- // are milestone polls over the in-process transcript, and the recorder
19
- // rows carry no wall-clock values.
20
- //
21
- // SECRETS: the oracle only ever sees the conformance suite's synthetic
22
- // payloads. The output is a local test artifact (.differential/ is
23
- // gitignored, never published) and stays unminified for debuggability.
24
- import { mkdir } from 'node:fs/promises';
25
- import { dirname, join } from 'node:path';
26
- import { fileURLToPath } from 'node:url';
27
- import { build } from 'esbuild';
28
-
29
- const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
30
- const stubModulePath = join(
31
- packageRoot,
32
- '..',
33
- 'commander-harness',
34
- 'src',
35
- 'scripted',
36
- 'ScriptedClaudeAgentSdk.res.mjs'
37
- );
38
- const scriptModulePath = join(
39
- packageRoot,
40
- '..',
41
- 'commander-harness',
42
- 'src',
43
- 'scripted',
44
- 'ScriptedClaudeAgentSdkScript.res.mjs'
45
- );
46
-
47
- const driverSource = `
48
- import {
49
- startClaudeCodeSession,
50
- validateClaudeCodeResumeSession,
51
- } from './src/claudeCodeSession';
52
- import type { ClaudeCodeTranscriptEvent } from './src/claudeCodeSession';
53
- // The scenario side-channel of the SAME stub instance the alias bundles in
54
- // (esbuild dedupes by resolved path, so install/recorder observe the
55
- // aliased SDK the session driver consumes).
56
- import { install, recorder } from '${scriptModulePath.replace(/\\\\/g, '/')}';
57
-
58
- const cwd = '/scripted/workspace';
59
- const model = 'scripted-model-alpha';
60
-
61
- // The recorded API-provenance error text (must stay byte-identical to the
62
- // ReScript differential leg's scenario data).
63
- const apiErrorText =
64
- 'API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"},"request_id":"req_scripted42"}';
65
-
66
- const scenarios: Record<string, unknown> = {
67
- 'clean-turn': {
68
- queries: [{ TAG: 'CleanText', assistantText: 'scripted claude answer' }],
69
- startupBehavior: 'StartupOk',
70
- sessionInfo: 'SessionFound',
71
- sessionFirstPrompts: [],
72
- },
73
- 'approval-accept': {
74
- queries: [
75
- {
76
- TAG: 'ToolUseWithPermission',
77
- toolName: 'Bash',
78
- toolInputJson: '{"command":"curl https://api.example.test/v1/voices"}',
79
- assistantText: 'voice roster fetched',
80
- },
81
- ],
82
- startupBehavior: 'StartupOk',
83
- sessionInfo: 'SessionFound',
84
- sessionFirstPrompts: [],
85
- },
86
- 'approval-decline': {
87
- queries: [
88
- {
89
- TAG: 'ToolUseWithPermission',
90
- toolName: 'Bash',
91
- toolInputJson: '{"command":"curl https://api.example.test/v1/voices"}',
92
- assistantText: 'voice roster fetched',
93
- },
94
- ],
95
- startupBehavior: 'StartupOk',
96
- sessionInfo: 'SessionFound',
97
- sessionFirstPrompts: [],
98
- },
99
- error: {
100
- queries: [{ TAG: 'ResultApiError', errorText: apiErrorText }],
101
- startupBehavior: 'StartupOk',
102
- sessionInfo: 'SessionFound',
103
- sessionFirstPrompts: [],
104
- },
105
- interrupt: {
106
- queries: [{ TAG: 'MidTurnPark', assistantText: 'partial answer, then' }],
107
- startupBehavior: 'StartupOk',
108
- sessionInfo: 'SessionFound',
109
- sessionFirstPrompts: [],
110
- interruptBehavior: 'YieldInterruptResult',
111
- },
112
- 'resume-attach': {
113
- queries: [{ TAG: 'CleanText', assistantText: 'resumed answer' }],
114
- startupBehavior: 'StartupOk',
115
- sessionInfo: 'SessionFound',
116
- sessionFirstPrompts: [],
117
- },
118
- };
119
-
120
- // The runner-shaped streaming input queue (the live multi-turn channel:
121
- // only the owner closes it).
122
- function createInputQueue() {
123
- const pending: unknown[] = [];
124
- const waiters: Array<(step: { done: boolean; value: unknown }) => void> = [];
125
- let closed = false;
126
- return {
127
- messages: {
128
- [Symbol.asyncIterator]() {
129
- return {
130
- next(): Promise<{ done: boolean; value: unknown }> {
131
- if (pending.length > 0) {
132
- return Promise.resolve({ done: false, value: pending.shift() });
133
- }
134
- if (closed) {
135
- return Promise.resolve({ done: true, value: undefined });
136
- }
137
- return new Promise((resolve) => waiters.push(resolve));
138
- },
139
- };
140
- },
141
- },
142
- push(message: unknown) {
143
- const waiter = waiters.shift();
144
- if (waiter !== undefined) {
145
- waiter({ done: false, value: message });
146
- } else {
147
- pending.push(message);
148
- }
149
- },
150
- close() {
151
- closed = true;
152
- while (waiters.length > 0) {
153
- waiters.shift()!({ done: true, value: undefined });
154
- }
155
- },
156
- };
157
- }
158
-
159
- function userMessage(text: string) {
160
- return {
161
- type: 'user' as const,
162
- message: { role: 'user' as const, content: text },
163
- parent_tool_use_id: null,
164
- };
165
- }
166
-
167
- const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
168
-
169
- async function waitFor(predicate: () => boolean): Promise<void> {
170
- while (!predicate()) {
171
- await sleep(5);
172
- }
173
- }
174
-
175
- function transcript(): string[] {
176
- return (recorder as { events: Array<{ label: string; detail: string }> }).events.map(
177
- (event) => event.label + '|' + event.detail
178
- );
179
- }
180
-
181
- async function run(): Promise<void> {
182
- const scenarioName = process.argv[2];
183
- const scenario = scenarios[scenarioName ?? ''];
184
- if (scenario === undefined) {
185
- throw new Error('unknown scenario: ' + String(scenarioName));
186
- }
187
- install(scenario);
188
-
189
- const events: ClaudeCodeTranscriptEvent[] = [];
190
- const has = (type: string) => events.some((event) => event.type === type);
191
- let controls:
192
- | { interrupt: () => Promise<void> }
193
- | undefined;
194
- const queue = createInputQueue();
195
-
196
- if (scenarioName === 'resume-attach') {
197
- await validateClaudeCodeResumeSession({
198
- cwd,
199
- sessionId: 'scripted-claude-session-resumed-7',
200
- });
201
- }
202
-
203
- const sessionPromise = startClaudeCodeSession({
204
- cwd,
205
- prompt: '',
206
- streamingInput: queue,
207
- developerInstructions: undefined,
208
- model,
209
- permissionMode: 'default',
210
- ...(scenarioName === 'resume-attach'
211
- ? { resumeSessionId: 'scripted-claude-session-resumed-7' }
212
- : {}),
213
- canUseTool: async () =>
214
- scenarioName === 'approval-decline'
215
- ? { type: 'deny' as const, message: 'not on this machine' }
216
- : { type: 'allow' as const },
217
- onSessionControls: (liveControls) => {
218
- controls = liveControls;
219
- },
220
- onTranscriptEvent: (event) => {
221
- events.push(event);
222
- },
223
- });
224
- // The session settles by scenario design; failures are the error leg's
225
- // expected outcome and are re-checked below.
226
- const settled = sessionPromise.then(
227
- () => undefined,
228
- (error: unknown) => (error instanceof Error ? error.message : String(error))
229
- );
230
-
231
- queue.push(userMessage('do the thing'));
232
-
233
- switch (scenarioName) {
234
- case 'error': {
235
- // The TS session driver THROWS on the result error after emitting
236
- // session_failed; the transcript snapshot is taken AT the terminal
237
- // (the abandoned generator never closes the stub query - the
238
- // documented TS lifecycle - so the close rows are not part of this
239
- // scenario's comparison surface).
240
- await waitFor(() => has('session_failed'));
241
- const failure = await settled;
242
- if (failure === undefined) {
243
- throw new Error('the error scenario must fail the session');
244
- }
245
- process.stdout.write(JSON.stringify(transcript()) + '\\n');
246
- return;
247
- }
248
- case 'interrupt': {
249
- await waitFor(() => has('assistant_message'));
250
- await controls!.interrupt();
251
- await waitFor(() => has('turn_interrupted'));
252
- queue.close();
253
- // An interrupted single-turn session settles as the documented
254
- // no-text-response failure; the transcript is the comparison
255
- // surface.
256
- await settled;
257
- process.stdout.write(JSON.stringify(transcript()) + '\\n');
258
- return;
259
- }
260
- default: {
261
- await waitFor(() => has('turn_completed'));
262
- queue.close();
263
- const failure = await settled;
264
- if (failure !== undefined) {
265
- throw new Error('scenario ' + scenarioName + ' must complete: ' + failure);
266
- }
267
- process.stdout.write(JSON.stringify(transcript()) + '\\n');
268
- }
269
- }
270
- }
271
-
272
- run().then(
273
- () => process.exit(0),
274
- (error) => {
275
- process.stderr.write(String(error && error.stack ? error.stack : error) + '\\n');
276
- process.exit(1);
277
- }
278
- );
279
- `;
280
-
281
- const questionCardDriverSource = `
282
- /*
283
- * Spec: spec/commander-completion-pipeline-rules.md
284
- * (\`:commander-completion-pipeline/rule-07-claude-events-publish\`).
285
- * Relationship: Batch driver over the active TS Claude question-card model;
286
- * it contains no copied approval behavior.
287
- */
288
- import {
289
- claudeCodeQuestionAnsweredInput,
290
- claudeCodeToolApprovalRequest,
291
- claudeCodeUserQuestionStreamKey,
292
- claudeCodeUserQuestionStructuredMessage,
293
- parseClaudeCodeUserQuestionRequest,
294
- } from './src/claudeCodeUserQuestions';
295
- import type { ClaudeCodeUserQuestionAnswer } from './src/claudeCodeUserQuestions';
296
- import type { ClaudeCodePermissionRequest } from './src/claudeCodeSession';
297
- import type { JsonObject } from './src/protocol';
298
-
299
- type OracleCase = {
300
- readonly op?: 'approval' | 'question';
301
- readonly request: ClaudeCodePermissionRequest;
302
- readonly answers?: readonly ClaudeCodeUserQuestionAnswer[];
303
- readonly sessionId: string | undefined;
304
- readonly sourceSeq: number;
305
- readonly answerState: JsonObject;
306
- readonly streamState: 'streaming' | 'completed' | 'failed' | 'interrupted';
307
- };
308
-
309
- function handle(testCase: OracleCase): JsonObject {
310
- if (testCase.op === 'question') {
311
- const parsed = parseClaudeCodeUserQuestionRequest(testCase.request);
312
- if (parsed.type === 'question' && testCase.answers !== undefined) {
313
- return {
314
- parsed,
315
- answeredInput: claudeCodeQuestionAnsweredInput(
316
- testCase.request.input,
317
- parsed.request,
318
- testCase.answers
319
- ),
320
- };
321
- }
322
- return { parsed };
323
- }
324
- const approval = claudeCodeToolApprovalRequest(testCase.request);
325
- return {
326
- approval,
327
- structured: claudeCodeUserQuestionStructuredMessage({
328
- request: approval.request,
329
- sessionId: testCase.sessionId,
330
- sourceSeq: testCase.sourceSeq,
331
- answerState: testCase.answerState,
332
- streamState: testCase.streamState,
333
- }),
334
- streamKey: claudeCodeUserQuestionStreamKey(testCase.request.requestId),
335
- decisions: Object.fromEntries(
336
- approval.choices.map((choice) => [choice.decision, choice.permissionDecision])
337
- ),
338
- };
339
- }
340
-
341
- const chunks: Buffer[] = [];
342
- for await (const chunk of process.stdin) {
343
- chunks.push(Buffer.from(chunk));
344
- }
345
- const cases = JSON.parse(Buffer.concat(chunks).toString('utf8')) as OracleCase[];
346
- process.stdout.write(JSON.stringify(cases.map(handle)));
347
-
348
- `;
349
-
350
- const outDir = join(packageRoot, '.differential');
351
- const outPath = join(outDir, 'harness-claude-parity-oracle.mjs');
352
- const buildQuestionCard = process.argv[2] === 'question-card';
353
-
354
- await mkdir(outDir, { recursive: true });
355
-
356
- if (!buildQuestionCard) {
357
- await build({
358
- stdin: {
359
- contents: driverSource,
360
- resolveDir: packageRoot,
361
- sourcefile: 'harness-claude-parity-driver.ts',
362
- loader: 'ts',
363
- },
364
- bundle: true,
365
- platform: 'node',
366
- target: 'node20',
367
- format: 'esm',
368
- outfile: outPath,
369
- minify: false,
370
- sourcemap: false,
371
- legalComments: 'none',
372
- logLevel: 'silent',
373
- external: ['ws', 'undici', 'blessed'],
374
- alias: {
375
- '@anthropic-ai/claude-agent-sdk': stubModulePath,
376
- },
377
- });
378
- }
379
-
380
- const questionCardOutPath = join(
381
- outDir,
382
- 'claude-question-card-parity-oracle.mjs'
383
- );
384
-
385
- if (buildQuestionCard) {
386
- await build({
387
- stdin: {
388
- contents: questionCardDriverSource,
389
- resolveDir: packageRoot,
390
- sourcefile: 'claude-question-card-parity-driver.ts',
391
- loader: 'ts',
392
- },
393
- bundle: true,
394
- platform: 'node',
395
- target: 'node22',
396
- format: 'esm',
397
- outfile: questionCardOutPath,
398
- minify: false,
399
- sourcemap: 'inline',
400
- legalComments: 'none',
401
- logLevel: 'silent',
402
- });
403
- }
404
-
405
- process.stdout.write(
406
- (buildQuestionCard ? questionCardOutPath : outPath) + '\n'
407
- );