@linzumi/cli 1.0.215 → 1.0.217

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.
@@ -1556,7 +1556,7 @@ To kick the agent off:
1556
1556
  `,A=Buffer.byteLength(P,"utf8");if(A>s)return l("runner_diagnostics.spool_entry_dropped",{reason:"entry_too_large",entry_bytes:A,max_entry_bytes:s}),!1;F1e(n,{recursive:!0}),f(u)+A>i&&h(),_(A);let E=x()?`
1557
1557
  `:"";return q1e(u,`${E}${P}`,"utf8"),!0}catch(S){return l("runner_diagnostics.spool_failed",{error:S instanceof Error?S.message:String(S)}),!1}},v=k=>{let S=[],P=z1e(k,"utf8");for(let A of P.split(`
1558
1558
  `))if(A.trim()!=="")try{let E=JSON.parse(A);E!==null&&typeof E=="object"&&S.push({parsed:E,raw:A})}catch{}return S};return{append:w,drain:async k=>{if(c)return{uploadedBatches:0,uploadedEntries:0,remainingBatches:p().length,skipped:!0};c=!0;let S=0,P=0;try{h(),_(0);let A=a()-o;for(let E of p()){let O;try{O=v(E)}catch(V){l("runner_diagnostics.spool_batch_unreadable",{file:E,error:V instanceof Error?V.message:String(V)}),m(E,"unreadable");continue}let K=O.filter(V=>{let H=o2e(V.parsed);return H===void 0||H>=A});if(K.length===0){m(E,"empty_or_expired");continue}let W=AA(E,".jsonl"),Z=K.map(V=>V.raw).join(`
