@linzumi/cli 1.0.108 → 1.0.109

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.
package/README.md CHANGED
@@ -58,7 +58,7 @@ Install the CLI or run it with `npx`:
58
58
  ```bash
59
59
  npm install -g @linzumi/cli@latest
60
60
  npx -y @linzumi/cli@latest signup
61
- npx -y @linzumi/cli@1.0.108 --version
61
+ npx -y @linzumi/cli@1.0.109 --version
62
62
  linzumi --version
63
63
  ```
64
64
 
package/dist/index.js CHANGED
@@ -1473,7 +1473,7 @@ To kick the agent off:
1473
1473
  `,L=Buffer.byteLength(P,"utf8");if(L>s)return l("runner_diagnostics.spool_entry_dropped",{reason:"entry_too_large",entry_bytes:L,max_entry_bytes:s}),!1;jSe(n,{recursive:!0}),m(u)+L>i&&f(),_(L);let D=w()?`
1474
1474
  `:"";return $Se(u,`${D}${P}`,"utf8"),!0}catch(R){return l("runner_diagnostics.spool_failed",{error:R instanceof Error?R.message:String(R)}),!1}},v=k=>{let R=[],P=zSe(k,"utf8");for(let L of P.split(`
1475
1475
  `))if(L.trim()!=="")try{let D=JSON.parse(L);D!==null&&typeof D=="object"&&R.push({parsed:D,raw:L})}catch{}return R};return{append:S,drain:async k=>{if(c)return{uploadedBatches:0,uploadedEntries:0,remainingBatches:p().length,skipped:!0};c=!0;let R=0,P=0;try{f(),_(0);let L=a()-o;for(let D of p()){let j;try{j=v(D)}catch(Z){l("runner_diagnostics.spool_batch_unreadable",{file:D,error:Z instanceof Error?Z.message:String(Z)}),y(D,"unreadable");continue}let z=j.filter(Z=>{let me=tke(Z.parsed);return me===void 0||me>=L});if(z.length===0){y(D,"empty_or_expired");continue}let E=hP(D,".jsonl"),B=z.map(Z=>Z.raw).join(`
