@linzumi/cli 1.0.253 → 1.0.254

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.
@@ -1566,7 +1566,7 @@ To kick the agent off:
1566
1566
  `,F=Buffer.byteLength(T,"utf8");if(F>a)return l("runner_diagnostics.spool_entry_dropped",{reason:"entry_too_large",entry_bytes:F,max_entry_bytes:a}),!1;nUe(n,{recursive:!0}),f(u)+F>i&&g(),m(F);let E=b()?`
1567
1567
  `:"";return Xze(u,`${E}${T}`,"utf8"),!0}catch(P){return l("runner_diagnostics.spool_failed",{error:P instanceof Error?P.message:String(P)}),!1}},v=C=>{let P=[],T=rUe(C,"utf8");for(let F of T.split(`
1568
1568
  `))if(F.trim()!=="")try{let E=JSON.parse(F);E!==null&&typeof E=="object"&&P.push({parsed:E,raw:F})}catch{}return P};return{append:w,drain:async C=>{if(c)return{uploadedBatches:0,uploadedEntries:0,remainingBatches:p().length,skipped:!0};c=!0;let P=0,T=0;try{g(),m(0);let F=s()-o;for(let E of p()){let A;try{A=v(E)}catch(ne){l("runner_diagnostics.spool_batch_unreadable",{file:E,error:ne instanceof Error?ne.message:String(ne)}),_(E,"unreadable");continue}let K=A.filter(ne=>{let N=xUe(ne.parsed);return N===void 0||N>=F});if(K.length===0){_(E,"empty_or_expired");continue}let B=WO(E,".jsonl"),H=K.map(ne=>ne.raw).join(`
