@linzumi/cli 1.0.207 → 1.0.209

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
  `,D=Buffer.byteLength(I,"utf8");if(D>s)return l("runner_diagnostics.spool_entry_dropped",{reason:"entry_too_large",entry_bytes:D,max_entry_bytes:s}),!1;T1e(n,{recursive:!0}),f(u)+D>i&&g(),_(D);let E=b()?`
1557
1557
  `:"";return S1e(u,`${E}${I}`,"utf8"),!0}catch(C){return l("runner_diagnostics.spool_failed",{error:C instanceof Error?C.message:String(C)}),!1}},v=S=>{let C=[],I=I1e(S,"utf8");for(let D of I.split(`
1558
1558
  `))if(D.trim()!=="")try{let E=JSON.parse(D);E!==null&&typeof E=="object"&&C.push({parsed:E,raw:D})}catch{}return C};return{append:w,drain:async S=>{if(c)return{uploadedBatches:0,uploadedEntries:0,remainingBatches:p().length,skipped:!0};c=!0;let C=0,I=0;try{g(),_(0);let D=a()-o;for(let E of p()){let j;try{j=v(E)}catch(K){l("runner_diagnostics.spool_batch_unreadable",{file:E,error:K instanceof Error?K.message:String(K)}),m(E,"unreadable");continue}let V=j.filter(K=>{let Z=K1e(K.parsed);return Z===void 0||Z>=D});if(V.length===0){m(E,"empty_or_expired");continue}let G=TA(E,".jsonl"),H=V.map(K=>K.raw).join(`