1476
- `),q=z.map(Z=>Z.parsed.spooled_at).filter(Z=>typeof Z=="string"),W={bundle_name:"runner-diagnostics-spool",exported_at:new Date(a()).toISOString(),idempotency_key:E,diagnostics:{kind:"runner_diagnostic_log",spool_batch:!0,idempotency_key:E,entry_count:z.length,...q.length===0?{}:{first_spooled_at:q[0],last_spooled_at:q[q.length-1]}},telemetry_ndjson:B};try{await k(W)}catch(Z){l("runner_diagnostics.spool_upload_failed",{file:D,remaining_batches:p().length,error:Z instanceof Error?Z.message:String(Z)});break}R+=1,P+=z.length;try{F9(D)}catch(Z){l("runner_diagnostics.spool_delete_failed",{file:D,error:Z instanceof Error?Z.message:String(Z)})}}}catch(L){l("runner_diagnostics.spool_drain_failed",{error:L instanceof Error?L.message:String(L)})}finally{c=!1}return{uploadedBatches:R,uploadedEntries:P,remainingBatches:p().length,skipped:!1}},pendingBatchFiles:p}}var KSe,VSe,WSe,HSe,GSe,z9,QSe,XSe,N9=F(()=>{"use strict";ax();KSe=32*1024*1024,VSe=10080*60*1e3,WSe=4*1024*1024,HSe=1024*1024,GSe="spool.jsonl",z9=/^batch-(\d{1,16})-[0-9a-f-]+\.jsonl$/;QSe=/\b([A-Z][A-Z0-9_]{1,})=("[^"\n]*"|'[^'\n]*'|[^\s"'`;,)\]}]+)/g,XSe=/(?:\/(?:[A-Za-z0-9._@~+-]|%[0-9A-Fa-f]{2})+){2,}/g});var qt,yP,ta=F(()=>{"use strict";qt="1.0.108",yP=`linzumi ${qt}`});import{closeSync as B9,existsSync as _P,mkdirSync as rke,openSync as J9,readFileSync as K9,renameSync as oke,unlinkSync as _d,writeFileSync as ike,writeSync as V9}from"node:fs";import{dirname as W9,join as ske}from"node:path";function bP(e){return e instanceof ys||e instanceof Error&&e.name===G9&&"lockPath"in e&&"heldBy"in e}function wP(e,n=Wn(),t){let r=t===void 0?encodeURIComponent(e):ld(t);return ske(W9(n),"runners",`${r}.lock`)}function x_(e){let n=wP(e.machineId,e.configPath,e.linzumiUrl),t=e.isPidAlive??t3,r=e.now??(()=>new Date),o=e.killPid??_ke,i=r().toISOString(),s={version:1,machineId:e.machineId,runnerId:e.runnerId,pid:e.pid??process.pid,cwd:e.cwd,workspace:e.workspace,...e.linzumiUrl===void 0?{}:{linzumiUrl:zn(e.linzumiUrl)},...e.launchSource===void 0?{}:{launchSource:e.launchSource},startedAt:i,heartbeatAt:i,cliVersion:e.cliVersion??qt,...e.gracefulUpdateDrain===!0?{gracefulUpdateDrain:!0}:{}};cke(e.machineId,e.configPath,e.linzumiUrl,t,r,o,e.onTakeover),lke(n,s,t,r,o,e.onTakeover,e.beforeReadExistingLock,e.beforeReplaceStaleLock);let a=()=>Z9(n,s,r),d=setInterval(a,H9);return d.unref(),{path:n,record:s,heartbeat:a,release:()=>{clearInterval(d),e3(n,s)}}}function Z9(e,n,t){try{let r=b_(e);if(r===void 0||r.machineId!==n.machineId||r.runnerId!==n.runnerId||r.pid!==n.pid||r.startedAt!==n.startedAt)return;let o={...r,heartbeatAt:t().toISOString()},i=`${e}.tmp`;ike(i,`${JSON.stringify(o,null,2)}
1476
+ `),q=z.map(Z=>Z.parsed.spooled_at).filter(Z=>typeof Z=="string"),W={bundle_name:"runner-diagnostics-spool",exported_at:new Date(a()).toISOString(),idempotency_key:E,diagnostics:{kind:"runner_diagnostic_log",spool_batch:!0,idempotency_key:E,entry_count:z.length,...q.length===0?{}:{first_spooled_at:q[0],last_spooled_at:q[q.length-1]}},telemetry_ndjson:B};try{await k(W)}catch(Z){l("runner_diagnostics.spool_upload_failed",{file:D,remaining_batches:p().length,error:Z instanceof Error?Z.message:String(Z)});break}R+=1,P+=z.length;try{F9(D)}catch(Z){l("runner_diagnostics.spool_delete_failed",{file:D,error:Z instanceof Error?Z.message:String(Z)})}}}catch(L){l("runner_diagnostics.spool_drain_failed",{error:L instanceof Error?L.message:String(L)})}finally{c=!1}return{uploadedBatches:R,uploadedEntries:P,remainingBatches:p().length,skipped:!1}},pendingBatchFiles:p}}var KSe,VSe,WSe,HSe,GSe,z9,QSe,XSe,N9=F(()=>{"use strict";ax();KSe=32*1024*1024,VSe=10080*60*1e3,WSe=4*1024*1024,HSe=1024*1024,GSe="spool.jsonl",z9=/^batch-(\d{1,16})-[0-9a-f-]+\.jsonl$/;QSe=/\b([A-Z][A-Z0-9_]{1,})=("[^"\n]*"|'[^'\n]*'|[^\s"'`;,)\]}]+)/g,XSe=/(?:\/(?:[A-Za-z0-9._@~+-]|%[0-9A-Fa-f]{2})+){2,}/g});var qt,yP,ta=F(()=>{"use strict";qt="1.0.109",yP=`linzumi ${qt}`});import{closeSync as B9,existsSync as _P,mkdirSync as rke,openSync as J9,readFileSync as K9,renameSync as oke,unlinkSync as _d,writeFileSync as ike,writeSync as V9}from"node:fs";import{dirname as W9,join as ske}from"node:path";function bP(e){return e instanceof ys||e instanceof Error&&e.name===G9&&"lockPath"in e&&"heldBy"in e}function wP(e,n=Wn(),t){let r=t===void 0?encodeURIComponent(e):ld(t);return ske(W9(n),"runners",`${r}.lock`)}function x_(e){let n=wP(e.machineId,e.configPath,e.linzumiUrl),t=e.isPidAlive??t3,r=e.now??(()=>new Date),o=e.killPid??_ke,i=r().toISOString(),s={version:1,machineId:e.machineId,runnerId:e.runnerId,pid:e.pid??process.pid,cwd:e.cwd,workspace:e.workspace,...e.linzumiUrl===void 0?{}:{linzumiUrl:zn(e.linzumiUrl)},...e.launchSource===void 0?{}:{launchSource:e.launchSource},startedAt:i,heartbeatAt:i,cliVersion:e.cliVersion??qt,...e.gracefulUpdateDrain===!0?{gracefulUpdateDrain:!0}:{}};cke(e.machineId,e.configPath,e.linzumiUrl,t,r,o,e.onTakeover),lke(n,s,t,r,o,e.onTakeover,e.beforeReadExistingLock,e.beforeReplaceStaleLock);let a=()=>Z9(n,s,r),d=setInterval(a,H9);return d.unref(),{path:n,record:s,heartbeat:a,release:()=>{clearInterval(d),e3(n,s)}}}function Z9(e,n,t){try{let r=b_(e);if(r===void 0||r.machineId!==n.machineId||r.runnerId!==n.runnerId||r.pid!==n.pid||r.startedAt!==n.startedAt)return;let o={...r,heartbeatAt:t().toISOString()},i=`${e}.tmp`;ike(i,`${JSON.stringify(o,null,2)}
1477
1477
  `,"utf8"),oke(i,e)}catch{}}function bd(e,n,t){if(!n(e.pid))return{state:"dead"};let r=e.heartbeatAt??e.startedAt,o=Date.parse(r);return Number.isNaN(o)||t().getTime()-o>ake?{state:"wedged",reason:e.heartbeatAt===void 0?"missing_heartbeat":"stale_heartbeat"}:{state:"live"}}function Q9(e,n,t,r){return t!==__||e.launchSource!==__?!1:r.state!=="live"?!0:dke(n,e.cliVersion)>0}function dke(e,n){let t=U9(e),r=U9(n);for(let o=0;o<3;o++){let i=t.core[o],s=r.core[o];if(i===void 0||s===void 0)throw new Error(`compareCliVersions: unexpected undefined at core index ${o}`);if(i!==s)return i>s?1:-1}return t.prerelease.length===0&&r.prerelease.length===0?0:t.prerelease.length===0?1:r.prerelease.length===0?-1:uke(t.prerelease,r.prerelease)}function U9(e){let n=e.trim().replace(/^v/i,"").split("+",1)[0]??"",t=n.indexOf("-"),r=t===-1?n:n.slice(0,t),o=t===-1?"":n.slice(t+1),i=r.split("."),s=[xP(i[0]),xP(i[1]),xP(i[2])],a=o===""?[]:o.split(".").filter(d=>d!=="");return{core:s,prerelease:a}}function xP(e){let n=Number.parseInt(e??"",10);return Number.isInteger(n)&&n>=0?n:0}function uke(e,n){let t=Math.max(e.length,n.length);for(let r=0;r<t;r++){let o=e[r],i=n[r];if(o===void 0)return-1;if(i===void 0)return 1;let s=Number.parseInt(o,10),a=Number.parseInt(i,10),d=s.toString()===o,u=a.toString()===i;if(d&&u){if(s!==a)return s>a?1:-1}else{if(d!==u)return d?-1:1;if(o!==i)return o>i?1:-1}}return 0}function X9(e,n,t,r,o){try{r(n.pid)}catch(i){let s=i!==null&&typeof i=="object"&&"code"in i?i.code:void 0;if(s!=="ESRCH")throw s==="EPERM"||s==="EACCES"?new Error(`Cannot take over the runner lock at ${e}: its holder process (pid ${n.pid}) is owned by another user and cannot be stopped. Stop that process, or remove the lock file, then retry.`):i}o?.({lockPath:e,holderPid:n.pid,holderRunnerId:n.runnerId,reason:t})}function cke(e,n,t,r,o,i,s){if(t===void 0||yr(t)!==yr(Jt))return;let a=wP(e,n),d=b_(a);if(d!==void 0){if(bd(d,r,o).state==="live")throw new ys(a,d);Y9(a,r,()=>{let u=_P(a)?vP(a):void 0;if(u===void 0)return;let c=bd(u,r,o);if(c.state==="live")throw new ys(a,u);c.state==="wedged"&&X9(a,u,c.reason,i,s),_d(a)})}}function lke(e,n,t,r,o,i,s,a){if(y_(e,n))return;s?.();let d=b_(e);if(d===void 0){if(y_(e,n))return;throw new Error(`another Linzumi runner lock appeared while starting: ${e}`)}if(bd(d,t,r).state==="live")throw new ys(e,d);a?.(),Y9(e,t,()=>{let u=_P(e)?vP(e):void 0;if(u!==void 0){let c=bd(u,t,r);if(c.state==="live")throw new ys(e,u);c.state==="wedged"&&X9(e,u,c.reason,o,i),_d(e)}if(!y_(e,n))throw new Error(`another Linzumi runner lock appeared while starting: ${e}`)})}function y_(e,n){rke(W9(e),{recursive:!0});try{let t=J9(e,"wx");try{V9(t,`${JSON.stringify(n,null,2)}
1478
1478
  `)}finally{B9(t)}return!0}catch(t){if(Vc(t,"EEXIST"))return!1;throw t}}function Y9(e,n,t){let r=`${e}.replace`;for(;;)try{let o=J9(r,"wx");try{V9(o,`${process.pid}
1479
1479
  `),t()}finally{B9(o),_d(r)}return}catch(o){if(Vc(o,"EEXIST")){let i=pke(r);if(i===void 0)continue;if(n(i))throw new Error(["another Linzumi runner is already replacing a stale runner lock",`lock: ${e}`,"Wait for that startup to finish, then retry."].join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linzumi/cli",
3
- "version": "1.0.108",
3
+ "version": "1.0.109",
4
4
  "description": "Linzumi CLI \u2014 point a Codex agent at the real code on your laptop, with your team watching and steering from shared threads.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,93 @@
1
+ // Spec: kandan/plans/2026-07-13-t1-canonical-activity-format-spec.md
2
+ // (section 11, the T.2 amendment; compute-nodes program, workstream T,
3
+ // task T.2).
4
+ // Relationship: Builds the TS-side ORACLE for the codex transpiler's
5
+ // live-injection leg. T.2's ReScript module
6
+ // (packages/linzumi-cli-rescript/src/transpile/HarnessCodexTranspiler.res)
7
+ // owns the codex SESSION-FORMAT directions; canonical -> codex
8
+ // `thread/inject_items` stays THE one implementation here in
9
+ // src/transcriptCompiler.ts (`transpileCanonicalToCodexInjectItems`, the
10
+ // T.1 re-expressed rebuild path). This oracle bundles that REAL
11
+ // implementation behind a one-shot stdin/stdout driver so the T.2
12
+ // conformance
13
+ // (packages/linzumi-cli-rescript/src/parity/HarnessCodexTranspilerConformance.res)
14
+ // can prove a T.2 foreign-export page parses through the real consumer and
15
+ // feeds the real inject_items emission - one implementation, never a
16
+ // ReScript re-expression.
17
+ //
18
+ // Like build-protocol-parity-oracle.mjs, the output is a local test
19
+ // artifact (.differential/ is gitignored, never published) and stays
20
+ // unminified for debuggability.
21
+ import { mkdir } from 'node:fs/promises';
22
+ import { dirname, join } from 'node:path';
23
+ import { fileURLToPath } from 'node:url';
24
+ import { build } from 'esbuild';
25
+
26
+ const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
27
+
28
+ const driverSource = `
29
+ import {
30
+ parseCanonicalActivityPage,
31
+ transpileCanonicalToCodexInjectItems,
32
+ } from './src/transcriptCompiler';
33
+
34
+ let stdin = '';
35
+ process.stdin.setEncoding('utf8');
36
+ for await (const chunk of process.stdin) {
37
+ stdin += chunk;
38
+ }
39
+ const input = JSON.parse(stdin);
40
+ const page = parseCanonicalActivityPage(input.page);
41
+
42
+ if (page === undefined) {
43
+ process.stdout.write(JSON.stringify({ parsed: false }));
44
+ } else {
45
+ const emission = transpileCanonicalToCodexInjectItems({
46
+ nodes: page.nodes,
47
+ budget: page.budget,
48
+ resumeFailure:
49
+ typeof input.resume_failure === 'string' ? input.resume_failure : '',
50
+ threadTitle: page.threadTitle,
51
+ });
52
+ process.stdout.write(
53
+ JSON.stringify({
54
+ parsed: true,
55
+ ir_version: page.irVersion,
56
+ node_count: page.nodes.length,
57
+ node_kinds: page.nodes.map((node) => node.kind),
58
+ emission: {
59
+ items: emission.items,
60
+ emitted_node_count: emission.emittedNodeCount,
61
+ omitted_node_count: emission.omittedNodeCount,
62
+ redacted_reasoning_count: emission.redactedReasoningCount,
63
+ max_emission_tokens: emission.maxEmissionTokens,
64
+ },
65
+ })
66
+ );
67
+ }
68
+ `;
69
+
70
+ await mkdir(join(packageRoot, '.differential'), { recursive: true });
71
+
72
+ await build({
73
+ stdin: {
74
+ contents: driverSource,
75
+ resolveDir: packageRoot,
76
+ sourcefile: 'canonical-codex-transpiler-driver.ts',
77
+ loader: 'ts',
78
+ },
79
+ bundle: true,
80
+ platform: 'node',
81
+ target: 'node20',
82
+ format: 'esm',
83
+ outfile: join(
84
+ packageRoot,
85
+ '.differential/canonical-codex-transpiler-oracle.mjs'
86
+ ),
87
+ minify: false,
88
+ sourcemap: false,
89
+ legalComments: 'none',
90
+ // transcriptCompiler is dependency-light; anything leaking in from the
91
+ // wider commander graph stays external exactly like the entry build.
92
+ external: ['ws', 'undici', 'blessed', '@anthropic-ai/claude-agent-sdk'],
93
+ });