@linzumi/cli 1.0.200 → 1.0.201

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.
@@ -1540,7 +1540,7 @@ To kick the agent off:
1540
1540
  `,O=Buffer.byteLength(P,"utf8");if(O>s)return l("runner_diagnostics.spool_entry_dropped",{reason:"entry_too_large",entry_bytes:O,max_entry_bytes:s}),!1;iDe(n,{recursive:!0}),f(u)+O>i&&g(),_(O);let R=b()?`
1541
1541
  `:"";return tDe(u,`${R}${P}`,"utf8"),!0}catch(T){return l("runner_diagnostics.spool_failed",{error:T instanceof Error?T.message:String(T)}),!1}},v=C=>{let T=[],P=aDe(C,"utf8");for(let O of P.split(`
1542
1542
  `))if(O.trim()!=="")try{let R=JSON.parse(O);R!==null&&typeof R=="object"&&T.push({parsed:R,raw:O})}catch{}return T};return{append:w,drain:async C=>{if(c)return{uploadedBatches:0,uploadedEntries:0,remainingBatches:p().length,skipped:!0};c=!0;let T=0,P=0;try{g(),_(0);let O=a()-o;for(let R of p()){let j;try{j=v(R)}catch(H){l("runner_diagnostics.spool_batch_unreadable",{file:R,error:H instanceof Error?H.message:String(H)}),m(R,"unreadable");continue}let B=j.filter(H=>{let X=kDe(H.parsed);return X===void 0||X>=O});if(B.length===0){m(R,"empty_or_expired");continue}let K=UE(R,".jsonl"),D=B.map(H=>H.raw).join(`
