@linzumi/cli 1.0.274 → 1.0.276

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 (41) hide show
  1. package/README.md +10 -9
  2. package/dist/{impl-ts/cloud-supervisor.mjs → cloud-supervisor.mjs} +85 -85
  3. package/dist/hosted-coding-account-worker.js +25 -0
  4. package/dist/index.js +1609 -3
  5. package/dist/mcp-server.mjs +174 -168
  6. package/dist/{impl-res/native → native}/darwin/manifest.json +5 -2
  7. package/dist/remote-codex-harness-worker.js +757 -0
  8. package/dist/tcp-tunnel-cli.mjs +25 -69
  9. package/dist/topics-cli.mjs +137 -13
  10. package/package.json +9 -16
  11. package/scripts/build.mjs +33 -356
  12. package/scripts/bump-cli-version.mjs +35 -9
  13. package/scripts/check-package-size-budget.mjs +13 -61
  14. package/dist/impl-res/cloud-supervisor.mjs +0 -281
  15. package/dist/impl-res/index.js +0 -1546
  16. package/dist/impl-res/mcp-server.mjs +0 -461
  17. package/dist/impl-ts/assets/linzumi-logo.svg +0 -1
  18. package/dist/impl-ts/crossHarnessFailover.mjs +0 -14
  19. package/dist/impl-ts/index.js +0 -2617
  20. package/dist/impl-ts/mcp-server.mjs +0 -455
  21. package/dist/impl-ts/native/darwin/manifest.json +0 -21
  22. package/dist/impl-ts/native/darwin/preview-process-identity +0 -0
  23. package/dist/impl-ts/tcp-tunnel-cli.mjs +0 -93
  24. package/scripts/build-differential-entry-impl-res.mjs +0 -64
  25. package/scripts/build-differential-entry.mjs +0 -180
  26. package/scripts/build-onboarding-demo-evidence.mjs +0 -186
  27. package/scripts/build-tui-demo-evidence.mjs +0 -107
  28. package/scripts/diagnose-claude-probe.ts +0 -198
  29. package/scripts/differentialMutations.mjs +0 -114
  30. package/scripts/f5_live_cross_harness_failover_e2e.mjs +0 -239
  31. package/scripts/golden-chaos-harness.mjs +0 -1420
  32. package/scripts/normalize-agent-replay-fixture.ts +0 -281
  33. package/scripts/promote-gstack-claude-smoke-fixture.ts +0 -891
  34. package/scripts/record-agent-replay-fixtures.ts +0 -610
  35. package/scripts/replay-agent-backend-browser.ts +0 -198
  36. package/scripts/replay-agent-backend.ts +0 -1961
  37. package/scripts/replay-agent-fixture.ts +0 -326
  38. package/scripts/typecheck.mjs +0 -42
  39. /package/dist/{impl-res/assets → assets}/linzumi-logo.svg +0 -0
  40. /package/dist/{impl-res/crossHarnessFailover.mjs → crossHarnessFailover.mjs} +0 -0
  41. /package/dist/{impl-res/native → native}/darwin/preview-process-identity +0 -0
