@linzumi/cli 1.0.224 → 1.0.225
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/impl-res/index.js +217 -217
- package/dist/impl-ts/index.js +1 -1
- package/package.json +1 -1
package/dist/impl-ts/index.js
CHANGED
|
@@ -1556,7 +1556,7 @@ To kick the agent off:
|
|
|
1556
1556
|
`,M=Buffer.byteLength(P,"utf8");if(M>s)return l("runner_diagnostics.spool_entry_dropped",{reason:"entry_too_large",entry_bytes:M,max_entry_bytes:s}),!1;a2e(n,{recursive:!0}),f(u)+M>i&&g(),_(M);let R=b()?`
|
|
1557
1557
|
`:"";return o2e(u,`${R}${P}`,"utf8"),!0}catch(S){return l("runner_diagnostics.spool_failed",{error:S instanceof Error?S.message:String(S)}),!1}},v=T=>{let S=[],P=u2e(T,"utf8");for(let M of P.split(`
|
|
1558
1558
|
`))if(M.trim()!=="")try{let R=JSON.parse(M);R!==null&&typeof R=="object"&&S.push({parsed:R,raw:M})}catch{}return S};return{append:w,drain:async T=>{if(c)return{uploadedBatches:0,uploadedEntries:0,remainingBatches:p().length,skipped:!0};c=!0;let S=0,P=0;try{g(),_(0);let M=a()-o;for(let R of p()){let $;try{$=v(R)}catch(W){l("runner_diagnostics.spool_batch_unreadable",{file:R,error:W instanceof Error?W.message:String(W)}),m(R,"unreadable");continue}let J=$.filter(W=>{let G=T2e(W.parsed);return G===void 0||G>=M});if(J.length===0){m(R,"empty_or_expired");continue}let V=LA(R,".jsonl"),Z=J.map(W=>W.raw).join(`
|
|
1559
|
-
`),ee=J.map(W=>W.parsed.spooled_at).filter(W=>typeof W=="string"),F={bundle_name:"runner-diagnostics-spool",exported_at:new Date(a()).toISOString(),idempotency_key:V,diagnostics:{kind:"runner_diagnostic_log",spool_batch:!0,idempotency_key:V,entry_count:J.length,...ee.length===0?{}:{first_spooled_at:ee[0],last_spooled_at:ee[ee.length-1]}},telemetry_ndjson:Z};try{await T(F)}catch(W){l("runner_diagnostics.spool_upload_failed",{file:R,remaining_batches:p().length,error:W instanceof Error?W.message:String(W)});break}S+=1,P+=J.length;try{KW(R)}catch(W){l("runner_diagnostics.spool_delete_failed",{file:R,error:W instanceof Error?W.message:String(W)})}}}catch(M){l("runner_diagnostics.spool_drain_failed",{error:M instanceof Error?M.message:String(M)})}finally{c=!1}return{uploadedBatches:S,uploadedEntries:P,remainingBatches:p().length,skipped:!1}},pendingBatchFiles:p}}var h2e,g2e,y2e,_2e,x2e,VW,v2e,w2e,GW=U(()=>{"use strict";dv();h2e=32*1024*1024,g2e=10080*60*1e3,y2e=4*1024*1024,_2e=1024*1024,x2e="spool.jsonl",VW=/^batch-(\d{1,16})-[0-9a-f-]+\.jsonl$/;v2e=/\b([A-Z][A-Z0-9_]{1,})=("[^"\n]*"|'[^'\n]*'|[^\s"'`;,)\]}]+)/g,w2e=/(?:\/(?:[A-Za-z0-9._@~+-]|%[0-9A-Fa-f]{2})+){2,}/g});var ir,zA,id=U(()=>{"use strict";ir="1.0.
|
|
1559
|
+
`),ee=J.map(W=>W.parsed.spooled_at).filter(W=>typeof W=="string"),F={bundle_name:"runner-diagnostics-spool",exported_at:new Date(a()).toISOString(),idempotency_key:V,diagnostics:{kind:"runner_diagnostic_log",spool_batch:!0,idempotency_key:V,entry_count:J.length,...ee.length===0?{}:{first_spooled_at:ee[0],last_spooled_at:ee[ee.length-1]}},telemetry_ndjson:Z};try{await T(F)}catch(W){l("runner_diagnostics.spool_upload_failed",{file:R,remaining_batches:p().length,error:W instanceof Error?W.message:String(W)});break}S+=1,P+=J.length;try{KW(R)}catch(W){l("runner_diagnostics.spool_delete_failed",{file:R,error:W instanceof Error?W.message:String(W)})}}}catch(M){l("runner_diagnostics.spool_drain_failed",{error:M instanceof Error?M.message:String(M)})}finally{c=!1}return{uploadedBatches:S,uploadedEntries:P,remainingBatches:p().length,skipped:!1}},pendingBatchFiles:p}}var h2e,g2e,y2e,_2e,x2e,VW,v2e,w2e,GW=U(()=>{"use strict";dv();h2e=32*1024*1024,g2e=10080*60*1e3,y2e=4*1024*1024,_2e=1024*1024,x2e="spool.jsonl",VW=/^batch-(\d{1,16})-[0-9a-f-]+\.jsonl$/;v2e=/\b([A-Z][A-Z0-9_]{1,})=("[^"\n]*"|'[^'\n]*'|[^\s"'`;,)\]}]+)/g,w2e=/(?:\/(?:[A-Za-z0-9._@~+-]|%[0-9A-Fa-f]{2})+){2,}/g});var ir,zA,id=U(()=>{"use strict";ir="1.0.225",zA=`linzumi ${ir}`});import{closeSync as ZW,existsSync as BA,mkdirSync as P2e,openSync as QW,readFileSync as XW,renameSync as I2e,unlinkSync as Nu,writeFileSync as R2e,writeSync as YW}from"node:fs";import{dirname as eG,join as E2e}from"node:path";function JA(e){return e instanceof ua||e instanceof Error&&e.name===tG&&"lockPath"in e&&"heldBy"in e}function KA(e,n=pt(),t){let r=t===void 0?encodeURIComponent(e):Au(t);return E2e(eG(n),"runners",`${r}.lock`)}function Cw(e){let n=KA(e.machineId,e.configPath,e.linzumiUrl),t=e.isPidAlive??uG,r=e.now??(()=>new Date),o=e.killPid??B2e,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:tt(e.linzumiUrl)},...e.launchSource===void 0?{}:{launchSource:e.launchSource},startedAt:i,heartbeatAt:i,cliVersion:e.cliVersion??ir,...e.gracefulUpdateDrain===!0?{gracefulUpdateDrain:!0}:{}};O2e(e.machineId,e.configPath,e.linzumiUrl,t,r,o,e.onTakeover),$2e(n,s,t,r,o,e.onTakeover,e.beforeReadExistingLock,e.beforeReplaceStaleLock);let a=()=>rG(n,s,r),d=setInterval(a,nG);return d.unref(),{path:n,record:s,heartbeat:a,release:()=>{clearInterval(d),aG(n,s)}}}function rG(e,n,t){try{let r=Pw(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`;R2e(i,`${JSON.stringify(o,null,2)}
|
|
1560
1560
|
`,"utf8"),I2e(i,e)}catch{}}function zu(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>A2e?{state:"wedged",reason:e.heartbeatAt===void 0?"missing_heartbeat":"stale_heartbeat"}:{state:"live"}}function oG(e,n,t,r){return t!==Tw||e.launchSource!==Tw?!1:r.state!=="live"?!0:M2e(n,e.cliVersion)>0}function M2e(e,n){let t=HW(e),r=HW(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:D2e(t.prerelease,r.prerelease)}function HW(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=[UA(i[0]),UA(i[1]),UA(i[2])],a=o===""?[]:o.split(".").filter(d=>d!=="");return{core:s,prerelease:a}}function UA(e){let n=Number.parseInt(e??"",10);return Number.isInteger(n)&&n>=0?n:0}function D2e(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 iG(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 O2e(e,n,t,r,o,i,s){if(t===void 0||zr(t)!==zr(hr))return;let a=KA(e,n),d=Pw(a);if(d!==void 0){if(zu(d,r,o).state==="live")throw new ua(a,d);sG(a,r,()=>{let u=BA(a)?VA(a):void 0;if(u===void 0)return;let c=zu(u,r,o);if(c.state==="live")throw new ua(a,u);c.state==="wedged"&&iG(a,u,c.reason,i,s),Nu(a)})}}function $2e(e,n,t,r,o,i,s,a){if(kw(e,n))return;s?.();let d=Pw(e);if(d===void 0){if(kw(e,n))return;throw new Error(`another Linzumi runner lock appeared while starting: ${e}`)}if(zu(d,t,r).state==="live")throw new ua(e,d);a?.(),sG(e,t,()=>{let u=BA(e)?VA(e):void 0;if(u!==void 0){let c=zu(u,t,r);if(c.state==="live")throw new ua(e,u);c.state==="wedged"&&iG(e,u,c.reason,o,i),Nu(e)}if(!kw(e,n))throw new Error(`another Linzumi runner lock appeared while starting: ${e}`)})}function kw(e,n){P2e(eG(e),{recursive:!0});try{let t=QW(e,"wx");try{YW(t,`${JSON.stringify(n,null,2)}
|
|
1561
1561
|
`)}finally{ZW(t)}return!0}catch(t){if(Ep(t,"EEXIST"))return!1;throw t}}function sG(e,n,t){let r=`${e}.replace`;for(;;)try{let o=QW(r,"wx");try{YW(o,`${process.pid}
|
|
1562
1562
|
`),t()}finally{ZW(o),Nu(r)}return}catch(o){if(Ep(o,"EEXIST")){let i=q2e(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