1543
- `),J=B.map(H=>H.parsed.spooled_at).filter(H=>typeof H=="string"),W={bundle_name:"runner-diagnostics-spool",exported_at:new Date(a()).toISOString(),idempotency_key:K,diagnostics:{kind:"runner_diagnostic_log",spool_batch:!0,idempotency_key:K,entry_count:B.length,...J.length===0?{}:{first_spooled_at:J[0],last_spooled_at:J[J.length-1]}},telemetry_ndjson:D};try{await C(W)}catch(H){l("runner_diagnostics.spool_upload_failed",{file:R,remaining_batches:p().length,error:H instanceof Error?H.message:String(H)});break}T+=1,P+=B.length;try{RV(R)}catch(H){l("runner_diagnostics.spool_delete_failed",{file:R,error:H instanceof Error?H.message:String(H)})}}}catch(O){l("runner_diagnostics.spool_drain_failed",{error:O instanceof Error?O.message:String(O)})}finally{c=!1}return{uploadedBatches:T,uploadedEntries:P,remainingBatches:p().length,skipped:!1}},pendingBatchFiles:p}}var fDe,mDe,hDe,gDe,yDe,EV,xDe,bDe,MV=U(()=>{"use strict";qb();fDe=32*1024*1024,mDe=10080*60*1e3,hDe=4*1024*1024,gDe=1024*1024,yDe="spool.jsonl",EV=/^batch-(\d{1,16})-[0-9a-f-]+\.jsonl$/;xDe=/\b([A-Z][A-Z0-9_]{1,})=("[^"\n]*"|'[^'\n]*'|[^\s"'`;,)\]}]+)/g,bDe=/(?:\/(?:[A-Za-z0-9._@~+-]|%[0-9A-Fa-f]{2})+){2,}/g});var Yt,JE,Ka=U(()=>{"use strict";Yt="1.0.200",JE=`linzumi ${Yt}`});import{closeSync as OV,existsSync as VE,mkdirSync as CDe,openSync as $V,readFileSync as qV,renameSync as TDe,unlinkSync as ku,writeFileSync as PDe,writeSync as jV}from"node:fs";import{dirname as LV,join as IDe}from"node:path";function WE(e){return e instanceof Gs||e instanceof Error&&e.name===NV&&"lockPath"in e&&"heldBy"in e}function HE(e,n=at(),t){let r=t===void 0?encodeURIComponent(e):gu(t);return IDe(LV(n),"runners",`${r}.lock`)}function Hv(e){let n=HE(e.machineId,e.configPath,e.linzumiUrl),t=e.isPidAlive??WV,r=e.now??(()=>new Date),o=e.killPid??zDe,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:Gn(e.linzumiUrl)},...e.launchSource===void 0?{}:{launchSource:e.launchSource},startedAt:i,heartbeatAt:i,cliVersion:e.cliVersion??Yt,...e.gracefulUpdateDrain===!0?{gracefulUpdateDrain:!0}:{}};MDe(e.machineId,e.configPath,e.linzumiUrl,t,r,o,e.onTakeover),DDe(n,s,t,r,o,e.onTakeover,e.beforeReadExistingLock,e.beforeReplaceStaleLock);let a=()=>zV(n,s,r),d=setInterval(a,FV);return d.unref(),{path:n,record:s,heartbeat:a,release:()=>{clearInterval(d),KV(n,s)}}}function zV(e,n,t){try{let r=Zv(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`;PDe(i,`${JSON.stringify(o,null,2)}
1543
+ `),J=B.map(H=>H.parsed.spooled_at).filter(H=>typeof H=="string"),W={bundle_name:"runner-diagnostics-spool",exported_at:new Date(a()).toISOString(),idempotency_key:K,diagnostics:{kind:"runner_diagnostic_log",spool_batch:!0,idempotency_key:K,entry_count:B.length,...J.length===0?{}:{first_spooled_at:J[0],last_spooled_at:J[J.length-1]}},telemetry_ndjson:D};try{await C(W)}catch(H){l("runner_diagnostics.spool_upload_failed",{file:R,remaining_batches:p().length,error:H instanceof Error?H.message:String(H)});break}T+=1,P+=B.length;try{RV(R)}catch(H){l("runner_diagnostics.spool_delete_failed",{file:R,error:H instanceof Error?H.message:String(H)})}}}catch(O){l("runner_diagnostics.spool_drain_failed",{error:O instanceof Error?O.message:String(O)})}finally{c=!1}return{uploadedBatches:T,uploadedEntries:P,remainingBatches:p().length,skipped:!1}},pendingBatchFiles:p}}var fDe,mDe,hDe,gDe,yDe,EV,xDe,bDe,MV=U(()=>{"use strict";qb();fDe=32*1024*1024,mDe=10080*60*1e3,hDe=4*1024*1024,gDe=1024*1024,yDe="spool.jsonl",EV=/^batch-(\d{1,16})-[0-9a-f-]+\.jsonl$/;xDe=/\b([A-Z][A-Z0-9_]{1,})=("[^"\n]*"|'[^'\n]*'|[^\s"'`;,)\]}]+)/g,bDe=/(?:\/(?:[A-Za-z0-9._@~+-]|%[0-9A-Fa-f]{2})+){2,}/g});var Yt,JE,Ka=U(()=>{"use strict";Yt="1.0.201",JE=`linzumi ${Yt}`});import{closeSync as OV,existsSync as VE,mkdirSync as CDe,openSync as $V,readFileSync as qV,renameSync as TDe,unlinkSync as ku,writeFileSync as PDe,writeSync as jV}from"node:fs";import{dirname as LV,join as IDe}from"node:path";function WE(e){return e instanceof Gs||e instanceof Error&&e.name===NV&&"lockPath"in e&&"heldBy"in e}function HE(e,n=at(),t){let r=t===void 0?encodeURIComponent(e):gu(t);return IDe(LV(n),"runners",`${r}.lock`)}function Hv(e){let n=HE(e.machineId,e.configPath,e.linzumiUrl),t=e.isPidAlive??WV,r=e.now??(()=>new Date),o=e.killPid??zDe,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:Gn(e.linzumiUrl)},...e.launchSource===void 0?{}:{launchSource:e.launchSource},startedAt:i,heartbeatAt:i,cliVersion:e.cliVersion??Yt,...e.gracefulUpdateDrain===!0?{gracefulUpdateDrain:!0}:{}};MDe(e.machineId,e.configPath,e.linzumiUrl,t,r,o,e.onTakeover),DDe(n,s,t,r,o,e.onTakeover,e.beforeReadExistingLock,e.beforeReplaceStaleLock);let a=()=>zV(n,s,r),d=setInterval(a,FV);return d.unref(),{path:n,record:s,heartbeat:a,release:()=>{clearInterval(d),KV(n,s)}}}function zV(e,n,t){try{let r=Zv(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`;PDe(i,`${JSON.stringify(o,null,2)}
1544
1544
  `,"utf8"),TDe(i,e)}catch{}}function Cu(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>RDe?{state:"wedged",reason:e.heartbeatAt===void 0?"missing_heartbeat":"stale_heartbeat"}:{state:"live"}}function UV(e,n,t,r){return t!==Gv||e.launchSource!==Gv?!1:r.state!=="live"?!0:EDe(n,e.cliVersion)>0}function EDe(e,n){let t=DV(e),r=DV(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:ADe(t.prerelease,r.prerelease)}function DV(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=[KE(i[0]),KE(i[1]),KE(i[2])],a=o===""?[]:o.split(".").filter(d=>d!=="");return{core:s,prerelease:a}}function KE(e){let n=Number.parseInt(e??"",10);return Number.isInteger(n)&&n>=0?n:0}function ADe(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 BV(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 MDe(e,n,t,r,o,i,s){if(t===void 0||Er(t)!==Er(sr))return;let a=HE(e,n),d=Zv(a);if(d!==void 0){if(Cu(d,r,o).state==="live")throw new Gs(a,d);JV(a,r,()=>{let u=VE(a)?GE(a):void 0;if(u===void 0)return;let c=Cu(u,r,o);if(c.state==="live")throw new Gs(a,u);c.state==="wedged"&&BV(a,u,c.reason,i,s),ku(a)})}}function DDe(e,n,t,r,o,i,s,a){if(Wv(e,n))return;s?.();let d=Zv(e);if(d===void 0){if(Wv(e,n))return;throw new Error(`another Linzumi runner lock appeared while starting: ${e}`)}if(Cu(d,t,r).state==="live")throw new Gs(e,d);a?.(),JV(e,t,()=>{let u=VE(e)?GE(e):void 0;if(u!==void 0){let c=Cu(u,t,r);if(c.state==="live")throw new Gs(e,u);c.state==="wedged"&&BV(e,u,c.reason,o,i),ku(e)}if(!Wv(e,n))throw new Error(`another Linzumi runner lock appeared while starting: ${e}`)})}function Wv(e,n){CDe(LV(e),{recursive:!0});try{let t=$V(e,"wx");try{jV(t,`${JSON.stringify(n,null,2)}
1545
1545
  `)}finally{OV(t)}return!0}catch(t){if(rp(t,"EEXIST"))return!1;throw t}}function JV(e,n,t){let r=`${e}.replace`;for(;;)try{let o=$V(r,"wx");try{jV(o,`${process.pid}
1546
1546
  `),t()}finally{OV(o),ku(r)}return}catch(o){if(rp(o,"EEXIST")){let i=ODe(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.200",
3
+ "version": "1.0.201",
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": {