quantex-cli 1.8.2 → 1.8.7

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.
Files changed (41) hide show
  1. package/dist/{agent-installation-DGeDTMgF.mjs → agent-installation-D6uummdo.mjs} +1 -1
  2. package/dist/{agents-Btib2SO_.mjs → agents-BbEquU_b.mjs} +1 -1
  3. package/dist/{agents-DoqAiugw.mjs → agents-P24fAIzH.mjs} +1 -1
  4. package/dist/{capabilities-R_JO88hZ.mjs → capabilities-CHiNTxEi.mjs} +1 -1
  5. package/dist/capabilities-CYcD4_NY.mjs +1 -0
  6. package/dist/cli.mjs +1 -1
  7. package/dist/commands-Cz5tn9Ps.mjs +1 -0
  8. package/dist/{commands-DsPlMpTu.mjs → commands-miMrtQY3.mjs} +1 -1
  9. package/dist/{config-Bhb5bpwB.mjs → config-Cr2Pslwm.mjs} +1 -1
  10. package/dist/{core-installation-cli-kov7gRPL.mjs → core-installation-cli-CQu4TuJ2.mjs} +1 -1
  11. package/dist/{core-read-observations-dwe6-Jqu.mjs → core-read-observations-_7tVGtZS.mjs} +1 -1
  12. package/dist/{doctor-Bo1hvKrH.mjs → doctor-DvHiTaP5.mjs} +1 -1
  13. package/dist/{ensure-DggVCnjj.mjs → ensure-B6WiVBYl.mjs} +1 -1
  14. package/dist/ensure-Cc4fvLyi.mjs +1 -0
  15. package/dist/index.mjs +1 -1
  16. package/dist/{info-DD3eHuri.mjs → info-BZD-572u.mjs} +1 -1
  17. package/dist/{inspect-CAO2CIto.mjs → inspect-Bk3sdxCM.mjs} +1 -1
  18. package/dist/inspect-WlDhk37x.mjs +1 -0
  19. package/dist/{install-DXJ7LYRx.mjs → install-uZ456ZFv.mjs} +1 -1
  20. package/dist/{lifecycle-observations-C-5fSuCT.mjs → lifecycle-observations-fWuwyopY.mjs} +1 -1
  21. package/dist/{lifecycle-policy-CqtKQ7HZ.mjs → lifecycle-policy-Cdmy_5EZ.mjs} +1 -1
  22. package/dist/{list-DIpFEmST.mjs → list-CNpRL3Zh.mjs} +1 -1
  23. package/dist/{output-7rFW9QE9.mjs → output-DQY0YUII.mjs} +1 -1
  24. package/dist/{provider-evidence-C7sM0RM3.mjs → provider-evidence-B7Yr8c7e.mjs} +1 -1
  25. package/dist/{provider-observations-CZEYLzDb.mjs → provider-observations-CCzejHFi.mjs} +1 -1
  26. package/dist/{providers-D5426cNP.mjs → providers-DHIXHYu1.mjs} +1 -1
  27. package/dist/{resolve-0wKoLOKT.mjs → resolve-Bzj-pCBt.mjs} +1 -1
  28. package/dist/resolve-CXWYjQDQ.mjs +1 -0
  29. package/dist/schema-BHyrmkaz.mjs +1 -0
  30. package/dist/{schema-CGLYU_o3.mjs → schema-y8PVCGf9.mjs} +1 -1
  31. package/dist/{uninstall-DDGasTWZ.mjs → uninstall-D7vzzJq4.mjs} +1 -1
  32. package/dist/{unmanaged-install-compatibility-W7xIDFeL.mjs → unmanaged-install-compatibility-DlGzVFy_.mjs} +1 -1
  33. package/dist/{update-BzpKRVzd.mjs → update-1hQo16hh.mjs} +1 -1
  34. package/dist/{upgrade-Cfb83i7Y.mjs → upgrade-C4X1kx0j.mjs} +1 -1
  35. package/package.json +25 -25
  36. package/dist/capabilities-Dix1AuHZ.mjs +0 -1
  37. package/dist/commands-Cg7wgIq5.mjs +0 -1
  38. package/dist/ensure-BrhNlVHZ.mjs +0 -1
  39. package/dist/inspect-CxCbv3bU.mjs +0 -1
  40. package/dist/resolve-Cc5EchW7.mjs +0 -1
  41. package/dist/schema-CZPkozin.mjs +0 -1