1569
- `),oe=K.map(ne=>ne.parsed.spooled_at).filter(ne=>typeof ne=="string"),ie={bundle_name:"runner-diagnostics-spool",exported_at:new Date(s()).toISOString(),idempotency_key:B,diagnostics:{kind:"runner_diagnostic_log",spool_batch:!0,idempotency_key:B,entry_count:K.length,...oe.length===0?{}:{first_spooled_at:oe[0],last_spooled_at:oe[oe.length-1]}},telemetry_ndjson:H};try{await C(ie)}catch(ne){l("runner_diagnostics.spool_upload_failed",{file:E,remaining_batches:p().length,error:ne instanceof Error?ne.message:String(ne)});break}P+=1,T+=K.length;try{Mne(E)}catch(ne){l("runner_diagnostics.spool_delete_failed",{file:E,error:ne instanceof Error?ne.message:String(ne)})}}}catch(F){l("runner_diagnostics.spool_drain_failed",{error:F instanceof Error?F.message:String(F)})}finally{c=!1}return{uploadedBatches:P,uploadedEntries:T,remainingBatches:p().length,skipped:!1}},pendingBatchFiles:p}}var uUe,cUe,lUe,pUe,fUe,Dne,hUe,gUe,qne=V(()=>{"use strict";AS();uUe=32*1024*1024,cUe=10080*60*1e3,lUe=4*1024*1024,pUe=1024*1024,fUe="spool.jsonl",Dne=/^batch-(\d{1,16})-[0-9a-f-]+\.jsonl$/;hUe=/\b([A-Z][A-Z0-9_]{1,})=("[^"\n]*"|'[^'\n]*'|[^\s"'`;,)\]}]+)/g,gUe=/(?:\/(?:[A-Za-z0-9._@~+-]|%[0-9A-Fa-f]{2})+){2,}/g});var nr,GO,qu=V(()=>{"use strict";nr="1.0.253",GO=`linzumi ${nr}`});import{closeSync as Fne,existsSync as ZO,mkdirSync as vUe,openSync as Lne,readFileSync as jne,renameSync as wUe,unlinkSync as Cl,writeFileSync as SUe,writeSync as Nne}from"node:fs";import{dirname as zne,join as kUe}from"node:path";function QO(e){return e instanceof Cd||e instanceof Error&&e.name===Bne&&"lockPath"in e&&"heldBy"in e}function XO(e,n=Et(),t){let r=t===void 0?encodeURIComponent(e):il(t);return kUe(zne(n),"runners",`${r}.lock`)}function bC(e){let n=XO(e.machineId,e.configPath,e.linzumiUrl),t=e.isPidAlive??Zne,r=e.now??(()=>new Date),o=e.killPid??FUe,i=r().toISOString(),a={version:1,machineId:e.machineId,runnerId:e.runnerId,pid:e.pid??process.pid,cwd:e.cwd,workspace:e.workspace,...e.linzumiUrl===void 0?{}:{linzumiUrl:xt(e.linzumiUrl)},...e.launchSource===void 0?{}:{launchSource:e.launchSource},...e.processGroupLeader===!0?{processGroupLeader:!0}:{},startedAt:i,heartbeatAt:i,cliVersion:e.cliVersion??nr,...e.gracefulUpdateDrain===!0?{gracefulUpdateDrain:!0}:{}};PUe(e.machineId,e.configPath,e.linzumiUrl,t,r,o,e.onTakeover),RUe(n,a,t,r,o,e.onTakeover,e.beforeReadExistingLock,e.beforeReplaceStaleLock);let s=()=>Jne(n,a,r),d=setInterval(s,Une);return d.unref(),{path:n,record:a,heartbeat:s,release:()=>{clearInterval(d),Gne(n,a)}}}function Jne(e,n,t){try{let r=vC(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`;SUe(i,`${JSON.stringify(o,null,2)}
1569
+ `),oe=K.map(ne=>ne.parsed.spooled_at).filter(ne=>typeof ne=="string"),ie={bundle_name:"runner-diagnostics-spool",exported_at:new Date(s()).toISOString(),idempotency_key:B,diagnostics:{kind:"runner_diagnostic_log",spool_batch:!0,idempotency_key:B,entry_count:K.length,...oe.length===0?{}:{first_spooled_at:oe[0],last_spooled_at:oe[oe.length-1]}},telemetry_ndjson:H};try{await C(ie)}catch(ne){l("runner_diagnostics.spool_upload_failed",{file:E,remaining_batches:p().length,error:ne instanceof Error?ne.message:String(ne)});break}P+=1,T+=K.length;try{Mne(E)}catch(ne){l("runner_diagnostics.spool_delete_failed",{file:E,error:ne instanceof Error?ne.message:String(ne)})}}}catch(F){l("runner_diagnostics.spool_drain_failed",{error:F instanceof Error?F.message:String(F)})}finally{c=!1}return{uploadedBatches:P,uploadedEntries:T,remainingBatches:p().length,skipped:!1}},pendingBatchFiles:p}}var uUe,cUe,lUe,pUe,fUe,Dne,hUe,gUe,qne=V(()=>{"use strict";AS();uUe=32*1024*1024,cUe=10080*60*1e3,lUe=4*1024*1024,pUe=1024*1024,fUe="spool.jsonl",Dne=/^batch-(\d{1,16})-[0-9a-f-]+\.jsonl$/;hUe=/\b([A-Z][A-Z0-9_]{1,})=("[^"\n]*"|'[^'\n]*'|[^\s"'`;,)\]}]+)/g,gUe=/(?:\/(?:[A-Za-z0-9._@~+-]|%[0-9A-Fa-f]{2})+){2,}/g});var nr,GO,qu=V(()=>{"use strict";nr="1.0.254",GO=`linzumi ${nr}`});import{closeSync as Fne,existsSync as ZO,mkdirSync as vUe,openSync as Lne,readFileSync as jne,renameSync as wUe,unlinkSync as Cl,writeFileSync as SUe,writeSync as Nne}from"node:fs";import{dirname as zne,join as kUe}from"node:path";function QO(e){return e instanceof Cd||e instanceof Error&&e.name===Bne&&"lockPath"in e&&"heldBy"in e}function XO(e,n=Et(),t){let r=t===void 0?encodeURIComponent(e):il(t);return kUe(zne(n),"runners",`${r}.lock`)}function bC(e){let n=XO(e.machineId,e.configPath,e.linzumiUrl),t=e.isPidAlive??Zne,r=e.now??(()=>new Date),o=e.killPid??FUe,i=r().toISOString(),a={version:1,machineId:e.machineId,runnerId:e.runnerId,pid:e.pid??process.pid,cwd:e.cwd,workspace:e.workspace,...e.linzumiUrl===void 0?{}:{linzumiUrl:xt(e.linzumiUrl)},...e.launchSource===void 0?{}:{launchSource:e.launchSource},...e.processGroupLeader===!0?{processGroupLeader:!0}:{},startedAt:i,heartbeatAt:i,cliVersion:e.cliVersion??nr,...e.gracefulUpdateDrain===!0?{gracefulUpdateDrain:!0}:{}};PUe(e.machineId,e.configPath,e.linzumiUrl,t,r,o,e.onTakeover),RUe(n,a,t,r,o,e.onTakeover,e.beforeReadExistingLock,e.beforeReplaceStaleLock);let s=()=>Jne(n,a,r),d=setInterval(s,Une);return d.unref(),{path:n,record:a,heartbeat:s,release:()=>{clearInterval(d),Gne(n,a)}}}function Jne(e,n,t){try{let r=vC(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`;SUe(i,`${JSON.stringify(o,null,2)}
1570
1570
  `,"utf8"),wUe(i,e)}catch{}}function Tl(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>CUe?{state:"wedged",reason:e.heartbeatAt===void 0?"missing_heartbeat":"stale_heartbeat"}:{state:"live"}}function Kne(e,n,t,r){return t!==xC||e.launchSource!==xC?!1:r.state!=="live"?!0:TUe(n,e.cliVersion)>0}function TUe(e,n){let t=$ne(e),r=$ne(n);for(let o=0;o<3;o++){let i=t.core[o],a=r.core[o];if(i===void 0||a===void 0)throw new Error(`compareCliVersions: unexpected undefined at core index ${o}`);if(i!==a)return i>a?1:-1}return t.prerelease.length===0&&r.prerelease.length===0?0:t.prerelease.length===0?1:r.prerelease.length===0?-1:IUe(t.prerelease,r.prerelease)}function $ne(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("."),a=[HO(i[0]),HO(i[1]),HO(i[2])],s=o===""?[]:o.split(".").filter(d=>d!=="");return{core:a,prerelease:s}}function HO(e){let n=Number.parseInt(e??"",10);return Number.isInteger(n)&&n>=0?n:0}function IUe(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 a=Number.parseInt(o,10),s=Number.parseInt(i,10),d=a.toString()===o,u=s.toString()===i;if(d&&u){if(a!==s)return a>s?1:-1}else{if(d!==u)return d?-1:1;if(o!==i)return o>i?1:-1}}return 0}function Wne(e,n,t,r,o){try{r(n.pid)}catch(i){let a=i!==null&&typeof i=="object"&&"code"in i?i.code:void 0;if(a!=="ESRCH")throw a==="EPERM"||a==="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 PUe(e,n,t,r,o,i,a){if(t===void 0||go(t)!==go(Lr))return;let s=XO(e,n),d=vC(s);if(d!==void 0){if(Tl(d,r,o).state==="live")throw new Cd(s,d);Vne(s,r,()=>{let u=ZO(s)?YO(s):void 0;if(u===void 0)return;let c=Tl(u,r,o);if(c.state==="live")throw new Cd(s,u);c.state==="wedged"&&Wne(s,u,c.reason,i,a),Cl(s)})}}function RUe(e,n,t,r,o,i,a,s){if(_C(e,n))return;a?.();let d=vC(e);if(d===void 0){if(_C(e,n))return;throw new Error(`another Linzumi runner lock appeared while starting: ${e}`)}if(Tl(d,t,r).state==="live")throw new Cd(e,d);s?.(),Vne(e,t,()=>{let u=ZO(e)?YO(e):void 0;if(u!==void 0){let c=Tl(u,t,r);if(c.state==="live")throw new Cd(e,u);c.state==="wedged"&&Wne(e,u,c.reason,o,i),Cl(e)}if(!_C(e,n))throw new Error(`another Linzumi runner lock appeared while starting: ${e}`)})}function _C(e,n){vUe(zne(e),{recursive:!0});try{let t=Lne(e,"wx");try{Nne(t,`${JSON.stringify(n,null,2)}
1571
1571
  `)}finally{Fne(t)}return!0}catch(t){if(jm(t,"EEXIST"))return!1;throw t}}function Vne(e,n,t){let r=`${e}.replace`;for(;;)try{let o=Lne(r,"wx");try{Nne(o,`${process.pid}
1572
1572
  `),t()}finally{Fne(o),Cl(r)}return}catch(o){if(jm(o,"EEXIST")){let i=EUe(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.253",
3
+ "version": "1.0.254",
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": {