@linzumi/cli 1.0.105 → 1.0.106
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 +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
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;_Se(n,{recursive:!0}),m(u)+L>i&&f(),_(L);let D=w()?`
|
|
1474
1474
|
`:"";return gSe(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=wSe(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 q=j.filter(Z=>{let me=FSe(Z.parsed);return me===void 0||me>=L});if(q.length===0){y(D,"empty_or_expired");continue}let E=uP(D,".jsonl"),B=q.map(Z=>Z.raw).join(`
|
|
1476
|
-
`),z=q.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:q.length,...z.length===0?{}:{first_spooled_at:z[0],last_spooled_at:z[z.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+=q.length;try{k9(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 PSe,ISe,RSe,ESe,DSe,C9,ASe,$Se,P9=F(()=>{"use strict";ix();PSe=32*1024*1024,ISe=10080*60*1e3,RSe=4*1024*1024,ESe=1024*1024,DSe="spool.jsonl",C9=/^batch-(\d{1,16})-[0-9a-f-]+\.jsonl$/;ASe=/\b([A-Z][A-Z0-9_]{1,})=("[^"\n]*"|'[^'\n]*'|[^\s"'`;,)\]}]+)/g,$Se=/(?:\/(?:[A-Za-z0-9._@~+-]|%[0-9A-Fa-f]{2})+){2,}/g});var qt,lP,ea=F(()=>{"use strict";qt="1.0.
|
|
1476
|
+
`),z=q.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:q.length,...z.length===0?{}:{first_spooled_at:z[0],last_spooled_at:z[z.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+=q.length;try{k9(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 PSe,ISe,RSe,ESe,DSe,C9,ASe,$Se,P9=F(()=>{"use strict";ix();PSe=32*1024*1024,ISe=10080*60*1e3,RSe=4*1024*1024,ESe=1024*1024,DSe="spool.jsonl",C9=/^batch-(\d{1,16})-[0-9a-f-]+\.jsonl$/;ASe=/\b([A-Z][A-Z0-9_]{1,})=("[^"\n]*"|'[^'\n]*'|[^\s"'`;,)\]}]+)/g,$Se=/(?:\/(?:[A-Za-z0-9._@~+-]|%[0-9A-Fa-f]{2})+){2,}/g});var qt,lP,ea=F(()=>{"use strict";qt="1.0.106",lP=`linzumi ${qt}`});import{closeSync as R9,existsSync as fP,mkdirSync as qSe,openSync as E9,readFileSync as D9,renameSync as zSe,unlinkSync as yd,writeFileSync as NSe,writeSync as M9}from"node:fs";import{dirname as A9,join as USe}from"node:path";function mP(e){return e instanceof gs||e instanceof Error&&e.name===O9&&"lockPath"in e&&"heldBy"in e}function hP(e,n=Wn(),t){let r=t===void 0?encodeURIComponent(e):ud(t);return USe(A9(n),"runners",`${r}.lock`)}function g0(e){let n=hP(e.machineId,e.configPath,e.linzumiUrl),t=e.isPidAlive??U9,r=e.now??(()=>new Date),o=e.killPid??nke,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:qn(e.linzumiUrl)},...e.launchSource===void 0?{}:{launchSource:e.launchSource},startedAt:i,heartbeatAt:i,cliVersion:e.cliVersion??qt,...e.gracefulUpdateDrain===!0?{gracefulUpdateDrain:!0}:{}};VSe(e.machineId,e.configPath,e.linzumiUrl,t,r,o,e.onTakeover),WSe(n,s,t,r,o,e.onTakeover,e.beforeReadExistingLock,e.beforeReplaceStaleLock);let a=()=>L9(n,s,r),d=setInterval(a,$9);return d.unref(),{path:n,record:s,heartbeat:a,release:()=>{clearInterval(d),z9(n,s)}}}function L9(e,n,t){try{let r=x0(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`;NSe(i,`${JSON.stringify(o,null,2)}
|
|
1477
1477
|
`,"utf8"),zSe(i,e)}catch{}}function xd(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>BSe?{state:"wedged",reason:e.heartbeatAt===void 0?"missing_heartbeat":"stale_heartbeat"}:{state:"live"}}function j9(e,n,t,r){return t!==y0||e.launchSource!==y0?!1:r.state!=="live"?!0:JSe(n,e.cliVersion)>0}function JSe(e,n){let t=I9(e),r=I9(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:KSe(t.prerelease,r.prerelease)}function I9(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=[pP(i[0]),pP(i[1]),pP(i[2])],a=o===""?[]:o.split(".").filter(d=>d!=="");return{core:s,prerelease:a}}function pP(e){let n=Number.parseInt(e??"",10);return Number.isInteger(n)&&n>=0?n:0}function KSe(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 F9(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 VSe(e,n,t,r,o,i,s){if(t===void 0||yr(t)!==yr(Jt))return;let a=hP(e,n),d=x0(a);if(d!==void 0){if(xd(d,r,o).state==="live")throw new gs(a,d);q9(a,r,()=>{let u=fP(a)?gP(a):void 0;if(u===void 0)return;let c=xd(u,r,o);if(c.state==="live")throw new gs(a,u);c.state==="wedged"&&F9(a,u,c.reason,i,s),yd(a)})}}function WSe(e,n,t,r,o,i,s,a){if(h0(e,n))return;s?.();let d=x0(e);if(d===void 0){if(h0(e,n))return;throw new Error(`another Linzumi runner lock appeared while starting: ${e}`)}if(xd(d,t,r).state==="live")throw new gs(e,d);a?.(),q9(e,t,()=>{let u=fP(e)?gP(e):void 0;if(u!==void 0){let c=xd(u,t,r);if(c.state==="live")throw new gs(e,u);c.state==="wedged"&&F9(e,u,c.reason,o,i),yd(e)}if(!h0(e,n))throw new Error(`another Linzumi runner lock appeared while starting: ${e}`)})}function h0(e,n){qSe(A9(e),{recursive:!0});try{let t=E9(e,"wx");try{M9(t,`${JSON.stringify(n,null,2)}
|
|
1478
1478
|
`)}finally{R9(t)}return!0}catch(t){if(Kc(t,"EEXIST"))return!1;throw t}}function q9(e,n,t){let r=`${e}.replace`;for(;;)try{let o=E9(r,"wx");try{M9(o,`${process.pid}
|
|
1479
1479
|
`),t()}finally{R9(o),yd(r)}return}catch(o){if(Kc(o,"EEXIST")){let i=HSe(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