@@ -1,6 +1,6 @@
1
1
  import{i as e,n as t,o as n,r,t as i}from"./child-process-CBKnpMWt.mjs";import{d as a,l as o,n as s}from"./npm-fDgYmVes.mjs";import{n as c,r as l,t as u}from"./registry-N9jeGQcX.mjs";import{s as d,t as f}from"./schema-hCKyxJjR.mjs";import{n as p,r as m}from"./cli-context-xudTdmO7.mjs";import{a as h,d as g,n as ee,r as _,s as v,t as te}from"./file-store-Caz7fnAB.mjs";import{existsSync as ne}from"node:fs";import{basename as re,dirname as y,join as b,win32 as x}from"node:path";import S from"node:process";import{chmod as ie,mkdir as ae,mkdtemp as oe,readFile as C,realpath as se,rename as w,rm as T,stat as ce,writeFile as le}from"node:fs/promises";import{homedir as ue}from"node:os";import{createHash as de}from"node:crypto";import{fileURLToPath as fe}from"node:url";import{gunzipSync as pe}from"node:zlib";import{Buffer as E}from"node:buffer";var me=class extends Error{timeoutMs;constructor(e){super(`Network attempt timed out after ${e}ms.`),this.name=`NetworkAttemptTimeoutError`,this.timeoutMs=e}};async function he(e,t,n={}){let r=await ge(e,t,`json`,n);if(r)try{return JSON.parse(r)}catch{return}}async function ge(e,t,n=`text`,r={}){let i=r.context?.signal??r.signal;D(i);let a=await g();D(i);let o=a.versionCacheTtlHours*60*60*1e3,s=r.cacheMode??p().cacheMode,c=s===`no-cache`?{entries:{}}:await Se();D(i);let l=c.entries[t],u=Date.now();if(s===`default`&&l&&l.expiresAt>u)return D(i),k(l,o),l.body;let d=await _e(e,{context:r.context,headers:s!==`no-cache`&&l?.etag?{"If-None-Match":l.etag}:void 0,mode:n,networkPort:r.networkPort,retries:a.networkRetries,signal:i,timeoutMs:a.networkTimeoutMs});if(D(i),!d)return l&&(D(i),k(l,o)),l?.body;if(d.status===304&&l)return D(i),c.entries[t]={...l,expiresAt:u+o,fetchedAt:u},s!==`no-cache`&&(D(i),await Ce(c)),D(i),Te(u,u+o),l.body;if(!d.ok||!d.valid||d.body===void 0)return l&&(D(i),k(l,o)),l?.body;D(i);let f={body:d.body,etag:d.etag,expiresAt:u+o,fetchedAt:u};return s!==`no-cache`&&(c.entries[t]=f,D(i),await Ce(c)),D(i),Te(u,u+o),d.body}async function _e(e,t){let n=t.context?.timeoutMs===void 0?void 0:Date.now()+t.context.timeoutMs;for(let r=0;r<=t.retries;r++)try{return await ve(e,{...t,invocationDeadline:n})}catch(e){if(e instanceof i)throw e;if(r===t.retries)return}}async function ve(e,t){let n=t.networkPort;if(n)return ye(e,{...t,networkPort:n});let r=new AbortController,a,o,s,c,l,u=new Promise((e,t)=>c=t),d=()=>l??=xe(Promise.resolve().then(async()=>{a?await a.cancel(s):o?.body&&!o.body.locked&&await o.body.cancel(s)}).then(()=>void 0).catch(()=>void 0),250),f=e=>{let n=e===`cancelled`?O(t.signal):e===`invocation-timeout`?new i({kind:`timed-out`,timeoutMs:t.context?.timeoutMs??0}):new me(t.timeoutMs),a=s===void 0;return(a||s instanceof me&&n instanceof i)&&(s=n),a&&(r.abort(s),d().finally(()=>c(s))),d()},p=()=>void f(`cancelled`);t.signal?.addEventListener(`abort`,p,{once:!0});let m=t.context?.registerCleanup?.({cleanup:()=>f(`cancelled`),force:d}),h=Date.now()+t.timeoutMs,g=setTimeout(()=>void f(`network-timeout`),t.timeoutMs),ee=t.invocationDeadline===void 0?void 0:setTimeout(()=>void f(`invocation-timeout`),Math.max(0,t.invocationDeadline-Date.now())),_=async()=>{if(s||(t.signal?.aborted?await f(`cancelled`):t.invocationDeadline!==void 0&&Date.now()>=t.invocationDeadline?await f(`invocation-timeout`):Date.now()>=h&&await f(`network-timeout`),s))throw s};try{t.signal?.aborted&&await f(`cancelled`);let n=(async()=>{o=await fetch(e,{headers:t.headers,signal:r.signal}),await _();let n=o.status,i=o.headers?.get?.(`etag`)??void 0;if(!o.ok)return await d(),{etag:i,ok:!1,status:n,valid:!0};let s=await be(o,e=>a=e);await _();let c=!0;if(t.mode===`json`)try{JSON.parse(s)}catch{c=!1}return await _(),{body:s,etag:i,ok:!0,status:n,valid:c}})();try{return await Promise.race([n,u])}catch(e){throw s?(await d(),s):e}}finally{clearTimeout(g),ee&&clearTimeout(ee),t.signal?.removeEventListener(`abort`,p),m?.()}}async function ye(e,t){if(t.signal?.aborted)throw O(t.signal);let n=Date.now();if(t.invocationDeadline!==void 0&&t.invocationDeadline<=n)throw new i({kind:`timed-out`,timeoutMs:t.context?.timeoutMs??0});let r=t.invocationDeadline===void 0?t.timeoutMs:Math.max(1,Math.min(t.timeoutMs,t.invocationDeadline-n)),a=t.signal??new AbortController().signal,o=await t.networkPort.request({headers:t.headers,signal:a,timeoutMs:r,url:e});if(o.kind===`failure`)throw t.signal?.aborted||o.error.kind===`cancelled`?O(t.signal):o.error.kind===`timed-out`?t.invocationDeadline!==void 0&&Date.now()>=t.invocationDeadline?new i({kind:`timed-out`,timeoutMs:t.context?.timeoutMs??0}):new me(t.timeoutMs):Error(o.error.message);let s=new TextDecoder().decode(o.value.body),c=!0;if(t.mode===`json`&&o.value.status>=200&&o.value.status<300)try{JSON.parse(s)}catch{c=!1}return{body:o.value.status>=200&&o.value.status<300?s:void 0,etag:o.value.headers.etag,ok:o.value.status>=200&&o.value.status<300,status:o.value.status,valid:c}}async function be(e,t){if(!e.body)return``;let n=e.body.getReader();t(n);let r=new TextDecoder,i=``;for(;;){let e=await n.read();if(e.done)break;i+=r.decode(e.value,{stream:!0})}return i+r.decode()}async function xe(e,t){let n;try{await Promise.race([e,new Promise(e=>{n=setTimeout(e,t)})])}finally{n&&clearTimeout(n)}}function D(e){if(e?.aborted)throw O(e)}function O(e){return e?.reason instanceof i?e.reason:new i({kind:`cancelled`,reason:typeof e?.reason==`string`?e.reason:e?.reason instanceof Error?e.reason.message:e?.reason===void 0?void 0:String(e.reason)})}async function Se(){try{return JSON.parse(await C(we(),`utf8`))}catch{return{entries:{}}}}async function Ce(e){await ae(b(v(),`cache`),{recursive:!0}),await le(we(),`${JSON.stringify(e,null,2)}\n`,`utf8`)}function we(){return b(v(),`cache`,`versions.json`)}function k(e,t){let n=e.fetchedAt??Math.max(0,e.expiresAt-t);m({fetchedAt:new Date(n).toISOString(),source:`cache`,staleAfter:new Date(e.expiresAt).toISOString()})}function Te(e,t){m({fetchedAt:new Date(e).toISOString(),source:`network`,staleAfter:new Date(t).toISOString()})}const Ee=/v?(\d+\.\d+\.\d+(?:-[a-z0-9.]+)?)/i;function De(e,t){if(t)return t(e);let n=e.trim().split(`
2
2
  `)[0],r=n.match(Ee);return r?r[1]:n||void 0}function Oe(e,t){return d(e,t)===1}async function ke(i,a,o){let s=a?.command??[i,`--version`];try{let t=n(s,{detached:o!==void 0&&S.platform!==`win32`}),{exitCode:i,stdout:c}=o?await e(t,o):await r(t);return i===0?De(c,a?.parser):void 0}catch(e){if(t(e))throw e;return}}async function Ae(e,t=`latest`,n={}){return je(e,t,n)}async function je(e,n=`latest`,r={}){try{let t=l(r.registry)??`https://registry.npmjs.org`,i=await he(c(e,n,t),`npm:${t}:${e}:${n}`,{cacheMode:r.cacheMode,context:r.context,networkPort:r.networkPort});if(r.context?.signal.aborted)throw A(r.context.signal);return i?.version}catch(e){if(t(e))throw e;if(r.context?.signal.aborted)throw A(r.context.signal);return}}async function Me(i,a){try{let t=n([S.platform===`win32`?`where`:`which`,i],{detached:a!==void 0&&S.platform!==`win32`}),{exitCode:o,stdout:s}=a?await e(t,a):await r(t);return o===0?s.trim().split(`
3
- `)[0]:void 0}catch(e){if(t(e))throw e;return}}async function Ne(e,t){if(e){if(t?.signal.aborted)throw A(t.signal);try{let n=await se(e);if(t?.signal.aborted)throw A(t.signal);return n}catch{if(t?.signal.aborted)throw A(t.signal);return e}}}function A(e){return new i({kind:`cancelled`,reason:typeof e.reason==`string`?e.reason:void 0})}const j={additionalProperties:!1,properties:{action:{type:`string`},data:{type:`object`},error:{additionalProperties:!1,properties:{code:{type:`string`},message:{type:`string`}},required:[`code`,`message`],type:`object`},exitCode:{type:`integer`},meta:{additionalProperties:!1,properties:{mode:{type:`string`},runId:{type:`string`},schemaVersion:{type:`string`},source:{type:`string`},fetchedAt:{type:`string`},staleAfter:{type:`string`},timestamp:{type:`string`},version:{type:`string`}},required:[`mode`,`runId`,`schemaVersion`,`timestamp`,`version`],type:`object`},ok:{type:`boolean`},target:{additionalProperties:!1,properties:{kind:{type:`string`},name:{type:`string`}},required:[`kind`],type:`object`},warnings:{items:{additionalProperties:!1,properties:{code:{type:`string`},message:{type:`string`}},required:[`code`,`message`],type:`object`},type:`array`}},required:[`action`,`error`,`meta`,`ok`,`warnings`],type:`object`},M={additionalProperties:!1,properties:{action:{type:`string`},data:{type:`object`},meta:{additionalProperties:!1,properties:{mode:{type:`string`},runId:{type:`string`},schemaVersion:{type:`string`},source:{type:`string`},fetchedAt:{type:`string`},staleAfter:{type:`string`},timestamp:{type:`string`},version:{type:`string`}},required:[`mode`,`runId`,`schemaVersion`,`timestamp`,`version`],type:`object`},target:{additionalProperties:!1,properties:{kind:{type:`string`},name:{type:`string`}},required:[`kind`],type:`object`},type:{type:`string`}},required:[`action`,`meta`,`type`],type:`object`},N={additionalProperties:!1,properties:{available:{type:`boolean`},reason:{type:`string`}},required:[`available`],type:`object`},Pe={brew:N,bun:N,cargo:N,deno:N,mise:N,npm:N,pip:N,uv:N,winget:N},Fe=[`brew`,`bun`,`cargo`,`deno`,`mise`,`npm`,`pip`,`uv`,`winget`],Ie=[{dataSchema:{additionalProperties:!1,properties:{agents:{items:{type:`string`},type:`array`},features:{additionalProperties:!1,properties:{assumeYes:{type:`boolean`},cacheBypass:{type:`boolean`},cacheRefresh:{type:`boolean`},channels:{items:{type:`string`},type:`array`},colorModes:{items:{type:`string`},type:`array`},dryRun:{type:`boolean`},execInstallPolicies:{items:{type:`string`},type:`array`},freshnessMetadata:{type:`boolean`},idempotencyKey:{type:`boolean`},logLevels:{items:{type:`string`},type:`array`},quietLogs:{type:`boolean`},selfUpgrade:{type:`boolean`},timeout:{type:`boolean`}},required:[`assumeYes`,`cacheBypass`,`cacheRefresh`,`channels`,`colorModes`,`dryRun`,`execInstallPolicies`,`freshnessMetadata`,`idempotencyKey`,`logLevels`,`quietLogs`,`selfUpgrade`,`timeout`],type:`object`},installers:{additionalProperties:!1,properties:Pe,required:Fe,type:`object`},outputModes:{items:{type:`string`},type:`array`},platform:{additionalProperties:!1,properties:{arch:{type:`string`},os:{type:`string`}},required:[`arch`,`os`],type:`object`}},required:[`agents`,`features`,`installers`,`outputModes`,`platform`],type:`object`},description:`Environment and surface capabilities`,envelopeSchema:j,name:`capabilities`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{commands:{items:{additionalProperties:!1,properties:{flags:{items:{type:`string`},type:`array`},name:{type:`string`},outputSchemaRef:{type:`string`},stability:{type:`string`},summary:{type:`string`}},required:[`flags`,`name`,`outputSchemaRef`,`stability`,`summary`],type:`object`},type:`array`}},required:[`commands`],type:`object`},description:`Stable command catalog`,envelopeSchema:j,name:`commands`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{action:{type:`string`},config:{type:`object`},key:{type:`string`},value:{type:[`number`,`string`]}},required:[`action`],type:`object`},description:`Configuration read or mutation result`,envelopeSchema:j,name:`config`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agents:{items:{additionalProperties:!1,properties:{displayName:{type:`string`},installedVersion:{type:`string`},latestVersion:{type:`string`},lifecycle:{type:`string`},outdated:{type:`boolean`},sourceLabel:{type:`string`}},required:[`displayName`,`lifecycle`,`outdated`,`sourceLabel`],type:`object`},type:`array`},installers:{additionalProperties:!1,properties:{brew:{type:`boolean`},bun:{type:`boolean`},cargo:{type:`boolean`},deno:{type:`boolean`},mise:{type:`boolean`},npm:{type:`boolean`},pip:{type:`boolean`},uv:{type:`boolean`},winget:{type:`boolean`}},required:Fe,type:`object`},issues:{items:{additionalProperties:!1,properties:{blocking:{type:`boolean`},category:{type:`string`},code:{type:`string`},docsRef:{type:`string`},message:{type:`string`},severity:{type:`string`},subject:{additionalProperties:!1,properties:{kind:{type:`string`},name:{type:`string`}},required:[`kind`],type:`object`},suggestedAction:{type:`string`},suggestedCommands:{items:{type:`string`},type:`array`}},required:[`blocking`,`category`,`code`,`message`,`severity`,`subject`,`suggestedAction`,`suggestedCommands`],type:`object`},type:`array`},self:{additionalProperties:!1,properties:{canAutoUpdate:{type:`boolean`},currentVersion:{type:`string`},installSource:{type:`string`},latestVersion:{type:`string`},outdated:{type:`boolean`},recoveryHint:{type:`string`}},required:[`canAutoUpdate`,`currentVersion`,`installSource`,`outdated`],type:`object`}},required:[`agents`,`installers`,`issues`,`self`],type:`object`},description:`Diagnostic state and remediation guidance for the current environment`,envelopeSchema:j,name:`doctor`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agent:{additionalProperties:!1,properties:{binaryName:{type:`string`},displayName:{type:`string`},name:{type:`string`}},required:[`name`],type:`object`},execution:{additionalProperties:!1,properties:{args:{items:{type:`string`},type:`array`},installGuidance:{additionalProperties:!1,properties:{docsRef:{type:`string`},installMethods:{items:{additionalProperties:!1,properties:{command:{type:`string`},label:{type:`string`},type:{type:`string`}},required:[`command`,`label`,`type`],type:`object`},type:`array`},suggestedAction:{type:`string`},suggestedEnsureCommand:{type:`string`},suggestedExecCommand:{type:`string`}},required:[`docsRef`,`installMethods`,`suggestedAction`,`suggestedEnsureCommand`,`suggestedExecCommand`],type:`object`},installPolicy:{type:`string`},installed:{type:`boolean`},interactive:{type:`boolean`},launched:{type:`boolean`}},required:[`args`,`installPolicy`,`installed`,`interactive`,`launched`],type:`object`}},required:[`agent`,`execution`],type:`object`},description:`Preflight contract for managed agent execution`,envelopeSchema:j,name:`exec`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agent:{type:`object`},changed:{type:`boolean`},installState:{type:`object`},installed:{type:`boolean`}},required:[`agent`,`changed`,`installed`],type:`object`},description:`Ensure result for an agent`,envelopeSchema:j,name:`ensure`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agent:{additionalProperties:!1,properties:{aliases:{items:{type:`string`},type:`array`},binaryName:{type:`string`},displayName:{type:`string`},installMethods:{items:{additionalProperties:!1,properties:{command:{type:`string`},label:{type:`string`},type:{type:`string`}},required:[`command`,`label`,`type`],type:`object`},type:`array`},name:{type:`string`},packageName:{type:`string`},selfUpdateCommands:{items:{type:`string`},type:`array`}},required:[`aliases`,`binaryName`,`displayName`,`installMethods`,`name`,`selfUpdateCommands`],type:`object`},inspection:{additionalProperties:!1,properties:{binaryPath:{type:`string`},installed:{type:`boolean`},installedVersion:{type:`string`},latestVersion:{type:`string`},lifecycle:{type:`string`},sourceLabel:{type:`string`}},required:[`installed`,`lifecycle`],type:`object`}},required:[`agent`,`inspection`],type:`object`},description:`Human-friendly details for an agent`,envelopeSchema:j,name:`info`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agent:{type:`object`},capabilities:{type:`object`},inspection:{type:`object`}},required:[`agent`,`capabilities`,`inspection`],type:`object`},description:`Structured inspection result for an agent`,envelopeSchema:j,name:`inspect`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agent:{type:`object`},changed:{type:`boolean`},installState:{type:`object`},installed:{type:`boolean`},results:{items:{additionalProperties:!1,properties:{agent:{type:`object`},changed:{type:`boolean`},error:{type:`object`},input:{type:`string`},installState:{type:`object`},installed:{type:`boolean`},ok:{type:`boolean`},status:{type:`string`},warnings:{items:{type:`object`},type:`array`}},required:[`agent`,`changed`,`input`,`installed`,`ok`,`status`,`warnings`],type:`object`},type:`array`},scope:{type:`string`},summary:{type:`object`}},type:`object`},description:`Install result for one or more agents`,envelopeSchema:j,name:`install`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agents:{items:{additionalProperties:!1,properties:{binaryName:{type:`string`},displayName:{type:`string`},installed:{type:`boolean`},installedVersion:{type:`string`},latestVersion:{type:`string`},lifecycle:{type:`string`},name:{type:`string`},sourceLabel:{type:`string`},updateLabel:{type:`string`}},required:[`binaryName`,`displayName`,`installed`,`lifecycle`,`name`,`sourceLabel`,`updateLabel`],type:`object`},type:`array`}},required:[`agents`],type:`object`},description:`Supported agent catalog`,envelopeSchema:j,name:`list`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agent:{type:`object`},resolution:{additionalProperties:!1,properties:{binaryPath:{type:`string`},installGuidance:{additionalProperties:!1,properties:{docsRef:{type:`string`},installMethods:{items:{additionalProperties:!1,properties:{command:{type:`string`},label:{type:`string`},type:{type:`string`}},required:[`command`,`label`,`type`],type:`object`},type:`array`},suggestedAction:{type:`string`},suggestedEnsureCommand:{type:`string`}},required:[`docsRef`,`installMethods`,`suggestedAction`,`suggestedEnsureCommand`],type:`object`},installed:{type:`boolean`},installSource:{type:`string`},installedVersion:{type:`string`},lifecycle:{type:`string`},sourceLabel:{type:`string`},suggestedLaunchCommand:{items:{type:`string`},type:`array`}},required:[`binaryPath`,`installed`,`installSource`,`lifecycle`,`sourceLabel`,`suggestedLaunchCommand`],type:`object`}},required:[`agent`,`resolution`],type:`object`},description:`Resolved executable entrypoint for an agent`,envelopeSchema:j,name:`resolve`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{commands:{items:{additionalProperties:!1,properties:{dataSchema:{type:`object`},description:{type:`string`},envelopeSchema:{type:`object`},name:{type:`string`},ndjsonEventSchema:{type:`object`}},required:[`dataSchema`,`description`,`envelopeSchema`,`name`],type:`object`},type:`array`}},required:[`commands`],type:`object`},description:`Structured schema catalog`,envelopeSchema:j,name:`schema`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{results:{items:{additionalProperties:!1,properties:{displayName:{type:`string`},hint:{type:`string`},installedVersion:{type:`string`},latestVersion:{type:`string`},message:{type:`string`},name:{type:`string`},resource:{type:`string`},status:{type:`string`},strategy:{type:`string`}},required:[`displayName`,`name`,`status`],type:`object`},type:`array`},scope:{type:`string`}},required:[`results`,`scope`],type:`object`},description:`Update result for one or all agents`,envelopeSchema:j,name:`update`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agent:{additionalProperties:!1,properties:{displayName:{type:`string`},name:{type:`string`}},required:[`displayName`,`name`],type:`object`},changed:{type:`boolean`}},required:[`agent`,`changed`],type:`object`},description:`Uninstall result for an agent`,envelopeSchema:j,name:`uninstall`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{canAutoUpdate:{type:`boolean`},channel:{type:`string`},currentVersion:{type:`string`},installSource:{type:`string`},latestVersion:{type:`string`},recoveryHint:{type:`string`},status:{type:`string`}},required:[`canAutoUpdate`,`channel`,`currentVersion`,`installSource`,`status`],type:`object`},description:`Quantex self-upgrade status`,envelopeSchema:j,name:`upgrade`,ndjsonEventSchema:M}],P=[{description:`Output structured JSON`,flags:`--json`,id:`json`,value:`boolean`},{description:`Output mode: human, json, or ndjson`,flags:`--output <mode>`,id:`output`,value:`string`},{description:`Disable interactive prompts and confirmations`,flags:`--non-interactive`,id:`nonInteractive`,value:`boolean`},{description:`Automatically accept safe default confirmations`,flags:`--yes`,id:`yes`,value:`boolean`},{description:`Suppress non-essential human logs`,flags:`--quiet`,id:`quiet`,value:`boolean`},{description:`Color mode: auto, always, or never`,flags:`--color <mode>`,id:`color`,value:`string`},{description:`Log level: silent, error, warn, info, or debug`,flags:`--log-level <level>`,id:`logLevel`,value:`string`},{description:`Show what would happen without making changes`,flags:`--dry-run`,id:`dryRun`,value:`boolean`},{description:`Refresh cached version metadata before returning results`,flags:`--refresh`,id:`refresh`,value:`boolean`},{commanderProperty:`cache`,description:`Bypass the local version cache for this command`,flags:`--no-cache`,id:`noCache`,negateCommanderValue:!0,value:`boolean`},{description:`Attach a run id to structured output and logs`,flags:`--run-id <id>`,id:`runId`,value:`string`},{description:`Deduplicate repeated mutating requests by client-supplied key`,flags:`--idempotency-key <key>`,id:`idempotencyKey`,value:`string`},{description:`Abort a command after the given duration, e.g. 500ms, 30s, 5m`,flags:`--timeout <duration>`,id:`timeout`,value:`string`}],Le=new Map(P.map(e=>[e.id,e])),Re=new Map(Ie.map(e=>[e.name,e])),F=[`json`,`output`,`quiet`,`color`,`logLevel`,`refresh`,`noCache`,`timeout`],ze=[`json`,`output`,`yes`,`quiet`,`color`,`logLevel`,`dryRun`,`timeout`,`idempotencyKey`],Be=[I({aliases:[],description:`查看当前环境与 surface 能力`,effects:[`filesystem`,`network`,`process`],globalOptions:[`json`,`output`,`nonInteractive`,`quiet`,`color`,`logLevel`,`refresh`,`noCache`,`timeout`],name:`capabilities`,summary:`Return environment and surface capabilities`}),I({aliases:[],description:`查看命令目录与稳定能力`,effects:[],globalOptions:[`json`,`output`,`quiet`,`color`,`logLevel`,`timeout`],name:`commands`,summary:`Return the stable command catalog`}),I({aliases:[],arguments:[{description:`Action: get, set, reset`,name:`action`,syntax:`[action]`},{description:`Config key`,name:`key`,syntax:`[key]`},{description:`Config value`,name:`value`,syntax:`[value]`}],catalogTokens:[`get`,`set`,`reset`],description:`配置管理`,effects:[`filesystem`,`mutation`],globalOptions:[`json`,`output`,`quiet`,`color`,`logLevel`,`timeout`],name:`config`,summary:`Read and modify Quantex configuration`}),I({aliases:[],description:`检查环境`,effects:[`filesystem`,`network`,`process`],globalOptions:F,name:`doctor`,summary:`Diagnose the current environment and installed tools`}),I({aliases:[],allowUnknownOptions:!0,arguments:[{description:`Agent name or alias`,name:`agent`,syntax:`<agent>`},{description:`Arguments passed through to the agent`,name:`args`,syntax:`[args...]`}],description:`以显式策略启动 agent`,effects:[`filesystem`,`interaction`,`mutation`,`network`,`process`],globalOptions:[`nonInteractive`,`yes`,`quiet`,`color`,`logLevel`,`dryRun`,`output`],name:`exec`,options:[{defaultValue:`never`,description:`Install policy: never, if-missing, always`,flags:`--install <policy>`,id:`install`,value:`string`}],summary:`Run an agent with explicit install policy`}),I({aliases:[],arguments:[{description:`Agent name or alias`,name:`agent`,syntax:`<agent>`}],description:`确保指定 agent 已安装`,effects:[`filesystem`,`interaction`,`mutation`,`network`,`process`],globalOptions:ze,name:`ensure`,summary:`Ensure an agent is installed`}),I({aliases:[],arguments:[{description:`Agent name or alias`,name:`agent`,syntax:`<agent>`}],description:`查看 agent 详细信息`,effects:[`filesystem`,`network`,`process`],globalOptions:F,name:`info`,summary:`Show human-friendly agent details`}),I({aliases:[],arguments:[{description:`Agent name or alias`,name:`agent`,syntax:`<agent>`}],description:`查看 agent 结构化状态`,effects:[`filesystem`,`network`,`process`],globalOptions:F,name:`inspect`,summary:`Return structured agent state`}),I({aliases:[`i`],arguments:[{description:`Agent names or aliases`,name:`agents`,syntax:`<agents...>`}],description:`安装指定 agent`,effects:[`filesystem`,`interaction`,`mutation`,`network`,`process`],globalOptions:ze,name:`install`,summary:`Install one or more agents`}),I({aliases:[`ls`],description:`列出所有支持的 agent`,effects:[`filesystem`,`network`,`process`],globalOptions:F,name:`list`,summary:`List supported agents`}),I({aliases:[],arguments:[{description:`Agent name or alias`,name:`agent`,syntax:`<agent>`}],description:`解析 agent 可执行入口`,effects:[`filesystem`,`network`,`process`],globalOptions:F,name:`resolve`,summary:`Resolve an agent executable entrypoint`}),I({aliases:[],arguments:[{description:`Optional command name`,name:`command`,syntax:`[command]`}],description:`查看结构化输出 schema`,effects:[],globalOptions:[`json`,`output`,`quiet`,`color`,`logLevel`,`timeout`],name:`schema`,summary:`Return structured output schemas`}),I({aliases:[`u`],arguments:[{description:`Agent name or alias`,name:`agent`,syntax:`[agent]`}],description:`更新指定 agent`,effects:[`filesystem`,`mutation`,`network`,`process`],globalOptions:[`json`,`output`,`quiet`,`color`,`logLevel`,`dryRun`,`refresh`,`noCache`,`timeout`,`idempotencyKey`],name:`update`,options:[{description:`Update all installed agents`,flags:`--all`,id:`all`,value:`boolean`}],summary:`Update one or all agents`}),I({aliases:[`rm`],arguments:[{description:`Agent name or alias`,name:`agent`,syntax:`<agent>`}],description:`卸载指定 agent`,effects:[`filesystem`,`mutation`,`process`],globalOptions:[`json`,`output`,`quiet`,`color`,`logLevel`,`dryRun`,`timeout`,`idempotencyKey`],name:`uninstall`,summary:`Uninstall an agent`}),I({aliases:[],description:`升级 Quantex CLI`,effects:[`filesystem`,`mutation`,`network`,`process`],globalOptions:[`json`,`output`,`quiet`,`color`,`logLevel`,`dryRun`,`refresh`,`noCache`,`timeout`,`idempotencyKey`],name:`upgrade`,options:[{description:`Only check whether an update is available`,flags:`--check`,id:`check`,value:`boolean`},{description:`Update channel: stable or beta`,flags:`--channel <channel>`,id:`channel`,value:`string`}],summary:`Upgrade Quantex CLI itself`})];function Ve(){return Be}function He(){return P}function Ue(e){let t={...e};for(let n of P){let r=n.commanderProperty??n.id;r in e&&(t[n.id]=n.negateCommanderValue?e[r]===!1:e[r],r!==n.id&&delete t[r])}return t}function We(e){return{flags:qe(e),name:e.name,outputSchemaRef:`#/commands/${e.schema.name}`,stability:e.stability,summary:e.summary}}function Ge(e,t){let n=new Set,r=new Set;for(let t of e){if(n.has(t.name))throw Error(`Duplicate command name: ${t.name}`);n.add(t.name)}for(let t of e){let e=new Set,i=new Set,a=new Set,o=new Set;for(let e of t.aliases){if(n.has(e))throw Error(`Command alias collides with command name: ${e}`);if(r.has(e))throw Error(`Duplicate command alias: ${e}`);r.add(e)}for(let n of t.effects){if(e.has(n))throw Error(`Duplicate command effect: ${n}`);e.add(n)}for(let[e,n]of t.arguments.entries()){if(i.has(n.name))throw Error(`Duplicate command argument: ${t.name} ${n.name}`);if(i.add(n.name),n.syntax.includes(`...`)&&e!==t.arguments.length-1)throw Error(`Variadic command argument must be last: ${t.name} ${n.name}`)}let s=new Set;for(let e of t.globalOptions){let n=Le.get(e);if(!n)throw Error(`Unknown global option: ${t.name} ${e}`);let r=L(n.flags);if(s.has(r))throw Error(`Duplicate command global option: ${t.name} ${r}`);s.add(r)}for(let e of t.options){let n=L(e.flags);if(a.has(n))throw Error(`Duplicate command option: ${t.name} ${n}`);if(o.has(e.id))throw Error(`Duplicate command option id: ${t.name} ${e.id}`);if(s.has(n))throw Error(`Command option duplicates global option: ${t.name} ${n}`);Je(e,t.name),a.add(n),o.add(e.id)}if((t.globalOptions.includes(`dryRun`)||t.globalOptions.includes(`idempotencyKey`)||t.options.some(e=>e.id===`dryRun`||e.id===`idempotencyKey`))&&!e.has(`mutation`)){let e=t.globalOptions.includes(`dryRun`)?`--dry-run`:`--idempotency-key`;throw Error(`Command effect mismatch: ${t.name} exposes ${e} without mutation`)}let c=qe(t);if(c.length!==t.flags.length||c.some((e,n)=>e!==t.flags[n]))throw Error(`Command discovery option mismatch: ${t.name}`)}for(let t of e){if(!n.has(t.handlerId))throw Error(`Unresolved command handler: ${t.handlerId}`);if(!n.has(t.presenterId))throw Error(`Unresolved command presenter: ${t.presenterId}`)}let i=new Set(t);for(let t of e){if(!i.has(t.schemaName))throw Error(`Missing command schema: ${t.schemaName}`);if(t.schema.name!==t.schemaName)throw Error(`Command schema mismatch: ${t.name} ${t.schema.name}`)}}function I(e){let t=Ke(e.name),n={...e,arguments:e.arguments??[],catalogTokens:e.catalogTokens??[],flags:[],handlerId:e.name,options:e.options??[],presenterId:e.name,schema:t,schemaName:e.name,stability:`stable`};return{...n,flags:qe(n)}}function Ke(e){let t=Re.get(e);if(!t)throw Error(`Missing command schema: ${e}`);return t}function qe(e){return[...e.catalogTokens,...e.options.map(e=>L(e.flags)),...e.globalOptions.map(t=>{let n=Le.get(t);if(!n)throw Error(`Unknown global option: ${e.name} ${t}`);return L(n.flags)})]}function L(e){let t=e.match(/--[a-z][a-z-]*/);if(!t)throw Error(`Command option requires a long flag: ${e}`);return t[0]}function Je(e,t){let n=e.flags.includes(`<`)||e.flags.includes(`[`);if(e.value===`string`!==n)throw Error(`Command option value mismatch: ${t} ${L(e.flags)}`);if(e.value===`boolean`&&typeof e.defaultValue==`string`)throw Error(`Command option default mismatch: ${t} ${L(e.flags)}`)}const Ye=new Map(Ve().map(e=>[e.name,$e(e.presenterId)]));function Xe(e){return Ye.get(e)}function Ze(e,t,n,r,i,a){if(t===`json`){i(e?.serializeJson(n)??JSON.stringify(n,null,2));return}if(t===`ndjson`){a(e?.toResultEvent(n)??et(n));return}e?e.presentHuman(n,r):r(n)}function Qe(e,t,n,r){if(t===`ndjson`)return r(e?.toEvent(n)??n)}function $e(e){return{presenterId:e,presentHuman:(e,t)=>t(e),serializeJson:e=>JSON.stringify(e,null,2),toEvent:e=>e,toResultEvent:et}}function et(e){return{action:e.action,data:e,target:e.target,type:`result`}}const R=`quantex-cli`,z=`https://github.com/Drswith/quantex-cli`,tt=`1.8.2`;function nt(e){return e.replaceAll(`\\`,`/`).toLowerCase()}function B(e=S.execPath){let t=rt(e);return t?`${t}.tar.gz`:void 0}function rt(e=S.execPath){if(re(nt(e)).endsWith(`.exe`))return`quantex-windows-x64.exe`;if(S.platform===`darwin`)return S.arch===`arm64`?`quantex-darwin-arm64`:`quantex-darwin-x64`;if(S.platform===`linux`)return S.arch===`arm64`?`quantex-linux-arm64`:`quantex-linux-x64`}function it(e=S.execPath){let t=B(e);if(t)return`${z}/releases/latest/download/${t}`}function at(e,t,n=S.env){return e||(n.QUANTEX_UPDATE_CHANNEL===`beta`?`beta`:n.QUANTEX_UPDATE_CHANNEL===`stable`?`stable`:t===`beta`?`beta`:`stable`)}async function ot(e,t,n,r){let i=await he(await st(e,t,n,r),`self:manifest:${e}`,{cacheMode:r,context:t,networkPort:n});if(!i)throw Error(`Failed to download release manifest.`);return i}async function st(e,t,n,r){if(e===`stable`)return`${z}/releases/latest/download/manifest.json`;let i=(await ct(e,t,n,r)).assets.find(e=>e.name===`manifest.json`);if(!i?.browser_download_url)throw Error(`No manifest.json asset was found for the ${e} release channel.`);return i.browser_download_url}async function ct(e,t,n,r){let i=ut();if(!i)throw Error(`Failed to resolve the GitHub repository slug for Quantex releases.`);let a=await he(`https://api.github.com/repos/${i}/releases?per_page=20`,`self:github-releases`,{cacheMode:r,context:t,networkPort:n});if(!a)throw Error(`Failed to query GitHub releases.`);let o=a.find(t=>e===`beta`?t.prerelease:!t.prerelease);if(!o)throw Error(`No GitHub release was found for the ${e} channel.`);return o}function lt(e,t=S.execPath){let n=S.platform,r=S.arch===`arm64`?`arm64`:`x64`,i=B(t);return e.assets.find(e=>e.platform===n&&e.arch===r&&(!i||e.name===i))}function ut(){return z.match(/github\.com\/([^/]+\/[^/]+)$/)?.[1]}var V=class extends Error{constructor(e,t){super(e,t),this.name=`StateFileError`}};const dt={installedAgents:{},self:{}};function ft(){return ee(v())}async function H(){return Et()}async function pt(e){let t=await _({resource:`state`,scope:[`state`]});try{await Dt(e)}finally{await t()}}async function mt(e){return(await H()).installedAgents[e]}async function ht(e){try{return await U().getReceipt(e)}catch(e){throw e instanceof V?e:new V(`Failed to read Quantex state file.`,{cause:e})}}async function gt(e){let t=await _({resource:`state`,scope:[`state`]});try{await U().setReceipt(e)}catch(e){throw e instanceof V?e:new V(`Failed to write Quantex state file.`,{cause:e})}finally{await t()}}async function _t(e,t){let n=await _({resource:`state`,scope:[`state`]});try{await U().setAgentLifecycleEvidence(e,t)}catch(e){throw e instanceof V?e:new V(`Failed to write Quantex state file.`,{cause:e})}finally{await n()}}async function vt(e){let t=await _({resource:`state`,scope:[`state`]});try{await U().removeReceipt(e)}catch(e){throw e instanceof V?e:new V(`Failed to write Quantex state file.`,{cause:e})}finally{await t()}}const yt=Object.freeze({read:ht,remove:vt,write:gt});async function bt(e){await W(t=>{t.installedAgents[e.agentName]=e})}async function xt(e){await W(t=>{delete t.installedAgents[e]})}async function St(){return(await H()).self}async function Ct(e){await W(t=>{t.self.installSource=e})}async function wt(){await W(e=>{delete e.self.installSource})}async function Tt(e,t){await W(n=>{n.self.updateNoticeVersion=e,n.self.updateNoticeAt=t})}async function Et(){try{return await U().loadProjection()}catch(e){if(Ot(e))return{...dt};throw e instanceof V?e:e instanceof f?new V(`Failed to read Quantex state file: ${e.message}`,{cause:e}):new V(`Failed to read Quantex state file.`,{cause:e})}}async function Dt(e){try{await U().saveProjection(e)}catch(e){throw e instanceof V?e:new V(`Failed to write Quantex state file.`,{cause:e})}}function U(){return te(v())}function Ot(e){let t=typeof e==`object`&&e&&`code`in e?e.code:void 0;return t===`ENOENT`||t===`ENOTDIR`}async function W(e){let t=await _({resource:`state`,scope:[`state`]});try{let t=await Et();await e(t),await Dt(t)}finally{await t()}}const kt=`self:install-source`,At={clearInstallSource:wt,getSelfState:St,setInstallSource:Ct};function G(e=At){return{async load(t){let n=jt(t.key,t.signal);if(n)return n;try{let t=(await e.getSelfState()).installSource;return Nt(t===void 0?{kind:`missing`}:{kind:`found`,snapshot:{value:t}})}catch(e){return Pt(`Failed to read the persisted self install source.`,e)}},async remove(t){let n=jt(t.key,t.signal);if(n)return n;try{return await e.clearInstallSource(),Nt(void 0)}catch(e){return Pt(`Failed to remove the persisted self install source.`,e)}},async save(t){let n=jt(t.key,t.signal);if(n)return n;if(!Mt(t.value))return K({kind:`invalid-data`,message:`The persisted self install source is invalid.`});try{return await e.setInstallSource(t.value),Nt({})}catch(e){return Pt(`Failed to persist the self install source.`,e)}}}}function jt(e,t){if(t.aborted)return K({kind:`cancelled`,message:`Self install-source persistence was cancelled.`});if(e!==`self:install-source`)return K({kind:`invalid-data`,message:`Unsupported self persistence key "${e}".`})}function Mt(e){return e===`binary`||e===`bun`||e===`npm`||e===`source`||e===`unknown`}function Nt(e){return{kind:`success`,value:e}}function K(e){return{error:e,kind:`failure`}}function Pt(e,t){return K({details:{cause:t},kind:`failed`,message:e})}const Ft=R,It=`/node_modules/${Ft}`;async function Lt(e){return zt(e,!0)}async function Rt(e){return zt(e,!1)}async function zt(e,t){let n=await Kt(),r=S.execPath,i=n.foundPackageJson?Gt(n.packageRoot):Gt(``,r),a=e?.persistence??G(),o=e?.signal??new AbortController().signal,s=await Ut(a,o),c=t?await Ht(s,i,{persistence:a,signal:o}):Bt(s,i),l=await g(),u=at(e?.updateChannel,l.selfUpdateChannel);return{canAutoUpdate:Vt(c),currentVersion:n.version||`1.8.2`,executablePath:r,installSource:c,packageRoot:n.packageRoot,updateChannel:u}}function Bt(e,t){return t===`unknown`?e??t:t}function Vt(e){return e===`binary`||e===`bun`||e===`npm`}async function Ht(e,t,n){if(t!==`unknown`&&e!==t){let e=await(n?.persistence??G()).save({key:kt,signal:n?.signal??new AbortController().signal,value:t});return e.kind===`failure`&&Wt(e.error),t}return Bt(e,t)}async function Ut(e,t){let n=await e.load({key:kt,signal:t});if(n.kind===`failure`&&Wt(n.error),n.value.kind===`missing`)return;let r=n.value.snapshot.value;if(r===`binary`||r===`bun`||r===`npm`||r===`source`||r===`unknown`)return r;throw Error(`The persisted self install source is invalid.`)}function Wt(e){let t=e.details?.cause;throw t instanceof Error?t:e.kind===`cancelled`?new i({kind:`cancelled`,reason:e.message}):e.kind===`timed-out`?new i({kind:`timed-out`,timeoutMs:0}):Error(e.message)}function Gt(e,t=S.execPath){let n=Yt(e);return n.includes(`/.bun/install/global/`)?`bun`:n.includes(It)?`npm`:n?`source`:Xt(t)?`binary`:`unknown`}async function Kt(e=import.meta.url){let t=Zt(e),n=y(t);for(;;){let e=b(n,`package.json`),t=await Jt(e);if(t?.name===Ft)return{foundPackageJson:!0,packageJsonPath:e,packageRoot:n,version:t.version??`1.8.2`};let r=y(n);if(r===n)break;n=r}return{foundPackageJson:!1,packageJsonPath:b(y(t),`package.json`),packageRoot:y(t),version:tt}}function qt(){return tt}async function Jt(e){try{return JSON.parse(await C(e,`utf8`))}catch{return}}function Yt(e){return e.replaceAll(`\\`,`/`).toLowerCase()}function Xt(e){let t=re(Yt(e));return t!==`bun`&&t!==`bun.exe`}function Zt(e){try{return fe(e)}catch{return S.execPath}}async function Qt(){try{return await _({resource:`self upgrade`,scope:[`self-upgrade`]})}catch(e){if(h(e))return;throw e}}function $t(){return{async acquire(e){if(e.signal.aborted)return q(`cancelled`,`Self-upgrade lock acquisition was cancelled.`);if(e.scope.length!==1||e.scope[0]!==`self-upgrade`)return q(`unavailable`,`Unsupported self-upgrade lock scope: ${e.scope.join(`/`)}`);let t=await Qt();if(!t)return q(`conflict`,`Another qtx upgrade is already running.`);if(e.signal.aborted)return await t(),q(`cancelled`,`Self-upgrade lock acquisition was cancelled.`);let n=!1;return{kind:`success`,value:{async release(){if(n)return{kind:`success`,value:void 0};n=!0;try{return await t(),{kind:`success`,value:void 0}}catch(e){return q(`failed`,e instanceof Error?e.message:`Failed to release self-upgrade lock.`)}}}}}}}function q(e,t){return{error:{kind:e,message:t},kind:`failure`}}async function en(e,t,n=S.env,r=S.cwd()){if(e!==`bun`&&e!==`npm`)return;let i=l(n.QTX_SELF_UPDATE_REGISTRY);return i?{isOverride:!0,registry:i,source:`quantex-env`}:t.selfUpdateRegistry?{isOverride:!0,registry:t.selfUpdateRegistry,source:`quantex-config`}:await tn(e,n,r)||{isOverride:!1,registry:u,source:`fallback`}}async function tn(e,t,n){if(e===`bun`){let e=nn(t,[`BUN_CONFIG_REGISTRY`,`NPM_CONFIG_REGISTRY`,`npm_config_registry`]);if(e)return{isOverride:!1,registry:e,source:`bun-env`};let r=await rn(n,t);if(r)return{isOverride:!1,registry:r,source:`bunfig`}}let r=nn(t,[`NPM_CONFIG_REGISTRY`,`npm_config_registry`]);if(r)return{isOverride:!1,registry:r,source:`npm-env`};let i=await on(n,t);if(i)return{isOverride:!1,registry:i,source:`npmrc`}}function nn(e,t){for(let n of t){let t=l(e[n]);if(t)return t}}async function rn(e,t){let n=ln(t),r=t.XDG_CONFIG_HOME,i=cn(e,`bunfig.toml`),a=[b(n,`.bunfig.toml`),r?b(r,`.bunfig.toml`):void 0];if(i){let e=await an(i);if(e)return e}for(let e of a){if(!e||!ne(e))continue;let t=await an(e);if(t)return t}}async function an(e){try{return un(await C(e,`utf8`))}catch{return}}async function on(e,t){let n=ln(t),r=cn(e,`.npmrc`),i=b(n,`.npmrc`);if(r){let e=await sn(r);if(e)return e}if(ne(i))return sn(i)}async function sn(e){try{let t=(await C(e,`utf8`)).split(`
3
+ `)[0]:void 0}catch(e){if(t(e))throw e;return}}async function Ne(e,t){if(e){if(t?.signal.aborted)throw A(t.signal);try{let n=await se(e);if(t?.signal.aborted)throw A(t.signal);return n}catch{if(t?.signal.aborted)throw A(t.signal);return e}}}function A(e){return new i({kind:`cancelled`,reason:typeof e.reason==`string`?e.reason:void 0})}const j={additionalProperties:!1,properties:{action:{type:`string`},data:{type:`object`},error:{additionalProperties:!1,properties:{code:{type:`string`},message:{type:`string`}},required:[`code`,`message`],type:`object`},exitCode:{type:`integer`},meta:{additionalProperties:!1,properties:{mode:{type:`string`},runId:{type:`string`},schemaVersion:{type:`string`},source:{type:`string`},fetchedAt:{type:`string`},staleAfter:{type:`string`},timestamp:{type:`string`},version:{type:`string`}},required:[`mode`,`runId`,`schemaVersion`,`timestamp`,`version`],type:`object`},ok:{type:`boolean`},target:{additionalProperties:!1,properties:{kind:{type:`string`},name:{type:`string`}},required:[`kind`],type:`object`},warnings:{items:{additionalProperties:!1,properties:{code:{type:`string`},message:{type:`string`}},required:[`code`,`message`],type:`object`},type:`array`}},required:[`action`,`error`,`meta`,`ok`,`warnings`],type:`object`},M={additionalProperties:!1,properties:{action:{type:`string`},data:{type:`object`},meta:{additionalProperties:!1,properties:{mode:{type:`string`},runId:{type:`string`},schemaVersion:{type:`string`},source:{type:`string`},fetchedAt:{type:`string`},staleAfter:{type:`string`},timestamp:{type:`string`},version:{type:`string`}},required:[`mode`,`runId`,`schemaVersion`,`timestamp`,`version`],type:`object`},target:{additionalProperties:!1,properties:{kind:{type:`string`},name:{type:`string`}},required:[`kind`],type:`object`},type:{type:`string`}},required:[`action`,`meta`,`type`],type:`object`},N={additionalProperties:!1,properties:{available:{type:`boolean`},reason:{type:`string`}},required:[`available`],type:`object`},Pe={brew:N,bun:N,cargo:N,deno:N,mise:N,npm:N,pip:N,uv:N,winget:N},Fe=[`brew`,`bun`,`cargo`,`deno`,`mise`,`npm`,`pip`,`uv`,`winget`],Ie=[{dataSchema:{additionalProperties:!1,properties:{agents:{items:{type:`string`},type:`array`},features:{additionalProperties:!1,properties:{assumeYes:{type:`boolean`},cacheBypass:{type:`boolean`},cacheRefresh:{type:`boolean`},channels:{items:{type:`string`},type:`array`},colorModes:{items:{type:`string`},type:`array`},dryRun:{type:`boolean`},execInstallPolicies:{items:{type:`string`},type:`array`},freshnessMetadata:{type:`boolean`},idempotencyKey:{type:`boolean`},logLevels:{items:{type:`string`},type:`array`},quietLogs:{type:`boolean`},selfUpgrade:{type:`boolean`},timeout:{type:`boolean`}},required:[`assumeYes`,`cacheBypass`,`cacheRefresh`,`channels`,`colorModes`,`dryRun`,`execInstallPolicies`,`freshnessMetadata`,`idempotencyKey`,`logLevels`,`quietLogs`,`selfUpgrade`,`timeout`],type:`object`},installers:{additionalProperties:!1,properties:Pe,required:Fe,type:`object`},outputModes:{items:{type:`string`},type:`array`},platform:{additionalProperties:!1,properties:{arch:{type:`string`},os:{type:`string`}},required:[`arch`,`os`],type:`object`}},required:[`agents`,`features`,`installers`,`outputModes`,`platform`],type:`object`},description:`Environment and surface capabilities`,envelopeSchema:j,name:`capabilities`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{commands:{items:{additionalProperties:!1,properties:{flags:{items:{type:`string`},type:`array`},name:{type:`string`},outputSchemaRef:{type:`string`},stability:{type:`string`},summary:{type:`string`}},required:[`flags`,`name`,`outputSchemaRef`,`stability`,`summary`],type:`object`},type:`array`}},required:[`commands`],type:`object`},description:`Stable command catalog`,envelopeSchema:j,name:`commands`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{action:{type:`string`},config:{type:`object`},key:{type:`string`},value:{type:[`number`,`string`]}},required:[`action`],type:`object`},description:`Configuration read or mutation result`,envelopeSchema:j,name:`config`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agents:{items:{additionalProperties:!1,properties:{displayName:{type:`string`},installedVersion:{type:`string`},latestVersion:{type:`string`},lifecycle:{type:`string`},outdated:{type:`boolean`},sourceLabel:{type:`string`}},required:[`displayName`,`lifecycle`,`outdated`,`sourceLabel`],type:`object`},type:`array`},installers:{additionalProperties:!1,properties:{brew:{type:`boolean`},bun:{type:`boolean`},cargo:{type:`boolean`},deno:{type:`boolean`},mise:{type:`boolean`},npm:{type:`boolean`},pip:{type:`boolean`},uv:{type:`boolean`},winget:{type:`boolean`}},required:Fe,type:`object`},issues:{items:{additionalProperties:!1,properties:{blocking:{type:`boolean`},category:{type:`string`},code:{type:`string`},docsRef:{type:`string`},message:{type:`string`},severity:{type:`string`},subject:{additionalProperties:!1,properties:{kind:{type:`string`},name:{type:`string`}},required:[`kind`],type:`object`},suggestedAction:{type:`string`},suggestedCommands:{items:{type:`string`},type:`array`}},required:[`blocking`,`category`,`code`,`message`,`severity`,`subject`,`suggestedAction`,`suggestedCommands`],type:`object`},type:`array`},self:{additionalProperties:!1,properties:{canAutoUpdate:{type:`boolean`},currentVersion:{type:`string`},installSource:{type:`string`},latestVersion:{type:`string`},outdated:{type:`boolean`},recoveryHint:{type:`string`}},required:[`canAutoUpdate`,`currentVersion`,`installSource`,`outdated`],type:`object`}},required:[`agents`,`installers`,`issues`,`self`],type:`object`},description:`Diagnostic state and remediation guidance for the current environment`,envelopeSchema:j,name:`doctor`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agent:{additionalProperties:!1,properties:{binaryName:{type:`string`},displayName:{type:`string`},name:{type:`string`}},required:[`name`],type:`object`},execution:{additionalProperties:!1,properties:{args:{items:{type:`string`},type:`array`},installGuidance:{additionalProperties:!1,properties:{docsRef:{type:`string`},installMethods:{items:{additionalProperties:!1,properties:{command:{type:`string`},label:{type:`string`},type:{type:`string`}},required:[`command`,`label`,`type`],type:`object`},type:`array`},suggestedAction:{type:`string`},suggestedEnsureCommand:{type:`string`},suggestedExecCommand:{type:`string`}},required:[`docsRef`,`installMethods`,`suggestedAction`,`suggestedEnsureCommand`,`suggestedExecCommand`],type:`object`},installPolicy:{type:`string`},installed:{type:`boolean`},interactive:{type:`boolean`},launched:{type:`boolean`}},required:[`args`,`installPolicy`,`installed`,`interactive`,`launched`],type:`object`}},required:[`agent`,`execution`],type:`object`},description:`Preflight contract for managed agent execution`,envelopeSchema:j,name:`exec`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agent:{type:`object`},changed:{type:`boolean`},installState:{type:`object`},installed:{type:`boolean`}},required:[`agent`,`changed`,`installed`],type:`object`},description:`Ensure result for an agent`,envelopeSchema:j,name:`ensure`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agent:{additionalProperties:!1,properties:{aliases:{items:{type:`string`},type:`array`},binaryName:{type:`string`},displayName:{type:`string`},installMethods:{items:{additionalProperties:!1,properties:{command:{type:`string`},label:{type:`string`},type:{type:`string`}},required:[`command`,`label`,`type`],type:`object`},type:`array`},name:{type:`string`},packageName:{type:`string`},selfUpdateCommands:{items:{type:`string`},type:`array`}},required:[`aliases`,`binaryName`,`displayName`,`installMethods`,`name`,`selfUpdateCommands`],type:`object`},inspection:{additionalProperties:!1,properties:{binaryPath:{type:`string`},installed:{type:`boolean`},installedVersion:{type:`string`},latestVersion:{type:`string`},lifecycle:{type:`string`},sourceLabel:{type:`string`}},required:[`installed`,`lifecycle`],type:`object`}},required:[`agent`,`inspection`],type:`object`},description:`Human-friendly details for an agent`,envelopeSchema:j,name:`info`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agent:{type:`object`},capabilities:{type:`object`},inspection:{type:`object`}},required:[`agent`,`capabilities`,`inspection`],type:`object`},description:`Structured inspection result for an agent`,envelopeSchema:j,name:`inspect`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agent:{type:`object`},changed:{type:`boolean`},installState:{type:`object`},installed:{type:`boolean`},results:{items:{additionalProperties:!1,properties:{agent:{type:`object`},changed:{type:`boolean`},error:{type:`object`},input:{type:`string`},installState:{type:`object`},installed:{type:`boolean`},ok:{type:`boolean`},status:{type:`string`},warnings:{items:{type:`object`},type:`array`}},required:[`agent`,`changed`,`input`,`installed`,`ok`,`status`,`warnings`],type:`object`},type:`array`},scope:{type:`string`},summary:{type:`object`}},type:`object`},description:`Install result for one or more agents`,envelopeSchema:j,name:`install`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agents:{items:{additionalProperties:!1,properties:{binaryName:{type:`string`},displayName:{type:`string`},installed:{type:`boolean`},installedVersion:{type:`string`},latestVersion:{type:`string`},lifecycle:{type:`string`},name:{type:`string`},sourceLabel:{type:`string`},updateLabel:{type:`string`}},required:[`binaryName`,`displayName`,`installed`,`lifecycle`,`name`,`sourceLabel`,`updateLabel`],type:`object`},type:`array`}},required:[`agents`],type:`object`},description:`Supported agent catalog`,envelopeSchema:j,name:`list`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agent:{type:`object`},resolution:{additionalProperties:!1,properties:{binaryPath:{type:`string`},installGuidance:{additionalProperties:!1,properties:{docsRef:{type:`string`},installMethods:{items:{additionalProperties:!1,properties:{command:{type:`string`},label:{type:`string`},type:{type:`string`}},required:[`command`,`label`,`type`],type:`object`},type:`array`},suggestedAction:{type:`string`},suggestedEnsureCommand:{type:`string`}},required:[`docsRef`,`installMethods`,`suggestedAction`,`suggestedEnsureCommand`],type:`object`},installed:{type:`boolean`},installSource:{type:`string`},installedVersion:{type:`string`},lifecycle:{type:`string`},sourceLabel:{type:`string`},suggestedLaunchCommand:{items:{type:`string`},type:`array`}},required:[`binaryPath`,`installed`,`installSource`,`lifecycle`,`sourceLabel`,`suggestedLaunchCommand`],type:`object`}},required:[`agent`,`resolution`],type:`object`},description:`Resolved executable entrypoint for an agent`,envelopeSchema:j,name:`resolve`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{commands:{items:{additionalProperties:!1,properties:{dataSchema:{type:`object`},description:{type:`string`},envelopeSchema:{type:`object`},name:{type:`string`},ndjsonEventSchema:{type:`object`}},required:[`dataSchema`,`description`,`envelopeSchema`,`name`],type:`object`},type:`array`}},required:[`commands`],type:`object`},description:`Structured schema catalog`,envelopeSchema:j,name:`schema`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{results:{items:{additionalProperties:!1,properties:{displayName:{type:`string`},hint:{type:`string`},installedVersion:{type:`string`},latestVersion:{type:`string`},message:{type:`string`},name:{type:`string`},resource:{type:`string`},status:{type:`string`},strategy:{type:`string`}},required:[`displayName`,`name`,`status`],type:`object`},type:`array`},scope:{type:`string`}},required:[`results`,`scope`],type:`object`},description:`Update result for one or all agents`,envelopeSchema:j,name:`update`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{agent:{additionalProperties:!1,properties:{displayName:{type:`string`},name:{type:`string`}},required:[`displayName`,`name`],type:`object`},changed:{type:`boolean`}},required:[`agent`,`changed`],type:`object`},description:`Uninstall result for an agent`,envelopeSchema:j,name:`uninstall`,ndjsonEventSchema:M},{dataSchema:{additionalProperties:!1,properties:{canAutoUpdate:{type:`boolean`},channel:{type:`string`},currentVersion:{type:`string`},installSource:{type:`string`},latestVersion:{type:`string`},recoveryHint:{type:`string`},status:{type:`string`}},required:[`canAutoUpdate`,`channel`,`currentVersion`,`installSource`,`status`],type:`object`},description:`Quantex self-upgrade status`,envelopeSchema:j,name:`upgrade`,ndjsonEventSchema:M}],P=[{description:`Output structured JSON`,flags:`--json`,id:`json`,value:`boolean`},{description:`Output mode: human, json, or ndjson`,flags:`--output <mode>`,id:`output`,value:`string`},{description:`Disable interactive prompts and confirmations`,flags:`--non-interactive`,id:`nonInteractive`,value:`boolean`},{description:`Automatically accept safe default confirmations`,flags:`--yes`,id:`yes`,value:`boolean`},{description:`Suppress non-essential human logs`,flags:`--quiet`,id:`quiet`,value:`boolean`},{description:`Color mode: auto, always, or never`,flags:`--color <mode>`,id:`color`,value:`string`},{description:`Log level: silent, error, warn, info, or debug`,flags:`--log-level <level>`,id:`logLevel`,value:`string`},{description:`Show what would happen without making changes`,flags:`--dry-run`,id:`dryRun`,value:`boolean`},{description:`Refresh cached version metadata before returning results`,flags:`--refresh`,id:`refresh`,value:`boolean`},{commanderProperty:`cache`,description:`Bypass the local version cache for this command`,flags:`--no-cache`,id:`noCache`,negateCommanderValue:!0,value:`boolean`},{description:`Attach a run id to structured output and logs`,flags:`--run-id <id>`,id:`runId`,value:`string`},{description:`Deduplicate repeated mutating requests by client-supplied key`,flags:`--idempotency-key <key>`,id:`idempotencyKey`,value:`string`},{description:`Abort a command after the given duration, e.g. 500ms, 30s, 5m`,flags:`--timeout <duration>`,id:`timeout`,value:`string`}],Le=new Map(P.map(e=>[e.id,e])),Re=new Map(Ie.map(e=>[e.name,e])),F=[`json`,`output`,`quiet`,`color`,`logLevel`,`refresh`,`noCache`,`timeout`],ze=[`json`,`output`,`yes`,`quiet`,`color`,`logLevel`,`dryRun`,`timeout`,`idempotencyKey`],Be=[I({aliases:[],description:`查看当前环境与 surface 能力`,effects:[`filesystem`,`network`,`process`],globalOptions:[`json`,`output`,`nonInteractive`,`quiet`,`color`,`logLevel`,`refresh`,`noCache`,`timeout`],name:`capabilities`,summary:`Return environment and surface capabilities`}),I({aliases:[],description:`查看命令目录与稳定能力`,effects:[],globalOptions:[`json`,`output`,`quiet`,`color`,`logLevel`,`timeout`],name:`commands`,summary:`Return the stable command catalog`}),I({aliases:[],arguments:[{description:`Action: get, set, reset`,name:`action`,syntax:`[action]`},{description:`Config key`,name:`key`,syntax:`[key]`},{description:`Config value`,name:`value`,syntax:`[value]`}],catalogTokens:[`get`,`set`,`reset`],description:`配置管理`,effects:[`filesystem`,`mutation`],globalOptions:[`json`,`output`,`quiet`,`color`,`logLevel`,`timeout`],name:`config`,summary:`Read and modify Quantex configuration`}),I({aliases:[],description:`检查环境`,effects:[`filesystem`,`network`,`process`],globalOptions:F,name:`doctor`,summary:`Diagnose the current environment and installed tools`}),I({aliases:[],allowUnknownOptions:!0,arguments:[{description:`Agent name or alias`,name:`agent`,syntax:`<agent>`},{description:`Arguments passed through to the agent`,name:`args`,syntax:`[args...]`}],description:`以显式策略启动 agent`,effects:[`filesystem`,`interaction`,`mutation`,`network`,`process`],globalOptions:[`nonInteractive`,`yes`,`quiet`,`color`,`logLevel`,`dryRun`,`output`],name:`exec`,options:[{defaultValue:`never`,description:`Install policy: never, if-missing, always`,flags:`--install <policy>`,id:`install`,value:`string`}],summary:`Run an agent with explicit install policy`}),I({aliases:[],arguments:[{description:`Agent name or alias`,name:`agent`,syntax:`<agent>`}],description:`确保指定 agent 已安装`,effects:[`filesystem`,`interaction`,`mutation`,`network`,`process`],globalOptions:ze,name:`ensure`,summary:`Ensure an agent is installed`}),I({aliases:[],arguments:[{description:`Agent name or alias`,name:`agent`,syntax:`<agent>`}],description:`查看 agent 详细信息`,effects:[`filesystem`,`network`,`process`],globalOptions:F,name:`info`,summary:`Show human-friendly agent details`}),I({aliases:[],arguments:[{description:`Agent name or alias`,name:`agent`,syntax:`<agent>`}],description:`查看 agent 结构化状态`,effects:[`filesystem`,`network`,`process`],globalOptions:F,name:`inspect`,summary:`Return structured agent state`}),I({aliases:[`i`],arguments:[{description:`Agent names or aliases`,name:`agents`,syntax:`<agents...>`}],description:`安装指定 agent`,effects:[`filesystem`,`interaction`,`mutation`,`network`,`process`],globalOptions:ze,name:`install`,summary:`Install one or more agents`}),I({aliases:[`ls`],description:`列出所有支持的 agent`,effects:[`filesystem`,`network`,`process`],globalOptions:F,name:`list`,summary:`List supported agents`}),I({aliases:[],arguments:[{description:`Agent name or alias`,name:`agent`,syntax:`<agent>`}],description:`解析 agent 可执行入口`,effects:[`filesystem`,`network`,`process`],globalOptions:F,name:`resolve`,summary:`Resolve an agent executable entrypoint`}),I({aliases:[],arguments:[{description:`Optional command name`,name:`command`,syntax:`[command]`}],description:`查看结构化输出 schema`,effects:[],globalOptions:[`json`,`output`,`quiet`,`color`,`logLevel`,`timeout`],name:`schema`,summary:`Return structured output schemas`}),I({aliases:[`u`],arguments:[{description:`Agent name or alias`,name:`agent`,syntax:`[agent]`}],description:`更新指定 agent`,effects:[`filesystem`,`mutation`,`network`,`process`],globalOptions:[`json`,`output`,`quiet`,`color`,`logLevel`,`dryRun`,`refresh`,`noCache`,`timeout`,`idempotencyKey`],name:`update`,options:[{description:`Update all installed agents`,flags:`--all`,id:`all`,value:`boolean`}],summary:`Update one or all agents`}),I({aliases:[`rm`],arguments:[{description:`Agent name or alias`,name:`agent`,syntax:`<agent>`}],description:`卸载指定 agent`,effects:[`filesystem`,`mutation`,`process`],globalOptions:[`json`,`output`,`quiet`,`color`,`logLevel`,`dryRun`,`timeout`,`idempotencyKey`],name:`uninstall`,summary:`Uninstall an agent`}),I({aliases:[],description:`升级 Quantex CLI`,effects:[`filesystem`,`mutation`,`network`,`process`],globalOptions:[`json`,`output`,`quiet`,`color`,`logLevel`,`dryRun`,`refresh`,`noCache`,`timeout`,`idempotencyKey`],name:`upgrade`,options:[{description:`Only check whether an update is available`,flags:`--check`,id:`check`,value:`boolean`},{description:`Update channel: stable or beta`,flags:`--channel <channel>`,id:`channel`,value:`string`}],summary:`Upgrade Quantex CLI itself`})];function Ve(){return Be}function He(){return P}function Ue(e){let t={...e};for(let n of P){let r=n.commanderProperty??n.id;r in e&&(t[n.id]=n.negateCommanderValue?e[r]===!1:e[r],r!==n.id&&delete t[r])}return t}function We(e){return{flags:qe(e),name:e.name,outputSchemaRef:`#/commands/${e.schema.name}`,stability:e.stability,summary:e.summary}}function Ge(e,t){let n=new Set,r=new Set;for(let t of e){if(n.has(t.name))throw Error(`Duplicate command name: ${t.name}`);n.add(t.name)}for(let t of e){let e=new Set,i=new Set,a=new Set,o=new Set;for(let e of t.aliases){if(n.has(e))throw Error(`Command alias collides with command name: ${e}`);if(r.has(e))throw Error(`Duplicate command alias: ${e}`);r.add(e)}for(let n of t.effects){if(e.has(n))throw Error(`Duplicate command effect: ${n}`);e.add(n)}for(let[e,n]of t.arguments.entries()){if(i.has(n.name))throw Error(`Duplicate command argument: ${t.name} ${n.name}`);if(i.add(n.name),n.syntax.includes(`...`)&&e!==t.arguments.length-1)throw Error(`Variadic command argument must be last: ${t.name} ${n.name}`)}let s=new Set;for(let e of t.globalOptions){let n=Le.get(e);if(!n)throw Error(`Unknown global option: ${t.name} ${e}`);let r=L(n.flags);if(s.has(r))throw Error(`Duplicate command global option: ${t.name} ${r}`);s.add(r)}for(let e of t.options){let n=L(e.flags);if(a.has(n))throw Error(`Duplicate command option: ${t.name} ${n}`);if(o.has(e.id))throw Error(`Duplicate command option id: ${t.name} ${e.id}`);if(s.has(n))throw Error(`Command option duplicates global option: ${t.name} ${n}`);Je(e,t.name),a.add(n),o.add(e.id)}if((t.globalOptions.includes(`dryRun`)||t.globalOptions.includes(`idempotencyKey`)||t.options.some(e=>e.id===`dryRun`||e.id===`idempotencyKey`))&&!e.has(`mutation`)){let e=t.globalOptions.includes(`dryRun`)?`--dry-run`:`--idempotency-key`;throw Error(`Command effect mismatch: ${t.name} exposes ${e} without mutation`)}let c=qe(t);if(c.length!==t.flags.length||c.some((e,n)=>e!==t.flags[n]))throw Error(`Command discovery option mismatch: ${t.name}`)}for(let t of e){if(!n.has(t.handlerId))throw Error(`Unresolved command handler: ${t.handlerId}`);if(!n.has(t.presenterId))throw Error(`Unresolved command presenter: ${t.presenterId}`)}let i=new Set(t);for(let t of e){if(!i.has(t.schemaName))throw Error(`Missing command schema: ${t.schemaName}`);if(t.schema.name!==t.schemaName)throw Error(`Command schema mismatch: ${t.name} ${t.schema.name}`)}}function I(e){let t=Ke(e.name),n={...e,arguments:e.arguments??[],catalogTokens:e.catalogTokens??[],flags:[],handlerId:e.name,options:e.options??[],presenterId:e.name,schema:t,schemaName:e.name,stability:`stable`};return{...n,flags:qe(n)}}function Ke(e){let t=Re.get(e);if(!t)throw Error(`Missing command schema: ${e}`);return t}function qe(e){return[...e.catalogTokens,...e.options.map(e=>L(e.flags)),...e.globalOptions.map(t=>{let n=Le.get(t);if(!n)throw Error(`Unknown global option: ${e.name} ${t}`);return L(n.flags)})]}function L(e){let t=e.match(/--[a-z][a-z-]*/);if(!t)throw Error(`Command option requires a long flag: ${e}`);return t[0]}function Je(e,t){let n=e.flags.includes(`<`)||e.flags.includes(`[`);if(e.value===`string`!==n)throw Error(`Command option value mismatch: ${t} ${L(e.flags)}`);if(e.value===`boolean`&&typeof e.defaultValue==`string`)throw Error(`Command option default mismatch: ${t} ${L(e.flags)}`)}const Ye=new Map(Ve().map(e=>[e.name,$e(e.presenterId)]));function Xe(e){return Ye.get(e)}function Ze(e,t,n,r,i,a){if(t===`json`){i(e?.serializeJson(n)??JSON.stringify(n,null,2));return}if(t===`ndjson`){a(e?.toResultEvent(n)??et(n));return}e?e.presentHuman(n,r):r(n)}function Qe(e,t,n,r){if(t===`ndjson`)return r(e?.toEvent(n)??n)}function $e(e){return{presenterId:e,presentHuman:(e,t)=>t(e),serializeJson:e=>JSON.stringify(e,null,2),toEvent:e=>e,toResultEvent:et}}function et(e){return{action:e.action,data:e,target:e.target,type:`result`}}const R=`quantex-cli`,z=`https://github.com/Drswith/quantex-cli`,tt=`1.8.7`;function nt(e){return e.replaceAll(`\\`,`/`).toLowerCase()}function B(e=S.execPath){let t=rt(e);return t?`${t}.tar.gz`:void 0}function rt(e=S.execPath){if(re(nt(e)).endsWith(`.exe`))return`quantex-windows-x64.exe`;if(S.platform===`darwin`)return S.arch===`arm64`?`quantex-darwin-arm64`:`quantex-darwin-x64`;if(S.platform===`linux`)return S.arch===`arm64`?`quantex-linux-arm64`:`quantex-linux-x64`}function it(e=S.execPath){let t=B(e);if(t)return`${z}/releases/latest/download/${t}`}function at(e,t,n=S.env){return e||(n.QUANTEX_UPDATE_CHANNEL===`beta`?`beta`:n.QUANTEX_UPDATE_CHANNEL===`stable`?`stable`:t===`beta`?`beta`:`stable`)}async function ot(e,t,n,r){let i=await he(await st(e,t,n,r),`self:manifest:${e}`,{cacheMode:r,context:t,networkPort:n});if(!i)throw Error(`Failed to download release manifest.`);return i}async function st(e,t,n,r){if(e===`stable`)return`${z}/releases/latest/download/manifest.json`;let i=(await ct(e,t,n,r)).assets.find(e=>e.name===`manifest.json`);if(!i?.browser_download_url)throw Error(`No manifest.json asset was found for the ${e} release channel.`);return i.browser_download_url}async function ct(e,t,n,r){let i=ut();if(!i)throw Error(`Failed to resolve the GitHub repository slug for Quantex releases.`);let a=await he(`https://api.github.com/repos/${i}/releases?per_page=20`,`self:github-releases`,{cacheMode:r,context:t,networkPort:n});if(!a)throw Error(`Failed to query GitHub releases.`);let o=a.find(t=>e===`beta`?t.prerelease:!t.prerelease);if(!o)throw Error(`No GitHub release was found for the ${e} channel.`);return o}function lt(e,t=S.execPath){let n=S.platform,r=S.arch===`arm64`?`arm64`:`x64`,i=B(t);return e.assets.find(e=>e.platform===n&&e.arch===r&&(!i||e.name===i))}function ut(){return z.match(/github\.com\/([^/]+\/[^/]+)$/)?.[1]}var V=class extends Error{constructor(e,t){super(e,t),this.name=`StateFileError`}};const dt={installedAgents:{},self:{}};function ft(){return ee(v())}async function H(){return Et()}async function pt(e){let t=await _({resource:`state`,scope:[`state`]});try{await Dt(e)}finally{await t()}}async function mt(e){return(await H()).installedAgents[e]}async function ht(e){try{return await U().getReceipt(e)}catch(e){throw e instanceof V?e:new V(`Failed to read Quantex state file.`,{cause:e})}}async function gt(e){let t=await _({resource:`state`,scope:[`state`]});try{await U().setReceipt(e)}catch(e){throw e instanceof V?e:new V(`Failed to write Quantex state file.`,{cause:e})}finally{await t()}}async function _t(e,t){let n=await _({resource:`state`,scope:[`state`]});try{await U().setAgentLifecycleEvidence(e,t)}catch(e){throw e instanceof V?e:new V(`Failed to write Quantex state file.`,{cause:e})}finally{await n()}}async function vt(e){let t=await _({resource:`state`,scope:[`state`]});try{await U().removeReceipt(e)}catch(e){throw e instanceof V?e:new V(`Failed to write Quantex state file.`,{cause:e})}finally{await t()}}const yt=Object.freeze({read:ht,remove:vt,write:gt});async function bt(e){await W(t=>{t.installedAgents[e.agentName]=e})}async function xt(e){await W(t=>{delete t.installedAgents[e]})}async function St(){return(await H()).self}async function Ct(e){await W(t=>{t.self.installSource=e})}async function wt(){await W(e=>{delete e.self.installSource})}async function Tt(e,t){await W(n=>{n.self.updateNoticeVersion=e,n.self.updateNoticeAt=t})}async function Et(){try{return await U().loadProjection()}catch(e){if(Ot(e))return{...dt};throw e instanceof V?e:e instanceof f?new V(`Failed to read Quantex state file: ${e.message}`,{cause:e}):new V(`Failed to read Quantex state file.`,{cause:e})}}async function Dt(e){try{await U().saveProjection(e)}catch(e){throw e instanceof V?e:new V(`Failed to write Quantex state file.`,{cause:e})}}function U(){return te(v())}function Ot(e){let t=typeof e==`object`&&e&&`code`in e?e.code:void 0;return t===`ENOENT`||t===`ENOTDIR`}async function W(e){let t=await _({resource:`state`,scope:[`state`]});try{let t=await Et();await e(t),await Dt(t)}finally{await t()}}const kt=`self:install-source`,At={clearInstallSource:wt,getSelfState:St,setInstallSource:Ct};function G(e=At){return{async load(t){let n=jt(t.key,t.signal);if(n)return n;try{let t=(await e.getSelfState()).installSource;return Nt(t===void 0?{kind:`missing`}:{kind:`found`,snapshot:{value:t}})}catch(e){return Pt(`Failed to read the persisted self install source.`,e)}},async remove(t){let n=jt(t.key,t.signal);if(n)return n;try{return await e.clearInstallSource(),Nt(void 0)}catch(e){return Pt(`Failed to remove the persisted self install source.`,e)}},async save(t){let n=jt(t.key,t.signal);if(n)return n;if(!Mt(t.value))return K({kind:`invalid-data`,message:`The persisted self install source is invalid.`});try{return await e.setInstallSource(t.value),Nt({})}catch(e){return Pt(`Failed to persist the self install source.`,e)}}}}function jt(e,t){if(t.aborted)return K({kind:`cancelled`,message:`Self install-source persistence was cancelled.`});if(e!==`self:install-source`)return K({kind:`invalid-data`,message:`Unsupported self persistence key "${e}".`})}function Mt(e){return e===`binary`||e===`bun`||e===`npm`||e===`source`||e===`unknown`}function Nt(e){return{kind:`success`,value:e}}function K(e){return{error:e,kind:`failure`}}function Pt(e,t){return K({details:{cause:t},kind:`failed`,message:e})}const Ft=R,It=`/node_modules/${Ft}`;async function Lt(e){return zt(e,!0)}async function Rt(e){return zt(e,!1)}async function zt(e,t){let n=await Kt(),r=S.execPath,i=n.foundPackageJson?Gt(n.packageRoot):Gt(``,r),a=e?.persistence??G(),o=e?.signal??new AbortController().signal,s=await Ut(a,o),c=t?await Ht(s,i,{persistence:a,signal:o}):Bt(s,i),l=await g(),u=at(e?.updateChannel,l.selfUpdateChannel);return{canAutoUpdate:Vt(c),currentVersion:n.version||`1.8.7`,executablePath:r,installSource:c,packageRoot:n.packageRoot,updateChannel:u}}function Bt(e,t){return t===`unknown`?e??t:t}function Vt(e){return e===`binary`||e===`bun`||e===`npm`}async function Ht(e,t,n){if(t!==`unknown`&&e!==t){let e=await(n?.persistence??G()).save({key:kt,signal:n?.signal??new AbortController().signal,value:t});return e.kind===`failure`&&Wt(e.error),t}return Bt(e,t)}async function Ut(e,t){let n=await e.load({key:kt,signal:t});if(n.kind===`failure`&&Wt(n.error),n.value.kind===`missing`)return;let r=n.value.snapshot.value;if(r===`binary`||r===`bun`||r===`npm`||r===`source`||r===`unknown`)return r;throw Error(`The persisted self install source is invalid.`)}function Wt(e){let t=e.details?.cause;throw t instanceof Error?t:e.kind===`cancelled`?new i({kind:`cancelled`,reason:e.message}):e.kind===`timed-out`?new i({kind:`timed-out`,timeoutMs:0}):Error(e.message)}function Gt(e,t=S.execPath){let n=Yt(e);return n.includes(`/.bun/install/global/`)?`bun`:n.includes(It)?`npm`:n?`source`:Xt(t)?`binary`:`unknown`}async function Kt(e=import.meta.url){let t=Zt(e),n=y(t);for(;;){let e=b(n,`package.json`),t=await Jt(e);if(t?.name===Ft)return{foundPackageJson:!0,packageJsonPath:e,packageRoot:n,version:t.version??`1.8.7`};let r=y(n);if(r===n)break;n=r}return{foundPackageJson:!1,packageJsonPath:b(y(t),`package.json`),packageRoot:y(t),version:tt}}function qt(){return tt}async function Jt(e){try{return JSON.parse(await C(e,`utf8`))}catch{return}}function Yt(e){return e.replaceAll(`\\`,`/`).toLowerCase()}function Xt(e){let t=re(Yt(e));return t!==`bun`&&t!==`bun.exe`}function Zt(e){try{return fe(e)}catch{return S.execPath}}async function Qt(){try{return await _({resource:`self upgrade`,scope:[`self-upgrade`]})}catch(e){if(h(e))return;throw e}}function $t(){return{async acquire(e){if(e.signal.aborted)return q(`cancelled`,`Self-upgrade lock acquisition was cancelled.`);if(e.scope.length!==1||e.scope[0]!==`self-upgrade`)return q(`unavailable`,`Unsupported self-upgrade lock scope: ${e.scope.join(`/`)}`);let t=await Qt();if(!t)return q(`conflict`,`Another qtx upgrade is already running.`);if(e.signal.aborted)return await t(),q(`cancelled`,`Self-upgrade lock acquisition was cancelled.`);let n=!1;return{kind:`success`,value:{async release(){if(n)return{kind:`success`,value:void 0};n=!0;try{return await t(),{kind:`success`,value:void 0}}catch(e){return q(`failed`,e instanceof Error?e.message:`Failed to release self-upgrade lock.`)}}}}}}}function q(e,t){return{error:{kind:e,message:t},kind:`failure`}}async function en(e,t,n=S.env,r=S.cwd()){if(e!==`bun`&&e!==`npm`)return;let i=l(n.QTX_SELF_UPDATE_REGISTRY);return i?{isOverride:!0,registry:i,source:`quantex-env`}:t.selfUpdateRegistry?{isOverride:!0,registry:t.selfUpdateRegistry,source:`quantex-config`}:await tn(e,n,r)||{isOverride:!1,registry:u,source:`fallback`}}async function tn(e,t,n){if(e===`bun`){let e=nn(t,[`BUN_CONFIG_REGISTRY`,`NPM_CONFIG_REGISTRY`,`npm_config_registry`]);if(e)return{isOverride:!1,registry:e,source:`bun-env`};let r=await rn(n,t);if(r)return{isOverride:!1,registry:r,source:`bunfig`}}let r=nn(t,[`NPM_CONFIG_REGISTRY`,`npm_config_registry`]);if(r)return{isOverride:!1,registry:r,source:`npm-env`};let i=await on(n,t);if(i)return{isOverride:!1,registry:i,source:`npmrc`}}function nn(e,t){for(let n of t){let t=l(e[n]);if(t)return t}}async function rn(e,t){let n=ln(t),r=t.XDG_CONFIG_HOME,i=cn(e,`bunfig.toml`),a=[b(n,`.bunfig.toml`),r?b(r,`.bunfig.toml`):void 0];if(i){let e=await an(i);if(e)return e}for(let e of a){if(!e||!ne(e))continue;let t=await an(e);if(t)return t}}async function an(e){try{return un(await C(e,`utf8`))}catch{return}}async function on(e,t){let n=ln(t),r=cn(e,`.npmrc`),i=b(n,`.npmrc`);if(r){let e=await sn(r);if(e)return e}if(ne(i))return sn(i)}async function sn(e){try{let t=(await C(e,`utf8`)).split(`
4
4
  `).map(e=>e.trim());for(let e=t.length-1;e>=0;--e){let n=t[e];if(!n||n.startsWith(`#`)||n.startsWith(`;`))continue;let r=n.match(/^registry\s*=\s*(.+)$/);if(!r?.[1])continue;let i=l(r[1]);if(i)return i}}catch{}}function cn(e,t){let n=e;for(;;){let e=b(n,t);if(ne(e))return e;let r=y(n);if(r===n)return;n=r}}function ln(e){return e.HOME||e.USERPROFILE||ue()}function un(e){let t=dn(e,[/(?:^|\n)\s*install\.registry\s*=\s*["']([^"'#\n]+)["']/,/(?:^|\n)\s*install\.registry\s*=\s*\{\s*url\s*=\s*["']([^"'#\n]+)["']/,/(?:^|\n)\s*install\s*=\s*\{[\s\S]*?\bregistry\s*=\s*["']([^"'#\n]+)["'][\s\S]*?\}/,/(?:^|\n)\s*install\s*=\s*\{[\s\S]*?\bregistry\s*=\s*\{\s*url\s*=\s*["']([^"'#\n]+)["'][\s\S]*?\}[\s\S]*?\}/]);if(t)return l(t);let n=e.match(/(?:^|\n)\s*\[install\]\s*\n([\s\S]*?)(?=\n\s*\[[^\]]+\]|\s*$)/)?.[1];if(n)return l(dn(n,[/(?:^|\n)\s*registry\s*=\s*["']([^"'#\n]+)["']/,/(?:^|\n)\s*registry\s*=\s*\{\s*url\s*=\s*["']([^"'#\n]+)["']/]))}function dn(e,t){for(let n of t){let t=e.match(n)?.[1];if(t)return t}}function fn(e){return`self:update-metadata:${e.installSource}:${e.updateChannel}`}function pn(e){return{canAutoUpdate:!0,expiresAtMs:e.expiresAtMs,fetchedAtMs:e.fetchedAtMs,installSource:e.facts.installSource,schemaVersion:1,targetVersion:e.targetVersion,updateChannel:e.facts.updateChannel}}function mn(e,t){if(_n(e)&&e.schemaVersion===1&&!(e.canAutoUpdate!==!0||!t.facts.canAutoUpdate)&&!(e.installSource!==t.facts.installSource||e.updateChannel!==t.facts.updateChannel)&&!(typeof e.targetVersion!=`string`||d(e.targetVersion,e.targetVersion)!==0)&&!(!vn(e.fetchedAtMs)||!vn(e.expiresAtMs))&&!(e.fetchedAtMs>t.nowMs||e.expiresAtMs<=t.nowMs||e.fetchedAtMs>=e.expiresAtMs))return e}async function hn(e){let t=await e.cache.read({key:fn(e.facts),signal:e.signal});if(!(t.kind===`failure`||t.value.kind===`miss`)&&!(t.value.expiresAtMs!==void 0&&t.value.expiresAtMs<=e.nowMs))return mn(t.value.value,e)}function gn(e){return e.cache.write({expiresAtMs:e.metadata.expiresAtMs,key:fn(e.metadata),signal:e.signal,value:e.metadata})}function _n(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vn(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}async function yn(e,n,r,i){let a=await g();if(e.installSource===`binary`)try{let t=n?await ot(e.updateChannel,n,r,i):await ot(e.updateChannel,void 0,r,i),a=lt(t,e.executablePath);return a?{binaryAsset:a,targetVersion:t.version}:{resolutionError:{detail:{channel:e.updateChannel},kind:`unsupported`,message:`No binary asset is available for the current platform on the ${e.updateChannel} channel.`}}}catch(n){if(t(n))throw n;return{resolutionError:{kind:`network`,message:`Failed to resolve the ${e.updateChannel} release manifest.`}}}let o=e.updateChannel===`beta`?`beta`:`latest`,s=await je(R,o,{...n?{context:n}:{},cacheMode:i,networkPort:r,registry:u});if(e.installSource===`bun`||e.installSource===`npm`){let t=await en(e.installSource,a);return{managedRegistry:t?.registry,managedRegistryIsOverride:t?.isOverride??!1,packageTag:o,targetVersion:await je(R,o,{...n?{context:n}:{},cacheMode:i,networkPort:r,registry:t?.registry}),upstreamLatestVersion:s,verificationCommand:En(e.packageRoot)}}return{packageTag:o,targetVersion:s,upstreamLatestVersion:s}}async function J(e){let t=e?.facts??await Lt({persistence:e?.persistencePort,signal:e?.context?.signal,updateChannel:e?.updateChannel}),n=e?.target??await yn(t,e?.context,e?.networkPort,e?.metadataCacheMode),r=n.targetVersion?Oe(n.targetVersion,t.currentVersion):!1,i={facts:t,status:Cn(t,n,r),target:n,updateAvailable:r};if(e?.metadataCache&&t.canAutoUpdate&&n.targetVersion){let r=e.nowMs??Date.now(),i=e.metadataTtlMs??(await g()).versionCacheTtlHours*60*60*1e3;await gn({cache:e.metadataCache,metadata:pn({expiresAtMs:r+i,facts:t,fetchedAtMs:r,targetVersion:n.targetVersion}),signal:e.context?.signal??new AbortController().signal})}return i}function bn(e){return{canAutoUpdate:e.facts.canAutoUpdate,currentVersion:e.facts.currentVersion,executablePath:e.facts.executablePath,installSource:e.facts.installSource,latestVersion:e.target.targetVersion,managedRegistry:e.target.managedRegistry,managedRegistryIsOverride:e.target.managedRegistryIsOverride,packageRoot:e.facts.packageRoot,recommendedUpgradeCommand:e.facts.canAutoUpdate?`quantex upgrade`:void 0,upstreamLatestVersion:e.target.upstreamLatestVersion,updateChannel:e.facts.updateChannel}}async function xn(e,t,n){if(!t.success||e.facts.installSource!==`bun`&&e.facts.installSource!==`npm`)return t;let r=await wn(e,n);if(!r)return{error:{kind:`verify`,message:`Managed self-upgrade finished but Quantex could not verify the installed version afterwards.`},installSource:e.facts.installSource,success:!1};let i=t.newVersion??e.target.targetVersion;return i&&r!==i?{error:{detail:{expectedVersion:i,observedVersion:r},kind:`verify`,message:`Managed self-upgrade installed version ${r}, but expected ${i}.`},installSource:e.facts.installSource,success:!1}:!i&&r===e.facts.currentVersion&&e.target.targetVersion!==void 0?{error:{detail:{observedVersion:r},kind:`verify`,message:`Managed self-upgrade completed without changing the installed Quantex version.`},installSource:e.facts.installSource,success:!1}:{...t,newVersion:r}}function Sn(e){let t={canAutoUpdate:e.canAutoUpdate,currentVersion:e.currentVersion,executablePath:e.executablePath,installSource:e.installSource,packageRoot:e.packageRoot,updateChannel:e.updateChannel},n={managedRegistry:e.managedRegistry,managedRegistryIsOverride:e.managedRegistryIsOverride,packageTag:e.updateChannel===`beta`?`beta`:`latest`,targetVersion:e.latestVersion,upstreamLatestVersion:e.upstreamLatestVersion,verificationCommand:En(e.packageRoot)},r=e.latestVersion?Oe(e.latestVersion,e.currentVersion):!1;return{facts:t,status:Cn(t,n,r),target:n,updateAvailable:r}}function Cn(e,t,n){return e.canAutoUpdate?t.targetVersion&&!n?`up-to-date`:t.targetVersion?`update-available`:`check-unavailable`:`manual-required`}async function wn(e,t){let n=t?.process;if(n&&t){let r={...t,process:n};if(e.target.verificationCommand){let t=await Tn(e.target.verificationCommand,r);if(t)return t}return Tn([e.facts.executablePath,`--version`],r)}if(e.target.verificationCommand){let t=await ke(e.facts.executablePath,{command:e.target.verificationCommand});if(t)return t}return ke(e.facts.executablePath)}async function Tn(e,t){let n=await t.process.run({argv:e,signal:t.signal,stdio:[`ignore`,`pipe`,`ignore`],timeoutMs:t.timeoutMs});if(n.kind===`failure`){if(n.error.kind===`cancelled`)throw new i({kind:`cancelled`,reason:n.error.message});if(n.error.kind===`timed-out`)throw new i({kind:`timed-out`,timeoutMs:t.timeoutMs??0});return}if(n.value.exitCode!==0||!n.value.stdout)return;let r=new TextDecoder().decode(n.value.stdout).trim().split(`
5
5
  `)[0];if(r)return r.match(/v?(\d+\.\d+\.\d+(?:-[a-z0-9.]+)?)/i)?.[1]??r}function En(e){if(e)return[S.execPath,b(e,`dist`,`cli.mjs`),`--version`]}const Dn=[`quantex-darwin-arm64`,`quantex-darwin-x64`,`quantex-linux-arm64`,`quantex-linux-x64`,`quantex-windows-x64.exe`].map(On);function On(e){return`${e}.tar.gz`}function Y(e){if(!e.endsWith(`.tar.gz`))return;let t=e.slice(0,-7);return X(t)?t:void 0}function kn(e){return`${e.sort((e,t)=>e.name.localeCompare(t.name)).map(e=>`${e.checksum} ${e.name}`).join(`
6
6
  `)}\n`}function An(e){let t=new Map;for(let n of e.split(/\r?\n/)){let e=n.trim();if(!e)continue;let[r,i]=e.split(/\s+/,2),a=i?.replace(/^\*/,``);r&&a&&t.set(a,r)}return t}function X(e){let t=(Y(e)??e).match(/^quantex-(darwin|linux|windows)-(arm64|x64)(?:\.exe)?$/);if(t)return{arch:t[2]===`arm64`?`arm64`:`x64`,platform:t[1]===`windows`?`win32`:t[1]===`darwin`?`darwin`:`linux`}}function jn(e){return e?e.startsWith(`git+`)?e.slice(4).replace(/\.git$/,``):e.startsWith(`git@github.com:`)?e.replace(`git@github.com:`,`https://github.com/`).replace(/\.git$/,``):e.replace(/\.git$/,``):`https://github.com/Drswith/quantex-cli`}function Mn(e){return e.includes(`beta`)?`beta`:`stable`}function Nn(e){let t=jn(e.repositoryUrl),n=Mn(e.version),r=e.files.map(n=>{let r=X(n.name);if(!r)return;let i=e.checksums.get(n.name);if(!i)throw Error(`Missing checksum entry for ${n.name}.`);if(!Y(n.name))throw Error(`Release asset is not a compressed binary archive: ${n.name}.`);return{arch:r.arch,checksum:i,downloadUrl:`${t}/releases/download/v${e.version}/${n.name}`,name:n.name,platform:r.platform,size:n.size}}).filter(e=>e!==void 0).sort((e,t)=>e.name.localeCompare(t.name));if(r.length===0)throw Error(`No release binaries were found when creating manifest.json.`);return{assets:r,channel:n,version:e.version}}function Pn(e,t){if(e.assets.length===0)throw Error(`manifest.json must contain at least one binary asset.`);let n=new Set(e.assets.map(e=>e.name));for(let e of Dn)if(!n.has(e))throw Error(`manifest.json is missing required release asset: ${e}.`);for(let n of e.assets){let e=t.get(n.name);if(!e)throw Error(`manifest.json references ${n.name}, but it is missing from SHA256SUMS.txt.`);if(n.checksum!==e)throw Error(`manifest.json checksum mismatch for ${n.name}.`);if(!X(n.name))throw Error(`manifest.json contains an invalid binary asset name: ${n.name}.`)}}function Fn(e,t){if(Y(On(t))!==t)throw Error(`Invalid expected release binary name: ${t}.`);let n;try{n=pe(e)}catch(e){throw Error(`Release archive is not a valid gzip stream.`,{cause:e})}let r=0,i;for(;r+512<=n.length;){let e=n.subarray(r,r+512);if(e.every(e=>e===0))break;let a=In(e.subarray(0,100)),o=In(e.subarray(345,500)),s=o?`${o}/${a}`:a,c=e[156],l=Ln(e.subarray(124,136)),u=r+512,d=u+l;if(!a||d>n.length)throw Error(`Release archive contains an invalid tar entry.`);if(c!==0&&c!==48)throw Error(`Release archive must contain only a regular file.`);if(s!==t||i)throw Error(`Release archive must contain exactly ${t}.`);i=n.slice(u,d),r=u+Math.ceil(l/512)*512}if(!i)throw Error(`Release archive does not contain ${t}.`);return i}function In(e){let t=e.indexOf(0);return new TextDecoder().decode(t===-1?e:e.subarray(0,t))}function Ln(e){let t=In(e).trim();if(!/^[0-7]+$/u.test(t))throw Error(`Release archive contains an invalid tar size.`);let n=Number.parseInt(t,8);if(!Number.isSafeInteger(n)||n<0)throw Error(`Release archive contains an unsafe tar size.`);return n}async function Rn(e,t,n,r,a=Vn(t),o){let s=o?.networkPort,c=s&&o?await Bn(e,{...o,networkPort:s}):await zn(e);if(c.kind===`failure`)return c.result;let l=c.binary;Z(o);let u=Jn(c.binary);if(u!==Yn(n))return $(`checksum`,`Checksum mismatch for ${e}. Expected ${Yn(n)}, got ${u}.`);if(o?.archiveEntryName)try{l=E.from(Fn(l,o.archiveEntryName))}catch(t){return $(`unknown`,`Failed to extract the expected binary from ${e}.`,t)}let d=await oe(b(y(t),`.quantex-upgrade-`)),f=b(d,re(t)),p=`${t}.bak`,m=!1,h=!1;try{Z(o);let e=await Hn(t);if(await le(f,l),Z(o),S.platform===`win32`){let e=Un(f,t,p,d,r,a);return h=e.success,e}await ie(f,e),Z(o),await T(p,{force:!0}),await w(t,p),m=!0,await w(f,t);let n=await qn(t,r,o);return n.success?(m=!1,await T(p,{force:!0}),{success:!0}):(await Kn(p,t),m=!1,n)}catch(e){if(m){try{await Kn(p,t)}catch{}m=!1}if(e instanceof i)throw e;return $(Gn(e),`Failed to replace the current Quantex binary.`,e)}finally{(S.platform!==`win32`||!h)&&await T(d,{recursive:!0,force:!0})}}function Z(e){if(e?.signal.aborted)throw new i({kind:`cancelled`,reason:e.signal.reason instanceof Error?e.signal.reason.message:String(e.signal.reason??``)})}async function zn(e){let t;try{t=await fetch(e)}catch(t){return{kind:`failure`,result:$(`network`,`Failed to download ${e}.`,t)}}return t.ok?{binary:E.from(await t.arrayBuffer()),kind:`success`}:{kind:`failure`,result:$(`network`,`Failed to download ${e}: HTTP ${t.status}.`)}}async function Bn(e,t){let n=await t.networkPort.request({signal:t.signal,timeoutMs:t.timeoutMs,url:e});if(n.kind===`failure`){if(n.error.kind===`cancelled`)throw new i({kind:`cancelled`,reason:n.error.message});if(n.error.kind===`timed-out`)throw new i({kind:`timed-out`,timeoutMs:t.timeoutMs??0});return{kind:`failure`,result:$(`network`,`Failed to download ${e}.`,n.error)}}return n.value.status<200||n.value.status>=300?{kind:`failure`,result:$(`network`,`Failed to download ${e}: HTTP ${n.value.status}.`)}:{binary:E.from(n.value.body),kind:`success`}}function Vn(e){if(S.platform!==`win32`)return;let t=x.basename(e).toLowerCase();if(t===`qtx.exe`)return x.join(x.dirname(e),`quantex.exe`);if(t===`quantex.exe`)return x.join(x.dirname(e),`qtx.exe`)}async function Hn(e){try{return(await ce(e)).mode&511}catch{return 493}}function Un(e,t,r,i,a,o){try{return n([`powershell.exe`,`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-WindowStyle`,`Hidden`,`-Command`,Wn(e,t,r,i,S.pid,a,o)],{stdio:[`ignore`,`ignore`,`ignore`],windowsHide:!0}).unref(),{success:!0}}catch(e){return $(`locked`,`Failed to schedule Windows binary replacement.`,e)}}function Wn(e,t,n,r,i,a,o){let s=Q(e),c=Q(t),l=Q(n),u=Q(r),d=Q(a??``),f=Q(o??``);return[`$ErrorActionPreference = 'Stop'`,`$pidToWait = ${i}`,`$tempPath = '${s}'`,`$targetPath = '${c}'`,`$backupPath = '${l}'`,`$tempDir = '${u}'`,`$expectedVersion = '${d}'`,`$peerPath = '${f}'`,`while (Get-Process -Id $pidToWait -ErrorAction SilentlyContinue) { Start-Sleep -Milliseconds 200 }`,`$backupReady = $false`,`for ($attempt = 0; $attempt -lt 50; $attempt++) {`,` try {`,` if (Test-Path -LiteralPath $backupPath) { Remove-Item -LiteralPath $backupPath -Force -ErrorAction SilentlyContinue }`,` Move-Item -LiteralPath $targetPath -Destination $backupPath -Force -ErrorAction Stop`,` $backupReady = $true`,` break`,` }`,` catch {`,` Start-Sleep -Milliseconds 200`,` }`,`}`,`if (-not $backupReady) {`,` Remove-Item -LiteralPath $tempDir -Force -Recurse -ErrorAction SilentlyContinue`,` exit 1`,`}`,`try {`,` Move-Item -LiteralPath $tempPath -Destination $targetPath -Force`,`}`,`catch {`,` if (Test-Path -LiteralPath $backupPath) {`,` Move-Item -LiteralPath $backupPath -Destination $targetPath -Force -ErrorAction SilentlyContinue`,` }`,` Remove-Item -LiteralPath $tempDir -Force -Recurse -ErrorAction SilentlyContinue`,` exit 1`,`}`,`if ($expectedVersion -ne '') {`,` $output = & $targetPath --version 2>$null`,` if ($LASTEXITCODE -ne 0 -or ($output -notmatch [regex]::Escape($expectedVersion))) {`,` Remove-Item -LiteralPath $targetPath -Force -ErrorAction SilentlyContinue`,` Move-Item -LiteralPath $backupPath -Destination $targetPath -Force`,` Remove-Item -LiteralPath $tempDir -Force -Recurse -ErrorAction SilentlyContinue`,` exit 1`,` }`,`}`,`if ($peerPath -ne '') {`,` Copy-Item -LiteralPath $targetPath -Destination $peerPath -Force`,`}`,`Remove-Item -LiteralPath $backupPath -Force -ErrorAction SilentlyContinue`,`Remove-Item -LiteralPath $tempDir -Force -Recurse -ErrorAction SilentlyContinue`].join(`; `)}function Q(e){return e.replaceAll(`'`,`''`)}function $(e,t,n){return{error:{detail:n,kind:e,message:t},success:!1}}function Gn(e){let t=typeof e==`object`&&e&&`code`in e?String(e.code):``;return t===`EACCES`||t===`EPERM`?`permission`:t===`EBUSY`?`locked`:`unknown`}async function Kn(e,t){await T(t,{force:!0}),await w(e,t)}async function qn(e,t,a){if(!t)return{success:!0};try{if(a?.processPort){let n=await a.processPort.run({argv:[e,`--version`],signal:a.signal,stdio:[`ignore`,`pipe`,`ignore`],timeoutMs:a.timeoutMs});if(n.kind===`failure`){if(n.error.kind===`cancelled`)throw new i({kind:`cancelled`,reason:n.error.message});if(n.error.kind===`timed-out`)throw new i({kind:`timed-out`,timeoutMs:a.timeoutMs??0});return $(`verify`,`Failed to execute the upgraded Quantex binary for verification.`,n.error)}let r=n.value.stdout?new TextDecoder().decode(n.value.stdout):``;return n.value.exitCode===0?r.includes(t)?{success:!0}:$(`verify`,`The upgraded Quantex binary reported an unexpected version during verification.`):$(`verify`,`The upgraded Quantex binary exited with code ${n.value.exitCode} during verification.`)}let{exitCode:o,stdout:s}=await r(n([e,`--version`],{stdio:[`ignore`,`pipe`,`ignore`]}));return o===0?s.includes(t)?{success:!0}:$(`verify`,`The upgraded Quantex binary reported an unexpected version during verification.`):$(`verify`,`The upgraded Quantex binary exited with code ${o} during verification.`)}catch(e){if(e instanceof i)throw e;return $(`verify`,`Failed to execute the upgraded Quantex binary for verification.`,e)}}function Jn(e){return de(`sha256`).update(e).digest(`hex`)}function Yn(e){return e.trim().toLowerCase()}const Xn={source:`binary`,canHandle:e=>Zn(e)===`binary`,getRecoveryHint:(e,t)=>{let n=t?.error?.detail&&typeof t.error.detail==`object`&&`downloadUrl`in t.error.detail?String(t.error.detail.downloadUrl):it(e.executablePath);if(n)return t?.error?.kind===`locked`?`close other qtx processes and retry, or download and replace the binary from ${n}`:t?.error?.kind===`permission`?`check write permission for the current binary path, or download and replace the binary from ${n}`:t?.error?.kind===`network`?`check network access and retry, or download and replace the binary from ${n}`:`download and replace the binary from ${n}`},async upgrade(e,t){let n=e.target.binaryAsset;if(!n)return{error:e.target.resolutionError??{kind:`unsupported`,message:`No release artifact is available for the current platform and architecture.`},installSource:e.facts.installSource,success:!1};let r=Vn(e.facts.executablePath),i=Y(n.name);if(!i)return{error:{kind:`unsupported`,message:`The resolved release artifact is not a compressed standalone binary archive.`},installSource:e.facts.installSource,success:!1};let a=await Rn(n.downloadUrl,e.facts.executablePath,n.checksum,e.target.targetVersion??`latest`,r,t?{archiveEntryName:i,networkPort:t.network,processPort:t.process,signal:t.signal,timeoutMs:t.timeoutMs}:{archiveEntryName:i,signal:new AbortController().signal});return{...!a.success&&a.error?{...a,error:{...a.error,detail:{...typeof a.error.detail==`object`&&a.error.detail?a.error.detail:{},downloadUrl:n.downloadUrl}}}:a,installSource:e.facts.installSource,newVersion:a.success?e.target.targetVersion:void 0}}};function Zn(e){return`facts`in e?e.facts.installSource:e.installSource}async function Qn(e,t){return t.process?(await er(e,t,{forwardPipedOutput:!0,stdio:t.stdio}))?.exitCode===0:!1}async function $n(e,t,n){if(!await Qn(e,n))return!1;let r=await er([`bun`,`pm`,`-g`,`untrusted`],n,{forwardPipedOutput:!1,stdio:[`ignore`,`pipe`,`pipe`]});return!r||r.exitCode!==0?!1:a(r.stdout?new TextDecoder().decode(r.stdout):``).has(t)?Qn([`bun`,`pm`,`-g`,`trust`,t],n):!0}async function er(e,t,n){if(!t.process)return;let r=await t.process.run({argv:e,forwardPipedOutput:n.forwardPipedOutput,signal:t.signal,stdio:n.stdio,timeoutMs:t.timeoutMs});if(r.kind===`success`)return r.value;if(r.error.kind===`cancelled`)throw new i({kind:`cancelled`,reason:r.error.message});if(r.error.kind===`timed-out`)throw new i({kind:`timed-out`,timeoutMs:t.timeoutMs??0})}const tr={source:`bun`,canHandle:e=>nr(e)===`bun`,getRecoveryHint:e=>`bun add -g ${R}@${e.updateChannel===`beta`?`beta`:`latest`}`,async upgrade(e,t){let n=e.target.packageTag??(e.facts.updateChannel===`beta`?`beta`:`latest`),r=t?.process?await $n([`bun`,`add`,`-g`,...e.target.managedRegistry?[`--registry`,e.target.managedRegistry]:[],`${R}@${n}`],R,t):await o(R,n,e.target.managedRegistry);return{error:r?void 0:{kind:`unknown`,message:`Failed to update ${R} through Bun.`},installSource:e.facts.installSource,newVersion:r?e.target.targetVersion:void 0,success:r}}};function nr(e){return`facts`in e?e.facts.installSource:e.installSource}const rr={source:`npm`,canHandle:e=>ir(e)===`npm`,getRecoveryHint:e=>`npm install -g ${R}@${e.updateChannel===`beta`?`beta`:`latest`}`,async upgrade(e,t){let n=e.target.packageTag??(e.facts.updateChannel===`beta`?`beta`:`latest`),r=t?.process?await Qn([`npm`,`install`,`-g`,`${R}@${n}`,...e.target.managedRegistry?[`--registry`,e.target.managedRegistry]:[]],t):await s(R,n,e.target.managedRegistry);return{error:r?void 0:{kind:`unknown`,message:`Failed to update ${R} through npm.`},installSource:e.facts.installSource,newVersion:r?e.target.targetVersion:void 0,success:r}}};function ir(e){return`facts`in e?e.facts.installSource:e.installSource}const ar={source:`source`,canHandle:e=>{let t=`facts`in e?e.facts.installSource:e.installSource;return t===`source`||t===`unknown`},getRecoveryHint:()=>void 0,async upgrade(e){return{error:{kind:`unsupported`,message:`Install source "${e.facts.installSource}" does not support auto-update.`},installSource:e.facts.installSource,success:!1}}},or=[tr,rr,Xn,ar];function sr(e){return or.find(t=>t.canHandle(e))??ar}function cr(e,t,n=`stable`){return sr({canAutoUpdate:e===`binary`||e===`bun`||e===`npm`,currentVersion:``,executablePath:t,installSource:e,packageRoot:``,updateChannel:n})}function lr(e,t,n=`stable`,r){return r?.error?.kind===`locked`?`another qtx upgrade is already running; wait for it to finish and retry`:cr(e,t,n).getRecoveryHint({canAutoUpdate:e===`binary`||e===`bun`||e===`npm`,currentVersion:``,executablePath:t,installSource:e,packageRoot:``,updateChannel:n},r)}function ur(e,t){return t?.error?.kind===`locked`?`another qtx upgrade is already running; wait for it to finish and retry`:sr(e).getRecoveryHint(e,t)}async function dr(e){return bn(await J({updateChannel:e?.updateChannel}))}async function fr(e){let t=await Rt({updateChannel:e?.updateChannel});return bn(await J({context:e?.context,facts:t}))}async function pr(e,t={}){let n=await gr(e),r=t.lockPort?await t.lockPort.acquire({resource:`self upgrade`,scope:[`self-upgrade`],signal:t.signal??new AbortController().signal,timeoutMs:t.timeoutMs}):await mr();if(r.kind===`failure`){if(r.error.kind===`cancelled`)throw new i({kind:`cancelled`});if(r.error.kind===`timed-out`)throw new i({kind:`timed-out`,timeoutMs:t.timeoutMs??0});return{error:{kind:r.error.kind===`conflict`?`locked`:`unknown`,message:r.error.message},installSource:n.facts.installSource,success:!1}}let a;try{let e=t.networkPort!==void 0||t.processPort!==void 0,r=t.signal??new AbortController().signal;a=await xn(n,await sr(n).upgrade(n,e?{network:t.networkPort,process:t.processPort,signal:r,stdio:t.stdio,timeoutMs:t.timeoutMs}:void 0),t.processPort?{process:t.processPort,signal:r,timeoutMs:t.timeoutMs}:void 0)}catch(e){let t=await r.value.release();throw t.kind===`failure`?Error(`Self-upgrade failed and its lock could not be released: ${t.error.message}`,{cause:e}):e}let o=await r.value.release();if(o.kind===`failure`)throw Error(o.error.message);return a}async function mr(){let e=await Qt();return e?{kind:`success`,value:{async release(){return await e(),{kind:`success`,value:void 0}}}}:{error:{kind:`conflict`,message:`Another qtx upgrade is already running.`},kind:`failure`}}function hr(e,t=S.execPath){return lr(e,t)}async function gr(e){return e?`facts`in e?e:e.installSource===`binary`?J({facts:{canAutoUpdate:e.canAutoUpdate,currentVersion:e.currentVersion,executablePath:e.executablePath,installSource:e.installSource,packageRoot:e.packageRoot,updateChannel:e.updateChannel}}):Sn(e):J()}function _r(e){return xr({...e,error:null,ok:!0})}function vr(e){return xr({...e,ok:!1})}function yr(e,t,n={}){let r=p();return r.cancelled&&!n.force||Ze(Xe(e.action),r.outputMode,e,t,e=>console.log(e),e=>Cr(e)),e}function br(e,t={}){let n=p();if(!(n.cancelled&&!t.force))return Qe(Xe(e.action),n.outputMode,e,e=>Cr(e))}function xr(e){let t=p();return{action:e.action,data:e.data,error:e.error??null,exitCode:e.exitCode,meta:{fetchedAt:t.freshness?.fetchedAt,mode:t.outputMode,runId:t.runId,schemaVersion:`1`,source:t.freshness?.source,staleAfter:t.freshness?.staleAfter,timestamp:new Date().toISOString(),version:qt()},ok:e.ok,target:e.target,warnings:e.warnings??[]}}function Sr(e){let t=p();return{action:e.action,data:e.data,meta:{fetchedAt:t.freshness?.fetchedAt,mode:`ndjson`,runId:t.runId,schemaVersion:`1`,source:t.freshness?.source,staleAfter:t.freshness?.staleAfter,timestamp:new Date().toISOString(),version:qt()},target:e.target,type:e.type}}function Cr(e){let t=Sr(e);return wr(t),t}function wr(e){console.log(JSON.stringify(e))}export{Ne as $,St as A,Ct as B,Gt as C,V as D,G as E,vt as F,Ve as G,B as H,pt as I,We as J,He as K,_t as L,yt as M,H as N,mt as O,xt as P,Ae as Q,bt as R,Vt as S,Rt as T,it as U,Tt as V,R as W,Me as X,Ge as Y,ke as Z,Pn as _,hr as a,hn as b,pr as c,Nn as d,Oe as et,kn as f,Mn as g,An as h,yr as i,ft as j,ht as k,lr as l,X as m,_r as n,dr as o,jn as p,Ue as q,br as r,fr as s,vr as t,ur as u,bn as v,qt as w,$t as x,J as y,gt as z};
@@ -1 +1 @@
1
- import{I as e}from"./agents-Btib2SO_.mjs";async function t(t,n){let r=(n.registry??e).get(t.providerId);return r?r.observe({context:{signal:n.signal,timeoutMs:n.timeoutMs},target:t.target}):{kind:`unavailable`,reason:`Provider ${t.providerId} is not registered.`,retryable:!1}}export{t};
1
+ import{I as e}from"./agents-BbEquU_b.mjs";async function t(t,n){let r=(n.registry??e).get(t.providerId);return r?r.observe({context:{signal:n.signal,timeoutMs:n.timeoutMs},target:t.target}):{kind:`unavailable`,reason:`Provider ${t.providerId} is not registered.`,retryable:!1}}export{t};
@@ -1 +1 @@
1
- import{I as e}from"./agents-Btib2SO_.mjs";const t=Object.freeze([`brew`,`bun`,`cargo`,`deno`,`mise`,`npm`,`pip`,`uv`,`winget`]);async function n(t){let n=t.registry??e;return Promise.all(n.list().map(async e=>({availability:await i(e.availability,t.context),capabilities:n.getCapabilities(e.id),id:e.id})))}function r(e,n){let r=new Map(e.map(e=>[e.id,e]));return Object.fromEntries(t.map(e=>{let t=r.get(e);if(!t)throw Error(`Provider snapshot is missing first-party adapter: ${e}`);return[e,n(t)]}))}async function i(e,t){try{return await e(t)}catch(e){return{kind:`failed`,reason:e instanceof Error?e.message:String(e),retryable:!1}}}export{r as n,n as t};
1
+ import{I as e}from"./agents-BbEquU_b.mjs";const t=Object.freeze([`brew`,`bun`,`cargo`,`deno`,`mise`,`npm`,`pip`,`uv`,`winget`]);async function n(t){let n=t.registry??e;return Promise.all(n.list().map(async e=>({availability:await i(e.availability,t.context),capabilities:n.getCapabilities(e.id),id:e.id})))}function r(e,n){let r=new Map(e.map(e=>[e.id,e]));return Object.fromEntries(t.map(e=>{let t=r.get(e);if(!t)throw Error(`Provider snapshot is missing first-party adapter: ${e}`);return[e,n(t)]}))}async function i(e,t){try{return await e(t)}catch(e){return{kind:`failed`,reason:e instanceof Error?e.message:String(e),retryable:!1}}}export{r as n,n as t};
@@ -1 +1 @@
1
- import{I as e}from"./agents-Btib2SO_.mjs";const t=Object.freeze(e.list().filter(t=>{let n=e.getCapabilities(t.id);return n.includes(`update`)&&n.includes(`uninstall`)}).map(e=>e.id));function n(t){let n=e.getCapabilities(t);if(!n.includes(`install`))throw Error(`First-party provider ${t} must implement install`);let r=n.includes(`update`),i=n.includes(`uninstall`);return{canInstall:!0,canLookupLatestVersion:n.includes(`resolve-latest-version`),canUninstall:i,canUpdate:r,lifecycle:r&&i?`managed`:`unmanaged`}}function r(){return t}function i(e){return t.includes(e)}function a(e){return n(e).lifecycle}function o(e){return n(e).canUpdate}function s(e){return n(e).canUninstall}function c(e){return n(e).canLookupLatestVersion}function l(e,t){return e?t===`cask`?` (${e} cask)`:t===`id`?` (${e} id)`:` (${e})`:``}function u(e,t){if(t.packageName)return t.packageName;if(t.type===`cargo`)return e.packages?.cargo;if(t.type===`deno`)return e.packages?.deno;if(t.type===`mise`)return e.packages?.mise;if(t.type===`pip`)return e.packages?.pip;if(t.type===`uv`)return e.packages?.uv;if(t.type===`bun`||t.type===`npm`)return e.packages?.npm}function d(e){return e?o(e.installType):!1}function f(e,t){return d(t)||!!e.selfUpdate}function p(e){return!!e&&c(e.installType)}function m(e){return e.length>0&&e.every(e=>c(e.type))}function h(e){return i(e.type)?`${a(e.type)}/${e.type}${l(e.packageName,e.packageTargetKind)}`:e.type===`script`?`unmanaged/script`:`unmanaged/binary`}function g(e){return e?i(e.installType)?`managed via ${e.installType}${l(e.packageName,e.packageTargetKind)}`:e.installType===`script`?`script installer`:`binary installer`:`detected in PATH`}function _(e,t){let n=k({agent:e,installedState:t,methods:[]});return n===`managed`?`managed update`:n===`self-update`?`command update`:`manual update`}function v(e,t){if(t.type===`bun`){let n=u(e,t);return n?`bun add -g ${n}`:``}if(t.type===`npm`){let n=u(e,t);return n?`npm i -g ${n}`:``}if(t.type===`brew`)return t.packageName?t.packageTargetKind===`cask`?`brew install --cask ${t.packageName}`:`brew install ${t.packageName}`:``;if(t.type===`cargo`){let n=u(e,t);return n?[`cargo`,`install`,n,...t.packageInstallArgs??[]].join(` `):``}if(t.type===`deno`){let n=u(e,t);return n?[`deno`,`install`,`--global`,...t.packageInstallArgs??[],n].join(` `):``}if(t.type===`mise`){let n=u(e,t);return n?`mise use --global ${n}`:``}if(t.type===`pip`){let n=u(e,t);return n?`pip install ${n}`:``}if(t.type===`uv`){let n=u(e,t);return n?[`uv`,`tool`,`install`,n,...t.packageInstallArgs??[]].join(` `):``}return t.type===`winget`?t.packageName?`winget install --id ${t.packageName} -e`:``:t.command??``}function y(e,t,n){if(t)return p(t)&&(t.packageName||e.packages?.npm)||void 0;if(!(!e.packages?.npm||!m(n)))return e.packages.npm}function b(e,t){let n=x(t);if(n){let t=e.find(e=>e.type===n);if(t)return t}if(e.length!==1)return;let[r]=e;if(!(r.type!==`script`&&r.type!==`binary`))return r}function x(e){if(!e)return;let t=e.replaceAll(`\\`,`/`);if(t.includes(`/.bun/bin/`)||t.includes(`/.bun/install/global/`))return`bun`;if(t.includes(`/.local/share/mise/shims/`)||t.includes(`/.mise/shims/`))return`mise`;if(S(t))return`npm`}function S(e){return e.includes(`/node_modules/.bin/`)?!1:e.includes(`/lib/node_modules/`)||e.includes(`/AppData/Roaming/npm/`)||e.includes(`/.nvm/versions/node/`)||e.includes(`/.fnm/node-versions/`)||e.includes(`/.volta/tools/image/node/`)}function C(e){if(e.installedState)return i(e.installedState.installType)?e.installedState.installType:void 0;for(let t of e.methods)if(i(t.type)&&o(t.type))return t.type}const w={strategy:`managed`,canHandle:e=>!!C(e),getManagedInstallerType:e=>C(e)},T={strategy:`self-update`,canHandle:e=>!d(e.installedState)&&!!e.agent.selfUpdate},E={strategy:`manual-hint`,canHandle:()=>!0},D=[w,T,E];function O(e){return D.find(t=>t.canHandle(e))??E}function k(e){return O(e).strategy}function A(e){return f(e.agent,e.installedState)}export{r as _,v as a,_ as c,u as d,c as f,n as g,a as h,O as i,b as l,o as m,A as n,h as o,s as p,k as r,g as s,D as t,y as u,i as v};
1
+ import{I as e}from"./agents-BbEquU_b.mjs";const t=Object.freeze(e.list().filter(t=>{let n=e.getCapabilities(t.id);return n.includes(`update`)&&n.includes(`uninstall`)}).map(e=>e.id));function n(t){let n=e.getCapabilities(t);if(!n.includes(`install`))throw Error(`First-party provider ${t} must implement install`);let r=n.includes(`update`),i=n.includes(`uninstall`);return{canInstall:!0,canLookupLatestVersion:n.includes(`resolve-latest-version`),canUninstall:i,canUpdate:r,lifecycle:r&&i?`managed`:`unmanaged`}}function r(){return t}function i(e){return t.includes(e)}function a(e){return n(e).lifecycle}function o(e){return n(e).canUpdate}function s(e){return n(e).canUninstall}function c(e){return n(e).canLookupLatestVersion}function l(e,t){return e?t===`cask`?` (${e} cask)`:t===`id`?` (${e} id)`:` (${e})`:``}function u(e,t){if(t.packageName)return t.packageName;if(t.type===`cargo`)return e.packages?.cargo;if(t.type===`deno`)return e.packages?.deno;if(t.type===`mise`)return e.packages?.mise;if(t.type===`pip`)return e.packages?.pip;if(t.type===`uv`)return e.packages?.uv;if(t.type===`bun`||t.type===`npm`)return e.packages?.npm}function d(e){return e?o(e.installType):!1}function f(e,t){return d(t)||!!e.selfUpdate}function p(e){return!!e&&c(e.installType)}function m(e){return e.length>0&&e.every(e=>c(e.type))}function h(e){return i(e.type)?`${a(e.type)}/${e.type}${l(e.packageName,e.packageTargetKind)}`:e.type===`script`?`unmanaged/script`:`unmanaged/binary`}function g(e){return e?i(e.installType)?`managed via ${e.installType}${l(e.packageName,e.packageTargetKind)}`:e.installType===`script`?`script installer`:`binary installer`:`detected in PATH`}function _(e,t){let n=k({agent:e,installedState:t,methods:[]});return n===`managed`?`managed update`:n===`self-update`?`command update`:`manual update`}function v(e,t){if(t.type===`bun`){let n=u(e,t);return n?`bun add -g ${n}`:``}if(t.type===`npm`){let n=u(e,t);return n?`npm i -g ${n}`:``}if(t.type===`brew`)return t.packageName?t.packageTargetKind===`cask`?`brew install --cask ${t.packageName}`:`brew install ${t.packageName}`:``;if(t.type===`cargo`){let n=u(e,t);return n?[`cargo`,`install`,n,...t.packageInstallArgs??[]].join(` `):``}if(t.type===`deno`){let n=u(e,t);return n?[`deno`,`install`,`--global`,...t.packageInstallArgs??[],n].join(` `):``}if(t.type===`mise`){let n=u(e,t);return n?`mise use --global ${n}`:``}if(t.type===`pip`){let n=u(e,t);return n?`pip install ${n}`:``}if(t.type===`uv`){let n=u(e,t);return n?[`uv`,`tool`,`install`,n,...t.packageInstallArgs??[]].join(` `):``}return t.type===`winget`?t.packageName?`winget install --id ${t.packageName} -e`:``:t.command??``}function y(e,t,n){if(t)return p(t)&&(t.packageName||e.packages?.npm)||void 0;if(!(!e.packages?.npm||!m(n)))return e.packages.npm}function b(e,t){let n=x(t);if(n){let t=e.find(e=>e.type===n);if(t)return t}if(e.length!==1)return;let[r]=e;if(!(r.type!==`script`&&r.type!==`binary`))return r}function x(e){if(!e)return;let t=e.replaceAll(`\\`,`/`);if(t.includes(`/.bun/bin/`)||t.includes(`/.bun/install/global/`))return`bun`;if(t.includes(`/.local/share/mise/shims/`)||t.includes(`/.mise/shims/`))return`mise`;if(S(t))return`npm`}function S(e){return e.includes(`/node_modules/.bin/`)?!1:e.includes(`/lib/node_modules/`)||e.includes(`/AppData/Roaming/npm/`)||e.includes(`/.nvm/versions/node/`)||e.includes(`/.fnm/node-versions/`)||e.includes(`/.volta/tools/image/node/`)}function C(e){if(e.installedState)return i(e.installedState.installType)?e.installedState.installType:void 0;for(let t of e.methods)if(i(t.type)&&o(t.type))return t.type}const w={strategy:`managed`,canHandle:e=>!!C(e),getManagedInstallerType:e=>C(e)},T={strategy:`self-update`,canHandle:e=>!d(e.installedState)&&!!e.agent.selfUpdate},E={strategy:`manual-hint`,canHandle:()=>!0},D=[w,T,E];function O(e){return D.find(t=>t.canHandle(e))??E}function k(e){return O(e).strategy}function A(e){return f(e.agent,e.installedState)}export{r as _,v as a,_ as c,u as d,c as f,n as g,a as h,O as i,b as l,o as m,A as n,h as o,s as p,k as r,g as s,D as t,y as u,i as v};
@@ -1 +1 @@
1
- import{i as e,n as t,t as n}from"./output-7rFW9QE9.mjs";import{a as r,o as i}from"./providers-D5426cNP.mjs";import{i as a,n as o,t as s}from"./human-D52z36dT.mjs";import{t as c}from"./color-FZclrXnv.mjs";import{n as l,r as u}from"./core-read-observations-dwe6-Jqu.mjs";async function d(a){let o=await l(a);if(!o)return e(n({action:`resolve`,error:{code:`AGENT_NOT_FOUND`,details:{input:a},message:`Unknown agent: ${a}`},target:{kind:`agent`,name:a}}),f);let{agent:s}=o,c=u(o);if(!c.inPath||!c.binaryPath){let t=c.methods.map(e=>({command:r(s,e),label:i(e),type:e.type})).filter(e=>e.command);return e(n({action:`resolve`,data:{agent:{binaryName:s.binaryName,displayName:s.displayName,name:s.name},resolution:{binaryPath:``,installGuidance:{docsRef:`skills/quantex-cli/references/command-recipes.md`,installMethods:t,suggestedAction:`ensure-agent-installed`,suggestedEnsureCommand:`quantex ensure ${s.name}`},installed:!1,installSource:`not-installed`,lifecycle:`unmanaged`,sourceLabel:`not installed`,suggestedLaunchCommand:[]}},error:{code:`AGENT_NOT_INSTALLED`,details:{docsRef:`skills/quantex-cli/references/command-recipes.md`,installMethods:t,suggestedAction:`ensure-agent-installed`,suggestedEnsureCommand:`quantex ensure ${s.name}`},message:`${s.displayName} is not installed.`},target:{kind:`agent`,name:s.name}}),f)}return e(t({action:`resolve`,data:{agent:{binaryName:s.binaryName,displayName:s.displayName,name:s.name},resolution:{binaryPath:c.binaryPath,installed:!0,installSource:c.installedState?.installType??`detected-in-path`,installedVersion:c.installedVersion,lifecycle:c.lifecycle,sourceLabel:c.sourceLabel,suggestedLaunchCommand:[c.binaryPath]}},target:{kind:`agent`,name:s.name}}),f)}function f(e){let t=s();if(e.error){for(let n of a(c.red(e.error.message),{width:t}))console.log(n);let n=e.data?.resolution.installGuidance;if(n){for(let e of a(c.dim(`Try: ${n.suggestedEnsureCommand}`),{continuationIndent:` `,width:t}))console.log(e);for(let e of n.installMethods)for(let n of a(c.dim(`[${e.label}] ${e.command}`),{continuationIndent:` `,indent:`Install: `,width:t}))console.log(n)}return}if(!e.data)return;console.log(c.bold(`\n${e.data.agent.displayName}\n`));let n=[{label:`Name`,value:e.data.agent.name},{label:`Binary`,value:e.data.agent.binaryName},{label:`Path`,value:e.data.resolution.binaryPath},{label:`Source`,value:e.data.resolution.sourceLabel},{label:`Lifecycle`,value:e.data.resolution.lifecycle},{label:`Install type`,value:e.data.resolution.installSource},...e.data.resolution.installedVersion?[{label:`Version`,value:e.data.resolution.installedVersion}]:[],{label:`Launch`,value:e.data.resolution.suggestedLaunchCommand.join(` `)}];for(let e of o(n,{labelStyle:c.bold,width:t}))console.log(e);console.log()}export{d as t};
1
+ import{i as e,n as t,t as n}from"./output-DQY0YUII.mjs";import{a as r,o as i}from"./providers-DHIXHYu1.mjs";import{i as a,n as o,t as s}from"./human-D52z36dT.mjs";import{t as c}from"./color-FZclrXnv.mjs";import{n as l,r as u}from"./core-read-observations-_7tVGtZS.mjs";async function d(a){let o=await l(a);if(!o)return e(n({action:`resolve`,error:{code:`AGENT_NOT_FOUND`,details:{input:a},message:`Unknown agent: ${a}`},target:{kind:`agent`,name:a}}),f);let{agent:s}=o,c=u(o);if(!c.inPath||!c.binaryPath){let t=c.methods.map(e=>({command:r(s,e),label:i(e),type:e.type})).filter(e=>e.command);return e(n({action:`resolve`,data:{agent:{binaryName:s.binaryName,displayName:s.displayName,name:s.name},resolution:{binaryPath:``,installGuidance:{docsRef:`skills/quantex-cli/references/command-recipes.md`,installMethods:t,suggestedAction:`ensure-agent-installed`,suggestedEnsureCommand:`quantex ensure ${s.name}`},installed:!1,installSource:`not-installed`,lifecycle:`unmanaged`,sourceLabel:`not installed`,suggestedLaunchCommand:[]}},error:{code:`AGENT_NOT_INSTALLED`,details:{docsRef:`skills/quantex-cli/references/command-recipes.md`,installMethods:t,suggestedAction:`ensure-agent-installed`,suggestedEnsureCommand:`quantex ensure ${s.name}`},message:`${s.displayName} is not installed.`},target:{kind:`agent`,name:s.name}}),f)}return e(t({action:`resolve`,data:{agent:{binaryName:s.binaryName,displayName:s.displayName,name:s.name},resolution:{binaryPath:c.binaryPath,installed:!0,installSource:c.installedState?.installType??`detected-in-path`,installedVersion:c.installedVersion,lifecycle:c.lifecycle,sourceLabel:c.sourceLabel,suggestedLaunchCommand:[c.binaryPath]}},target:{kind:`agent`,name:s.name}}),f)}function f(e){let t=s();if(e.error){for(let n of a(c.red(e.error.message),{width:t}))console.log(n);let n=e.data?.resolution.installGuidance;if(n){for(let e of a(c.dim(`Try: ${n.suggestedEnsureCommand}`),{continuationIndent:` `,width:t}))console.log(e);for(let e of n.installMethods)for(let n of a(c.dim(`[${e.label}] ${e.command}`),{continuationIndent:` `,indent:`Install: `,width:t}))console.log(n)}return}if(!e.data)return;console.log(c.bold(`\n${e.data.agent.displayName}\n`));let n=[{label:`Name`,value:e.data.agent.name},{label:`Binary`,value:e.data.agent.binaryName},{label:`Path`,value:e.data.resolution.binaryPath},{label:`Source`,value:e.data.resolution.sourceLabel},{label:`Lifecycle`,value:e.data.resolution.lifecycle},{label:`Install type`,value:e.data.resolution.installSource},...e.data.resolution.installedVersion?[{label:`Version`,value:e.data.resolution.installedVersion}]:[],{label:`Launch`,value:e.data.resolution.suggestedLaunchCommand.join(` `)}];for(let e of o(n,{labelStyle:c.bold,width:t}))console.log(e);console.log()}export{d as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./resolve-Bzj-pCBt.mjs";export{e as resolveCommand};
@@ -0,0 +1 @@
1
+ import{n as e}from"./schema-y8PVCGf9.mjs";export{e as schemaCommand};
@@ -1,3 +1,3 @@
1
- import{G as e,i as t,n,t as r}from"./output-7rFW9QE9.mjs";import{i,r as a,t as o}from"./human-D52z36dT.mjs";import{t as s}from"./color-FZclrXnv.mjs";async function c(e){let i=u(),a=e?i.filter(t=>t.name===e):i;return e&&a.length===0?t(r({action:`schema`,error:{code:`INVALID_ARGUMENT`,details:{command:e},message:`Unknown schema target: ${e}`},target:{kind:`system`,name:`schema`}}),l):t(n({action:`schema`,data:{commands:a},target:{kind:`system`,name:`schema`}}),l)}function l(e){if(e.error){console.log(s.red(e.error.message));return}if(!e.data)return;let t=o();console.log(s.bold(`
1
+ import{G as e,i as t,n,t as r}from"./output-DQY0YUII.mjs";import{i,r as a,t as o}from"./human-D52z36dT.mjs";import{t as s}from"./color-FZclrXnv.mjs";async function c(e){let i=u(),a=e?i.filter(t=>t.name===e):i;return e&&a.length===0?t(r({action:`schema`,error:{code:`INVALID_ARGUMENT`,details:{command:e},message:`Unknown schema target: ${e}`},target:{kind:`system`,name:`schema`}}),l):t(n({action:`schema`,data:{commands:a},target:{kind:`system`,name:`schema`}}),l)}function l(e){if(e.error){console.log(s.red(e.error.message));return}if(!e.data)return;let t=o();console.log(s.bold(`
2
2
  Quantex Schemas
3
3
  `));for(let n of a(e.data.commands,[{header:`Command`,maxWidth:24,minWidth:8,value:e=>s.cyan(e.name)},{header:`Description`,minWidth:16,value:e=>e.description,wrap:!0}],{headerStyle:s.bold,width:t}))console.log(n);console.log();for(let e of i(s.dim(`Document: qtx schema <command> --json`),{indent:` `,width:t}))console.log(e);console.log()}function u(){return e().map(e=>e.schema)}export{c as n,u as t};
@@ -1 +1 @@
1
- import{n as e}from"./detect-BdnZzKbm.mjs";import{n as t}from"./cli-context-xudTdmO7.mjs";import{a as n}from"./file-store-Caz7fnAB.mjs";import{F as r,O as i,P as a,R as o,i as s,k as c,n as l,t as u,z as d}from"./output-7rFW9QE9.mjs";import{p as f}from"./providers-D5426cNP.mjs";import{t as p}from"./color-FZclrXnv.mjs";import{g as m,n as h,p as g}from"./agents-DoqAiugw.mjs";import{a as _,i as v}from"./provider-binding-D1muQsgD.mjs";import{t as y}from"./provider-evidence-C7sM0RM3.mjs";import{t as b}from"./lifecycle-errors-B0bwmxkB.mjs";import{a as x,i as S,n as C,r as w}from"./user-output-B-zDs13K.mjs";const T=e=>new Promise(t=>setTimeout(t,e));async function E(e,t={}){let n=Math.max(1,t.attempts??6),r=t.delay??T,i=Math.max(0,t.delayMs??100);for(let a=0;a<n;a+=1){if(t.signal?.aborted||t.isCancelled?.())return!1;let o=await e();if(t.signal?.aborted||t.isCancelled?.())return!1;if(o)return!0;a+1<n&&await r(i)}return!1}async function D(p){let y=h(p);if(!y)return s(u({action:`uninstall`,error:{code:`AGENT_NOT_FOUND`,details:{input:p},message:`Unknown agent: ${p}`},target:{kind:`agent`,name:p}}),P);try{return await m(async()=>{let[n,u]=await Promise.all([i(y.name),c(y.name)]);if(!n&&!u)return s(N(p,y),P);let m=await e(y.binaryName),h=n?_(y,n):void 0,b=u?v(u):void 0;if(n&&!h||u&&!b)return s(A(y,`indeterminate-source`,`Cannot resolve provider evidence for ${y.displayName}.`),P);if(h&&b&&!O(h,b))return s(A(y,`conflicting-source`,`Recorded sources disagree for ${y.displayName}.`),P);let x=h??b,S=await k(x);return S.kind===`success`?S.value.kind===`absent`?m?s(A(y,`conflicting-source`,`${y.displayName} is on PATH but its recorded provider target is absent.`),P):C()?s(j(y,`would reconcile stale lifecycle evidence`),P):(n&&await a(y.name),u&&await r(y.name),s(M(y),P)):n?C()?s(j(y,`would uninstall ${y.displayName}`),P):f(n.installType)?(u||await d({...x.target.binaryName?{executableName:x.target.binaryName}:{},kind:`lifecycle-receipt`,providerId:x.providerId,providerTargetId:x.target.id,providerTargetKind:x.target.kind,schemaVersion:1,targetId:y.name,verifiedAt:new Date().toISOString(),...S.value.executablePath?{executablePath:S.value.executablePath}:{},...S.value.version?{version:S.value.version}:{}}),(await g(y,n)).kind===`success`?await E(async()=>{let t=await k(x);return t.kind!==`success`||t.value.kind!==`absent`?!1:!await e(y.binaryName)},{isCancelled:()=>!!t().cancelled})?(await r(y.name),s(l({action:`uninstall`,data:{agent:{displayName:y.displayName,name:y.name},changed:!0},target:{kind:`agent`,name:y.name}}),P)):(await o(n),s(A(y,`verification-failed`,`${y.displayName} is still present after provider removal.`),P)):s(A(y,`provider-failure`,`Failed to uninstall ${y.displayName}.`),P)):(await g(y,n)).kind===`success`?(await r(y.name),s(l({action:`uninstall`,data:{agent:{displayName:y.displayName,name:y.name},changed:!0},target:{kind:`agent`,name:y.name}}),P)):s(A(y,`provider-failure`,`Failed to uninstall ${y.displayName}.`),P):s(A(y,`indeterminate-source`,`Cannot safely reconstruct ${y.displayName}'s uninstall source.`),P):s(A(y,`indeterminate-source`,`Cannot verify provider state for ${y.displayName}.`),P)})}catch(e){if(n(e))return s(u({action:`uninstall`,data:{agent:{displayName:y.displayName,name:y.name},changed:!1},...b(e,{kind:`agent`,name:y.name})}),P);throw e}}function O(e,t){return e.providerId===t.providerId&&e.target.id===t.target.id&&e.target.kind===t.target.kind&&e.target.binaryName===t.target.binaryName}async function k(e){let n=t(),r=new AbortController;return n.cancelled&&r.abort(`cli-cancelled`),y(e,{signal:r.signal,timeoutMs:n.timeoutMs})}function A(e,t,n){return u({action:`uninstall`,data:{agent:{displayName:e.displayName,name:e.name},changed:!1},error:{code:`UNINSTALL_FAILED`,details:{lifecycle:t},message:n},target:{kind:`agent`,name:e.name}})}function j(e,t){return l({action:`uninstall`,data:{agent:{displayName:e.displayName,name:e.name},changed:!1},target:{kind:`agent`,name:e.name},warnings:[{code:`DRY_RUN`,message:`Dry run: ${t}.`}]})}function M(e){return l({action:`uninstall`,data:{agent:{displayName:e.displayName,name:e.name},changed:!0},target:{kind:`agent`,name:e.name},warnings:[{code:`GHOST_STATE_RECONCILED`,message:`${e.displayName} was already absent; stale lifecycle evidence was removed.`}]})}function N(e,t){return u({action:`uninstall`,data:{agent:{displayName:t.displayName,name:t.name},changed:!1},error:{code:`UNINSTALL_UNMANAGED`,details:{canAutoUninstall:!1,displayName:t.displayName,input:e,lifecycle:`unmanaged`,name:t.name},message:`${t.displayName} is not managed by qtx, so qtx cannot auto-uninstall it. Run qtx inspect ${t.name} for details.`},target:{kind:`agent`,name:t.name}})}function P(e){if(e.error){w(p.red(e.error.message));return}if(e.data){if(e.warnings&&e.warnings.length>0){for(let t of e.warnings)x(p.yellow(t.message));return}S(p.cyan(`Uninstalling ${e.data.agent.displayName}...`)),S(p.green(`${e.data.agent.displayName} uninstalled successfully!`))}}export{D as uninstallCommand};
1
+ import{n as e}from"./detect-BdnZzKbm.mjs";import{n as t}from"./cli-context-xudTdmO7.mjs";import{a as n}from"./file-store-Caz7fnAB.mjs";import{F as r,O as i,P as a,R as o,i as s,k as c,n as l,t as u,z as d}from"./output-DQY0YUII.mjs";import{p as f}from"./providers-DHIXHYu1.mjs";import{t as p}from"./color-FZclrXnv.mjs";import{g as m,n as h,p as g}from"./agents-P24fAIzH.mjs";import{a as _,i as v}from"./provider-binding-D1muQsgD.mjs";import{t as y}from"./provider-evidence-B7Yr8c7e.mjs";import{t as b}from"./lifecycle-errors-B0bwmxkB.mjs";import{a as x,i as S,n as C,r as w}from"./user-output-B-zDs13K.mjs";const T=e=>new Promise(t=>setTimeout(t,e));async function E(e,t={}){let n=Math.max(1,t.attempts??6),r=t.delay??T,i=Math.max(0,t.delayMs??100);for(let a=0;a<n;a+=1){if(t.signal?.aborted||t.isCancelled?.())return!1;let o=await e();if(t.signal?.aborted||t.isCancelled?.())return!1;if(o)return!0;a+1<n&&await r(i)}return!1}async function D(p){let y=h(p);if(!y)return s(u({action:`uninstall`,error:{code:`AGENT_NOT_FOUND`,details:{input:p},message:`Unknown agent: ${p}`},target:{kind:`agent`,name:p}}),P);try{return await m(async()=>{let[n,u]=await Promise.all([i(y.name),c(y.name)]);if(!n&&!u)return s(N(p,y),P);let m=await e(y.binaryName),h=n?_(y,n):void 0,b=u?v(u):void 0;if(n&&!h||u&&!b)return s(A(y,`indeterminate-source`,`Cannot resolve provider evidence for ${y.displayName}.`),P);if(h&&b&&!O(h,b))return s(A(y,`conflicting-source`,`Recorded sources disagree for ${y.displayName}.`),P);let x=h??b,S=await k(x);return S.kind===`success`?S.value.kind===`absent`?m?s(A(y,`conflicting-source`,`${y.displayName} is on PATH but its recorded provider target is absent.`),P):C()?s(j(y,`would reconcile stale lifecycle evidence`),P):(n&&await a(y.name),u&&await r(y.name),s(M(y),P)):n?C()?s(j(y,`would uninstall ${y.displayName}`),P):f(n.installType)?(u||await d({...x.target.binaryName?{executableName:x.target.binaryName}:{},kind:`lifecycle-receipt`,providerId:x.providerId,providerTargetId:x.target.id,providerTargetKind:x.target.kind,schemaVersion:1,targetId:y.name,verifiedAt:new Date().toISOString(),...S.value.executablePath?{executablePath:S.value.executablePath}:{},...S.value.version?{version:S.value.version}:{}}),(await g(y,n)).kind===`success`?await E(async()=>{let t=await k(x);return t.kind!==`success`||t.value.kind!==`absent`?!1:!await e(y.binaryName)},{isCancelled:()=>!!t().cancelled})?(await r(y.name),s(l({action:`uninstall`,data:{agent:{displayName:y.displayName,name:y.name},changed:!0},target:{kind:`agent`,name:y.name}}),P)):(await o(n),s(A(y,`verification-failed`,`${y.displayName} is still present after provider removal.`),P)):s(A(y,`provider-failure`,`Failed to uninstall ${y.displayName}.`),P)):(await g(y,n)).kind===`success`?(await r(y.name),s(l({action:`uninstall`,data:{agent:{displayName:y.displayName,name:y.name},changed:!0},target:{kind:`agent`,name:y.name}}),P)):s(A(y,`provider-failure`,`Failed to uninstall ${y.displayName}.`),P):s(A(y,`indeterminate-source`,`Cannot safely reconstruct ${y.displayName}'s uninstall source.`),P):s(A(y,`indeterminate-source`,`Cannot verify provider state for ${y.displayName}.`),P)})}catch(e){if(n(e))return s(u({action:`uninstall`,data:{agent:{displayName:y.displayName,name:y.name},changed:!1},...b(e,{kind:`agent`,name:y.name})}),P);throw e}}function O(e,t){return e.providerId===t.providerId&&e.target.id===t.target.id&&e.target.kind===t.target.kind&&e.target.binaryName===t.target.binaryName}async function k(e){let n=t(),r=new AbortController;return n.cancelled&&r.abort(`cli-cancelled`),y(e,{signal:r.signal,timeoutMs:n.timeoutMs})}function A(e,t,n){return u({action:`uninstall`,data:{agent:{displayName:e.displayName,name:e.name},changed:!1},error:{code:`UNINSTALL_FAILED`,details:{lifecycle:t},message:n},target:{kind:`agent`,name:e.name}})}function j(e,t){return l({action:`uninstall`,data:{agent:{displayName:e.displayName,name:e.name},changed:!1},target:{kind:`agent`,name:e.name},warnings:[{code:`DRY_RUN`,message:`Dry run: ${t}.`}]})}function M(e){return l({action:`uninstall`,data:{agent:{displayName:e.displayName,name:e.name},changed:!0},target:{kind:`agent`,name:e.name},warnings:[{code:`GHOST_STATE_RECONCILED`,message:`${e.displayName} was already absent; stale lifecycle evidence was removed.`}]})}function N(e,t){return u({action:`uninstall`,data:{agent:{displayName:t.displayName,name:t.name},changed:!1},error:{code:`UNINSTALL_UNMANAGED`,details:{canAutoUninstall:!1,displayName:t.displayName,input:e,lifecycle:`unmanaged`,name:t.name},message:`${t.displayName} is not managed by qtx, so qtx cannot auto-uninstall it. Run qtx inspect ${t.name} for details.`},target:{kind:`agent`,name:t.name}})}function P(e){if(e.error){w(p.red(e.error.message));return}if(e.data){if(e.warnings&&e.warnings.length>0){for(let t of e.warnings)x(p.yellow(t.message));return}S(p.cyan(`Uninstalling ${e.data.agent.displayName}...`)),S(p.green(`${e.data.agent.displayName} uninstalled successfully!`))}}export{D as uninstallCommand};
@@ -1 +1 @@
1
- import{n as e}from"./detect-BdnZzKbm.mjs";import{l as t}from"./providers-D5426cNP.mjs";import{n}from"./agents-DoqAiugw.mjs";import{n as r}from"./lifecycle-observations-C-5fSuCT.mjs";async function i(i){let a=n(i);if(!a||!await e(a.binaryName))return;let o=await r(i);if(!(!o?.pathExecutable.present||o.installedState||o.receipt))return t(o.methods,o.resolvedBinaryPath??o.pathExecutable.path)?void 0:o.agent}export{i as t};
1
+ import{n as e}from"./detect-BdnZzKbm.mjs";import{l as t}from"./providers-DHIXHYu1.mjs";import{n}from"./agents-P24fAIzH.mjs";import{n as r}from"./lifecycle-observations-fWuwyopY.mjs";async function i(i){let a=n(i);if(!a||!await e(a.binaryName))return;let o=await r(i);if(!(!o?.pathExecutable.present||o.installedState||o.receipt))return t(o.methods,o.resolvedBinaryPath??o.pathExecutable.path)?void 0:o.agent}export{i as t};
@@ -1 +1 @@
1
- import{n as e,r as t,t as n}from"./messages-qcLhD-Gc.mjs";import{g as r}from"./npm-fDgYmVes.mjs";import{I as i,r as a}from"./agents-Btib2SO_.mjs";import{n as o}from"./cli-context-xudTdmO7.mjs";import{a as s,d as c}from"./file-store-Caz7fnAB.mjs";import{M as l,i as u,n as d,r as f,t as p}from"./output-7rFW9QE9.mjs";import{r as m}from"./providers-D5426cNP.mjs";import{t as h}from"./cli-operation-context-BhNiJdQ3.mjs";import{t as g}from"./color-FZclrXnv.mjs";import{g as _,n as v}from"./agents-DoqAiugw.mjs";import{t as y}from"./update-planner-DIhkPXeI.mjs";import{t as b}from"./lifecycle-observations-C-5fSuCT.mjs";import{a as x,i as S,n as C,r as w}from"./user-output-B-zDs13K.mjs";import{a as T,c as E,l as D,r as O,s as k,u as A}from"./lifecycle-policy-CqtKQ7HZ.mjs";async function j(e){let t;for(let n of e.commands){let i=await r(n,e.context,`agent self-update failed`);if(i.kind===`success`)return{kind:`success`,value:{evidence:[{kind:`command`,value:n.join(` `)}],target:e.target}};if(i.kind===`cancelled`||i.kind===`timed-out`)return i;t=i}return t??{kind:`unsupported`,operation:`update`,reason:`No self-update command is configured.`}}async function M(){let e=N();try{return await e.run()}finally{e.dispose()}}function N(){let e=h(),t=0,n=!1,r=!1,o,u,d,f,p=()=>{!n||r||t>0||(r=!0,e.dispose())},m=async r=>{if(n)throw Error(`Lifecycle update batch invocation has been disposed.`);t+=1;try{return await e.run(r)}finally{--t,p()}},g=()=>(d??=c().then(t=>{let n=b(e.context);return{classifyMutationLockError:e=>s(e)?{reason:e.message,resource:e.resource}:void 0,clock:()=>new Date().toISOString(),dryRun:C(),executeSelfUpdate:j,listRegisteredAgentNames:()=>a().map(e=>e.name),observe:n.resolveAgentObservation,planLifecycleUpdate:y,providerRegistry:i,registerCleanup:e.context.registerCleanup,signal:e.context.signal,timeoutMs:e.context.timeoutMs,updateOptions:{updateStrategy:t.npmBunUpdateStrategy},withMutationLock:_,writeReceipt:l.write}}),d),v=()=>n?Promise.reject(Error(`Lifecycle update batch invocation has been disposed.`)):(u??=m(async()=>D(await g())),u);return{dispose(){n||(n=!0,p())},getOutcome:()=>o,async observe(e){return m(async()=>(await g()).observe(e))},prepare:v,run(){return n?Promise.reject(Error(`Lifecycle update batch invocation has been disposed.`)):(f??=(async()=>{let e=await v();return o=await m(async()=>k(e,await g())),o})(),f)}}}async function P(e){let t=F(e);try{return await t.run()}finally{t.dispose()}}function F(e){let t=h(),n=0,r=!1,a=!1,o,s,u,d,f=()=>{!r||a||n>0||(a=!0,t.dispose())},p=async e=>{if(r)throw Error(`Single-agent update invocation has been disposed.`);n+=1;try{return await t.run(e)}finally{--n,f()}},m=()=>(u??=c().then(e=>{let n=b(t.context);return{clock:()=>new Date().toISOString(),dryRun:C(),executeSelfUpdate:j,observe:n.resolveAgentObservation,planLifecycleUpdate:y,providerRegistry:i,registerCleanup:t.context.registerCleanup,signal:t.context.signal,timeoutMs:t.context.timeoutMs,updateOptions:{updateStrategy:e.npmBunUpdateStrategy},withMutationLock:_,writeReceipt:l.write}}),u),g=()=>r?Promise.reject(Error(`Single-agent update invocation has been disposed.`)):(s??=p(async()=>A(e,await m())),s);return{dispose(){r||(r=!0,f())},getOutcome:()=>o,async observe(e){return p(async()=>(await m()).observe(e))},prepare:g,run(){return r?Promise.reject(Error(`Single-agent update invocation has been disposed.`)):(d??=(async()=>{let e=await g();return o=e.kind===`planned`?await p(async()=>E(e.planned,await m())):e,o})(),d)}}}async function I(e,t,n={runBatch:M,runSingle:P}){if(t)return R(n);if(!e)return u(p({action:`update`,error:{code:`INVALID_ARGUMENT`,message:`Please specify an agent name or use --all flag`},target:{kind:`agent`}}),Z);let r=v(e);return r?z(r,n):u(p({action:`update`,error:{code:`AGENT_NOT_FOUND`,details:{input:e},message:`Unknown agent: ${e}`},target:{kind:`agent`,name:e}}),Z)}function L(e,t){if(t){let t=N();return{dispose:t.dispose,idempotencyPolicy:()=>O(t),run:()=>I(e,!0,{runBatch:()=>t.run(),runSingle:P})}}if(!e)return{dispose(){},run:()=>I(e,t)};let n=F(e);return{dispose:n.dispose,idempotencyPolicy:()=>T(e,n),run:()=>I(e,!1,{runBatch:M,runSingle:()=>n.run()})}}async function R(e){f({action:`update`,data:{scope:`all`},target:{kind:`agent`},type:`started`});let t=await e.runBatch(),n=H(t),r=G(t);return Y(t)?u(p({action:`update`,data:{results:n,scope:`all`},error:{code:`CANCELLED`,message:`Update was cancelled before all agents could be updated.`},target:{kind:`agent`},warnings:r}),Z):n.some(e=>e.status===`failed`||e.status===`locked`)?u(p({action:`update`,data:{results:n,scope:`all`},error:{code:`UPDATE_FAILED`,message:`One or more agents failed to update.`},target:{kind:`agent`},warnings:r}),Z):u(d({action:`update`,data:{results:n,scope:`all`},target:{kind:`agent`},warnings:r}),Z)}async function z(e,t){f({action:`update`,data:{agent:e.name,scope:`single`},target:{kind:`agent`,name:e.name},type:`started`});let n;try{n=await t.runSingle(e.name)}catch(t){if(!s(t))throw t;return u(p({action:`update`,data:{results:[{displayName:e.displayName,message:t.message,name:e.name,resource:t.resource,status:`locked`}],scope:`single`},error:{code:`RESOURCE_LOCKED`,details:{resource:t.resource},message:t.message},target:{kind:`agent`,name:e.name}}),Z)}let r=V(n);if(n.kind===`unknown-agent`)return u(p({action:`update`,error:{code:`AGENT_NOT_FOUND`,message:`Unknown agent: ${e.name}`},target:{kind:`agent`,name:e.name}}),Z);if(r?.observation.kind===`absent`){let t=r.observation.drift.kind===`recorded-absent`?[K(e)]:[];return u(p({action:`update`,error:{code:`AGENT_NOT_INSTALLED`,message:`${e.displayName} is not installed.`},target:{kind:`agent`,name:e.name},warnings:t}),Z)}let i=B(e,n);return X([],i),n.kind===`cancelled`?u(p({action:`update`,data:{results:[i],scope:`single`},error:{code:`CANCELLED`,message:`Update of ${e.displayName} was cancelled.`},target:{kind:`agent`,name:e.name}}),Z):i.status===`failed`||i.status===`locked`?u(p({action:`update`,data:{results:[i],scope:`single`},error:{code:`UPDATE_FAILED`,message:`Failed to update ${e.displayName}.`},target:{kind:`agent`,name:e.name}}),Z):u(d({action:`update`,data:{results:[i],scope:`single`},target:{kind:`agent`,name:e.name}}),Z)}function B(n,r){let i=V(r),a=`plan`in r?r.plan:void 0,o=i?.observation.kind===`present`?i.observation.version:void 0,s=q(a),c=J(a)??i?.binding?.providerId;switch(r.kind){case`updated`:return{displayName:n.displayName,installedVersion:o,latestVersion:r.receipt.version??s,name:n.name,status:`updated`,strategy:c};case`up-to-date`:return{displayName:n.displayName,installedVersion:r.receipt.version??o,name:n.name,status:`up-to-date`,strategy:c};case`dry-run`:return{displayName:n.displayName,installedVersion:o,latestVersion:s,message:`Dry run: would update ${n.displayName}.`,name:n.name,status:`planned`,strategy:c};case`not-executed`:return r.plan.planning.decision===`up-to-date`?{displayName:n.displayName,installedVersion:o,latestVersion:s,name:n.name,status:`up-to-date`}:{displayName:n.displayName,installedVersion:o,latestVersion:s,message:e(n),name:n.name,status:`manual-required`};case`blocked`:return r.category===`untracked`?{displayName:n.displayName,installedVersion:o,message:t(n),name:n.name,status:`manual-required`}:r.category===`manual-required`?{displayName:n.displayName,installedVersion:o,message:e(n),name:n.name,status:`manual-required`}:{displayName:n.displayName,installedVersion:o,message:r.reason,name:n.name,status:`failed`};case`cancelled`:return{displayName:n.displayName,installedVersion:o,latestVersion:s,message:r.reason??`Update was cancelled before it could complete.`,name:n.name,status:`failed`,strategy:c};case`timed-out`:return{displayName:n.displayName,installedVersion:o,latestVersion:s,message:`Update timed out after ${r.timeoutMs}ms.`,name:n.name,status:`failed`,strategy:c};case`provider-failed`:return{displayName:n.displayName,installedVersion:o,latestVersion:s,name:n.name,status:`failed`,strategy:c};case`verification-failed`:case`receipt-failed`:return{displayName:n.displayName,installedVersion:o,latestVersion:s,message:r.kind===`receipt-failed`?r.reason:r.verification.reason,name:n.name,status:`failed`,strategy:c};case`unknown-agent`:return{displayName:n.displayName,name:n.name,status:`failed`}}}function V(e){if(`plan`in e)return e.plan.before;if(`before`in e)return e.before}function H(e){let t=new Map(e.results.map(e=>[e.id,e])),n=new Map(e.cancellationRemainder.map(e=>[e.id,e])),r=[];for(let i of e.plan.targets){let e=t.get(i.id),a=n.get(i.id);if(e){let t=U(e);t&&X(r,t)}else a&&X(r,W(a))}return r}function U(e){let t=e.planning.kind===`unknown-agent`?void 0:e.planning.kind===`planned`?e.planning.planned.before:e.planning.before,r=v(e.agentName);if(!r)return{displayName:t?.agent.displayName??e.agentName,name:e.agentName,status:`failed`};let i=e.execution;if(e.planning.kind===`blocked`&&e.planning.category===`stale-state`)return;if(i?.kind===`locked`)return{displayName:r.displayName,installedVersion:i.plan.before.observation.kind===`present`?i.plan.before.observation.version:void 0,latestVersion:q(i.plan),message:i.reason,name:r.name,resource:i.resource,status:`locked`,strategy:J(i.plan)};if(i?.kind===`unexpected-failure`)return{displayName:r.displayName,installedVersion:i.plan.before.observation.kind===`present`?i.plan.before.observation.version:void 0,latestVersion:q(i.plan),message:i.reason,name:r.name,status:`failed`,strategy:J(i.plan)};let a=i??(e.planning.kind===`planned`?{kind:`not-executed`,plan:e.planning.planned}:e.planning),o=B(r,a);return o.status===`failed`&&a.kind===`provider-failed`&&(o.hint=n(r,m({agent:r,installedState:t?.installedState,methods:[...t?.methods??[]]}))),o}function W(e){let t=v(e.agentName),n=e.planning.planned.before;return{displayName:t?.displayName??n.agent.displayName,installedVersion:n.observation.kind===`present`?n.observation.version:void 0,latestVersion:q(e.planning.planned),message:e.reason??`Update was cancelled before it could start.`,name:t?.name??e.agentName,status:`failed`,strategy:J(e.planning.planned)}}function G(e){return e.plan.targets.flatMap(e=>e.outcome.kind!==`blocked`||e.outcome.category!==`stale-state`?[]:[K(v(e.agentName)??e.outcome.before.agent)])}function K(e){return{code:`AGENT_STALE_STATE`,details:{agentName:e.name,suggestedAction:`reconcile-agent-state`,suggestedCommands:[`quantex uninstall ${e.name}`]},message:`${e.displayName} is not installed but has stale lifecycle evidence. Run \`quantex uninstall ${e.name}\` to reconcile it.`}}function q(e){return e?.strategy===`managed-provider`?e.plannedTargetVersion:void 0}function J(e){if(e)return e.strategy===`self-update`?`self-update`:`managed/${e.binding.providerId}`}function Y(e){return o().cancelled||e.cancellationRemainder.length>0||e.results.some(e=>e.planning.kind===`cancelled`||e.execution?.kind===`cancelled`)}function X(e,t){e.push(t),f({action:`update`,data:t,target:{kind:`agent`,name:t.name},type:`progress`})}function Z(e){if(!e.data){e.error&&w(g.red(e.error.message));return}for(let t of e.warnings)x(g.yellow(t.message));for(let t of e.data.results)switch(t.status){case`up-to-date`:S(g.green(`${t.displayName} is up to date (${t.installedVersion??`unknown`})`));break;case`manual-required`:x(g.yellow(`${t.displayName}: manual action required.`)),t.message&&x(g.cyan(`Next step: ${t.message}`));break;case`planned`:x(g.cyan(`Would update ${t.displayName}${t.strategy?` via ${t.strategy}`:``}${Q(t.installedVersion,t.latestVersion)}`));break;case`updated`:S(g.cyan(`Updating ${t.displayName}${t.strategy?` via ${t.strategy}`:``}...${Q(t.installedVersion,t.latestVersion)}`)),S(g.green(`${t.displayName} updated successfully!`));break;case`failed`:S(g.cyan(`Updating ${t.displayName}${t.strategy?` via ${t.strategy}`:``}...${Q(t.installedVersion,t.latestVersion)}`)),w(g.red(`Failed to update ${t.displayName}.`)),t.hint&&x(g.cyan(`Next step: ${t.hint}`));break;case`locked`:x(g.yellow(t.message??`Another quantex process is already updating ${t.displayName}.`));break}e.data.results.length>1&&$(e.data.results),!e.data.results.length&&e.error&&w(g.red(e.error.message))}function Q(e,t){return e?` (${e} -> ${t??`latest`})`:``}function $(e){let t={failed:0,locked:0,manualRequired:0,planned:0,upToDate:0,updated:0};for(let n of e)switch(n.status){case`up-to-date`:t.upToDate+=1;break;case`manual-required`:t.manualRequired+=1;break;case`planned`:t.planned+=1;break;case`updated`:t.updated+=1;break;case`failed`:t.failed+=1;break;case`locked`:t.locked+=1;break}let n=[t.updated?`updated ${t.updated}`:void 0,t.upToDate?`up to date ${t.upToDate}`:void 0,t.manualRequired?`manual ${t.manualRequired}`:void 0,t.failed?`failed ${t.failed}`:void 0,t.locked?`locked ${t.locked}`:void 0,t.planned?`planned ${t.planned}`:void 0].filter(Boolean);n.length>0&&S(g.bold(`Summary: ${n.join(`, `)}`))}export{L as createUpdateCommandInvocation};
1
+ import{n as e,r as t,t as n}from"./messages-qcLhD-Gc.mjs";import{g as r}from"./npm-fDgYmVes.mjs";import{I as i,r as a}from"./agents-BbEquU_b.mjs";import{n as o}from"./cli-context-xudTdmO7.mjs";import{a as s,d as c}from"./file-store-Caz7fnAB.mjs";import{M as l,i as u,n as d,r as f,t as p}from"./output-DQY0YUII.mjs";import{r as m}from"./providers-DHIXHYu1.mjs";import{t as h}from"./cli-operation-context-BhNiJdQ3.mjs";import{t as g}from"./color-FZclrXnv.mjs";import{g as _,n as v}from"./agents-P24fAIzH.mjs";import{t as y}from"./update-planner-DIhkPXeI.mjs";import{t as b}from"./lifecycle-observations-fWuwyopY.mjs";import{a as x,i as S,n as C,r as w}from"./user-output-B-zDs13K.mjs";import{a as T,c as E,l as D,r as O,s as k,u as A}from"./lifecycle-policy-Cdmy_5EZ.mjs";async function j(e){let t;for(let n of e.commands){let i=await r(n,e.context,`agent self-update failed`);if(i.kind===`success`)return{kind:`success`,value:{evidence:[{kind:`command`,value:n.join(` `)}],target:e.target}};if(i.kind===`cancelled`||i.kind===`timed-out`)return i;t=i}return t??{kind:`unsupported`,operation:`update`,reason:`No self-update command is configured.`}}async function M(){let e=N();try{return await e.run()}finally{e.dispose()}}function N(){let e=h(),t=0,n=!1,r=!1,o,u,d,f,p=()=>{!n||r||t>0||(r=!0,e.dispose())},m=async r=>{if(n)throw Error(`Lifecycle update batch invocation has been disposed.`);t+=1;try{return await e.run(r)}finally{--t,p()}},g=()=>(d??=c().then(t=>{let n=b(e.context);return{classifyMutationLockError:e=>s(e)?{reason:e.message,resource:e.resource}:void 0,clock:()=>new Date().toISOString(),dryRun:C(),executeSelfUpdate:j,listRegisteredAgentNames:()=>a().map(e=>e.name),observe:n.resolveAgentObservation,planLifecycleUpdate:y,providerRegistry:i,registerCleanup:e.context.registerCleanup,signal:e.context.signal,timeoutMs:e.context.timeoutMs,updateOptions:{updateStrategy:t.npmBunUpdateStrategy},withMutationLock:_,writeReceipt:l.write}}),d),v=()=>n?Promise.reject(Error(`Lifecycle update batch invocation has been disposed.`)):(u??=m(async()=>D(await g())),u);return{dispose(){n||(n=!0,p())},getOutcome:()=>o,async observe(e){return m(async()=>(await g()).observe(e))},prepare:v,run(){return n?Promise.reject(Error(`Lifecycle update batch invocation has been disposed.`)):(f??=(async()=>{let e=await v();return o=await m(async()=>k(e,await g())),o})(),f)}}}async function P(e){let t=F(e);try{return await t.run()}finally{t.dispose()}}function F(e){let t=h(),n=0,r=!1,a=!1,o,s,u,d,f=()=>{!r||a||n>0||(a=!0,t.dispose())},p=async e=>{if(r)throw Error(`Single-agent update invocation has been disposed.`);n+=1;try{return await t.run(e)}finally{--n,f()}},m=()=>(u??=c().then(e=>{let n=b(t.context);return{clock:()=>new Date().toISOString(),dryRun:C(),executeSelfUpdate:j,observe:n.resolveAgentObservation,planLifecycleUpdate:y,providerRegistry:i,registerCleanup:t.context.registerCleanup,signal:t.context.signal,timeoutMs:t.context.timeoutMs,updateOptions:{updateStrategy:e.npmBunUpdateStrategy},withMutationLock:_,writeReceipt:l.write}}),u),g=()=>r?Promise.reject(Error(`Single-agent update invocation has been disposed.`)):(s??=p(async()=>A(e,await m())),s);return{dispose(){r||(r=!0,f())},getOutcome:()=>o,async observe(e){return p(async()=>(await m()).observe(e))},prepare:g,run(){return r?Promise.reject(Error(`Single-agent update invocation has been disposed.`)):(d??=(async()=>{let e=await g();return o=e.kind===`planned`?await p(async()=>E(e.planned,await m())):e,o})(),d)}}}async function I(e,t,n={runBatch:M,runSingle:P}){if(t)return R(n);if(!e)return u(p({action:`update`,error:{code:`INVALID_ARGUMENT`,message:`Please specify an agent name or use --all flag`},target:{kind:`agent`}}),Z);let r=v(e);return r?z(r,n):u(p({action:`update`,error:{code:`AGENT_NOT_FOUND`,details:{input:e},message:`Unknown agent: ${e}`},target:{kind:`agent`,name:e}}),Z)}function L(e,t){if(t){let t=N();return{dispose:t.dispose,idempotencyPolicy:()=>O(t),run:()=>I(e,!0,{runBatch:()=>t.run(),runSingle:P})}}if(!e)return{dispose(){},run:()=>I(e,t)};let n=F(e);return{dispose:n.dispose,idempotencyPolicy:()=>T(e,n),run:()=>I(e,!1,{runBatch:M,runSingle:()=>n.run()})}}async function R(e){f({action:`update`,data:{scope:`all`},target:{kind:`agent`},type:`started`});let t=await e.runBatch(),n=H(t),r=G(t);return Y(t)?u(p({action:`update`,data:{results:n,scope:`all`},error:{code:`CANCELLED`,message:`Update was cancelled before all agents could be updated.`},target:{kind:`agent`},warnings:r}),Z):n.some(e=>e.status===`failed`||e.status===`locked`)?u(p({action:`update`,data:{results:n,scope:`all`},error:{code:`UPDATE_FAILED`,message:`One or more agents failed to update.`},target:{kind:`agent`},warnings:r}),Z):u(d({action:`update`,data:{results:n,scope:`all`},target:{kind:`agent`},warnings:r}),Z)}async function z(e,t){f({action:`update`,data:{agent:e.name,scope:`single`},target:{kind:`agent`,name:e.name},type:`started`});let n;try{n=await t.runSingle(e.name)}catch(t){if(!s(t))throw t;return u(p({action:`update`,data:{results:[{displayName:e.displayName,message:t.message,name:e.name,resource:t.resource,status:`locked`}],scope:`single`},error:{code:`RESOURCE_LOCKED`,details:{resource:t.resource},message:t.message},target:{kind:`agent`,name:e.name}}),Z)}let r=V(n);if(n.kind===`unknown-agent`)return u(p({action:`update`,error:{code:`AGENT_NOT_FOUND`,message:`Unknown agent: ${e.name}`},target:{kind:`agent`,name:e.name}}),Z);if(r?.observation.kind===`absent`){let t=r.observation.drift.kind===`recorded-absent`?[K(e)]:[];return u(p({action:`update`,error:{code:`AGENT_NOT_INSTALLED`,message:`${e.displayName} is not installed.`},target:{kind:`agent`,name:e.name},warnings:t}),Z)}let i=B(e,n);return X([],i),n.kind===`cancelled`?u(p({action:`update`,data:{results:[i],scope:`single`},error:{code:`CANCELLED`,message:`Update of ${e.displayName} was cancelled.`},target:{kind:`agent`,name:e.name}}),Z):i.status===`failed`||i.status===`locked`?u(p({action:`update`,data:{results:[i],scope:`single`},error:{code:`UPDATE_FAILED`,message:`Failed to update ${e.displayName}.`},target:{kind:`agent`,name:e.name}}),Z):u(d({action:`update`,data:{results:[i],scope:`single`},target:{kind:`agent`,name:e.name}}),Z)}function B(n,r){let i=V(r),a=`plan`in r?r.plan:void 0,o=i?.observation.kind===`present`?i.observation.version:void 0,s=q(a),c=J(a)??i?.binding?.providerId;switch(r.kind){case`updated`:return{displayName:n.displayName,installedVersion:o,latestVersion:r.receipt.version??s,name:n.name,status:`updated`,strategy:c};case`up-to-date`:return{displayName:n.displayName,installedVersion:r.receipt.version??o,name:n.name,status:`up-to-date`,strategy:c};case`dry-run`:return{displayName:n.displayName,installedVersion:o,latestVersion:s,message:`Dry run: would update ${n.displayName}.`,name:n.name,status:`planned`,strategy:c};case`not-executed`:return r.plan.planning.decision===`up-to-date`?{displayName:n.displayName,installedVersion:o,latestVersion:s,name:n.name,status:`up-to-date`}:{displayName:n.displayName,installedVersion:o,latestVersion:s,message:e(n),name:n.name,status:`manual-required`};case`blocked`:return r.category===`untracked`?{displayName:n.displayName,installedVersion:o,message:t(n),name:n.name,status:`manual-required`}:r.category===`manual-required`?{displayName:n.displayName,installedVersion:o,message:e(n),name:n.name,status:`manual-required`}:{displayName:n.displayName,installedVersion:o,message:r.reason,name:n.name,status:`failed`};case`cancelled`:return{displayName:n.displayName,installedVersion:o,latestVersion:s,message:r.reason??`Update was cancelled before it could complete.`,name:n.name,status:`failed`,strategy:c};case`timed-out`:return{displayName:n.displayName,installedVersion:o,latestVersion:s,message:`Update timed out after ${r.timeoutMs}ms.`,name:n.name,status:`failed`,strategy:c};case`provider-failed`:return{displayName:n.displayName,installedVersion:o,latestVersion:s,name:n.name,status:`failed`,strategy:c};case`verification-failed`:case`receipt-failed`:return{displayName:n.displayName,installedVersion:o,latestVersion:s,message:r.kind===`receipt-failed`?r.reason:r.verification.reason,name:n.name,status:`failed`,strategy:c};case`unknown-agent`:return{displayName:n.displayName,name:n.name,status:`failed`}}}function V(e){if(`plan`in e)return e.plan.before;if(`before`in e)return e.before}function H(e){let t=new Map(e.results.map(e=>[e.id,e])),n=new Map(e.cancellationRemainder.map(e=>[e.id,e])),r=[];for(let i of e.plan.targets){let e=t.get(i.id),a=n.get(i.id);if(e){let t=U(e);t&&X(r,t)}else a&&X(r,W(a))}return r}function U(e){let t=e.planning.kind===`unknown-agent`?void 0:e.planning.kind===`planned`?e.planning.planned.before:e.planning.before,r=v(e.agentName);if(!r)return{displayName:t?.agent.displayName??e.agentName,name:e.agentName,status:`failed`};let i=e.execution;if(e.planning.kind===`blocked`&&e.planning.category===`stale-state`)return;if(i?.kind===`locked`)return{displayName:r.displayName,installedVersion:i.plan.before.observation.kind===`present`?i.plan.before.observation.version:void 0,latestVersion:q(i.plan),message:i.reason,name:r.name,resource:i.resource,status:`locked`,strategy:J(i.plan)};if(i?.kind===`unexpected-failure`)return{displayName:r.displayName,installedVersion:i.plan.before.observation.kind===`present`?i.plan.before.observation.version:void 0,latestVersion:q(i.plan),message:i.reason,name:r.name,status:`failed`,strategy:J(i.plan)};let a=i??(e.planning.kind===`planned`?{kind:`not-executed`,plan:e.planning.planned}:e.planning),o=B(r,a);return o.status===`failed`&&a.kind===`provider-failed`&&(o.hint=n(r,m({agent:r,installedState:t?.installedState,methods:[...t?.methods??[]]}))),o}function W(e){let t=v(e.agentName),n=e.planning.planned.before;return{displayName:t?.displayName??n.agent.displayName,installedVersion:n.observation.kind===`present`?n.observation.version:void 0,latestVersion:q(e.planning.planned),message:e.reason??`Update was cancelled before it could start.`,name:t?.name??e.agentName,status:`failed`,strategy:J(e.planning.planned)}}function G(e){return e.plan.targets.flatMap(e=>e.outcome.kind!==`blocked`||e.outcome.category!==`stale-state`?[]:[K(v(e.agentName)??e.outcome.before.agent)])}function K(e){return{code:`AGENT_STALE_STATE`,details:{agentName:e.name,suggestedAction:`reconcile-agent-state`,suggestedCommands:[`quantex uninstall ${e.name}`]},message:`${e.displayName} is not installed but has stale lifecycle evidence. Run \`quantex uninstall ${e.name}\` to reconcile it.`}}function q(e){return e?.strategy===`managed-provider`?e.plannedTargetVersion:void 0}function J(e){if(e)return e.strategy===`self-update`?`self-update`:`managed/${e.binding.providerId}`}function Y(e){return o().cancelled||e.cancellationRemainder.length>0||e.results.some(e=>e.planning.kind===`cancelled`||e.execution?.kind===`cancelled`)}function X(e,t){e.push(t),f({action:`update`,data:t,target:{kind:`agent`,name:t.name},type:`progress`})}function Z(e){if(!e.data){e.error&&w(g.red(e.error.message));return}for(let t of e.warnings)x(g.yellow(t.message));for(let t of e.data.results)switch(t.status){case`up-to-date`:S(g.green(`${t.displayName} is up to date (${t.installedVersion??`unknown`})`));break;case`manual-required`:x(g.yellow(`${t.displayName}: manual action required.`)),t.message&&x(g.cyan(`Next step: ${t.message}`));break;case`planned`:x(g.cyan(`Would update ${t.displayName}${t.strategy?` via ${t.strategy}`:``}${Q(t.installedVersion,t.latestVersion)}`));break;case`updated`:S(g.cyan(`Updating ${t.displayName}${t.strategy?` via ${t.strategy}`:``}...${Q(t.installedVersion,t.latestVersion)}`)),S(g.green(`${t.displayName} updated successfully!`));break;case`failed`:S(g.cyan(`Updating ${t.displayName}${t.strategy?` via ${t.strategy}`:``}...${Q(t.installedVersion,t.latestVersion)}`)),w(g.red(`Failed to update ${t.displayName}.`)),t.hint&&x(g.cyan(`Next step: ${t.hint}`));break;case`locked`:x(g.yellow(t.message??`Another quantex process is already updating ${t.displayName}.`));break}e.data.results.length>1&&$(e.data.results),!e.data.results.length&&e.error&&w(g.red(e.error.message))}function Q(e,t){return e?` (${e} -> ${t??`latest`})`:``}function $(e){let t={failed:0,locked:0,manualRequired:0,planned:0,upToDate:0,updated:0};for(let n of e)switch(n.status){case`up-to-date`:t.upToDate+=1;break;case`manual-required`:t.manualRequired+=1;break;case`planned`:t.planned+=1;break;case`updated`:t.updated+=1;break;case`failed`:t.failed+=1;break;case`locked`:t.locked+=1;break}let n=[t.updated?`updated ${t.updated}`:void 0,t.upToDate?`up to date ${t.upToDate}`:void 0,t.manualRequired?`manual ${t.manualRequired}`:void 0,t.failed?`failed ${t.failed}`:void 0,t.locked?`locked ${t.locked}`:void 0,t.planned?`planned ${t.planned}`:void 0].filter(Boolean);n.length>0&&S(g.bold(`Summary: ${n.join(`, `)}`))}export{L as createUpdateCommandInvocation};
@@ -1 +1 @@
1
- import{c as e,o as t,t as n}from"./child-process-CBKnpMWt.mjs";import{s as r}from"./schema-hCKyxJjR.mjs";import{i,n as a}from"./cli-context-xudTdmO7.mjs";import{E as o,c as s,i as c,n as l,t as u,u as d,v as f,x as p,y as m}from"./output-7rFW9QE9.mjs";import{t as h}from"./color-FZclrXnv.mjs";import{a as g,i as _,n as v,r as y}from"./user-output-B-zDs13K.mjs";import{n as b,t as x}from"./version-cache-C5F6SycS.mjs";const S={platform:process.platform,spawn:(e,n)=>t(e,{...n,stdio:n.stdio?[...n.stdio]:void 0}),terminate:e,writeStderr:e=>{process.stderr.write(e)}};function C(e=S){let t=b(e);return{run:e=>t.run({...e,forwardPipedOutput:e.forwardPipedOutput??!1})}}const w={fetch:globalThis.fetch.bind(globalThis)};function T(e=w){return{async request(t){if(t.signal.aborted)return E(t.signal);let n=new AbortController,r,i,a=!1,o=new Promise(e=>i=e),s=e=>{a||(a=!0,n.abort(),i(e))},c=()=>s(E(t.signal));t.signal.addEventListener(`abort`,c,{once:!0}),t.signal.aborted&&c(),t.timeoutMs!==void 0&&(r=setTimeout(()=>s(D(`timed-out`,`Network request timed out after ${t.timeoutMs}ms.`)),t.timeoutMs));let l=Promise.resolve().then(async()=>{let r=await e.fetch(t.url,{body:t.body,headers:t.headers,method:t.method,signal:n.signal}),i={};return r.headers.forEach((e,t)=>i[t.toLowerCase()]=e),{kind:`success`,value:{body:new Uint8Array(await r.arrayBuffer()),headers:i,status:r.status}}}).catch(e=>t.signal.aborted?E(t.signal):n.signal.aborted&&t.timeoutMs!==void 0?D(`timed-out`,`Network request timed out after ${t.timeoutMs}ms.`):D(`failed`,e instanceof Error?e.message:`Network request failed.`));try{return await Promise.race([l,o])}finally{a=!0,r&&clearTimeout(r),t.signal.removeEventListener(`abort`,c)}}}}function E(e){return D(`cancelled`,e.reason instanceof Error?e.reason.message:String(e.reason??`Network request was cancelled.`))}function D(e,t){return{error:{kind:e,message:t},kind:`failure`}}function O(e){let t=new AbortController,n=new Set,r=Object.freeze({cacheMode:e.cacheMode??`default`,dryRun:e.dryRun??!1,outputMode:e.outputMode??`human`,quiet:e.quiet??!1,timeoutMs:e.timeoutMs}),i=Object.freeze({...e.ports}),a;return{options:r,ports:i,signal:t.signal,cancel(e){if(a)return a;let r;a=new Promise(e=>{r=e}),t.abort(e);let i=[...n];return n.clear(),Promise.allSettled(i.map(t=>Promise.resolve().then(()=>t(e)))).then(()=>r()),a},onCancel(e){return t.signal.aborted?()=>void 0:(n.add(e),()=>{n.delete(e)})}}}async function k(e,t,n){if(t.signal.aborted)return A();let r=await n.plan({context:{signal:t.signal,timeoutMs:t.options.timeoutMs},metadataCache:t.ports.cache,metadataCacheMode:t.options.cacheMode===`no-cache`?`no-cache`:`refresh`,networkPort:t.ports.network,persistencePort:t.ports.persistence,updateChannel:e.updateChannel});return t.signal.aborted?A(r):e.check||e.dryRun||r.status!==`update-available`?{kind:`planned`,plan:r}:{kind:`executed`,plan:r,result:await n.upgrade(r,{lockPort:t.ports.locks,networkPort:t.ports.network,processPort:t.ports.process,signal:t.signal,stdio:t.options.outputMode===`human`?[`inherit`,`inherit`,`inherit`]:[`ignore`,`pipe`,`pipe`],timeoutMs:t.options.timeoutMs})}}function A(e){return{error:{kind:`cancelled`,message:`Self-upgrade invocation was cancelled.`},kind:`interrupted`,...e?{plan:e}:{}}}function j(){let e=a(),t=O({cacheMode:e.cacheMode,dryRun:e.dryRun,outputMode:e.outputMode,ports:M(),quiet:e.quiet,timeoutMs:e.timeoutMs});e.cancelled&&t.cancel(`cancelled`);let n=i(()=>t.cancel(`cancelled`)),r=!1,o={plan:e=>m({context:e.context,metadataCache:e.metadataCache,metadataCacheMode:e.metadataCacheMode,networkPort:e.networkPort,persistencePort:e.persistencePort,updateChannel:e.updateChannel}),upgrade:(e,t)=>s(e,t)};return{dispose(){r||(r=!0,n())},run:e=>k(e,t,o)}}function M(){return{cache:x(),clock:{now:Date.now,sleep:N},fileSystem:{makeDirectory:N,readFile:N,remove:N,rename:N,writeFile:N},locks:p(),network:T(),persistence:o(),process:C()}}async function N(){return{error:{kind:`unavailable`,message:`Runtime port is not bound for this self-upgrade operation.`},kind:`failure`}}function P(e){if(e===`stable`||e===`beta`)return e}async function F(e={}){let t=v(),r=j(),i=await r.run({check:e.check??!1,dryRun:t,updateChannel:e.channel}).finally(()=>r.dispose());if(i.kind===`interrupted`)throw new n({kind:`cancelled`,reason:i.error.message});let a=i.plan,o=f(a),s=L(o),p=z(o);if(a.status===`up-to-date`)return c(l({action:`upgrade`,data:{canAutoUpdate:o.canAutoUpdate,channel:o.updateChannel,currentVersion:o.currentVersion,installSource:o.installSource,latestVersion:o.latestVersion,status:`up-to-date`},target:{kind:`self`,name:`quantex`},warnings:[...s,...p?[p]:[]]}),I);if(e.check||t)return a.status===`update-available`?c(l({action:`upgrade`,data:{canAutoUpdate:o.canAutoUpdate,channel:o.updateChannel,currentVersion:o.currentVersion,installSource:o.installSource,latestVersion:o.latestVersion,status:`update-available`},exitCode:e.check?1:void 0,target:{kind:`self`,name:`quantex`},warnings:[...s,...p?[p]:[],...t?[{code:`DRY_RUN`,message:`Dry run: would upgrade Quantex CLI.`}]:[]]}),I):c(u({action:`upgrade`,data:{canAutoUpdate:o.canAutoUpdate,channel:o.updateChannel,currentVersion:o.currentVersion,installSource:o.installSource,status:`check-unavailable`},error:{code:`NETWORK_ERROR`,message:`Unable to determine the latest Quantex CLI version.`},target:{kind:`self`,name:`quantex`},warnings:[...s,...p?[p]:[]]}),I);if(a.status===`manual-required`){let e=d(o);return c(u({action:`upgrade`,data:{canAutoUpdate:o.canAutoUpdate,channel:o.updateChannel,currentVersion:o.currentVersion,installSource:o.installSource,latestVersion:o.latestVersion,recoveryHint:e,status:`manual-required`},error:{code:`MANUAL_ACTION_REQUIRED`,message:`Quantex CLI cannot auto-update from the current install source: ${o.installSource}.`},target:{kind:`self`,name:`quantex`},warnings:[...s,...p?[p]:[]]}),I)}if(i.kind!==`executed`)throw Error(`Self-upgrade execution did not produce a result.`);let m=i.result;if(m.success)return c(l({action:`upgrade`,data:{canAutoUpdate:o.canAutoUpdate,channel:o.updateChannel,currentVersion:o.currentVersion,installSource:o.installSource,latestVersion:o.latestVersion,status:`updated`},target:{kind:`self`,name:`quantex`},warnings:[...s,...p?[p]:[]]}),I);let h=d(o,m);return c(u({action:`upgrade`,data:{canAutoUpdate:o.canAutoUpdate,channel:o.updateChannel,currentVersion:o.currentVersion,installSource:o.installSource,latestVersion:o.latestVersion,recoveryHint:h,status:`manual-required`},error:{code:`UPGRADE_FAILED`,details:m.error?.kind?{kind:m.error.kind}:void 0,message:m.error?.message??`Failed to upgrade Quantex CLI.`},target:{kind:`self`,name:`quantex`},warnings:[...s,...h?[{code:`MANUAL_RECOVERY`,message:`Manual recovery: ${h}`}]:[]]}),I)}function I(e){if(!e.data){e.error&&y(h.red(e.error.message));return}if(e.data.status===`up-to-date`){_(h.green(`Quantex CLI is already up to date (${e.data.currentVersion}).`)),R(e.warnings);return}if(e.data.status===`update-available`){let t=e.warnings.some(e=>e.message.includes(`Dry run`))?`Dry run: `:``;g(h.yellow(`${t}Update available for Quantex CLI: ${e.data.currentVersion} -> ${e.data.latestVersion} (${e.data.channel}).`)),R(e.warnings);return}if(e.data.status===`check-unavailable`){e.error&&g(h.yellow(e.error.message)),R(e.warnings);return}if(e.data.status===`manual-required`&&e.error?.code===`MANUAL_ACTION_REQUIRED`){g(h.yellow(e.error.message)),e.data.recoveryHint&&g(h.cyan(`Next step: ${e.data.recoveryHint}`));return}let t=e.data.latestVersion?` (${e.data.currentVersion} -> ${e.data.latestVersion})`:` (${e.data.currentVersion})`;if(_(h.cyan(`Upgrading Quantex CLI...${t}`)),!e.error){_(h.green(`Quantex CLI upgraded successfully.`)),R(e.warnings);return}y(h.red(`Failed to upgrade Quantex CLI.`)),g(h.yellow(`Reason: ${e.error.message}`));for(let t of e.warnings)g(h.cyan(t.message.replace(/^Manual recovery:/,`Next step:`)))}function L(e){return!e.latestVersion||!e.upstreamLatestVersion||e.latestVersion===e.upstreamLatestVersion||e.installSource!==`bun`&&e.installSource!==`npm`?[]:[{code:`MIRROR_LAG`,details:{installableLatestVersion:e.latestVersion,upstreamLatestVersion:e.upstreamLatestVersion},message:`The selected registry currently installs ${e.latestVersion}, while upstream npm has ${e.upstreamLatestVersion}. Retry later or set selfUpdateRegistry / QTX_SELF_UPDATE_REGISTRY to another registry if you need the upstream release now.`}]}function R(e){for(let t of e)t.code===`DRY_RUN`||t.code===`MANUAL_RECOVERY`||g(h.yellow(t.message))}function z(e){if(!e.latestVersion)return;let t=r(e.latestVersion,e.currentVersion);if(!(t===void 0||t>=0))return{code:`STALE_LATEST_VERSION`,details:{currentVersion:e.currentVersion,latestVersion:e.latestVersion},message:`The resolved latest version ${e.latestVersion} is older than the installed Quantex CLI ${e.currentVersion}. Quantex will not downgrade; retry with --refresh or --no-cache if you need a fresh check.`}}export{P as resolveUpgradeChannelOption,F as upgradeCommand};
1
+ import{c as e,o as t,t as n}from"./child-process-CBKnpMWt.mjs";import{s as r}from"./schema-hCKyxJjR.mjs";import{i,n as a}from"./cli-context-xudTdmO7.mjs";import{E as o,c as s,i as c,n as l,t as u,u as d,v as f,x as p,y as m}from"./output-DQY0YUII.mjs";import{t as h}from"./color-FZclrXnv.mjs";import{a as g,i as _,n as v,r as y}from"./user-output-B-zDs13K.mjs";import{n as b,t as x}from"./version-cache-C5F6SycS.mjs";const S={platform:process.platform,spawn:(e,n)=>t(e,{...n,stdio:n.stdio?[...n.stdio]:void 0}),terminate:e,writeStderr:e=>{process.stderr.write(e)}};function C(e=S){let t=b(e);return{run:e=>t.run({...e,forwardPipedOutput:e.forwardPipedOutput??!1})}}const w={fetch:globalThis.fetch.bind(globalThis)};function T(e=w){return{async request(t){if(t.signal.aborted)return E(t.signal);let n=new AbortController,r,i,a=!1,o=new Promise(e=>i=e),s=e=>{a||(a=!0,n.abort(),i(e))},c=()=>s(E(t.signal));t.signal.addEventListener(`abort`,c,{once:!0}),t.signal.aborted&&c(),t.timeoutMs!==void 0&&(r=setTimeout(()=>s(D(`timed-out`,`Network request timed out after ${t.timeoutMs}ms.`)),t.timeoutMs));let l=Promise.resolve().then(async()=>{let r=await e.fetch(t.url,{body:t.body,headers:t.headers,method:t.method,signal:n.signal}),i={};return r.headers.forEach((e,t)=>i[t.toLowerCase()]=e),{kind:`success`,value:{body:new Uint8Array(await r.arrayBuffer()),headers:i,status:r.status}}}).catch(e=>t.signal.aborted?E(t.signal):n.signal.aborted&&t.timeoutMs!==void 0?D(`timed-out`,`Network request timed out after ${t.timeoutMs}ms.`):D(`failed`,e instanceof Error?e.message:`Network request failed.`));try{return await Promise.race([l,o])}finally{a=!0,r&&clearTimeout(r),t.signal.removeEventListener(`abort`,c)}}}}function E(e){return D(`cancelled`,e.reason instanceof Error?e.reason.message:String(e.reason??`Network request was cancelled.`))}function D(e,t){return{error:{kind:e,message:t},kind:`failure`}}function O(e){let t=new AbortController,n=new Set,r=Object.freeze({cacheMode:e.cacheMode??`default`,dryRun:e.dryRun??!1,outputMode:e.outputMode??`human`,quiet:e.quiet??!1,timeoutMs:e.timeoutMs}),i=Object.freeze({...e.ports}),a;return{options:r,ports:i,signal:t.signal,cancel(e){if(a)return a;let r;a=new Promise(e=>{r=e}),t.abort(e);let i=[...n];return n.clear(),Promise.allSettled(i.map(t=>Promise.resolve().then(()=>t(e)))).then(()=>r()),a},onCancel(e){return t.signal.aborted?()=>void 0:(n.add(e),()=>{n.delete(e)})}}}async function k(e,t,n){if(t.signal.aborted)return A();let r=await n.plan({context:{signal:t.signal,timeoutMs:t.options.timeoutMs},metadataCache:t.ports.cache,metadataCacheMode:t.options.cacheMode===`no-cache`?`no-cache`:`refresh`,networkPort:t.ports.network,persistencePort:t.ports.persistence,updateChannel:e.updateChannel});return t.signal.aborted?A(r):e.check||e.dryRun||r.status!==`update-available`?{kind:`planned`,plan:r}:{kind:`executed`,plan:r,result:await n.upgrade(r,{lockPort:t.ports.locks,networkPort:t.ports.network,processPort:t.ports.process,signal:t.signal,stdio:t.options.outputMode===`human`?[`inherit`,`inherit`,`inherit`]:[`ignore`,`pipe`,`pipe`],timeoutMs:t.options.timeoutMs})}}function A(e){return{error:{kind:`cancelled`,message:`Self-upgrade invocation was cancelled.`},kind:`interrupted`,...e?{plan:e}:{}}}function j(){let e=a(),t=O({cacheMode:e.cacheMode,dryRun:e.dryRun,outputMode:e.outputMode,ports:M(),quiet:e.quiet,timeoutMs:e.timeoutMs});e.cancelled&&t.cancel(`cancelled`);let n=i(()=>t.cancel(`cancelled`)),r=!1,o={plan:e=>m({context:e.context,metadataCache:e.metadataCache,metadataCacheMode:e.metadataCacheMode,networkPort:e.networkPort,persistencePort:e.persistencePort,updateChannel:e.updateChannel}),upgrade:(e,t)=>s(e,t)};return{dispose(){r||(r=!0,n())},run:e=>k(e,t,o)}}function M(){return{cache:x(),clock:{now:Date.now,sleep:N},fileSystem:{makeDirectory:N,readFile:N,remove:N,rename:N,writeFile:N},locks:p(),network:T(),persistence:o(),process:C()}}async function N(){return{error:{kind:`unavailable`,message:`Runtime port is not bound for this self-upgrade operation.`},kind:`failure`}}function P(e){if(e===`stable`||e===`beta`)return e}async function F(e={}){let t=v(),r=j(),i=await r.run({check:e.check??!1,dryRun:t,updateChannel:e.channel}).finally(()=>r.dispose());if(i.kind===`interrupted`)throw new n({kind:`cancelled`,reason:i.error.message});let a=i.plan,o=f(a),s=L(o),p=z(o);if(a.status===`up-to-date`)return c(l({action:`upgrade`,data:{canAutoUpdate:o.canAutoUpdate,channel:o.updateChannel,currentVersion:o.currentVersion,installSource:o.installSource,latestVersion:o.latestVersion,status:`up-to-date`},target:{kind:`self`,name:`quantex`},warnings:[...s,...p?[p]:[]]}),I);if(e.check||t)return a.status===`update-available`?c(l({action:`upgrade`,data:{canAutoUpdate:o.canAutoUpdate,channel:o.updateChannel,currentVersion:o.currentVersion,installSource:o.installSource,latestVersion:o.latestVersion,status:`update-available`},exitCode:e.check?1:void 0,target:{kind:`self`,name:`quantex`},warnings:[...s,...p?[p]:[],...t?[{code:`DRY_RUN`,message:`Dry run: would upgrade Quantex CLI.`}]:[]]}),I):c(u({action:`upgrade`,data:{canAutoUpdate:o.canAutoUpdate,channel:o.updateChannel,currentVersion:o.currentVersion,installSource:o.installSource,status:`check-unavailable`},error:{code:`NETWORK_ERROR`,message:`Unable to determine the latest Quantex CLI version.`},target:{kind:`self`,name:`quantex`},warnings:[...s,...p?[p]:[]]}),I);if(a.status===`manual-required`){let e=d(o);return c(u({action:`upgrade`,data:{canAutoUpdate:o.canAutoUpdate,channel:o.updateChannel,currentVersion:o.currentVersion,installSource:o.installSource,latestVersion:o.latestVersion,recoveryHint:e,status:`manual-required`},error:{code:`MANUAL_ACTION_REQUIRED`,message:`Quantex CLI cannot auto-update from the current install source: ${o.installSource}.`},target:{kind:`self`,name:`quantex`},warnings:[...s,...p?[p]:[]]}),I)}if(i.kind!==`executed`)throw Error(`Self-upgrade execution did not produce a result.`);let m=i.result;if(m.success)return c(l({action:`upgrade`,data:{canAutoUpdate:o.canAutoUpdate,channel:o.updateChannel,currentVersion:o.currentVersion,installSource:o.installSource,latestVersion:o.latestVersion,status:`updated`},target:{kind:`self`,name:`quantex`},warnings:[...s,...p?[p]:[]]}),I);let h=d(o,m);return c(u({action:`upgrade`,data:{canAutoUpdate:o.canAutoUpdate,channel:o.updateChannel,currentVersion:o.currentVersion,installSource:o.installSource,latestVersion:o.latestVersion,recoveryHint:h,status:`manual-required`},error:{code:`UPGRADE_FAILED`,details:m.error?.kind?{kind:m.error.kind}:void 0,message:m.error?.message??`Failed to upgrade Quantex CLI.`},target:{kind:`self`,name:`quantex`},warnings:[...s,...h?[{code:`MANUAL_RECOVERY`,message:`Manual recovery: ${h}`}]:[]]}),I)}function I(e){if(!e.data){e.error&&y(h.red(e.error.message));return}if(e.data.status===`up-to-date`){_(h.green(`Quantex CLI is already up to date (${e.data.currentVersion}).`)),R(e.warnings);return}if(e.data.status===`update-available`){let t=e.warnings.some(e=>e.message.includes(`Dry run`))?`Dry run: `:``;g(h.yellow(`${t}Update available for Quantex CLI: ${e.data.currentVersion} -> ${e.data.latestVersion} (${e.data.channel}).`)),R(e.warnings);return}if(e.data.status===`check-unavailable`){e.error&&g(h.yellow(e.error.message)),R(e.warnings);return}if(e.data.status===`manual-required`&&e.error?.code===`MANUAL_ACTION_REQUIRED`){g(h.yellow(e.error.message)),e.data.recoveryHint&&g(h.cyan(`Next step: ${e.data.recoveryHint}`));return}let t=e.data.latestVersion?` (${e.data.currentVersion} -> ${e.data.latestVersion})`:` (${e.data.currentVersion})`;if(_(h.cyan(`Upgrading Quantex CLI...${t}`)),!e.error){_(h.green(`Quantex CLI upgraded successfully.`)),R(e.warnings);return}y(h.red(`Failed to upgrade Quantex CLI.`)),g(h.yellow(`Reason: ${e.error.message}`));for(let t of e.warnings)g(h.cyan(t.message.replace(/^Manual recovery:/,`Next step:`)))}function L(e){return!e.latestVersion||!e.upstreamLatestVersion||e.latestVersion===e.upstreamLatestVersion||e.installSource!==`bun`&&e.installSource!==`npm`?[]:[{code:`MIRROR_LAG`,details:{installableLatestVersion:e.latestVersion,upstreamLatestVersion:e.upstreamLatestVersion},message:`The selected registry currently installs ${e.latestVersion}, while upstream npm has ${e.upstreamLatestVersion}. Retry later or set selfUpdateRegistry / QTX_SELF_UPDATE_REGISTRY to another registry if you need the upstream release now.`}]}function R(e){for(let t of e)t.code===`DRY_RUN`||t.code===`MANUAL_RECOVERY`||g(h.yellow(t.message))}function z(e){if(!e.latestVersion)return;let t=r(e.latestVersion,e.currentVersion);if(!(t===void 0||t>=0))return{code:`STALE_LATEST_VERSION`,details:{currentVersion:e.currentVersion,latestVersion:e.latestVersion},message:`The resolved latest version ${e.latestVersion} is older than the installed Quantex CLI ${e.currentVersion}. Quantex will not downgrade; retry with --refresh or --no-cache if you need a fresh check.`}}export{P as resolveUpgradeChannelOption,F as upgradeCommand};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quantex-cli",
3
- "version": "1.8.2",
3
+ "version": "1.8.7",
4
4
  "description": "Agent-friendly lifecycle CLI for AI coding assistant CLIs: install, inspect, update, uninstall, run, and automate Codex, Claude Code, Gemini, Cursor, OpenCode, and more",
5
5
  "keywords": [
6
6
  "agent-cli",
@@ -54,43 +54,44 @@
54
54
  "./package.json": "./package.json"
55
55
  },
56
56
  "scripts": {
57
- "agent-catalog:generate": "bun run agent-catalog:manifest && bun run agent-catalog:schema && bun run core-catalog:write",
58
- "agent-catalog:manifest": "bun run scripts/write-agent-catalog-manifest.ts",
59
- "agent-catalog:schema": "bun run scripts/write-agent-catalog-schema.ts",
57
+ "agent-catalog:generate": "bun run agent-catalog:manifest && bun run core-catalog:write",
58
+ "agent-catalog:manifest": "bun run scripts/build/write-agent-catalog-manifest.ts",
60
59
  "build": "bun run build:core && bun run build:cli",
61
- "build:bin": "bun run build:meta && bun run scripts/build-bin.ts",
60
+ "build:bin": "bun run build:meta && bun run scripts/build/build-bin.ts",
62
61
  "build:cli": "bun run build:meta && tsdown --config tsdown.config.ts",
63
62
  "build:core": "bun run --cwd packages/core build",
64
- "build:meta": "bun run scripts/write-build-metadata.ts",
65
- "ci:commit-trailer-policy": "bun run scripts/commit-trailer-policy.ts",
66
- "ci:path-taxonomy": "bun run scripts/path-taxonomy.ts",
67
- "ci:pr-merge-commit-policy": "bun run scripts/pr-merge-commit-policy.ts",
68
- "ci:release-pr-policy": "bun run scripts/release-pr-policy.js",
69
- "ci:release-publish-contract": "bun run scripts/release-seal-contract.ts",
70
- "ci:release-tag-backstop": "bun run scripts/release-tag-backstop.ts",
71
- "core-catalog:write": "bun run scripts/write-core-agent-catalog.ts",
63
+ "build:meta": "bun run scripts/build/write-build-metadata.ts",
64
+ "ci:commit-policy": "bun run scripts/ci/commit-policy.ts",
65
+ "ci:context": "bun run scripts/ci/ci-context.ts",
66
+ "ci:path-taxonomy": "bun run scripts/ci/path-taxonomy.ts",
67
+ "ci:release-pr-policy": "bun run scripts/ci/release-pr-policy.ts",
68
+ "ci:release-publish-contract": "bun run scripts/release/release-seal-contract.ts",
69
+ "ci:tag-release": "bun run scripts/release/tag-release.ts",
70
+ "core-catalog:write": "bun run scripts/build/write-core-agent-catalog.ts",
72
71
  "dev": "bun run src/cli.ts",
73
72
  "format": "oxfmt",
74
73
  "format:check": "oxfmt --check",
75
74
  "lint": "oxlint",
76
75
  "lint:fix": "oxlint --fix",
77
- "memory:check": "bun run scripts/check-project-memory.ts",
78
- "openspec:archive-closure": "bun run scripts/openspec-archive-closure.ts",
76
+ "memory:check": "bun run scripts/ci/check-project-memory.ts",
77
+ "openspec:archive-closure": "bun run scripts/ci/openspec-archive-closure.ts",
79
78
  "openspec:list": "openspec list",
80
79
  "openspec:status": "openspec status --json",
81
80
  "openspec:validate": "openspec validate --all --no-interactive",
82
81
  "package:check": "bun run package:check:core && bun run package:check:cli",
83
- "package:check:cli": "bun run scripts/verify-package-distribution.ts",
84
- "package:check:core": "bun run scripts/verify-core-package-distribution.ts",
85
- "pr:body:check": "bun run scripts/pr-body-policy.ts",
82
+ "package:check:cli": "bun run scripts/release/verify-package-distribution.ts",
83
+ "package:check:core": "bun run scripts/release/verify-core-package-distribution.ts",
84
+ "pr:body:check": "bun run scripts/ci/pr-body-policy.ts",
86
85
  "prepare": "simple-git-hooks",
87
86
  "prepublishOnly": "bun run build",
88
- "release:artifacts": "bun run scripts/compress-release-binaries.ts && bun run scripts/write-release-checksums.ts && bun run scripts/generate-release-manifest.ts && bun run scripts/verify-release-artifacts.ts",
89
- "release:smoke": "bun run scripts/verify-release-smoke.ts",
87
+ "release:artifacts": "bun run scripts/release/release-artifacts.ts",
88
+ "release:candidate": "bun run scripts/release/release-candidate.ts",
89
+ "release:dry-run": "bun run scripts/release/release-candidate.ts --local",
90
+ "release:smoke": "bun run scripts/release/verify-release-smoke.ts",
91
+ "setup": "simple-git-hooks",
90
92
  "test": "vitest run",
91
- "test:container": "bun run scripts/test-container.ts",
92
- "test:readonly-smoke": "vitest run test/read-only-lifecycle-smoke.test.ts test/read-only-lifecycle-timeout.test.ts test/read-only-lifecycle-provider-timeout.test.ts test/read-only-lifecycle-provider-signal.test.ts test/read-only-spawn-guard.test.ts",
93
- "test:sandbox": "bun run scripts/test-sandbox.ts",
93
+ "test:container": "bun run scripts/smoke/test-isolation.ts docker",
94
+ "test:sandbox": "bun run scripts/smoke/test-isolation.ts modal",
94
95
  "test:watch": "vitest",
95
96
  "typecheck": "bun run typecheck:cli && bun run typecheck:core",
96
97
  "typecheck:cli": "tsc --noEmit",
@@ -123,8 +124,7 @@
123
124
  "vitest": "^4.1.3"
124
125
  },
125
126
  "simple-git-hooks": {
126
- "commit-msg": "bun run scripts/strip-cursor-coauthor.ts \"$1\"",
127
- "pre-commit": "bun install --frozen-lockfile && npx lint-staged",
127
+ "pre-commit": "bunx lint-staged",
128
128
  "pre-push": "bun run lint && bun run format:check && bun run typecheck && bun run openspec:validate && bun run memory:check"
129
129
  },
130
130
  "lint-staged": {
@@ -1 +0,0 @@
1
- import{t as e}from"./capabilities-R_JO88hZ.mjs";export{e as capabilitiesCommand};
@@ -1 +0,0 @@
1
- import{t as e}from"./commands-DsPlMpTu.mjs";export{e as commandsCommand};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./ensure-DggVCnjj.mjs";export{t as ensureCommand,e as ensureCommandWithRoute};
@@ -1 +0,0 @@
1
- import{t as e}from"./inspect-CAO2CIto.mjs";export{e as inspectCommand};
@@ -1 +0,0 @@
1
- import{t as e}from"./resolve-0wKoLOKT.mjs";export{e as resolveCommand};
@@ -1 +0,0 @@
1
- import{n as e}from"./schema-CGLYU_o3.mjs";export{e as schemaCommand};