1559
- `),ee=V.map(K=>K.parsed.spooled_at).filter(K=>typeof K=="string"),$={bundle_name:"runner-diagnostics-spool",exported_at:new Date(a()).toISOString(),idempotency_key:G,diagnostics:{kind:"runner_diagnostic_log",spool_batch:!0,idempotency_key:G,entry_count:V.length,...ee.length===0?{}:{first_spooled_at:ee[0],last_spooled_at:ee[ee.length-1]}},telemetry_ndjson:H};try{await S($)}catch(K){l("runner_diagnostics.spool_upload_failed",{file:E,remaining_batches:p().length,error:K instanceof Error?K.message:String(K)});break}C+=1,I+=V.length;try{kW(E)}catch(K){l("runner_diagnostics.spool_delete_failed",{file:E,error:K instanceof Error?K.message:String(K)})}}}catch(D){l("runner_diagnostics.spool_drain_failed",{error:D instanceof Error?D.message:String(D)})}finally{c=!1}return{uploadedBatches:C,uploadedEntries:I,remainingBatches:p().length,skipped:!1}},pendingBatchFiles:p}}var O1e,$1e,q1e,j1e,F1e,CW,N1e,z1e,PW=z(()=>{"use strict";Yb();O1e=32*1024*1024,$1e=10080*60*1e3,q1e=4*1024*1024,j1e=1024*1024,F1e="spool.jsonl",CW=/^batch-(\d{1,16})-[0-9a-f-]+\.jsonl$/;N1e=/\b([A-Z][A-Z0-9_]{1,})=("[^"\n]*"|'[^'\n]*'|[^\s"'`;,)\]}]+)/g,z1e=/(?:\/(?:[A-Za-z0-9._@~+-]|%[0-9A-Fa-f]{2})+){2,}/g});var sr,IA,od=z(()=>{"use strict";sr="1.0.207",IA=`linzumi ${sr}`});import{closeSync as RW,existsSync as EA,mkdirSync as V1e,openSync as EW,readFileSync as AW,renameSync as W1e,unlinkSync as ju,writeFileSync as G1e,writeSync as MW}from"node:fs";import{dirname as DW,join as H1e}from"node:path";function AA(e){return e instanceof ua||e instanceof Error&&e.name===$W&&"lockPath"in e&&"heldBy"in e}function MA(e,n=pt(),t){let r=t===void 0?encodeURIComponent(e):Iu(t);return H1e(DW(n),"runners",`${r}.lock`)}function gw(e){let n=MA(e.machineId,e.configPath,e.linzumiUrl),t=e.isPidAlive??UW,r=e.now??(()=>new Date),o=e.killPid??d2e,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}:{}};Y1e(e.machineId,e.configPath,e.linzumiUrl,t,r,o,e.onTakeover),e2e(n,s,t,r,o,e.onTakeover,e.beforeReadExistingLock,e.beforeReplaceStaleLock);let a=()=>qW(n,s,r),d=setInterval(a,OW);return d.unref(),{path:n,record:s,heartbeat:a,release:()=>{clearInterval(d),NW(n,s)}}}function qW(e,n,t){try{let r=_w(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`;G1e(i,`${JSON.stringify(o,null,2)}
1559
+ `),ee=V.map(K=>K.parsed.spooled_at).filter(K=>typeof K=="string"),$={bundle_name:"runner-diagnostics-spool",exported_at:new Date(a()).toISOString(),idempotency_key:G,diagnostics:{kind:"runner_diagnostic_log",spool_batch:!0,idempotency_key:G,entry_count:V.length,...ee.length===0?{}:{first_spooled_at:ee[0],last_spooled_at:ee[ee.length-1]}},telemetry_ndjson:H};try{await S($)}catch(K){l("runner_diagnostics.spool_upload_failed",{file:E,remaining_batches:p().length,error:K instanceof Error?K.message:String(K)});break}C+=1,I+=V.length;try{kW(E)}catch(K){l("runner_diagnostics.spool_delete_failed",{file:E,error:K instanceof Error?K.message:String(K)})}}}catch(D){l("runner_diagnostics.spool_drain_failed",{error:D instanceof Error?D.message:String(D)})}finally{c=!1}return{uploadedBatches:C,uploadedEntries:I,remainingBatches:p().length,skipped:!1}},pendingBatchFiles:p}}var O1e,$1e,q1e,j1e,F1e,CW,N1e,z1e,PW=z(()=>{"use strict";Yb();O1e=32*1024*1024,$1e=10080*60*1e3,q1e=4*1024*1024,j1e=1024*1024,F1e="spool.jsonl",CW=/^batch-(\d{1,16})-[0-9a-f-]+\.jsonl$/;N1e=/\b([A-Z][A-Z0-9_]{1,})=("[^"\n]*"|'[^'\n]*'|[^\s"'`;,)\]}]+)/g,z1e=/(?:\/(?:[A-Za-z0-9._@~+-]|%[0-9A-Fa-f]{2})+){2,}/g});var sr,IA,od=z(()=>{"use strict";sr="1.0.209",IA=`linzumi ${sr}`});import{closeSync as RW,existsSync as EA,mkdirSync as V1e,openSync as EW,readFileSync as AW,renameSync as W1e,unlinkSync as ju,writeFileSync as G1e,writeSync as MW}from"node:fs";import{dirname as DW,join as H1e}from"node:path";function AA(e){return e instanceof ua||e instanceof Error&&e.name===$W&&"lockPath"in e&&"heldBy"in e}function MA(e,n=pt(),t){let r=t===void 0?encodeURIComponent(e):Iu(t);return H1e(DW(n),"runners",`${r}.lock`)}function gw(e){let n=MA(e.machineId,e.configPath,e.linzumiUrl),t=e.isPidAlive??UW,r=e.now??(()=>new Date),o=e.killPid??d2e,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}:{}};Y1e(e.machineId,e.configPath,e.linzumiUrl,t,r,o,e.onTakeover),e2e(n,s,t,r,o,e.onTakeover,e.beforeReadExistingLock,e.beforeReplaceStaleLock);let a=()=>qW(n,s,r),d=setInterval(a,OW);return d.unref(),{path:n,record:s,heartbeat:a,release:()=>{clearInterval(d),NW(n,s)}}}function qW(e,n,t){try{let r=_w(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`;G1e(i,`${JSON.stringify(o,null,2)}
1560
1560
  `,"utf8"),W1e(i,e)}catch{}}function Fu(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>Z1e?{state:"wedged",reason:e.heartbeatAt===void 0?"missing_heartbeat":"stale_heartbeat"}:{state:"live"}}function jW(e,n,t,r){return t!==yw||e.launchSource!==yw?!1:r.state!=="live"?!0:Q1e(n,e.cliVersion)>0}function Q1e(e,n){let t=IW(e),r=IW(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:X1e(t.prerelease,r.prerelease)}function IW(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=[RA(i[0]),RA(i[1]),RA(i[2])],a=o===""?[]:o.split(".").filter(d=>d!=="");return{core:s,prerelease:a}}function RA(e){let n=Number.parseInt(e??"",10);return Number.isInteger(n)&&n>=0?n:0}function X1e(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 FW(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 Y1e(e,n,t,r,o,i,s){if(t===void 0||zr(t)!==zr(yr))return;let a=MA(e,n),d=_w(a);if(d!==void 0){if(Fu(d,r,o).state==="live")throw new ua(a,d);LW(a,r,()=>{let u=EA(a)?DA(a):void 0;if(u===void 0)return;let c=Fu(u,r,o);if(c.state==="live")throw new ua(a,u);c.state==="wedged"&&FW(a,u,c.reason,i,s),ju(a)})}}function e2e(e,n,t,r,o,i,s,a){if(hw(e,n))return;s?.();let d=_w(e);if(d===void 0){if(hw(e,n))return;throw new Error(`another Linzumi runner lock appeared while starting: ${e}`)}if(Fu(d,t,r).state==="live")throw new ua(e,d);a?.(),LW(e,t,()=>{let u=EA(e)?DA(e):void 0;if(u!==void 0){let c=Fu(u,t,r);if(c.state==="live")throw new ua(e,u);c.state==="wedged"&&FW(e,u,c.reason,o,i),ju(e)}if(!hw(e,n))throw new Error(`another Linzumi runner lock appeared while starting: ${e}`)})}function hw(e,n){V1e(DW(e),{recursive:!0});try{let t=EW(e,"wx");try{MW(t,`${JSON.stringify(n,null,2)}
1561
1561
  `)}finally{RW(t)}return!0}catch(t){if(kp(t,"EEXIST"))return!1;throw t}}function LW(e,n,t){let r=`${e}.replace`;for(;;)try{let o=EW(r,"wx");try{MW(o,`${process.pid}
1562
1562
  `),t()}finally{RW(o),ju(r)}return}catch(o){if(kp(o,"EEXIST")){let i=n2e(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.207",
3
+ "version": "1.0.209",
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": {