1559
- `),Y=K.map(V=>V.parsed.spooled_at).filter(V=>typeof V=="string"),$={bundle_name:"runner-diagnostics-spool",exported_at:new Date(a()).toISOString(),idempotency_key:W,diagnostics:{kind:"runner_diagnostic_log",spool_batch:!0,idempotency_key:W,entry_count:K.length,...Y.length===0?{}:{first_spooled_at:Y[0],last_spooled_at:Y[Y.length-1]}},telemetry_ndjson:Z};try{await k($)}catch(V){l("runner_diagnostics.spool_upload_failed",{file:E,remaining_batches:p().length,error:V instanceof Error?V.message:String(V)});break}S+=1,P+=K.length;try{RW(E)}catch(V){l("runner_diagnostics.spool_delete_failed",{file:E,error:V instanceof Error?V.message:String(V)})}}}catch(A){l("runner_diagnostics.spool_drain_failed",{error:A instanceof Error?A.message:String(A)})}finally{c=!1}return{uploadedBatches:S,uploadedEntries:P,remainingBatches:p().length,skipped:!1}},pendingBatchFiles:p}}var W1e,G1e,H1e,Z1e,Q1e,EW,Y1e,e2e,MW=z(()=>{"use strict";nv();W1e=32*1024*1024,G1e=10080*60*1e3,H1e=4*1024*1024,Z1e=1024*1024,Q1e="spool.jsonl",EW=/^batch-(\d{1,16})-[0-9a-f-]+\.jsonl$/;Y1e=/\b([A-Z][A-Z0-9_]{1,})=("[^"\n]*"|'[^'\n]*'|[^\s"'`;,)\]}]+)/g,e2e=/(?:\/(?:[A-Za-z0-9._@~+-]|%[0-9A-Fa-f]{2})+){2,}/g});var sr,DA,sd=z(()=>{"use strict";sr="1.0.215",DA=`linzumi ${sr}`});import{closeSync as OW,existsSync as $A,mkdirSync as i2e,openSync as $W,readFileSync as qW,renameSync as s2e,unlinkSync as Fu,writeFileSync as a2e,writeSync as jW}from"node:fs";import{dirname as LW,join as d2e}from"node:path";function qA(e){return e instanceof ca||e instanceof Error&&e.name===NW&&"lockPath"in e&&"heldBy"in e}function jA(e,n=pt(),t){let r=t===void 0?encodeURIComponent(e):Eu(t);return d2e(LW(n),"runners",`${r}.lock`)}function _w(e){let n=jA(e.machineId,e.configPath,e.linzumiUrl),t=e.isPidAlive??WW,r=e.now??(()=>new Date),o=e.killPid??v2e,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:nt(e.linzumiUrl)},...e.launchSource===void 0?{}:{launchSource:e.launchSource},startedAt:i,heartbeatAt:i,cliVersion:e.cliVersion??sr,...e.gracefulUpdateDrain===!0?{gracefulUpdateDrain:!0}:{}};p2e(e.machineId,e.configPath,e.linzumiUrl,t,r,o,e.onTakeover),f2e(n,s,t,r,o,e.onTakeover,e.beforeReadExistingLock,e.beforeReplaceStaleLock);let a=()=>zW(n,s,r),d=setInterval(a,FW);return d.unref(),{path:n,record:s,heartbeat:a,release:()=>{clearInterval(d),KW(n,s)}}}function zW(e,n,t){try{let r=bw(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`;a2e(i,`${JSON.stringify(o,null,2)}
1559
+ `),Y=K.map(V=>V.parsed.spooled_at).filter(V=>typeof V=="string"),$={bundle_name:"runner-diagnostics-spool",exported_at:new Date(a()).toISOString(),idempotency_key:W,diagnostics:{kind:"runner_diagnostic_log",spool_batch:!0,idempotency_key:W,entry_count:K.length,...Y.length===0?{}:{first_spooled_at:Y[0],last_spooled_at:Y[Y.length-1]}},telemetry_ndjson:Z};try{await k($)}catch(V){l("runner_diagnostics.spool_upload_failed",{file:E,remaining_batches:p().length,error:V instanceof Error?V.message:String(V)});break}S+=1,P+=K.length;try{RW(E)}catch(V){l("runner_diagnostics.spool_delete_failed",{file:E,error:V instanceof Error?V.message:String(V)})}}}catch(A){l("runner_diagnostics.spool_drain_failed",{error:A instanceof Error?A.message:String(A)})}finally{c=!1}return{uploadedBatches:S,uploadedEntries:P,remainingBatches:p().length,skipped:!1}},pendingBatchFiles:p}}var W1e,G1e,H1e,Z1e,Q1e,EW,Y1e,e2e,MW=z(()=>{"use strict";nv();W1e=32*1024*1024,G1e=10080*60*1e3,H1e=4*1024*1024,Z1e=1024*1024,Q1e="spool.jsonl",EW=/^batch-(\d{1,16})-[0-9a-f-]+\.jsonl$/;Y1e=/\b([A-Z][A-Z0-9_]{1,})=("[^"\n]*"|'[^'\n]*'|[^\s"'`;,)\]}]+)/g,e2e=/(?:\/(?:[A-Za-z0-9._@~+-]|%[0-9A-Fa-f]{2})+){2,}/g});var sr,DA,sd=z(()=>{"use strict";sr="1.0.217",DA=`linzumi ${sr}`});import{closeSync as OW,existsSync as $A,mkdirSync as i2e,openSync as $W,readFileSync as qW,renameSync as s2e,unlinkSync as Fu,writeFileSync as a2e,writeSync as jW}from"node:fs";import{dirname as LW,join as d2e}from"node:path";function qA(e){return e instanceof ca||e instanceof Error&&e.name===NW&&"lockPath"in e&&"heldBy"in e}function jA(e,n=pt(),t){let r=t===void 0?encodeURIComponent(e):Eu(t);return d2e(LW(n),"runners",`${r}.lock`)}function _w(e){let n=jA(e.machineId,e.configPath,e.linzumiUrl),t=e.isPidAlive??WW,r=e.now??(()=>new Date),o=e.killPid??v2e,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:nt(e.linzumiUrl)},...e.launchSource===void 0?{}:{launchSource:e.launchSource},startedAt:i,heartbeatAt:i,cliVersion:e.cliVersion??sr,...e.gracefulUpdateDrain===!0?{gracefulUpdateDrain:!0}:{}};p2e(e.machineId,e.configPath,e.linzumiUrl,t,r,o,e.onTakeover),f2e(n,s,t,r,o,e.onTakeover,e.beforeReadExistingLock,e.beforeReplaceStaleLock);let a=()=>zW(n,s,r),d=setInterval(a,FW);return d.unref(),{path:n,record:s,heartbeat:a,release:()=>{clearInterval(d),KW(n,s)}}}function zW(e,n,t){try{let r=bw(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`;a2e(i,`${JSON.stringify(o,null,2)}
1560
1560
  `,"utf8"),s2e(i,e)}catch{}}function Nu(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>u2e?{state:"wedged",reason:e.heartbeatAt===void 0?"missing_heartbeat":"stale_heartbeat"}:{state:"live"}}function UW(e,n,t,r){return t!==xw||e.launchSource!==xw?!1:r.state!=="live"?!0:c2e(n,e.cliVersion)>0}function c2e(e,n){let t=DW(e),r=DW(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:l2e(t.prerelease,r.prerelease)}function DW(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=[OA(i[0]),OA(i[1]),OA(i[2])],a=o===""?[]:o.split(".").filter(d=>d!=="");return{core:s,prerelease:a}}function OA(e){let n=Number.parseInt(e??"",10);return Number.isInteger(n)&&n>=0?n:0}function l2e(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 BW(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 p2e(e,n,t,r,o,i,s){if(t===void 0||zr(t)!==zr(yr))return;let a=jA(e,n),d=bw(a);if(d!==void 0){if(Nu(d,r,o).state==="live")throw new ca(a,d);JW(a,r,()=>{let u=$A(a)?LA(a):void 0;if(u===void 0)return;let c=Nu(u,r,o);if(c.state==="live")throw new ca(a,u);c.state==="wedged"&&BW(a,u,c.reason,i,s),Fu(a)})}}function f2e(e,n,t,r,o,i,s,a){if(yw(e,n))return;s?.();let d=bw(e);if(d===void 0){if(yw(e,n))return;throw new Error(`another Linzumi runner lock appeared while starting: ${e}`)}if(Nu(d,t,r).state==="live")throw new ca(e,d);a?.(),JW(e,t,()=>{let u=$A(e)?LA(e):void 0;if(u!==void 0){let c=Nu(u,t,r);if(c.state==="live")throw new ca(e,u);c.state==="wedged"&&BW(e,u,c.reason,o,i),Fu(e)}if(!yw(e,n))throw new Error(`another Linzumi runner lock appeared while starting: ${e}`)})}function yw(e,n){i2e(LW(e),{recursive:!0});try{let t=$W(e,"wx");try{jW(t,`${JSON.stringify(n,null,2)}
1561
1561
  `)}finally{OW(t)}return!0}catch(t){if(Pp(t,"EEXIST"))return!1;throw t}}function JW(e,n,t){let r=`${e}.replace`;for(;;)try{let o=$W(r,"wx");try{jW(o,`${process.pid}
1562
1562
  `),t()}finally{OW(o),Fu(r)}return}catch(o){if(Pp(o,"EEXIST")){let i=m2e(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.215",
3
+ "version": "1.0.217",
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": {
@@ -14,6 +14,7 @@
14
14
  ],
15
15
  "scripts": {
16
16
  "build": "rescript build ../linzumi-cli-rescript && node scripts/build.mjs",
17
+ "test:actual-commander-parity": "pnpm --dir ../linzumi-cli-rescript build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/ActualCommanderParityConformance.res.mjs",
17
18
  "bump-version": "node scripts/bump-cli-version.mjs",
18
19
  "codex:history-table": "node scripts/codex_history_table.mjs",
19
20
  "test": "rescript build ../linzumi-cli-rescript && node --import tsx --test ../linzumi-cli-rescript/src/parity/McpToolCallBoundaryTest.res.mjs && rescript build ../../kandan/server_v2/web/replay_harness && vitest run --config vitest.config.mjs",