@@ -1,281 +0,0 @@
1
- /*
2
- - Date: 2026-06-29
3
- Spec: plans/2026-06-29-claude-code-raw-replay-harness-plan.md
4
- Relationship: Promotion-time normalizer for real raw agent replay captures.
5
- Capture files stay exact in /tmp; this script produces deterministic fixtures
6
- by normalizing machine-local paths and volatile run/session identifiers.
7
- */
8
- import { mkdir, readFile, readdir, writeFile } from 'node:fs/promises';
9
- import { basename, dirname, extname, join, resolve } from 'node:path';
10
-
11
- export type AgentReplayNormalizeOptions = {
12
- readonly normalizeProviderIds: boolean;
13
- };
14
-
15
- type NormalizerState = {
16
- readonly options: AgentReplayNormalizeOptions;
17
- readonly mappings: Map<string, string>;
18
- nextRunId: number;
19
- nextSessionId: number;
20
- nextMessageId: number;
21
- };
22
-
23
- type CliOptions =
24
- | {
25
- readonly type: 'single';
26
- readonly input: string;
27
- readonly output: string;
28
- readonly normalizeProviderIds: boolean;
29
- }
30
- | {
31
- readonly type: 'directory';
32
- readonly inputDir: string;
33
- readonly outputDir: string;
34
- readonly normalizeProviderIds: boolean;
35
- };
36
-
37
- const defaultOptions: AgentReplayNormalizeOptions = {
38
- normalizeProviderIds: true,
39
- };
40
-
41
- const homePathPattern = /\/home\/([A-Za-z0-9._-]+)/gu;
42
- const tmpRunPathPattern =
43
- /\/tmp\/linzumi-(codex|claude)-fixture-[A-Za-z0-9]+/gu;
44
- const tmpReplayPathPattern = /\/tmp\/linzumi-agent-replay-[A-Za-z0-9._-]+/gu;
45
- const codexSessionFilePattern =
46
- /rollout-\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-[0-9a-f-]{36}\.jsonl/giu;
47
- const uuidPattern =
48
- /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/giu;
49
- const codexMessageIdPattern = /\bmsg_[A-Za-z0-9_-]{16,}\b/gu;
50
- const claudeSignaturePattern = /("signature"\s*:\s*")[^"]+(")/gu;
51
-
52
- export function normalizeAgentReplayText(
53
- text: string,
54
- options: AgentReplayNormalizeOptions = defaultOptions
55
- ): string {
56
- const state: NormalizerState = {
57
- options,
58
- mappings: new Map(),
59
- nextRunId: 1,
60
- nextSessionId: 1,
61
- nextMessageId: 1,
62
- };
63
-
64
- return text
65
- .split(/\r?\n/u)
66
- .map((line) => normalizeNdjsonLine(line, state))
67
- .join('\n');
68
- }
69
-
70
- function normalizeNdjsonLine(line: string, state: NormalizerState): string {
71
- if (line.trim() === '') {
72
- return line;
73
- }
74
-
75
- try {
76
- const parsed = JSON.parse(line) as unknown;
77
- return JSON.stringify(normalizeJsonValue(parsed, state));
78
- } catch (_error) {
79
- return normalizeString(line, state);
80
- }
81
- }
82
-
83
- function normalizeJsonValue(value: unknown, state: NormalizerState): unknown {
84
- if (Array.isArray(value)) {
85
- return value.map((item) => normalizeJsonValue(item, state));
86
- }
87
-
88
- if (value !== null && typeof value === 'object') {
89
- const normalizedEntries = Object.entries(value).map(([key, child]) => {
90
- if (key === 'rawText' && typeof child === 'string') {
91
- return [key, normalizeRawText(child, state)] as const;
92
- }
93
-
94
- if (key === 'signature' && typeof child === 'string') {
95
- return [key, '[fixture-signature]'] as const;
96
- }
97
-
98
- return [key, normalizeJsonValue(child, state)] as const;
99
- });
100
-
101
- return Object.fromEntries(normalizedEntries);
102
- }
103
-
104
- return typeof value === 'string' ? normalizeString(value, state) : value;
105
- }
106
-
107
- function normalizeRawText(value: string, state: NormalizerState): string {
108
- try {
109
- const parsed = JSON.parse(value) as unknown;
110
- return JSON.stringify(normalizeJsonValue(parsed, state));
111
- } catch (_error) {
112
- return normalizeString(value, state);
113
- }
114
- }
115
-
116
- function normalizeString(value: string, state: NormalizerState): string {
117
- let normalized = value
118
- .replace(tmpRunPathPattern, (_match, provider: string) =>
119
- mappedValue(
120
- state,
121
- _match,
122
- () => `/tmp/linzumi-agent-fixture/${provider}-run-${state.nextRunId++}`
123
- )
124
- )
125
- .replace(tmpReplayPathPattern, '/tmp/linzumi-agent-replay')
126
- .replace(homePathPattern, '/home/fixture-user')
127
- .replace(codexSessionFilePattern, (match) =>
128
- mappedValue(
129
- state,
130
- match,
131
- () =>
132
- `rollout-2026-06-29T00-00-00-fixture-session-${state.nextSessionId++}.jsonl`
133
- )
134
- )
135
- .replace(claudeSignaturePattern, '$1[fixture-signature]$2');
136
-
137
- switch (state.options.normalizeProviderIds) {
138
- case true:
139
- normalized = normalized
140
- .replace(uuidPattern, (match) =>
141
- mappedValue(
142
- state,
143
- match,
144
- () =>
145
- `00000000-0000-4000-8000-${String(state.nextSessionId++).padStart(12, '0')}`
146
- )
147
- )
148
- .replace(codexMessageIdPattern, (match) =>
149
- mappedValue(
150
- state,
151
- match,
152
- () =>
153
- `msg_fixture_${String(state.nextMessageId++).padStart(4, '0')}`
154
- )
155
- );
156
- break;
157
- case false:
158
- break;
159
- }
160
-
161
- return normalized;
162
- }
163
-
164
- function mappedValue(
165
- state: NormalizerState,
166
- input: string,
167
- create: () => string
168
- ): string {
169
- const existing = state.mappings.get(input);
170
-
171
- if (existing !== undefined) {
172
- return existing;
173
- }
174
-
175
- const next = create();
176
- state.mappings.set(input, next);
177
- return next;
178
- }
179
-
180
- async function main(): Promise<void> {
181
- const args = process.argv.slice(2);
182
-
183
- if (args.includes('--help')) {
184
- printHelp();
185
- return;
186
- }
187
-
188
- const options = parseCliOptions(args);
189
-
190
- switch (options.type) {
191
- case 'single':
192
- await normalizeFile(options.input, options.output, {
193
- normalizeProviderIds: options.normalizeProviderIds,
194
- });
195
- process.stdout.write(`wrote ${options.output}\n`);
196
- break;
197
- case 'directory': {
198
- await mkdir(options.outputDir, { recursive: true });
199
- const entries = await readdir(options.inputDir, { withFileTypes: true });
200
- const ndjsonFiles = entries.filter(
201
- (entry) => entry.isFile() && extname(entry.name) === '.ndjson'
202
- );
203
-
204
- for (const entry of ndjsonFiles) {
205
- const input = join(options.inputDir, entry.name);
206
- const output = join(options.outputDir, entry.name);
207
- await normalizeFile(input, output, {
208
- normalizeProviderIds: options.normalizeProviderIds,
209
- });
210
- process.stdout.write(`wrote ${output}\n`);
211
- }
212
- break;
213
- }
214
- }
215
- }
216
-
217
- async function normalizeFile(
218
- input: string,
219
- output: string,
220
- options: AgentReplayNormalizeOptions
221
- ): Promise<void> {
222
- const source = await readFile(input, 'utf8');
223
- const normalized = normalizeAgentReplayText(source, options);
224
- await mkdir(dirname(output), { recursive: true });
225
- await writeFile(output, normalized, 'utf8');
226
- }
227
-
228
- function parseCliOptions(args: readonly string[]): CliOptions {
229
- const normalizeProviderIds = !args.includes('--keep-provider-ids');
230
- const input = argValue(args, '--input');
231
- const output = argValue(args, '--output');
232
- const inputDir = argValue(args, '--input-dir');
233
- const outputDir = argValue(args, '--output-dir');
234
-
235
- if (input !== undefined && output !== undefined) {
236
- return {
237
- type: 'single',
238
- input: resolve(input),
239
- output: resolve(output),
240
- normalizeProviderIds,
241
- };
242
- }
243
-
244
- if (inputDir !== undefined && outputDir !== undefined) {
245
- return {
246
- type: 'directory',
247
- inputDir: resolve(inputDir),
248
- outputDir: resolve(outputDir),
249
- normalizeProviderIds,
250
- };
251
- }
252
-
253
- throw new Error(
254
- 'provide either --input/--output or --input-dir/--output-dir'
255
- );
256
- }
257
-
258
- function argValue(args: readonly string[], name: string): string | undefined {
259
- const index = args.indexOf(name);
260
-
261
- if (index === -1) {
262
- return undefined;
263
- }
264
-
265
- return args[index + 1];
266
- }
267
-
268
- function printHelp(): void {
269
- process.stdout.write(
270
- `Usage: pnpm run normalize:agent-fixture -- [options]\n\nOptions:\n --input <file> --output <file> Normalize one NDJSON fixture\n --input-dir <dir> --output-dir <dir> Normalize every .ndjson file in a directory\n --keep-provider-ids Preserve provider session/message ids\n\nExamples:\n pnpm run normalize:agent-fixture -- --input-dir /tmp/linzumi-agent-replay-probe --output-dir test/fixtures/agent-raw-replay/promoted\n`
271
- );
272
- }
273
-
274
- if (basename(process.argv[1] ?? '') === 'normalize-agent-replay-fixture.ts') {
275
- main().catch((error) => {
276
- process.stderr.write(
277
- `${error instanceof Error ? (error.stack ?? error.message) : String(error)}\n`
278
- );
279
- process.exitCode = 1;
280
- });
281
- }