@arcforge/axon 2.0.157 → 2.0.158
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent-main.js +1 -1
- package/app.js +5 -5
- package/declare-worker.js +1 -1
- package/package.json +1 -1
- package/update-helper.js +1 -1
package/app.js
CHANGED
|
@@ -683,7 +683,7 @@ ${NA.stack??""}`}),nO(Ta,"reload")}});let Mi=new Map;if(Ye.provide(rqn,Mi),Ye.pr
|
|
|
683
683
|
${Rr}`:""}`})},Ye.config.performance=!1,Ye.config.compilerOptions.isCustomElement=()=>!0,Ye.config.errorHandler=(Ta,NA,Rr)=>{nO(Ta,`vue:${Rr}`)};let rn=(Ta)=>{if(tO.value===null)nO(Ta,"uncaughtException")},_a=(Ta)=>{if(tO.value===null)nO(Ta,"unhandledRejection")};process.on("uncaughtException",rn),process.on("unhandledRejection",_a),wK("vterm:app:mount"),Ye.mount(Aa),await new Promise((Ta)=>queueMicrotask(Ta)),na(),wK("vterm:boot:complete",{durationMs:Date.now()-(k??Date.now())});let fn={screen:A,app:Ye,inputParser:i,snapshot:ENi(A),async unmount(){if(Hun(),process.off("uncaughtException",rn),process.off("unhandledRejection",_a),A.off("resize",ga),A.off("drain",fr),Xe!==null)clearTimeout(Xe),Xe=null;for(let Ta of Mi.values())await Ta.close();Ye.unmount(),A.cleanup(),A.destroy()},render(){na()}};if(A.key(x,()=>void Dr()),n.onMounted)try{n.onMounted(fn)}catch(Ta){nO(Ta,"onMounted")}return fn}var WUe;var p_a=xt(()=>{NOn();VQa();t_a();WDt();c_a();Oun();zun();iyt();$yn();fCe();LEn();Mgn();agt();mQt();tqe();eQn();WUe=fp(qf(),1)});async function tQn(e){let n=Date.now(),{entry:A,layout:i,highlight:s,ui:u}=e;if(wK("vterm:boot",{cwd:process.cwd()}),RLn(),WLn(),wK("vterm:console:capture"),s)vgt(s);wK("vterm:highlight:config",{theme:s?.theme});let p=new pQt,d=new Ggn({inputParser:p,alternateScreen:!0,hideCursor:!0,cursor:u?.cursor,width:e.dimensions?.width,height:e.dimensions?.height});if(d.initialize(),wK("vterm:driver:init",{width:d.width,height:d.height}),e.styles?.length)for(let[V,te]of e.styles.entries()){if(!te||typeof te!=="object"||Array.isArray(te))continue;Aqe.register(`__bundled__${V}`,te)}let b=Aqe.proxy,E=typeof i==="object"&&i!==null?i:null,y=e.routes??[],k=e.layouts instanceof Map?e.layouts:new Map;wK("vterm:routes:load",{count:y.length,paths:y.map((V)=>V.path??V.name??"?")});let x=e.errorPage??n7.defineComponent({name:"VTermError",setup(){return()=>n7.h("div",{style:{color:"red",padding:"1",display:"flex",flexDirection:"column"}},[n7.h("p",{style:{color:"brightred"}},"Runtime Error"),n7.h("p",{style:{color:"white"}},String(tO.value?.message??tO.value??"Unknown error")),n7.h("p",{style:{color:"yellow"}},String(tO.value?.stack?.split(`
|
|
684
684
|
`)[1]??""))])}}),S;if(y.length>0)S=E??n7.defineComponent({name:"AppRoot",setup(){return()=>n7.h(Ty)}});else{if(!A)throw Error("No entry component or routes provided to vterm()");S=typeof A==="string"?(()=>{throw Error(`vterm build error: entry must be a component object in production, got string "${A}"`)})():A}let L=S;S=n7.defineComponent({name:"VTermRoot",setup(){return n7.onErrorCaptured((V)=>{return nO(V,"component"),!1}),()=>tO.value!==null?n7.h(x):n7.h(L)}});let U=e.middleware??[],$=U.length>0?async(V,te)=>{V.beforeEach(async(ee,me)=>{for(let be of U){let ce=await be(ee,me);if(ce!==void 0)return ce}return})}:void 0;return g_a({options:e,driver:d,inputParser:p,component:S,allStyles:b,routes:y,layoutsMap:k,notFoundComponent:e.notFoundComponent,bootStart:n,onMiddleware:$})}var n7;var m_a=xt(()=>{IOn();EOn();fCe();agt();tqe();Xun();Mgn();mQt();iyt();p_a();n7=fp(qf(),1)});var uA;var Fs=xt(()=>{iyt();Oun();zun();Iyt();Xun();fCe();m_a();REn();eQn();uA=fp(qf(),1)});import d_a from"fs";function yNi(){try{return d_a.statSync("/.dockerenv"),!0}catch{return!1}}function QNi(){try{return d_a.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function aQn(){if(nQn===void 0)nQn=yNi()||QNi();return nQn}var nQn;var f_a=()=>{};import _Ni from"fs";function GMe(){if(AQn===void 0)AQn=wNi()||aQn();return AQn}var AQn,wNi=()=>{try{return _Ni.statSync("/run/.containerenv"),!0}catch{return!1}};var iQn=xt(()=>{f_a()});import b_a from"process";import kNi from"os";import rQn from"fs";var h_a=()=>{if(b_a.platform!=="linux")return!1;if(kNi.release().toLowerCase().includes("microsoft")){if(GMe())return!1;return!0}try{if(rQn.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!GMe()}catch{}if(rQn.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||rQn.existsSync("/run/WSL"))return!GMe();return!1},The;var oQn=xt(()=>{iQn();The=b_a.env.__IS_WSL_TEST__?h_a:h_a()});import C_a from"process";import{Buffer as DNi}from"buffer";import{promisify as xNi}from"util";import FNi from"child_process";var vNi,sQn=()=>`${C_a.env.SYSTEMROOT||C_a.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,mJ=async(e,n={})=>{let{powerShellPath:A,...i}=n,s=mJ.encodeCommand(e);return vNi(A??sQn(),[...mJ.argumentsPrefix,s],{encoding:"utf8",...i})};var cQn=xt(()=>{vNi=xNi(FNi.execFile);mJ.argumentsPrefix=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"];mJ.encodeCommand=(e)=>DNi.from(e,"utf16le").toString("base64");mJ.escapeArgument=(e)=>`'${String(e).replaceAll("'","''")}'`});function B_a(e){for(let n of e.split(`
|
|
685
685
|
`)){if(/^\s*#/.test(n))continue;let A=/^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(n);if(!A)continue;return A.groups.mountPoint.trim().replaceAll(/^["']|["']$/g,"")}}import{promisify as SNi}from"util";import NNi from"child_process";import uQn,{constants as E_a}from"fs/promises";var GNi,MNi,LNi=async()=>{return`${await MNi()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`},T1t,I_a,y_a=async()=>{return I_a??=(async()=>{try{let e=await T1t();return await uQn.access(e,E_a.X_OK),!0}catch{return!1}})(),I_a},Q_a=async()=>{let e=await T1t(),n=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:A}=await mJ(n,{powerShellPath:e});return A.trim()},__a=async(e)=>{if(/^[a-z]+:\/\//i.test(e))return e;try{let{stdout:n}=await GNi("wslpath",["-aw",e],{encoding:"utf8"});return n.trim()}catch{return e}};var w_a=xt(()=>{oQn();cQn();oQn();GNi=SNi(NNi.execFile),MNi=(()=>{let n;return async function(){if(n)return n;let A="/etc/wsl.conf",i=!1;try{await uQn.access(A,E_a.F_OK),i=!0}catch{}if(!i)return"/mnt/";let s=await uQn.readFile(A,{encoding:"utf8"}),u=B_a(s);if(u===void 0)return"/mnt/";return n=u,n=n.endsWith("/")?n:`${n}/`,n}})(),T1t=The?LNi:sQn});function MMe(e,n,A){let i=(s)=>Object.defineProperty(e,n,{value:s,enumerable:!0,writable:!0});return Object.defineProperty(e,n,{configurable:!0,enumerable:!0,get(){let s=A();return i(s),s},set(s){i(s)}}),e}import{promisify as qNi}from"util";import TNi from"process";import{execFile as UNi}from"child_process";async function lQn(){if(TNi.platform!=="darwin")throw Error("macOS only");let{stdout:e}=await RNi("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),A=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??"com.apple.Safari";if(A==="com.apple.safari")return"com.apple.Safari";return A}var RNi;var k_a=xt(()=>{RNi=qNi(UNi)});import KNi from"process";import{promisify as YNi}from"util";import{execFile as jNi,execFileSync as YUr}from"child_process";async function D_a(e,{humanReadableOutput:n=!0,signal:A}={}){if(KNi.platform!=="darwin")throw Error("macOS only");let i=n?[]:["-ss"],s={};if(A)s.signal=A;let{stdout:u}=await HNi("osascript",["-e",e,i],s);return u.trim()}var HNi;var x_a=xt(()=>{HNi=YNi(jNi)});async function gQn(e){return D_a(`tell application "Finder" to set app_path to application file id "${e}" as string
|
|
686
|
-
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var F_a=xt(()=>{x_a()});import{promisify as PNi}from"util";import{execFile as JNi}from"child_process";async function pQn(e=ONi){let{stdout:n}=await e("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),A=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(n);if(!A)throw new v_a(`Cannot find Windows browser in stdout: ${JSON.stringify(n)}`);let{id:i}=A.groups,s=i.lastIndexOf("."),u=i.lastIndexOf("-"),p=s===-1?void 0:i.slice(0,s),d=u===-1?void 0:i.slice(0,u);return U1t[i]??U1t[p]??U1t[d]??{name:i,id:i}}var ONi,U1t,R1t,v_a;var mQn=xt(()=>{ONi=PNi(JNi),U1t={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},R1t=new Map(Object.entries(U1t));v_a=class v_a extends Error{}});import{promisify as $Ni}from"util";import dQn from"process";import{execFile as zNi}from"child_process";async function fQn(){if(dQn.platform==="darwin"){let e=await lQn();return{name:await gQn(e),id:e}}if(dQn.platform==="linux"){let{stdout:e}=await WNi("xdg-mime",["query","default","x-scheme-handler/http"]),n=e.trim();return{name:ZNi(n.replace(/.desktop$/,"").replace("-"," ")),id:n}}if(dQn.platform==="win32")return pQn();throw Error("Only macOS, Linux, and Windows are supported")}var WNi,ZNi=(e)=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,(n)=>n.toUpperCase());var S_a=xt(()=>{k_a();F_a();mQn();mQn();WNi=$Ni(zNi)});import hQn from"process";var VNi,N_a;var G_a=xt(()=>{VNi=Boolean(hQn.env.SSH_CONNECTION||hQn.env.SSH_CLIENT||hQn.env.SSH_TTY),N_a=VNi});import bQn from"process";import U_a from"path";import{fileURLToPath as XNi}from"url";import e3i from"child_process";import t3i,{constants as n3i}from"fs/promises";function T_a(e){if(typeof e==="string"||Array.isArray(e))return e;let{[L_a]:n}=e;if(!n)throw Error(`${L_a} is not supported`);return n}function Vft({[ZUe]:e},{wsl:n}={}){if(n&&The)return T_a(n);if(!e)throw Error(`${ZUe} is not supported`);return T_a(e)}var K1t,CQn,M_a,ZUe,L_a,q_a=async(e,n)=>{if(e.length===0)return;let A=[];for(let i of e)try{return await n(i)}catch(s){A.push(s)}throw AggregateError(A,"Failed to open in all supported apps")},Y1t=async(e)=>{e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e};let n=e[K1t]===!0;if(delete e[K1t],Array.isArray(e.app))return q_a(e.app,(E)=>Y1t({...e,app:E,[K1t]:!0}));let{name:A,arguments:i=[]}=e.app??{};if(i=[...i],Array.isArray(A))return q_a(A,(E)=>Y1t({...e,app:{name:E,arguments:i},[K1t]:!0}));if(A==="browser"||A==="browserPrivate"){let E={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},y={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},k;if(The){let x=await Q_a();k=R1t.get(x)??{}}else k=await fQn();if(k.id in E){let x=E[k.id.toLowerCase()];if(A==="browserPrivate"){if(x==="safari")throw Error("Safari doesn't support opening in private mode via command line");i.push(y[x])}return Y1t({...e,app:{name:VUe[x],arguments:i}})}throw Error(`${k.name} is not supported as a default browser`)}let s,u=[],p={},d=!1;if(The&&!GMe()&&!N_a&&!A)d=await y_a();if(ZUe==="darwin"){if(s="open",e.wait)u.push("--wait-apps");if(e.background)u.push("--background");if(e.newInstance)u.push("--new");if(A)u.push("-a",A)}else if(ZUe==="win32"||d){if(s=await T1t(),u.push(...mJ.argumentsPrefix),!The)p.windowsVerbatimArguments=!0;if(The&&e.target)e.target=await __a(e.target);let E=["$ProgressPreference = 'SilentlyContinue';","Start"];if(e.wait)E.push("-Wait");if(A){if(E.push(mJ.escapeArgument(A)),e.target)i.push(e.target)}else if(e.target)E.push(mJ.escapeArgument(e.target));if(i.length>0)i=i.map((y)=>mJ.escapeArgument(y)),E.push("-ArgumentList",i.join(","));if(e.target=mJ.encodeCommand(E.join(" ")),!e.wait)p.stdio="ignore"}else{if(A)s=A;else{let E=!CQn||CQn==="/",y=!1;try{await t3i.access(M_a,n3i.X_OK),y=!0}catch{}s=bQn.versions.electron??(ZUe==="android"||E||!y)?"xdg-open":M_a}if(i.length>0)u.push(...i);if(!e.wait)p.stdio="ignore",p.detached=!0}if(ZUe==="darwin"&&i.length>0)u.push("--args",...i);if(e.target)u.push(e.target);let b=e3i.spawn(s,u,p);if(e.wait)return new Promise((E,y)=>{b.once("error",y),b.once("close",(k)=>{if(!e.allowNonzeroExitCode&&k!==0){y(Error(`Exited with code ${k}`));return}E(b)})});if(n)return new Promise((E,y)=>{b.once("error",y),b.once("spawn",()=>{b.once("close",(k)=>{if(b.off("error",y),k!==0){y(Error(`Exited with code ${k}`));return}b.unref(),E(b)})})});return b.unref(),new Promise((E,y)=>{b.once("error",y),b.once("spawn",()=>{b.off("error",y),E(b)})})},a3i=(e,n)=>{if(typeof e!=="string")throw TypeError("Expected a `target`");return Y1t({...n,target:e})},VUe,Uhe;var Xft=xt(()=>{w_a();cQn();S_a();iQn();G_a();K1t=Symbol("fallbackAttempt"),CQn=import.meta.url?U_a.dirname(XNi(import.meta.url)):"",M_a=U_a.join(CQn,"xdg-open"),{platform:ZUe,arch:L_a}=bQn;VUe={browser:"browser",browserPrivate:"browserPrivate"};MMe(VUe,"chrome",()=>Vft({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));MMe(VUe,"brave",()=>Vft({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));MMe(VUe,"firefox",()=>Vft({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));MMe(VUe,"edge",()=>Vft({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));MMe(VUe,"safari",()=>Vft({darwin:"Safari"}));Uhe=a3i});var j1t;var BQn=xt(()=>{j1t={UNKNOWN:{code:"AX-UNKNOWN-001",title:"Unclassified Error",description:"An error occurred that hasn't been given a proper code yet. This is itself worth fixing \u2014 see the err(cause) call site that produced it.",source:"runtime",severity:"fatal"},PROMPT_NOT_FOUND:{code:"AX-PROMPT-001",title:"Prompt Not Found",description:"The requested prompt could not be resolved \u2014 it is not declared by the agent, or the published package it names ships no prompt by that name.",source:"runtime",severity:"fatal",expected:!0},PROMPT_FILE_NOT_FOUND:{code:"AX-PROMPT-002",title:"Prompt File Missing",description:"The prompt is declared but its source file no longer exists on disk.",source:"runtime",severity:"fatal",expected:!0},PROMPT_RENDER_FAILED:{code:"AX-PROMPT-003",title:"Prompt Render Failed",description:"The prompt's source file failed to compile or render \u2014 likely a malformed SFC (content outside <template>/<script>/<style>) or an error thrown while rendering. See the cause for the underlying parser/render error.",source:"runtime",severity:"fatal"},OUTPUT_INVALID:{code:"AX-OUTPUT-001",title:"Invalid Output Type",description:"The `output` type passed to request() is not valid TypeScript, or references a type that does not exist. Checked before the model is called, so no inference was spent \u2014 fix the type string at the call site.",source:"runtime",severity:"fatal"},OUTPUT_UNSATISFIED:{code:"AX-OUTPUT-002",title:"Output Type Not Satisfied",description:"The model could not produce a response matching the declared `output` type within its retry budget. The accumulated TypeScript diagnostics describe what it got wrong on each attempt.",source:"runtime",severity:"fatal"},OUTPUT_EMPTY:{code:"AX-OUTPUT-003",title:"Model Produced No Output Block",description:"Every reply must wrap its content in a <text> or <script> block \u2014 text outside a block is discarded by the parser. The model replied with none, on every attempt in its retry budget, so there was nothing to render or run. Usually means the model is not following the block protocol rather than that anything is misconfigured: the reply itself is often correct, just unwrapped. Try a different model, or check that the protocol the cognet renders matches the one it parses with.",source:"runtime",severity:"fatal",expected:!0},SCRIPT_NOT_FOUND:{code:"AX-SCRIPT-001",title:"Script Not Found",description:"The requested script was not found in the agent's blueprint. It may not be declared, or the agent needs to be re-prepared.",source:"runtime",severity:"fatal",expected:!0},SCRIPT_FILE_NOT_FOUND:{code:"AX-SCRIPT-002",title:"Script File Missing",description:"The script is declared but its source file no longer exists on disk.",source:"runtime",severity:"fatal",expected:!0},SCRIPT_AGENT_NOT_LOCAL:{code:"AX-SCRIPT-003",title:"Script Agent Is Not In-Process",description:"A script's agent must run in the same process as the script. Scripts() booted a linked (confined) agent instead, so there is no in-heap runtime for the script's proxy to forward to. This is a wiring fault, not a user error.",source:"runtime",severity:"fatal"},SUBAGENT_LINK_UNSUPPORTED:{code:"AX-SCRIPT-004",title:"Subagent Not Supported Over The Link",description:"An agent asked to spawn a subagent whose child runs as a confined process. `axon.request()` returns a wake's collected entries, while the link's `stimulus` verb returns only admission \u2014 the supervisor needs a verb that collects a wake and answers when it settles. Until that exists this fails rather than returning an admission receipt the caller would read as a result.",source:"runtime",severity:"fatal"},AGENT_BOOT_FAILED:{code:"AX-AGENT-006",title:"Agent Failed To Boot",description:"The agent process exited before it connected to its supervisor. Its own stderr is carried as the detail \u2014 the agent usually knows exactly what went wrong (a missing cognet, a tool that would not compile), and without this that diagnosis died in a pipe while the supervisor reported only a closed socket.",source:"runtime",severity:"fatal"},LINK_NO_HANDLER:{code:"AX-LINK-001",title:"No Handler For Link Verb",description:"The peer sent a verb this side does not implement. Both ends speak a versioned contract, so this means they disagree about it \u2014 a wiring fault, not something a user did.",source:"runtime",severity:"fatal"},LINK_PEER_CLOSED:{code:"AX-LINK-002",title:"Agent Disconnected",description:"The agent process closed its side of the link. Every call still in flight is rejected rather than left hanging \u2014 a dead peer must be an error, never a wait that never ends.",source:"runtime",severity:"fatal"},LINK_CLOSED:{code:"AX-LINK-003",title:"Link Closed",description:"The link to the agent was torn down by this side \u2014 a shutdown, a dispose, or a failed boot. Outstanding calls are rejected with this rather than hanging.",source:"runtime",severity:"fatal"},LINK_FRAME_TOO_LARGE:{code:"AX-LINK-004",title:"Link Frame Too Large",description:"A message on the link exceeded the maximum frame size, or a length prefix declared one that did. The prefix is peer-controlled input, so an oversized declaration is refused rather than allocated \u2014 a desynchronised stream cannot be recovered by reading past it.",source:"runtime",severity:"fatal"},LINK_UNKNOWN_PROMPT_ACTION:{code:"AX-LINK-005",title:"Unknown Prompt Action",description:"The prompt verb was called with an action this side does not know. Loud rather than silent: an unrecognised action would otherwise return undefined, which a caller renders as an empty prompt list.",source:"runtime",severity:"fatal"},AGENT_LINK_MISSING:{code:"AX-AGENT-001",title:"Agent Started Without A Supervisor",description:"An agent process was started with no link paths in its environment, which means nothing is supervising it. It cannot guess a socket path \u2014 doing so risks connecting to a different agent's supervisor entirely.",source:"runtime",severity:"fatal"},AGENT_LINK_MALFORMED:{code:"AX-AGENT-002",title:"Malformed Agent Link",description:"The link carrier in the agent's environment is not valid JSON, or does not name both a control and a data socket. Both are required \u2014 an agent with only one connected can accept work it has no way to answer.",source:"runtime",severity:"fatal"},AGENT_BLUEPRINT_MISSING:{code:"AX-AGENT-003",title:"Agent Started Without A Blueprint",description:"An agent process was started with no blueprint path in its environment. The supervisor writes the blueprint beside the sockets before spawning; its absence means the spawn path is broken.",source:"runtime",severity:"fatal"},AGENT_NOT_READY:{code:"AX-AGENT-004",title:"Agent Still Booting",description:"A verb arrived before the agent's runtime finished booting. The link connects first so that boot failures are reportable, which leaves a brief window where the agent can be addressed but cannot answer.",source:"runtime",severity:"fatal"},CLI_AGENT_NOT_LOCAL:{code:"AX-AGENT-005",title:"Command Needs An In-Process Agent",description:"A headless CLI command booted an agent that runs as a separate process, but the command reaches into the runtime directly. This is a wiring fault: the command needs either an in-process agent or a link verb.",source:"runtime",severity:"fatal"},ENGINE_ROLE_UNBOUND_LINK:{code:"AX-ENGINE-010",title:"No Engine For Role",description:"A confined agent asked for inference on a role the supervisor has no engine bound to. Roles are resolved on the supervisor's side before the agent starts, so an unbound one here means resolution and the cognet's declaration disagree.",source:"runtime",severity:"fatal"},ENGINE_KIND_MISMATCH_LINK:{code:"AX-ENGINE-011",title:"Engine Kind Mismatch",description:"A role bound to a transform or session engine was asked to serve a generate call. Resolution already matched the declared type, so reaching here means a provider's create() disagreed with the capability it was handed.",source:"runtime",severity:"fatal"},ENGINE_MISSING:{code:"AX-ENGINE-001",title:"No Engine Configured",description:"The agent's blueprint has no engine \u2014 it cannot dispatch to a model. Set `engine` in axon.config.ts.",source:"runtime",severity:"fatal"},ENGINE_ROLE_UNBOUND:{code:"AX-ENGINE-002",title:"Engine Role Not Bound",description:"The cognet asked for an engine role that resolution did not fill. A required role stops the boot, so reaching this means an OPTIONAL role was used without checking `kernel.engine.has()` first \u2014 or the role was never declared in the cognet's `engines:` block.",source:"runtime",severity:"fatal"},RESOURCES_EXHAUSTED:{code:"AX-RES-001",title:"Not Enough Memory",description:"A local model does not fit in what is left of this machine's video memory. Nothing was evicted: another agent is using it, and taking memory out from under a running agent would slow it down invisibly. Stop an agent that is holding a model, or raise the ceiling in your profile's `resources`.",source:"runtime",severity:"degraded",expected:!0},ENGINE_PIN_UNAVAILABLE:{code:"AX-ENGINE-004",title:"Model Not Available",description:"The agent pins a model no declared provider can supply. The agent still runs \u2014 resolution picked the best available model instead \u2014 but it is NOT the one that was asked for. Declare the provider that supplies it in your profile, or pick a model from a provider you have.",source:"runtime",severity:"degraded",expected:!0},ENGINE_REQUIREMENTS_UNMET:{code:"AX-ENGINE-003",title:"Inference Requirements Unmet",description:"This cognet declares engine roles that nothing among the user's providers can fill. Add a provider that supplies what is missing, or run a cognet whose requirements this machine meets.",source:"runtime",severity:"fatal",expected:!0},INJECT_OUTSIDE_RUNTIME:{code:"AX-RUNTIME-001",title:"Runtime Accessed Before Boot",description:"A runtime global (axon, args) was read before the runtime finished booting.",source:"runtime",severity:"fatal"},BOOT_FAILED:{code:"AX-BOOT-001",title:"Agent Failed To Start",description:"The agent's runtime crashed while starting, before it could accept requests.",source:"runtime",severity:"fatal"},BOOT_SCRIPT_FAILED:{code:"AX-BOOT-002",title:"Boot Script Failed",description:"The agent's boot.vue threw while rendering \u2014 check the script setup block for the error.",source:"runtime",severity:"fatal"},BOOT_SCRIPT_INVALID:{code:"AX-BOOT-003",title:"Boot Script Malformed",description:"The agent's boot.vue has content outside its recognized <script>/<template> blocks, or otherwise failed to parse as a valid SFC.",source:"runtime",severity:"fatal"},COGNET_ACCESSED_BEFORE_LOAD:{code:"AX-COGNET-001",title:"Cognet Accessed Before Load",description:"A cognet global (kernel, phase, system, blueprint) was read before the brain finished loading, or outside the loop body that owns it.",source:"cognet",severity:"fatal"},COGNET_LOOP_ALREADY_DECLARED:{code:"AX-COGNET-002",title:"Loop Already Declared",description:"A cognet's main() called loop() more than once \u2014 the loop is the program's entire main body and can only be declared once.",source:"cognet",severity:"fatal"},COGNET_ALREADY_LOADED:{code:"AX-COGNET-003",title:"Cognet Bound To A Different Kernel",description:"This cognet instance already loaded against a different kernel ABI \u2014 a reload produced a conflicting bind instead of a clean swap.",source:"cognet",severity:"fatal"},COGNET_NO_LOOP:{code:"AX-COGNET-004",title:"Cognet Declared No Loop",description:"The cognet's main() ran (or was woken) without ever declaring loop() \u2014 there is no program to run.",source:"cognet",severity:"fatal"},COGNET_MAX_TICKS:{code:"AX-COGNET-005",title:"Cognet Exceeded Max Ticks",description:"The cognet's loop ran more ticks in one wake than its configured limit allows \u2014 likely a runaway loop that never calls stop().",source:"cognet",severity:"fatal"},COGNET_ABI_MISMATCH:{code:"AX-COGNET-006",title:"Cognet ABI Mismatch",description:"The compiled cognet targets a kernel ABI version the running kernel doesn't provide \u2014 rebuild the cognet against the current framework version.",source:"cognet",severity:"fatal"},COGNET_MISSING:{code:"AX-COGNET-007",title:"No Compiled Cognet",description:"The blueprint points at a compiled cognet bundle that doesn't exist on disk yet \u2014 run `axon prepare` before booting.",source:"cognet",severity:"fatal"},COGNET_HASH_MISMATCH:{code:"AX-COGNET-008",title:"Cognet Bundle Hash Mismatch",description:"The compiled cognet bundle on disk doesn't match the hash the blueprint expects \u2014 it's stale or was tampered with. Run `axon prepare` again.",source:"cognet",severity:"fatal"},COGNET_INVALID:{code:"AX-COGNET-009",title:"Invalid Cognet Bundle",description:"The compiled cognet's default export isn't a real cognet definition \u2014 the compile step produced something malformed.",source:"cognet",severity:"fatal"},COGNET_IDENTITY_MISMATCH:{code:"AX-COGNET-010",title:"Cognet Identity Mismatch",description:"The compiled cognet artifact's own name doesn't match what the blueprint declared \u2014 the wrong bundle may be at this path.",source:"cognet",severity:"fatal"},COGNET_CONFIG_MISSING:{code:"AX-COGNET-011",title:"Cognet Config Missing",description:"No cognet.config.ts was found in the cognet's source directory \u2014 every cognet needs one to declare its identity.",source:"cognet",severity:"fatal"},COGNET_BUILD_FAILED:{code:"AX-COGNET-012",title:"Cognet Failed To Compile",description:"Bundling the cognet's source into a runnable artifact failed \u2014 check the build log for the underlying syntax or import error.",source:"cognet",severity:"fatal"},COGNET_RUNTIME_UNAVAILABLE:{code:"AX-COGNET-014",title:"Cognet Runtime Temporarily Unavailable",description:"The cognet runtime is declared but not present on disk \u2014 the dependency tree is mid-rewrite. Transient: the reload keeps the previous blueprint and picks the change up on the next watch event.",source:"cognet",severity:"recovered"},COGNET_AMBIGUOUS:{code:"AX-COGNET-015",title:"Two Cognets Declared",description:"The agent both declares `cognet:` in axon.config.ts and holds an inline cognet at `cognet/`. An agent has exactly one brain, and choosing between them silently would either ignore a directory of source or overrule what the author wrote. Keep one.",source:"cognet",severity:"fatal"},COGNET_NOT_FOUND:{code:"AX-COGNET-013",title:"Cognet Not Found",description:"The cognet named by `cognet:` in axon.config.ts could not be located. The detail says where it was looked for \u2014 a registry that answered 404, or a node_modules tree it was missing from. Check the specifier for a typo, and check which registry the CLI is pointed at (AXON_API_BASE).",source:"cognet",severity:"fatal",expected:!0},MODULE_SPECIFIER_INVALID:{code:"AX-PROJECT-005",title:"Invalid Module Specifier",description:"Module names must be scoped as @scope/name. The registry does not accept unscoped packages, so an unscoped specifier can never resolve.",source:"manifest",severity:"fatal"},CONFIG_MODULES_UNPARSEABLE:{code:"AX-PROJECT-006",title:"Could Not Edit axon.config.ts",description:"The install succeeded but the module entry could not be written into the config's modules array automatically \u2014 add or remove it by hand.",source:"manifest",severity:"fatal"},CONFIG_ENGINE_DEPRECATED:{code:"AX-PROJECT-033",title:"`engine:` Is Deprecated And Ignored",description:"This agent's axon.config.ts declares `engine:`, which the runtime no longer reads \u2014 inference is resolving against the profile's providers instead. Use `model: \"codex:gpt-5.6-terra\"` for a cortex pin, and `providers: [...]` for a source the user would not otherwise have.",source:"manifest",severity:"degraded"},MODULE_DEPENDENCY_INSTALL_FAILED:{code:"AX-PROJECT-004",title:"Module Dependencies Failed To Install",description:"The module source was downloaded, but its npm dependencies could not be materialized for the agent. Resolve the package-manager error and run the install again.",source:"manifest",severity:"fatal"},BLUEPRINT_NOT_LOADED:{code:"AX-PROJECT-002",title:"Blueprint Accessed Before Load",description:"Something read the blueprint's current value before load() had ever run.",source:"manifest",severity:"fatal"},AGENT_INVALID:{code:"AX-PROJECT-003",title:"Invalid Agent Directory",description:"The agent root has no package.json \u2014 every agent is a real package, this one isn't.",source:"manifest",severity:"fatal"},CORRUPT_JSON:{code:"AX-PROJECT-016",title:"Corrupt JSON File",description:"A stored JSON file failed to parse \u2014 it may have been hand-edited into an invalid state, or a write was interrupted mid-flight.",source:"manifest",severity:"fatal"},FILE_UNREADABLE:{code:"AX-PROJECT-032",title:"File Could Not Be Read",description:"A file exists but could not be read \u2014 most often a permissions problem, a directory where a file was expected, or a disk error. Distinct from a missing file, which is an ordinary absent-surface state.",source:"manifest",severity:"fatal"},PROVIDER_NOT_CONNECTED:{code:"AX-TUI-011",title:"Provider Not Connected",description:"The selected model routes through a provider (OpenRouter, Codex) that isn't connected yet \u2014 connect it before picking a model on that route.",source:"tui",severity:"fatal",expected:!0},PALETTE_INPUT_REQUIRED:{code:"AX-TUI-012",title:"Required Input Missing",description:"A palette command needs a value for this field before it can run.",source:"tui",severity:"fatal",expected:!0},BENCH_NO_CASES:{code:"AX-TUI-013",title:"Bench Declared No Cases",description:"The bench's test file ran to completion under Bun but never declared a single benchmark case.",source:"tui",severity:"fatal"},PROJECT_NOT_FOUND:{code:"AX-PROJECT-017",title:"Project Not Found",description:"No axon.config.ts, module.config.ts, cognet.config.ts, bench.config.ts, or prompt.config.ts was found at this path \u2014 it isn't a recognized project directory.",source:"manifest",severity:"fatal",expected:!0},PROJECT_WRONG_KIND:{code:"AX-PROJECT-011",title:"Wrong Project Kind",description:"This command targets one project kind, and the directory holds another \u2014 run the command that matches what is actually here.",source:"manifest",severity:"fatal",expected:!0},PROJECT_EXISTS:{code:"AX-PROJECT-018",title:"Project Already Exists",description:"Scaffolding refused to overwrite a directory that already exists \u2014 remove it or pick a different name first.",source:"manifest",severity:"fatal"},TYPEGEN_NO_BLUEPRINT:{code:"AX-PROJECT-007",title:"Typegen Needs A Loaded Blueprint",description:"Agent-kind typegen was called without a blueprint \u2014 its declared surfaces are the source of the generated types.",source:"manifest",severity:"fatal"},DEPLOY_AGENTS_ONLY:{code:"AX-PROJECT-008",title:"Only Agents Can Deploy",description:"A module was asked to deploy on its own \u2014 modules only run installed inside an agent, deploy the agent instead.",source:"manifest",severity:"fatal"},PUBLISH_UNSUPPORTED_KIND:{code:"AX-PROJECT-009",title:"This Project Kind Cannot Publish",description:"The registry accepts agents, modules, cognets, benches and prompts. Extensions are not accepted yet \u2014 the `registry_artifact_kind` enum needs the value first, and publishing before then would register under the wrong kind and claim the name in the shared namespace. A profile is never publishable: it holds one person's credentials, history and agents. See KINDS[kind].publishable.",source:"manifest",severity:"fatal"},MODEL_SPECIFIER_INVALID:{code:"AX-MODEL-001",title:"Malformed Model Specifier",description:"A `models:` entry in cognet.config.ts could not be parsed. The short form is `hf:owner/repo/path/to/file` \u2014 a repo alone is ambiguous, since one repo holds many weights.",source:"manifest",severity:"fatal"},MODEL_FETCH_FAILED:{code:"AX-MODEL-002",title:"Model Weights Could Not Be Fetched",description:"A declared model could not be downloaded. Check the repo, file path and revision, and that the machine can reach the registry. A brain without its weights is broken rather than degraded, so this fails at prepare instead of at first inference.",source:"manifest",severity:"fatal"},MODEL_HASH_MISMATCH:{code:"AX-MODEL-003",title:"Model Weights Failed Verification",description:"Downloaded bytes did not hash to the expected value \u2014 the upstream file changed, or the download was corrupted. Nothing is cached: storing unverified weights would make every later run trust them.",source:"manifest",severity:"fatal"},MODEL_NOT_CACHED:{code:"AX-MODEL-004",title:"Declared Model Is Not Cached",description:"`--frozen` asserts the machine is already provisioned, so it will not fetch. Run `axon prepare` without --frozen to populate the model cache.",source:"manifest",severity:"fatal"},PREPARE_FROZEN_DRIFT:{code:"AX-PROJECT-014",title:"Dependencies Drifted From The Lockfile",description:"`--frozen` asserts that package.json, the lockfile and node_modules already agree. Something did not: a dependency is missing, at a version outside its declared range, or declared but no longer selected. Run `axon prepare` without --frozen to reconcile, and commit the result.",source:"manifest",severity:"fatal"},PUBLISH_VERIFY_FAILED:{code:"AX-PROJECT-013",title:"Artifact Does Not Compile",description:"The package was built, but compiling it the way a consumer would failed \u2014 so publishing it would ship something nobody can install. Usually a file the source imports was left out of the package. Published versions are immutable, so this is caught before upload rather than after.",source:"manifest",severity:"fatal"},DEPLOY_PROVISION_FAILED:{code:"AX-PROJECT-012",title:"Deployment Provisioning Failed",description:"The agent was published, but the cloud control plane could not provision its runtime. The request ID identifies the server-side failure.",source:"manifest",severity:"fatal"},DEPLOY_RUNTIME_FAILED:{code:"AX-PROJECT-035",title:"Agent Failed To Start",description:"Cloud infrastructure was provisioned, but the agent process failed during boot. The reported runtime diagnostic identifies the immediate cause.",source:"runtime",severity:"fatal"},DEPLOY_ENV_RESERVED:{code:"AX-PROJECT-036",title:"Reserved Deployment Variable",description:"The production .env file attempts to override a variable owned by the Axon runtime or Cloud Run.",source:"manifest",severity:"fatal"},DEPLOY_ENV_INVALID:{code:"AX-PROJECT-015",title:"Invalid Deployment Variable",description:"The production .env file contains a key that is not a valid environment variable name.",source:"manifest",severity:"fatal"},BUNDLE_MODULE_COLLISION:{code:"AX-PROJECT-019",title:"Module Name Collision",description:"A hard-imported source module's name collides with an already-installed registry module of the same name.",source:"manifest",severity:"fatal"},BUNDLE_INVALID:{code:"AX-PROJECT-010",title:"Invalid Bundle Source",description:"The directory being bundled has no package.json, or its package.json has no name \u2014 every bundle needs a real package identity.",source:"manifest",severity:"fatal"},BUNDLE_TAR_MISSING:{code:"AX-PROJECT-020",title:"tar Not Found",description:"Bundling shells out to the system's tar binary, which isn't on PATH \u2014 install Git for Windows or use WSL on that platform.",source:"manifest",severity:"fatal"},BUNDLE_TAR_FAILED:{code:"AX-PROJECT-021",title:"tar Failed",description:"The tar subprocess exited non-zero while building a bundle archive.",source:"manifest",severity:"fatal"},BENCH_RUN_NOT_FOUND:{code:"AX-BENCH-001",title:"Bench Run Not Found",description:"No recorded bench run exists with this id.",source:"bench",severity:"fatal",expected:!0},BENCH_NOT_FOUND:{code:"AX-BENCH-002",title:"Bench Not Found",description:"No bench.config.ts was found at this path \u2014 it isn't a recognized bench project.",source:"bench",severity:"fatal",expected:!0},BENCH_TESTS_NOT_FOUND:{code:"AX-BENCH-003",title:"Bench Test Files Not Found",description:"The bench config declares test files that don't exist on disk.",source:"bench",severity:"fatal",expected:!0},BENCH_LOCAL_REF_NOT_FOUND:{code:"AX-BENCH-004",title:"Bench Local Reference Not Found",description:"A factor variable references a local file/directory that doesn't exist.",source:"bench",severity:"fatal",expected:!0},BENCH_CONFIG_INVALID:{code:"AX-BENCH-005",title:"Bench Config Invalid",description:"bench.config.ts failed to evaluate or didn't produce a valid bench definition.",source:"bench",severity:"fatal"},BENCH_PACKAGE_NOT_FOUND:{code:"AX-BENCH-006",title:"Bench Package Not Found",description:"No package.json exists at the bench root \u2014 every bench project needs one for identity.",source:"bench",severity:"fatal",expected:!0},BENCH_PACKAGE_NAME_REQUIRED:{code:"AX-BENCH-007",title:"Bench Package Name Required",description:"The bench's package.json has no name field.",source:"bench",severity:"fatal",expected:!0},BENCH_PACKAGE_VERSION_REQUIRED:{code:"AX-BENCH-008",title:"Bench Package Version Required",description:"The bench's package.json has no version field.",source:"bench",severity:"fatal",expected:!0},BENCH_CONTEXT_MISSING:{code:"AX-BENCH-009",title:"Bench Context Missing",description:"The benchmark preload needs AXON_BENCH_CONTEXT set \u2014 it was run outside the bench harness.",source:"bench",severity:"fatal"},BENCH_NO_ACTIVE_CASE:{code:"AX-BENCH-010",title:"No Active Bench Case",description:"A bench emission (measurement, artifact) happened outside any running Bun test \u2014 these calls must occur inside a test case.",source:"bench",severity:"fatal"},BENCH_WORKSPACE_UNAVAILABLE:{code:"AX-BENCH-011",title:"Bench Workspace Unavailable",description:"The bench's workspace directory hasn't been materialized yet for this run.",source:"bench",severity:"fatal"},BENCH_AGENT_UNRESOLVED:{code:"AX-BENCH-012",title:"Bench Agent Unresolved",description:"The bench's declared subject agent isn't a prepared local agent \u2014 run `axon prepare` on it first.",source:"bench",severity:"fatal"},BENCH_MEASUREMENT_UNKNOWN:{code:"AX-BENCH-013",title:"Unknown Bench Measurement",description:"A measurement was emitted under an id the bench config never declared.",source:"bench",severity:"fatal"},BENCH_MEASUREMENT_TYPE:{code:"AX-BENCH-014",title:"Bench Measurement Type Mismatch",description:"A measurement's emitted value doesn't match the type its bench config declaration expects.",source:"bench",severity:"fatal"},BENCH_MEASUREMENT_DOMAIN:{code:"AX-BENCH-015",title:"Bench Measurement Out Of Domain",description:"A measurement's emitted value falls outside the range or category the bench config declares for it.",source:"bench",severity:"fatal"},BENCH_DIMENSION_UNKNOWN:{code:"AX-BENCH-016",title:"Unknown Bench Dimension",description:"A dimension value was set under an id the bench config never declared.",source:"bench",severity:"fatal"},BENCH_DIMENSION_DOMAIN:{code:"AX-BENCH-017",title:"Bench Dimension Out Of Domain",description:"A dimension's set value isn't one of the categories its bench config declares.",source:"bench",severity:"fatal"},BENCH_AXIS_UNKNOWN:{code:"AX-BENCH-018",title:"Unknown Bench Factor",description:"Something referenced a factor id the running bench's coordinate never assigned a value to.",source:"bench",severity:"fatal"},BENCH_ARTIFACT_UNKNOWN:{code:"AX-BENCH-019",title:"Unknown Bench Artifact",description:"An artifact was emitted under an id the bench config never declared.",source:"bench",severity:"fatal"},BENCH_ARTIFACT_MEDIA_TYPE:{code:"AX-BENCH-020",title:"Bench Artifact Media Type Not Allowed",description:"An artifact was emitted with a media type its bench config declaration doesn't allow.",source:"bench",severity:"fatal"},BENCH_SCHEMA_UNREADABLE:{code:"AX-BENCH-030",title:"Bench Schema Unreadable",description:"bench.config.ts could not be parsed while extracting the measurement schema.",source:"bench",severity:"fatal"},BENCH_SCHEMA_EMPTY:{code:"AX-BENCH-031",title:"Bench Schema Empty",description:"defineBench<Schema> was given a type with no properties \u2014 an empty schema and a failed extraction must never look alike.",source:"bench",severity:"fatal"},BENCH_SCHEMA_UNSUPPORTED_TYPE:{code:"AX-BENCH-032",title:"Bench Measurement Type Unsupported",description:"A measurement is not a boolean, number, union of string literals, or string.",source:"bench",severity:"fatal"},BENCH_SCHEMA_EXTRACTION_FAILED:{code:"AX-BENCH-033",title:"Bench Schema Extraction Failed",description:"The schema worker did not return a schema. Prepare fails rather than continuing with an empty one, which would silently make every measurement undeclared.",source:"bench",severity:"fatal"},BENCH_AXIS_NOT_FOUND:{code:"AX-BENCH-021",title:"Bench Axis Not Found",description:"The bench config's matrix has no axis with this key.",source:"bench",severity:"fatal",expected:!0},BENCH_AXIS_VALUE_NOT_FOUND:{code:"AX-BENCH-022",title:"Bench Axis Value Not Found",description:"The bench config's matrix axis has no declared value with this id.",source:"bench",severity:"fatal",expected:!0},BENCH_WORKSPACE_ESCAPE:{code:"AX-BENCH-023",title:"Bench Workspace Path Escapes Root",description:"A workspace source entry resolved to a path outside the workspace directory \u2014 refused rather than materialized.",source:"bench",severity:"fatal"},BENCH_WORKSPACE_SYMLINK_UNSUPPORTED:{code:"AX-BENCH-024",title:"Bench Workspace Symlinks Unsupported",description:"A workspace source contains a symlink \u2014 not supported when materializing a bench workspace.",source:"bench",severity:"fatal"},BENCH_WORKSPACE_OUTSIDE_ROOT:{code:"AX-BENCH-025",title:"Bench Template Outside Root",description:"A workspace template's declared source path resolves outside the bench project root.",source:"bench",severity:"fatal"},BENCH_WORKSPACE_SOURCE_NOT_FOUND:{code:"AX-BENCH-026",title:"Bench Template Not Found",description:"A workspace template's declared source path isn't a real directory.",source:"bench",severity:"fatal",expected:!0},BENCH_LOG_INVALID:{code:"AX-BENCH-027",title:"Bench Log Invalid",description:"A bench run's event log is missing an entry its projection requires \u2014 the log is incomplete or was written out of order.",source:"bench",severity:"fatal"},TOOL_DECLARE_FAILED:{code:"AX-BLUEPRINT-002",title:"Tool Declaration Failed",description:"Compiling a src/tools/*.ts file's TypeScript declarations failed \u2014 the worker subprocess reported a compile error.",source:"manifest",severity:"fatal"},TOOL_BUNDLE_FAILED:{code:"AX-BLUEPRINT-006",title:"Tool Bundle Failed",description:"Bundling a src/tools/*.ts file to self-contained source failed \u2014 the bundler subprocess reported an error. Tools are bundled so the sandbox loads them without mounting the project; a bundle failure means the tool cannot enter the box.",source:"manifest",severity:"fatal"},ROUTE_LOAD_FAILED:{code:"AX-BLUEPRINT-007",title:"Route Load Failed",description:"A file in server/api/ could not be imported. The agent would serve an endpoint set that is not the declared one \u2014 a caller gets a 404 for a route whose file exists.",source:"manifest",severity:"fatal"},SCRIPT_LOAD_FAILED:{code:"AX-BLUEPRINT-008",title:"Script Load Failed",description:"A file in src/scripts/ could not be processed. `axon run <name>` would report the script as not found while its file sits in the project.",source:"manifest",severity:"fatal"},PLUGIN_LOAD_FAILED:{code:"AX-BLUEPRINT-009",title:"Plugin Load Failed",description:"A plugin could not be imported. Plugins wire server behaviour at boot; one silently missing means the agent runs without behaviour its author declared.",source:"manifest",severity:"fatal"},MIDDLEWARE_LOAD_FAILED:{code:"AX-BLUEPRINT-010",title:"Middleware Load Failed",description:"A middleware file could not be imported. Middleware commonly carries auth and validation, so a silently skipped one is a request path running without the checks its author wrote.",source:"manifest",severity:"fatal"},PROMPT_INTROSPECT_FAILED:{code:"AX-BLUEPRINT-011",title:"Prompt Introspection Failed",description:"A .vue prompt could not be introspected for its props. The prompt would render without the inputs it declares, or not at all.",source:"manifest",severity:"fatal"},CONFIG_NOT_FOUND:{code:"AX-BLUEPRINT-003",title:"Config Not Found",description:"No axon.config.ts exists at this path.",source:"manifest",severity:"fatal",expected:!0},CONFIG_LOAD_FAILED:{code:"AX-BLUEPRINT-004",title:"Config Failed To Load",description:"axon.config.ts threw or failed to evaluate \u2014 check the file for a syntax or runtime error.",source:"manifest",severity:"fatal"},CONFIG_INVALID:{code:"AX-BLUEPRINT-005",title:"Config Invalid",description:"axon.config.ts evaluated but never called defineAgent() \u2014 every agent config must produce one.",source:"manifest",severity:"fatal"},ENGINE_NO_DONE:{code:"AX-KERNEL-001",title:"Engine Stream Ended Without Completing",description:"The model driver's stream ended without ever emitting a completion event \u2014 the engine likely disconnected or crashed mid-response.",source:"kernel",severity:"fatal"},ENGINE_NOT_CONNECTED:{code:"AX-KERNEL-015",title:"Provider Not Connected",description:"This model's route is not connected to your account yet \u2014 run `:provider <name> connect` for the provider named below, or pick a model on a route you are already signed in to.",source:"kernel",severity:"fatal",expected:!0},ENGINE_AUTH_FAILED:{code:"AX-KERNEL-016",title:"Provider Rejected Your Credentials",description:"The provider refused the credential this agent is using \u2014 it has expired, been revoked, or is for a different account. Reconnect the provider, or pick a model on a route you are signed in to.",source:"kernel",severity:"fatal",expected:!0},ENGINE_RATE_LIMITED:{code:"AX-KERNEL-017",title:"Provider Rate Limit Reached",description:"The provider is refusing further calls right now \u2014 either too many requests in a short window, or a subscription whose allowance is spent. Waiting usually clears the first; the second needs a plan change or a different model.",source:"kernel",severity:"fatal",expected:!0},ENGINE_QUOTA_EXHAUSTED:{code:"AX-KERNEL-018",title:"Provider Credits Exhausted",description:"This route has no credit left to spend. Top it up, or switch to a model on a route that does \u2014 the conversation is intact either way.",source:"kernel",severity:"fatal",expected:!0},ENGINE_REQUEST_REJECTED:{code:"AX-KERNEL-019",title:"Provider Rejected The Request",description:"The provider refused this call as malformed or unsupported \u2014 commonly a model id it does not serve, a context window this conversation has outgrown, or a parameter that route does not accept.",source:"kernel",severity:"fatal",expected:!0},ENGINE_UNREACHABLE:{code:"AX-KERNEL-020",title:"Could Not Reach The Provider",description:"The provider could not be reached, or kept failing, across every retry \u2014 usually a network problem on this machine or an outage on their side. Nothing about this agent needs changing; try again.",source:"kernel",severity:"fatal",expected:!0},ENGINE_STREAM_FAILED:{code:"AX-KERNEL-008",title:"Engine Stream Failed",description:"The model driver's stream failed and exhausted its retries (or the failure wasn't retryable) \u2014 see context for the provider's fault code.",source:"kernel",severity:"fatal"},CODEX_NOT_CONNECTED:{code:"AX-KERNEL-012",title:"Codex Subscription Not Connected",description:"This agent uses a Codex model, but your Axon account is not connected to ChatGPT \u2014 run :provider codex connect and try again.",source:"kernel",severity:"fatal",expected:!0},RUN_IN_PROGRESS:{code:"AX-KERNEL-002",title:"A Wake Is Already Running",description:"The kernel only executes one wake at a time \u2014 a new run was requested while the previous one was still active.",source:"kernel",severity:"recovered"},RUN_RESERVATION_EXPIRED:{code:"AX-KERNEL-003",title:"Wake Reservation Expired",description:"The reserved execution slot for this wake is no longer active \u2014 it was released before the run could start.",source:"kernel",severity:"fatal"},NO_COGNET_LOADED:{code:"AX-KERNEL-004",title:"No Cognet Loaded",description:"The kernel tried to execute a wake, but the blueprint carried no cognet definition to run it against.",source:"kernel",severity:"fatal"},SYSCALL_OUTSIDE_RUN:{code:"AX-KERNEL-005",title:"Syscall Outside An Active Run",description:"A kernel syscall (engine.stream and similar) was made with no active wake to attribute it to.",source:"kernel",severity:"fatal"},CAPSULE_ACCESSED_BEFORE_BOOT:{code:"AX-KERNEL-007",title:"Capsule Accessed Before Boot",description:"Something reached for the live capsule instance before boot() had run \u2014 there is no sandbox yet to hand back.",source:"kernel",severity:"fatal"},COGNET_EMIT_FORBIDDEN:{code:"AX-KERNEL-009",title:"Cognet Emit Forbidden",description:"A cognet tried to emit an event outside the cognet:* namespace \u2014 the ABI only lets a cognet narrate its own telemetry, never forge kernel machinery events.",source:"kernel",severity:"fatal"},KNOWLEDGE_NOT_FOUND:{code:"AX-KERNEL-011",title:"Knowledge Entry Not Found",description:"A cognet read a knowledge entry that does not exist. The knowledge store is not a cache \u2014 a brain reading something the catalogue advertised has hit a real inconsistency, so this is loud rather than an empty result.",source:"kernel",severity:"fatal",expected:!0},KNOWLEDGE_READONLY:{code:"AX-KERNEL-013",title:"Knowledge Entry Is Read-Only",description:"A cognet tried to write or remove knowledge contributed by a module. Module material lives inside its own package and the next install would destroy any change \u2014 so this fails loudly rather than succeeding and vanishing later. An agent's own data/knowledge/ is writable.",source:"kernel",severity:"fatal",expected:!0},KNOWLEDGE_RECORD_FAILED:{code:"AX-KERNEL-014",title:"Knowledge Mutation Went Unrecorded",description:"A knowledge write or remove succeeded on disk, but the session record of it could not be committed. The mutation is real and already visible to the agent; only its audit trail is missing, so this is reported rather than thrown \u2014 the caller cannot undo a completed write. It matters because 'the agent rewrote its own memory' is the fact you want weeks later when behaviour drifts, and here the ledger and the filesystem disagree.",source:"kernel",severity:"degraded"},KNOWLEDGE_ESCAPE:{code:"AX-KERNEL-021",title:"Knowledge Path Escapes Store",description:"A knowledge name resolved outside the store root. Names are identifiers, not paths \u2014 traversal is refused at the boundary rather than trusted not to happen.",source:"kernel",severity:"fatal"},SCHEDULER_MODE_MISMATCH:{code:"AX-KERNEL-010",title:"Scheduler Mode Mismatch",description:"A caller used the wrong wake verb for the cognet's mode: continuous cognets advance via tick(), driven by the body's clock; invocation cognets wake on a stimulus via request()/stream().",source:"kernel",severity:"fatal"},THREAD_UNKNOWN_PARENT:{code:"AX-SESSION-001",title:"Thread Branched From Unknown Parent",description:"A thread's recorded lineage points at a parent thread id that isn't registered in this session \u2014 the session index is inconsistent.",source:"thread",severity:"fatal"},THREAD_NOT_FOUND:{code:"AX-SESSION-002",title:"Thread Not Found",description:"The requested thread id isn't registered in this session.",source:"thread",severity:"fatal",expected:!0},THREAD_BRANCH_UNKNOWN:{code:"AX-SESSION-003",title:"Cannot Branch Unknown Thread",description:"A branch was requested from a parent thread id that isn't registered in this session.",source:"thread",severity:"fatal"},SENSORY_WRITE_FAILED:{code:"AX-SESSION-004",title:"Sensory Ring Write Failed",description:"A dense sense entry (audio or visual) could not be written to the session's sensory ring \u2014 usually a full or read-only data directory. Delivery to the cognet is unaffected; the debug window for this session will have a gap.",source:"runtime",severity:"degraded"},NO_COGNET:{code:"AX-BLUEPRINT-001",title:"No Cognet Declared",description:"The blueprint carries no cognet definition \u2014 an agent cannot run without a brain. The CLI or test harness must construct and pass one.",source:"runtime",severity:"fatal"},CONTROL_PATH_NOT_FOUND:{code:"AX-CONTROL-001",title:"Control Path Not Found",description:"A control-channel call named a method the peer does not expose. The two ends disagree about the surface \u2014 usually a TUI and an extension built from different versions.",source:"server",severity:"fatal",expected:!0},CONTROL_PATH_NOT_CALLABLE:{code:"AX-CONTROL-002",title:"Control Path Not Callable",description:"A control-channel call resolved to a value on the peer's handle that is not a function.",source:"server",severity:"fatal"},CONTROL_CALL_FAILED:{code:"AX-CONTROL-003",title:"Control Call Failed",description:"The peer served a control-channel call and it threw. The remote message is carried here \u2014 the failure surfaces at the local call site rather than being returned as a falsy value.",source:"server",severity:"fatal"},CONTROL_CLOSED:{code:"AX-CONTROL-004",title:"Control Channel Closed",description:"A control-channel call was made, or was still in flight, when the channel closed. In-flight calls reject on close rather than hanging forever on an answer that is no longer coming.",source:"server",severity:"fatal"},CONTROL_UNAUTHORIZED:{code:"AX-CONTROL-005",title:"Control Handshake Rejected",description:"A connection to the control socket presented a missing or incorrect token. The token lives in the instance record, which is readable only by the owning user \u2014 a mismatch means the caller is not the local Fleet extension.",source:"server",severity:"fatal"},PLUGIN_BOOT_FAILED:{code:"AX-SERVER-001",title:"Plugin Failed During Boot",description:"A server plugin threw while running at boot \u2014 plugins are the one place in server startup where a failure must abort the boot rather than being warned and skipped.",source:"server",severity:"fatal"},HANDLE_SHUTDOWN_FAILED:{code:"AX-RUNTIME-002",title:"Handle Failed To Shut Down",description:"One of the runtime's owned handles (kernel, etc.) threw during shutdown \u2014 teardown is error-isolated, so the others still ran, but this one didn't close cleanly.",source:"runtime",severity:"fatal"},BUS_HANDLER_FAILED:{code:"AX-RUNTIME-004",title:"Bus Handler Failed",description:"A handler subscribed to a runtime bus event threw. Handler failures are non-fatal by design \u2014 the remaining handlers still run \u2014 but they are recorded rather than swallowed, since plugins and modules register handlers and a silently-broken one is invisible rot.",source:"runtime",severity:"degraded"},TOOL_CALL_FAILED:{code:"AX-RUNTIME-003",title:"Tool Call Failed",description:"An axon.tools.<namespace>.<fn>() call from script-land completed with a non-ok result from the capsule \u2014 unwrapped here into a normal throw, since script-land expects the ordinary call/throw contract, not the kernel's own stable-result shape.",source:"runtime",severity:"fatal"},CAPSULE_TOOL_TIMEOUT:{code:"AX-CAPSULE-001",title:"Tool Load Timed Out",description:"The sandbox never confirmed loading a declared tool within the timeout \u2014 it may be stuck on a slow import or the subprocess is unresponsive.",source:"capsule",severity:"fatal"},CAPSULE_TOOL_SCOPE_MISMATCH:{code:"AX-CAPSULE-002",title:"Tool Scope Mismatch",description:"A tool's declared exports don't match what it actually exported once loaded in the sandbox \u2014 the bundled source and its declaration have drifted apart.",source:"capsule",severity:"fatal"},CAPSULE_TOOL_FAILED:{code:"AX-CAPSULE-003",title:"Tool Failed To Load",description:"A declared tool failed to load into the sandbox \u2014 its source may be malformed, too large to import, or the subprocess exited before confirming.",source:"capsule",severity:"fatal"},CAPSULE_CONFINE_UNAVAILABLE:{code:"AX-CAPSULE-004",title:"OS Confinement Unavailable",description:"The policy requested OS confinement (isolation: auto) but the host is missing a required primitive (bubblewrap, systemd, nft, or the axon-agent user). Run `axon install`, or set isolation: none to opt out explicitly. The capsule refuses to boot rather than silently run unconfined.",source:"capsule",severity:"fatal"},CAPSULE_CONFINE_USER_UNRESOLVED:{code:"AX-CAPSULE-005",title:"Confinement User Unresolved",description:"The confinement user exists but its numeric uid/gid could not be read \u2014 the box cannot drop privileges without them. The host user database may be inconsistent.",source:"capsule",severity:"fatal"},CAPSULE_BOOT_FAILED:{code:"AX-CAPSULE-006",title:"Capsule Failed To Boot",description:"The sandbox subprocess exited or reported failure before completing the boot handshake. The captured stderr in the error context is the real cause \u2014 most often a confinement mount that could not be satisfied (a declared fs path that does not exist) or a runtime that could not start.",source:"capsule",severity:"fatal"},CAPSULE_BOOT_TIMEOUT:{code:"AX-CAPSULE-007",title:"Capsule Boot Timed Out",description:"The sandbox subprocess did not report ready within the boot timeout. Its captured stderr is in the error context; if empty, the subprocess may be hung rather than crashed.",source:"capsule",severity:"fatal"},CAPSULE_SPAWN_FAILED:{code:"AX-CAPSULE-008",title:"Capsule Spawn Failed",description:"The capsule subprocess command could not be spawned at all \u2014 the interpreter or confinement wrapper was not found, or PATH is unset. Check that bun (and, under confinement, bwrap/systemd-run) are on PATH.",source:"capsule",severity:"fatal"},CAPSULE_WIRE_CLOSED:{code:"AX-CAPSULE-009",title:"Capsule Wire Closed",description:"A command was sent to the sandbox after its stdin pipe was gone \u2014 the subprocess has exited or is mid-teardown. The caller is racing the capsule lifecycle.",source:"capsule",severity:"fatal"},CAPSULE_DOWN:{code:"AX-CAPSULE-010",title:"No Live Capsule",description:"An operation needed a running sandbox subprocess, but none is live \u2014 it is booting, restarting after a crash, or has been declared dead.",source:"capsule",severity:"fatal"},CAPSULE_ALREADY_BOOTED:{code:"AX-CAPSULE-011",title:"Capsule Already Booted",description:"boot() was called on a capsule that already has a live subprocess. Boot is once per lifetime; use update()/reload() to replace a running incarnation.",source:"capsule",severity:"fatal"},CAPSULE_INSTALL_FAILED:{code:"AX-CAPSULE-013",title:"Confinement Install Failed",description:"Provisioning the host for the hardened confinement tier failed \u2014 most often because creating the dedicated system user needs root. Re-run `axon install` with sufficient privilege.",source:"capsule",severity:"fatal"},CAPSULE_HOST_UNAVAILABLE:{code:"AX-CAPSULE-014",title:"Host Bridge Unavailable",description:"Sandboxed code called a host service, but this capsule was built with no host provider. Host calls require a wired host bridge on the manager side.",source:"capsule",severity:"fatal"},CAPSULE_CRASHED:{code:"AX-CAPSULE-015",title:"Capsule Crashed",description:"An unhandled error escaped inside the sandbox subprocess. The capsule reports it on the wire and exits immediately \u2014 after an unhandled throw the sandbox's state is unknown, and a capsule that keeps serving is worse than one that dies loudly.",source:"capsule",severity:"fatal"},CAPSULE_DEAD:{code:"AX-CAPSULE-016",title:"Capsule Dead",description:"The capsule subprocess is gone and supervision gave up restarting it. Every subsequent execution request fails until a new capsule is booted.",source:"capsule",severity:"fatal"},CAPSULE_PARSE_ERROR:{code:"AX-CAPSULE-017",title:"Capsule Wire Parse Error",description:"A line arriving from the sandbox was not a valid protocol event. The sandbox is speaking garbage \u2014 a protocol mismatch or corrupted output \u2014 and the line is dropped rather than acted on, never silently.",source:"capsule",severity:"degraded"},CAPSULE_CMD_FAILED:{code:"AX-CAPSULE-018",title:"Capsule Command Failed",description:"Code executed in the sandbox threw. This is the ordinary failure path for an agent-emitted block or a script-land run() \u2014 the error is the sandboxed code's own, surfaced verbatim.",source:"capsule",severity:"degraded"},CAPSULE_FN_FAILED:{code:"AX-CAPSULE-019",title:"Tool Call Threw",description:"A mediated tool function threw inside the sandbox. The failure is the tool's own; it propagates to the calling code unchanged and is recorded as the closing half of the call's span.",source:"capsule",severity:"degraded"},CAPSULE_PROC_DENIED:{code:"AX-CAPSULE-020",title:"Process Spawn Denied",description:"A process the sandbox tried to start was refused \u2014 denied by policy, killed before it could spawn, or the spawn itself failed. No process was created.",source:"capsule",severity:"degraded"},CAPSULE_PROC_FAILED:{code:"AX-CAPSULE-022",title:"Managed Process Failed",description:"A spawned child process errored without ever producing an exit code \u2014 an exec failure or a broken IPC channel. Distinct from a non-zero exit, which is the process running correctly and reporting a result.",source:"capsule",severity:"degraded"},CAPSULE_PROC_STDIN_FAILED:{code:"AX-CAPSULE-021",title:"Process Stdin Write Failed",description:"Writing to a managed child process's stdin failed \u2014 the process is no longer running, or its stdin has already closed.",source:"capsule",severity:"degraded"},NOT_BOOTED:{code:"AX-TUI-001",title:"No Agent Running",description:"A message was sent, or an action requiring a live agent was taken, before any agent finished booting.",source:"tui",severity:"fatal"},NOT_AUTHENTICATED:{code:"AX-TUI-002",title:"Not Logged In",description:"The action needs an active profile, but none is logged in yet.",source:"tui",severity:"fatal",expected:!0},PROFILE_NOT_AUTHENTICATED:{code:"AX-TUI-003",title:"Profile Has No Session",description:"The target profile exists but has no stored session \u2014 it has never logged in, or its session was cleared.",source:"tui",severity:"fatal",expected:!0},BACKEND_UNREACHABLE:{code:"AX-TUI-044",title:"Backend Unreachable",description:"A stored credential could not be verified because the backend could not be reached. The credential is NOT discarded \u2014 it may be perfectly valid \u2014 but it cannot be trusted until it is checked, so the action is refused rather than proceeding unverified.",source:"tui",severity:"fatal",expected:!0},PROFILE_UNKNOWN:{code:"AX-TUI-004",title:"Unknown Profile",description:"The requested profile id isn't one of the profiles stored on this machine.",source:"tui",severity:"fatal",expected:!0},SESSION_NOT_FOUND:{code:"AX-SESSION-005",title:"Session Not Found",description:"No session log exists at that path. A session is a .jsonl file under the agent's frame (`.agent/data/sessions/`); it may have been deleted, or belong to an agent that has since been removed.",source:"runtime",severity:"fatal",expected:!0},SESSION_UNREADABLE:{code:"AX-SESSION-006",title:"Session Log Unreadable",description:"The session log does not begin with a `session:header` line, so it cannot be forked or renamed. Either the file is truncated, or it was written by a version predating the header \u2014 an older log can still be read and resumed, just not copied.",source:"runtime",severity:"fatal",expected:!0},SESSION_ALREADY_RUNNING:{code:"AX-TUI-005",title:"Session Is Already Running",description:"spawn() was asked to resume a session that already has a live instance. Focus the running instance instead of booting a second runtime over the same log.",source:"tui",severity:"fatal",expected:!0},SESSION_NOT_RUNNING:{code:"AX-TUI-016",title:"Session Is Not Running",description:"focus() was pointed at a sessionId with no live instance behind it. Spawn (or resume) it first \u2014 focus is pure selection over running instances.",source:"tui",severity:"fatal",expected:!0},NO_ACTIVE_AGENT:{code:"AX-TUI-045",title:"No Active Agent",description:"The action needs a running agent, but none is active \u2014 start one first.",source:"tui",severity:"fatal",expected:!0},NO_LOCAL_PROJECT:{code:"AX-TUI-050",title:"No Local Project",description:"This agent has no project directory on this machine \u2014 it was attached over the network, so its source lives wherever it is running. Opening its config, or any other file verb, has to happen there. Focus a local agent instead.",source:"tui",severity:"fatal",expected:!0},NO_FOCUSED_INSTANCE:{code:"AX-TUI-017",title:"No Focused Agent Instance",description:"A module install/uninstall was requested with no running agent instance focused \u2014 spawn or focus one first.",source:"tui",severity:"fatal",expected:!0},MODEL_UNAVAILABLE:{code:"AX-TUI-051",title:"Model Not Available From Any Declared Provider",description:"The picked model was saved to the agent's config, but no provider this profile declares can supply it \u2014 so the running agent still uses its previous model. Connect the provider that serves it, or pick a model from the offered list.",source:"tui",severity:"fatal",expected:!0},MODEL_IMMUTABLE_DEPLOYED:{code:"AX-TUI-006",title:"Cannot Change A Deployment's Model",description:"A deployed agent's config lives in the cloud, not on this machine \u2014 its model is fixed at deploy time. Change it in the local project and deploy again.",source:"tui",severity:"fatal",expected:!0},MODULE_INSTALL_FAILED:{code:"AX-TUI-018",title:"Module Install Failed",description:"The registry installer returned an error for this module specifier \u2014 check the specifier and registry connectivity.",source:"tui",severity:"fatal"},NO_MODULES_INSTALLED:{code:"AX-TUI-019",title:"No Modules Installed",description:"The `:module uninstall` command was opened with no modules resolved into the focused instance's blueprint.",source:"tui",severity:"fatal"},SETTINGS_NOT_WRITABLE:{code:"AX-EXT-027",title:"Settings Cannot Be Written",description:"A settings change was requested on a store with no profile config behind it \u2014 nobody is logged in, or this Store was built without one (tests). Settings live in `profile.config.ts`, so there is nowhere to write them; the change was refused rather than saved somewhere nothing reads back.",source:"tui",severity:"fatal",expected:!0},REGISTRY_EMPTY:{code:"AX-TUI-047",title:"Nothing To Install",description:"The install palette was opened with no rows to show \u2014 the catalogue is still loading, the registry could not be reached, or everything published for that kind is already installed. The row itself says which.",source:"tui",severity:"fatal",expected:!0},NO_EXTENSIONS_INSTALLED:{code:"AX-TUI-046",title:"No Extensions Installed",description:"The `:ext uninstall` command was opened with no extensions declared in the active profile's profile.config.ts.",source:"tui",severity:"fatal",expected:!0},ATTACH_URL_REQUIRED:{code:"AX-TUI-048",title:"Attach URL Required",description:"`:attach` needs the address of a running agent \u2014 e.g. `:attach http://localhost:3010`. The agent must already be serving; attach binds to it and never boots anything.",source:"tui",severity:"fatal"},ATTACH_URL_INVALID:{code:"AX-TUI-049",title:"Attach URL Invalid",description:"The address is not a usable agent URL. An agent is reached over http or https and the scheme is required \u2014 `localhost:3010` is a path, `http://localhost:3010` is an address. Checked before anything connects, so a typo fails immediately rather than as a transport error.",source:"tui",severity:"fatal"},DEPLOYMENT_NOT_CONNECTABLE:{code:"AX-TUI-028",title:"Deployment Not Connectable",description:"The deployment is not in the connectable list \u2014 it may have stopped, errored, or never finished provisioning. Refresh the deployment list and try again.",source:"tui",severity:"fatal"},SUBAGENT_REMOTE_PARENT:{code:"AX-TUI-027",title:"Cannot Spawn A Subagent From A Deployment",description:"A subagent is forked from its parent's local project, and an attached deployment has no local project here \u2014 the deployed agent runs its own subagents inside its own capsule.",source:"tui",severity:"fatal"},BASE_MODEL_INSTANCE_CONFLICT:{code:"AX-TUI-026",title:"Managed Model Instance Already Running",description:"A managed base instance is already running on a different engine. The base workspace holds one shared config, so spawning a second naked model would rewrite it underneath the live instance \u2014 close the running one first.",source:"tui",severity:"fatal"},NOT_WIRED:{code:"AX-TUI-008",title:"Not Wired Yet",description:"This surface is a declared stub \u2014 the real implementation hasn't been built yet.",source:"tui",severity:"fatal"},MIC_ALREADY_CAPTURING:{code:"AX-TUI-009",title:"Mic Already Capturing",description:"capture.start() was called while a capture was already in progress \u2014 stop the current one first.",source:"tui",severity:"fatal"},MIC_CAPTURE_UNAVAILABLE:{code:"AX-TUI-010",title:"No Audio Capture Tool Found",description:"Voice input needs one of arecord, sox, or ffmpeg installed and on PATH.",source:"tui",severity:"fatal"},MIC_FFT_SIZE_MISMATCH:{code:"AX-TUI-014",title:"FFT Sample Size Mismatch",description:"computeBuckets() was called with a sample buffer that isn't exactly config.fftSize long \u2014 an internal invariant, callers must pad/trim first.",source:"tui",severity:"fatal"},MIC_CAPTURE_FAILED:{code:"AX-TUI-015",title:"Mic Capture Failed",description:"The audio capture subprocess produced no output or exited immediately \u2014 check that a microphone is available.",source:"tui",severity:"fatal"},WATCH_PATH_REQUIRED:{code:"AX-TUI-021",title:"Watch Path Required",description:"`axon watch`/`axon unwatch` need a directory argument.",source:"tui",severity:"fatal",expected:!0},WATCH_PATH_NOT_FOUND:{code:"AX-TUI-022",title:"Watch Path Not Found",description:"`axon watch` was given a directory that doesn't exist on disk.",source:"tui",severity:"fatal",expected:!0},EDITOR_NOT_SET:{code:"AX-TUI-023",title:"No Editor Configured",description:"`axon settings` needs the $EDITOR environment variable set to know which editor to open.",source:"tui",severity:"fatal"},EDITOR_LAUNCH_FAILED:{code:"AX-TUI-024",title:"Editor Failed To Launch",description:"The command in $EDITOR could not be spawned \u2014 check that it's installed and on PATH.",source:"tui",severity:"fatal"},WATCH_AND_INIT_ARGS_REQUIRED:{code:"AX-TUI-025",title:"Directory And Name Required",description:`The init palette's "watch a new directory" entry needs both a directory path and an agent name, space-separated.`,source:"tui",severity:"fatal",expected:!0},MODULE_CONFIG_LOAD_FAILED:{code:"AX-MODULE-001",title:"Module Config Failed To Load",description:"The runtime could not import a module's module.config.ts at boot \u2014 the file is missing at its resolved path, or importing it threw. A module that cannot load contributes nothing, so boot fails rather than run a partially-wired agent.",source:"runtime",severity:"fatal"},MODULE_SOURCE_DECLARED:{code:"AX-MODULE-008",title:"Module Declared As Source",description:"Uninstall was asked to remove a module that axon.config.ts declares as an IMPORT rather than by registry name. The import statement is the author's own code, so uninstall does not rewrite it \u2014 and removing the dependency alone would leave the config importing a package that is no longer declared, with the agent still loading it. Nothing was changed: delete the import and its entry in modules: [...] by hand.",source:"cli",severity:"fatal"},MODULE_NOT_INSTALLED:{code:"AX-MODULE-003",title:"Module Not Installed",description:"A plugin asked for the options of a module this agent does not have installed \u2014 almost always a name mismatch between the plugin and the module that ships it. Reported rather than defaulted: handing back an empty options bag would let a hardware module open the wrong device and never say so.",source:"runtime",severity:"fatal"},MODULE_OPTIONS_INVALID:{code:"AX-MODULE-002",title:"Invalid Module Options",description:"The options declared for a module under modules.<name> in axon.config.ts do not satisfy the module's options schema \u2014 a required option is missing or a value has the wrong type.",source:"runtime",severity:"fatal"},MODULE_SETUP_FAILED:{code:"AX-MODULE-007",title:"Module Setup Failed",description:"A module's setup() threw during agent boot. Setup runs sequentially in blueprint order and a failure is total \u2014 no later module is wired, and the agent does not boot half-configured.",source:"runtime",severity:"fatal"},MODULE_SERVER_NOT_WIRED:{code:"AX-MODULE-004",title:"Module Server API Not Wired",description:"A module's setup() called ctx.server.addRoute/addMiddleware or ctx.tools.get, but that surface is not implemented yet. Declare routes as server/api/ files in the module instead.",source:"runtime",severity:"fatal"},MODULE_ENV_REQUIRED:{code:"AX-MODULE-005",title:"Module Env Var Missing",description:"A module's setup() called ctx.env.require() for a variable the agent's resolved environment does not provide. The module declares required env in module.config.ts; the agent must supply it (e.g. in .env).",source:"runtime",severity:"fatal",expected:!0},MODULE_POLICY_IMMUTABLE:{code:"AX-MODULE-006",title:"Module Policy Is Immutable At Boot",description:"A module's setup() called ctx.policy.update(). The resolved agent policy is authoritative and cannot be mutated at boot \u2014 declare policy needs statically in module.config.ts so the CLI reconciles them at install.",source:"runtime",severity:"fatal",expected:!0},CLONE_REF_REQUIRED:{code:"AX-PROJECT-022",title:"No Artifact Named",description:"`axon clone` was run without an artifact to clone. Name one, for example: axon clone @axon/arxiv",source:"cli",severity:"fatal",expected:!0},FORK_REF_REQUIRED:{code:"AX-PROJECT-023",title:"No Artifact Named",description:"`axon fork` was run without an artifact to fork. Name one, for example: axon fork @axon/arxiv --as @you/arxiv",source:"cli",severity:"fatal"},FORK_NAME_REQUIRED:{code:"AX-PROJECT-024",title:"Fork Needs A New Name",description:"A fork is published under your own namespace, so it needs a name: pass --as <package-name>, for example: axon fork @axon/arxiv --as @you/arxiv",source:"cli",severity:"fatal"},CLONE_TARGET_EXISTS:{code:"AX-PROJECT-025",title:"Clone Target Not Empty",description:"The directory the artifact would be cloned into already has files in it. Clone into a new directory, or clear this one first.",source:"cli",severity:"fatal"},ARTIFACT_DOWNLOAD_FAILED:{code:"AX-PROJECT-026",title:"Artifact Download Failed",description:"The registry did not serve the artifact's source archive. The version may have been unpublished, or the network request failed.",source:"cli",severity:"fatal"},ARTIFACT_EXTRACT_FAILED:{code:"AX-PROJECT-027",title:"Artifact Extract Failed",description:"The downloaded archive could not be unpacked. It may be truncated, or `tar` is unavailable on this machine.",source:"cli",severity:"fatal"},VERSION_INVALID:{code:"AX-PROJECT-028",title:"Invalid Version",description:"The project's package.json version is not valid semver, so the next version cannot be derived from it. Fix the version field by hand.",source:"cli",severity:"fatal"},FRAMEWORK_NOT_INSTALLED:{code:"AX-PROJECT-029",title:"Framework Packages Not Installed",description:"The generated type frame references @arcforge/types, @arcforge/engines and h3, none of which resolve from this project. Run `bun install` before `axon prepare`.",source:"cli",severity:"fatal"},FRAME_MIGRATION_CONFLICT:{code:"AX-PROJECT-034",title:"Frame Migration Cannot Proceed Safely",description:"Runtime output exists in BOTH the old location and the new one, so migrating would have to merge or overwrite two sets of session history. Nothing was moved. Inspect both directories and remove or merge them by hand.",source:"cli",severity:"fatal"},CONFIG_EVALUATION_ESCAPED:{code:"AX-PROJECT-030",title:"defineAgent() Called Outside Config Evaluation",description:"defineAgent() ran outside the loader that evaluates axon.config.ts \u2014 it is a declaration helper, not a runtime function, and cannot be called from application code.",source:"cli",severity:"fatal"},PROMPT_NOT_INSTALLABLE:{code:"AX-PROJECT-037",title:"Prompts Are Not Installed Into Agents",description:"A prompt is content, not a capability: it resolves from the global cache and renders on demand, so every agent can already use it without declaring anything. Installing one into an agent would put content through the code path \u2014 an ABI check, a node_modules link, an agent reload \u2014 for something that needs none of it.",source:"manifest",severity:"fatal"},ASSET_TYPE_REFUSED:{code:"AX-PROJECT-038",title:"Unsupported Asset Type",description:"A file in assets/ is not a type the registry serves. Images (png, jpg, jpeg, webp, gif) and video (mp4, webm, mov) are accepted. SVG is deliberately refused: it is an executable document that would be served from our own storage origin, so a published SVG is a script-injection surface for every visitor reading that README.",source:"manifest",severity:"fatal",expected:!0},ASSET_TOO_LARGE:{code:"AX-PROJECT-039",title:"Asset Exceeds Size Limit",description:"A single file in assets/ is over the per-asset limit. Assets exist to illustrate a README, not to distribute media \u2014 compress the file or link to it externally.",source:"manifest",severity:"fatal",expected:!0},ASSETS_BUDGET_EXCEEDED:{code:"AX-PROJECT-040",title:"Assets Exceed Total Budget",description:"The assets/ folder as a whole is over budget for one published version. Every version stores its own copy of every asset, so the total is what determines how much a package costs to host forever.",source:"manifest",severity:"fatal",expected:!0},ASSET_PATH_INVALID:{code:"AX-PROJECT-041",title:"Unsafe Asset Path",description:"An entry under assets/ is a symlink, or its name escapes the assets directory. Both are refused: a published asset must be a real file that lands where its name says it does, or extraction on the server could write outside the target directory.",source:"manifest",severity:"fatal",expected:!0},ASSET_UNREADABLE:{code:"AX-PROJECT-042",title:"Asset Could Not Be Processed",description:"A file in assets/ has an image extension but could not be decoded, so it is either corrupt or not the format its name claims. Publishing it would ship a broken image into a README.",source:"manifest",severity:"fatal",expected:!0},PORT_UNAVAILABLE:{code:"AX-PROJECT-031",title:"No Free Port",description:"Every port in the range the agent scanned is already in use. Stop whatever is holding them, or start the agent on a different port.",source:"cli",severity:"fatal"},PARENT_INSTANCE_NOT_RUNNING:{code:"AX-RUNTIME-005",title:"Parent Agent Not Running",description:"A subagent was requested against a parent session that is no longer live \u2014 the parent shut down, crashed, or was never booted by this process.",source:"runtime",severity:"fatal"},SUBAGENT_DEPTH_EXCEEDED:{code:"AX-RUNTIME-006",title:"Subagent Depth Limit Reached",description:"An agent tried to spawn a subagent beyond the maximum nesting depth. The limit exists so a recursive delegation cannot spawn processes without bound.",source:"runtime",severity:"fatal"},SUBAGENT_CHILD_LIMIT_EXCEEDED:{code:"AX-RUNTIME-007",title:"Subagent Child Limit Reached",description:"One agent tried to hold more live children than the limit allows. Existing children must finish before more can be spawned.",source:"runtime",severity:"fatal"},SUBAGENT_DESCENDANT_LIMIT_EXCEEDED:{code:"AX-RUNTIME-008",title:"Subagent Descendant Limit Reached",description:"The whole subagent tree beneath one root exceeded its live-descendant budget. The limit bounds total concurrent processes, not just direct children.",source:"runtime",severity:"fatal"},SUBAGENT_REQUEST_INVALID:{code:"AX-RUNTIME-009",title:"Malformed Subagent Request",description:"A subagent request did not carry a usable prompt. It must be an object with `prompt` as a string or an array of strings.",source:"runtime",severity:"fatal"},INSTANCE_NOT_LOCAL:{code:"AX-RUNTIME-010",title:"Agent Instance Is Not Local",description:"An operation that only works against a locally booted agent was given a remote one. Subagent spawning and the managed base workspace both require a local process.",source:"runtime",severity:"fatal"},HOST_METHOD_UNKNOWN:{code:"AX-RUNTIME-011",title:"Unknown Host Method",description:"A booted agent called a host method this platform does not implement. The agent's framework version is likely newer than the CLI running it.",source:"runtime",severity:"fatal"},UPDATE_CURRENT_VERSION_INVALID:{code:"AX-TUI-029",title:"Running Version Is Not Semver",description:"The version this app reports for itself is not valid semver, so it cannot be compared against the latest release.",source:"cli",severity:"fatal"},UPDATE_RELEASE_INVALID:{code:"AX-TUI-030",title:"Malformed Release Record",description:"The backend's release record did not describe a valid @arcforge/axon `latest` version, so there is nothing safe to update to.",source:"cli",severity:"fatal"},UPDATE_UNAVAILABLE_IN_DEVELOPMENT:{code:"AX-TUI-031",title:"Update Not Available Here",description:"Self-update needs the packaged update helper and a supervisor request path, neither of which exists in a source checkout. Update the installed app instead.",source:"cli",severity:"fatal"},UPDATE_SUPERVISOR_UNAVAILABLE:{code:"AX-TUI-032",title:"Update Supervisor Unavailable",description:"The running app has no supervisor request path, so it cannot hand an update off to be applied after exit.",source:"cli",severity:"fatal"},UPDATE_HELPER_ARGS_INVALID:{code:"AX-TUI-033",title:"Malformed Update Helper Arguments",description:"The update helper was invoked without the --from/--to/--bun/--axon/--state arguments it requires. It is spawned by the app, not run by hand.",source:"cli",severity:"fatal"},UPDATE_HELPER_VERSION_INVALID:{code:"AX-TUI-034",title:"Update Helper Given Bad Versions",description:"The update helper received a --from or --to value that is not valid semver, so it refused to install anything.",source:"cli",severity:"fatal"},TEST_FILES_NOT_FOUND:{code:"AX-TUI-035",title:"No Test Files Matched",description:"No files matched the requested test patterns, so there was nothing to run. Check the pattern, or the directory it was resolved against.",source:"cli",severity:"fatal"},OLLAMA_UNAVAILABLE:{code:"AX-TUI-037",title:"Ollama Is Not Running",description:"No Ollama daemon answered on this machine. Start it with `ollama serve`, or install Ollama from https://ollama.com to run models locally.",source:"cli",severity:"fatal"},OLLAMA_REQUEST_FAILED:{code:"AX-TUI-038",title:"Ollama Request Failed",description:"The local Ollama daemon is running but refused a request \u2014 most often an unknown model name. The daemon's own message is included.",source:"cli",severity:"fatal"},OLLAMA_REGISTRY_UNREACHABLE:{code:"AX-TUI-039",title:"Ollama Registry Unreachable",description:"Could not reach the Ollama model registry to look a model up. Downloading needs a network connection; models already on disk still work offline.",source:"cli",severity:"fatal"},NO_EDITOR_ATTACHED:{code:"AX-TUI-042",title:"No Editor Attached",description:"Opening a pane hands it to a connected editor, and none is listening. Open this project in an editor running the Axon Fleet extension \u2014 it dials each running TUI itself, so the connection appears on its own once the window is up.",source:"tui",severity:"fatal"},NO_SESSION_TO_OPEN:{code:"AX-TUI-043",title:"No Session To Open",description:"A runtime pane is a view of one conversation, and no agent is focused yet \u2014 so there is nothing to point it at. Start or focus an agent first.",source:"tui",severity:"fatal"},CLEAR_IMMUTABLE_DEPLOYED:{code:"AX-TUI-041",title:"Cannot Clear A Deployment's Conversation",description:"A deployed agent owns its own session in the cloud \u2014 the TUI attaches to whatever session it is already running, so there is no fresh one to start from here. Use `:close` to detach, or clear it on a local instance of the same agent.",source:"tui",severity:"fatal"},OLLAMA_PULL_FAILED:{code:"AX-TUI-040",title:"Model Download Failed",description:"Ollama could not finish downloading the model. The name may not exist in the registry, or the transfer was interrupted \u2014 a retry resumes from whatever was already fetched.",source:"cli",severity:"fatal"},TEST_PRELOAD_MISSING:{code:"AX-TUI-036",title:"Test API Loaded Without Its Preload",description:"The instrumented test API was imported without the preload that installs it. Tests must run through `axon test`, which wires the preload.",source:"cli",severity:"fatal"},PROFILE_CONFIG_INVALID:{code:"AX-EXT-001",title:"profile.config.ts Did Not Call defineProfile()",description:"A profile's config must default-export defineProfile({ ... }). Without it there is no extension list to read, so nothing can be installed, enabled or disabled. The rest of the profile \u2014 main.ts and plugins/ \u2014 still loads.",source:"tui",severity:"fatal",expected:!0},PROFILE_CONFIG_FAILED:{code:"AX-EXT-002",title:"profile.config.ts Failed to Load",description:"The file threw while being evaluated, so its extension list could not be read and no extensions were loaded. The profile's own main.ts and plugins/ are unaffected \u2014 a typo in an extension list must not cost you the config you already had working.",source:"tui",severity:"degraded",expected:!0},EXTENSION_ENTRY_INVALID:{code:"AX-EXT-003",title:"Malformed Extension Entry",description:'An entry in profile.config.ts\'s `extensions` array is neither a string nor an object with a `source`. Accepted forms are "@scope/name" for a registry extension and "./extensions/name" for a local one.',source:"tui",severity:"degraded",expected:!0},EXTENSION_NOT_FOUND:{code:"AX-EXT-004",title:"Extension Not Found",description:"An extension listed in profile.config.ts is not on disk. A local path may have moved or been deleted; a registry name may never have been installed. Everything else in the list still loads.",source:"tui",severity:"degraded",expected:!0},EXTENSION_INSTALL_FAILED:{code:"AX-EXT-005",title:"Extension Install Failed",description:"A registry extension could not be fetched or prepared \u2014 most often no network, or a name that does not exist in the registry. It is skipped for this session and retried on the next launch.",source:"tui",severity:"degraded",expected:!0},EXTENSION_UNINSTALL_FAILED:{code:"AX-EXT-028",title:"Extension Uninstall Failed",description:"An extension could not be removed from profile.config.ts \u2014 most often the file is unreadable or has been edited into a shape the editor cannot find the extensions list in. The extension is still declared and will load on the next launch.",source:"tui",severity:"degraded",expected:!0},EXTENSION_NOT_AN_EXTENSION:{code:"AX-EXT-006",title:"Not an Extension",description:"The directory has no extension.config.ts, which is the file that marks a directory as an extension. A path pointing at an agent, a module, or an ordinary folder is not loadable as one.",source:"tui",severity:"degraded",expected:!0},EXTENSION_LOAD_FAILED:{code:"AX-EXT-007",title:"Extension Failed to Load",description:"An extension's main.ts threw while it was being loaded, so whatever it had not yet registered is missing. Its commands, keys and palettes are removed and the rest of your config loads normally.",source:"tui",severity:"degraded",expected:!0},PROFILE_MAIN_FAILED:{code:"AX-EXT-008",title:"main.ts Failed to Load",description:"Your profile's main.ts threw while being evaluated. Anything it registered before the error survives; everything after it did not run. Plugins and extensions still load.",source:"tui",severity:"degraded",expected:!0},PLUGIN_FAILED:{code:"AX-EXT-009",title:"Plugin Failed to Load",description:"A file in plugins/ threw while being imported, so its hooks were not registered. Other plugins in the same folder are unaffected \u2014 each file is loaded independently.",source:"tui",severity:"degraded",expected:!0},HOOK_FAILED:{code:"AX-EXT-010",title:"Lifecycle Hook Failed",description:"A tui.hook() handler threw while the event it listens for was firing. For a notification hook nothing else is affected; for a gating hook (tui:boot, tui:shutdown) the operation continues anyway rather than leaving the terminal stuck.",source:"tui",severity:"degraded",expected:!0},HOOK_TIMED_OUT:{code:"AX-EXT-011",title:"Hook Blocked Too Long",description:"A gating hook (tui:boot or tui:shutdown) did not finish within its budget, so the TUI continued without waiting. A config must never be able to hang the terminal silently \u2014 whatever the handler was doing may not have completed.",source:"tui",severity:"degraded",expected:!0},COMMAND_NOT_FOUND:{code:"AX-EXT-012",title:"No Such Command",description:"commands.run() was given a path that resolves to nothing in the command tree. The path must name a leaf, spelled exactly as it appears in the `:` palette.",source:"tui",severity:"fatal",expected:!0},PALETTE_NOT_FOUND:{code:"AX-EXT-013",title:"No Such Palette",description:"palette.open() was given a name no palette was registered under. Palettes are created with palette.create(name, ...) \u2014 a name is only openable once its registration has run.",source:"tui",severity:"fatal",expected:!0},PALETTE_NAME_TAKEN:{code:"AX-EXT-014",title:"Palette Name Already Registered",description:"Two palettes tried to claim the same name. Names are how palette.open() addresses one, so they have to be unique \u2014 silently replacing the first would make whichever loaded last win, invisibly.",source:"tui",severity:"degraded",expected:!0},PALETTE_ALREADY_OPEN:{code:"AX-EXT-015",title:"A Palette Is Already Open",description:"Something tried to open a palette, or ask a question, while the user was already navigating one. Stealing it mid-navigation would drop whatever they were doing, so the call fails instead \u2014 check palette.isOpen first.",source:"tui",severity:"degraded",expected:!0},KEY_CHORD_UNBOUND:{code:"AX-EXT-022",title:"No Such Key Binding",description:"keys.send() was given a chord nothing is bound to \u2014 neither a mode key nor a registered binding. Sending it would do nothing at all, which is indistinguishable from a binding that ran and had no effect.",source:"tui",severity:"fatal",expected:!0},AGENT_SPAWN_NO_INSTANCE:{code:"AX-EXT-023",title:"Agent Started but No Instance Appeared",description:"A spawn reported success without producing a focused instance, so there is no id to hand back. This is a fault in Axon rather than in your config \u2014 the agent may or may not be running.",source:"tui",severity:"fatal"},PROFILE_CONFIG_MISSING:{code:"AX-EXT-025",title:"No profile.config.ts",description:"The profile has no config file to record the extension in. It is normally created on first launch \u2014 starting Axon once will scaffold it.",source:"tui",severity:"fatal",expected:!0},PROFILE_CONFIG_UNEDITABLE:{code:"AX-EXT-026",title:"profile.config.ts Could Not Be Edited",description:"The `defineProfile({ ... })` call could not be located, or editing it would have produced invalid TypeScript. Nothing was written \u2014 this file is yours, and a botched edit costs your whole TUI config. Add or remove the entry by hand.",source:"tui",severity:"fatal",expected:!0},COMMAND_INVALID:{code:"AX-EXT-029",title:"Command Is Not Registerable",description:"A command was registered with no path, or with no `run` to call. Both are caught here rather than when someone presses Enter on it \u2014 a command that registers cleanly and then does nothing reads as a broken terminal instead of a config mistake, and gives no clue which file to open. Use `commands.register(path, fn)` or `commands.register(path, { run })`.",source:"tui",severity:"degraded",expected:!0},COMPONENT_NAME_TAKEN:{code:"AX-EXT-030",title:"Component Already Registered",description:"Two sources registered the same line component name. The first one loaded keeps it \u2014 your own config beats any extension. A silently shadowed component would render someone else's value under your name, so the second registration fails instead. Component names are `provider:name`; pick a prefix of your own.",source:"tui",severity:"degraded",expected:!0},COMPONENT_UNKNOWN:{code:"AX-EXT-031",title:"No Such Component",description:"A line named a component that is not registered. Caught when the line is created rather than when it paints, because a missing component renders as an empty gap \u2014 which reads as a layout bug instead of a typo, and gives no clue which name was wrong. components.list() returns everything available.",source:"tui",severity:"degraded",expected:!0},LINE_NAME_TAKEN:{code:"AX-EXT-032",title:"Line Already Registered",description:"Two sources registered the same line name. The first one loaded keeps it, the same rule commands and key chords follow.",source:"tui",severity:"degraded",expected:!0},LINE_UNKNOWN:{code:"AX-EXT-033",title:"No Such Line",description:"lines.set(), move(), show(), hide() or toggle() named a line that is not registered. Doing nothing would be indistinguishable from a line that registered and then rendered empty, so this fails instead. lines.list() returns what exists.",source:"tui",severity:"degraded",expected:!0},COMMAND_PATH_TAKEN:{code:"AX-EXT-020",title:"Command Already Registered",description:"Two sources registered the same command path. The first one loaded keeps it \u2014 your own config beats any extension, and between extensions the one listed earlier in profile.config.ts wins. Rename one of them.",source:"tui",severity:"degraded",expected:!0},KEY_CHORD_TAKEN:{code:"AX-EXT-021",title:"Key Chord Already Bound",description:"Two sources bound the same key chord. The first one loaded keeps it. A silently shadowed binding is unbearable to debug in someone else's config, so the second registration fails instead of replacing it.",source:"tui",severity:"degraded",expected:!0},MODE_KEY_TAKEN:{code:"AX-EXT-016",title:"Mode Key Already Bound",description:"A palette asked for a mode key that is already in use \u2014 either by a built-in mode or by another extension. A silently shadowed key is unbearable to debug in someone else's config, so the registration fails loudly instead.",source:"tui",severity:"degraded",expected:!0},MODE_UNKNOWN:{code:"AX-EXT-017",title:"No Such Mode",description:"mode.set() was given a name that is neither a built-in mode nor a registered palette. Doing nothing would look identical to a mode that simply does not render, so this fails instead.",source:"tui",severity:"fatal",expected:!0},NO_FOCUSED_AGENT:{code:"AX-EXT-018",title:"No Agent Focused",description:"A verb that acts on the focused agent \u2014 send, stop, reboot \u2014 was called while nothing was running. Start one with agents.spawn(name) or tui.nav(name) first.",source:"tui",severity:"fatal",expected:!0},INSTANCE_NOT_RUNNING:{code:"AX-EXT-019",title:"Instance Not Running",description:"An instance id was given for a conversation that is not live \u2014 it may already have been stopped, or it belongs to an earlier session. agents.list() returns what is currently running.",source:"tui",severity:"fatal",expected:!0},CONNECT_REJECTED:{code:"AX-EXT-020",title:"Connector Credential Rejected",description:"The platform refused the credential pasted during `:connect`. Verification runs before the value is written, so nothing was stored \u2014 the detail carries the platform's own reason, and the most common cause is copying the wrong secret from the developer portal.",source:"tui",severity:"fatal",expected:!0}}});import{readFileSync as A3i}from"fs";function IQn(e=1){let n=Error().stack;if(!n)return[];return n.split(`
|
|
686
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var F_a=xt(()=>{x_a()});import{promisify as PNi}from"util";import{execFile as JNi}from"child_process";async function pQn(e=ONi){let{stdout:n}=await e("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),A=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(n);if(!A)throw new v_a(`Cannot find Windows browser in stdout: ${JSON.stringify(n)}`);let{id:i}=A.groups,s=i.lastIndexOf("."),u=i.lastIndexOf("-"),p=s===-1?void 0:i.slice(0,s),d=u===-1?void 0:i.slice(0,u);return U1t[i]??U1t[p]??U1t[d]??{name:i,id:i}}var ONi,U1t,R1t,v_a;var mQn=xt(()=>{ONi=PNi(JNi),U1t={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},R1t=new Map(Object.entries(U1t));v_a=class v_a extends Error{}});import{promisify as $Ni}from"util";import dQn from"process";import{execFile as zNi}from"child_process";async function fQn(){if(dQn.platform==="darwin"){let e=await lQn();return{name:await gQn(e),id:e}}if(dQn.platform==="linux"){let{stdout:e}=await WNi("xdg-mime",["query","default","x-scheme-handler/http"]),n=e.trim();return{name:ZNi(n.replace(/.desktop$/,"").replace("-"," ")),id:n}}if(dQn.platform==="win32")return pQn();throw Error("Only macOS, Linux, and Windows are supported")}var WNi,ZNi=(e)=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,(n)=>n.toUpperCase());var S_a=xt(()=>{k_a();F_a();mQn();mQn();WNi=$Ni(zNi)});import hQn from"process";var VNi,N_a;var G_a=xt(()=>{VNi=Boolean(hQn.env.SSH_CONNECTION||hQn.env.SSH_CLIENT||hQn.env.SSH_TTY),N_a=VNi});import bQn from"process";import U_a from"path";import{fileURLToPath as XNi}from"url";import e3i from"child_process";import t3i,{constants as n3i}from"fs/promises";function T_a(e){if(typeof e==="string"||Array.isArray(e))return e;let{[L_a]:n}=e;if(!n)throw Error(`${L_a} is not supported`);return n}function Vft({[ZUe]:e},{wsl:n}={}){if(n&&The)return T_a(n);if(!e)throw Error(`${ZUe} is not supported`);return T_a(e)}var K1t,CQn,M_a,ZUe,L_a,q_a=async(e,n)=>{if(e.length===0)return;let A=[];for(let i of e)try{return await n(i)}catch(s){A.push(s)}throw AggregateError(A,"Failed to open in all supported apps")},Y1t=async(e)=>{e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e};let n=e[K1t]===!0;if(delete e[K1t],Array.isArray(e.app))return q_a(e.app,(E)=>Y1t({...e,app:E,[K1t]:!0}));let{name:A,arguments:i=[]}=e.app??{};if(i=[...i],Array.isArray(A))return q_a(A,(E)=>Y1t({...e,app:{name:E,arguments:i},[K1t]:!0}));if(A==="browser"||A==="browserPrivate"){let E={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},y={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},k;if(The){let x=await Q_a();k=R1t.get(x)??{}}else k=await fQn();if(k.id in E){let x=E[k.id.toLowerCase()];if(A==="browserPrivate"){if(x==="safari")throw Error("Safari doesn't support opening in private mode via command line");i.push(y[x])}return Y1t({...e,app:{name:VUe[x],arguments:i}})}throw Error(`${k.name} is not supported as a default browser`)}let s,u=[],p={},d=!1;if(The&&!GMe()&&!N_a&&!A)d=await y_a();if(ZUe==="darwin"){if(s="open",e.wait)u.push("--wait-apps");if(e.background)u.push("--background");if(e.newInstance)u.push("--new");if(A)u.push("-a",A)}else if(ZUe==="win32"||d){if(s=await T1t(),u.push(...mJ.argumentsPrefix),!The)p.windowsVerbatimArguments=!0;if(The&&e.target)e.target=await __a(e.target);let E=["$ProgressPreference = 'SilentlyContinue';","Start"];if(e.wait)E.push("-Wait");if(A){if(E.push(mJ.escapeArgument(A)),e.target)i.push(e.target)}else if(e.target)E.push(mJ.escapeArgument(e.target));if(i.length>0)i=i.map((y)=>mJ.escapeArgument(y)),E.push("-ArgumentList",i.join(","));if(e.target=mJ.encodeCommand(E.join(" ")),!e.wait)p.stdio="ignore"}else{if(A)s=A;else{let E=!CQn||CQn==="/",y=!1;try{await t3i.access(M_a,n3i.X_OK),y=!0}catch{}s=bQn.versions.electron??(ZUe==="android"||E||!y)?"xdg-open":M_a}if(i.length>0)u.push(...i);if(!e.wait)p.stdio="ignore",p.detached=!0}if(ZUe==="darwin"&&i.length>0)u.push("--args",...i);if(e.target)u.push(e.target);let b=e3i.spawn(s,u,p);if(e.wait)return new Promise((E,y)=>{b.once("error",y),b.once("close",(k)=>{if(!e.allowNonzeroExitCode&&k!==0){y(Error(`Exited with code ${k}`));return}E(b)})});if(n)return new Promise((E,y)=>{b.once("error",y),b.once("spawn",()=>{b.once("close",(k)=>{if(b.off("error",y),k!==0){y(Error(`Exited with code ${k}`));return}b.unref(),E(b)})})});return b.unref(),new Promise((E,y)=>{b.once("error",y),b.once("spawn",()=>{b.off("error",y),E(b)})})},a3i=(e,n)=>{if(typeof e!=="string")throw TypeError("Expected a `target`");return Y1t({...n,target:e})},VUe,Uhe;var Xft=xt(()=>{w_a();cQn();S_a();iQn();G_a();K1t=Symbol("fallbackAttempt"),CQn=import.meta.url?U_a.dirname(XNi(import.meta.url)):"",M_a=U_a.join(CQn,"xdg-open"),{platform:ZUe,arch:L_a}=bQn;VUe={browser:"browser",browserPrivate:"browserPrivate"};MMe(VUe,"chrome",()=>Vft({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));MMe(VUe,"brave",()=>Vft({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));MMe(VUe,"firefox",()=>Vft({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));MMe(VUe,"edge",()=>Vft({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));MMe(VUe,"safari",()=>Vft({darwin:"Safari"}));Uhe=a3i});var j1t;var BQn=xt(()=>{j1t={UNKNOWN:{code:"AX-UNKNOWN-001",title:"Unclassified Error",description:"An error occurred that hasn't been given a proper code yet. This is itself worth fixing \u2014 see the err(cause) call site that produced it.",source:"runtime",severity:"fatal"},PROMPT_NOT_FOUND:{code:"AX-PROMPT-001",title:"Prompt Not Found",description:"The requested prompt could not be resolved \u2014 it is not declared by the agent, or the published package it names ships no prompt by that name.",source:"runtime",severity:"fatal",expected:!0},PROMPT_FILE_NOT_FOUND:{code:"AX-PROMPT-002",title:"Prompt File Missing",description:"The prompt is declared but its source file no longer exists on disk.",source:"runtime",severity:"fatal",expected:!0},PROMPT_RENDER_FAILED:{code:"AX-PROMPT-003",title:"Prompt Render Failed",description:"The prompt's source file failed to compile or render \u2014 likely a malformed SFC (content outside <template>/<script>/<style>) or an error thrown while rendering. See the cause for the underlying parser/render error.",source:"runtime",severity:"fatal"},OUTPUT_INVALID:{code:"AX-OUTPUT-001",title:"Invalid Output Type",description:"The `output` type passed to request() is not valid TypeScript, or references a type that does not exist. Checked before the model is called, so no inference was spent \u2014 fix the type string at the call site.",source:"runtime",severity:"fatal"},OUTPUT_UNSATISFIED:{code:"AX-OUTPUT-002",title:"Output Type Not Satisfied",description:"The model could not produce a response matching the declared `output` type within its retry budget. The accumulated TypeScript diagnostics describe what it got wrong on each attempt.",source:"runtime",severity:"fatal"},OUTPUT_EMPTY:{code:"AX-OUTPUT-003",title:"Model Produced No Output Block",description:"Every reply must wrap its content in a <text> or <script> block \u2014 text outside a block is discarded by the parser. The model replied with none, on every attempt in its retry budget, so there was nothing to render or run. Usually means the model is not following the block protocol rather than that anything is misconfigured: the reply itself is often correct, just unwrapped. Try a different model, or check that the protocol the cognet renders matches the one it parses with.",source:"runtime",severity:"fatal",expected:!0},SCRIPT_NOT_FOUND:{code:"AX-SCRIPT-001",title:"Script Not Found",description:"The requested script was not found in the agent's blueprint. It may not be declared, or the agent needs to be re-prepared.",source:"runtime",severity:"fatal",expected:!0},SCRIPT_FILE_NOT_FOUND:{code:"AX-SCRIPT-002",title:"Script File Missing",description:"The script is declared but its source file no longer exists on disk.",source:"runtime",severity:"fatal",expected:!0},SCRIPT_AGENT_NOT_LOCAL:{code:"AX-SCRIPT-003",title:"Script Agent Is Not In-Process",description:"A script's agent must run in the same process as the script. Scripts() booted a linked (confined) agent instead, so there is no in-heap runtime for the script's proxy to forward to. This is a wiring fault, not a user error.",source:"runtime",severity:"fatal"},SUBAGENT_LINK_UNSUPPORTED:{code:"AX-SCRIPT-004",title:"Subagent Not Supported Over The Link",description:"An agent asked to spawn a subagent whose child runs as a confined process. `axon.request()` returns a wake's collected entries, while the link's `stimulus` verb returns only admission \u2014 the supervisor needs a verb that collects a wake and answers when it settles. Until that exists this fails rather than returning an admission receipt the caller would read as a result.",source:"runtime",severity:"fatal"},AGENT_BOOT_FAILED:{code:"AX-AGENT-006",title:"Agent Failed To Boot",description:"The agent process exited before it connected to its supervisor. Its own stderr is carried as the detail \u2014 the agent usually knows exactly what went wrong (a missing cognet, a tool that would not compile), and without this that diagnosis died in a pipe while the supervisor reported only a closed socket.",source:"runtime",severity:"fatal"},CAPSULE_NOT_LOCAL:{code:"AX-AGENT-007",title:"No Capsule On This Machine",description:'A console eval was requested against an attached deployment. Its capsule runs wherever the deployment is hosted, so there is nothing here to execute in \u2014 and quietly resolving would read as "it ran and did nothing".',source:"runtime",severity:"fatal",expected:!0},LINK_NO_HANDLER:{code:"AX-LINK-001",title:"No Handler For Link Verb",description:"The peer sent a verb this side does not implement. Both ends speak a versioned contract, so this means they disagree about it \u2014 a wiring fault, not something a user did.",source:"runtime",severity:"fatal"},LINK_PEER_CLOSED:{code:"AX-LINK-002",title:"Agent Disconnected",description:"The agent process closed its side of the link. Every call still in flight is rejected rather than left hanging \u2014 a dead peer must be an error, never a wait that never ends.",source:"runtime",severity:"fatal"},LINK_CLOSED:{code:"AX-LINK-003",title:"Link Closed",description:"The link to the agent was torn down by this side \u2014 a shutdown, a dispose, or a failed boot. Outstanding calls are rejected with this rather than hanging.",source:"runtime",severity:"fatal"},LINK_FRAME_TOO_LARGE:{code:"AX-LINK-004",title:"Link Frame Too Large",description:"A message on the link exceeded the maximum frame size, or a length prefix declared one that did. The prefix is peer-controlled input, so an oversized declaration is refused rather than allocated \u2014 a desynchronised stream cannot be recovered by reading past it.",source:"runtime",severity:"fatal"},LINK_UNKNOWN_PROMPT_ACTION:{code:"AX-LINK-005",title:"Unknown Prompt Action",description:"The prompt verb was called with an action this side does not know. Loud rather than silent: an unrecognised action would otherwise return undefined, which a caller renders as an empty prompt list.",source:"runtime",severity:"fatal"},AGENT_LINK_MISSING:{code:"AX-AGENT-001",title:"Agent Started Without A Supervisor",description:"An agent process was started with no link paths in its environment, which means nothing is supervising it. It cannot guess a socket path \u2014 doing so risks connecting to a different agent's supervisor entirely.",source:"runtime",severity:"fatal"},AGENT_LINK_MALFORMED:{code:"AX-AGENT-002",title:"Malformed Agent Link",description:"The link carrier in the agent's environment is not valid JSON, or does not name both a control and a data socket. Both are required \u2014 an agent with only one connected can accept work it has no way to answer.",source:"runtime",severity:"fatal"},AGENT_BLUEPRINT_MISSING:{code:"AX-AGENT-003",title:"Agent Started Without A Blueprint",description:"An agent process was started with no blueprint path in its environment. The supervisor writes the blueprint beside the sockets before spawning; its absence means the spawn path is broken.",source:"runtime",severity:"fatal"},AGENT_NOT_READY:{code:"AX-AGENT-004",title:"Agent Still Booting",description:"A verb arrived before the agent's runtime finished booting. The link connects first so that boot failures are reportable, which leaves a brief window where the agent can be addressed but cannot answer.",source:"runtime",severity:"fatal"},CLI_AGENT_NOT_LOCAL:{code:"AX-AGENT-005",title:"Command Needs An In-Process Agent",description:"A headless CLI command booted an agent that runs as a separate process, but the command reaches into the runtime directly. This is a wiring fault: the command needs either an in-process agent or a link verb.",source:"runtime",severity:"fatal"},ENGINE_ROLE_UNBOUND_LINK:{code:"AX-ENGINE-010",title:"No Engine For Role",description:"A confined agent asked for inference on a role the supervisor has no engine bound to. Roles are resolved on the supervisor's side before the agent starts, so an unbound one here means resolution and the cognet's declaration disagree.",source:"runtime",severity:"fatal"},ENGINE_KIND_MISMATCH_LINK:{code:"AX-ENGINE-011",title:"Engine Kind Mismatch",description:"A role bound to a transform or session engine was asked to serve a generate call. Resolution already matched the declared type, so reaching here means a provider's create() disagreed with the capability it was handed.",source:"runtime",severity:"fatal"},ENGINE_MISSING:{code:"AX-ENGINE-001",title:"No Engine Configured",description:"The agent's blueprint has no engine \u2014 it cannot dispatch to a model. Set `engine` in axon.config.ts.",source:"runtime",severity:"fatal"},ENGINE_ROLE_UNBOUND:{code:"AX-ENGINE-002",title:"Engine Role Not Bound",description:"The cognet asked for an engine role that resolution did not fill. A required role stops the boot, so reaching this means an OPTIONAL role was used without checking `kernel.engine.has()` first \u2014 or the role was never declared in the cognet's `engines:` block.",source:"runtime",severity:"fatal"},RESOURCES_EXHAUSTED:{code:"AX-RES-001",title:"Not Enough Memory",description:"A local model does not fit in what is left of this machine's video memory. Nothing was evicted: another agent is using it, and taking memory out from under a running agent would slow it down invisibly. Stop an agent that is holding a model, or raise the ceiling in your profile's `resources`.",source:"runtime",severity:"degraded",expected:!0},ENGINE_PIN_UNAVAILABLE:{code:"AX-ENGINE-004",title:"Model Not Available",description:"The agent pins a model no declared provider can supply. The agent still runs \u2014 resolution picked the best available model instead \u2014 but it is NOT the one that was asked for. Declare the provider that supplies it in your profile, or pick a model from a provider you have.",source:"runtime",severity:"degraded",expected:!0},ENGINE_REQUIREMENTS_UNMET:{code:"AX-ENGINE-003",title:"Inference Requirements Unmet",description:"This cognet declares engine roles that nothing among the user's providers can fill. Add a provider that supplies what is missing, or run a cognet whose requirements this machine meets.",source:"runtime",severity:"fatal",expected:!0},INJECT_OUTSIDE_RUNTIME:{code:"AX-RUNTIME-001",title:"Runtime Accessed Before Boot",description:"A runtime global (axon, args) was read before the runtime finished booting.",source:"runtime",severity:"fatal"},BOOT_FAILED:{code:"AX-BOOT-001",title:"Agent Failed To Start",description:"The agent's runtime crashed while starting, before it could accept requests.",source:"runtime",severity:"fatal"},BOOT_SCRIPT_FAILED:{code:"AX-BOOT-002",title:"Boot Script Failed",description:"The agent's boot.vue threw while rendering \u2014 check the script setup block for the error.",source:"runtime",severity:"fatal"},BOOT_SCRIPT_INVALID:{code:"AX-BOOT-003",title:"Boot Script Malformed",description:"The agent's boot.vue has content outside its recognized <script>/<template> blocks, or otherwise failed to parse as a valid SFC.",source:"runtime",severity:"fatal"},COGNET_ACCESSED_BEFORE_LOAD:{code:"AX-COGNET-001",title:"Cognet Accessed Before Load",description:"A cognet global (kernel, phase, system, blueprint) was read before the brain finished loading, or outside the loop body that owns it.",source:"cognet",severity:"fatal"},COGNET_LOOP_ALREADY_DECLARED:{code:"AX-COGNET-002",title:"Loop Already Declared",description:"A cognet's main() called loop() more than once \u2014 the loop is the program's entire main body and can only be declared once.",source:"cognet",severity:"fatal"},COGNET_ALREADY_LOADED:{code:"AX-COGNET-003",title:"Cognet Bound To A Different Kernel",description:"This cognet instance already loaded against a different kernel ABI \u2014 a reload produced a conflicting bind instead of a clean swap.",source:"cognet",severity:"fatal"},COGNET_NO_LOOP:{code:"AX-COGNET-004",title:"Cognet Declared No Loop",description:"The cognet's main() ran (or was woken) without ever declaring loop() \u2014 there is no program to run.",source:"cognet",severity:"fatal"},COGNET_MAX_TICKS:{code:"AX-COGNET-005",title:"Cognet Exceeded Max Ticks",description:"The cognet's loop ran more ticks in one wake than its configured limit allows \u2014 likely a runaway loop that never calls stop().",source:"cognet",severity:"fatal"},COGNET_ABI_MISMATCH:{code:"AX-COGNET-006",title:"Cognet ABI Mismatch",description:"The compiled cognet targets a kernel ABI version the running kernel doesn't provide \u2014 rebuild the cognet against the current framework version.",source:"cognet",severity:"fatal"},COGNET_MISSING:{code:"AX-COGNET-007",title:"No Compiled Cognet",description:"The blueprint points at a compiled cognet bundle that doesn't exist on disk yet \u2014 run `axon prepare` before booting.",source:"cognet",severity:"fatal"},COGNET_HASH_MISMATCH:{code:"AX-COGNET-008",title:"Cognet Bundle Hash Mismatch",description:"The compiled cognet bundle on disk doesn't match the hash the blueprint expects \u2014 it's stale or was tampered with. Run `axon prepare` again.",source:"cognet",severity:"fatal"},COGNET_INVALID:{code:"AX-COGNET-009",title:"Invalid Cognet Bundle",description:"The compiled cognet's default export isn't a real cognet definition \u2014 the compile step produced something malformed.",source:"cognet",severity:"fatal"},COGNET_IDENTITY_MISMATCH:{code:"AX-COGNET-010",title:"Cognet Identity Mismatch",description:"The compiled cognet artifact's own name doesn't match what the blueprint declared \u2014 the wrong bundle may be at this path.",source:"cognet",severity:"fatal"},COGNET_CONFIG_MISSING:{code:"AX-COGNET-011",title:"Cognet Config Missing",description:"No cognet.config.ts was found in the cognet's source directory \u2014 every cognet needs one to declare its identity.",source:"cognet",severity:"fatal"},COGNET_BUILD_FAILED:{code:"AX-COGNET-012",title:"Cognet Failed To Compile",description:"Bundling the cognet's source into a runnable artifact failed \u2014 check the build log for the underlying syntax or import error.",source:"cognet",severity:"fatal"},COGNET_RUNTIME_UNAVAILABLE:{code:"AX-COGNET-014",title:"Cognet Runtime Temporarily Unavailable",description:"The cognet runtime is declared but not present on disk \u2014 the dependency tree is mid-rewrite. Transient: the reload keeps the previous blueprint and picks the change up on the next watch event.",source:"cognet",severity:"recovered"},COGNET_AMBIGUOUS:{code:"AX-COGNET-015",title:"Two Cognets Declared",description:"The agent both declares `cognet:` in axon.config.ts and holds an inline cognet at `cognet/`. An agent has exactly one brain, and choosing between them silently would either ignore a directory of source or overrule what the author wrote. Keep one.",source:"cognet",severity:"fatal"},COGNET_NOT_FOUND:{code:"AX-COGNET-013",title:"Cognet Not Found",description:"The cognet named by `cognet:` in axon.config.ts could not be located. The detail says where it was looked for \u2014 a registry that answered 404, or a node_modules tree it was missing from. Check the specifier for a typo, and check which registry the CLI is pointed at (AXON_API_BASE).",source:"cognet",severity:"fatal",expected:!0},MODULE_SPECIFIER_INVALID:{code:"AX-PROJECT-005",title:"Invalid Module Specifier",description:"Module names must be scoped as @scope/name. The registry does not accept unscoped packages, so an unscoped specifier can never resolve.",source:"manifest",severity:"fatal"},CONFIG_MODULES_UNPARSEABLE:{code:"AX-PROJECT-006",title:"Could Not Edit axon.config.ts",description:"The install succeeded but the module entry could not be written into the config's modules array automatically \u2014 add or remove it by hand.",source:"manifest",severity:"fatal"},CONFIG_ENGINE_DEPRECATED:{code:"AX-PROJECT-033",title:"`engine:` Is Deprecated And Ignored",description:"This agent's axon.config.ts declares `engine:`, which the runtime no longer reads \u2014 inference is resolving against the profile's providers instead. Use `model: \"codex:gpt-5.6-terra\"` for a cortex pin, and `providers: [...]` for a source the user would not otherwise have.",source:"manifest",severity:"degraded"},MODULE_DEPENDENCY_INSTALL_FAILED:{code:"AX-PROJECT-004",title:"Module Dependencies Failed To Install",description:"The module source was downloaded, but its npm dependencies could not be materialized for the agent. Resolve the package-manager error and run the install again.",source:"manifest",severity:"fatal"},BLUEPRINT_NOT_LOADED:{code:"AX-PROJECT-002",title:"Blueprint Accessed Before Load",description:"Something read the blueprint's current value before load() had ever run.",source:"manifest",severity:"fatal"},AGENT_INVALID:{code:"AX-PROJECT-003",title:"Invalid Agent Directory",description:"The agent root has no package.json \u2014 every agent is a real package, this one isn't.",source:"manifest",severity:"fatal"},CORRUPT_JSON:{code:"AX-PROJECT-016",title:"Corrupt JSON File",description:"A stored JSON file failed to parse \u2014 it may have been hand-edited into an invalid state, or a write was interrupted mid-flight.",source:"manifest",severity:"fatal"},FILE_UNREADABLE:{code:"AX-PROJECT-032",title:"File Could Not Be Read",description:"A file exists but could not be read \u2014 most often a permissions problem, a directory where a file was expected, or a disk error. Distinct from a missing file, which is an ordinary absent-surface state.",source:"manifest",severity:"fatal"},PROVIDER_NOT_CONNECTED:{code:"AX-TUI-011",title:"Provider Not Connected",description:"The selected model routes through a provider (OpenRouter, Codex) that isn't connected yet \u2014 connect it before picking a model on that route.",source:"tui",severity:"fatal",expected:!0},PALETTE_INPUT_REQUIRED:{code:"AX-TUI-012",title:"Required Input Missing",description:"A palette command needs a value for this field before it can run.",source:"tui",severity:"fatal",expected:!0},BENCH_NO_CASES:{code:"AX-TUI-013",title:"Bench Declared No Cases",description:"The bench's test file ran to completion under Bun but never declared a single benchmark case.",source:"tui",severity:"fatal"},PROJECT_NOT_FOUND:{code:"AX-PROJECT-017",title:"Project Not Found",description:"No axon.config.ts, module.config.ts, cognet.config.ts, bench.config.ts, or prompt.config.ts was found at this path \u2014 it isn't a recognized project directory.",source:"manifest",severity:"fatal",expected:!0},PROJECT_WRONG_KIND:{code:"AX-PROJECT-011",title:"Wrong Project Kind",description:"This command targets one project kind, and the directory holds another \u2014 run the command that matches what is actually here.",source:"manifest",severity:"fatal",expected:!0},PROJECT_EXISTS:{code:"AX-PROJECT-018",title:"Project Already Exists",description:"Scaffolding refused to overwrite a directory that already exists \u2014 remove it or pick a different name first.",source:"manifest",severity:"fatal"},TYPEGEN_NO_BLUEPRINT:{code:"AX-PROJECT-007",title:"Typegen Needs A Loaded Blueprint",description:"Agent-kind typegen was called without a blueprint \u2014 its declared surfaces are the source of the generated types.",source:"manifest",severity:"fatal"},DEPLOY_AGENTS_ONLY:{code:"AX-PROJECT-008",title:"Only Agents Can Deploy",description:"A module was asked to deploy on its own \u2014 modules only run installed inside an agent, deploy the agent instead.",source:"manifest",severity:"fatal"},PUBLISH_UNSUPPORTED_KIND:{code:"AX-PROJECT-009",title:"This Project Kind Cannot Publish",description:"The registry accepts agents, modules, cognets, benches and prompts. Extensions are not accepted yet \u2014 the `registry_artifact_kind` enum needs the value first, and publishing before then would register under the wrong kind and claim the name in the shared namespace. A profile is never publishable: it holds one person's credentials, history and agents. See KINDS[kind].publishable.",source:"manifest",severity:"fatal"},MODEL_SPECIFIER_INVALID:{code:"AX-MODEL-001",title:"Malformed Model Specifier",description:"A `models:` entry in cognet.config.ts could not be parsed. The short form is `hf:owner/repo/path/to/file` \u2014 a repo alone is ambiguous, since one repo holds many weights.",source:"manifest",severity:"fatal"},MODEL_FETCH_FAILED:{code:"AX-MODEL-002",title:"Model Weights Could Not Be Fetched",description:"A declared model could not be downloaded. Check the repo, file path and revision, and that the machine can reach the registry. A brain without its weights is broken rather than degraded, so this fails at prepare instead of at first inference.",source:"manifest",severity:"fatal"},MODEL_HASH_MISMATCH:{code:"AX-MODEL-003",title:"Model Weights Failed Verification",description:"Downloaded bytes did not hash to the expected value \u2014 the upstream file changed, or the download was corrupted. Nothing is cached: storing unverified weights would make every later run trust them.",source:"manifest",severity:"fatal"},MODEL_NOT_CACHED:{code:"AX-MODEL-004",title:"Declared Model Is Not Cached",description:"`--frozen` asserts the machine is already provisioned, so it will not fetch. Run `axon prepare` without --frozen to populate the model cache.",source:"manifest",severity:"fatal"},PREPARE_FROZEN_DRIFT:{code:"AX-PROJECT-014",title:"Dependencies Drifted From The Lockfile",description:"`--frozen` asserts that package.json, the lockfile and node_modules already agree. Something did not: a dependency is missing, at a version outside its declared range, or declared but no longer selected. Run `axon prepare` without --frozen to reconcile, and commit the result.",source:"manifest",severity:"fatal"},PUBLISH_VERIFY_FAILED:{code:"AX-PROJECT-013",title:"Artifact Does Not Compile",description:"The package was built, but compiling it the way a consumer would failed \u2014 so publishing it would ship something nobody can install. Usually a file the source imports was left out of the package. Published versions are immutable, so this is caught before upload rather than after.",source:"manifest",severity:"fatal"},DEPLOY_PROVISION_FAILED:{code:"AX-PROJECT-012",title:"Deployment Provisioning Failed",description:"The agent was published, but the cloud control plane could not provision its runtime. The request ID identifies the server-side failure.",source:"manifest",severity:"fatal"},DEPLOY_RUNTIME_FAILED:{code:"AX-PROJECT-035",title:"Agent Failed To Start",description:"Cloud infrastructure was provisioned, but the agent process failed during boot. The reported runtime diagnostic identifies the immediate cause.",source:"runtime",severity:"fatal"},DEPLOY_ENV_RESERVED:{code:"AX-PROJECT-036",title:"Reserved Deployment Variable",description:"The production .env file attempts to override a variable owned by the Axon runtime or Cloud Run.",source:"manifest",severity:"fatal"},DEPLOY_ENV_INVALID:{code:"AX-PROJECT-015",title:"Invalid Deployment Variable",description:"The production .env file contains a key that is not a valid environment variable name.",source:"manifest",severity:"fatal"},BUNDLE_MODULE_COLLISION:{code:"AX-PROJECT-019",title:"Module Name Collision",description:"A hard-imported source module's name collides with an already-installed registry module of the same name.",source:"manifest",severity:"fatal"},BUNDLE_INVALID:{code:"AX-PROJECT-010",title:"Invalid Bundle Source",description:"The directory being bundled has no package.json, or its package.json has no name \u2014 every bundle needs a real package identity.",source:"manifest",severity:"fatal"},BUNDLE_TAR_MISSING:{code:"AX-PROJECT-020",title:"tar Not Found",description:"Bundling shells out to the system's tar binary, which isn't on PATH \u2014 install Git for Windows or use WSL on that platform.",source:"manifest",severity:"fatal"},BUNDLE_TAR_FAILED:{code:"AX-PROJECT-021",title:"tar Failed",description:"The tar subprocess exited non-zero while building a bundle archive.",source:"manifest",severity:"fatal"},BENCH_RUN_NOT_FOUND:{code:"AX-BENCH-001",title:"Bench Run Not Found",description:"No recorded bench run exists with this id.",source:"bench",severity:"fatal",expected:!0},BENCH_NOT_FOUND:{code:"AX-BENCH-002",title:"Bench Not Found",description:"No bench.config.ts was found at this path \u2014 it isn't a recognized bench project.",source:"bench",severity:"fatal",expected:!0},BENCH_TESTS_NOT_FOUND:{code:"AX-BENCH-003",title:"Bench Test Files Not Found",description:"The bench config declares test files that don't exist on disk.",source:"bench",severity:"fatal",expected:!0},BENCH_LOCAL_REF_NOT_FOUND:{code:"AX-BENCH-004",title:"Bench Local Reference Not Found",description:"A factor variable references a local file/directory that doesn't exist.",source:"bench",severity:"fatal",expected:!0},BENCH_CONFIG_INVALID:{code:"AX-BENCH-005",title:"Bench Config Invalid",description:"bench.config.ts failed to evaluate or didn't produce a valid bench definition.",source:"bench",severity:"fatal"},BENCH_PACKAGE_NOT_FOUND:{code:"AX-BENCH-006",title:"Bench Package Not Found",description:"No package.json exists at the bench root \u2014 every bench project needs one for identity.",source:"bench",severity:"fatal",expected:!0},BENCH_PACKAGE_NAME_REQUIRED:{code:"AX-BENCH-007",title:"Bench Package Name Required",description:"The bench's package.json has no name field.",source:"bench",severity:"fatal",expected:!0},BENCH_PACKAGE_VERSION_REQUIRED:{code:"AX-BENCH-008",title:"Bench Package Version Required",description:"The bench's package.json has no version field.",source:"bench",severity:"fatal",expected:!0},BENCH_CONTEXT_MISSING:{code:"AX-BENCH-009",title:"Bench Context Missing",description:"The benchmark preload needs AXON_BENCH_CONTEXT set \u2014 it was run outside the bench harness.",source:"bench",severity:"fatal"},BENCH_NO_ACTIVE_CASE:{code:"AX-BENCH-010",title:"No Active Bench Case",description:"A bench emission (measurement, artifact) happened outside any running Bun test \u2014 these calls must occur inside a test case.",source:"bench",severity:"fatal"},BENCH_WORKSPACE_UNAVAILABLE:{code:"AX-BENCH-011",title:"Bench Workspace Unavailable",description:"The bench's workspace directory hasn't been materialized yet for this run.",source:"bench",severity:"fatal"},BENCH_AGENT_UNRESOLVED:{code:"AX-BENCH-012",title:"Bench Agent Unresolved",description:"The bench's declared subject agent isn't a prepared local agent \u2014 run `axon prepare` on it first.",source:"bench",severity:"fatal"},BENCH_MEASUREMENT_UNKNOWN:{code:"AX-BENCH-013",title:"Unknown Bench Measurement",description:"A measurement was emitted under an id the bench config never declared.",source:"bench",severity:"fatal"},BENCH_MEASUREMENT_TYPE:{code:"AX-BENCH-014",title:"Bench Measurement Type Mismatch",description:"A measurement's emitted value doesn't match the type its bench config declaration expects.",source:"bench",severity:"fatal"},BENCH_MEASUREMENT_DOMAIN:{code:"AX-BENCH-015",title:"Bench Measurement Out Of Domain",description:"A measurement's emitted value falls outside the range or category the bench config declares for it.",source:"bench",severity:"fatal"},BENCH_DIMENSION_UNKNOWN:{code:"AX-BENCH-016",title:"Unknown Bench Dimension",description:"A dimension value was set under an id the bench config never declared.",source:"bench",severity:"fatal"},BENCH_DIMENSION_DOMAIN:{code:"AX-BENCH-017",title:"Bench Dimension Out Of Domain",description:"A dimension's set value isn't one of the categories its bench config declares.",source:"bench",severity:"fatal"},BENCH_AXIS_UNKNOWN:{code:"AX-BENCH-018",title:"Unknown Bench Factor",description:"Something referenced a factor id the running bench's coordinate never assigned a value to.",source:"bench",severity:"fatal"},BENCH_ARTIFACT_UNKNOWN:{code:"AX-BENCH-019",title:"Unknown Bench Artifact",description:"An artifact was emitted under an id the bench config never declared.",source:"bench",severity:"fatal"},BENCH_ARTIFACT_MEDIA_TYPE:{code:"AX-BENCH-020",title:"Bench Artifact Media Type Not Allowed",description:"An artifact was emitted with a media type its bench config declaration doesn't allow.",source:"bench",severity:"fatal"},BENCH_SCHEMA_UNREADABLE:{code:"AX-BENCH-030",title:"Bench Schema Unreadable",description:"bench.config.ts could not be parsed while extracting the measurement schema.",source:"bench",severity:"fatal"},BENCH_SCHEMA_EMPTY:{code:"AX-BENCH-031",title:"Bench Schema Empty",description:"defineBench<Schema> was given a type with no properties \u2014 an empty schema and a failed extraction must never look alike.",source:"bench",severity:"fatal"},BENCH_SCHEMA_UNSUPPORTED_TYPE:{code:"AX-BENCH-032",title:"Bench Measurement Type Unsupported",description:"A measurement is not a boolean, number, union of string literals, or string.",source:"bench",severity:"fatal"},BENCH_SCHEMA_EXTRACTION_FAILED:{code:"AX-BENCH-033",title:"Bench Schema Extraction Failed",description:"The schema worker did not return a schema. Prepare fails rather than continuing with an empty one, which would silently make every measurement undeclared.",source:"bench",severity:"fatal"},BENCH_AXIS_NOT_FOUND:{code:"AX-BENCH-021",title:"Bench Axis Not Found",description:"The bench config's matrix has no axis with this key.",source:"bench",severity:"fatal",expected:!0},BENCH_AXIS_VALUE_NOT_FOUND:{code:"AX-BENCH-022",title:"Bench Axis Value Not Found",description:"The bench config's matrix axis has no declared value with this id.",source:"bench",severity:"fatal",expected:!0},BENCH_WORKSPACE_ESCAPE:{code:"AX-BENCH-023",title:"Bench Workspace Path Escapes Root",description:"A workspace source entry resolved to a path outside the workspace directory \u2014 refused rather than materialized.",source:"bench",severity:"fatal"},BENCH_WORKSPACE_SYMLINK_UNSUPPORTED:{code:"AX-BENCH-024",title:"Bench Workspace Symlinks Unsupported",description:"A workspace source contains a symlink \u2014 not supported when materializing a bench workspace.",source:"bench",severity:"fatal"},BENCH_WORKSPACE_OUTSIDE_ROOT:{code:"AX-BENCH-025",title:"Bench Template Outside Root",description:"A workspace template's declared source path resolves outside the bench project root.",source:"bench",severity:"fatal"},BENCH_WORKSPACE_SOURCE_NOT_FOUND:{code:"AX-BENCH-026",title:"Bench Template Not Found",description:"A workspace template's declared source path isn't a real directory.",source:"bench",severity:"fatal",expected:!0},BENCH_LOG_INVALID:{code:"AX-BENCH-027",title:"Bench Log Invalid",description:"A bench run's event log is missing an entry its projection requires \u2014 the log is incomplete or was written out of order.",source:"bench",severity:"fatal"},TOOL_DECLARE_FAILED:{code:"AX-BLUEPRINT-002",title:"Tool Declaration Failed",description:"Compiling a src/tools/*.ts file's TypeScript declarations failed \u2014 the worker subprocess reported a compile error.",source:"manifest",severity:"fatal"},TOOL_BUNDLE_FAILED:{code:"AX-BLUEPRINT-006",title:"Tool Bundle Failed",description:"Bundling a src/tools/*.ts file to self-contained source failed \u2014 the bundler subprocess reported an error. Tools are bundled so the sandbox loads them without mounting the project; a bundle failure means the tool cannot enter the box.",source:"manifest",severity:"fatal"},ROUTE_LOAD_FAILED:{code:"AX-BLUEPRINT-007",title:"Route Load Failed",description:"A file in server/api/ could not be imported. The agent would serve an endpoint set that is not the declared one \u2014 a caller gets a 404 for a route whose file exists.",source:"manifest",severity:"fatal"},SCRIPT_LOAD_FAILED:{code:"AX-BLUEPRINT-008",title:"Script Load Failed",description:"A file in src/scripts/ could not be processed. `axon run <name>` would report the script as not found while its file sits in the project.",source:"manifest",severity:"fatal"},PLUGIN_LOAD_FAILED:{code:"AX-BLUEPRINT-009",title:"Plugin Load Failed",description:"A plugin could not be imported. Plugins wire server behaviour at boot; one silently missing means the agent runs without behaviour its author declared.",source:"manifest",severity:"fatal"},MIDDLEWARE_LOAD_FAILED:{code:"AX-BLUEPRINT-010",title:"Middleware Load Failed",description:"A middleware file could not be imported. Middleware commonly carries auth and validation, so a silently skipped one is a request path running without the checks its author wrote.",source:"manifest",severity:"fatal"},PROMPT_INTROSPECT_FAILED:{code:"AX-BLUEPRINT-011",title:"Prompt Introspection Failed",description:"A .vue prompt could not be introspected for its props. The prompt would render without the inputs it declares, or not at all.",source:"manifest",severity:"fatal"},CONFIG_NOT_FOUND:{code:"AX-BLUEPRINT-003",title:"Config Not Found",description:"No axon.config.ts exists at this path.",source:"manifest",severity:"fatal",expected:!0},CONFIG_LOAD_FAILED:{code:"AX-BLUEPRINT-004",title:"Config Failed To Load",description:"axon.config.ts threw or failed to evaluate \u2014 check the file for a syntax or runtime error.",source:"manifest",severity:"fatal"},CONFIG_INVALID:{code:"AX-BLUEPRINT-005",title:"Config Invalid",description:"axon.config.ts evaluated but never called defineAgent() \u2014 every agent config must produce one.",source:"manifest",severity:"fatal"},ENGINE_NO_DONE:{code:"AX-KERNEL-001",title:"Engine Stream Ended Without Completing",description:"The model driver's stream ended without ever emitting a completion event \u2014 the engine likely disconnected or crashed mid-response.",source:"kernel",severity:"fatal"},ENGINE_NOT_CONNECTED:{code:"AX-KERNEL-015",title:"Provider Not Connected",description:"This model's route is not connected to your account yet \u2014 run `:provider <name> connect` for the provider named below, or pick a model on a route you are already signed in to.",source:"kernel",severity:"fatal",expected:!0},ENGINE_AUTH_FAILED:{code:"AX-KERNEL-016",title:"Provider Rejected Your Credentials",description:"The provider refused the credential this agent is using \u2014 it has expired, been revoked, or is for a different account. Reconnect the provider, or pick a model on a route you are signed in to.",source:"kernel",severity:"fatal",expected:!0},ENGINE_RATE_LIMITED:{code:"AX-KERNEL-017",title:"Provider Rate Limit Reached",description:"The provider is refusing further calls right now \u2014 either too many requests in a short window, or a subscription whose allowance is spent. Waiting usually clears the first; the second needs a plan change or a different model.",source:"kernel",severity:"fatal",expected:!0},ENGINE_QUOTA_EXHAUSTED:{code:"AX-KERNEL-018",title:"Provider Credits Exhausted",description:"This route has no credit left to spend. Top it up, or switch to a model on a route that does \u2014 the conversation is intact either way.",source:"kernel",severity:"fatal",expected:!0},ENGINE_REQUEST_REJECTED:{code:"AX-KERNEL-019",title:"Provider Rejected The Request",description:"The provider refused this call as malformed or unsupported \u2014 commonly a model id it does not serve, a context window this conversation has outgrown, or a parameter that route does not accept.",source:"kernel",severity:"fatal",expected:!0},ENGINE_UNREACHABLE:{code:"AX-KERNEL-020",title:"Could Not Reach The Provider",description:"The provider could not be reached, or kept failing, across every retry \u2014 usually a network problem on this machine or an outage on their side. Nothing about this agent needs changing; try again.",source:"kernel",severity:"fatal",expected:!0},ENGINE_STREAM_FAILED:{code:"AX-KERNEL-008",title:"Engine Stream Failed",description:"The model driver's stream failed and exhausted its retries (or the failure wasn't retryable) \u2014 see context for the provider's fault code.",source:"kernel",severity:"fatal"},CODEX_NOT_CONNECTED:{code:"AX-KERNEL-012",title:"Codex Subscription Not Connected",description:"This agent uses a Codex model, but your Axon account is not connected to ChatGPT \u2014 run :provider codex connect and try again.",source:"kernel",severity:"fatal",expected:!0},RUN_IN_PROGRESS:{code:"AX-KERNEL-002",title:"A Wake Is Already Running",description:"The kernel only executes one wake at a time \u2014 a new run was requested while the previous one was still active.",source:"kernel",severity:"recovered"},RUN_RESERVATION_EXPIRED:{code:"AX-KERNEL-003",title:"Wake Reservation Expired",description:"The reserved execution slot for this wake is no longer active \u2014 it was released before the run could start.",source:"kernel",severity:"fatal"},NO_COGNET_LOADED:{code:"AX-KERNEL-004",title:"No Cognet Loaded",description:"The kernel tried to execute a wake, but the blueprint carried no cognet definition to run it against.",source:"kernel",severity:"fatal"},SYSCALL_OUTSIDE_RUN:{code:"AX-KERNEL-005",title:"Syscall Outside An Active Run",description:"A kernel syscall (engine.stream and similar) was made with no active wake to attribute it to.",source:"kernel",severity:"fatal"},CAPSULE_ACCESSED_BEFORE_BOOT:{code:"AX-KERNEL-007",title:"Capsule Accessed Before Boot",description:"Something reached for the live capsule instance before boot() had run \u2014 there is no sandbox yet to hand back.",source:"kernel",severity:"fatal"},COGNET_EMIT_FORBIDDEN:{code:"AX-KERNEL-009",title:"Cognet Emit Forbidden",description:"A cognet tried to emit an event outside the cognet:* namespace \u2014 the ABI only lets a cognet narrate its own telemetry, never forge kernel machinery events.",source:"kernel",severity:"fatal"},KNOWLEDGE_NOT_FOUND:{code:"AX-KERNEL-011",title:"Knowledge Entry Not Found",description:"A cognet read a knowledge entry that does not exist. The knowledge store is not a cache \u2014 a brain reading something the catalogue advertised has hit a real inconsistency, so this is loud rather than an empty result.",source:"kernel",severity:"fatal",expected:!0},KNOWLEDGE_READONLY:{code:"AX-KERNEL-013",title:"Knowledge Entry Is Read-Only",description:"A cognet tried to write or remove knowledge contributed by a module. Module material lives inside its own package and the next install would destroy any change \u2014 so this fails loudly rather than succeeding and vanishing later. An agent's own data/knowledge/ is writable.",source:"kernel",severity:"fatal",expected:!0},KNOWLEDGE_RECORD_FAILED:{code:"AX-KERNEL-014",title:"Knowledge Mutation Went Unrecorded",description:"A knowledge write or remove succeeded on disk, but the session record of it could not be committed. The mutation is real and already visible to the agent; only its audit trail is missing, so this is reported rather than thrown \u2014 the caller cannot undo a completed write. It matters because 'the agent rewrote its own memory' is the fact you want weeks later when behaviour drifts, and here the ledger and the filesystem disagree.",source:"kernel",severity:"degraded"},KNOWLEDGE_ESCAPE:{code:"AX-KERNEL-021",title:"Knowledge Path Escapes Store",description:"A knowledge name resolved outside the store root. Names are identifiers, not paths \u2014 traversal is refused at the boundary rather than trusted not to happen.",source:"kernel",severity:"fatal"},SCHEDULER_MODE_MISMATCH:{code:"AX-KERNEL-010",title:"Scheduler Mode Mismatch",description:"A caller used the wrong wake verb for the cognet's mode: continuous cognets advance via tick(), driven by the body's clock; invocation cognets wake on a stimulus via request()/stream().",source:"kernel",severity:"fatal"},THREAD_UNKNOWN_PARENT:{code:"AX-SESSION-001",title:"Thread Branched From Unknown Parent",description:"A thread's recorded lineage points at a parent thread id that isn't registered in this session \u2014 the session index is inconsistent.",source:"thread",severity:"fatal"},THREAD_NOT_FOUND:{code:"AX-SESSION-002",title:"Thread Not Found",description:"The requested thread id isn't registered in this session.",source:"thread",severity:"fatal",expected:!0},THREAD_BRANCH_UNKNOWN:{code:"AX-SESSION-003",title:"Cannot Branch Unknown Thread",description:"A branch was requested from a parent thread id that isn't registered in this session.",source:"thread",severity:"fatal"},SENSORY_WRITE_FAILED:{code:"AX-SESSION-004",title:"Sensory Ring Write Failed",description:"A dense sense entry (audio or visual) could not be written to the session's sensory ring \u2014 usually a full or read-only data directory. Delivery to the cognet is unaffected; the debug window for this session will have a gap.",source:"runtime",severity:"degraded"},NO_COGNET:{code:"AX-BLUEPRINT-001",title:"No Cognet Declared",description:"The blueprint carries no cognet definition \u2014 an agent cannot run without a brain. The CLI or test harness must construct and pass one.",source:"runtime",severity:"fatal"},CONTROL_PATH_NOT_FOUND:{code:"AX-CONTROL-001",title:"Control Path Not Found",description:"A control-channel call named a method the peer does not expose. The two ends disagree about the surface \u2014 usually a TUI and an extension built from different versions.",source:"server",severity:"fatal",expected:!0},CONTROL_PATH_NOT_CALLABLE:{code:"AX-CONTROL-002",title:"Control Path Not Callable",description:"A control-channel call resolved to a value on the peer's handle that is not a function.",source:"server",severity:"fatal"},CONTROL_CALL_FAILED:{code:"AX-CONTROL-003",title:"Control Call Failed",description:"The peer served a control-channel call and it threw. The remote message is carried here \u2014 the failure surfaces at the local call site rather than being returned as a falsy value.",source:"server",severity:"fatal"},CONTROL_CLOSED:{code:"AX-CONTROL-004",title:"Control Channel Closed",description:"A control-channel call was made, or was still in flight, when the channel closed. In-flight calls reject on close rather than hanging forever on an answer that is no longer coming.",source:"server",severity:"fatal"},CONTROL_UNAUTHORIZED:{code:"AX-CONTROL-005",title:"Control Handshake Rejected",description:"A connection to the control socket presented a missing or incorrect token. The token lives in the instance record, which is readable only by the owning user \u2014 a mismatch means the caller is not the local Fleet extension.",source:"server",severity:"fatal"},PLUGIN_BOOT_FAILED:{code:"AX-SERVER-001",title:"Plugin Failed During Boot",description:"A server plugin threw while running at boot \u2014 plugins are the one place in server startup where a failure must abort the boot rather than being warned and skipped.",source:"server",severity:"fatal"},HANDLE_SHUTDOWN_FAILED:{code:"AX-RUNTIME-002",title:"Handle Failed To Shut Down",description:"One of the runtime's owned handles (kernel, etc.) threw during shutdown \u2014 teardown is error-isolated, so the others still ran, but this one didn't close cleanly.",source:"runtime",severity:"fatal"},BUS_HANDLER_FAILED:{code:"AX-RUNTIME-004",title:"Bus Handler Failed",description:"A handler subscribed to a runtime bus event threw. Handler failures are non-fatal by design \u2014 the remaining handlers still run \u2014 but they are recorded rather than swallowed, since plugins and modules register handlers and a silently-broken one is invisible rot.",source:"runtime",severity:"degraded"},TOOL_CALL_FAILED:{code:"AX-RUNTIME-003",title:"Tool Call Failed",description:"An axon.tools.<namespace>.<fn>() call from script-land completed with a non-ok result from the capsule \u2014 unwrapped here into a normal throw, since script-land expects the ordinary call/throw contract, not the kernel's own stable-result shape.",source:"runtime",severity:"fatal"},CAPSULE_TOOL_TIMEOUT:{code:"AX-CAPSULE-001",title:"Tool Load Timed Out",description:"The sandbox never confirmed loading a declared tool within the timeout \u2014 it may be stuck on a slow import or the subprocess is unresponsive.",source:"capsule",severity:"fatal"},CAPSULE_TOOL_SCOPE_MISMATCH:{code:"AX-CAPSULE-002",title:"Tool Scope Mismatch",description:"A tool's declared exports don't match what it actually exported once loaded in the sandbox \u2014 the bundled source and its declaration have drifted apart.",source:"capsule",severity:"fatal"},CAPSULE_TOOL_FAILED:{code:"AX-CAPSULE-003",title:"Tool Failed To Load",description:"A declared tool failed to load into the sandbox \u2014 its source may be malformed, too large to import, or the subprocess exited before confirming.",source:"capsule",severity:"fatal"},CAPSULE_CONFINE_UNAVAILABLE:{code:"AX-CAPSULE-004",title:"OS Confinement Unavailable",description:"The policy requested OS confinement (isolation: auto) but the host is missing a required primitive (bubblewrap, systemd, nft, or the axon-agent user). Run `axon install`, or set isolation: none to opt out explicitly. The capsule refuses to boot rather than silently run unconfined.",source:"capsule",severity:"fatal"},CAPSULE_CONFINE_USER_UNRESOLVED:{code:"AX-CAPSULE-005",title:"Confinement User Unresolved",description:"The confinement user exists but its numeric uid/gid could not be read \u2014 the box cannot drop privileges without them. The host user database may be inconsistent.",source:"capsule",severity:"fatal"},CAPSULE_BOOT_FAILED:{code:"AX-CAPSULE-006",title:"Capsule Failed To Boot",description:"The sandbox subprocess exited or reported failure before completing the boot handshake. The captured stderr in the error context is the real cause \u2014 most often a confinement mount that could not be satisfied (a declared fs path that does not exist) or a runtime that could not start.",source:"capsule",severity:"fatal"},CAPSULE_BOOT_TIMEOUT:{code:"AX-CAPSULE-007",title:"Capsule Boot Timed Out",description:"The sandbox subprocess did not report ready within the boot timeout. Its captured stderr is in the error context; if empty, the subprocess may be hung rather than crashed.",source:"capsule",severity:"fatal"},CAPSULE_SPAWN_FAILED:{code:"AX-CAPSULE-008",title:"Capsule Spawn Failed",description:"The capsule subprocess command could not be spawned at all \u2014 the interpreter or confinement wrapper was not found, or PATH is unset. Check that bun (and, under confinement, bwrap/systemd-run) are on PATH.",source:"capsule",severity:"fatal"},CAPSULE_WIRE_CLOSED:{code:"AX-CAPSULE-009",title:"Capsule Wire Closed",description:"A command was sent to the sandbox after its stdin pipe was gone \u2014 the subprocess has exited or is mid-teardown. The caller is racing the capsule lifecycle.",source:"capsule",severity:"fatal"},CAPSULE_DOWN:{code:"AX-CAPSULE-010",title:"No Live Capsule",description:"An operation needed a running sandbox subprocess, but none is live \u2014 it is booting, restarting after a crash, or has been declared dead.",source:"capsule",severity:"fatal"},CAPSULE_ALREADY_BOOTED:{code:"AX-CAPSULE-011",title:"Capsule Already Booted",description:"boot() was called on a capsule that already has a live subprocess. Boot is once per lifetime; use update()/reload() to replace a running incarnation.",source:"capsule",severity:"fatal"},CAPSULE_INSTALL_FAILED:{code:"AX-CAPSULE-013",title:"Confinement Install Failed",description:"Provisioning the host for the hardened confinement tier failed \u2014 most often because creating the dedicated system user needs root. Re-run `axon install` with sufficient privilege.",source:"capsule",severity:"fatal"},CAPSULE_HOST_UNAVAILABLE:{code:"AX-CAPSULE-014",title:"Host Bridge Unavailable",description:"Sandboxed code called a host service, but this capsule was built with no host provider. Host calls require a wired host bridge on the manager side.",source:"capsule",severity:"fatal"},CAPSULE_CRASHED:{code:"AX-CAPSULE-015",title:"Capsule Crashed",description:"An unhandled error escaped inside the sandbox subprocess. The capsule reports it on the wire and exits immediately \u2014 after an unhandled throw the sandbox's state is unknown, and a capsule that keeps serving is worse than one that dies loudly.",source:"capsule",severity:"fatal"},CAPSULE_DEAD:{code:"AX-CAPSULE-016",title:"Capsule Dead",description:"The capsule subprocess is gone and supervision gave up restarting it. Every subsequent execution request fails until a new capsule is booted.",source:"capsule",severity:"fatal"},CAPSULE_PARSE_ERROR:{code:"AX-CAPSULE-017",title:"Capsule Wire Parse Error",description:"A line arriving from the sandbox was not a valid protocol event. The sandbox is speaking garbage \u2014 a protocol mismatch or corrupted output \u2014 and the line is dropped rather than acted on, never silently.",source:"capsule",severity:"degraded"},CAPSULE_CMD_FAILED:{code:"AX-CAPSULE-018",title:"Capsule Command Failed",description:"Code executed in the sandbox threw. This is the ordinary failure path for an agent-emitted block or a script-land run() \u2014 the error is the sandboxed code's own, surfaced verbatim.",source:"capsule",severity:"degraded"},CAPSULE_FN_FAILED:{code:"AX-CAPSULE-019",title:"Tool Call Threw",description:"A mediated tool function threw inside the sandbox. The failure is the tool's own; it propagates to the calling code unchanged and is recorded as the closing half of the call's span.",source:"capsule",severity:"degraded"},CAPSULE_PROC_DENIED:{code:"AX-CAPSULE-020",title:"Process Spawn Denied",description:"A process the sandbox tried to start was refused \u2014 denied by policy, killed before it could spawn, or the spawn itself failed. No process was created.",source:"capsule",severity:"degraded"},CAPSULE_PROC_FAILED:{code:"AX-CAPSULE-022",title:"Managed Process Failed",description:"A spawned child process errored without ever producing an exit code \u2014 an exec failure or a broken IPC channel. Distinct from a non-zero exit, which is the process running correctly and reporting a result.",source:"capsule",severity:"degraded"},CAPSULE_PROC_STDIN_FAILED:{code:"AX-CAPSULE-021",title:"Process Stdin Write Failed",description:"Writing to a managed child process's stdin failed \u2014 the process is no longer running, or its stdin has already closed.",source:"capsule",severity:"degraded"},NOT_BOOTED:{code:"AX-TUI-001",title:"No Agent Running",description:"A message was sent, or an action requiring a live agent was taken, before any agent finished booting.",source:"tui",severity:"fatal"},NOT_AUTHENTICATED:{code:"AX-TUI-002",title:"Not Logged In",description:"The action needs an active profile, but none is logged in yet.",source:"tui",severity:"fatal",expected:!0},PROFILE_NOT_AUTHENTICATED:{code:"AX-TUI-003",title:"Profile Has No Session",description:"The target profile exists but has no stored session \u2014 it has never logged in, or its session was cleared.",source:"tui",severity:"fatal",expected:!0},BACKEND_UNREACHABLE:{code:"AX-TUI-044",title:"Backend Unreachable",description:"A stored credential could not be verified because the backend could not be reached. The credential is NOT discarded \u2014 it may be perfectly valid \u2014 but it cannot be trusted until it is checked, so the action is refused rather than proceeding unverified.",source:"tui",severity:"fatal",expected:!0},PROFILE_UNKNOWN:{code:"AX-TUI-004",title:"Unknown Profile",description:"The requested profile id isn't one of the profiles stored on this machine.",source:"tui",severity:"fatal",expected:!0},SESSION_NOT_FOUND:{code:"AX-SESSION-005",title:"Session Not Found",description:"No session log exists at that path. A session is a .jsonl file under the agent's frame (`.agent/data/sessions/`); it may have been deleted, or belong to an agent that has since been removed.",source:"runtime",severity:"fatal",expected:!0},SESSION_UNREADABLE:{code:"AX-SESSION-006",title:"Session Log Unreadable",description:"The session log does not begin with a `session:header` line, so it cannot be forked or renamed. Either the file is truncated, or it was written by a version predating the header \u2014 an older log can still be read and resumed, just not copied.",source:"runtime",severity:"fatal",expected:!0},SESSION_ALREADY_RUNNING:{code:"AX-TUI-005",title:"Session Is Already Running",description:"spawn() was asked to resume a session that already has a live instance. Focus the running instance instead of booting a second runtime over the same log.",source:"tui",severity:"fatal",expected:!0},SESSION_NOT_RUNNING:{code:"AX-TUI-016",title:"Session Is Not Running",description:"focus() was pointed at a sessionId with no live instance behind it. Spawn (or resume) it first \u2014 focus is pure selection over running instances.",source:"tui",severity:"fatal",expected:!0},NO_ACTIVE_AGENT:{code:"AX-TUI-045",title:"No Active Agent",description:"The action needs a running agent, but none is active \u2014 start one first.",source:"tui",severity:"fatal",expected:!0},NO_LOCAL_PROJECT:{code:"AX-TUI-050",title:"No Local Project",description:"This agent has no project directory on this machine \u2014 it was attached over the network, so its source lives wherever it is running. Opening its config, or any other file verb, has to happen there. Focus a local agent instead.",source:"tui",severity:"fatal",expected:!0},NO_FOCUSED_INSTANCE:{code:"AX-TUI-017",title:"No Focused Agent Instance",description:"A module install/uninstall was requested with no running agent instance focused \u2014 spawn or focus one first.",source:"tui",severity:"fatal",expected:!0},MODEL_UNAVAILABLE:{code:"AX-TUI-051",title:"Model Not Available From Any Declared Provider",description:"The picked model was saved to the agent's config, but no provider this profile declares can supply it \u2014 so the running agent still uses its previous model. Connect the provider that serves it, or pick a model from the offered list.",source:"tui",severity:"fatal",expected:!0},MODEL_IMMUTABLE_DEPLOYED:{code:"AX-TUI-006",title:"Cannot Change A Deployment's Model",description:"A deployed agent's config lives in the cloud, not on this machine \u2014 its model is fixed at deploy time. Change it in the local project and deploy again.",source:"tui",severity:"fatal",expected:!0},MODULE_INSTALL_FAILED:{code:"AX-TUI-018",title:"Module Install Failed",description:"The registry installer returned an error for this module specifier \u2014 check the specifier and registry connectivity.",source:"tui",severity:"fatal"},NO_MODULES_INSTALLED:{code:"AX-TUI-019",title:"No Modules Installed",description:"The `:module uninstall` command was opened with no modules resolved into the focused instance's blueprint.",source:"tui",severity:"fatal"},SETTINGS_NOT_WRITABLE:{code:"AX-EXT-027",title:"Settings Cannot Be Written",description:"A settings change was requested on a store with no profile config behind it \u2014 nobody is logged in, or this Store was built without one (tests). Settings live in `profile.config.ts`, so there is nowhere to write them; the change was refused rather than saved somewhere nothing reads back.",source:"tui",severity:"fatal",expected:!0},REGISTRY_EMPTY:{code:"AX-TUI-047",title:"Nothing To Install",description:"The install palette was opened with no rows to show \u2014 the catalogue is still loading, the registry could not be reached, or everything published for that kind is already installed. The row itself says which.",source:"tui",severity:"fatal",expected:!0},NO_EXTENSIONS_INSTALLED:{code:"AX-TUI-046",title:"No Extensions Installed",description:"The `:ext uninstall` command was opened with no extensions declared in the active profile's profile.config.ts.",source:"tui",severity:"fatal",expected:!0},ATTACH_URL_REQUIRED:{code:"AX-TUI-048",title:"Attach URL Required",description:"`:attach` needs the address of a running agent \u2014 e.g. `:attach http://localhost:3010`. The agent must already be serving; attach binds to it and never boots anything.",source:"tui",severity:"fatal"},ATTACH_URL_INVALID:{code:"AX-TUI-049",title:"Attach URL Invalid",description:"The address is not a usable agent URL. An agent is reached over http or https and the scheme is required \u2014 `localhost:3010` is a path, `http://localhost:3010` is an address. Checked before anything connects, so a typo fails immediately rather than as a transport error.",source:"tui",severity:"fatal"},DEPLOYMENT_NOT_CONNECTABLE:{code:"AX-TUI-028",title:"Deployment Not Connectable",description:"The deployment is not in the connectable list \u2014 it may have stopped, errored, or never finished provisioning. Refresh the deployment list and try again.",source:"tui",severity:"fatal"},SUBAGENT_REMOTE_PARENT:{code:"AX-TUI-027",title:"Cannot Spawn A Subagent From A Deployment",description:"A subagent is forked from its parent's local project, and an attached deployment has no local project here \u2014 the deployed agent runs its own subagents inside its own capsule.",source:"tui",severity:"fatal"},BASE_MODEL_INSTANCE_CONFLICT:{code:"AX-TUI-026",title:"Managed Model Instance Already Running",description:"A managed base instance is already running on a different engine. The base workspace holds one shared config, so spawning a second naked model would rewrite it underneath the live instance \u2014 close the running one first.",source:"tui",severity:"fatal"},NOT_WIRED:{code:"AX-TUI-008",title:"Not Wired Yet",description:"This surface is a declared stub \u2014 the real implementation hasn't been built yet.",source:"tui",severity:"fatal"},MIC_ALREADY_CAPTURING:{code:"AX-TUI-009",title:"Mic Already Capturing",description:"capture.start() was called while a capture was already in progress \u2014 stop the current one first.",source:"tui",severity:"fatal"},MIC_CAPTURE_UNAVAILABLE:{code:"AX-TUI-010",title:"No Audio Capture Tool Found",description:"Voice input needs one of arecord, sox, or ffmpeg installed and on PATH.",source:"tui",severity:"fatal"},MIC_FFT_SIZE_MISMATCH:{code:"AX-TUI-014",title:"FFT Sample Size Mismatch",description:"computeBuckets() was called with a sample buffer that isn't exactly config.fftSize long \u2014 an internal invariant, callers must pad/trim first.",source:"tui",severity:"fatal"},MIC_CAPTURE_FAILED:{code:"AX-TUI-015",title:"Mic Capture Failed",description:"The audio capture subprocess produced no output or exited immediately \u2014 check that a microphone is available.",source:"tui",severity:"fatal"},WATCH_PATH_REQUIRED:{code:"AX-TUI-021",title:"Watch Path Required",description:"`axon watch`/`axon unwatch` need a directory argument.",source:"tui",severity:"fatal",expected:!0},WATCH_PATH_NOT_FOUND:{code:"AX-TUI-022",title:"Watch Path Not Found",description:"`axon watch` was given a directory that doesn't exist on disk.",source:"tui",severity:"fatal",expected:!0},EDITOR_NOT_SET:{code:"AX-TUI-023",title:"No Editor Configured",description:"`axon settings` needs the $EDITOR environment variable set to know which editor to open.",source:"tui",severity:"fatal"},EDITOR_LAUNCH_FAILED:{code:"AX-TUI-024",title:"Editor Failed To Launch",description:"The command in $EDITOR could not be spawned \u2014 check that it's installed and on PATH.",source:"tui",severity:"fatal"},WATCH_AND_INIT_ARGS_REQUIRED:{code:"AX-TUI-025",title:"Directory And Name Required",description:`The init palette's "watch a new directory" entry needs both a directory path and an agent name, space-separated.`,source:"tui",severity:"fatal",expected:!0},MODULE_CONFIG_LOAD_FAILED:{code:"AX-MODULE-001",title:"Module Config Failed To Load",description:"The runtime could not import a module's module.config.ts at boot \u2014 the file is missing at its resolved path, or importing it threw. A module that cannot load contributes nothing, so boot fails rather than run a partially-wired agent.",source:"runtime",severity:"fatal"},MODULE_SOURCE_DECLARED:{code:"AX-MODULE-008",title:"Module Declared As Source",description:"Uninstall was asked to remove a module that axon.config.ts declares as an IMPORT rather than by registry name. The import statement is the author's own code, so uninstall does not rewrite it \u2014 and removing the dependency alone would leave the config importing a package that is no longer declared, with the agent still loading it. Nothing was changed: delete the import and its entry in modules: [...] by hand.",source:"cli",severity:"fatal"},MODULE_NOT_INSTALLED:{code:"AX-MODULE-003",title:"Module Not Installed",description:"A plugin asked for the options of a module this agent does not have installed \u2014 almost always a name mismatch between the plugin and the module that ships it. Reported rather than defaulted: handing back an empty options bag would let a hardware module open the wrong device and never say so.",source:"runtime",severity:"fatal"},MODULE_OPTIONS_INVALID:{code:"AX-MODULE-002",title:"Invalid Module Options",description:"The options declared for a module under modules.<name> in axon.config.ts do not satisfy the module's options schema \u2014 a required option is missing or a value has the wrong type.",source:"runtime",severity:"fatal"},MODULE_SETUP_FAILED:{code:"AX-MODULE-007",title:"Module Setup Failed",description:"A module's setup() threw during agent boot. Setup runs sequentially in blueprint order and a failure is total \u2014 no later module is wired, and the agent does not boot half-configured.",source:"runtime",severity:"fatal"},MODULE_SERVER_NOT_WIRED:{code:"AX-MODULE-004",title:"Module Server API Not Wired",description:"A module's setup() called ctx.server.addRoute/addMiddleware or ctx.tools.get, but that surface is not implemented yet. Declare routes as server/api/ files in the module instead.",source:"runtime",severity:"fatal"},MODULE_ENV_REQUIRED:{code:"AX-MODULE-005",title:"Module Env Var Missing",description:"A module's setup() called ctx.env.require() for a variable the agent's resolved environment does not provide. The module declares required env in module.config.ts; the agent must supply it (e.g. in .env).",source:"runtime",severity:"fatal",expected:!0},MODULE_POLICY_IMMUTABLE:{code:"AX-MODULE-006",title:"Module Policy Is Immutable At Boot",description:"A module's setup() called ctx.policy.update(). The resolved agent policy is authoritative and cannot be mutated at boot \u2014 declare policy needs statically in module.config.ts so the CLI reconciles them at install.",source:"runtime",severity:"fatal",expected:!0},CLONE_REF_REQUIRED:{code:"AX-PROJECT-022",title:"No Artifact Named",description:"`axon clone` was run without an artifact to clone. Name one, for example: axon clone @axon/arxiv",source:"cli",severity:"fatal",expected:!0},FORK_REF_REQUIRED:{code:"AX-PROJECT-023",title:"No Artifact Named",description:"`axon fork` was run without an artifact to fork. Name one, for example: axon fork @axon/arxiv --as @you/arxiv",source:"cli",severity:"fatal"},FORK_NAME_REQUIRED:{code:"AX-PROJECT-024",title:"Fork Needs A New Name",description:"A fork is published under your own namespace, so it needs a name: pass --as <package-name>, for example: axon fork @axon/arxiv --as @you/arxiv",source:"cli",severity:"fatal"},CLONE_TARGET_EXISTS:{code:"AX-PROJECT-025",title:"Clone Target Not Empty",description:"The directory the artifact would be cloned into already has files in it. Clone into a new directory, or clear this one first.",source:"cli",severity:"fatal"},ARTIFACT_DOWNLOAD_FAILED:{code:"AX-PROJECT-026",title:"Artifact Download Failed",description:"The registry did not serve the artifact's source archive. The version may have been unpublished, or the network request failed.",source:"cli",severity:"fatal"},ARTIFACT_EXTRACT_FAILED:{code:"AX-PROJECT-027",title:"Artifact Extract Failed",description:"The downloaded archive could not be unpacked. It may be truncated, or `tar` is unavailable on this machine.",source:"cli",severity:"fatal"},VERSION_INVALID:{code:"AX-PROJECT-028",title:"Invalid Version",description:"The project's package.json version is not valid semver, so the next version cannot be derived from it. Fix the version field by hand.",source:"cli",severity:"fatal"},FRAMEWORK_NOT_INSTALLED:{code:"AX-PROJECT-029",title:"Framework Packages Not Installed",description:"The generated type frame references @arcforge/types, @arcforge/engines and h3, none of which resolve from this project. Run `bun install` before `axon prepare`.",source:"cli",severity:"fatal"},FRAME_MIGRATION_CONFLICT:{code:"AX-PROJECT-034",title:"Frame Migration Cannot Proceed Safely",description:"Runtime output exists in BOTH the old location and the new one, so migrating would have to merge or overwrite two sets of session history. Nothing was moved. Inspect both directories and remove or merge them by hand.",source:"cli",severity:"fatal"},CONFIG_EVALUATION_ESCAPED:{code:"AX-PROJECT-030",title:"defineAgent() Called Outside Config Evaluation",description:"defineAgent() ran outside the loader that evaluates axon.config.ts \u2014 it is a declaration helper, not a runtime function, and cannot be called from application code.",source:"cli",severity:"fatal"},PROMPT_NOT_INSTALLABLE:{code:"AX-PROJECT-037",title:"Prompts Are Not Installed Into Agents",description:"A prompt is content, not a capability: it resolves from the global cache and renders on demand, so every agent can already use it without declaring anything. Installing one into an agent would put content through the code path \u2014 an ABI check, a node_modules link, an agent reload \u2014 for something that needs none of it.",source:"manifest",severity:"fatal"},ASSET_TYPE_REFUSED:{code:"AX-PROJECT-038",title:"Unsupported Asset Type",description:"A file in assets/ is not a type the registry serves. Images (png, jpg, jpeg, webp, gif) and video (mp4, webm, mov) are accepted. SVG is deliberately refused: it is an executable document that would be served from our own storage origin, so a published SVG is a script-injection surface for every visitor reading that README.",source:"manifest",severity:"fatal",expected:!0},ASSET_TOO_LARGE:{code:"AX-PROJECT-039",title:"Asset Exceeds Size Limit",description:"A single file in assets/ is over the per-asset limit. Assets exist to illustrate a README, not to distribute media \u2014 compress the file or link to it externally.",source:"manifest",severity:"fatal",expected:!0},ASSETS_BUDGET_EXCEEDED:{code:"AX-PROJECT-040",title:"Assets Exceed Total Budget",description:"The assets/ folder as a whole is over budget for one published version. Every version stores its own copy of every asset, so the total is what determines how much a package costs to host forever.",source:"manifest",severity:"fatal",expected:!0},ASSET_PATH_INVALID:{code:"AX-PROJECT-041",title:"Unsafe Asset Path",description:"An entry under assets/ is a symlink, or its name escapes the assets directory. Both are refused: a published asset must be a real file that lands where its name says it does, or extraction on the server could write outside the target directory.",source:"manifest",severity:"fatal",expected:!0},ASSET_UNREADABLE:{code:"AX-PROJECT-042",title:"Asset Could Not Be Processed",description:"A file in assets/ has an image extension but could not be decoded, so it is either corrupt or not the format its name claims. Publishing it would ship a broken image into a README.",source:"manifest",severity:"fatal",expected:!0},PORT_UNAVAILABLE:{code:"AX-PROJECT-031",title:"No Free Port",description:"Every port in the range the agent scanned is already in use. Stop whatever is holding them, or start the agent on a different port.",source:"cli",severity:"fatal"},PARENT_INSTANCE_NOT_RUNNING:{code:"AX-RUNTIME-005",title:"Parent Agent Not Running",description:"A subagent was requested against a parent session that is no longer live \u2014 the parent shut down, crashed, or was never booted by this process.",source:"runtime",severity:"fatal"},SUBAGENT_DEPTH_EXCEEDED:{code:"AX-RUNTIME-006",title:"Subagent Depth Limit Reached",description:"An agent tried to spawn a subagent beyond the maximum nesting depth. The limit exists so a recursive delegation cannot spawn processes without bound.",source:"runtime",severity:"fatal"},SUBAGENT_CHILD_LIMIT_EXCEEDED:{code:"AX-RUNTIME-007",title:"Subagent Child Limit Reached",description:"One agent tried to hold more live children than the limit allows. Existing children must finish before more can be spawned.",source:"runtime",severity:"fatal"},SUBAGENT_DESCENDANT_LIMIT_EXCEEDED:{code:"AX-RUNTIME-008",title:"Subagent Descendant Limit Reached",description:"The whole subagent tree beneath one root exceeded its live-descendant budget. The limit bounds total concurrent processes, not just direct children.",source:"runtime",severity:"fatal"},SUBAGENT_REQUEST_INVALID:{code:"AX-RUNTIME-009",title:"Malformed Subagent Request",description:"A subagent request did not carry a usable prompt. It must be an object with `prompt` as a string or an array of strings.",source:"runtime",severity:"fatal"},INSTANCE_NOT_LOCAL:{code:"AX-RUNTIME-010",title:"Agent Instance Is Not Local",description:"An operation that only works against a locally booted agent was given a remote one. Subagent spawning and the managed base workspace both require a local process.",source:"runtime",severity:"fatal"},HOST_METHOD_UNKNOWN:{code:"AX-RUNTIME-011",title:"Unknown Host Method",description:"A booted agent called a host method this platform does not implement. The agent's framework version is likely newer than the CLI running it.",source:"runtime",severity:"fatal"},UPDATE_CURRENT_VERSION_INVALID:{code:"AX-TUI-029",title:"Running Version Is Not Semver",description:"The version this app reports for itself is not valid semver, so it cannot be compared against the latest release.",source:"cli",severity:"fatal"},UPDATE_RELEASE_INVALID:{code:"AX-TUI-030",title:"Malformed Release Record",description:"The backend's release record did not describe a valid @arcforge/axon `latest` version, so there is nothing safe to update to.",source:"cli",severity:"fatal"},UPDATE_UNAVAILABLE_IN_DEVELOPMENT:{code:"AX-TUI-031",title:"Update Not Available Here",description:"Self-update needs the packaged update helper and a supervisor request path, neither of which exists in a source checkout. Update the installed app instead.",source:"cli",severity:"fatal"},UPDATE_SUPERVISOR_UNAVAILABLE:{code:"AX-TUI-032",title:"Update Supervisor Unavailable",description:"The running app has no supervisor request path, so it cannot hand an update off to be applied after exit.",source:"cli",severity:"fatal"},UPDATE_HELPER_ARGS_INVALID:{code:"AX-TUI-033",title:"Malformed Update Helper Arguments",description:"The update helper was invoked without the --from/--to/--bun/--axon/--state arguments it requires. It is spawned by the app, not run by hand.",source:"cli",severity:"fatal"},UPDATE_HELPER_VERSION_INVALID:{code:"AX-TUI-034",title:"Update Helper Given Bad Versions",description:"The update helper received a --from or --to value that is not valid semver, so it refused to install anything.",source:"cli",severity:"fatal"},TEST_FILES_NOT_FOUND:{code:"AX-TUI-035",title:"No Test Files Matched",description:"No files matched the requested test patterns, so there was nothing to run. Check the pattern, or the directory it was resolved against.",source:"cli",severity:"fatal"},OLLAMA_UNAVAILABLE:{code:"AX-TUI-037",title:"Ollama Is Not Running",description:"No Ollama daemon answered on this machine. Start it with `ollama serve`, or install Ollama from https://ollama.com to run models locally.",source:"cli",severity:"fatal"},OLLAMA_REQUEST_FAILED:{code:"AX-TUI-038",title:"Ollama Request Failed",description:"The local Ollama daemon is running but refused a request \u2014 most often an unknown model name. The daemon's own message is included.",source:"cli",severity:"fatal"},OLLAMA_REGISTRY_UNREACHABLE:{code:"AX-TUI-039",title:"Ollama Registry Unreachable",description:"Could not reach the Ollama model registry to look a model up. Downloading needs a network connection; models already on disk still work offline.",source:"cli",severity:"fatal"},NO_EDITOR_ATTACHED:{code:"AX-TUI-042",title:"No Editor Attached",description:"Opening a pane hands it to a connected editor, and none is listening. Open this project in an editor running the Axon Fleet extension \u2014 it dials each running TUI itself, so the connection appears on its own once the window is up.",source:"tui",severity:"fatal"},NO_SESSION_TO_OPEN:{code:"AX-TUI-043",title:"No Session To Open",description:"A runtime pane is a view of one conversation, and no agent is focused yet \u2014 so there is nothing to point it at. Start or focus an agent first.",source:"tui",severity:"fatal"},CLEAR_IMMUTABLE_DEPLOYED:{code:"AX-TUI-041",title:"Cannot Clear A Deployment's Conversation",description:"A deployed agent owns its own session in the cloud \u2014 the TUI attaches to whatever session it is already running, so there is no fresh one to start from here. Use `:close` to detach, or clear it on a local instance of the same agent.",source:"tui",severity:"fatal"},OLLAMA_PULL_FAILED:{code:"AX-TUI-040",title:"Model Download Failed",description:"Ollama could not finish downloading the model. The name may not exist in the registry, or the transfer was interrupted \u2014 a retry resumes from whatever was already fetched.",source:"cli",severity:"fatal"},TEST_PRELOAD_MISSING:{code:"AX-TUI-036",title:"Test API Loaded Without Its Preload",description:"The instrumented test API was imported without the preload that installs it. Tests must run through `axon test`, which wires the preload.",source:"cli",severity:"fatal"},PROFILE_CONFIG_INVALID:{code:"AX-EXT-001",title:"profile.config.ts Did Not Call defineProfile()",description:"A profile's config must default-export defineProfile({ ... }). Without it there is no extension list to read, so nothing can be installed, enabled or disabled. The rest of the profile \u2014 main.ts and plugins/ \u2014 still loads.",source:"tui",severity:"fatal",expected:!0},PROFILE_CONFIG_FAILED:{code:"AX-EXT-002",title:"profile.config.ts Failed to Load",description:"The file threw while being evaluated, so its extension list could not be read and no extensions were loaded. The profile's own main.ts and plugins/ are unaffected \u2014 a typo in an extension list must not cost you the config you already had working.",source:"tui",severity:"degraded",expected:!0},EXTENSION_ENTRY_INVALID:{code:"AX-EXT-003",title:"Malformed Extension Entry",description:'An entry in profile.config.ts\'s `extensions` array is neither a string nor an object with a `source`. Accepted forms are "@scope/name" for a registry extension and "./extensions/name" for a local one.',source:"tui",severity:"degraded",expected:!0},EXTENSION_NOT_FOUND:{code:"AX-EXT-004",title:"Extension Not Found",description:"An extension listed in profile.config.ts is not on disk. A local path may have moved or been deleted; a registry name may never have been installed. Everything else in the list still loads.",source:"tui",severity:"degraded",expected:!0},EXTENSION_INSTALL_FAILED:{code:"AX-EXT-005",title:"Extension Install Failed",description:"A registry extension could not be fetched or prepared \u2014 most often no network, or a name that does not exist in the registry. It is skipped for this session and retried on the next launch.",source:"tui",severity:"degraded",expected:!0},EXTENSION_UNINSTALL_FAILED:{code:"AX-EXT-028",title:"Extension Uninstall Failed",description:"An extension could not be removed from profile.config.ts \u2014 most often the file is unreadable or has been edited into a shape the editor cannot find the extensions list in. The extension is still declared and will load on the next launch.",source:"tui",severity:"degraded",expected:!0},EXTENSION_NOT_AN_EXTENSION:{code:"AX-EXT-006",title:"Not an Extension",description:"The directory has no extension.config.ts, which is the file that marks a directory as an extension. A path pointing at an agent, a module, or an ordinary folder is not loadable as one.",source:"tui",severity:"degraded",expected:!0},EXTENSION_LOAD_FAILED:{code:"AX-EXT-007",title:"Extension Failed to Load",description:"An extension's main.ts threw while it was being loaded, so whatever it had not yet registered is missing. Its commands, keys and palettes are removed and the rest of your config loads normally.",source:"tui",severity:"degraded",expected:!0},PROFILE_MAIN_FAILED:{code:"AX-EXT-008",title:"main.ts Failed to Load",description:"Your profile's main.ts threw while being evaluated. Anything it registered before the error survives; everything after it did not run. Plugins and extensions still load.",source:"tui",severity:"degraded",expected:!0},PLUGIN_FAILED:{code:"AX-EXT-009",title:"Plugin Failed to Load",description:"A file in plugins/ threw while being imported, so its hooks were not registered. Other plugins in the same folder are unaffected \u2014 each file is loaded independently.",source:"tui",severity:"degraded",expected:!0},HOOK_FAILED:{code:"AX-EXT-010",title:"Lifecycle Hook Failed",description:"A tui.hook() handler threw while the event it listens for was firing. For a notification hook nothing else is affected; for a gating hook (tui:boot, tui:shutdown) the operation continues anyway rather than leaving the terminal stuck.",source:"tui",severity:"degraded",expected:!0},HOOK_TIMED_OUT:{code:"AX-EXT-011",title:"Hook Blocked Too Long",description:"A gating hook (tui:boot or tui:shutdown) did not finish within its budget, so the TUI continued without waiting. A config must never be able to hang the terminal silently \u2014 whatever the handler was doing may not have completed.",source:"tui",severity:"degraded",expected:!0},COMMAND_NOT_FOUND:{code:"AX-EXT-012",title:"No Such Command",description:"commands.run() was given a path that resolves to nothing in the command tree. The path must name a leaf, spelled exactly as it appears in the `:` palette.",source:"tui",severity:"fatal",expected:!0},PALETTE_NOT_FOUND:{code:"AX-EXT-013",title:"No Such Palette",description:"palette.open() was given a name no palette was registered under. Palettes are created with palette.create(name, ...) \u2014 a name is only openable once its registration has run.",source:"tui",severity:"fatal",expected:!0},PALETTE_NAME_TAKEN:{code:"AX-EXT-014",title:"Palette Name Already Registered",description:"Two palettes tried to claim the same name. Names are how palette.open() addresses one, so they have to be unique \u2014 silently replacing the first would make whichever loaded last win, invisibly.",source:"tui",severity:"degraded",expected:!0},PALETTE_ALREADY_OPEN:{code:"AX-EXT-015",title:"A Palette Is Already Open",description:"Something tried to open a palette, or ask a question, while the user was already navigating one. Stealing it mid-navigation would drop whatever they were doing, so the call fails instead \u2014 check palette.isOpen first.",source:"tui",severity:"degraded",expected:!0},KEY_CHORD_UNBOUND:{code:"AX-EXT-022",title:"No Such Key Binding",description:"keys.send() was given a chord nothing is bound to \u2014 neither a mode key nor a registered binding. Sending it would do nothing at all, which is indistinguishable from a binding that ran and had no effect.",source:"tui",severity:"fatal",expected:!0},AGENT_SPAWN_NO_INSTANCE:{code:"AX-EXT-023",title:"Agent Started but No Instance Appeared",description:"A spawn reported success without producing a focused instance, so there is no id to hand back. This is a fault in Axon rather than in your config \u2014 the agent may or may not be running.",source:"tui",severity:"fatal"},PROFILE_CONFIG_MISSING:{code:"AX-EXT-025",title:"No profile.config.ts",description:"The profile has no config file to record the extension in. It is normally created on first launch \u2014 starting Axon once will scaffold it.",source:"tui",severity:"fatal",expected:!0},PROFILE_CONFIG_UNEDITABLE:{code:"AX-EXT-026",title:"profile.config.ts Could Not Be Edited",description:"The `defineProfile({ ... })` call could not be located, or editing it would have produced invalid TypeScript. Nothing was written \u2014 this file is yours, and a botched edit costs your whole TUI config. Add or remove the entry by hand.",source:"tui",severity:"fatal",expected:!0},COMMAND_INVALID:{code:"AX-EXT-029",title:"Command Is Not Registerable",description:"A command was registered with no path, or with no `run` to call. Both are caught here rather than when someone presses Enter on it \u2014 a command that registers cleanly and then does nothing reads as a broken terminal instead of a config mistake, and gives no clue which file to open. Use `commands.register(path, fn)` or `commands.register(path, { run })`.",source:"tui",severity:"degraded",expected:!0},COMPONENT_NAME_TAKEN:{code:"AX-EXT-030",title:"Component Already Registered",description:"Two sources registered the same line component name. The first one loaded keeps it \u2014 your own config beats any extension. A silently shadowed component would render someone else's value under your name, so the second registration fails instead. Component names are `provider:name`; pick a prefix of your own.",source:"tui",severity:"degraded",expected:!0},COMPONENT_UNKNOWN:{code:"AX-EXT-031",title:"No Such Component",description:"A line named a component that is not registered. Caught when the line is created rather than when it paints, because a missing component renders as an empty gap \u2014 which reads as a layout bug instead of a typo, and gives no clue which name was wrong. components.list() returns everything available.",source:"tui",severity:"degraded",expected:!0},LINE_NAME_TAKEN:{code:"AX-EXT-032",title:"Line Already Registered",description:"Two sources registered the same line name. The first one loaded keeps it, the same rule commands and key chords follow.",source:"tui",severity:"degraded",expected:!0},LINE_UNKNOWN:{code:"AX-EXT-033",title:"No Such Line",description:"lines.set(), move(), show(), hide() or toggle() named a line that is not registered. Doing nothing would be indistinguishable from a line that registered and then rendered empty, so this fails instead. lines.list() returns what exists.",source:"tui",severity:"degraded",expected:!0},COMMAND_PATH_TAKEN:{code:"AX-EXT-020",title:"Command Already Registered",description:"Two sources registered the same command path. The first one loaded keeps it \u2014 your own config beats any extension, and between extensions the one listed earlier in profile.config.ts wins. Rename one of them.",source:"tui",severity:"degraded",expected:!0},KEY_CHORD_TAKEN:{code:"AX-EXT-021",title:"Key Chord Already Bound",description:"Two sources bound the same key chord. The first one loaded keeps it. A silently shadowed binding is unbearable to debug in someone else's config, so the second registration fails instead of replacing it.",source:"tui",severity:"degraded",expected:!0},MODE_KEY_TAKEN:{code:"AX-EXT-016",title:"Mode Key Already Bound",description:"A palette asked for a mode key that is already in use \u2014 either by a built-in mode or by another extension. A silently shadowed key is unbearable to debug in someone else's config, so the registration fails loudly instead.",source:"tui",severity:"degraded",expected:!0},MODE_UNKNOWN:{code:"AX-EXT-017",title:"No Such Mode",description:"mode.set() was given a name that is neither a built-in mode nor a registered palette. Doing nothing would look identical to a mode that simply does not render, so this fails instead.",source:"tui",severity:"fatal",expected:!0},NO_FOCUSED_AGENT:{code:"AX-EXT-018",title:"No Agent Focused",description:"A verb that acts on the focused agent \u2014 send, stop, reboot \u2014 was called while nothing was running. Start one with agents.spawn(name) or tui.nav(name) first.",source:"tui",severity:"fatal",expected:!0},INSTANCE_NOT_RUNNING:{code:"AX-EXT-019",title:"Instance Not Running",description:"An instance id was given for a conversation that is not live \u2014 it may already have been stopped, or it belongs to an earlier session. agents.list() returns what is currently running.",source:"tui",severity:"fatal",expected:!0},CONNECT_REJECTED:{code:"AX-EXT-020",title:"Connector Credential Rejected",description:"The platform refused the credential pasted during `:connect`. Verification runs before the value is written, so nothing was stored \u2014 the detail carries the platform's own reason, and the most common cause is copying the wrong secret from the developer portal.",source:"tui",severity:"fatal",expected:!0}}});import{readFileSync as A3i}from"fs";function IQn(e=1){let n=Error().stack;if(!n)return[];return n.split(`
|
|
687
687
|
`).slice(1+e).map(Y_a).filter(j_a).map(H_a)}function K_a(e){return e.split(`
|
|
688
688
|
`).slice(1).map(Y_a).filter(j_a).map(H_a)}function EQn(e){if(!e)return null;return K_a(e)[0]??null}function Y_a(e){let n=e.match(i3i);if(n){let[,i,s,u,p]=n;return{functionName:i??null,fileName:s??null,lineNumber:H1t(u),columnNumber:H1t(p)}}let A=e.match(r3i);if(A){let[,i,s,u]=A;return{functionName:null,fileName:i??null,lineNumber:H1t(s),columnNumber:H1t(u)}}return{functionName:null,fileName:null,lineNumber:null,columnNumber:null}}function H1t(e){if(e===void 0)return null;let n=parseInt(e,10);return Number.isNaN(n)?null:n}function j_a(e){if(!e.fileName)return!1;return!o3i.some((n)=>e.fileName.includes(n))}function H_a(e){return{...e,source:s3i(e.fileName,e.lineNumber)}}function s3i(e,n){if(!e||n===null)return null;let A;try{A=A3i(e,"utf-8")}catch{return null}let i=A.split(`
|
|
689
689
|
`),s=n-1;if(s<0||s>=i.length)return null;let u=Math.max(0,s-R_a),p=Math.min(i.length-1,s+R_a),d=[];for(let b=u;b<=p;b++)d.push({lineNumber:b+1,text:i[b]??""});return d}var i3i,r3i,o3i,R_a=2;var yQn=xt(()=>{i3i=/at\s+(.*?)\s+\((.*?):(\d+):(\d+)\)/,r3i=/at\s+(.*?):(\d+):(\d+)/,o3i=["node_modules","native:","internal","bun:"]});function J_a(e){if(!e.fileName||e.lineNumber===null)return e.functionName?`at ${e.functionName}`:"at <unknown>";let n=`${e.fileName}:${e.lineNumber}:${e.columnNumber??0}`,A=e.functionName?`at ${e.functionName} (${n})`:`at ${n}`,i=e.source?p3i(e.source,e.lineNumber,e.columnNumber):null;return i?`${A}
|
|
@@ -4966,7 +4966,7 @@ ${V}`+i.slice(L+1)}return await Qbe(A,_be(U,A)),{changed:!0}}let u=Hmr(A,i);if(!
|
|
|
4966
4966
|
|
|
4967
4967
|
${b}`+i.slice(d):i.slice(0,d)+`
|
|
4968
4968
|
${b}${E}
|
|
4969
|
-
`+i.slice(d);return await Qbe(A,_be(y,A)),{changed:!0}}async function mvn(e,n){let A=kbe(e);if(!Or.exists(A))return{changed:!1};let i=await wbe(A,"utf-8"),s=PKe(A,i,"providers");if(!s)return{changed:!1};let u=s.array.elements.find((x)=>lvn(x)===n);if(!u)return{changed:!1};if(Pmr(u))return{changed:!1};let p=u.getStart(s.source),d=u.getEnd(),b=i.slice(d).match(/^\s*,/),E=d+(b?b[0].length:0),y=i.slice(0,p).match(/\s*$/),k=p-(y?y[0].length:0);return await Qbe(A,_be(i.slice(0,k)+i.slice(E),A)),{changed:!0}}var eB,jmr="profile.config.ts";var dvn=xt(()=>{qs();ph();pCt();tBt();eB=fp(Jhe(),1)});import{pathToFileURL as Jmr}from"url";import{join as fvn}from"path";function hvn(){let e=null;return{open(){e=[]},close(){let n=e??[];return e=null,n},track(n){e?.push(n)}}}async function C7a(e){await import(`${Jmr(e).href}?t=${crypto.randomUUID()}`)}async function Omr(e){let n=fvn(e,"plugins");if(!Or.exists(n))return[];return(await Or.list(n)).filter((i)=>i.endsWith(".ts")).sort().map((i)=>fvn(n,i))}async function bvn(e){let{root:n,label:A,sink:i,mainError:s}=e;i.open();let u=[],p=fvn(n,"main.ts");if(Or.exists(p))try{await C7a(p),u.push({path:p,error:null})}catch(d){u.push({path:p,error:Pn(s,{detail:`${p} \u2014 ${d instanceof Error?d.message:String(d)}`,context:{path:p,source:A},cause:d})})}for(let d of await Omr(n))try{await C7a(d),u.push({path:d,error:null})}catch(b){u.push({path:d,error:Pn("PLUGIN_FAILED",{detail:`${d} \u2014 ${b instanceof Error?b.message:String(b)}`,context:{path:d,source:A},cause:b})})}return{root:n,label:A,files:u,disposers:i.close()}}function B7a(e){for(let n of[...e.disposers].reverse())try{n()}catch{}}var Cvn=xt(()=>{qs();ph()});import{mkdir as $mr,rename as zmr,rm as Bvn}from"fs/promises";import{dirname as Wmr,join as I7a}from"path";function Ivn(e){return Or.exists(I7a(e,"extension.config.ts"))}function Evn(e){let n=e.store??jKe(),A=hvn(),i=[],s=[];async function u(){s=await JKe(e.root())}async function p(y,k){let x=await XSt(y,k);return await u(),x}async function d(y,k){let x=await e8t(y,k);return await u(),x}let b=null;async function E(y){if(y.kind==="registry"&&!Ivn(y.root)){if(Or.exists(y.root))await Bvn(y.root,{recursive:!0,force:!0});if(!e.install)return Pn("EXTENSION_NOT_FOUND",{detail:`${y.source} is not installed`,context:{source:y.source,root:y.root}});try{await e.install(y.source,y.root)}catch(k){return Pn("EXTENSION_INSTALL_FAILED",{detail:`${y.source} \u2014 ${k instanceof Error?k.message:String(k)}`,context:{source:y.source,root:y.root},cause:k})}}if(!Or.exists(y.root))return Pn("EXTENSION_NOT_FOUND",{detail:`${y.source} \u2192 ${y.root}`,context:{source:y.source,root:y.root}});if(!Ivn(y.root))return Pn("EXTENSION_NOT_AN_EXTENSION",{detail:`${y.root} has no extension.config.ts`,context:{source:y.source,root:y.root}});return null}return{get sources(){return i},get declared(){return s},syncDeclared:u,list(){return JKe(e.root())},settings(){return t8t(e.root())},async setSetting(y,k){let x=e.root(),S=()=>uvn(x,y,k);return b?b(S):S()},readProviders(){return gvn(e.root())},async addProvider(y){let k=e.root(),x=()=>pvn(k,y);return b?b(x):x()},async removeProvider(y){let k=e.root(),x=()=>mvn(k,y);return b?b(x):x()},isLocalExtension(y){try{return Ivn(U6e(y,e.root(),n).root)}catch{return!1}},async install(y){let k=e.root();if(U6e(y,k,n).kind==="local"){let me=U6e(y,k,n),be=await E(me);if(be)throw be;let{changed:ce}=await p(k,y);return{root:me.root,declared:ce,ref:y}}let{name:x,version:S}=eL(y),L=S?n.resolve(y):null;if(L){let me=eBt(L.name,L.version),{changed:be}=await p(k,me);return{root:L.root,declared:be,ref:me}}if(!e.install)throw Pn("EXTENSION_NOT_FOUND",{detail:`${y} is not installed`,context:{source:y}});let U=I7a(n.root,".staging",crypto.randomUUID()),$;try{({version:$}=await e.install(y,U))}catch(me){throw await Bvn(U,{recursive:!0,force:!0}),Pn("EXTENSION_INSTALL_FAILED",{detail:`${y} \u2014 ${me instanceof Error?me.message:String(me)}`,context:{source:y},cause:me})}let V=n.pathFor(x,$);if(n.isUsable(V))await Bvn(U,{recursive:!0,force:!0});else await $mr(Wmr(V),{recursive:!0}),await zmr(U,V);let te=eBt(x,$),{changed:ee}=await p(k,te);return{root:V,declared:ee,ref:te}},async uninstall(y){let k=e.root(),x=await JKe(k),{name:S}=eL(y),L=x.find(($)=>eL($).name===S)??y,{changed:U}=await d(k,L);return{changed:U,removed:!1}},async updates(){if(!e.latest)return[];let y=e.root(),k=await JKe(y);return(await Promise.all(k.map(async(S)=>{if(U6e(S,y,n).kind==="local")return null;let{name:L,version:U}=eL(S);try{let $=await e.latest(L);return{source:S,name:L,current:U,latest:$,outdated:U!==null&&$!==U}}catch{return{source:S,name:L,current:U,latest:null,outdated:!1}}}))).filter((S)=>S!==null)},async update(y,k){let{root:x,ref:S}=await this.install(eBt(y,k));return{root:x,ref:S}},get disposers(){return A},async load(){let y=[],k=[],x=e.root();if(Or.exists(x))k.push(await bvn({root:x,label:"profile",sink:A,mainError:"PROFILE_MAIN_FAILED"}));let S=await R6e(x,n);if(S.error)y.push(S.error);s=S.entries.map((L)=>L.source);for(let L of S.entries){let U=await E(L);if(U){y.push(U);continue}k.push(await bvn({root:L.root,label:L.source,sink:A,mainError:"EXTENSION_LOAD_FAILED"}))}return i=k,{sources:k,errors:y}},unload(){for(let y of[...i].reverse())B7a(y);i=[]},async reload(){return this.unload(),this.load()},watch(y){let k=T6e({root:e.root(),ignore:["node_modules",".git",".axon","agents","store"],debounceMs:150}),x=400;b=($)=>k.during($,{selfReloads:!0});let S=!1,L=0,U=k.onChange(()=>{if(S||Date.now()<L)return;S=!0,(async()=>{try{await y()}finally{S=!1,L=Date.now()+400}})()});return k.start(),()=>{b=null,U(),k.stop()}}}}var E7a=xt(()=>{qs();ph();XCt();ivn();dvn();tBt();Cvn()});var n8t=xt(()=>{E7a();ivn();dvn();Cvn();tBt()});function Q7a(e,n){if(e===null)return!0;return y7a.indexOf(n)>y7a.indexOf(e)}function yvn(e){switch(e){case"build:modules:complete":return"modules";case"build:tree:complete":return"dependencies";case"build:cognet:complete":return"cognet";default:return null}}function Qvn(e){switch(e){case"build:prepare:start":case"build:framework:start":case"build:modules:start":case"build:typegen:start":return"preparing";case"build:tree:start":return"dependencies";case"build:cognet:start":return"compiling";default:return null}}var y7a;var _vn=xt(()=>{y7a=["preparing","dependencies","compiling","booting"]});import{randomUUID as Zmr}from"crypto";import{resolve as _7a}from"path";async function K6e(e){let{project:n}=e,A=bCt({root:n.root});async function i(){try{let nt=e.store.profiles.active();if(!nt)return;let je=await cvn(nt.root);return Object.keys(je).length>0?je:void 0}catch{return}}async function s(){try{let nt=e.store.profiles.active();if(!nt)return;let{providers:je}=await R6e(nt.root);return je?[...je]:void 0}catch{return}}let u=e.session??Zmr(),p=Jxn({root:Fh({root:n.root,kind:"agent"}).path("data"),sessionId:u,...e.onProgress||e.onTiming?{onEmit:E}:{}}),d=null;function b(nt){if(!Q7a(d,nt.stage))return;d=nt.stage,e.onProgress?.(nt)}function E(nt,je){let Xe=yvn(nt);if(Xe){let _t=je.durationMs;if(typeof _t==="number")e.onTiming?.({unit:Xe,durationMs:_t});return}let gt=Qvn(nt);if(!gt)return;let Oe=nt==="build:modules:start"?je.specifiers:void 0;b(Oe?.length?{stage:gt,total:Oe.length,detail:Oe[0]}:{stage:gt})}let y=new Set;function k(nt){return`${nt.domain}\x00${nt.error}`}function x(nt){p.emit("build:warning",{domain:nt.domain,message:nt.error,...nt.cause?{error:nt.cause}:{}})}function S(nt){let je=new Set;for(let Xe of nt){let gt=k(Xe);if(je.has(gt)||y.has(gt)){je.add(gt);continue}je.add(gt),x(Xe)}y.clear();for(let Xe of je)y.add(Xe)}async function L(){let nt=await NKe(p,"build:prepare",{root:n.root},()=>n.prepare({report:(gt,Oe)=>p.emit(gt,Oe)}),(gt)=>({warnings:gt.warnings.length})),{blueprint:je,warnings:Xe}=await NKe(p,"build:load",{root:n.root},async()=>A.load({profilePolicy:await i(),profileProviders:await s()}),(gt)=>({agent:gt.blueprint.agent?.name??"",tools:gt.blueprint.tools?.length??0,prompts:gt.blueprint.prompts?.length??0,modules:gt.blueprint.modules?.length??0,warnings:gt.warnings.length}));if(je.agent?.name)p.identify(je.agent.name);return S([...nt.warnings,...Xe]),await p.flush(),{...je,session:{id:u}}}if(e.confined)return await $(e.confined);let U=await V();async function $(nt){return NKe(p,"build",{root:n.root},async()=>{let je=await L(),Xe=await nt({blueprint:{...je,session:{id:u}},sessionId:u,rescan:()=>L().then((gt)=>({...gt,session:{id:u}}))});return p.handOver((gt,Oe)=>{Xe.session.commit(gt,Oe)}),e.store.running.start({pid:Xe.pid,sessionId:u,parentSessionId:e.parentSessionId??null,rootSessionId:e.rootSessionId??u,depth:e.depth??0,agentName:je.agent?.name??n.name,projectRoot:n.root,dataRoot:_7a(n.root,".agent/data"),...e.job?{job:e.job}:{},...e.control?{control:e.control}:{},startedAt:new Date().toISOString()}),Xe})}async function V(){return NKe(p,"build",{root:n.root},async()=>{let je={...await L(),session:{id:u}};if(e.onProgress)b({stage:"booting"});let Xe=await PSt({blueprint:je,cloud:e.cloud,cwd:e.cwd,...e.host?{host:e.host}:{},...e.escalate?{escalate:e.escalate}:{}});return p.handOver((gt,Oe)=>{Xe.session.commit(gt,Oe)}),Xe})}e.store.running.start({pid:process.pid,sessionId:U.blueprint.session.id,parentSessionId:e.parentSessionId??null,rootSessionId:e.rootSessionId??U.blueprint.session.id,depth:e.depth??0,agentName:U.blueprint.agent.name,projectRoot:n.root,dataRoot:_7a(U.blueprint.paths.root,U.blueprint.paths.data),...e.job?{job:e.job}:{},...e.control?{control:e.control}:{},startedAt:new Date().toISOString()});let te=e.watch??!0,ee=te?n.watcher.onChange(()=>{Ze().catch(()=>{})}):()=>{},me=te?A.cognet.compiledFrom:null,be=me?T6e({root:me}):null,ce=be?.onChange(()=>{Ze().catch(()=>{})}),ke=be?n.link(be):null,Te=null;async function Ze(){if(Te)return Te.then(()=>Ze());Te=U.session.scope(async()=>{let nt,je=Date.now();try{let Xe=await A.load({compile:!0,profilePolicy:await i(),profileProviders:await s()});nt=Xe.blueprint,S(Xe.warnings),await n.typegen(nt)}catch(Xe){let gt=Pn(Xe);if(gt.code==="AX-COGNET-014"){let Oe={domain:"cognet",error:"dependency tree is being rewritten \u2014 keeping the current blueprint, will reload when it settles"},_t=k(Oe);if(!y.has(_t))y.add(_t),x(Oe);return}throw await U.session.commit("axon:reload:start",{revision:0}),await U.session.commit("axon:reload:failed",{error:gt,durationMs:Date.now()-je}),gt}await U.update(nt,{mode:"replace"})});try{await Te}finally{Te=null}}if(te)await n.watcher.start();return await be?.start(),{kind:"process",get sessionId(){return U.blueprint.session.id},get current(){return U},reload:Ze,serve(nt,je=10){let Xe=(gt)=>U.server.handler(gt);for(let gt=nt;gt<nt+je;gt++)try{return Bun.serve({port:gt,fetch:Xe})}catch(Oe){if(Vmr(Oe)&><nt+je-1)continue;throw Oe}throw Pn("PORT_UNAVAILABLE",{detail:`no free port in range ${nt}\u2013${nt+je-1}`,context:{from:nt,to:nt+je-1}})},async shutdown(){if(e.store.running.stop(U.blueprint.session.id),ee(),ce?.(),ke?.(),te)n.watcher.stop();be?.stop(),await Te?.catch(()=>{}),await U.shutdown()}}}function Vmr(e){let n=e?.code,A=e instanceof Error?e.message:String(e);return n==="EADDRINUSE"||/address already in use|in use|EADDRINUSE/i.test(A)}var a8t=xt(()=>{KKe();qs();qCt();Cbe();n8t();_vn();e2();zSt()});function w7a(e){if(e.byteLength>j6e)throw Pn("LINK_FRAME_TOO_LARGE",{detail:`${e.byteLength} exceeds ${j6e}`,context:{bytes:e.byteLength,max:j6e}});let n=new Uint8Array(Y6e+e.byteLength);return new DataView(n.buffer).setUint32(0,e.byteLength,!1),n.set(e,Y6e),n}function wvn(){let e=new Uint8Array(0);function n(A){if(e.byteLength===0){e=new Uint8Array(A);return}let i=new Uint8Array(e.byteLength+A.byteLength);i.set(e,0),i.set(A,e.byteLength),e=i}return{push(A){n(A);let i=[];for(;;){if(e.byteLength<Y6e)break;let u=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0,!1);if(u>j6e)throw Pn("LINK_FRAME_TOO_LARGE",{detail:`declared ${u} exceeds ${j6e}`,context:{declared:u,max:j6e}});if(e.byteLength<Y6e+u)break;i.push(e.slice(Y6e,Y6e+u)),e=e.slice(Y6e+u)}return i},get pending(){return e.byteLength}}}function kvn(e){return w7a(Xmr.encode(JSON.stringify(e)))}function Dvn(e){return JSON.parse(edr.decode(e))}var j6e=67108864,Y6e=4,Xmr,edr;var xvn=xt(()=>{qs();Xmr=new TextEncoder,edr=new TextDecoder});function A8t(e){let n=wvn(),A=new Map,i=new Map,s=new Map,u=null;function p(k){if(u)throw u;e.socket.write(kvn(k))}function d(k){try{p(k)}catch(x){e.onError(x)}}async function b(k){let x=new AbortController;s.set(k.id,x);try{if(!e.handlers?.call)throw Pn("LINK_NO_HANDLER",{detail:`call ${k.verb}`,context:{verb:k.verb,kind:"call"}});let S=await e.handlers.call(k.verb,k.arg,x.signal);d({k:"reply",id:k.id,ok:!0,value:S})}catch(S){d({k:"reply",id:k.id,ok:!1,error:S.message})}finally{s.delete(k.id)}}async function E(k){let x=new AbortController;s.set(k.id,x);try{if(!e.handlers?.stream)throw Pn("LINK_NO_HANDLER",{detail:`stream ${k.verb}`,context:{verb:k.verb,kind:"stream"}});for await(let S of e.handlers.stream(k.verb,k.arg,x.signal)){if(x.signal.aborted)break;if(d({k:"chunk",id:k.id,value:S}),(e.socket.pending??0)>k7a&&e.socket.whenDrained)await e.socket.whenDrained(k7a)}d({k:"end",id:k.id,ok:!0})}catch(S){d({k:"end",id:k.id,ok:!1,error:S.message})}finally{s.delete(k.id)}}function y(k){switch(k.k){case"call":b(k);return;case"open":E(k);return;case"send":try{e.handlers?.send?.(k.verb,k.arg)}catch(x){e.onError(x)}return;case"reply":{let x=A.get(k.id);if(!x)return;A.delete(k.id),k.ok?x.resolve(k.value):x.reject(Error(k.error));return}case"chunk":i.get(k.id)?.push(k.value);return;case"end":{let x=i.get(k.id);if(!x)return;i.delete(k.id),x.end(k.ok?void 0:Error(k.error));return}case"abort":s.get(k.id)?.abort();return}}return{receive(k){let x;try{x=n.push(k)}catch(S){this.fail(S);return}for(let S of x)try{y(Dvn(S))}catch(L){e.onError(L)}},call(k,x,S){if(u)return Promise.reject(u);let L=D7a();return new Promise((U,$)=>{A.set(L,{resolve:U,reject:$}),S?.addEventListener("abort",()=>{if(!A.delete(L))return;d({k:"abort",id:L}),$(new DOMException("aborted","AbortError"))},{once:!0}),p({k:"call",id:L,verb:k,arg:x})})},send(k,x){p({k:"send",verb:k,arg:x})},async*stream(k,x,S){if(u)throw u;let L=D7a(),U=[],$,V=null;i.set(L,{push(ee){U.push(ee),V?.(),V=null},end(ee){$=ee??null,V?.(),V=null}});let te=()=>{d({k:"abort",id:L}),i.delete(L),$=new DOMException("aborted","AbortError"),V?.(),V=null};S?.addEventListener("abort",te,{once:!0});try{p({k:"open",id:L,verb:k,arg:x});for(;;){while(U.length>0)yield U.shift();if($!==void 0){if($)throw $;return}await new Promise((ee)=>{V=ee})}}finally{i.delete(L),S?.removeEventListener("abort",te)}},fail(k){if(u)return;u=k;for(let[x,S]of A)A.delete(x),S.reject(k);for(let[x,S]of i)i.delete(x),S.end(k);for(let x of s.values())x.abort();s.clear(),e.socket.close()},get isClosed(){return u!==null}}}var k7a=262144,tdr=0,D7a=()=>`${Date.now().toString(36)}-${(tdr++).toString(36)}`;var Fvn=xt(()=>{qs();xvn()});import{mkdirSync as ndr,rmSync as vvn}from"fs";import{dirname as adr}from"path";function Adr(e){let n=[],A=0;function i(){while(n.length>0){let p=n[0],d=e.write(p);if(d<p.byteLength){n[0]=p.subarray(d),A-=d;return}n.shift(),A-=p.byteLength}}let s=[];function u(){for(let p=s.length-1;p>=0;p--)if(A<=s[p].below)s.splice(p,1)[0].resolve()}return{write(p){if(n.length>0)return n.push(p),A+=p.byteLength,i(),p.byteLength;let d=e.write(p);if(d<p.byteLength)n.push(p.subarray(d)),A+=p.byteLength-d;return p.byteLength},drain(){i(),u()},get pending(){return A},whenDrained(p){if(A<=p)return Promise.resolve();return new Promise((d)=>{s.push({below:p,resolve:d})})},release(){for(let p of s.splice(0))p.resolve()},close(){this.release(),e.end()}}}async function i8t(e){let n=[];function A(u,p){return ndr(adr(u),{recursive:!0}),vvn(u,{force:!0}),new Promise((d,b)=>{let E=null,y=null;try{let k=Bun.listen({unix:u,socket:{open(x){y=Adr(x),E=A8t({socket:{write:(S)=>y.write(S),get pending(){return y.pending},whenDrained:(S)=>y.whenDrained(S),close:()=>y.close()},handlers:p,onError:e.onError}),d(E)},data(x,S){E?.receive(S)},drain(){y?.drain()},close(){E?.fail(Pn("LINK_PEER_CLOSED"))},error(x,S){E?.fail(S)}}});n.push(k)}catch(k){b(k)}})}let[i,s]=await Promise.all([A(e.paths.control,e.control),A(e.paths.data,e.data)]);return{control:i,data:s,close(){i.fail(Pn("LINK_CLOSED")),s.fail(Pn("LINK_CLOSED"));for(let u of n)u.stop();vvn(e.paths.control,{force:!0}),vvn(e.paths.data,{force:!0})}}}var r8t=xt(()=>{qs();Fvn()});function Svn(e){let{channels:n}=e;return{stimulus(A){return n.control.call(t$.stimulus,A)},update(A){return n.control.call(t$.update,A)},interrupt(A){n.control.send(t$.interrupt,A)},shutdown(){return n.control.call(t$.shutdown,null)},request(A){return n.control.call(t$.request,A)},run(A){return n.control.call(t$.run,A)},prompts(A){return n.control.call(t$.prompts,A)},close(){n.close()}}}function Nvn(e){return{control:{async call(n,A){if(n!==t$.escalate)throw Pn("LINK_NO_HANDLER",{detail:n,context:{verb:n}});if(!e.escalate)return{allow:!1};return e.escalate(A)}},data:{send(n,A){if(n!==t$.commit)throw Pn("LINK_NO_HANDLER",{detail:n,context:{verb:n}});let{type:i,data:s}=A;e.commit(i,s)},stream(n,A,i){if(n!==t$.infer)throw Pn("LINK_NO_HANDLER",{detail:n,context:{verb:n}});return e.infer(A,i)}}}}var t$;var o8t=xt(()=>{qs();t$={stimulus:"stimulus",update:"update",interrupt:"interrupt",shutdown:"shutdown",request:"request",run:"run",prompts:"prompts",infer:"infer",commit:"commit",escalate:"escalate"}});var Gvn=xt(()=>{qs();o8t()});var Mvn=xt(()=>{qs()});function qvn(e){return JSON.stringify(e)}var Lvn="AXON_AGENT_LINK";var s8t=xt(()=>{qs()});import{mkdirSync as idr,rmSync as x7a}from"fs";import{homedir as rdr}from"os";import{join as Tvn}from"path";function Uvn(e){return Tvn(rdr(),".axon","cache","link",e)}function F7a(e){let n=Uvn(e);return{control:Tvn(n,"control.sock"),data:Tvn(n,"data.sock")}}function Rvn(e){let n=Uvn(e.sessionId),A=F7a(e.sessionId);x7a(n,{recursive:!0,force:!0}),idr(n,{recursive:!0,mode:448});let i={[Lvn]:qvn(A)},u=i8t({paths:A,...Nvn(e.services),onError:e.onError}).then((p)=>({channels:p,paths:A,root:n,env:i,link:Svn({channels:p,services:e.services,onError:e.onError}),dispose(){p.close(),x7a(n,{recursive:!0,force:!0})}}));return{paths:A,root:n,env:i,connected:u}}var Kvn=xt(()=>{r8t();o8t();s8t()});function v7a(e){function n(){let A=["--unshare-pid","--unshare-ipc","--unshare-uts","--die-with-parent","--new-session","--proc","/proc","--dev","/dev","--tmpfs","/tmp"];if(e.tier==="hardened"&&e.uid!==null&&e.gid!==null)A.push("--unshare-user","--uid",String(e.uid),"--gid",String(e.gid));if(e.network.length===0)A.push("--unshare-net");for(let i of odr)A.push("--ro-bind-try",i,i);for(let i of e.runtime)A.push("--ro-bind",i,i);for(let i of e.fs.read)A.push("--ro-bind",i,i);for(let i of e.fs.write)A.push("--bind",i,i);for(let i of e.control)A.push("--bind",i,i);if(e.bindCwd)A.push("--bind",e.cwd,e.cwd);return A.push("--chdir",e.workdir),A.push("--setenv","HOME","/tmp"),A.push("--setenv","PATH","/usr/bin:/bin:/usr/sbin:/sbin"),A}return{args:n,wrap(A){return["bwrap",...n(),"--",...A]}}}var odr;var S7a=xt(()=>{odr=["/usr","/bin","/sbin","/lib","/lib64","/etc/ssl","/etc/resolv.conf"]});function N7a(e){let{tier:n,limits:A}=e;function i(){let s=["systemd-run"];if(n==="auto")s.push("--user");if(s.push("--scope","--quiet","--collect"),A.memory!==null)s.push("-p",`MemoryMax=${A.memory}`);if(A.cpu!==null)s.push("-p",`CPUQuota=${A.cpu}`);if(A.pids!==null)s.push("-p",`TasksMax=${A.pids}`);return s}return{args:i,wrap(s){return[...i(),...s]}}}import{spawnSync as G7a}from"child_process";import{existsSync as sdr}from"fs";function jvn(e){let n=e.find((A)=>sdr(A));if(n)return n;throw Error(`CONFINE_ENTRYPOINT_MISSING: none of [${e.join(", ")}] exists`)}function Yvn(e,n){return G7a(e,[n],{stdio:"ignore"}).status===0}function cdr(e){return G7a("id",[e],{stdio:"ignore"}).status===0}function H6e(e=GIe){let n=process.platform==="linux";if(!n)return{isLinux:!1,bwrap:!1,systemd:!1,nft:!1,userExists:!1,auto:!1,hardened:!1};let A=Yvn("bwrap","--version"),i=Yvn("systemd-run","--version"),s=Yvn("nft","--version"),u=cdr(e),p=A&&i;return{isLinux:n,bwrap:A,systemd:i,nft:s,userExists:u,auto:p,hardened:p&&s&&u}}function aBt(e,n=H6e()){return e==="auto"?n.auto:n.hardened}var GIe="axon-agent";var c8t=()=>{};import{isAbsolute as udr,resolve as ldr}from"path";function M7a(e){let{policy:n}=e,A=(d)=>udr(d)?d:ldr(e.cwd,d),i=(n.fs?.read??[]).map(A),s=(n.fs?.write??[]).map(A),u=i.length>0||s.length>0,p=u?s[0]??i[0]:e.cwd;return{tier:e.tier,user:e.user??null,uid:e.uid??null,gid:e.gid??null,workdir:p,bindCwd:!u,cwd:e.cwd,entrypoint:e.entrypoint,runtime:e.runtime,fs:{read:i,write:s},control:e.control??[],network:Object.keys(n.network??{}),limits:{memory:n.limits?.memory??null,cpu:n.limits?.cpu??null,pids:n.limits?.pids??null}}}var L7a=()=>{};import{spawnSync as U7a}from"child_process";import{existsSync as gdr}from"fs";import{dirname as q7a,join as pdr}from"path";function Hvn(e){let{tier:n,cwd:A,policy:i,entrypoint:s}=e;return{async build(){let u=H6e(GIe);if(!aBt(n,u))throw Pn("CAPSULE_CONFINE_UNAVAILABLE",{context:{tier:n,...u}});let p=null;if(n==="hardened"){if(p=fdr(GIe),!p)throw Pn("CAPSULE_CONFINE_USER_UNRESOLVED",{context:{user:GIe}})}let d=mdr(),b=ddr(d,s),E=M7a({policy:i,tier:n,cwd:A,entrypoint:s,...e.control?{control:e.control}:{},runtime:[...b,...e.project??[]],user:n==="hardened"?GIe:null,uid:p?.uid??null,gid:p?.gid??null}),y=v7a(E),k=N7a(E),x=[d,"run",s],S=k.wrap(y.wrap(x));return{spawnCommand:{command:S[0],args:S.slice(1)},cleanup:async()=>{}}}}}function mdr(){let e=U7a("which",["bun"],{encoding:"utf8"});return(e.status===0?e.stdout.trim():"")||process.execPath}function ddr(e,n){let A=new Set([e]),i=q7a(n),s=i;while(!0){if(gdr(pdr(i,"package.json"))){s=i;break}let u=q7a(i);if(u===i)break;i=u}return A.add(s),[...A]}function fdr(e){let n=T7a(["-u",e]),A=T7a(["-g",e]);if(n===null||A===null)return null;return{uid:n,gid:A}}function T7a(e){let n=U7a("id",e,{encoding:"utf8"});if(n.status!==0)return null;let A=Number.parseInt(n.stdout.trim(),10);return Number.isInteger(A)?A:null}var R7a=xt(()=>{qs();S7a();c8t();L7a()});var K7a=xt(()=>{qs();c8t()});var Y7a=xt(()=>{R7a();c8t();K7a()});var Pvn="AXON_AGENT_BLUEPRINT";var Jvn=xt(async()=>{qs();KKe();r8t();Gvn();Mvn();s8t()});import{writeFileSync as Edr}from"fs";import{dirname as ydr,join as Ovn}from"path";async function $vn(e){let n=e.policy.isolation??"none",A=Rvn({sessionId:e.sessionId,services:{...e.services,commit(S,L){if(S==="axon:boot:failed"){let U=L?.error;y.reject(Pn("AGENT_BOOT_FAILED",{detail:U?.message??"the agent failed to boot",context:{sessionId:e.sessionId}}))}e.services.commit(S,L)}},onError:e.onError}),i=Ovn(A.root,"blueprint.json");Edr(i,JSON.stringify(e.blueprint),{mode:384});let s={...A.env,[Pvn]:i},u=(n==="auto"||n==="hardened")&&process.platform==="linux",p=[process.execPath,"run",e.entrypoint],d=null;if(u){let S=H6e();if(!aBt(n,S))throw A.connected.catch(()=>{}),Error(`CAPSULE_CONFINE_UNAVAILABLE: tier "${n}" needs primitives this host lacks (${JSON.stringify(S)})`);let L=await Hvn({tier:n,cwd:e.blueprint.paths.root,policy:e.policy,entrypoint:e.entrypoint,control:[A.root],project:[e.blueprint.paths.root,ydr(e.entrypoint)]}).build();p=[L.spawnCommand.command,...L.spawnCommand.args],d=L.cleanup}let b=Bun.spawn(p,{env:{...process.env,...s},stdout:"pipe",stderr:"pipe"}),E=()=>{try{b.kill()}catch{}};process.on("exit",E);let y=(()=>{let S,L=new Promise((U,$)=>{S=$});return L.catch(()=>{}),{promise:L,reject:S}})(),k=[];(async()=>{for await(let S of b.stderr)k.push(new TextDecoder().decode(S))})().catch(()=>{});let x=await Promise.race([A.connected.then(async(S)=>{return await Promise.race([y.promise,new Promise((L)=>setTimeout(L,Qdr))]),S}),y.promise,b.exited.then(async(S)=>{throw await Promise.race([y.promise,new Promise((L)=>setTimeout(L,150))]),Pn("AGENT_BOOT_FAILED",{detail:k.join("").trim()||`the agent process exited with code ${S} before connecting`,context:{code:S,tier:n}})})]);return{...x,process:b,tier:u?n:n==="container"?"container":"none",dispose(){process.removeListener("exit",E),b.kill(),x.dispose(),d?.()}}}function Wvn(e){return jvn(e)}var Qdr=250,zvn;var H7a=xt(async()=>{qs();Y7a();Kvn();await Jvn();zvn=[Ovn(import.meta.dir,"agent-main.js"),Ovn(import.meta.dir,"agent-main.ts")]});var Zvn=xt(async()=>{Fvn();xvn();r8t();o8t();Gvn();Mvn();s8t();Kvn();await Qk([H7a(),Jvn()])});async function P7a(e){let n=DKe(),A=await LCt({blueprint:{...e.blueprint,session:{id:e.sessionId}},bus:n}),i=await HCt({blueprint:e.blueprint,cloud:e.cloud,session:A});return{session:A,bus:n,async*infer(s,u){let p=i?.get(s.role);if(!p)throw Pn("ENGINE_ROLE_UNBOUND_LINK",{detail:`no engine bound to "${s.role}"`,context:{role:s.role}});let d=p.driver;if(d.kind!==void 0&&d.kind!=="generate")throw Pn("ENGINE_KIND_MISMATCH_LINK",{detail:`role "${s.role}" is bound to a ${d.kind} driver`,context:{role:s.role,kind:d.kind}});for await(let b of d.stream({...s.request,signal:u})){if(u.aborted)break;yield b}},async close(){await A.end()}}}var J7a=xt(()=>{qs();qCt();KKe();KKe()});function O7a(e){let n=new Map,A=new Set,i=new Set,s=null,u=new Map,p=0;function d(V){s=V,u.set(V,++p)}async function b(V){if(typeof V!=="string")return V;let te=await e.resolve.one(V);return e.projects.open(te.root)}async function E(V,te={}){if(te?.session&&n.has(te.session))throw Pn("SESSION_ALREADY_RUNNING",{context:{sessionId:te.session}});let ee=te.parentSessionId?n.get(te.parentSessionId):void 0;if(te.parentSessionId&&!ee)throw Pn("PARENT_INSTANCE_NOT_RUNNING",{context:{sessionId:te.parentSessionId}});let me=await b(V),be=e.control?.()??null,ce=await K6e({project:me,confined:async({blueprint:Ze,sessionId:nt,rescan:je})=>{let Xe=[];function gt(Ra,Un){let Ja=Un&&typeof Un==="object"?Object.entries(Un).sort(([GA],[bn])=>GA.localeCompare(bn)).map(([GA,bn])=>`${GA}=${JSON.stringify(bn)}`).join("&"):JSON.stringify(Un);return`${Ra}:${Ja}`}function Oe(Ra){let Un=Ra;if(!Un?.type||!qMe(Un.type))return;Xe.push(gt(Un.type,Un.data)),Ct.commitEntry(Un.type,Un.data)}function _t(Ra,Un){let Ja=Xe.indexOf(gt(Ra,Un));if(Ja===-1)return!1;return Xe.splice(Ja,1),!0}let tn=await P7a({blueprint:Ze,cloud:e.cloud,sessionId:nt}),Ct=tn.session,Kn=Z1t({blueprint:Ze,tools:(Ze.tools??[]).map((Ra)=>Ra.name)}),ma=await $vn({sessionId:nt,blueprint:Ze,policy:Kn.policy,entrypoint:Wvn(zvn),services:{infer:(Ra,Un)=>tn.infer(Ra,Un),commit:(Ra,Un)=>{if(qMe(Ra)){if(_t(Ra,Un))return;Ct.commitEntry(Ra,Un);return}Ct.commit(Ra,Un)},...e.escalations?{escalate:async(Ra)=>({allow:await e.escalations.decide({agent:me.name,sessionId:nt},Ra)})}:{}},onError:(Ra)=>{Ct.commit("axon:log:error",{message:Ra.message})}}),Tt={...ma.link,stimulus(Ra){return Oe(Ra),ma.link.stimulus(Ra)},request(Ra){return Oe(Ra),ma.link.request(Ra)}},na=Ze;return{kind:"linked",sessionId:nt,link:Tt,session:Ct,bus:tn.bus,get blueprint(){return na},tier:ma.tier,pid:ma.process.pid,reload:async()=>{let Ra=await je();await ma.link.update(Ra),na=Ra},shutdown:async()=>{await ma.link.shutdown().catch(()=>{}),ma.dispose(),await tn.close()}}},cloud:e.cloud,store:e.store,cwd:e.cwd,host:e.host,...e.escalations?{escalate:(Ze)=>e.escalations.decide({agent:me.name,sessionId:ce.sessionId},Ze)}:{},parentSessionId:ee?.sessionId??null,...ee?{rootSessionId:ee.rootSessionId}:{},depth:ee?ee.depth+1:0,...te?.session?{session:te.session}:{},...te?.onProgress?{onProgress:te.onProgress}:{},...te?.onTiming?{onTiming:te.onTiming}:{},...be?{control:be}:{}}),ke=ce.sessionId,Te={sessionId:ke,parentSessionId:ee?.sessionId??null,rootSessionId:ee?.rootSessionId??ke,depth:ee?ee.depth+1:0,source:ce.kind==="linked"?{kind:"linked",project:me,agent:ce}:{kind:"local",project:me,agent:ce}};if(n.set(Te.sessionId,Te),te.focus!==!1)d(Te.sessionId);for(let Ze of A)Ze(Te);return Te}async function y(V){let te=x(V.url),ee=[...n.values()].find((nt)=>nt.source.kind==="remote"&&x(nt.source.target.url)===te);if(ee)return d(ee.sessionId),ee;let{axon:me,sessionId:be,agent:ce,loaded:ke,engine:Te}=await e.cloud.attach(te,{...V.agentId?{agentId:V.agentId}:{}}),Ze={sessionId:be,parentSessionId:null,rootSessionId:be,depth:0,source:{kind:"remote",target:{...V,url:te,name:V.name||ce||te,loaded:ke,engine:Te},agent:me}};n.set(be,Ze),d(be);for(let nt of A)nt(Ze);return Ze}async function k(V){let te=S(V);await Promise.allSettled(te.map((me)=>k(me.sessionId)));let ee=n.get(V);if(!ee)return;n.delete(V),u.delete(V);for(let me of i)me(V);if(s===V)s=L()[0]?.sessionId??null;if(ee.source.kind==="local")await ee.source.agent.shutdown()}function x(V){let te=V.trim().replace(/\/+$/,"");try{let ee=new URL(te),me=ee.pathname.replace(/\/+$/,"");return`${ee.protocol.toLowerCase()}//${ee.host.toLowerCase()}${me}`}catch{return te}}function S(V){return[...n.values()].filter((te)=>te.parentSessionId===V)}function L(){return[...n.values()].sort((V,te)=>(u.get(te.sessionId)??0)-(u.get(V.sessionId)??0))}function U(V){return[...n.values()].filter((te)=>te.rootSessionId===V&&te.sessionId!==V)}function $(){return s?n.get(s)??null:null}return{resolve:b,spawn:E,attach:y,stop:k,children:S,descendants:U,focused:$,list(){return[...n.values()]},recent:L,get(V){return n.get(V)??null},has(V){return n.has(V)},focus(V){if(!n.has(V))throw Pn("SESSION_NOT_RUNNING",{context:{sessionId:V}});d(V)},async shutdown(){await Promise.allSettled([...n.keys()].map((V)=>k(V)))},onSpawn(V){return A.add(V),()=>A.delete(V)},onStop(V){return i.add(V),()=>i.delete(V)}}}var Vvn=xt(async()=>{qs();a8t();J7a();r_();await Zvn()});import{existsSync as _dr}from"fs";import{isAbsolute as wdr,join as $7a,resolve as kdr}from"path";import{homedir as Ddr}from"os";function xdr(e){return e.startsWith("@")}function Fdr(e){return e.startsWith(".")||e.startsWith("~")||wdr(e)||e.includes("/")}function vdr(e){return e.startsWith("~")?$7a(Ddr(),e.slice(1)):e}function Xvn(e){return _dr($7a(e,"axon.config.ts"))}function ABt(e){let{store:n}=e;function A(){let s=n.profiles.active();if(!s)throw Pn("NOT_AUTHENTICATED");return s.agents}function i(s){let u=A().path(s);return Xvn(u)?u:null}return{async one(s){if(xdr(s)){let p=s.slice(1).split("@")[0]??"",d=i(p.includes("/")?p.split("/")[1]??p:p);if(d)return{root:d,kind:"registry",ref:s,installed:!1};let b=await e.clone(s,A().root);if(!Xvn(b.root))throw Pn("PROJECT_NOT_FOUND",{context:{ref:s,path:b.root}});return{root:b.root,kind:"registry",ref:s,installed:!0}}if(Fdr(s)){let p=kdr(e.cwd,vdr(s));if(!Xvn(p))throw Pn("PROJECT_NOT_FOUND",{context:{ref:s,path:p}});return{root:p,kind:"path",ref:s,installed:!1}}let u=i(s);if(!u)throw Pn("PROJECT_NOT_FOUND",{context:{ref:s,path:A().path(s),searched:A().extraRoots()}});return{root:u,kind:"name",ref:s,installed:!1}},async all(s){let u=Object.keys(s),p=await Promise.all(u.map((d)=>this.one(s[d])));return Object.fromEntries(u.map((d,b)=>[d,p[b]]))}}}var u8t=xt(()=>{qs()});import{randomUUID as Sdr}from"crypto";import{existsSync as Ndr}from"fs";import{resolve as Gdr}from"path";function Mdr(e){let n={get axon(){return e.current.axon},get sessionId(){return e.current.blueprint.session.id},get blueprint(){return e.current.blueprint},reload:e.reload,serve:e.serve,shutdown:e.shutdown};return new Proxy(n,{get(A,i,s){if(Reflect.has(A,i))return Reflect.get(A,i,s);let u=e.current.axon,p=u[i];return typeof p==="function"?p.bind(u):p},has(A,i){return Reflect.has(A,i)||i in e.current.axon},ownKeys(A){return[...new Set([...Reflect.ownKeys(A),...Reflect.ownKeys(e.current.axon)])]},getOwnPropertyDescriptor(A,i){if(Reflect.has(A,i))return Reflect.getOwnPropertyDescriptor(A,i);let s=Reflect.getOwnPropertyDescriptor(e.current.axon,i);return s?{...s,configurable:!0}:void 0}})}function eSn(e){let n=ABt({store:e.store,clone:e.clone,cwd:e.cwd}),A=[];async function i(d){let b=await e.projects.open(d),E=await K6e({project:b,cwd:e.cwd,cloud:e.cloud,store:e.store,watch:!1,...e.host?{host:e.host}:{}});if(A.push(E),E.kind!=="process")throw Pn("SCRIPT_AGENT_NOT_LOCAL",{detail:"a script's agent must run in this process \u2014 Scripts() booted a linked one",context:{root:d}});return Mdr(E)}async function s(d){if(d===void 0){let E=e.projects.find(e.cwd);if(!E)throw Pn("PROJECT_NOT_FOUND",{context:{path:e.cwd}});return i(E)}let b=await n.one(d);return i(b.root)}async function u(d){let b=await n.all(d),E=Object.keys(d),y=await Promise.all(E.map((k)=>i(b[k].root)));return Object.fromEntries(E.map((k,x)=>[k,y[x]]))}async function p(){let d=[];for(let b of[...A].reverse())try{await b.shutdown()}catch(E){d.push(E)}if(A.length=0,d.length>0)throw Pn(AggregateError(d,"one or more agents failed to shut down"))}return{Axon:s,Fleet:u,async exec(d){let b=Gdr(e.cwd,d);if(!Ndr(b))throw Pn("SCRIPT_FILE_NOT_FOUND",{context:{path:b}});let E=z7a.then(async()=>{let y=globalThis,k={Axon:y.Axon,Fleet:y.Fleet};y.Axon=s,y.Fleet=u;try{await import(`${b}?run=${Sdr()}`)}finally{y.Axon=k.Axon,y.Fleet=k.Fleet,await p()}});return z7a=E.catch(()=>{}),E},shutdown:p}}var z7a;var tSn=xt(()=>{qs();a8t();u8t();z7a=Promise.resolve()});function W7a(e){let n=e.instances;function A(){let p=Error("agent request aborted");return p.name="AbortError",p}function i(p){if(!p||typeof p!=="object")throw Pn("SUBAGENT_REQUEST_INVALID",{detail:"expected { prompt }"});let d=p.prompt;if(typeof d!=="string"&&!(Array.isArray(d)&&d.every((b)=>typeof b==="string")))throw Pn("SUBAGENT_REQUEST_INVALID",{detail:"prompt must be a string or string[]"});return{prompt:d}}function s(p){let d=n.get(p);if(!d)throw Pn("PARENT_INSTANCE_NOT_RUNNING",{context:{sessionId:p}});if(d.depth>=nSn)throw Pn("SUBAGENT_DEPTH_EXCEEDED",{detail:`maximum depth is ${nSn}`,context:{sessionId:d.sessionId,depth:d.depth,limit:nSn}});if(n.children(d.sessionId).length>=aSn)throw Pn("SUBAGENT_CHILD_LIMIT_EXCEEDED",{detail:`maximum live children is ${aSn}`,context:{sessionId:d.sessionId,limit:aSn}});if(n.descendants(d.rootSessionId).length>=ASn)throw Pn("SUBAGENT_DESCENDANT_LIMIT_EXCEEDED",{detail:`maximum live descendants is ${ASn}`,context:{rootSessionId:d.rootSessionId,limit:ASn}});return d}async function u(p){let d=s(p.parentSessionId);if(p.signal.aborted)throw A();let b=i(p.input);if(d.source.kind!=="local")throw Pn("SUBAGENT_REMOTE_PARENT",{context:{sessionId:d.sessionId}});let E=await n.spawn(d.source.project,{parentSessionId:d.sessionId,focus:!1});if(E.source.kind!=="local")throw Pn("INSTANCE_NOT_LOCAL",{detail:"spawn() must produce a local instance",context:{sessionId:E.sessionId,kind:E.source.kind}});let y=E.source.agent,k=y.kind==="process"?()=>y.current.kernel.interrupt("user"):()=>y.link.interrupt("user");p.signal.addEventListener("abort",k,{once:!0});try{let x=y.kind==="process"?await y.current.axon.request(b):await Promise.reject(Pn("SUBAGENT_LINK_UNSUPPORTED",{detail:"a confined agent cannot yet serve a subagent request \u2014 the supervisor needs a verb that collects a wake's entries",context:{sessionId:E.sessionId}}));if(p.signal.aborted)throw A();return x}finally{p.signal.removeEventListener("abort",k),await n.stop(E.sessionId)}}return{request:u,async call(p){if(p.method!=="request")throw Pn("HOST_METHOD_UNKNOWN",{context:{method:p.method}});return u({parentSessionId:p.callerSessionId,input:p.input,signal:p.signal})}}}var nSn=4,aSn=4,ASn=12;var Z7a=xt(()=>{qs()});function iSn(e){let n=null;return{handle(A){return n=A,()=>{if(n===A)n=null}},get attached(){return n!==null},async decide(A,i){let s=e.store.profiles.active(),u=Ldr(i);if(!s)return!1;let p=s.grants.covers(A.agent,i.fn,u);if(p){let b=s.requests.raise({agent:A.agent,sessionId:A.sessionId,fn:i.fn,subject:u});return s.requests.settle(b.id,{decision:"allow",by:"grant",at:Date.now(),grantId:p.id}),!0}let d=s.requests.raise({agent:A.agent,sessionId:A.sessionId,fn:i.fn,subject:u});if(!n)return s.requests.settle(d.id,{decision:"deny",by:"expired",at:Date.now()}),!1;try{let b=await n({id:d.id,agent:A.agent,sessionId:A.sessionId,fn:i.fn,subject:u});return s.requests.settle(d.id,{decision:b?"allow":"deny",by:"user",at:Date.now()}),b}catch{return s.requests.settle(d.id,{decision:"deny",by:"expired",at:Date.now()}),!1}}}}function Ldr(e){let n=e.args[0];return typeof n==="string"&&n.length>0?n:e.fn}import{closeSync as X7a,openSync as e5a,readSync as t5a}from"fs";function n5a(e){let n=e5a(e,"r"),A=Buffer.allocUnsafe(8192);try{let i=t5a(n,A,0,A.length,0);if(i===0)return l8t;let s=A.toString("utf-8",0,i),u=s.indexOf(`
|
|
4969
|
+
`+i.slice(d);return await Qbe(A,_be(y,A)),{changed:!0}}async function mvn(e,n){let A=kbe(e);if(!Or.exists(A))return{changed:!1};let i=await wbe(A,"utf-8"),s=PKe(A,i,"providers");if(!s)return{changed:!1};let u=s.array.elements.find((x)=>lvn(x)===n);if(!u)return{changed:!1};if(Pmr(u))return{changed:!1};let p=u.getStart(s.source),d=u.getEnd(),b=i.slice(d).match(/^\s*,/),E=d+(b?b[0].length:0),y=i.slice(0,p).match(/\s*$/),k=p-(y?y[0].length:0);return await Qbe(A,_be(i.slice(0,k)+i.slice(E),A)),{changed:!0}}var eB,jmr="profile.config.ts";var dvn=xt(()=>{qs();ph();pCt();tBt();eB=fp(Jhe(),1)});import{pathToFileURL as Jmr}from"url";import{join as fvn}from"path";function hvn(){let e=null;return{open(){e=[]},close(){let n=e??[];return e=null,n},track(n){e?.push(n)}}}async function C7a(e){await import(`${Jmr(e).href}?t=${crypto.randomUUID()}`)}async function Omr(e){let n=fvn(e,"plugins");if(!Or.exists(n))return[];return(await Or.list(n)).filter((i)=>i.endsWith(".ts")).sort().map((i)=>fvn(n,i))}async function bvn(e){let{root:n,label:A,sink:i,mainError:s}=e;i.open();let u=[],p=fvn(n,"main.ts");if(Or.exists(p))try{await C7a(p),u.push({path:p,error:null})}catch(d){u.push({path:p,error:Pn(s,{detail:`${p} \u2014 ${d instanceof Error?d.message:String(d)}`,context:{path:p,source:A},cause:d})})}for(let d of await Omr(n))try{await C7a(d),u.push({path:d,error:null})}catch(b){u.push({path:d,error:Pn("PLUGIN_FAILED",{detail:`${d} \u2014 ${b instanceof Error?b.message:String(b)}`,context:{path:d,source:A},cause:b})})}return{root:n,label:A,files:u,disposers:i.close()}}function B7a(e){for(let n of[...e.disposers].reverse())try{n()}catch{}}var Cvn=xt(()=>{qs();ph()});import{mkdir as $mr,rename as zmr,rm as Bvn}from"fs/promises";import{dirname as Wmr,join as I7a}from"path";function Ivn(e){return Or.exists(I7a(e,"extension.config.ts"))}function Evn(e){let n=e.store??jKe(),A=hvn(),i=[],s=[];async function u(){s=await JKe(e.root())}async function p(y,k){let x=await XSt(y,k);return await u(),x}async function d(y,k){let x=await e8t(y,k);return await u(),x}let b=null;async function E(y){if(y.kind==="registry"&&!Ivn(y.root)){if(Or.exists(y.root))await Bvn(y.root,{recursive:!0,force:!0});if(!e.install)return Pn("EXTENSION_NOT_FOUND",{detail:`${y.source} is not installed`,context:{source:y.source,root:y.root}});try{await e.install(y.source,y.root)}catch(k){return Pn("EXTENSION_INSTALL_FAILED",{detail:`${y.source} \u2014 ${k instanceof Error?k.message:String(k)}`,context:{source:y.source,root:y.root},cause:k})}}if(!Or.exists(y.root))return Pn("EXTENSION_NOT_FOUND",{detail:`${y.source} \u2192 ${y.root}`,context:{source:y.source,root:y.root}});if(!Ivn(y.root))return Pn("EXTENSION_NOT_AN_EXTENSION",{detail:`${y.root} has no extension.config.ts`,context:{source:y.source,root:y.root}});return null}return{get sources(){return i},get declared(){return s},syncDeclared:u,list(){return JKe(e.root())},settings(){return t8t(e.root())},async setSetting(y,k){let x=e.root(),S=()=>uvn(x,y,k);return b?b(S):S()},readProviders(){return gvn(e.root())},async addProvider(y){let k=e.root(),x=()=>pvn(k,y);return b?b(x):x()},async removeProvider(y){let k=e.root(),x=()=>mvn(k,y);return b?b(x):x()},isLocalExtension(y){try{return Ivn(U6e(y,e.root(),n).root)}catch{return!1}},async install(y){let k=e.root();if(U6e(y,k,n).kind==="local"){let me=U6e(y,k,n),be=await E(me);if(be)throw be;let{changed:ce}=await p(k,y);return{root:me.root,declared:ce,ref:y}}let{name:x,version:S}=eL(y),L=S?n.resolve(y):null;if(L){let me=eBt(L.name,L.version),{changed:be}=await p(k,me);return{root:L.root,declared:be,ref:me}}if(!e.install)throw Pn("EXTENSION_NOT_FOUND",{detail:`${y} is not installed`,context:{source:y}});let U=I7a(n.root,".staging",crypto.randomUUID()),$;try{({version:$}=await e.install(y,U))}catch(me){throw await Bvn(U,{recursive:!0,force:!0}),Pn("EXTENSION_INSTALL_FAILED",{detail:`${y} \u2014 ${me instanceof Error?me.message:String(me)}`,context:{source:y},cause:me})}let V=n.pathFor(x,$);if(n.isUsable(V))await Bvn(U,{recursive:!0,force:!0});else await $mr(Wmr(V),{recursive:!0}),await zmr(U,V);let te=eBt(x,$),{changed:ee}=await p(k,te);return{root:V,declared:ee,ref:te}},async uninstall(y){let k=e.root(),x=await JKe(k),{name:S}=eL(y),L=x.find(($)=>eL($).name===S)??y,{changed:U}=await d(k,L);return{changed:U,removed:!1}},async updates(){if(!e.latest)return[];let y=e.root(),k=await JKe(y);return(await Promise.all(k.map(async(S)=>{if(U6e(S,y,n).kind==="local")return null;let{name:L,version:U}=eL(S);try{let $=await e.latest(L);return{source:S,name:L,current:U,latest:$,outdated:U!==null&&$!==U}}catch{return{source:S,name:L,current:U,latest:null,outdated:!1}}}))).filter((S)=>S!==null)},async update(y,k){let{root:x,ref:S}=await this.install(eBt(y,k));return{root:x,ref:S}},get disposers(){return A},async load(){let y=[],k=[],x=e.root();if(Or.exists(x))k.push(await bvn({root:x,label:"profile",sink:A,mainError:"PROFILE_MAIN_FAILED"}));let S=await R6e(x,n);if(S.error)y.push(S.error);s=S.entries.map((L)=>L.source);for(let L of S.entries){let U=await E(L);if(U){y.push(U);continue}k.push(await bvn({root:L.root,label:L.source,sink:A,mainError:"EXTENSION_LOAD_FAILED"}))}return i=k,{sources:k,errors:y}},unload(){for(let y of[...i].reverse())B7a(y);i=[]},async reload(){return this.unload(),this.load()},watch(y){let k=T6e({root:e.root(),ignore:["node_modules",".git",".axon","agents","store"],debounceMs:150}),x=400;b=($)=>k.during($,{selfReloads:!0});let S=!1,L=0,U=k.onChange(()=>{if(S||Date.now()<L)return;S=!0,(async()=>{try{await y()}finally{S=!1,L=Date.now()+400}})()});return k.start(),()=>{b=null,U(),k.stop()}}}}var E7a=xt(()=>{qs();ph();XCt();ivn();dvn();tBt();Cvn()});var n8t=xt(()=>{E7a();ivn();dvn();Cvn();tBt()});function Q7a(e,n){if(e===null)return!0;return y7a.indexOf(n)>y7a.indexOf(e)}function yvn(e){switch(e){case"build:modules:complete":return"modules";case"build:tree:complete":return"dependencies";case"build:cognet:complete":return"cognet";default:return null}}function Qvn(e){switch(e){case"build:prepare:start":case"build:framework:start":case"build:modules:start":case"build:typegen:start":return"preparing";case"build:tree:start":return"dependencies";case"build:cognet:start":return"compiling";default:return null}}var y7a;var _vn=xt(()=>{y7a=["preparing","dependencies","compiling","booting"]});import{randomUUID as Zmr}from"crypto";import{resolve as _7a}from"path";async function K6e(e){let{project:n}=e,A=bCt({root:n.root});async function i(){try{let nt=e.store.profiles.active();if(!nt)return;let je=await cvn(nt.root);return Object.keys(je).length>0?je:void 0}catch{return}}async function s(){try{let nt=e.store.profiles.active();if(!nt)return;let{providers:je}=await R6e(nt.root);return je?[...je]:void 0}catch{return}}let u=e.session??Zmr(),p=Jxn({root:Fh({root:n.root,kind:"agent"}).path("data"),sessionId:u,...e.onProgress||e.onTiming?{onEmit:E}:{}}),d=null;function b(nt){if(!Q7a(d,nt.stage))return;d=nt.stage,e.onProgress?.(nt)}function E(nt,je){let Xe=yvn(nt);if(Xe){let _t=je.durationMs;if(typeof _t==="number")e.onTiming?.({unit:Xe,durationMs:_t});return}let gt=Qvn(nt);if(!gt)return;let Oe=nt==="build:modules:start"?je.specifiers:void 0;b(Oe?.length?{stage:gt,total:Oe.length,detail:Oe[0]}:{stage:gt})}let y=new Set;function k(nt){return`${nt.domain}\x00${nt.error}`}function x(nt){p.emit("build:warning",{domain:nt.domain,message:nt.error,...nt.cause?{error:nt.cause}:{}})}function S(nt){let je=new Set;for(let Xe of nt){let gt=k(Xe);if(je.has(gt)||y.has(gt)){je.add(gt);continue}je.add(gt),x(Xe)}y.clear();for(let Xe of je)y.add(Xe)}async function L(){let nt=await NKe(p,"build:prepare",{root:n.root},()=>n.prepare({report:(gt,Oe)=>p.emit(gt,Oe)}),(gt)=>({warnings:gt.warnings.length})),{blueprint:je,warnings:Xe}=await NKe(p,"build:load",{root:n.root},async()=>A.load({profilePolicy:await i(),profileProviders:await s()}),(gt)=>({agent:gt.blueprint.agent?.name??"",tools:gt.blueprint.tools?.length??0,prompts:gt.blueprint.prompts?.length??0,modules:gt.blueprint.modules?.length??0,warnings:gt.warnings.length}));if(je.agent?.name)p.identify(je.agent.name);return S([...nt.warnings,...Xe]),await p.flush(),{...je,session:{id:u}}}if(e.confined)return await $(e.confined);let U=await V();async function $(nt){return NKe(p,"build",{root:n.root},async()=>{let je=await L(),Xe=await nt({blueprint:{...je,session:{id:u}},sessionId:u,rescan:()=>L().then((gt)=>({...gt,session:{id:u}}))});return p.handOver((gt,Oe)=>{Xe.session.commit(gt,Oe)}),e.store.running.start({pid:Xe.pid,sessionId:u,parentSessionId:e.parentSessionId??null,rootSessionId:e.rootSessionId??u,depth:e.depth??0,agentName:je.agent?.name??n.name,projectRoot:n.root,dataRoot:_7a(n.root,".agent/data"),...e.job?{job:e.job}:{},...e.control?{control:e.control}:{},startedAt:new Date().toISOString()}),Xe})}async function V(){return NKe(p,"build",{root:n.root},async()=>{let je={...await L(),session:{id:u}};if(e.onProgress)b({stage:"booting"});let Xe=await PSt({blueprint:je,cloud:e.cloud,cwd:e.cwd,...e.host?{host:e.host}:{},...e.escalate?{escalate:e.escalate}:{}});return p.handOver((gt,Oe)=>{Xe.session.commit(gt,Oe)}),Xe})}e.store.running.start({pid:process.pid,sessionId:U.blueprint.session.id,parentSessionId:e.parentSessionId??null,rootSessionId:e.rootSessionId??U.blueprint.session.id,depth:e.depth??0,agentName:U.blueprint.agent.name,projectRoot:n.root,dataRoot:_7a(U.blueprint.paths.root,U.blueprint.paths.data),...e.job?{job:e.job}:{},...e.control?{control:e.control}:{},startedAt:new Date().toISOString()});let te=e.watch??!0,ee=te?n.watcher.onChange(()=>{Ze().catch(()=>{})}):()=>{},me=te?A.cognet.compiledFrom:null,be=me?T6e({root:me}):null,ce=be?.onChange(()=>{Ze().catch(()=>{})}),ke=be?n.link(be):null,Te=null;async function Ze(){if(Te)return Te.then(()=>Ze());Te=U.session.scope(async()=>{let nt,je=Date.now();try{let Xe=await A.load({compile:!0,profilePolicy:await i(),profileProviders:await s()});nt=Xe.blueprint,S(Xe.warnings),await n.typegen(nt)}catch(Xe){let gt=Pn(Xe);if(gt.code==="AX-COGNET-014"){let Oe={domain:"cognet",error:"dependency tree is being rewritten \u2014 keeping the current blueprint, will reload when it settles"},_t=k(Oe);if(!y.has(_t))y.add(_t),x(Oe);return}throw await U.session.commit("axon:reload:start",{revision:0}),await U.session.commit("axon:reload:failed",{error:gt,durationMs:Date.now()-je}),gt}await U.update(nt,{mode:"replace"})});try{await Te}finally{Te=null}}if(te)await n.watcher.start();return await be?.start(),{kind:"process",get sessionId(){return U.blueprint.session.id},get current(){return U},reload:Ze,serve(nt,je=10){let Xe=(gt)=>U.server.handler(gt);for(let gt=nt;gt<nt+je;gt++)try{return Bun.serve({port:gt,fetch:Xe})}catch(Oe){if(Vmr(Oe)&><nt+je-1)continue;throw Oe}throw Pn("PORT_UNAVAILABLE",{detail:`no free port in range ${nt}\u2013${nt+je-1}`,context:{from:nt,to:nt+je-1}})},async shutdown(){if(e.store.running.stop(U.blueprint.session.id),ee(),ce?.(),ke?.(),te)n.watcher.stop();be?.stop(),await Te?.catch(()=>{}),await U.shutdown()}}}function Vmr(e){let n=e?.code,A=e instanceof Error?e.message:String(e);return n==="EADDRINUSE"||/address already in use|in use|EADDRINUSE/i.test(A)}var a8t=xt(()=>{KKe();qs();qCt();Cbe();n8t();_vn();e2();zSt()});function w7a(e){if(e.byteLength>j6e)throw Pn("LINK_FRAME_TOO_LARGE",{detail:`${e.byteLength} exceeds ${j6e}`,context:{bytes:e.byteLength,max:j6e}});let n=new Uint8Array(Y6e+e.byteLength);return new DataView(n.buffer).setUint32(0,e.byteLength,!1),n.set(e,Y6e),n}function wvn(){let e=new Uint8Array(0);function n(A){if(e.byteLength===0){e=new Uint8Array(A);return}let i=new Uint8Array(e.byteLength+A.byteLength);i.set(e,0),i.set(A,e.byteLength),e=i}return{push(A){n(A);let i=[];for(;;){if(e.byteLength<Y6e)break;let u=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0,!1);if(u>j6e)throw Pn("LINK_FRAME_TOO_LARGE",{detail:`declared ${u} exceeds ${j6e}`,context:{declared:u,max:j6e}});if(e.byteLength<Y6e+u)break;i.push(e.slice(Y6e,Y6e+u)),e=e.slice(Y6e+u)}return i},get pending(){return e.byteLength}}}function kvn(e){return w7a(Xmr.encode(JSON.stringify(e)))}function Dvn(e){return JSON.parse(edr.decode(e))}var j6e=67108864,Y6e=4,Xmr,edr;var xvn=xt(()=>{qs();Xmr=new TextEncoder,edr=new TextDecoder});function A8t(e){let n=wvn(),A=new Map,i=new Map,s=new Map,u=null;function p(k){if(u)throw u;e.socket.write(kvn(k))}function d(k){try{p(k)}catch(x){e.onError(x)}}async function b(k){let x=new AbortController;s.set(k.id,x);try{if(!e.handlers?.call)throw Pn("LINK_NO_HANDLER",{detail:`call ${k.verb}`,context:{verb:k.verb,kind:"call"}});let S=await e.handlers.call(k.verb,k.arg,x.signal);d({k:"reply",id:k.id,ok:!0,value:S})}catch(S){d({k:"reply",id:k.id,ok:!1,error:S.message})}finally{s.delete(k.id)}}async function E(k){let x=new AbortController;s.set(k.id,x);try{if(!e.handlers?.stream)throw Pn("LINK_NO_HANDLER",{detail:`stream ${k.verb}`,context:{verb:k.verb,kind:"stream"}});for await(let S of e.handlers.stream(k.verb,k.arg,x.signal)){if(x.signal.aborted)break;if(d({k:"chunk",id:k.id,value:S}),(e.socket.pending??0)>k7a&&e.socket.whenDrained)await e.socket.whenDrained(k7a)}d({k:"end",id:k.id,ok:!0})}catch(S){d({k:"end",id:k.id,ok:!1,error:S.message})}finally{s.delete(k.id)}}function y(k){switch(k.k){case"call":b(k);return;case"open":E(k);return;case"send":try{e.handlers?.send?.(k.verb,k.arg)}catch(x){e.onError(x)}return;case"reply":{let x=A.get(k.id);if(!x)return;A.delete(k.id),k.ok?x.resolve(k.value):x.reject(Error(k.error));return}case"chunk":i.get(k.id)?.push(k.value);return;case"end":{let x=i.get(k.id);if(!x)return;i.delete(k.id),x.end(k.ok?void 0:Error(k.error));return}case"abort":s.get(k.id)?.abort();return}}return{receive(k){let x;try{x=n.push(k)}catch(S){this.fail(S);return}for(let S of x)try{y(Dvn(S))}catch(L){e.onError(L)}},call(k,x,S){if(u)return Promise.reject(u);let L=D7a();return new Promise((U,$)=>{A.set(L,{resolve:U,reject:$}),S?.addEventListener("abort",()=>{if(!A.delete(L))return;d({k:"abort",id:L}),$(new DOMException("aborted","AbortError"))},{once:!0}),p({k:"call",id:L,verb:k,arg:x})})},send(k,x){p({k:"send",verb:k,arg:x})},async*stream(k,x,S){if(u)throw u;let L=D7a(),U=[],$,V=null;i.set(L,{push(ee){U.push(ee),V?.(),V=null},end(ee){$=ee??null,V?.(),V=null}});let te=()=>{d({k:"abort",id:L}),i.delete(L),$=new DOMException("aborted","AbortError"),V?.(),V=null};S?.addEventListener("abort",te,{once:!0});try{p({k:"open",id:L,verb:k,arg:x});for(;;){while(U.length>0)yield U.shift();if($!==void 0){if($)throw $;return}await new Promise((ee)=>{V=ee})}}finally{i.delete(L),S?.removeEventListener("abort",te)}},fail(k){if(u)return;u=k;for(let[x,S]of A)A.delete(x),S.reject(k);for(let[x,S]of i)i.delete(x),S.end(k);for(let x of s.values())x.abort();s.clear(),e.socket.close()},get isClosed(){return u!==null}}}var k7a=262144,tdr=0,D7a=()=>`${Date.now().toString(36)}-${(tdr++).toString(36)}`;var Fvn=xt(()=>{qs();xvn()});import{mkdirSync as ndr,rmSync as vvn}from"fs";import{dirname as adr}from"path";function Adr(e){let n=[],A=0;function i(){while(n.length>0){let p=n[0],d=e.write(p);if(d<p.byteLength){n[0]=p.subarray(d),A-=d;return}n.shift(),A-=p.byteLength}}let s=[];function u(){for(let p=s.length-1;p>=0;p--)if(A<=s[p].below)s.splice(p,1)[0].resolve()}return{write(p){if(n.length>0)return n.push(p),A+=p.byteLength,i(),p.byteLength;let d=e.write(p);if(d<p.byteLength)n.push(p.subarray(d)),A+=p.byteLength-d;return p.byteLength},drain(){i(),u()},get pending(){return A},whenDrained(p){if(A<=p)return Promise.resolve();return new Promise((d)=>{s.push({below:p,resolve:d})})},release(){for(let p of s.splice(0))p.resolve()},close(){this.release(),e.end()}}}async function i8t(e){let n=[];function A(u,p){return ndr(adr(u),{recursive:!0}),vvn(u,{force:!0}),new Promise((d,b)=>{let E=null,y=null;try{let k=Bun.listen({unix:u,socket:{open(x){y=Adr(x),E=A8t({socket:{write:(S)=>y.write(S),get pending(){return y.pending},whenDrained:(S)=>y.whenDrained(S),close:()=>y.close()},handlers:p,onError:e.onError}),d(E)},data(x,S){E?.receive(S)},drain(){y?.drain()},close(){E?.fail(Pn("LINK_PEER_CLOSED"))},error(x,S){E?.fail(S)}}});n.push(k)}catch(k){b(k)}})}let[i,s]=await Promise.all([A(e.paths.control,e.control),A(e.paths.data,e.data)]);return{control:i,data:s,close(){i.fail(Pn("LINK_CLOSED")),s.fail(Pn("LINK_CLOSED"));for(let u of n)u.stop();vvn(e.paths.control,{force:!0}),vvn(e.paths.data,{force:!0})}}}var r8t=xt(()=>{qs();Fvn()});function Svn(e){let{channels:n}=e;return{stimulus(A){return n.control.call(t$.stimulus,A)},update(A){return n.control.call(t$.update,A)},interrupt(A){n.control.send(t$.interrupt,A)},shutdown(){return n.control.call(t$.shutdown,null)},request(A){return n.control.call(t$.request,A)},run(A){return n.control.call(t$.run,A)},prompts(A){return n.control.call(t$.prompts,A)},close(){n.close()}}}function Nvn(e){return{control:{async call(n,A){if(n!==t$.escalate)throw Pn("LINK_NO_HANDLER",{detail:n,context:{verb:n}});if(!e.escalate)return{allow:!1};return e.escalate(A)}},data:{send(n,A){if(n!==t$.commit)throw Pn("LINK_NO_HANDLER",{detail:n,context:{verb:n}});let{type:i,data:s}=A;e.commit(i,s)},stream(n,A,i){if(n!==t$.infer)throw Pn("LINK_NO_HANDLER",{detail:n,context:{verb:n}});return e.infer(A,i)}}}}var t$;var o8t=xt(()=>{qs();t$={stimulus:"stimulus",update:"update",interrupt:"interrupt",shutdown:"shutdown",request:"request",run:"run",prompts:"prompts",infer:"infer",commit:"commit",escalate:"escalate"}});var Gvn=xt(()=>{qs();o8t()});var Mvn=xt(()=>{qs()});function qvn(e){return JSON.stringify(e)}var Lvn="AXON_AGENT_LINK";var s8t=xt(()=>{qs()});import{mkdirSync as idr,rmSync as x7a}from"fs";import{homedir as rdr}from"os";import{join as Tvn}from"path";function Uvn(e){return Tvn(rdr(),".axon","cache","link",e)}function F7a(e){let n=Uvn(e);return{control:Tvn(n,"control.sock"),data:Tvn(n,"data.sock")}}function Rvn(e){let n=Uvn(e.sessionId),A=F7a(e.sessionId);x7a(n,{recursive:!0,force:!0}),idr(n,{recursive:!0,mode:448});let i={[Lvn]:qvn(A)},u=i8t({paths:A,...Nvn(e.services),onError:e.onError}).then((p)=>({channels:p,paths:A,root:n,env:i,link:Svn({channels:p,services:e.services,onError:e.onError}),dispose(){p.close(),x7a(n,{recursive:!0,force:!0})}}));return{paths:A,root:n,env:i,connected:u}}var Kvn=xt(()=>{r8t();o8t();s8t()});function v7a(e){function n(){let A=["--unshare-pid","--unshare-ipc","--unshare-uts","--die-with-parent","--new-session","--proc","/proc","--dev","/dev","--tmpfs","/tmp"];if(e.tier==="hardened"&&e.uid!==null&&e.gid!==null)A.push("--unshare-user","--uid",String(e.uid),"--gid",String(e.gid));if(e.network.length===0)A.push("--unshare-net");for(let i of odr)A.push("--ro-bind-try",i,i);for(let i of e.runtime)A.push("--ro-bind",i,i);for(let i of e.fs.read)A.push("--ro-bind",i,i);for(let i of e.fs.write)A.push("--bind",i,i);for(let i of e.control)A.push("--bind",i,i);if(e.bindCwd)A.push("--bind",e.cwd,e.cwd);return A.push("--chdir",e.workdir),A.push("--setenv","HOME","/tmp"),A.push("--setenv","PATH","/usr/bin:/bin:/usr/sbin:/sbin"),A}return{args:n,wrap(A){return["bwrap",...n(),"--",...A]}}}var odr;var S7a=xt(()=>{odr=["/usr","/bin","/sbin","/lib","/lib64","/etc/ssl","/etc/resolv.conf"]});function N7a(e){let{tier:n,limits:A}=e;function i(){let s=["systemd-run"];if(n==="auto")s.push("--user");if(s.push("--scope","--quiet","--collect"),A.memory!==null)s.push("-p",`MemoryMax=${A.memory}`);if(A.cpu!==null)s.push("-p",`CPUQuota=${A.cpu}`);if(A.pids!==null)s.push("-p",`TasksMax=${A.pids}`);return s}return{args:i,wrap(s){return[...i(),...s]}}}import{spawnSync as G7a}from"child_process";import{existsSync as sdr}from"fs";function jvn(e){let n=e.find((A)=>sdr(A));if(n)return n;throw Error(`CONFINE_ENTRYPOINT_MISSING: none of [${e.join(", ")}] exists`)}function Yvn(e,n){return G7a(e,[n],{stdio:"ignore"}).status===0}function cdr(e){return G7a("id",[e],{stdio:"ignore"}).status===0}function H6e(e=GIe){let n=process.platform==="linux";if(!n)return{isLinux:!1,bwrap:!1,systemd:!1,nft:!1,userExists:!1,auto:!1,hardened:!1};let A=Yvn("bwrap","--version"),i=Yvn("systemd-run","--version"),s=Yvn("nft","--version"),u=cdr(e),p=A&&i;return{isLinux:n,bwrap:A,systemd:i,nft:s,userExists:u,auto:p,hardened:p&&s&&u}}function aBt(e,n=H6e()){return e==="auto"?n.auto:n.hardened}var GIe="axon-agent";var c8t=()=>{};import{isAbsolute as udr,resolve as ldr}from"path";function M7a(e){let{policy:n}=e,A=(d)=>udr(d)?d:ldr(e.cwd,d),i=(n.fs?.read??[]).map(A),s=(n.fs?.write??[]).map(A),u=i.length>0||s.length>0,p=u?s[0]??i[0]:e.cwd;return{tier:e.tier,user:e.user??null,uid:e.uid??null,gid:e.gid??null,workdir:p,bindCwd:!u,cwd:e.cwd,entrypoint:e.entrypoint,runtime:e.runtime,fs:{read:i,write:s},control:e.control??[],network:Object.keys(n.network??{}),limits:{memory:n.limits?.memory??null,cpu:n.limits?.cpu??null,pids:n.limits?.pids??null}}}var L7a=()=>{};import{spawnSync as U7a}from"child_process";import{existsSync as gdr}from"fs";import{dirname as q7a,join as pdr}from"path";function Hvn(e){let{tier:n,cwd:A,policy:i,entrypoint:s}=e;return{async build(){let u=H6e(GIe);if(!aBt(n,u))throw Pn("CAPSULE_CONFINE_UNAVAILABLE",{context:{tier:n,...u}});let p=null;if(n==="hardened"){if(p=fdr(GIe),!p)throw Pn("CAPSULE_CONFINE_USER_UNRESOLVED",{context:{user:GIe}})}let d=mdr(),b=ddr(d,s),E=M7a({policy:i,tier:n,cwd:A,entrypoint:s,...e.control?{control:e.control}:{},runtime:[...b,...e.project??[]],user:n==="hardened"?GIe:null,uid:p?.uid??null,gid:p?.gid??null}),y=v7a(E),k=N7a(E),x=[d,"run",s],S=k.wrap(y.wrap(x));return{spawnCommand:{command:S[0],args:S.slice(1)},cleanup:async()=>{}}}}}function mdr(){let e=U7a("which",["bun"],{encoding:"utf8"});return(e.status===0?e.stdout.trim():"")||process.execPath}function ddr(e,n){let A=new Set([e]),i=q7a(n),s=i;while(!0){if(gdr(pdr(i,"package.json"))){s=i;break}let u=q7a(i);if(u===i)break;i=u}return A.add(s),[...A]}function fdr(e){let n=T7a(["-u",e]),A=T7a(["-g",e]);if(n===null||A===null)return null;return{uid:n,gid:A}}function T7a(e){let n=U7a("id",e,{encoding:"utf8"});if(n.status!==0)return null;let A=Number.parseInt(n.stdout.trim(),10);return Number.isInteger(A)?A:null}var R7a=xt(()=>{qs();S7a();c8t();L7a()});var K7a=xt(()=>{qs();c8t()});var Y7a=xt(()=>{R7a();c8t();K7a()});var Pvn="AXON_AGENT_BLUEPRINT";var Jvn=xt(async()=>{qs();KKe();r8t();Gvn();Mvn();s8t()});import{writeFileSync as Edr}from"fs";import{dirname as ydr,join as Ovn}from"path";async function $vn(e){let n=e.policy.isolation??"none",A=Rvn({sessionId:e.sessionId,services:{...e.services,commit(S,L){if(S==="axon:boot:failed"){let U=L?.error;y.reject(Pn("AGENT_BOOT_FAILED",{detail:U?.message??"the agent failed to boot",context:{sessionId:e.sessionId}}))}e.services.commit(S,L)}},onError:e.onError}),i=Ovn(A.root,"blueprint.json");Edr(i,JSON.stringify(e.blueprint),{mode:384});let s={...A.env,[Pvn]:i},u=(n==="auto"||n==="hardened")&&process.platform==="linux",p=[process.execPath,"run",e.entrypoint],d=null;if(u){let S=H6e();if(!aBt(n,S))throw A.connected.catch(()=>{}),Error(`CAPSULE_CONFINE_UNAVAILABLE: tier "${n}" needs primitives this host lacks (${JSON.stringify(S)})`);let L=await Hvn({tier:n,cwd:e.blueprint.paths.root,policy:e.policy,entrypoint:e.entrypoint,control:[A.root],project:[e.blueprint.paths.root,ydr(e.entrypoint)]}).build();p=[L.spawnCommand.command,...L.spawnCommand.args],d=L.cleanup}let b=Bun.spawn(p,{env:{...process.env,...s},stdout:"pipe",stderr:"pipe"}),E=()=>{try{b.kill()}catch{}};process.on("exit",E);let y=(()=>{let S,L=new Promise((U,$)=>{S=$});return L.catch(()=>{}),{promise:L,reject:S}})(),k=[];(async()=>{for await(let S of b.stderr)k.push(new TextDecoder().decode(S))})().catch(()=>{});let x=await Promise.race([A.connected.then(async(S)=>{return await Promise.race([y.promise,new Promise((L)=>setTimeout(L,Qdr))]),S}),y.promise,b.exited.then(async(S)=>{throw await Promise.race([y.promise,new Promise((L)=>setTimeout(L,150))]),Pn("AGENT_BOOT_FAILED",{detail:k.join("").trim()||`the agent process exited with code ${S} before connecting`,context:{code:S,tier:n}})})]);return{...x,process:b,tier:u?n:n==="container"?"container":"none",dispose(){process.removeListener("exit",E),b.kill(),x.dispose(),d?.()}}}function Wvn(e){return jvn(e)}var Qdr=250,zvn;var H7a=xt(async()=>{qs();Y7a();Kvn();await Jvn();zvn=[Ovn(import.meta.dir,"agent-main.js"),Ovn(import.meta.dir,"agent-main.ts")]});var Zvn=xt(async()=>{Fvn();xvn();r8t();o8t();Gvn();Mvn();s8t();Kvn();await Qk([H7a(),Jvn()])});async function P7a(e){let n=DKe(),A=await LCt({blueprint:{...e.blueprint,session:{id:e.sessionId}},bus:n}),i=await HCt({blueprint:e.blueprint,cloud:e.cloud,session:A});return{session:A,bus:n,async*infer(s,u){let p=i?.get(s.role);if(!p)throw Pn("ENGINE_ROLE_UNBOUND_LINK",{detail:`no engine bound to "${s.role}"`,context:{role:s.role}});let d=p.driver;if(d.kind!==void 0&&d.kind!=="generate")throw Pn("ENGINE_KIND_MISMATCH_LINK",{detail:`role "${s.role}" is bound to a ${d.kind} driver`,context:{role:s.role,kind:d.kind}});for await(let b of d.stream({...s.request,signal:u})){if(u.aborted)break;yield b}},async close(){await A.end()}}}var J7a=xt(()=>{qs();qCt();KKe();KKe()});function O7a(e){let n=new Map,A=new Set,i=new Set,s=null,u=new Map,p=0;function d(V){s=V,u.set(V,++p)}async function b(V){if(typeof V!=="string")return V;let te=await e.resolve.one(V);return e.projects.open(te.root)}async function E(V,te={}){if(te?.session&&n.has(te.session))throw Pn("SESSION_ALREADY_RUNNING",{context:{sessionId:te.session}});let ee=te.parentSessionId?n.get(te.parentSessionId):void 0;if(te.parentSessionId&&!ee)throw Pn("PARENT_INSTANCE_NOT_RUNNING",{context:{sessionId:te.parentSessionId}});let me=await b(V),be=e.control?.()??null,ce=await K6e({project:me,confined:async({blueprint:Ze,sessionId:nt,rescan:je})=>{let Xe=[];function gt(Ra,Un){let Ja=Un&&typeof Un==="object"?Object.entries(Un).sort(([GA],[bn])=>GA.localeCompare(bn)).map(([GA,bn])=>`${GA}=${JSON.stringify(bn)}`).join("&"):JSON.stringify(Un);return`${Ra}:${Ja}`}function Oe(Ra){let Un=Ra;if(!Un?.type||!qMe(Un.type))return;Xe.push(gt(Un.type,Un.data)),Ct.commitEntry(Un.type,Un.data)}function _t(Ra,Un){let Ja=Xe.indexOf(gt(Ra,Un));if(Ja===-1)return!1;return Xe.splice(Ja,1),!0}let tn=await P7a({blueprint:Ze,cloud:e.cloud,sessionId:nt}),Ct=tn.session,Kn=Z1t({blueprint:Ze,tools:(Ze.tools??[]).map((Ra)=>Ra.name)}),ma=await $vn({sessionId:nt,blueprint:Ze,policy:Kn.policy,entrypoint:Wvn(zvn),services:{infer:(Ra,Un)=>tn.infer(Ra,Un),commit:(Ra,Un)=>{if(qMe(Ra)){if(_t(Ra,Un))return;Ct.commitEntry(Ra,Un);return}Ct.commit(Ra,Un)},...e.escalations?{escalate:async(Ra)=>({allow:await e.escalations.decide({agent:me.name,sessionId:nt},Ra)})}:{}},onError:(Ra)=>{Ct.commit("axon:log:error",{message:Ra.message})}}),Tt={...ma.link,stimulus(Ra){return Oe(Ra),ma.link.stimulus(Ra)},request(Ra){return Oe(Ra),ma.link.request(Ra)}},na=Ze;return{kind:"linked",sessionId:nt,link:Tt,session:Ct,bus:tn.bus,get blueprint(){return na},tier:ma.tier,pid:ma.process.pid,reload:async()=>{let Ra=await je();await ma.link.update(Ra),na=Ra},shutdown:async()=>{await ma.link.shutdown().catch(()=>{}),ma.dispose(),await tn.close()}}},cloud:e.cloud,store:e.store,cwd:e.cwd,host:e.host,...e.escalations?{escalate:(Ze)=>e.escalations.decide({agent:me.name,sessionId:ce.sessionId},Ze)}:{},parentSessionId:ee?.sessionId??null,...ee?{rootSessionId:ee.rootSessionId}:{},depth:ee?ee.depth+1:0,...te?.session?{session:te.session}:{},...te?.onProgress?{onProgress:te.onProgress}:{},...te?.onTiming?{onTiming:te.onTiming}:{},...be?{control:be}:{}}),ke=ce.sessionId,Te={sessionId:ke,parentSessionId:ee?.sessionId??null,rootSessionId:ee?.rootSessionId??ke,depth:ee?ee.depth+1:0,source:ce.kind==="linked"?{kind:"linked",project:me,agent:ce}:{kind:"local",project:me,agent:ce}};if(n.set(Te.sessionId,Te),te.focus!==!1)d(Te.sessionId);for(let Ze of A)Ze(Te);return Te}async function y(V){let te=x(V.url),ee=[...n.values()].find((nt)=>nt.source.kind==="remote"&&x(nt.source.target.url)===te);if(ee)return d(ee.sessionId),ee;let{axon:me,sessionId:be,agent:ce,loaded:ke,engine:Te}=await e.cloud.attach(te,{...V.agentId?{agentId:V.agentId}:{}}),Ze={sessionId:be,parentSessionId:null,rootSessionId:be,depth:0,source:{kind:"remote",target:{...V,url:te,name:V.name||ce||te,loaded:ke,engine:Te},agent:me}};n.set(be,Ze),d(be);for(let nt of A)nt(Ze);return Ze}async function k(V){let te=S(V);await Promise.allSettled(te.map((me)=>k(me.sessionId)));let ee=n.get(V);if(!ee)return;n.delete(V),u.delete(V);for(let me of i)me(V);if(s===V)s=L()[0]?.sessionId??null;if(ee.source.kind!=="remote")await ee.source.agent.shutdown()}function x(V){let te=V.trim().replace(/\/+$/,"");try{let ee=new URL(te),me=ee.pathname.replace(/\/+$/,"");return`${ee.protocol.toLowerCase()}//${ee.host.toLowerCase()}${me}`}catch{return te}}function S(V){return[...n.values()].filter((te)=>te.parentSessionId===V)}function L(){return[...n.values()].sort((V,te)=>(u.get(te.sessionId)??0)-(u.get(V.sessionId)??0))}function U(V){return[...n.values()].filter((te)=>te.rootSessionId===V&&te.sessionId!==V)}function $(){return s?n.get(s)??null:null}return{resolve:b,spawn:E,attach:y,stop:k,children:S,descendants:U,focused:$,list(){return[...n.values()]},recent:L,get(V){return n.get(V)??null},has(V){return n.has(V)},focus(V){if(!n.has(V))throw Pn("SESSION_NOT_RUNNING",{context:{sessionId:V}});d(V)},async shutdown(){await Promise.allSettled([...n.keys()].map((V)=>k(V)))},onSpawn(V){return A.add(V),()=>A.delete(V)},onStop(V){return i.add(V),()=>i.delete(V)}}}var Vvn=xt(async()=>{qs();a8t();J7a();r_();await Zvn()});import{existsSync as _dr}from"fs";import{isAbsolute as wdr,join as $7a,resolve as kdr}from"path";import{homedir as Ddr}from"os";function xdr(e){return e.startsWith("@")}function Fdr(e){return e.startsWith(".")||e.startsWith("~")||wdr(e)||e.includes("/")}function vdr(e){return e.startsWith("~")?$7a(Ddr(),e.slice(1)):e}function Xvn(e){return _dr($7a(e,"axon.config.ts"))}function ABt(e){let{store:n}=e;function A(){let s=n.profiles.active();if(!s)throw Pn("NOT_AUTHENTICATED");return s.agents}function i(s){let u=A().path(s);return Xvn(u)?u:null}return{async one(s){if(xdr(s)){let p=s.slice(1).split("@")[0]??"",d=i(p.includes("/")?p.split("/")[1]??p:p);if(d)return{root:d,kind:"registry",ref:s,installed:!1};let b=await e.clone(s,A().root);if(!Xvn(b.root))throw Pn("PROJECT_NOT_FOUND",{context:{ref:s,path:b.root}});return{root:b.root,kind:"registry",ref:s,installed:!0}}if(Fdr(s)){let p=kdr(e.cwd,vdr(s));if(!Xvn(p))throw Pn("PROJECT_NOT_FOUND",{context:{ref:s,path:p}});return{root:p,kind:"path",ref:s,installed:!1}}let u=i(s);if(!u)throw Pn("PROJECT_NOT_FOUND",{context:{ref:s,path:A().path(s),searched:A().extraRoots()}});return{root:u,kind:"name",ref:s,installed:!1}},async all(s){let u=Object.keys(s),p=await Promise.all(u.map((d)=>this.one(s[d])));return Object.fromEntries(u.map((d,b)=>[d,p[b]]))}}}var u8t=xt(()=>{qs()});import{randomUUID as Sdr}from"crypto";import{existsSync as Ndr}from"fs";import{resolve as Gdr}from"path";function Mdr(e){let n={get axon(){return e.current.axon},get sessionId(){return e.current.blueprint.session.id},get blueprint(){return e.current.blueprint},reload:e.reload,serve:e.serve,shutdown:e.shutdown};return new Proxy(n,{get(A,i,s){if(Reflect.has(A,i))return Reflect.get(A,i,s);let u=e.current.axon,p=u[i];return typeof p==="function"?p.bind(u):p},has(A,i){return Reflect.has(A,i)||i in e.current.axon},ownKeys(A){return[...new Set([...Reflect.ownKeys(A),...Reflect.ownKeys(e.current.axon)])]},getOwnPropertyDescriptor(A,i){if(Reflect.has(A,i))return Reflect.getOwnPropertyDescriptor(A,i);let s=Reflect.getOwnPropertyDescriptor(e.current.axon,i);return s?{...s,configurable:!0}:void 0}})}function eSn(e){let n=ABt({store:e.store,clone:e.clone,cwd:e.cwd}),A=[];async function i(d){let b=await e.projects.open(d),E=await K6e({project:b,cwd:e.cwd,cloud:e.cloud,store:e.store,watch:!1,...e.host?{host:e.host}:{}});if(A.push(E),E.kind!=="process")throw Pn("SCRIPT_AGENT_NOT_LOCAL",{detail:"a script's agent must run in this process \u2014 Scripts() booted a linked one",context:{root:d}});return Mdr(E)}async function s(d){if(d===void 0){let E=e.projects.find(e.cwd);if(!E)throw Pn("PROJECT_NOT_FOUND",{context:{path:e.cwd}});return i(E)}let b=await n.one(d);return i(b.root)}async function u(d){let b=await n.all(d),E=Object.keys(d),y=await Promise.all(E.map((k)=>i(b[k].root)));return Object.fromEntries(E.map((k,x)=>[k,y[x]]))}async function p(){let d=[];for(let b of[...A].reverse())try{await b.shutdown()}catch(E){d.push(E)}if(A.length=0,d.length>0)throw Pn(AggregateError(d,"one or more agents failed to shut down"))}return{Axon:s,Fleet:u,async exec(d){let b=Gdr(e.cwd,d);if(!Ndr(b))throw Pn("SCRIPT_FILE_NOT_FOUND",{context:{path:b}});let E=z7a.then(async()=>{let y=globalThis,k={Axon:y.Axon,Fleet:y.Fleet};y.Axon=s,y.Fleet=u;try{await import(`${b}?run=${Sdr()}`)}finally{y.Axon=k.Axon,y.Fleet=k.Fleet,await p()}});return z7a=E.catch(()=>{}),E},shutdown:p}}var z7a;var tSn=xt(()=>{qs();a8t();u8t();z7a=Promise.resolve()});function W7a(e){let n=e.instances;function A(){let p=Error("agent request aborted");return p.name="AbortError",p}function i(p){if(!p||typeof p!=="object")throw Pn("SUBAGENT_REQUEST_INVALID",{detail:"expected { prompt }"});let d=p.prompt;if(typeof d!=="string"&&!(Array.isArray(d)&&d.every((b)=>typeof b==="string")))throw Pn("SUBAGENT_REQUEST_INVALID",{detail:"prompt must be a string or string[]"});return{prompt:d}}function s(p){let d=n.get(p);if(!d)throw Pn("PARENT_INSTANCE_NOT_RUNNING",{context:{sessionId:p}});if(d.depth>=nSn)throw Pn("SUBAGENT_DEPTH_EXCEEDED",{detail:`maximum depth is ${nSn}`,context:{sessionId:d.sessionId,depth:d.depth,limit:nSn}});if(n.children(d.sessionId).length>=aSn)throw Pn("SUBAGENT_CHILD_LIMIT_EXCEEDED",{detail:`maximum live children is ${aSn}`,context:{sessionId:d.sessionId,limit:aSn}});if(n.descendants(d.rootSessionId).length>=ASn)throw Pn("SUBAGENT_DESCENDANT_LIMIT_EXCEEDED",{detail:`maximum live descendants is ${ASn}`,context:{rootSessionId:d.rootSessionId,limit:ASn}});return d}async function u(p){let d=s(p.parentSessionId);if(p.signal.aborted)throw A();let b=i(p.input);if(d.source.kind==="remote")throw Pn("SUBAGENT_REMOTE_PARENT",{context:{sessionId:d.sessionId}});let E=await n.spawn(d.source.project,{parentSessionId:d.sessionId,focus:!1});if(E.source.kind==="remote")throw Pn("INSTANCE_NOT_LOCAL",{detail:"spawn() must produce an instance on this machine",context:{sessionId:E.sessionId,kind:E.source.kind}});let y=E.source.agent,k=y.kind==="process"?()=>y.current.kernel.interrupt("user"):()=>y.link.interrupt("user");p.signal.addEventListener("abort",k,{once:!0});try{let x=y.kind==="process"?await y.current.axon.request(b):await Promise.reject(Pn("SUBAGENT_LINK_UNSUPPORTED",{detail:"a confined agent cannot yet serve a subagent request \u2014 the supervisor needs a verb that collects a wake's entries",context:{sessionId:E.sessionId}}));if(p.signal.aborted)throw A();return x}finally{p.signal.removeEventListener("abort",k),await n.stop(E.sessionId)}}return{request:u,async call(p){if(p.method!=="request")throw Pn("HOST_METHOD_UNKNOWN",{context:{method:p.method}});return u({parentSessionId:p.callerSessionId,input:p.input,signal:p.signal})}}}var nSn=4,aSn=4,ASn=12;var Z7a=xt(()=>{qs()});function iSn(e){let n=null;return{handle(A){return n=A,()=>{if(n===A)n=null}},get attached(){return n!==null},async decide(A,i){let s=e.store.profiles.active(),u=Ldr(i);if(!s)return!1;let p=s.grants.covers(A.agent,i.fn,u);if(p){let b=s.requests.raise({agent:A.agent,sessionId:A.sessionId,fn:i.fn,subject:u});return s.requests.settle(b.id,{decision:"allow",by:"grant",at:Date.now(),grantId:p.id}),!0}let d=s.requests.raise({agent:A.agent,sessionId:A.sessionId,fn:i.fn,subject:u});if(!n)return s.requests.settle(d.id,{decision:"deny",by:"expired",at:Date.now()}),!1;try{let b=await n({id:d.id,agent:A.agent,sessionId:A.sessionId,fn:i.fn,subject:u});return s.requests.settle(d.id,{decision:b?"allow":"deny",by:"user",at:Date.now()}),b}catch{return s.requests.settle(d.id,{decision:"deny",by:"expired",at:Date.now()}),!1}}}}function Ldr(e){let n=e.args[0];return typeof n==="string"&&n.length>0?n:e.fn}import{closeSync as X7a,openSync as e5a,readSync as t5a}from"fs";function n5a(e){let n=e5a(e,"r"),A=Buffer.allocUnsafe(8192);try{let i=t5a(n,A,0,A.length,0);if(i===0)return l8t;let s=A.toString("utf-8",0,i),u=s.indexOf(`
|
|
4970
4970
|
`);if(u<0)return l8t;let p=JSON.parse(s.slice(0,u));if(p.type!=="session:header")return l8t;return{title:typeof p.title==="string"&&p.title.length>0?p.title:null,forkedFrom:typeof p.forkedFrom?.sessionId==="string"?p.forkedFrom.sessionId:null}}catch{return l8t}finally{X7a(n)}}function g8t(e){let n=e5a(e,"r"),A=Buffer.allocUnsafe(65536),i=Math.max(...V7a.map((u)=>u.length))-1,s="";try{while(!0){let u=t5a(n,A,0,A.length,null);if(u===0)return!1;let p=s+A.toString("utf-8",0,u);if(V7a.some((d)=>p.includes(d)))return!0;s=p.slice(-i)}}finally{X7a(n)}}var l8t,V7a;var rSn=xt(()=>{l8t={title:null,forkedFrom:null},V7a=['"type":"cognet:stimulus:','"type":"cognet:output:','"type":"cognet:action:','"type":"axon:interrupt"','"type":"axon:system:']});import{existsSync as oSn,readdirSync as qdr,statSync as Tdr}from"fs";import{readFile as a5a,rename as Udr,writeFile as A5a}from"fs/promises";import{basename as Rdr,dirname as Kdr,join as p8t}from"path";function m8t(e){function n(){let A=e.store.profiles.active();if(!A)return[];let i=[],s=new Set;for(let u of A.agents.list()){let p=A.agents.path(u),d=[p8t(Fh({root:p,kind:"agent"}).path("data"),"sessions"),p8t(p,"data","sessions")];for(let b of d){if(!oSn(b))continue;for(let E of qdr(b)){if(!E.endsWith(".jsonl"))continue;let y=Rdr(E,".jsonl"),k=`${u}/${y}`;if(s.has(k))continue;s.add(k);let x=p8t(b,E),S=Tdr(x),L=n5a(x);i.push({sessionId:y,agent:u,filePath:x,modifiedAt:S.mtimeMs,sizeBytes:S.size,running:e.isRunning(y),hasEntries:g8t(x),title:L.title,forkedFrom:L.forkedFrom})}}}return i.sort((u,p)=>p.modifiedAt-u.modifiedAt)}return{list:n,latest(){return n().find((A)=>A.hasEntries)??null},async fork(A,i={}){if(!oSn(A))throw Pn("SESSION_NOT_FOUND",{detail:A,context:{filePath:A}});let s=await a5a(A,"utf-8"),u=s.indexOf(`
|
|
4971
4971
|
`);if(u<0)throw Pn("SESSION_UNREADABLE",{detail:`${A} has no header line`,context:{filePath:A}});let p;try{p=JSON.parse(s.slice(0,u))}catch(y){throw Pn("SESSION_UNREADABLE",{detail:A,context:{filePath:A},cause:y})}if(p.type!=="session:header")throw Pn("SESSION_UNREADABLE",{detail:`${A} does not start with a session:header`,context:{filePath:A}});let d=crypto.randomUUID(),b={...p,sessionId:d,startedAt:new Date().toISOString(),...i.title?{title:i.title}:{},forkedFrom:{sessionId:p.sessionId,at:new Date().toISOString()}},E=p8t(Kdr(A),`${d}.jsonl`);return await A5a(E,JSON.stringify(b)+s.slice(u)),{sessionId:d,filePath:E}},async rename(A,i){if(!oSn(A))throw Pn("SESSION_NOT_FOUND",{detail:A,context:{filePath:A}});let s=await a5a(A,"utf-8"),u=s.indexOf(`
|
|
4972
4972
|
`);if(u<0)throw Pn("SESSION_UNREADABLE",{detail:A,context:{filePath:A}});let p;try{p=JSON.parse(s.slice(0,u))}catch(E){throw Pn("SESSION_UNREADABLE",{detail:A,context:{filePath:A},cause:E})}if(p.type!=="session:header")throw Pn("SESSION_UNREADABLE",{detail:`${A} does not start with a session:header`,context:{filePath:A}});let d=JSON.stringify({...p,title:i})+s.slice(u),b=`${A}.${Math.random().toString(36).slice(2,10)}.tmp`;await A5a(b,d),await Udr(b,A)}}}var i5a=xt(()=>{qs();e2();rSn()});var d8t=xt(()=>{i5a();rSn()});import{existsSync as Ydr}from"fs";import{rm as jdr}from"fs/promises";import{join as r5a}from"path";function o5a(e){function n(){let A=e.store.profiles.active();if(!A)throw Pn("NOT_AUTHENTICATED");return r5a(A.agents.root,iBt)}return{get name(){return iBt},get exists(){return jMe(n())==="agent"},async ensure(){let A=e.store.profiles.active();if(!A)throw Pn("NOT_AUTHENTICATED");let i=r5a(A.agents.root,iBt);if(jMe(i)==="agent")return e.projects.open(i);if(Ydr(i))await jdr(i,{recursive:!0,force:!0});await e.clone(Hdr,A.agents.root,{dir:iBt});let s=await e.projects.open(i);return await s.modules.install(Pdr),s}}}var iBt="zeno",Hdr="@axon/zeno",Pdr;var sSn=xt(()=>{qs();XCt();Pdr=["@axon/fs","@axon/subagent"]});function cSn(e){let n=ABt({store:e.store,clone:e.clone,cwd:e.cwd}),A=iSn({store:e.store}),i=O7a({store:e.store,projects:e.projects,resolve:n,cwd:e.cwd,cloud:e.cloud,host:{call:(d)=>s.call(d)},escalations:A,...e.control?{control:e.control}:{}}),s=W7a({instances:i}),u=m8t({store:e.store,isRunning:(d)=>i.has(d)}),p=o5a({store:e.store,projects:e.projects,clone:e.clone});return{resolve:i.resolve,host:s,escalations:A,script(d){return eSn({store:e.store,projects:e.projects,cloud:e.cloud,clone:e.clone,cwd:d.cwd,...d.host?{host:d.host}:{}})},spawn:i.spawn,attach:i.attach,focus:i.focus,stop:i.stop,shutdown:i.shutdown,children:i.children,onSpawn:i.onSpawn,onStop:i.onStop,list:i.list,recent:i.recent,get(d){return i.get(d)},sessions(){return u.list()},get history(){return u},zeno:p,get focused(){return i.focused()},get current(){let d=i.focused();if(!d||d.source.kind==="remote")return null;return d.source.agent},get project(){let d=i.focused();if(!d||d.source.kind==="remote")return null;return d.source.project},get active(){return i.focused()!==null},get axon(){let d=i.focused();if(d?.source.kind!=="local")return null;return d.source.agent.kind==="process"?d.source.agent.current.axon:null},get blueprint(){let d=i.focused();if(!d||d.source.kind==="remote")return null;let b=d.source.agent;return b.kind==="process"?b.current.blueprint:b.blueprint},get session(){let d=i.focused();if(!d||d.source.kind==="remote")return null;let b=d.source.agent;return b.kind==="process"?b.current.session:b.session},get runtime(){let d=i.focused();if(d?.source.kind!=="local")return null;return d.source.agent.kind==="process"?d.source.agent.current:null}}}var s5a=xt(async()=>{u8t();tSn();Z7a();d8t();sSn();await Vvn()});import{existsSync as Jdr,mkdirSync as Odr,writeFileSync as c5a}from"fs";import{dirname as u5a,join as f8t}from"path";function uSn(e){let n=u5a(e);try{let i=f8t(n,l5a);Odr(u5a(i),{recursive:!0}),c5a(i,$dr,"utf-8")}catch(i){return{ok:!1,reason:`could not write ${f8t(n,l5a)} \u2014 ${g5a(i)}`}}let A=f8t(n,"tsconfig.json");if(Jdr(A))return{ok:!0};try{c5a(A,zdr,"utf-8")}catch(i){return{ok:!1,reason:`could not write ${A} \u2014 ${g5a(i)}`}}return{ok:!0}}function g5a(e){return e instanceof Error?e.message:String(e)}var $dr=`// generated by axon \u2014 do not edit
|
|
@@ -5043,11 +5043,11 @@ held by:
|
|
|
5043
5043
|
${E}`:""),context:{model:u.model,needs:u.bytes,available:p.available}})}let d=A.take(u),b=!1;return()=>{if(b)return;b=!0,A.release(d)}},releaseAll(){A.releaseAll()}}}var C5a=xt(()=>{qs();mSn();bSn()});var B5a=xt(()=>{C5a();bSn();mSn()});import{execFile as afr}from"child_process";import{createHash as Afr}from"crypto";import{existsSync as ISn}from"fs";import{mkdir as ifr,readFile as rfr,readdir as sBt,rm as I5a,writeFile as Q5a}from"fs/promises";import{basename as ofr,join as P6e,resolve as E5a}from"path";function _5a(e){function n(A,i){return P6e(e.root,"cache","prompts",...A.split("/"),i)}return{async ensure(A){if(!A)throw Pn("CLONE_REF_REQUIRED");let{name:i,version:s}=yIe(A),u=await e.cloud.registry.resolve(i,s),p=n(u.name,u.version);if(!ISn(p)||(await sBt(p)).length===0)await ySn(await ESn(u.downloadUrl),p);return{name:u.name,version:u.version,root:p}},async cached(){let A=P6e(e.root,"cache","prompts");if(!ISn(A))return[];let i=[];for(let s of await sBt(A))for(let u of await sBt(P6e(A,s)).catch(()=>[]))for(let p of await sBt(P6e(A,s,u)).catch(()=>[]))i.push({name:`${s}/${u}`,version:p,root:P6e(A,s,u,p)});return i}}}function w5a(e){async function n(i,s,u={}){if(!i)throw Pn("CLONE_REF_REQUIRED");let{name:p,version:d}=yIe(i),b=await e.cloud.registry.resolve(p,d),E=E5a(s,u.dir??y5a(b.name));return await ySn(await ESn(b.downloadUrl),E),await e.prepare(E),{...b,root:E}}async function A(i,s,u={}){if(!u.as)throw Pn("FORK_NAME_REQUIRED");if(!i)throw Pn("FORK_REF_REQUIRED");let{name:p,version:d}=yIe(i),b=await e.cloud.registry.resolve(p,d),E=E5a(s,u.dir??y5a(u.as));await ySn(await ESn(b.downloadUrl),E);let y={...b,root:E},k=P6e(y.root,"package.json"),x=JSON.parse(await rfr(k,"utf-8")),S=x.axon&&typeof x.axon==="object"&&!Array.isArray(x.axon)?x.axon:{};return x.name=u.as,x.version="0.1.0",x.axon={...S,forkedFrom:{name:y.name,version:y.version}},await Q5a(k,JSON.stringify(x,null,2)+`
|
|
5044
5044
|
`),await e.prepare(E),{...y,name:u.as,version:"0.1.0"}}return{clone:n,fork:A}}function y5a(e){return ofr(e)}function BSn(e){return new Promise((n)=>{afr("tar",e,{maxBuffer:67108864},(A,i,s)=>{n({exitCode:A?typeof A.code==="number"?A.code:1:0,stdout:i,stderr:s||(A?A.message:"")})})})}async function ESn(e){let n=await fetch(e);if(!n.ok)throw Pn("ARTIFACT_DOWNLOAD_FAILED",{detail:`${n.status} ${n.statusText}`,context:{status:n.status}});return n.arrayBuffer()}async function ySn(e,n){let A=!1;if(ISn(n)){if((await sBt(n)).length>0)throw Pn("CLONE_TARGET_EXISTS",{detail:`${n} is not empty`,context:{target:n}})}else await ifr(n,{recursive:!0}),A=!0;let i=P6e(n,`.axon-clone-${Afr("sha256").update(new Uint8Array(e)).digest("hex")}.tar.gz`);try{await Q5a(i,new Uint8Array(e));let u=(await BSn(["-tzf",i])).stdout.split(`
|
|
5045
5045
|
`).filter(Boolean),d=u.length>0&&u.every((b)=>b==="package/"||b.startsWith("package/"))?await BSn(["-xzf",i,"-C",n,"--strip-components=1"]):await BSn(["-xzf",i,"-C",n]);if(d.exitCode!==0)throw Pn("ARTIFACT_EXTRACT_FAILED",{detail:d.stderr.trim(),context:{exitCode:d.exitCode}})}catch(s){if(A)await I5a(n,{recursive:!0,force:!0});throw s}finally{await I5a(i,{force:!0})}}var k5a=xt(()=>{qs();eSt()});import{join as sfr}from"path";async function D5a(e,n){let A=Or.exists(sfr(e,"src","prompts")),i=await lKe(e,{prefix:n,...A?{}:{dir:"."}}),s=i.entries.filter((d)=>d.name!==`${n}:README`),u=n.split("/").at(-1),p=s.find((d)=>d.name===`${n}:${u}`);if(p&&s.length===1)s.push({...p,name:n});return{entries:s,warnings:i.warnings}}var x5a=xt(()=>{ph();_vt()});function F5a(e){async function n(A){let{name:i,root:s}=await e.cache.ensure(A),u=await D5a(s,i);if(u.entries.length===0)throw Pn("PROMPT_NOT_FOUND",{detail:`${i} is published but ships no prompt files`,context:{name:i}});return u.entries}return{entries:n,async entry(A){let i=await n(A),s=i.find((u)=>u.name===A);if(s)return s;if(i.length>1)throw Pn("PROMPT_NOT_FOUND",{detail:`${A} ships ${i.length} prompts \u2014 name one of: ${i.map((u)=>u.name).join(", ")}`,context:{name:A}});return i[0]}}}var v5a=xt(()=>{qs();x5a()});var cBt=75,QSn="AXON_UPDATE_REQUEST";var _Sn=xt(()=>{qs()});import{existsSync as cfr,realpathSync as ufr}from"fs";import{mkdir as lfr,rename as gfr,writeFile as pfr}from"fs/promises";import{dirname as S5a,join as mfr}from"path";function wSn(e){let n=e.currentVersion,A=process.argv[1]??import.meta.path,i=e.helperPath??N5a(A),s=e.bunPath??process.execPath,u=e.axonPath??(typeof Bun>"u"?"axon":Bun.which("axon")??"axon"),p=e.requestPath??process.env[QSn];function d(){return cfr(i)&&Boolean(p)}async function b(y,k={}){if(!uBt.valid(n))throw Pn("UPDATE_CURRENT_VERSION_INVALID",{context:{version:n}});let x=await e.cloud.cloud.releases.axon(y,k);if(x.package!=="@arcforge/axon"||x.channel!=="latest"||!uBt.valid(x.version))throw Pn("UPDATE_RELEASE_INVALID",{context:{package:x.package,channel:x.channel,version:x.version}});return{status:uBt.gt(x.version,n)?"available":"current",current:n,latest:x.version}}async function E(y){let k=await b(y,{fresh:!0});if(k.status==="current")return k;if(!d())throw Pn("UPDATE_UNAVAILABLE_IN_DEVELOPMENT");e.store.update.state.set({status:"pending",from:k.current,to:k.latest,updatedAt:new Date().toISOString()});try{let x={from:k.current,to:k.latest,bun:s,axon:u,state:e.store.update.statePath};if(!p)throw Pn("UPDATE_SUPERVISOR_UNAVAILABLE");await lfr(S5a(p),{recursive:!0});let S=`${p}.${process.pid}.tmp`;await pfr(S,JSON.stringify(x,null,2)+`
|
|
5046
|
-
`,"utf-8"),await gfr(S,p)}catch(x){throw e.store.update.state.set({status:"failed",from:k.current,to:k.latest,updatedAt:new Date().toISOString(),error:x instanceof Error?x.message:String(x)}),x}return k}return{currentVersion:n,supported:d,check:b,handoff:E}}function N5a(e){let n=e;try{n=ufr(e)}catch{}return mfr(S5a(n),"update-helper.js")}var uBt;var G5a=xt(()=>{_Sn();qs();uBt=fp(txn(),1)});var M5a=()=>{};var C8t=xt(()=>{G5a();M5a();_Sn()});import{join as dfr,resolve as ffr}from"path";function lBt(e){let n=ffr(e.cwd??process.cwd()),A=e.distribution??hfr,i={},s=RQn({root:e.store??KQn(A),settings:()=>i,setSetting:async(be,ce)=>{let ke=await me.setSetting(be,ce);return await ee(),ke}}),u=Pka({store:s,distribution:A}),p=jQn(),d=e0a(),b=n0a({root:n}),E=VFn();async function y(){let be=s.profiles.active()?.root;if(!be)return;let{providers:ce}=await R6e(be);return ce}let k=CSn({budget:()=>{return}}),x=tvn({cloud:u.client,profileProviders:()=>y(),frameworkVersion:e.version,...e.frameworkSource?{frameworkSource:e.frameworkSource}:{},...e.repoRoot?{repoRoot:e.repoRoot}:{},bench:{tests:E,clone:(be,ce,ke)=>L.clone(be,ce,ke),prepare:async(be)=>{await(await x.open(be)).prepare()}}}),S=cSn({store:s,projects:x,cloud:u.client,cwd:n,clone:(be,ce,ke)=>L.clone(be,ce,ke),...e.control?{control:e.control}:{}}),L=w5a({cloud:u.client,async prepare(be){await(await x.open(be)).prepare()}}),U=F5a({cache:_5a({cloud:u.client,root:s.root})}),$=wSn({cloud:u.client,store:s,currentVersion:e.version}),V=Oka({cloud:u.client}),te=lSn({store:s,projects:x,frameworkVersion:e.version});async function ee(){try{i=await me.settings()}catch{i={}}}let me=Evn({root:()=>te.root,install:async(be,ce)=>{return{version:(await L.clone(be,dfr(ce,".."),{dir:ce.split("/").at(-1)})).version}},latest:async(be)=>(await u.client.registry.artifacts.resolve(be)).version});return{cloud:u,store:s,deployments:V,projects:x,profile:te,extensions:me,refreshSettings:ee,agents:S,registry:L,prompts:U,tests:E,mic:d,files:b,ollama:p,resources:k,updates:$}}var hfr="production";var L5a=xt(async()=>{Mwa();Hwa();PQn();a0a();Jka();XCt();n8t();B5a();XFn();k5a();v5a();C8t();await gSn()});function $Ke(e,n){let A=new Map;for(let s of e)switch(s.type){case"process:proc:start":{let u=s.data;A.set(u.procId,{procId:u.procId,kind:u.kind,command:u.command,pid:u.pid,cwd:u.cwd,status:"running",startedAt:typeof s.at==="number"?s.at:Date.now(),output:[]});break}case"process:proc:complete":{let u=s.data,p=A.get(u.procId);if(!p)break;if(p.status="exited",p.exitCode=u.code,typeof s.at==="number")p.endedAt=s.at;break}case"process:proc:failed":{let u=s.data,p=A.get(u.procId);if(!p)break;if(p.status="exited",typeof s.at==="number")p.endedAt=s.at;break}case"process:proc:denied":{let u=s.data,p=A.get(u.procId);if(p){p.status="exited",p.exitCode=-1;break}A.set(u.procId,{procId:u.procId,kind:"managed",command:u.command,status:"exited",exitCode:-1,startedAt:typeof s.at==="number"?s.at:Date.now(),output:[]});break}}let i=[...A.values()].sort((s,u)=>s.startedAt-u.startedAt);if(!n?.main)return i;return[{procId:"main",kind:"main",command:"agent \xB7 ts runtime",...n.main.pid!==void 0?{pid:n.main.pid}:{},status:n.main.status,startedAt:n.main.startedAt??i[0]?.startedAt??Date.now(),main:!0,output:[]},...i]}var q5a=async()=>{};var B8t=xt(async()=>{await Qk([L5a(),q5a(),Zvn()])});var J6e;var I8t=xt(()=>{J6e={name:"@arcforge/axon",version:"2.0.157",description:"coding agent cli",module:"index.ts",type:"module",scripts:{build:"vterm build",deploy:"bun run scripts/release.ts patch","deploy:major":"bun run scripts/release.ts major","deploy:minor":"bun run scripts/release.ts minor","deploy:patch":"bun run scripts/release.ts patch",dev:"vterm dev","dev:local":"vterm dev --dotenv .env.local",prepare:"vterm prepare",tail:"vterm tail",test:"bun test --parallel=4 --path-ignore-patterns='**/tests/perf/**'","test:perf":"bun test tests/perf","test:serial":"bun test --path-ignore-patterns='**/tests/perf/**'","test:watch":"bun test --watch",typecheck:"bun run scripts/typecheck.ts"},dependencies:{"@arcforge/cognet":"workspace:*","@arcforge/engines":"workspace:*","@arcforge/err":"workspace:*","@arcforge/platform":"workspace:*","@arcforge/types":"workspace:*","@arcforge/vterm":"workspace:*","@arclabs/cloud":"workspace:*","@arclabs/repo":"workspace:*","@arclabs/tools":"workspace:*","@axon/capsule":"workspace:*","@axon/core":"workspace:*","@axon/theme":"workspace:*","@axon/vstr":"workspace:*","@vue/compiler-sfc":"3.5.39",arcline:"workspace:*",chalk:"^5.6.2","fft.js":"^4.0.4",h3:"^1.15.11","markdown-it":"^14.3.0",open:"^11.0.0",semver:"^7.7.4",sharp:"^0.35.3"},devDependencies:{"@types/bun":"latest","@types/markdown-it":"^14.1.2","@types/semver":"^7.7.1","@vue/typescript-plugin":"^3.2.5",postgres:"^3.4.5"},peerDependencies:{typescript:"^5"},bin:{axon:"./bin/axon"}}});function E8t(e,n){let A=e;for(let i of n){if(A===null||typeof A!=="object"||!(i in A))throw Pn("CONTROL_PATH_NOT_FOUND",{detail:`no such method on the peer: ${n.join(".")}`,context:{path:n.join(".")}});A=A[i]}return A}function y8t(e){let n=new Map,A=new Map,i=new Map,s=!1,u=0,p=()=>`${++u}`;async function d(k){try{let x=E8t(e.handle,k.path.slice(0,-1)),S=E8t(e.handle,k.path);if(typeof S!=="function")throw Pn("CONTROL_PATH_NOT_CALLABLE",{detail:`not callable on the peer: ${k.path.join(".")}`,context:{path:k.path.join(".")}});let L=await S.apply(x,k.args);e.send({type:"rpc.result",id:k.id,ok:!0,value:L})}catch(x){e.send({type:"rpc.result",id:k.id,ok:!1,error:x instanceof Error?x.message:String(x)})}}function b(k){try{let x=E8t(e.handle,k.path.slice(0,-1)),S=E8t(e.handle,k.path);if(typeof S!=="function")throw Pn("CONTROL_PATH_NOT_CALLABLE",{detail:`not callable on the peer: ${k.path.join(".")}`,context:{path:k.path.join(".")}});let L=($)=>e.send({type:"rpc.event",id:k.id,value:$}),U=S.apply(x,[...k.args,L]);A.set(k.id,U)}catch(x){e.send({type:"rpc.result",id:k.id,ok:!1,error:x instanceof Error?x.message:String(x)})}}function E(k){A.get(k.id)?.(),A.delete(k.id)}function y(k){let x=n.get(k.id);if(!x)return;if(n.delete(k.id),k.ok)x.resolve(k.value);else x.reject(Pn("CONTROL_CALL_FAILED",{detail:k.error,context:{error:k.error}}))}return{accept(k){if(k.type==="rpc.call")return void d(k);if(k.type==="rpc.subscribe")return b(k);if(k.type==="rpc.unsubscribe")return E(k);if(k.type==="rpc.result")return y(k);i.get(k.id)?.(k.value)},call(k,x=[]){if(s)return Promise.reject(Pn("CONTROL_CLOSED",{detail:`channel closed before ${k.join(".")} could be sent`,context:{path:k.join(".")}}));let S=p();return new Promise((L,U)=>{n.set(S,{resolve:L,reject:U}),e.send({type:"rpc.call",id:S,path:k,args:x})})},subscribe(k,x,S){if(s)throw Pn("CONTROL_CLOSED",{detail:`channel closed before ${k.join(".")} could be sent`,context:{path:k.join(".")}});let L=p();return i.set(L,S),e.send({type:"rpc.subscribe",id:L,path:k,args:x}),()=>{if(!i.delete(L))return;if(!s)e.send({type:"rpc.unsubscribe",id:L})}},close(k){if(s)return;s=!0;for(let x of A.values())x();A.clear(),i.clear();for(let x of n.values())x.reject(Pn("CONTROL_CLOSED",{detail:k,context:{error:k}}));n.clear()}}}var Q8t=xt(()=>{qs()});function kSn(e){if(typeof e!=="object"||e===null)return!1;let n=e.type;return n==="rpc.call"||n==="rpc.result"||n==="rpc.subscribe"||n==="rpc.unsubscribe"||n==="rpc.event"}import{randomBytes as Bfr}from"crypto";function gBt(e){let n=Bfr(32).toString("hex"),A=null,i=new Set;function s(){for(let b of i)b(u.size)}let u=new Map;function p(b,E){let y=u.get(b);if(!y)return;y.dispatch.close(E),u.delete(b),s()}async function d(b){let E=[...u.values()];if(E.length===0)throw Pn("CONTROL_CLOSED",{detail:"no editor attached"});if(E.length===1)return E[0].dispatch;let y=await Promise.all(E.map(async(k)=>{try{let x=await k.dispatch.call(["editor","claim"],[b??null]);return{dispatch:k.dispatch,contains:x?.contains===!0,focusedAt:x?.focusedAt??0}}catch{return{dispatch:k.dispatch,contains:!1,focusedAt:0}}}));return y.sort((k,x)=>k.contains!==x.contains?k.contains?-1:1:x.focusedAt-k.focusedAt),y[0].dispatch}return{token:n,get port(){return A?.port??null},get attached(){return u.size>0},get peerCount(){return u.size},watch(b){return i.add(b),()=>{i.delete(b)}},listen(){if(A)return A.port;return A=Bun.serve({port:e.port??0,hostname:"127.0.0.1",fetch(b,E){if(E.upgrade(b,{data:null}))return;return new Response("axon control channel",{status:426})},websocket:{message(b,E){let y;try{y=JSON.parse(String(E))}catch{b.close(1003,"malformed frame");return}let k=u.get(b);if(!k){let x=y;if(x?.type!=="control.hello"||x.token!==n){b.close(1008,"unauthorized");return}let S={send:(L)=>b.send(L),close:()=>b.close()};u.set(b,{socket:S,dispatch:y8t({handle:e.handle,send:(L)=>S.send(JSON.stringify(L))})}),b.send(JSON.stringify({type:"control.welcome",peer:"tui"})),s();return}if(!kSn(y))return;k.dispatch.accept(y)},close(b){p(b,"editor disconnected")}}}),A.port},editor:{async call(b,...E){return await(await d()).call(["editor",String(b)],E)},async about(b,E,...y){return await(await d(b)).call(["editor",String(E)],y)}},close(){for(let[b,E]of u)p(b,"tui shutting down"),E.socket.close();A?.stop(!0),A=null}}}var T5a=xt(()=>{qs();Q8t()});var U5a=xt(()=>{qs();Q8t()});var DSn=xt(()=>{T5a();U5a();Q8t()});function _8t(){let e=(n)=>{let A=R5a[n];if(!A)throw Error(`TUI_NOT_READY: this TUI cannot ${n} yet \u2014 it is still starting up`);return A};return{send:(n)=>e("send")(n),interrupt:()=>e("interrupt")(),focus:(n)=>e("focus")(n),capsule:(n,A)=>e("capsule")(n,A),lastActiveAt:async()=>K5a}}function Y5a(e){R5a=e}function xSn(){K5a=Date.now()}var R5a,K5a;var pBt=xt(()=>{R5a={},K5a=Date.now()});function bAe(){if(!FSn)FSn=Ifr();return FSn}function Ifr(){let e=null,n=uA.ref(0);function A(){if(e)return;let b=gBt({handle:{tui:_8t()}});b.watch(()=>{n.value++}),b.listen(),e=b}function i(){let b=e?.port;if(!e||b===null||b===void 0)return null;return{port:b,token:e.token}}let s=uA.computed(()=>{return n.value,(e?.peerCount??0)>0});async function u(b,...E){if(!e)throw Error("CONTROL_NOT_LISTENING: this TUI is not serving a control channel");return e.editor.call(b,...E)}async function p(b,E,...y){if(!e)throw Error("CONTROL_NOT_LISTENING: this TUI is not serving a control channel");return e.editor.about(b,E,...y)}function d(){e?.close(),e=null,n.value++}return{listen:A,control:i,available:s,editor:u,editorAbout:p,close:d}}var FSn;var w8t=xt(()=>{Fs();DSn();pBt()});function IC(){if(!vSn)vSn=lBt({version:J6e.version,cwd:process.env.PWD??process.cwd(),control:()=>bAe().control()});return vSn}var vSn=null;var a3=xt(async()=>{I8t();w8t();await B8t()});function Efr(e,n){let A=uA.ref("idle"),i=uA.ref(null),s=uA.ref(null),u=uA.ref(0);function p(){u.value++}function d(me,be,ce){let ke=uA.ref(!1),Te=uA.ref(null),Ze=uA.ref(!1);async function nt(){if(!e.authenticated){Ze.value=!1;return}let gt=await me.status();Ze.value=gt.connected&>.status==="active"}nt().catch((gt)=>{Te.value=gt instanceof Error?gt:Error(String(gt))});async function je(...gt){ke.value=!0,Te.value=null;try{if(await be(...gt),ce)await IC().extensions.addProvider(ce);Ze.value=!0}catch(Oe){throw Te.value=Oe instanceof Error?Oe:Error(String(Oe)),Oe}finally{ke.value=!1,p()}}async function Xe(){if(await me.disconnect(),ce)await IC().extensions.removeProvider(ce);Ze.value=!1,p()}return{connected:Ze,connecting:ke,error:Te,connect:je,disconnect:Xe,refreshStatus:nt}}let b=d(e.connections.openai,()=>e.connections.openai.connect({open:(me)=>{Uhe(me)}}),"Codex"),E=d(e.connections.openrouter,(me)=>e.connections.openrouter.connect({key:me}),"OpenRouter");function y(me){let be=uA.ref(!1),ce=uA.ref(!1),ke=uA.ref(null);async function Te(){let je=await IC().extensions.readProviders();be.value=je.includes(me)}Te().catch((je)=>{ke.value=je instanceof Error?je:Error(String(je))});async function Ze(){ce.value=!0,ke.value=null;try{await IC().extensions.addProvider(me),be.value=!0}catch(je){throw ke.value=je instanceof Error?je:Error(String(je)),je}finally{ce.value=!1,p()}}async function nt(){await IC().extensions.removeProvider(me),be.value=!1,p()}return{connected:be,connecting:ce,error:ke,connect:Ze,disconnect:nt,refreshStatus:Te}}let k=y("Ollama"),x=uA.ref(e.authenticated?"checking":"signed-out"),S=uA.computed(()=>{return u.value,x.value==="verified"});async function L(){if(!e.authenticated)return x.value="signed-out",p(),x.value;x.value="checking",p();try{let me=await e.validate();x.value=me==="valid"?"verified":me==="rejected"?"signed-out":"unreachable"}catch{x.value="unreachable"}return p(),x.value}if(x.value==="checking")L();e.onSessionExpired(()=>{x.value="signed-out",p()});let U=uA.computed(()=>{return u.value,e.client.user.auth.user}),$=uA.computed(()=>{return u.value,n.profiles.list().flatMap((me)=>{let be=n.profiles.get(me).record.get();if(!be)return[];let ce=!!(be.auth.accessToken||be.auth.apiKey);return[{id:me,email:be.user.email,authenticated:ce}]})});async function V(me){A.value="authorizing",i.value=null;try{await e.login({...me!==void 0?{hint:me}:{},onCode:(be)=>{i.value=be,A.value="polling",Uhe(be.verificationUriComplete)}}),x.value="verified"}finally{A.value="idle",i.value=null,p()}}async function te(me){s.value=me;try{return await e.switch(me),x.value="verified","verified"}catch(be){let ce=P1t(be)&&be.code==="AX-TUI-044";return x.value=ce?"unreachable":"signed-out",ce?"unreachable":"rejected"}finally{s.value=null,p()}}async function ee(){await e.logout(),x.value="signed-out",p()}return{isAuthenticated:S,gate:uA.computed(()=>x.value),verify:L,identity:U,profiles:$,loginStatus:A,deviceAuthorization:i,switchingProfileId:s,startLogin:V,switchProfile:te,logout:ee,connections:{openai:b,openrouter:E,ollama:k}}}function b8(){if(!SSn){let e=IC();SSn=Efr(e.cloud,e.store)}return SSn}var SSn;var MIe=xt(async()=>{Fs();Xft();qs();await a3()});var LSn={};OA(LSn,{useSettings:()=>fBt});function Nfr(){let e=IC();async function n(){try{dBt.value=await e.extensions.settings()}catch{dBt.value={}}GSn.value++}return{settings:uA.computed(()=>{return GSn.value,dBt.value}),refresh:n,async set(A,i){dBt.value={...dBt.value,[A]:i},GSn.value++,await e.extensions.setSetting(A,i)}}}function fBt(){if(!MSn)MSn=Nfr();return MSn}var dBt,GSn,MSn;var hBt=xt(async()=>{Fs();await a3();dBt=uA.ref({}),GSn=uA.ref(0)});var USn={};OA(USn,{useTheme:()=>nE,DEFAULT_THEME_NAME:()=>D8t});async function Mfr(e){try{let{useSettings:n}=await hBt().then(() => LSn);await n().set("theme",e)}catch{}}function qIe(e){return Fne.value.find((n)=>n.name===e)??null}function J5a(e){let n=qIe(e);if(!n)throw Error(`no theme named "${e}"`);DJ.value=e,qSn.value=e,LIe.value=null,$6e(n),Mfr(e)}function $6e(e){Aqe.register(Gfr,{":root":{cssVariables:kgn(e)}}),vgt({theme:e.syntax==="arcnight"?rQt:e.syntax}),O6e.value++,TSn?.()}function nE(){if(!TSn)try{TSn=HC()}catch{}return{themes:uA.computed(()=>{return O6e.value,Fne.value}),active:uA.computed(()=>{return O6e.value,qIe(DJ.value)??Fne.value[0]}),committedName:uA.computed(()=>LIe.value??DJ.value),themeClass:uA.computed(()=>{return O6e.value,`theme-${DJ.value}`}),create(e){if(qIe(e.name))throw Error(`theme "${e.name}" is already registered`);if(Fne.value=[...Fne.value,e],O6e.value++,qSn.value===e.name)DJ.value=e.name,$6e(e);return()=>{if(Fne.value=Fne.value.filter((n)=>n.name!==e.name),DJ.value===e.name)DJ.value=Fne.value[0].name,$6e(Fne.value[0]);O6e.value++}},set:J5a,reset(){J5a(D8t)},preview(e){let n=qIe(e);if(!n)return;if(LIe.value===null)LIe.value=DJ.value;DJ.value=e,$6e(n)},cancelPreview(){if(LIe.value===null)return;let e=qIe(LIe.value);if(DJ.value=LIe.value,LIe.value=null,e)$6e(e)},mount(){let e=qIe(DJ.value)??Fne.value[0];$6e(e)},adopt(e){if(!e)return;qSn.value=e;let n=qIe(e);if(!n)return;DJ.value=e,$6e(n)},colors:uA.computed(()=>{O6e.value;let e=qIe(DJ.value)??Fne.value[0];return{primary:String(e.primary),background:String(e.background),text:String(e.text),dim:String(e.dim),warn:String(e.warn),error:String(e.error)}})}}var Gfr="axon:theme:tokens",D8t,Fne,DJ,LIe,qSn,O6e,TSn=null;var A3=xt(()=>{Fs();Fs();Dgn();D8t=Fgt[0].name,Fne=uA.ref([...Fgt]),DJ=uA.ref(Fgt[0].name),LIe=uA.ref(null),qSn=uA.ref(null),O6e=uA.ref(0)});function O5a(){let e=0;return{claim(){let n=++e;return{get latest(){return e===n}}}}}function $5a(e){for(let n=e.length-1;n>=0;n--){let A=e[n];if(A.type!=="kernel:engine:complete")continue;let i=A.data?.meta?.model;if(typeof i==="string")return i}return null}function z5a(e){let n=gne(e??void 0);if(!n)return null;if(n.provider!==void 0&&n.provider!=="axon")return null;if(n.model!=="auto")return null;return{model:"auto"}}function x8t(e){let{provider:n,declared:A,resolved:i}=e;if(!A)return n;let s=`${n}/${A}`;if(A!=="auto")return s;if(!i||i==="auto")return s;return`${i} (${A})`}var W5a=xt(()=>{pRe()});function Lfr(e,n,A){if(A<=0||n<=0)return;let i=n/A,s=RSn.get(e);RSn.set(e,s===void 0?i:s*0.7+i*0.3)}function qfr(e){return(e?RSn.get(e):void 0)??4.5}function Z5a(e,n=[]){let A=null,i=null,s=null,u=-1;for(let d=e.length-1;d>=0;d--){let b=e[d];if(b.type==="kernel:engine:complete"){let E=b.data?.meta;if(A??=E.model,E.tokens){i=E.tokens.in+E.tokens.out,u=b.time.seq;break}continue}if(b.type==="kernel:engine:input"){s=b.data?.bytes??s,u=b.time.seq,A??=Tfr(e,d);break}}if(i===null&&s===null)return null;if(i!==null){let d=Ufr(e,u);if(A&&d!==null)Lfr(A,d,i);return{tokens:i,model:A}}let p=Rfr(n,u);return{tokens:Math.round(s/qfr(A))+Math.round(p/3.3),model:A}}function Tfr(e,n){for(let A=n;A>=0;A--){let i=e[A];if(i.type==="kernel:engine:start"){let s=i.data.model;if(s)return s}if(i.type==="kernel:engine:complete")return i.data?.meta?.model??null}return null}function Ufr(e,n){for(let A=e.length-1;A>=0;A--){let i=e[A];if(i.time.seq>=n)continue;if(i.type==="kernel:engine:input")return i.data?.bytes??null;if(i.type==="kernel:engine:complete")return null}return null}function Rfr(e,n){let A=0;for(let i=e.length-1;i>=0;i--){let s=e[i];if(s.time.seq<=n)break;if(s.type!=="cognet:output:text")continue;let u=s.data.content;if(u)A+=u.length}return A}function V5a(){let A=0,i=null;return{step(s){if(!s)return null;if(s.model!==i)return i=s.model,A=s.tokens,A;if(s.tokens>=A)return A=s.tokens,A;let u=A-s.tokens;if(u<=200)return A;if(A=Math.round(A-u*0.25),A-s.tokens<=200)A=s.tokens;return A},reset(){A=0,i=null}}}function Kfr(e){if(e>=1e6){let n=e/1e6;return`${n.toFixed(n>=10?0:1)}m`}if(e===0)return"0k";return`${(e/1000).toFixed(1)}k`}function Yfr(e){if(e>=1e6){let n=Number((e/1e6).toFixed(1));return`${n%1===0?n.toFixed(0):n.toFixed(1)}m`}return`${Math.round(e/1000)}k`}function X5a(e,n){let A=e.find((s)=>s.id===n);if(A)return A.context;return e.find((s)=>s.id.slice(s.id.indexOf("/")+1)===n)?.context??0}function eYa(e,n){if(e===null||n<=0)return null;return`${Kfr(e)}/${Yfr(n)}`}var RSn;var KSn=xt(()=>{RSn=new Map});import{homedir as jfr}from"os";import{basename as Hfr,relative as Pfr,sep as tYa}from"path";function nYa(e,n){if(!e)return null;if(/^https?:\/\//i.test(e))return e;if(n&&Jfr(e,n))return`axon:${Hfr(e)}`;return Ofr(e)}function Jfr(e,n){let A=Pfr(n,e);return A.length>0&&!A.startsWith("..")&&!A.includes(tYa)}function Ofr(e){let n=jfr();if(e===n)return"~";return e.startsWith(n+tYa)?"~"+e.slice(n.length):e}var aYa=()=>{};function WKe(){Z6e.value++}function AYa(e){return e.join(" ")}function $fr(){let e=[];for(let n of M1.commands){let A=e;for(let s of n.path.slice(0,-1)){let u=A.find((d)=>d.kind==="group"&&d.label===s);if(u){A=Array.isArray(u.children)?u.children:[];continue}let p={kind:"group",label:s,description:"",children:[]};A.push(p),A=p.children}let i=n.path.at(-1);A.push({kind:"action",label:i,description:n.description??"",action:n.action,...n.workingMessage?{workingMessage:n.workingMessage}:{}})}return e}var W6e,bBt,z6e,CBt,Z6e,M1,F8t;var V6e=xt(()=>{Fs();qs();W6e=uA.ref([]),bBt=uA.ref(new Map),z6e=uA.ref(new Map),CBt=uA.ref(new Map),Z6e=uA.ref(0);M1={command(e){let n=AYa(e.path);if(W6e.value.some((i)=>AYa(i.path)===n))throw Pn("COMMAND_PATH_TAKEN",{detail:n,context:{path:e.path}});let A=crypto.randomUUID();return W6e.value=[...W6e.value,{...e,id:A}],WKe(),()=>{W6e.value=W6e.value.filter((i)=>i.id!==A),WKe()}},get commands(){return W6e.value},key(e,n){if(bBt.value.has(e))throw Pn("KEY_CHORD_TAKEN",{detail:e,context:{chord:e}});bBt.value.set(e,n),WKe();let A=!1;return()=>{if(A)return;A=!0,bBt.value.delete(e),WKe()}},keyHandler(e){return bBt.value.get(e)??null},chords:uA.computed(()=>{return Z6e.value,[...bBt.value.keys()]}),palette(e,n){if(z6e.value.has(e))throw Pn("PALETTE_NAME_TAKEN",{detail:e,context:{name:e}});let A={name:e,definition:n,cache:null};z6e.value.set(e,A);let i=null;if(n.key){let s=CBt.value.get(n.key);if(s)throw z6e.value.delete(e),Pn("MODE_KEY_TAKEN",{detail:`${n.key} is bound to "${s}"`,context:{key:n.key,name:e,taken:s}});CBt.value.set(n.key,e),i=()=>{CBt.value.delete(n.key)}}return WKe(),()=>{z6e.value.delete(e),i?.(),WKe()}},paletteFor(e){return Z6e.value,z6e.value.get(e)??null},paletteForKey(e){Z6e.value;let n=CBt.value.get(e);return n?z6e.value.get(n)??null:null},names:uA.computed(()=>{return Z6e.value,[...z6e.value.keys()]}),modeKeys:uA.computed(()=>{return Z6e.value,[...CBt.value.entries()].map(([e,n])=>({key:e,name:n}))})};F8t=uA.computed(()=>{return Z6e.value,W6e.value,$fr()})});function iYa(e,n){if(n.prefix===void 0)return!1;if(!e.endsWith(n.prefix))return!1;let A=e[e.length-n.prefix.length-1];return A===void 0||A===" "}function rYa(e,n){if(n.resolve!=="splice")return null;let A=zfr(e,n);if(A===-1)return null;let i=e.slice(A+n.key.length);if(/\s/.test(i))return null;return{start:A,query:i}}function oYa(e,n){let A=(n.prefix??"")+n.key;if(!e.endsWith(A))return-1;let i=e.length-A.length,s=e[i-1];return s===void 0||s===" "?i:-1}function zfr(e,n){for(let A=e.length-1;A>=0;A--){if(e[A]!==n.key)continue;let i=e[A-1];if(i===void 0||i===" ")return A}return-1}var X6e;var YSn=xt(()=>{X6e=[{mode:"voice",key:"#",prefix:">",resolve:"append"},{mode:"file",key:"@",resolve:"splice"}]});function BBt(e){return!Wfr.has(e)}function cYa(e,n=()=>!0){let A=uA.ref("normal"),i=uA.ref(!1),s=uA.ref(null),u=uA.ref(0),p=null;uA.watch([A,i],([y,k])=>{if((y==="loading"||k)&&!p)p=setInterval(()=>{u.value++},80);else if(y!=="loading"&&!k&&p)clearInterval(p),p=null}),uA.onUnmounted(()=>{if(p)clearInterval(p)});let d=uA.computed(()=>{if(i.value||A.value==="loading")return sYa[u.value%sYa.length];let y=IBt[A.value];if(y)return y;let k=M1.paletteFor(A.value);return k?.definition.symbol??k?.definition.key??Zfr});function b(y){A.value=y}function E(){for(let[y,k]of Object.entries(vne))fh(y,(x)=>{if(!n())return;if(A.value==="loading")return;if(A.value==="voice"&&k==="voice"){s.value="confirm",A.value="normal",x.consumed=!0;return}if(e().length>0)return;A.value=A.value===k?"normal":k,x.consumed=!0});fh("up",(y)=>{if(!n())return;if(A.value!=="normal")return;if(e().length>0)return;A.value="history",y.consumed=!0})}return{mode:A,symbol:d,processing:i,setMode:b,voiceExitReason:s,bindKeys:E}}var vne,Ayo,Wfr,v8t,IBt,Zfr="\xB7",sYa;var eLe=xt(()=>{Fs();V6e();YSn();vne={":":"command","/":"instance","*":"model","^":"session","~":"agent","#":"voice","?":"help",">":"prompt","%":"module",'"':"theme"},Ayo=new Set(X6e.map((e)=>e.mode)),Wfr=new Set(["normal","loading","voice"]);v8t={command:"run app commands",instance:"switch to a running conversation",session:"reopen a past session",agent:"start an agent",model:"set the agent's model",voice:"voice input via microphone",help:"show this help",prompt:"insert a prompt into your message",module:"manage agent modules",theme:"switch colour theme",file:"reference a file in your message"},IBt={normal:"\xBB",command:":",instance:"/",model:"*",session:"^",agent:"~",voice:"#",help:"?",history:"\u2191",loading:"\u280B",escalation:"\u203C",prompt:">",module:"%",theme:'"',file:"@",question:"\xB7"},sYa=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]});var uYa={};OA(uYa,{useQuestions:()=>e6});function e6(){if(!jSn)jSn=Vfr();return jSn}function Vfr(){function e(n){if(tLe.value)throw Pn("PALETTE_ALREADY_OPEN",{detail:"a question is already open"});return new Promise((A)=>{let i=(s)=>{if(!tLe.value)return;tLe.value=null,A(s)};tLe.value={...n(i),settle:i}})}return{pending:uA.computed(()=>tLe.value),cancel(){let n=tLe.value;if(!n)return;n.settle(n.kind==="confirm"?!1:void 0)},submitText(n){let A=tLe.value;if(A?.kind!=="prompt")return;A.settle(n.length>0?n:void 0)},async pick(n,A){return e((i)=>({kind:"pick",message:A?.placeholder??"",items:n.map((s,u)=>{let p=typeof s==="string",d=p?s:s.label,b=p?s:s.value;return{id:`pick-${u}`,label:d,...p?{}:s.description?{description:s.description}:{},action:()=>{i(b)}}})}))},async confirm(n,A){return e((i)=>({kind:"confirm",message:n,...A?.header?{header:A.header}:{},items:[{id:"yes",label:A?.choices?.yes??"yes",action:()=>{i(!0)}},{id:"no",label:A?.choices?.no??"no",action:()=>{i(!1)}}]}))},async prompt(n,A){return e(()=>({kind:"prompt",message:n,items:[],...A?.prompt?{prompt:A.prompt}:{},...A?.header?{header:A.header}:{},...A?.placeholder?{placeholder:A.placeholder}:{},...A?.secret?{secret:!0}:{}}))}}}var tLe,jSn;var nLe=xt(()=>{Fs();qs();tLe=uA.ref(null)});function TIe(){if(!HSn)HSn=Xfr();return HSn}function Xfr(){function e(n,A){let i=BAe.value.find((s)=>s.id===n);if(!i)return;BAe.value=BAe.value.filter((s)=>s.id!==n),i.settle(A)}return{current:uA.computed(()=>BAe.value[0]??null),waiting:uA.computed(()=>Math.max(0,BAe.value.length-1)),ask(n){return new Promise((A)=>{BAe.value=[...BAe.value,{...n,settle:A}]})},answer(n,A=!1){let i=BAe.value[0];if(i)e(i.id,{allow:n,always:A})},denyAll(){let n=BAe.value;BAe.value=[];for(let A of n)A.settle({allow:!1,always:!1})}}}var BAe,HSn;var S8t=xt(()=>{Fs();BAe=uA.ref([])});function ehr(e,n,A){return`${e}\x00${n}\x00${A??""}`}function OSn(e){return{id:e.id,label:e.label,...e.description!==void 0?{description:e.description}:{},...e.chunks!==void 0?{chunks:e.chunks}:{},...e.descendQuery!==void 0?{descendQuery:e.descendQuery}:{},...e.workingMessage!==void 0?{workingMessage:e.workingMessage}:{},...e.detach!==void 0?{detach:e.detach}:{},...e.header!==void 0?{header:e.header}:{},...e.separator!==void 0?{separator:e.separator}:{},...e.preview!==void 0?{preview:e.preview}:{},...e.choices!==void 0?{choices:()=>e.choices().map(OSn)}:{},action:e.action??(()=>{})}}function thr(e){if(Array.isArray(e))return{items:e.map(OSn)};return{items:e.items.map(OSn),...e.breadcrumb!==void 0?{breadcrumb:e.breadcrumb}:{},...e.status!==void 0?{status:e.status}:{},...e.invalid!==void 0?{invalid:e.invalid}:{}}}function nhr(e,n,A){let i=ehr(e.name,n,A);lYa.value;let s=PSn.value.get(i);if(s)return{items:s.items,...s.breadcrumb!==void 0?{breadcrumb:s.breadcrumb}:{},...s.status!==void 0?{status:s.status}:{},...s.invalid!==void 0?{invalid:s.invalid}:{}};if(!JSn.has(i))JSn.add(i),(async()=>{try{let u=await e.definition.list(n,A);PSn.value.set(i,{key:i,...thr(u)})}catch(u){PSn.value.set(i,{key:i,items:[],status:{kind:"error",message:u instanceof Error?u.message:String(u)}})}finally{JSn.delete(i),lYa.value++}})();return{items:[],status:{kind:"loading",message:"loading..."}}}function gYa(e){return{id:e,resolve:uA.computed(()=>(n,A)=>{let i=e6().pending.value;if(i)return{items:i.items,...i.message?{breadcrumb:i.message}:{}};let s=M1.paletteFor(e);if(!s)return{items:[]};return nhr(s,n,A)}),get skipDefaultFilter(){return M1.paletteFor(e)?.definition.filter===!1},get tabs(){return M1.paletteFor(e)?.definition.tabs},get anchor(){return M1.paletteFor(e)?.definition.anchor},get maxHeight(){return M1.paletteFor(e)?.definition.maxHeight}}}var PSn,JSn,lYa,ZKe="escalation",pYa,VKe="question",mYa;var $Sn=xt(()=>{Fs();V6e();nLe();S8t();PSn=uA.ref(new Map),JSn=new Set,lYa=uA.ref(0);pYa={id:ZKe,skipDefaultFilter:!0,resolve:uA.computed(()=>()=>{let e=TIe(),n=e.current.value;if(!n)return{items:[]};let A=e.waiting.value;return{items:[{id:"allow",label:"allow once",description:"just this call",action:()=>{e.answer(!0)}},{id:"always",label:"allow always",description:"remember this \u2014 revoke with :policy grants",action:()=>{e.answer(!0,!0)}},{id:"deny",label:"deny",description:"refuse this call",action:()=>{e.answer(!1)}}],header:{label:n.fn,detail:`"${n.subject}"`+(A>0?` (${A} more waiting)`:"")}}})},mYa={id:VKe,skipDefaultFilter:!0,resolve:uA.computed(()=>(e)=>{let n=e6().pending.value;if(!n)return{items:[]};if(n.kind==="prompt"){let A=e.length>0;return{items:[{id:"prompt",label:n.prompt??"waiting for input",placeholder:!n.prompt,description:A?"enter to confirm":"esc to cancel",action:()=>{}}],...n.header?{header:n.header}:{breadcrumb:n.message}}}return{items:n.items,...n.header?{header:n.header}:n.message?{breadcrumb:n.message}:{}}})}});function fYa(e){dYa.set(e.id,e)}function N8t(e){let n=dYa.get(e);if(n)return n;if(e===VKe)return mYa;if(e===ZKe)return pYa;return M1.paletteFor(e)?gYa(e):void 0}var dYa;var hYa=xt(()=>{V6e();$Sn();dYa=new Map});function ahr(e,n){if(e.length===0)return!0;if(e.length>n.length)return!1;let A=0;for(let i of n)if(i===e[A]){if(A++,A===e.length)return!0}return!1}function Ahr(e,n){if(n===e)return 100;if(n.startsWith(e))return 75;if(n.includes(e))return 50;if(e.length>=ihr&&n.length<=e.length*rhr){if(ahr(e,n))return 25}return null}function aLe(e,n){let A=e.toLowerCase().split(/[\s:]+/).filter(Boolean);if(A.length===0)return 0;let i=n.map((u)=>u.toLowerCase()),s=0;for(let u of A){let p=null;for(let d of i){let b=Ahr(u,d);if(b!==null&&(p===null||b>p))p=b}if(p===null)return null;s+=p}return s}var ihr=3,rhr=4;function xJ(e,n){let A=e[n];return!!A&&!A.header&&!A.separator&&!A.invalid}function bYa(e){let{items:n,previous:A,selectedIndex:i,homeIndex:s}=e,u=A?.[i],p=u!==void 0&&n[i]?.id!==u.id;if(!(i>=n.length||!xJ(n,i))&&!p)return i;let b=u?n.findIndex((E)=>E.id===u.id):-1;return b>=0&&xJ(n,b)?b:s}function CYa(e){return typeof e.children==="function"?e.children():e.children}function ohr(e,n){let A=e.label.toLowerCase(),i=e.description.toLowerCase();if(A===n)return 5;if(A.split("/").at(-1)===n)return 4;if(A.startsWith(n))return 3;if(A.includes(n))return 2;if(i.includes(n))return 1;return 0}function shr(e,n){let A=n.toLowerCase();return e.map((i,s)=>({node:i,index:s,score:ohr(i,A)})).filter((i)=>i.score>0).sort((i,s)=>s.score-i.score||i.index-s.index).map((i)=>i.node)}function BYa(e,n){let A=e.endsWith(" "),i=e.split(" "),s=i.map((k)=>k.toLowerCase()),u=n,p=[],d=A?s.length:s.length-1;for(let k=0;k<d;k++){let x=s[k];if(!x)continue;let S=u.find((L)=>L.label.toLowerCase()===x);if(!S)return{nodes:[],breadcrumb:p,partial:x,exactMatch:null,noMatch:!0,input:null};if(S.kind==="action")return{nodes:[],breadcrumb:p,partial:"",exactMatch:S,noMatch:!1,input:null};if(S.kind==="input")return{nodes:[],breadcrumb:[...p,S.label],partial:"",exactMatch:null,noMatch:!1,input:{node:S,value:i.slice(k+1).join(" ").trim()}};p.push(S.label),u=CYa(S)}let b=A?"":s[s.length-1]??"",E=b?shr(u,b):u;if(b&&E.length===0)return{nodes:E,breadcrumb:p,partial:b,exactMatch:null,noMatch:!0,input:null};let y=b?E.find((k)=>k.label.toLowerCase()===b.toLowerCase())??null:null;if(y&&y.kind==="group")return{nodes:CYa(y),breadcrumb:[...p,y.label],partial:"",exactMatch:null,noMatch:!1,input:null};return{nodes:E,breadcrumb:p,partial:b,exactMatch:y,noMatch:!1,input:null}}function IYa(e,n){return[...e,n].join(" ")+" "}function G8t(e){if(e.length===0)return null;let n=3,A=e.length>n?e.slice(-n):e;return(e.length>n?"\u2026 \u203A ":"")+A.join(" \u203A ")+" \u203A"}import{existsSync as chr}from"fs";import{join as EYa,resolve as uhr}from"path";import{homedir as yYa}from"os";function lhr(){let e=IC();function n(){let b=e.store.profiles.active();if(!b)throw Pn("NOT_AUTHENTICATED");return b}function A(b){let E=yYa();return b===E||b.startsWith(E+"/")?"~"+b.slice(E.length):b}function i(){let b=n(),E={dir:EYa(e.store.root,"profiles",b.id,"agents"),label:"~/.axon (default)"},y=b.agents.extraRoots().map((k)=>({dir:k,label:A(k)}));return[E,...y]}function s(){let b=e.store.profiles.active();if(!b)return[];return b.agents.extraRoots().map((E)=>({dir:E,label:A(E)}))}async function u(b,E){await e.projects.create("agent",{name:b,dir:E})}async function p(b){let E=uhr(b.startsWith("~")?EYa(yYa(),b.slice(1)):b);if(!chr(E))throw Pn("WATCH_PATH_NOT_FOUND",{context:{path:E}});return await n().agents.watch(E),Uc().refreshAvailable(),E}async function d(b){await n().agents.unwatch(b),Uc().refreshAvailable()}return{locations:i,watched:s,create:u,watch:p,unwatch:d}}function XKe(){if(!zSn)zSn=lhr();return zSn}var zSn;var QYa=xt(async()=>{qs();await Qk([a3(),Ek()])});function UIe(){if(!WSn)WSn=phr();return WSn}function phr(){let e=uA.ref(null),n=0,A=null,i=!1,s=null,u=!1,p=null;function d(k){s=k}function b(k){p=k}function E(){if(i)return!0;if(p?.(),n++,A)clearTimeout(A);if(n===1)return e.value="press ctrl+c again to quit",A=setTimeout(()=>{n=0,e.value=null},ghr),!1;if(n===2)return y(),!1;return process.exit(130),!1}async function y(k=0){if(u)return;if(u=!0,n=Math.max(n,2),A)clearTimeout(A);e.value="shutting down \xB7 ctrl+c to force quit";let x=process.env.AXON_SHUTDOWN_TRACE==="1",S=Date.now(),L=(V)=>{if(x)process.stderr.write(`[exit] ${V} +${Date.now()-S}ms
|
|
5046
|
+
`,"utf-8"),await gfr(S,p)}catch(x){throw e.store.update.state.set({status:"failed",from:k.current,to:k.latest,updatedAt:new Date().toISOString(),error:x instanceof Error?x.message:String(x)}),x}return k}return{currentVersion:n,supported:d,check:b,handoff:E}}function N5a(e){let n=e;try{n=ufr(e)}catch{}return mfr(S5a(n),"update-helper.js")}var uBt;var G5a=xt(()=>{_Sn();qs();uBt=fp(txn(),1)});var M5a=()=>{};var C8t=xt(()=>{G5a();M5a();_Sn()});import{join as dfr,resolve as ffr}from"path";function lBt(e){let n=ffr(e.cwd??process.cwd()),A=e.distribution??hfr,i={},s=RQn({root:e.store??KQn(A),settings:()=>i,setSetting:async(be,ce)=>{let ke=await me.setSetting(be,ce);return await ee(),ke}}),u=Pka({store:s,distribution:A}),p=jQn(),d=e0a(),b=n0a({root:n}),E=VFn();async function y(){let be=s.profiles.active()?.root;if(!be)return;let{providers:ce}=await R6e(be);return ce}let k=CSn({budget:()=>{return}}),x=tvn({cloud:u.client,profileProviders:()=>y(),frameworkVersion:e.version,...e.frameworkSource?{frameworkSource:e.frameworkSource}:{},...e.repoRoot?{repoRoot:e.repoRoot}:{},bench:{tests:E,clone:(be,ce,ke)=>L.clone(be,ce,ke),prepare:async(be)=>{await(await x.open(be)).prepare()}}}),S=cSn({store:s,projects:x,cloud:u.client,cwd:n,clone:(be,ce,ke)=>L.clone(be,ce,ke),...e.control?{control:e.control}:{}}),L=w5a({cloud:u.client,async prepare(be){await(await x.open(be)).prepare()}}),U=F5a({cache:_5a({cloud:u.client,root:s.root})}),$=wSn({cloud:u.client,store:s,currentVersion:e.version}),V=Oka({cloud:u.client}),te=lSn({store:s,projects:x,frameworkVersion:e.version});async function ee(){try{i=await me.settings()}catch{i={}}}let me=Evn({root:()=>te.root,install:async(be,ce)=>{return{version:(await L.clone(be,dfr(ce,".."),{dir:ce.split("/").at(-1)})).version}},latest:async(be)=>(await u.client.registry.artifacts.resolve(be)).version});return{cloud:u,store:s,deployments:V,projects:x,profile:te,extensions:me,refreshSettings:ee,agents:S,registry:L,prompts:U,tests:E,mic:d,files:b,ollama:p,resources:k,updates:$}}var hfr="production";var L5a=xt(async()=>{Mwa();Hwa();PQn();a0a();Jka();XCt();n8t();B5a();XFn();k5a();v5a();C8t();await gSn()});function $Ke(e,n){let A=new Map;for(let s of e)switch(s.type){case"process:proc:start":{let u=s.data;A.set(u.procId,{procId:u.procId,kind:u.kind,command:u.command,pid:u.pid,cwd:u.cwd,status:"running",startedAt:typeof s.at==="number"?s.at:Date.now(),output:[]});break}case"process:proc:complete":{let u=s.data,p=A.get(u.procId);if(!p)break;if(p.status="exited",p.exitCode=u.code,typeof s.at==="number")p.endedAt=s.at;break}case"process:proc:failed":{let u=s.data,p=A.get(u.procId);if(!p)break;if(p.status="exited",typeof s.at==="number")p.endedAt=s.at;break}case"process:proc:denied":{let u=s.data,p=A.get(u.procId);if(p){p.status="exited",p.exitCode=-1;break}A.set(u.procId,{procId:u.procId,kind:"managed",command:u.command,status:"exited",exitCode:-1,startedAt:typeof s.at==="number"?s.at:Date.now(),output:[]});break}}let i=[...A.values()].sort((s,u)=>s.startedAt-u.startedAt);if(!n?.main)return i;return[{procId:"main",kind:"main",command:"agent \xB7 ts runtime",...n.main.pid!==void 0?{pid:n.main.pid}:{},status:n.main.status,startedAt:n.main.startedAt??i[0]?.startedAt??Date.now(),main:!0,output:[]},...i]}var q5a=async()=>{};var B8t=xt(async()=>{await Qk([L5a(),q5a(),Zvn()])});var J6e;var I8t=xt(()=>{J6e={name:"@arcforge/axon",version:"2.0.158",description:"coding agent cli",module:"index.ts",type:"module",scripts:{build:"vterm build",deploy:"bun run scripts/release.ts patch","deploy:major":"bun run scripts/release.ts major","deploy:minor":"bun run scripts/release.ts minor","deploy:patch":"bun run scripts/release.ts patch",dev:"vterm dev","dev:local":"vterm dev --dotenv .env.local",prepare:"vterm prepare",tail:"vterm tail",test:"bun test --parallel=4 --path-ignore-patterns='**/tests/perf/**'","test:perf":"bun test tests/perf","test:serial":"bun test --path-ignore-patterns='**/tests/perf/**'","test:watch":"bun test --watch",typecheck:"bun run scripts/typecheck.ts"},dependencies:{"@arcforge/cognet":"workspace:*","@arcforge/engines":"workspace:*","@arcforge/err":"workspace:*","@arcforge/platform":"workspace:*","@arcforge/types":"workspace:*","@arcforge/vterm":"workspace:*","@arclabs/cloud":"workspace:*","@arclabs/repo":"workspace:*","@arclabs/tools":"workspace:*","@axon/capsule":"workspace:*","@axon/core":"workspace:*","@axon/theme":"workspace:*","@axon/vstr":"workspace:*","@vue/compiler-sfc":"3.5.39",arcline:"workspace:*",chalk:"^5.6.2","fft.js":"^4.0.4",h3:"^1.15.11","markdown-it":"^14.3.0",open:"^11.0.0",semver:"^7.7.4",sharp:"^0.35.3"},devDependencies:{"@types/bun":"latest","@types/markdown-it":"^14.1.2","@types/semver":"^7.7.1","@vue/typescript-plugin":"^3.2.5",postgres:"^3.4.5"},peerDependencies:{typescript:"^5"},bin:{axon:"./bin/axon"}}});function E8t(e,n){let A=e;for(let i of n){if(A===null||typeof A!=="object"||!(i in A))throw Pn("CONTROL_PATH_NOT_FOUND",{detail:`no such method on the peer: ${n.join(".")}`,context:{path:n.join(".")}});A=A[i]}return A}function y8t(e){let n=new Map,A=new Map,i=new Map,s=!1,u=0,p=()=>`${++u}`;async function d(k){try{let x=E8t(e.handle,k.path.slice(0,-1)),S=E8t(e.handle,k.path);if(typeof S!=="function")throw Pn("CONTROL_PATH_NOT_CALLABLE",{detail:`not callable on the peer: ${k.path.join(".")}`,context:{path:k.path.join(".")}});let L=await S.apply(x,k.args);e.send({type:"rpc.result",id:k.id,ok:!0,value:L})}catch(x){e.send({type:"rpc.result",id:k.id,ok:!1,error:x instanceof Error?x.message:String(x)})}}function b(k){try{let x=E8t(e.handle,k.path.slice(0,-1)),S=E8t(e.handle,k.path);if(typeof S!=="function")throw Pn("CONTROL_PATH_NOT_CALLABLE",{detail:`not callable on the peer: ${k.path.join(".")}`,context:{path:k.path.join(".")}});let L=($)=>e.send({type:"rpc.event",id:k.id,value:$}),U=S.apply(x,[...k.args,L]);A.set(k.id,U)}catch(x){e.send({type:"rpc.result",id:k.id,ok:!1,error:x instanceof Error?x.message:String(x)})}}function E(k){A.get(k.id)?.(),A.delete(k.id)}function y(k){let x=n.get(k.id);if(!x)return;if(n.delete(k.id),k.ok)x.resolve(k.value);else x.reject(Pn("CONTROL_CALL_FAILED",{detail:k.error,context:{error:k.error}}))}return{accept(k){if(k.type==="rpc.call")return void d(k);if(k.type==="rpc.subscribe")return b(k);if(k.type==="rpc.unsubscribe")return E(k);if(k.type==="rpc.result")return y(k);i.get(k.id)?.(k.value)},call(k,x=[]){if(s)return Promise.reject(Pn("CONTROL_CLOSED",{detail:`channel closed before ${k.join(".")} could be sent`,context:{path:k.join(".")}}));let S=p();return new Promise((L,U)=>{n.set(S,{resolve:L,reject:U}),e.send({type:"rpc.call",id:S,path:k,args:x})})},subscribe(k,x,S){if(s)throw Pn("CONTROL_CLOSED",{detail:`channel closed before ${k.join(".")} could be sent`,context:{path:k.join(".")}});let L=p();return i.set(L,S),e.send({type:"rpc.subscribe",id:L,path:k,args:x}),()=>{if(!i.delete(L))return;if(!s)e.send({type:"rpc.unsubscribe",id:L})}},close(k){if(s)return;s=!0;for(let x of A.values())x();A.clear(),i.clear();for(let x of n.values())x.reject(Pn("CONTROL_CLOSED",{detail:k,context:{error:k}}));n.clear()}}}var Q8t=xt(()=>{qs()});function kSn(e){if(typeof e!=="object"||e===null)return!1;let n=e.type;return n==="rpc.call"||n==="rpc.result"||n==="rpc.subscribe"||n==="rpc.unsubscribe"||n==="rpc.event"}import{randomBytes as Bfr}from"crypto";function gBt(e){let n=Bfr(32).toString("hex"),A=null,i=new Set;function s(){for(let b of i)b(u.size)}let u=new Map;function p(b,E){let y=u.get(b);if(!y)return;y.dispatch.close(E),u.delete(b),s()}async function d(b){let E=[...u.values()];if(E.length===0)throw Pn("CONTROL_CLOSED",{detail:"no editor attached"});if(E.length===1)return E[0].dispatch;let y=await Promise.all(E.map(async(k)=>{try{let x=await k.dispatch.call(["editor","claim"],[b??null]);return{dispatch:k.dispatch,contains:x?.contains===!0,focusedAt:x?.focusedAt??0}}catch{return{dispatch:k.dispatch,contains:!1,focusedAt:0}}}));return y.sort((k,x)=>k.contains!==x.contains?k.contains?-1:1:x.focusedAt-k.focusedAt),y[0].dispatch}return{token:n,get port(){return A?.port??null},get attached(){return u.size>0},get peerCount(){return u.size},watch(b){return i.add(b),()=>{i.delete(b)}},listen(){if(A)return A.port;return A=Bun.serve({port:e.port??0,hostname:"127.0.0.1",fetch(b,E){if(E.upgrade(b,{data:null}))return;return new Response("axon control channel",{status:426})},websocket:{message(b,E){let y;try{y=JSON.parse(String(E))}catch{b.close(1003,"malformed frame");return}let k=u.get(b);if(!k){let x=y;if(x?.type!=="control.hello"||x.token!==n){b.close(1008,"unauthorized");return}let S={send:(L)=>b.send(L),close:()=>b.close()};u.set(b,{socket:S,dispatch:y8t({handle:e.handle,send:(L)=>S.send(JSON.stringify(L))})}),b.send(JSON.stringify({type:"control.welcome",peer:"tui"})),s();return}if(!kSn(y))return;k.dispatch.accept(y)},close(b){p(b,"editor disconnected")}}}),A.port},editor:{async call(b,...E){return await(await d()).call(["editor",String(b)],E)},async about(b,E,...y){return await(await d(b)).call(["editor",String(E)],y)}},close(){for(let[b,E]of u)p(b,"tui shutting down"),E.socket.close();A?.stop(!0),A=null}}}var T5a=xt(()=>{qs();Q8t()});var U5a=xt(()=>{qs();Q8t()});var DSn=xt(()=>{T5a();U5a();Q8t()});function _8t(){let e=(n)=>{let A=R5a[n];if(!A)throw Error(`TUI_NOT_READY: this TUI cannot ${n} yet \u2014 it is still starting up`);return A};return{send:(n)=>e("send")(n),interrupt:()=>e("interrupt")(),focus:(n)=>e("focus")(n),capsule:(n,A)=>e("capsule")(n,A),lastActiveAt:async()=>K5a}}function Y5a(e){R5a=e}function xSn(){K5a=Date.now()}var R5a,K5a;var pBt=xt(()=>{R5a={},K5a=Date.now()});function bAe(){if(!FSn)FSn=Ifr();return FSn}function Ifr(){let e=null,n=uA.ref(0);function A(){if(e)return;let b=gBt({handle:{tui:_8t()}});b.watch(()=>{n.value++}),b.listen(),e=b}function i(){let b=e?.port;if(!e||b===null||b===void 0)return null;return{port:b,token:e.token}}let s=uA.computed(()=>{return n.value,(e?.peerCount??0)>0});async function u(b,...E){if(!e)throw Error("CONTROL_NOT_LISTENING: this TUI is not serving a control channel");return e.editor.call(b,...E)}async function p(b,E,...y){if(!e)throw Error("CONTROL_NOT_LISTENING: this TUI is not serving a control channel");return e.editor.about(b,E,...y)}function d(){e?.close(),e=null,n.value++}return{listen:A,control:i,available:s,editor:u,editorAbout:p,close:d}}var FSn;var w8t=xt(()=>{Fs();DSn();pBt()});function IC(){if(!vSn)vSn=lBt({version:J6e.version,cwd:process.env.PWD??process.cwd(),control:()=>bAe().control()});return vSn}var vSn=null;var a3=xt(async()=>{I8t();w8t();await B8t()});function Efr(e,n){let A=uA.ref("idle"),i=uA.ref(null),s=uA.ref(null),u=uA.ref(0);function p(){u.value++}function d(me,be,ce){let ke=uA.ref(!1),Te=uA.ref(null),Ze=uA.ref(!1);async function nt(){if(!e.authenticated){Ze.value=!1;return}let gt=await me.status();Ze.value=gt.connected&>.status==="active"}nt().catch((gt)=>{Te.value=gt instanceof Error?gt:Error(String(gt))});async function je(...gt){ke.value=!0,Te.value=null;try{if(await be(...gt),ce)await IC().extensions.addProvider(ce);Ze.value=!0}catch(Oe){throw Te.value=Oe instanceof Error?Oe:Error(String(Oe)),Oe}finally{ke.value=!1,p()}}async function Xe(){if(await me.disconnect(),ce)await IC().extensions.removeProvider(ce);Ze.value=!1,p()}return{connected:Ze,connecting:ke,error:Te,connect:je,disconnect:Xe,refreshStatus:nt}}let b=d(e.connections.openai,()=>e.connections.openai.connect({open:(me)=>{Uhe(me)}}),"Codex"),E=d(e.connections.openrouter,(me)=>e.connections.openrouter.connect({key:me}),"OpenRouter");function y(me){let be=uA.ref(!1),ce=uA.ref(!1),ke=uA.ref(null);async function Te(){let je=await IC().extensions.readProviders();be.value=je.includes(me)}Te().catch((je)=>{ke.value=je instanceof Error?je:Error(String(je))});async function Ze(){ce.value=!0,ke.value=null;try{await IC().extensions.addProvider(me),be.value=!0}catch(je){throw ke.value=je instanceof Error?je:Error(String(je)),je}finally{ce.value=!1,p()}}async function nt(){await IC().extensions.removeProvider(me),be.value=!1,p()}return{connected:be,connecting:ce,error:ke,connect:Ze,disconnect:nt,refreshStatus:Te}}let k=y("Ollama"),x=uA.ref(e.authenticated?"checking":"signed-out"),S=uA.computed(()=>{return u.value,x.value==="verified"});async function L(){if(!e.authenticated)return x.value="signed-out",p(),x.value;x.value="checking",p();try{let me=await e.validate();x.value=me==="valid"?"verified":me==="rejected"?"signed-out":"unreachable"}catch{x.value="unreachable"}return p(),x.value}if(x.value==="checking")L();e.onSessionExpired(()=>{x.value="signed-out",p()});let U=uA.computed(()=>{return u.value,e.client.user.auth.user}),$=uA.computed(()=>{return u.value,n.profiles.list().flatMap((me)=>{let be=n.profiles.get(me).record.get();if(!be)return[];let ce=!!(be.auth.accessToken||be.auth.apiKey);return[{id:me,email:be.user.email,authenticated:ce}]})});async function V(me){A.value="authorizing",i.value=null;try{await e.login({...me!==void 0?{hint:me}:{},onCode:(be)=>{i.value=be,A.value="polling",Uhe(be.verificationUriComplete)}}),x.value="verified"}finally{A.value="idle",i.value=null,p()}}async function te(me){s.value=me;try{return await e.switch(me),x.value="verified","verified"}catch(be){let ce=P1t(be)&&be.code==="AX-TUI-044";return x.value=ce?"unreachable":"signed-out",ce?"unreachable":"rejected"}finally{s.value=null,p()}}async function ee(){await e.logout(),x.value="signed-out",p()}return{isAuthenticated:S,gate:uA.computed(()=>x.value),verify:L,identity:U,profiles:$,loginStatus:A,deviceAuthorization:i,switchingProfileId:s,startLogin:V,switchProfile:te,logout:ee,connections:{openai:b,openrouter:E,ollama:k}}}function b8(){if(!SSn){let e=IC();SSn=Efr(e.cloud,e.store)}return SSn}var SSn;var MIe=xt(async()=>{Fs();Xft();qs();await a3()});var LSn={};OA(LSn,{useSettings:()=>fBt});function Nfr(){let e=IC();async function n(){try{dBt.value=await e.extensions.settings()}catch{dBt.value={}}GSn.value++}return{settings:uA.computed(()=>{return GSn.value,dBt.value}),refresh:n,async set(A,i){dBt.value={...dBt.value,[A]:i},GSn.value++,await e.extensions.setSetting(A,i)}}}function fBt(){if(!MSn)MSn=Nfr();return MSn}var dBt,GSn,MSn;var hBt=xt(async()=>{Fs();await a3();dBt=uA.ref({}),GSn=uA.ref(0)});var USn={};OA(USn,{useTheme:()=>nE,DEFAULT_THEME_NAME:()=>D8t});async function Mfr(e){try{let{useSettings:n}=await hBt().then(() => LSn);await n().set("theme",e)}catch{}}function qIe(e){return Fne.value.find((n)=>n.name===e)??null}function J5a(e){let n=qIe(e);if(!n)throw Error(`no theme named "${e}"`);DJ.value=e,qSn.value=e,LIe.value=null,$6e(n),Mfr(e)}function $6e(e){Aqe.register(Gfr,{":root":{cssVariables:kgn(e)}}),vgt({theme:e.syntax==="arcnight"?rQt:e.syntax}),O6e.value++,TSn?.()}function nE(){if(!TSn)try{TSn=HC()}catch{}return{themes:uA.computed(()=>{return O6e.value,Fne.value}),active:uA.computed(()=>{return O6e.value,qIe(DJ.value)??Fne.value[0]}),committedName:uA.computed(()=>LIe.value??DJ.value),themeClass:uA.computed(()=>{return O6e.value,`theme-${DJ.value}`}),create(e){if(qIe(e.name))throw Error(`theme "${e.name}" is already registered`);if(Fne.value=[...Fne.value,e],O6e.value++,qSn.value===e.name)DJ.value=e.name,$6e(e);return()=>{if(Fne.value=Fne.value.filter((n)=>n.name!==e.name),DJ.value===e.name)DJ.value=Fne.value[0].name,$6e(Fne.value[0]);O6e.value++}},set:J5a,reset(){J5a(D8t)},preview(e){let n=qIe(e);if(!n)return;if(LIe.value===null)LIe.value=DJ.value;DJ.value=e,$6e(n)},cancelPreview(){if(LIe.value===null)return;let e=qIe(LIe.value);if(DJ.value=LIe.value,LIe.value=null,e)$6e(e)},mount(){let e=qIe(DJ.value)??Fne.value[0];$6e(e)},adopt(e){if(!e)return;qSn.value=e;let n=qIe(e);if(!n)return;DJ.value=e,$6e(n)},colors:uA.computed(()=>{O6e.value;let e=qIe(DJ.value)??Fne.value[0];return{primary:String(e.primary),background:String(e.background),text:String(e.text),dim:String(e.dim),warn:String(e.warn),error:String(e.error)}})}}var Gfr="axon:theme:tokens",D8t,Fne,DJ,LIe,qSn,O6e,TSn=null;var A3=xt(()=>{Fs();Fs();Dgn();D8t=Fgt[0].name,Fne=uA.ref([...Fgt]),DJ=uA.ref(Fgt[0].name),LIe=uA.ref(null),qSn=uA.ref(null),O6e=uA.ref(0)});function O5a(){let e=0;return{claim(){let n=++e;return{get latest(){return e===n}}}}}function $5a(e){for(let n=e.length-1;n>=0;n--){let A=e[n];if(A.type!=="kernel:engine:complete")continue;let i=A.data?.meta?.model;if(typeof i==="string")return i}return null}function z5a(e){let n=gne(e??void 0);if(!n)return null;if(n.provider!==void 0&&n.provider!=="axon")return null;if(n.model!=="auto")return null;return{model:"auto"}}function x8t(e){let{provider:n,declared:A,resolved:i}=e;if(!A)return n;let s=`${n}/${A}`;if(A!=="auto")return s;if(!i||i==="auto")return s;return`${i} (${A})`}var W5a=xt(()=>{pRe()});function Lfr(e,n,A){if(A<=0||n<=0)return;let i=n/A,s=RSn.get(e);RSn.set(e,s===void 0?i:s*0.7+i*0.3)}function qfr(e){return(e?RSn.get(e):void 0)??4.5}function Z5a(e,n=[]){let A=null,i=null,s=null,u=-1;for(let d=e.length-1;d>=0;d--){let b=e[d];if(b.type==="kernel:engine:complete"){let E=b.data?.meta;if(A??=E.model,E.tokens){i=E.tokens.in+E.tokens.out,u=b.time.seq;break}continue}if(b.type==="kernel:engine:input"){s=b.data?.bytes??s,u=b.time.seq,A??=Tfr(e,d);break}}if(i===null&&s===null)return null;if(i!==null){let d=Ufr(e,u);if(A&&d!==null)Lfr(A,d,i);return{tokens:i,model:A}}let p=Rfr(n,u);return{tokens:Math.round(s/qfr(A))+Math.round(p/3.3),model:A}}function Tfr(e,n){for(let A=n;A>=0;A--){let i=e[A];if(i.type==="kernel:engine:start"){let s=i.data.model;if(s)return s}if(i.type==="kernel:engine:complete")return i.data?.meta?.model??null}return null}function Ufr(e,n){for(let A=e.length-1;A>=0;A--){let i=e[A];if(i.time.seq>=n)continue;if(i.type==="kernel:engine:input")return i.data?.bytes??null;if(i.type==="kernel:engine:complete")return null}return null}function Rfr(e,n){let A=0;for(let i=e.length-1;i>=0;i--){let s=e[i];if(s.time.seq<=n)break;if(s.type!=="cognet:output:text")continue;let u=s.data.content;if(u)A+=u.length}return A}function V5a(){let A=0,i=null;return{step(s){if(!s)return null;if(s.model!==i)return i=s.model,A=s.tokens,A;if(s.tokens>=A)return A=s.tokens,A;let u=A-s.tokens;if(u<=200)return A;if(A=Math.round(A-u*0.25),A-s.tokens<=200)A=s.tokens;return A},reset(){A=0,i=null}}}function Kfr(e){if(e>=1e6){let n=e/1e6;return`${n.toFixed(n>=10?0:1)}m`}if(e===0)return"0k";return`${(e/1000).toFixed(1)}k`}function Yfr(e){if(e>=1e6){let n=Number((e/1e6).toFixed(1));return`${n%1===0?n.toFixed(0):n.toFixed(1)}m`}return`${Math.round(e/1000)}k`}function X5a(e,n){let A=e.find((s)=>s.id===n);if(A)return A.context;return e.find((s)=>s.id.slice(s.id.indexOf("/")+1)===n)?.context??0}function eYa(e,n){if(e===null||n<=0)return null;return`${Kfr(e)}/${Yfr(n)}`}var RSn;var KSn=xt(()=>{RSn=new Map});import{homedir as jfr}from"os";import{basename as Hfr,relative as Pfr,sep as tYa}from"path";function nYa(e,n){if(!e)return null;if(/^https?:\/\//i.test(e))return e;if(n&&Jfr(e,n))return`axon:${Hfr(e)}`;return Ofr(e)}function Jfr(e,n){let A=Pfr(n,e);return A.length>0&&!A.startsWith("..")&&!A.includes(tYa)}function Ofr(e){let n=jfr();if(e===n)return"~";return e.startsWith(n+tYa)?"~"+e.slice(n.length):e}var aYa=()=>{};function WKe(){Z6e.value++}function AYa(e){return e.join(" ")}function $fr(){let e=[];for(let n of M1.commands){let A=e;for(let s of n.path.slice(0,-1)){let u=A.find((d)=>d.kind==="group"&&d.label===s);if(u){A=Array.isArray(u.children)?u.children:[];continue}let p={kind:"group",label:s,description:"",children:[]};A.push(p),A=p.children}let i=n.path.at(-1);A.push({kind:"action",label:i,description:n.description??"",action:n.action,...n.workingMessage?{workingMessage:n.workingMessage}:{}})}return e}var W6e,bBt,z6e,CBt,Z6e,M1,F8t;var V6e=xt(()=>{Fs();qs();W6e=uA.ref([]),bBt=uA.ref(new Map),z6e=uA.ref(new Map),CBt=uA.ref(new Map),Z6e=uA.ref(0);M1={command(e){let n=AYa(e.path);if(W6e.value.some((i)=>AYa(i.path)===n))throw Pn("COMMAND_PATH_TAKEN",{detail:n,context:{path:e.path}});let A=crypto.randomUUID();return W6e.value=[...W6e.value,{...e,id:A}],WKe(),()=>{W6e.value=W6e.value.filter((i)=>i.id!==A),WKe()}},get commands(){return W6e.value},key(e,n){if(bBt.value.has(e))throw Pn("KEY_CHORD_TAKEN",{detail:e,context:{chord:e}});bBt.value.set(e,n),WKe();let A=!1;return()=>{if(A)return;A=!0,bBt.value.delete(e),WKe()}},keyHandler(e){return bBt.value.get(e)??null},chords:uA.computed(()=>{return Z6e.value,[...bBt.value.keys()]}),palette(e,n){if(z6e.value.has(e))throw Pn("PALETTE_NAME_TAKEN",{detail:e,context:{name:e}});let A={name:e,definition:n,cache:null};z6e.value.set(e,A);let i=null;if(n.key){let s=CBt.value.get(n.key);if(s)throw z6e.value.delete(e),Pn("MODE_KEY_TAKEN",{detail:`${n.key} is bound to "${s}"`,context:{key:n.key,name:e,taken:s}});CBt.value.set(n.key,e),i=()=>{CBt.value.delete(n.key)}}return WKe(),()=>{z6e.value.delete(e),i?.(),WKe()}},paletteFor(e){return Z6e.value,z6e.value.get(e)??null},paletteForKey(e){Z6e.value;let n=CBt.value.get(e);return n?z6e.value.get(n)??null:null},names:uA.computed(()=>{return Z6e.value,[...z6e.value.keys()]}),modeKeys:uA.computed(()=>{return Z6e.value,[...CBt.value.entries()].map(([e,n])=>({key:e,name:n}))})};F8t=uA.computed(()=>{return Z6e.value,W6e.value,$fr()})});function iYa(e,n){if(n.prefix===void 0)return!1;if(!e.endsWith(n.prefix))return!1;let A=e[e.length-n.prefix.length-1];return A===void 0||A===" "}function rYa(e,n){if(n.resolve!=="splice")return null;let A=zfr(e,n);if(A===-1)return null;let i=e.slice(A+n.key.length);if(/\s/.test(i))return null;return{start:A,query:i}}function oYa(e,n){let A=(n.prefix??"")+n.key;if(!e.endsWith(A))return-1;let i=e.length-A.length,s=e[i-1];return s===void 0||s===" "?i:-1}function zfr(e,n){for(let A=e.length-1;A>=0;A--){if(e[A]!==n.key)continue;let i=e[A-1];if(i===void 0||i===" ")return A}return-1}var X6e;var YSn=xt(()=>{X6e=[{mode:"voice",key:"#",prefix:">",resolve:"append"},{mode:"file",key:"@",resolve:"splice"}]});function BBt(e){return!Wfr.has(e)}function cYa(e,n=()=>!0){let A=uA.ref("normal"),i=uA.ref(!1),s=uA.ref(null),u=uA.ref(0),p=null;uA.watch([A,i],([y,k])=>{if((y==="loading"||k)&&!p)p=setInterval(()=>{u.value++},80);else if(y!=="loading"&&!k&&p)clearInterval(p),p=null}),uA.onUnmounted(()=>{if(p)clearInterval(p)});let d=uA.computed(()=>{if(i.value||A.value==="loading")return sYa[u.value%sYa.length];let y=IBt[A.value];if(y)return y;let k=M1.paletteFor(A.value);return k?.definition.symbol??k?.definition.key??Zfr});function b(y){A.value=y}function E(){for(let[y,k]of Object.entries(vne))fh(y,(x)=>{if(!n())return;if(A.value==="loading")return;if(A.value==="voice"&&k==="voice"){s.value="confirm",A.value="normal",x.consumed=!0;return}if(e().length>0)return;A.value=A.value===k?"normal":k,x.consumed=!0});fh("up",(y)=>{if(!n())return;if(A.value!=="normal")return;if(e().length>0)return;A.value="history",y.consumed=!0})}return{mode:A,symbol:d,processing:i,setMode:b,voiceExitReason:s,bindKeys:E}}var vne,Ayo,Wfr,v8t,IBt,Zfr="\xB7",sYa;var eLe=xt(()=>{Fs();V6e();YSn();vne={":":"command","/":"instance","*":"model","^":"session","~":"agent","#":"voice","?":"help",">":"prompt","%":"module",'"':"theme"},Ayo=new Set(X6e.map((e)=>e.mode)),Wfr=new Set(["normal","loading","voice"]);v8t={command:"run app commands",instance:"switch to a running conversation",session:"reopen a past session",agent:"start an agent",model:"set the agent's model",voice:"voice input via microphone",help:"show this help",prompt:"insert a prompt into your message",module:"manage agent modules",theme:"switch colour theme",file:"reference a file in your message"},IBt={normal:"\xBB",command:":",instance:"/",model:"*",session:"^",agent:"~",voice:"#",help:"?",history:"\u2191",loading:"\u280B",escalation:"\u203C",prompt:">",module:"%",theme:'"',file:"@",question:"\xB7"},sYa=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]});var uYa={};OA(uYa,{useQuestions:()=>e6});function e6(){if(!jSn)jSn=Vfr();return jSn}function Vfr(){function e(n){if(tLe.value)throw Pn("PALETTE_ALREADY_OPEN",{detail:"a question is already open"});return new Promise((A)=>{let i=(s)=>{if(!tLe.value)return;tLe.value=null,A(s)};tLe.value={...n(i),settle:i}})}return{pending:uA.computed(()=>tLe.value),cancel(){let n=tLe.value;if(!n)return;n.settle(n.kind==="confirm"?!1:void 0)},submitText(n){let A=tLe.value;if(A?.kind!=="prompt")return;A.settle(n.length>0?n:void 0)},async pick(n,A){return e((i)=>({kind:"pick",message:A?.placeholder??"",items:n.map((s,u)=>{let p=typeof s==="string",d=p?s:s.label,b=p?s:s.value;return{id:`pick-${u}`,label:d,...p?{}:s.description?{description:s.description}:{},action:()=>{i(b)}}})}))},async confirm(n,A){return e((i)=>({kind:"confirm",message:n,...A?.header?{header:A.header}:{},items:[{id:"yes",label:A?.choices?.yes??"yes",action:()=>{i(!0)}},{id:"no",label:A?.choices?.no??"no",action:()=>{i(!1)}}]}))},async prompt(n,A){return e(()=>({kind:"prompt",message:n,items:[],...A?.prompt?{prompt:A.prompt}:{},...A?.header?{header:A.header}:{},...A?.placeholder?{placeholder:A.placeholder}:{},...A?.secret?{secret:!0}:{}}))}}}var tLe,jSn;var nLe=xt(()=>{Fs();qs();tLe=uA.ref(null)});function TIe(){if(!HSn)HSn=Xfr();return HSn}function Xfr(){function e(n,A){let i=BAe.value.find((s)=>s.id===n);if(!i)return;BAe.value=BAe.value.filter((s)=>s.id!==n),i.settle(A)}return{current:uA.computed(()=>BAe.value[0]??null),waiting:uA.computed(()=>Math.max(0,BAe.value.length-1)),ask(n){return new Promise((A)=>{BAe.value=[...BAe.value,{...n,settle:A}]})},answer(n,A=!1){let i=BAe.value[0];if(i)e(i.id,{allow:n,always:A})},denyAll(){let n=BAe.value;BAe.value=[];for(let A of n)A.settle({allow:!1,always:!1})}}}var BAe,HSn;var S8t=xt(()=>{Fs();BAe=uA.ref([])});function ehr(e,n,A){return`${e}\x00${n}\x00${A??""}`}function OSn(e){return{id:e.id,label:e.label,...e.description!==void 0?{description:e.description}:{},...e.chunks!==void 0?{chunks:e.chunks}:{},...e.descendQuery!==void 0?{descendQuery:e.descendQuery}:{},...e.workingMessage!==void 0?{workingMessage:e.workingMessage}:{},...e.detach!==void 0?{detach:e.detach}:{},...e.header!==void 0?{header:e.header}:{},...e.separator!==void 0?{separator:e.separator}:{},...e.preview!==void 0?{preview:e.preview}:{},...e.choices!==void 0?{choices:()=>e.choices().map(OSn)}:{},action:e.action??(()=>{})}}function thr(e){if(Array.isArray(e))return{items:e.map(OSn)};return{items:e.items.map(OSn),...e.breadcrumb!==void 0?{breadcrumb:e.breadcrumb}:{},...e.status!==void 0?{status:e.status}:{},...e.invalid!==void 0?{invalid:e.invalid}:{}}}function nhr(e,n,A){let i=ehr(e.name,n,A);lYa.value;let s=PSn.value.get(i);if(s)return{items:s.items,...s.breadcrumb!==void 0?{breadcrumb:s.breadcrumb}:{},...s.status!==void 0?{status:s.status}:{},...s.invalid!==void 0?{invalid:s.invalid}:{}};if(!JSn.has(i))JSn.add(i),(async()=>{try{let u=await e.definition.list(n,A);PSn.value.set(i,{key:i,...thr(u)})}catch(u){PSn.value.set(i,{key:i,items:[],status:{kind:"error",message:u instanceof Error?u.message:String(u)}})}finally{JSn.delete(i),lYa.value++}})();return{items:[],status:{kind:"loading",message:"loading..."}}}function gYa(e){return{id:e,resolve:uA.computed(()=>(n,A)=>{let i=e6().pending.value;if(i)return{items:i.items,...i.message?{breadcrumb:i.message}:{}};let s=M1.paletteFor(e);if(!s)return{items:[]};return nhr(s,n,A)}),get skipDefaultFilter(){return M1.paletteFor(e)?.definition.filter===!1},get tabs(){return M1.paletteFor(e)?.definition.tabs},get anchor(){return M1.paletteFor(e)?.definition.anchor},get maxHeight(){return M1.paletteFor(e)?.definition.maxHeight}}}var PSn,JSn,lYa,ZKe="escalation",pYa,VKe="question",mYa;var $Sn=xt(()=>{Fs();V6e();nLe();S8t();PSn=uA.ref(new Map),JSn=new Set,lYa=uA.ref(0);pYa={id:ZKe,skipDefaultFilter:!0,resolve:uA.computed(()=>()=>{let e=TIe(),n=e.current.value;if(!n)return{items:[]};let A=e.waiting.value;return{items:[{id:"allow",label:"allow once",description:"just this call",action:()=>{e.answer(!0)}},{id:"always",label:"allow always",description:"remember this \u2014 revoke with :policy grants",action:()=>{e.answer(!0,!0)}},{id:"deny",label:"deny",description:"refuse this call",action:()=>{e.answer(!1)}}],header:{label:n.fn,detail:`"${n.subject}"`+(A>0?` (${A} more waiting)`:"")}}})},mYa={id:VKe,skipDefaultFilter:!0,resolve:uA.computed(()=>(e)=>{let n=e6().pending.value;if(!n)return{items:[]};if(n.kind==="prompt"){let A=e.length>0;return{items:[{id:"prompt",label:n.prompt??"waiting for input",placeholder:!n.prompt,description:A?"enter to confirm":"esc to cancel",action:()=>{}}],...n.header?{header:n.header}:{breadcrumb:n.message}}}return{items:n.items,...n.header?{header:n.header}:n.message?{breadcrumb:n.message}:{}}})}});function fYa(e){dYa.set(e.id,e)}function N8t(e){let n=dYa.get(e);if(n)return n;if(e===VKe)return mYa;if(e===ZKe)return pYa;return M1.paletteFor(e)?gYa(e):void 0}var dYa;var hYa=xt(()=>{V6e();$Sn();dYa=new Map});function ahr(e,n){if(e.length===0)return!0;if(e.length>n.length)return!1;let A=0;for(let i of n)if(i===e[A]){if(A++,A===e.length)return!0}return!1}function Ahr(e,n){if(n===e)return 100;if(n.startsWith(e))return 75;if(n.includes(e))return 50;if(e.length>=ihr&&n.length<=e.length*rhr){if(ahr(e,n))return 25}return null}function aLe(e,n){let A=e.toLowerCase().split(/[\s:]+/).filter(Boolean);if(A.length===0)return 0;let i=n.map((u)=>u.toLowerCase()),s=0;for(let u of A){let p=null;for(let d of i){let b=Ahr(u,d);if(b!==null&&(p===null||b>p))p=b}if(p===null)return null;s+=p}return s}var ihr=3,rhr=4;function xJ(e,n){let A=e[n];return!!A&&!A.header&&!A.separator&&!A.invalid}function bYa(e){let{items:n,previous:A,selectedIndex:i,homeIndex:s}=e,u=A?.[i],p=u!==void 0&&n[i]?.id!==u.id;if(!(i>=n.length||!xJ(n,i))&&!p)return i;let b=u?n.findIndex((E)=>E.id===u.id):-1;return b>=0&&xJ(n,b)?b:s}function CYa(e){return typeof e.children==="function"?e.children():e.children}function ohr(e,n){let A=e.label.toLowerCase(),i=e.description.toLowerCase();if(A===n)return 5;if(A.split("/").at(-1)===n)return 4;if(A.startsWith(n))return 3;if(A.includes(n))return 2;if(i.includes(n))return 1;return 0}function shr(e,n){let A=n.toLowerCase();return e.map((i,s)=>({node:i,index:s,score:ohr(i,A)})).filter((i)=>i.score>0).sort((i,s)=>s.score-i.score||i.index-s.index).map((i)=>i.node)}function BYa(e,n){let A=e.endsWith(" "),i=e.split(" "),s=i.map((k)=>k.toLowerCase()),u=n,p=[],d=A?s.length:s.length-1;for(let k=0;k<d;k++){let x=s[k];if(!x)continue;let S=u.find((L)=>L.label.toLowerCase()===x);if(!S)return{nodes:[],breadcrumb:p,partial:x,exactMatch:null,noMatch:!0,input:null};if(S.kind==="action")return{nodes:[],breadcrumb:p,partial:"",exactMatch:S,noMatch:!1,input:null};if(S.kind==="input")return{nodes:[],breadcrumb:[...p,S.label],partial:"",exactMatch:null,noMatch:!1,input:{node:S,value:i.slice(k+1).join(" ").trim()}};p.push(S.label),u=CYa(S)}let b=A?"":s[s.length-1]??"",E=b?shr(u,b):u;if(b&&E.length===0)return{nodes:E,breadcrumb:p,partial:b,exactMatch:null,noMatch:!0,input:null};let y=b?E.find((k)=>k.label.toLowerCase()===b.toLowerCase())??null:null;if(y&&y.kind==="group")return{nodes:CYa(y),breadcrumb:[...p,y.label],partial:"",exactMatch:null,noMatch:!1,input:null};return{nodes:E,breadcrumb:p,partial:b,exactMatch:y,noMatch:!1,input:null}}function IYa(e,n){return[...e,n].join(" ")+" "}function G8t(e){if(e.length===0)return null;let n=3,A=e.length>n?e.slice(-n):e;return(e.length>n?"\u2026 \u203A ":"")+A.join(" \u203A ")+" \u203A"}import{existsSync as chr}from"fs";import{join as EYa,resolve as uhr}from"path";import{homedir as yYa}from"os";function lhr(){let e=IC();function n(){let b=e.store.profiles.active();if(!b)throw Pn("NOT_AUTHENTICATED");return b}function A(b){let E=yYa();return b===E||b.startsWith(E+"/")?"~"+b.slice(E.length):b}function i(){let b=n(),E={dir:EYa(e.store.root,"profiles",b.id,"agents"),label:"~/.axon (default)"},y=b.agents.extraRoots().map((k)=>({dir:k,label:A(k)}));return[E,...y]}function s(){let b=e.store.profiles.active();if(!b)return[];return b.agents.extraRoots().map((E)=>({dir:E,label:A(E)}))}async function u(b,E){await e.projects.create("agent",{name:b,dir:E})}async function p(b){let E=uhr(b.startsWith("~")?EYa(yYa(),b.slice(1)):b);if(!chr(E))throw Pn("WATCH_PATH_NOT_FOUND",{context:{path:E}});return await n().agents.watch(E),Uc().refreshAvailable(),E}async function d(b){await n().agents.unwatch(b),Uc().refreshAvailable()}return{locations:i,watched:s,create:u,watch:p,unwatch:d}}function XKe(){if(!zSn)zSn=lhr();return zSn}var zSn;var QYa=xt(async()=>{qs();await Qk([a3(),Ek()])});function UIe(){if(!WSn)WSn=phr();return WSn}function phr(){let e=uA.ref(null),n=0,A=null,i=!1,s=null,u=!1,p=null;function d(k){s=k}function b(k){p=k}function E(){if(i)return!0;if(p?.(),n++,A)clearTimeout(A);if(n===1)return e.value="press ctrl+c again to quit",A=setTimeout(()=>{n=0,e.value=null},ghr),!1;if(n===2)return y(),!1;return process.exit(130),!1}async function y(k=0){if(u)return;if(u=!0,n=Math.max(n,2),A)clearTimeout(A);e.value="shutting down \xB7 ctrl+c to force quit";let x=process.env.AXON_SHUTDOWN_TRACE==="1",S=Date.now(),L=(V)=>{if(x)process.stderr.write(`[exit] ${V} +${Date.now()-S}ms
|
|
5047
5047
|
`)};L("gracefulExit:start");let U=new Promise((V)=>{setTimeout(()=>{console.error(`shutdown exceeded ${_Ya}ms \u2014 exiting without waiting further`),V()},_Ya)});await Promise.race([Uc().shutdown().catch((V)=>{console.error("shutdown failed during exit:",V)}),U]),L("agents.shutdown settled"),i=!0,setTimeout(()=>{console.error(`exit exceeded ${wYa}ms \u2014 forcing`),process.exit(k)},wYa).unref?.(),L("calling vterm exit"),s?.(k),L("vterm exit returned")}return{hint:e,bind:d,bindDraft:b,onQuit:E,gracefulExit:y}}var ghr=500,_Ya=2000,wYa=1500,WSn;var EBt=xt(async()=>{Fs();await Ek()});function e7e(){if(!ZSn)ZSn=dhr();return ZSn}function dhr(){let e=IC().updates,n=uA.ref(null),A=uA.ref(!1),i=uA.computed(()=>n.value!==null),s=null;async function u(E){if(!e.supported()||A.value)return;A.value=!0;try{let y=await e.check(E);n.value=y.status==="available"?y.latest:null}finally{A.value=!1}}function p(){if(!e.supported())return()=>{};if(u().catch(()=>{}),!s)s=setInterval(()=>{u().catch(()=>{})},mhr);return d}function d(){if(s)clearInterval(s);s=null}async function b(E){if((await e.handoff(E)).status==="current"){n.value=null;return}await UIe().gracefulExit(cBt)}return{current:e.currentVersion,latest:n,available:i,checking:A,check:u,start:p,stop:d,update:b}}var mhr=21600000,ZSn;var M8t=xt(async()=>{Fs();C8t();await Qk([a3(),EBt()])});function fhr(){let e=process.env.TERM_FONT??process.env.FONT??"";if(/nerd|\bnf\b/i.test(e))return"nerd";let n=process.env.TERM_PROGRAM??"";if(/ghostty|wezterm/i.test(n))return"nerd";return"unicode"}function DYa(e,n){if(!e)return"";if(n==="none")return"";let A=kYa[e];if(!A)return e;return(n==="auto"?fhr():n)==="nerd"?A.nerd:A.unicode}var kYa,Lyo;var xYa=xt(()=>{kYa={agent:{nerd:"\uE26E",unicode:"\u25C6"},model:{nerd:"\uF085",unicode:"\u25C7"},modules:{nerd:"\uF487",unicode:"\u25A3"},session:{nerd:"\uF075",unicode:"\u25B8"},tokens:{nerd:"\uF080",unicode:"\u25AA"},messages:{nerd:"\uF086",unicode:"\u25AB"},branch:{nerd:"\uE725",unicode:"\u2442"},changes:{nerd:"\uF448",unicode:"\xB1"},ahead:{nerd:"\uF55C",unicode:"\u2191"},behind:{nerd:"\uF544",unicode:"\u2193"},folder:{nerd:"\uF07B",unicode:"\u25A4"},clock:{nerd:"\uF017",unicode:"\u25F7"},user:{nerd:"\uF007",unicode:"\u25C9"},warning:{nerd:"\uF071",unicode:"\u25B2"},error:{nerd:"\uF057",unicode:"\u2715"}};Lyo=Object.keys(kYa)});function xR(){if(!XSn)XSn=hhr();return XSn}function hhr(){let e=new Set;function n(A){return[...e].filter((i)=>i.name===A)}return{register(A,i){let s={name:A,handler:i};return e.add(s),()=>{e.delete(s)}},notify(A,...i){let s=[];for(let u of n(A))try{u.handler(...i)}catch(p){s.push(Pn("HOOK_FAILED",{detail:`${A} \u2014 ${p instanceof Error?p.message:String(p)}`,context:{hook:A},cause:p}))}return s},async gate(A,...i){let s=n(A);if(s.length===0)return[];let u=[],p,d=Promise.all(s.map(async(E)=>{try{await E.handler(...i)}catch(y){u.push(Pn("HOOK_FAILED",{detail:`${A} \u2014 ${y instanceof Error?y.message:String(y)}`,context:{hook:A},cause:y}))}})),b=new Promise((E)=>{p=setTimeout(()=>E("timeout"),VSn)});try{if(await Promise.race([d.then(()=>"done"),b])==="timeout")u.push(Pn("HOOK_TIMED_OUT",{detail:`${A} did not finish within ${VSn}ms`,context:{hook:A,budgetMs:VSn}}))}finally{if(p)clearTimeout(p)}return u},count(A){return n(A).length}}}var VSn=5000,XSn;var RIe=xt(()=>{qs()});function r$(){if(!t8n)t8n=bhr();return t8n}function bhr(){let e=xR();function n(b){try{let E=b.component.render(),y=E===null||E===void 0?"":String(E),k=DYa(b.component.icon,e8n.value);Dbe.value.set(b.name,y&&k?`${k} ${y}`:y)}catch(E){Dbe.value.set(b.name,""),console.error(`line component "${b.name}" failed to render:`,E)}Dbe.value=new Map(Dbe.value)}function A(b){return Array.isArray(b)?{left:[...b]}:{...b}}function i(b){if(!b||b.length===0)return[];return Array.isArray(b[0])?b.map((E)=>[...E]):[[...b]]}function s(b){return[b.left,b.middle,b.right].flatMap((E)=>i(E).flat())}function u(b,E){return b.style??E.content.style??L8t.value}function p(b){let E=tL.value.get(b);if(!E)throw Pn("LINE_UNKNOWN",{detail:`no line named "${b}"`,context:{name:b}});return E}function d(b){let E=(x,S)=>x.length===0||S.length>0,y=(x)=>i(x).map((S)=>[S,S.filter((L)=>Dbe.value.get(L))]).filter(([S,L])=>E(S,L)).map(([,S])=>S),k=(x)=>i(x).map((S)=>[S,S.map((L)=>Dbe.value.get(L)??"").filter(Boolean)]).filter(([S,L])=>E(S,L)).map(([,S])=>S);return b.map(({placed:x,line:S})=>({id:x.id,name:S.name,style:u(x,S),left:k(S.content.left),middle:k(S.content.middle),right:k(S.content.right),names:{left:y(S.content.left),middle:y(S.content.middle),right:y(S.content.right)}})).filter((x)=>{if(s(tL.value.get(x.name)?.content??{}).length===0)return!0;return x.left.length>0||x.middle.length>0||x.right.length>0})}return{createComponent(b,E){if(a$.value.has(b))throw Pn("COMPONENT_NAME_TAKEN",{detail:`a component named "${b}" is already registered`,context:{name:b}});let y={name:b,component:E,teardown:[]};for(let k of E.on??[])y.teardown.push(e.register(k,()=>n(y)));if(E.every!==void 0){let k=setInterval(()=>n(y),E.every);y.teardown.push(()=>clearInterval(k))}return a$.value.set(b,y),a$.value=new Map(a$.value),n(y),()=>{for(let k of y.teardown)k();a$.value.delete(b),Dbe.value.delete(b),a$.value=new Map(a$.value),Dbe.value=new Map(Dbe.value)}},listComponents(){return[...a$.value.keys()].sort()},createLine(b,E,y){if(tL.value.has(b))throw Pn("LINE_NAME_TAKEN",{detail:`a line named "${b}" is already registered`,context:{name:b}});let k=A(E);tL.value.set(b,{name:b,content:k}),tL.value=new Map(tL.value);let x=()=>{tL.value.delete(b),tL.value=new Map(tL.value),FR.value=FR.value.filter((L)=>L.name!==b),A$.value.delete(b)};y?.(x);let S=s(k).filter((L)=>!a$.value.has(L));if(S.length>0)i$.value=[...i$.value,Pn("COMPONENT_UNKNOWN",{detail:`line "${b}" names ${S.map((L)=>`"${L}"`).join(", ")}, which ${S.length>1?"are":"is"} not registered`,context:{line:b,components:S.join(", ")}})];return x},setStack(b){let E=[],y=[],k=new Set;for(let x of b){let S=typeof x==="string"?{line:x}:x;if(!tL.value.has(S.line)){y.push(S.line);continue}if(E.push({id:`${S.line}#${E.length}`,name:S.line,...S.style?{style:S.style}:{}}),S.hidden)k.add(S.line)}if(FR.value=E,A$.value=k,y.length>0)i$.value=[...i$.value,Pn("LINE_UNKNOWN",{detail:`no line named ${y.map((x)=>`"${x}"`).join(", ")}`,context:{names:y.join(", ")}})]},move(b,E){p(b);let y=FR.value.findIndex((U)=>U.name===b);if(y<0)throw Pn("LINE_UNKNOWN",{detail:`line "${b}" is not in the stack`,context:{name:b}});let k=E==="up"?y-1:E==="down"?y+1:E,x=Math.max(0,Math.min(FR.value.length-1,k)),S=[...FR.value],[L]=S.splice(y,1);S.splice(x,0,L),FR.value=S},hide(b){p(b),A$.value=new Set(A$.value).add(b)},show(b){p(b);let E=new Set(A$.value);if(E.delete(b),A$.value=E,!FR.value.some((y)=>y.name===b))FR.value=[...FR.value,{id:`${b}#${FR.value.length}`,name:b}]},toggle(b){p(b);let E=new Set(A$.value);if(E.has(b))E.delete(b);else E.add(b);A$.value=E},setTop(b,E){if(b===null){yBt.value=null;return}let y=typeof b==="string"?{line:b,...E}:b;if(!tL.value.has(y.line)){i$.value=[...i$.value,Pn("LINE_UNKNOWN",{detail:`no line named "${y.line}"`,context:{name:y.line}})];return}yBt.value={id:`top:${y.line}`,name:y.line,...y.style?{style:y.style}:{}}},top(){let b=yBt.value;if(!b)return null;let E=tL.value.get(b.name);if(!E)return null;return{id:b.id,name:E.name,content:E.content,style:u(b,E),visible:!0}},press(b){let y=a$.value.get(b)?.component.click;if(!y)return;try{let k=y();if(k instanceof Promise)k.catch((x)=>{i$.value=[...i$.value,x]})}catch(k){i$.value=[...i$.value,k]}},pressable(b){return Boolean(a$.value.get(b)?.component.click)},icons(b){if(b!==void 0){e8n.value=b;for(let E of a$.value.values())n(E)}return e8n.value},style(b){if(b!==void 0)L8t.value=b;return L8t.value},renderedTop:uA.computed(()=>{let b=yBt.value;if(!b)return[];let E=tL.value.get(b.name);if(!E)return[];return d([{placed:b,line:E}])}),faults:uA.computed(()=>i$.value),reset(){i$.value=[],FR.value=[],A$.value=new Set,L8t.value="powerline",yBt.value=null},listRegistered(){return[...tL.value.keys()].sort()},isVisible(b){return FR.value.some((E)=>E.name===b)&&!A$.value.has(b)},list(){let b=[];for(let E of FR.value){let y=tL.value.get(E.name);if(!y)continue;b.push({id:E.id,name:y.name,content:y.content,style:u(E,y),visible:!A$.value.has(y.name)})}return b},rendered:uA.computed(()=>d(FR.value.filter((b)=>!A$.value.has(b.name)).map((b)=>({placed:b,line:tL.value.get(b.name)})).filter((b)=>b.line!==void 0)))}}var a$,tL,FR,A$,Dbe,i$,L8t,yBt,e8n,t8n;var t7e=xt(()=>{Fs();qs();xYa();RIe();a$=uA.ref(new Map),tL=uA.ref(new Map),FR=uA.ref([]),A$=uA.ref(new Set),Dbe=uA.ref(new Map),i$=uA.ref([]),L8t=uA.ref("powerline"),yBt=uA.ref(null),e8n=uA.ref("auto")});function FYa(){return{entries:uA.computed(()=>QBt.value),checking:uA.computed(()=>n8n.value),outdated:uA.computed(()=>QBt.value.filter((e)=>e.outdated)),refresh(){if(_Bt)return _Bt;if(a8n!==null)return Promise.resolve();if(Date.now()<A8n)return Promise.resolve();return n8n.value=!0,_Bt=(async()=>{let e=!1;try{let n=await nL().updates();QBt.value=n,e=n.every((A)=>A.latest!==null)}catch{QBt.value=[]}finally{if(e)a8n=Date.now();else A8n=Date.now()+Chr;n8n.value=!1,_Bt=null}})(),_Bt},invalidate(){a8n=null,A8n=0,QBt.value=[]}}}var QBt,n8n,a8n=null,A8n=0,Chr=1e4,_Bt=null;var vYa=xt(async()=>{Fs();await KIe();QBt=uA.ref([]),n8n=uA.ref(!1)});function q8t({entries:e,checking:n,noun:A}){let i=(b)=>`${A}${b===1?"":"s"}`;if(n&&e.length===0)return[{kind:"message",label:"checking\u2026",description:"Asking the registry what is published"}];if(e.length===0)return[{kind:"message",label:"none installed",description:`Nothing declares a registry ${A}`}];let s=e.filter((b)=>b.outdated),u=e.filter((b)=>b.latest===null),p=e.filter((b)=>b.current===null&&b.latest!==null);if(s.length===0){if(u.length>0)return[{kind:"message",label:"could not reach the registry",description:`${u.length} ${i(u.length)} could not be checked`}];if(p.length>0)return[{kind:"message",label:"not installed",description:`${p.length} declared ${i(p.length)} ${p.length===1?"is":"are"} not installed \u2014 run prepare`}];return[{kind:"message",label:"up to date",description:`All ${e.length} ${i(e.length)} are current`}]}let d=[];if(s.length>1)d.push({kind:"all",count:s.length,entries:s});for(let b of s)d.push({kind:"entry",entry:b});return d}function Ihr(e){let n=a7e.get(e);if(!n)n={modules:[],checkedAt:null,retryAfter:0,inFlight:null},a7e.set(e,n);return n}function SYa(){let e=Uc(),n=uA.computed(()=>e.projectRoot.value);return{entries:uA.computed(()=>{n7e.value;let A=n.value;if(!A)return[];return a7e.get(A)?.modules??[]}),checking:uA.computed(()=>{n7e.value;let A=n.value;if(!A)return!1;return a7e.get(A)?.inFlight!=null}),outdated:uA.computed(()=>{n7e.value;let A=n.value;if(!A)return[];return(a7e.get(A)?.modules??[]).filter((i)=>i.outdated)}),refresh(){let A=n.value;if(!A)return Promise.resolve();let i=Ihr(A);if(i.inFlight)return i.inFlight;if(i.checkedAt!==null)return Promise.resolve();if(Date.now()<i.retryAfter)return Promise.resolve();return i.inFlight=(async()=>{let s=!1;try{let u=await e.moduleUpdates();i.modules=u,s=u.every((p)=>p.latest!==null)}catch{i.modules=[]}finally{if(s)i.checkedAt=Date.now();else i.retryAfter=Date.now()+Bhr;i.inFlight=null,n7e.value++}})(),n7e.value++,i.inFlight},invalidate(){let A=n.value;if(!A)return;a7e.delete(A),n7e.value++}}}var a7e,n7e,Bhr=1e4;var NYa=xt(async()=>{Fs();await Ek();a7e=new Map,n7e=uA.ref(0)});function yhr(e){let n=kBt.get(e);if(!n)n={cognet:null,checkedAt:null,retryAfter:0,inFlight:null},kBt.set(e,n);return n}function GYa(){let e=Uc(),n=uA.computed(()=>e.projectRoot.value);return{entry:uA.computed(()=>{wBt.value;let A=n.value;if(!A)return null;return kBt.get(A)?.cognet??null}),checking:uA.computed(()=>{wBt.value;let A=n.value;if(!A)return!1;return kBt.get(A)?.inFlight!=null}),refresh(){let A=n.value;if(!A)return Promise.resolve();let i=yhr(A);if(i.inFlight)return i.inFlight;if(i.checkedAt!==null)return Promise.resolve();if(Date.now()<i.retryAfter)return Promise.resolve();return i.inFlight=(async()=>{let s=!1;try{let u=await e.cognetUpdate();i.cognet=u,s=u===null||u.latest!==null}catch{i.cognet=null}finally{if(s)i.checkedAt=Date.now();else i.retryAfter=Date.now()+Ehr;i.inFlight=null,wBt.value++}})(),wBt.value++,i.inFlight},invalidate(){let A=n.value;if(!A)return;kBt.delete(A),wBt.value++}}}var kBt,wBt,Ehr=1e4;var MYa=xt(async()=>{Fs();await Ek();kBt=new Map,wBt=uA.ref(0)});function Qhr(){let e=process.env.AXON_API_BASE??(process.env.AXON_STAGING_MODE==="true"?"http://localhost:3099":"production"),n=0;for(let A=0;A<e.length;A++)n=Math.imul(31,n)+e.charCodeAt(A)|0;return(n>>>0).toString(36)}function _hr(e){let n=IC(),A=n.cloud.client.registry.artifacts,i=n.store.cache.file(`registry-${e}-${Qhr()}`),s=uA.ref([]),u=uA.ref(!1),p=uA.ref(null),d=!1;function b(){if(d)return;d=!0;try{let y=i.get();if(y?.entries?.length)s.value=y.entries}catch{}E()}function E(){if(u.value)return;u.value=!0,p.value=null,A.of(e).search().then((y)=>{s.value=y;try{i.set({fetchedAt:Date.now(),entries:y})}catch{}}).catch((y)=>{p.value=y instanceof Error?y:Error(String(y))}).finally(()=>{u.value=!1})}return{entries:s,loading:u,error:p,ensure:b,reset(){if(p.value)p.value=null,E()}}}function A7e(e){let n=LYa.get(e);if(!n)n=_hr(e),LYa.set(e,n);return n}var LYa;var T8t=xt(async()=>{Fs();await a3();LYa=new Map});function Mk(){return{current:U8t,show(e,n="info",A){let i=e.trim();if(i.length===0)return;U8t.value={message:i.length>qYa?`${i.slice(0,qYa-1)}\u2026`:i,level:n};let s=A!==void 0&&Number.isFinite(A)&&A>0?Math.min(A,khr):whr;if(ALe)clearTimeout(ALe);ALe=setTimeout(()=>{U8t.value=null,ALe=null},s)},clear(){if(ALe)clearTimeout(ALe);ALe=null,U8t.value=null}}}var qYa=50,whr=300,khr=5000,U8t,ALe=null;var iLe=xt(()=>{Fs();U8t=uA.ref(null)});function i7e(){let e=Uc(),n=uA.computed(()=>e.prompts.list());function A(s){return e.prompts.render(s)}function i(s){return e.prompts.fetch(s)}return{entries:n,render:A,fetch:i}}var TYa=xt(async()=>{Fs();await Ek()});function Dhr(){let e=IC().cloud.client.registry.artifacts,n=uA.ref([]),A=uA.ref(!1),i=uA.ref(null),s=!1;function u(){if(s||A.value||i.value)return;A.value=!0,e.of("prompt").search().then((d)=>{n.value=d,s=!0}).catch((d)=>{i.value=d instanceof Error?d:Error(String(d))}).finally(()=>{A.value=!1})}function p(){if(i.value)i.value=null}return{entries:n,loading:A,error:i,ensure:u,reset:p}}function UYa(){if(!i8n)i8n=Dhr();return i8n}var i8n;var RYa=xt(async()=>{Fs();await a3()});function xhr(e,n){let A=e.trim().toLowerCase();return{items:i7e().entries.value.filter((s)=>r7e(A,s.name,s.description)).map((s)=>({id:`prompt:${s.name}`,label:s.name,...s.description?{description:s.description}:{},completeQuery:s.name,inlineResult:!0,workingMessage:`rendering ${s.name}...`,action:async()=>{try{n(await i7e().render(s.name))}catch(u){Mb().sendError.value=jYa(u)}}}))}}function KYa(e,n,A){let i=UYa();if(i.ensure(),i.error.value)return{items:[],status:{kind:"error",message:`registry unavailable \u2014 ${i.error.value.message}`}};let s=e.trim().toLowerCase(),u=new Set(i7e().entries.value.map((d)=>d.name)),p=i.entries.value.filter((d)=>r7e(s,d.name,d.description)).filter((d)=>!(A?.excludeDeclared&&u.has(d.name))).map((d)=>({id:`registry-prompt:${d.name}`,label:d.name,description:d.description??"no description",completeQuery:d.name,inlineResult:!0,workingMessage:`rendering ${d.name}...`,action:async()=>{try{n(await i7e().fetch(d.name))}catch(b){Mb().sendError.value=jYa(b)}}}));if(i.loading.value){let d={kind:"loading",message:"loading registry prompts..."};return p.length===0?{items:[],status:d}:{items:p,status:d}}return{items:p}}function r8n(e,n=[]){if(!e.startsWith("@"))return!1;let A=e.trim().toLowerCase();return!n.some((i)=>i.toLowerCase()===A)}function r7e(e,n,A){if(!e)return!0;let i=e.toLowerCase();return n.toLowerCase().includes(i)||(A?.toLowerCase().includes(i)??!1)}function jYa(e){return e instanceof Error?e:Error(String(e))}var YYa;var R8t=xt(async()=>{Fs();await Qk([TYa(),RYa(),aL()]);YYa={id:"prompt",maxHeight:8,skipDefaultFilter:!0,resolve:uA.computed(()=>(e,n,A)=>{let i=i7e().entries.value.map((p)=>p.name);if(r8n(e,i))return KYa(e,A);let s=xhr(e,A),u=KYa(e,A,{excludeDeclared:!0});if(u.items.length===0)return s;return{items:[{id:"hdr:registry",label:"registry",header:!0,action:()=>{}},...u.items,...s.items.length>0?[{id:"sep:declared",separator:!0,label:"",action:()=>{}},{id:"hdr:declared",label:"this agent",header:!0,action:()=>{}},...s.items]:[]],...u.status?{status:u.status}:{}}})}});function K8t(e,n){return A7e(e).entries.value.filter((i)=>r7e(n.term,i.name,i.description)).filter((i)=>!(n.mode==="install"&&n.installed.has(i.name))).map((i)=>{let s=n.installed.has(i.name);return{id:`registry-${e}:${i.name}`,label:i.name,description:s?`installed \xB7 ${i.description??""}`.trimEnd():`install \xB7 ${i.description??"no description"}`,completeQuery:i.name,action:()=>{if(s)return;Fhr(e,i.name)}}})}async function Fhr(e,n){try{if(e==="extension"){await Uc().installExtension(n),Mk().show(`installed ${n}`);return}if((await Uc().installModule(n)).status==="not-found")throw Error(`${n} could not be resolved for install`)}catch(A){Mb().sendError.value=A instanceof Error?A:Error(String(A))}}var o8n=xt(async()=>{iLe();await Qk([T8t(),Ek(),aL(),R8t()])});function OYa(){return Uc().modules.value.map((e)=>e.packageName).filter((e)=>e!==void 0)}function s8n(e){return e.packageName!==void 0&&e.root.includes("node_modules")}function vhr(e,n){let A=e.trim().toLowerCase();return{items:Uc().modules.value.filter((s)=>r7e(A,s.packageName??s.name,PYa(s))).map((s)=>{let u=s.packageName??s.name;return{id:`module:${u}`,label:u,description:PYa(s),completeQuery:u,choices:()=>Shr(s,n),action:()=>{}}})}}function Shr(e,n){let A=e.packageName??e.name,i=[];if(s8n(e))i.push({id:`module:uninstall:${A}`,label:"\u2715 uninstall",description:`remove ${A} from this agent`,workingMessage:`uninstalling ${A}...`,action:async()=>{try{if((await Uc().uninstallModule(A)).status==="not-installed")Mb().palette.signalNoMatch();else n("")}catch(s){Mb().sendError.value=Nhr(s)}}});else i.push({id:`module:local:${A}`,label:"local module",description:"declared in axon.config.ts \u2014 remove the import to uninstall",placeholder:!0,action:()=>{}});return i}function HYa(e,n){let A=A7e("module");A.ensure();let i=e.trim().toLowerCase(),s=new Set(OYa()),u=K8t("module",{term:i,installed:s,mode:n?.excludeInstalled?"install":"browse"});if(A.error.value){let p={kind:"error",message:`registry unavailable \u2014 ${A.error.value.message}`};return u.length===0?{items:[],status:p}:{items:u,status:p}}if(A.loading.value){let p={kind:"loading",message:"loading registry modules..."};return u.length===0?{items:[],status:p}:{items:u,status:p}}return{items:u}}function PYa(e){if(e.version)return`v${e.version}`;return e.root.includes("node_modules")?"installed module":"local module"}function Nhr(e){return e instanceof Error?e:Error(String(e))}var JYa;var c8n=xt(async()=>{Fs();await Qk([Ek(),T8t(),o8n(),aL(),R8t()]);JYa={id:"module",maxHeight:8,skipDefaultFilter:!0,resolve:uA.computed(()=>(e,n,A)=>{let i=OYa();if(r8n(e,i))return HYa(e);let s=vhr(e,A),u=HYa(e,{excludeInstalled:!0});if(u.items.length===0)return s;return{items:[{id:"hdr:registry",label:"registry",header:!0,action:()=>{}},...u.items,...s.items.length>0?[{id:"sep:installed",separator:!0,label:"",action:()=>{}},{id:"hdr:installed",label:"installed",header:!0,action:()=>{}},...s.items]:[]],...u.status?{status:u.status}:{}}})}});function Ghr(e){let n=xBt.get(e);if(!n)n={names:[],loaded:!1,inFlight:null},xBt.set(e,n);return n}function YIe(){let e=Uc(),n=uA.computed(()=>e.projectRoot.value);return{names:uA.computed(()=>{DBt.value;let A=n.value;if(!A)return[];return xBt.get(A)?.names??[]}),checking:uA.computed(()=>{DBt.value;let A=n.value;if(!A)return!1;return xBt.get(A)?.inFlight!=null}),refresh(){let A=n.value;if(!A)return Promise.resolve();let i=Ghr(A);if(i.inFlight)return i.inFlight;if(i.loaded)return Promise.resolve();return i.inFlight=(async()=>{try{i.names=await e.envKeys(),i.loaded=!0}catch{i.names=[]}finally{i.inFlight=null,DBt.value++}})(),DBt.value++,i.inFlight},invalidate(){let A=n.value;if(!A)return;xBt.delete(A),DBt.value++}}}var xBt,DBt;var u8n=xt(async()=>{Fs();await Ek();xBt=new Map,DBt=uA.ref(0)});async function Lhr(e){try{let n=await fetch("https://discord.com/api/v10/users/@me/guilds",{headers:{Authorization:`Bot ${e}`}});if(!n.ok)return!1;let A=await n.json();return Array.isArray(A)&&A.length>0}catch{return!1}}async function qhr(e){let n=await fetch("https://discord.com/api/v10/users/@me",{headers:{Authorization:`Bot ${e}`}});if(!n.ok){if(n.status===401)throw Error("token rejected \u2014 copy from Bot \u2192 Reset Token, not the OAuth2 Client Secret");throw Error(`Discord returned ${n.status}`)}let A=await n.json(),i=A.discriminator&&A.discriminator!=="0"?`${A.username}#${A.discriminator}`:A.username;return{id:A.id,tag:i}}async function Uhr(e){let n=await fetch(`https://api.telegram.org/bot${e}/getMe`);if(!n.ok){if(n.status===401)throw Error("token rejected \u2014 check you copied the whole line from @BotFather");throw Error(`Telegram returned ${n.status}`)}let A=await n.json();if(!A.ok||!A.result?.username)throw Error("Telegram accepted the token but returned no bot \u2014 try /newbot again");return{username:A.result.username}}async function Rhr(e){try{let n=await fetch(`https://api.telegram.org/bot${e}/getUpdates?limit=1`);if(!n.ok)return!1;let A=await n.json();return A.ok===!0&&Array.isArray(A.result)&&A.result.length>0}catch{return!1}}function Y8t(e){return l8n.find((n)=>n.id===e)}var Mhr,Thr,Khr,l8n;var $Ya=xt(()=>{Mhr=[1n<<10n,1n<<11n,1n<<16n,1n<<38n].reduce((e,n)=>e|n,0n).toString();Thr={id:"discord",title:"Discord agent setup",description:"chat with your agent from a Discord server",envKey:"DISCORD_BOT_TOKEN",module:"@axon/discord",steps:[{kind:"input",title:"get token",placeholder:"paste token",prompt:"Enter your Discord bot token below",secret:!0,validate:async(e,n)=>{try{let A=await qhr(e);if(n.set("botId",A.id),n.set("botTag",A.tag),await Lhr(e))n.set("inGuild","yes");return null}catch(A){return A instanceof Error?A.message:String(A)}},body:["1. Open the Discord developer portal:"," https://discord.com/developers/applications","","2. New Application \u2014 name it, then Create","","3. Open the Bot tab in the left sidebar","","4. Reset Token, confirm, then Copy"," Discord shows it once \u2014 copy before leaving the page","","5. Paste the token below. Nothing is written to your"," agent until it checks out."]},{kind:"work",title:"connecting",run:async(e)=>{await e.setEnv("DISCORD_BOT_TOKEN",e.input.trim()),await e.install("@axon/discord")}},{kind:"instruct",title:"invite",confirmLabel:"open the invite in my browser",skip:(e)=>e.get("inGuild")==="yes",url:(e)=>{return`https://discord.com/oauth2/authorize?${new URLSearchParams({client_id:e.get("botId")??"",scope:"bot",permissions:Mhr})}`},body:[{text:"\u2713 Token accepted \u2014 the module is installed and running.",tone:"success"},"","1. Open the invite below","","2. Pick the server your agent should join"," Permissions are already set: read messages, send"," replies, read history. Nothing to tick."]}]};Khr={id:"telegram",title:"Telegram agent setup",description:"your agent on your phone \u2014 no app to build",envKey:"TELEGRAM_BOT_TOKEN",module:"@axon/telegram",steps:[{kind:"input",title:"get token",placeholder:"paste token",prompt:"Enter your Telegram bot token below",secret:!0,body:["1. Open @BotFather in Telegram:"," https://t.me/BotFather","","2. Send /newbot","",'3. Pick a display name, then a username ending in "bot"',"","4. BotFather replies with a token:"," 123456789:ABC-DEF...","","5. Paste it below. Nothing is written until it checks out."],validate:async(e,n)=>{try{let A=await Uhr(e);return n.set("username",A.username),null}catch(A){return A instanceof Error?A.message:String(A)}}},{kind:"work",title:"connecting",run:async(e)=>{await e.setEnv("TELEGRAM_BOT_TOKEN",e.input.trim()),await e.install("@axon/telegram")}},{kind:"await",title:"say hello",waitingLabel:"waiting for your message...",url:(e)=>`https://t.me/${e.get("username")??""}`,body:[{text:"\u2713 Token accepted \u2014 the module is installed and running.",tone:"success"},"","Telegram will not let a bot message you first, so it cannot","reach you until you message it.","","1. Open your bot:","",'2. Send it anything \u2014 "hi" will do'],poll:async(e)=>Rhr(e.input.trim()),done:(e)=>`connected telegram \xB7 @${e.get("username")??""}`}]},l8n=[Thr,Khr]});function FBt(){let e=Uc(),n=e6();async function A(b){await e.commit("axon:connect:step",{connector:"connect",note:b})}async function i(b){let E=Y8t(b);if(!E)throw Pn("NOT_WIRED",{detail:`no connector named "${b}"`});let y=new Map,k="",x={get input(){return k},set:(S,L)=>{y.set(S,L)},get:(S)=>y.get(S),setEnv:async(S,L)=>{await e.setKey(S,L)},install:async(S)=>{await e.installModule(S)},note:async()=>{}};for(let[S,L]of E.steps.entries()){let U=E.steps.filter((te)=>te.kind!=="work"&&!(te.kind==="instruct"&&te.skip?.(x))),$=L.kind==="work"?0:U.indexOf(L)+1,V=`${L.title} \xB7 ${$}/${U.length}`;if(L.kind==="instruct"){if(L.skip?.(x))continue;let te=zYa(L,x);if(!await n.confirm(L.title,{header:{label:E.title,detail:V,body:[...L.body,...te?["",` ${te}`]:[]]},choices:{yes:L.confirmLabel,no:"cancel"}}))return await s(E.id);if(te)try{await Uhe(te)}catch{}continue}if(L.kind==="input"){let te=null;for(;;){let ee=await n.prompt(L.title,{placeholder:L.placeholder,...L.prompt?{prompt:L.prompt}:{},...L.secret?{secret:!0}:{},header:{label:E.title,detail:V,body:te?[...L.body??[],"",{text:`\u2717 ${te}`,tone:"error"}]:L.body??[]}});if(ee===void 0||ee.trim()==="")return await s(E.id);let me=ee.trim();if(te=L.validate?await L.validate(me,x):null,!te){k=me;break}}continue}if(L.kind==="await"){let te=zYa(L,x),ee=!1,me=(async()=>{while(!ee){if(await L.poll(x))return!0;await new Promise((ke)=>setTimeout(ke,1000))}return!1})(),be=n.confirm(L.title,{header:{label:E.title,detail:V,body:[...L.body,...te?["",` ${te}`]:[]]},choices:{yes:L.waitingLabel,no:"cancel"}});if(await Promise.race([me,be.then((ke)=>ke?"again":"abort")])==="abort")return ee=!0,await s(E.id);ee=!0,n.cancel(),await A(L.done(x));continue}try{await L.run(x)}catch(te){let ee=te instanceof Error?te.message:String(te);await A(`connect ${E.id} \u2014 ${ee}`);return}}YIe().invalidate(),await A(`connected ${E.id}${y.get("botTag")?` \xB7 ${y.get("botTag")}`:""}`)}async function s(b){await A(`connect ${b} \u2014 aborted`)}function u(b){let E=Y8t(b);if(!E)return!1;return YIe().names.value.includes(E.envKey)}async function p(b){let E=Y8t(b);if(!E)throw Pn("NOT_WIRED",{detail:`no connector named "${b}"`});if(!await n.confirm(`disconnect ${E.id}?`,{header:{label:`disconnect ${E.id}`,detail:"this cannot be undone",body:[`Removes ${E.module} and deletes ${E.envKey}`,"from your agent's .env.","",{text:"The token cannot be recovered \u2014 Discord shows it once.",tone:"warn"},"You would need a new one to reconnect."]},choices:{yes:`disconnect ${E.id}`,no:"keep it"}}))return;await e.uninstallModule(E.module),await e.unsetKey(E.envKey),YIe().invalidate(),await A(`disconnected ${E.id}`)}function d(){return YIe().refresh(),l8n.map((b)=>({id:b.id,description:b.description,connected:u(b.id)}))}return{begin:i,disconnect:p,isConnected:u,list:d}}function zYa(e,n){if(!e.url)return;return typeof e.url==="string"?e.url:e.url(n)}var WYa=xt(async()=>{Xft();qs();nLe();$Ya();await Qk([Ek(),u8n()])});import{join as g8n}from"path";function ZYa(){return Yhr.map(({id:e,hint:n})=>({kind:"action",label:e,description:n,workingMessage:"setting thinking effort...",action:async()=>{await Uc().setThinking(e)}}))}function jhr(e){let n=e.lastIndexOf("@");return n>0?e.slice(0,n):e}function o$(e,n=""){return{kind:"action",label:`(${e})`,description:n,invalid:!0,action:()=>{}}}function VYa(e){let n=A7e(e);n.ensure();let A=e==="module"?new Set(Uc().modules.value.map((s)=>s.packageName).filter((s)=>Boolean(s))):new Set(nL().declared.value.map(jhr)),i=K8t(e,{term:"",installed:A,mode:"install"});if(i.length===0){let s=n.error.value?`registry unavailable \u2014 ${n.error.value.message}`:n.loading.value?"loading catalogue...":`no ${e}s available to install`;return[o$(s)]}return i.map((s)=>({kind:"action",label:s.label,description:s.description??"",action:(u)=>{s.action(u)}}))}var Yhr,XYa,eja="detail",l_o,vBt;var p8n=xt(async()=>{Xft();qs();w8t();t7e();iLe();A3();await Qk([MIe(),Ek(),QYa(),M8t(),EBt(),aL(),KIe(),vYa(),NYa(),MYa(),c8n(),u8n(),T8t(),o8n(),a3(),WYa()]);Yhr=[{id:"low",hint:"fastest, cheapest \u2014 routine edits and lookups"},{id:"medium",hint:"balanced"},{id:"high",hint:"slower, more deliberate \u2014 debugging and design"},{id:"xhigh",hint:"maximum, where the provider offers it"}];XYa=[{label:"log",kind:"events",description:"This session's full event log, as an editor buffer"},{label:"flame",kind:"trace",description:"This session's trace \u2014 the flame graph"},{label:"engine",kind:"engine",description:"Engine calls and responses for this session"}],l_o=[...XYa.map((e)=>e.label),eja],vBt=[{kind:"group",label:"connections",description:"Discord, Telegram, Slack \u2014 connect or disconnect",children:()=>FBt().list().map(({id:e,description:n,connected:A})=>({kind:"group",label:e,description:A?"connected":n,children:()=>A?[{kind:"action",label:"reconnect",description:"replace the credential \u2014 the flow runs again",action:()=>{FBt().begin(e)}},{kind:"action",label:"disconnect",description:"remove the module and delete the credential",action:()=>{FBt().disconnect(e)}}]:[{kind:"action",label:"connect",description:n,action:()=>{FBt().begin(e)}}]}))},{kind:"group",label:"open",description:"Open this session in the editor \u2014 a pane, or the console panel",children:()=>{let e=Uc(),n=bAe();if(!n.available.value)return[{kind:"action",label:"(no editor attached)",description:"Open this project in an editor running Axon Fleet",action:()=>{throw Pn("NO_EDITOR_ATTACHED")}}];if(e.sessionId.value===null)return[{kind:"action",label:"(no session)",description:"Start or focus an agent first",action:()=>{throw Pn("NO_SESSION_TO_OPEN")}}];let A=async(s,...u)=>{let p=e.home.value;if(p)await n.editorAbout(p,s,...u);else await n.editor(s,...u)};return[...XYa.map((s)=>({kind:"action",label:s.label,description:s.description,workingMessage:`opening ${s.label}...`,action:async()=>{let u=e.sessionId.value;if(!u)throw Pn("NO_SESSION_TO_OPEN");await A("buffer",s.kind,u)}})),{kind:"action",label:eja,description:"Bring the console panel forward on this instance",workingMessage:"opening console...",action:async()=>{let s=e.sessionId.value;if(!s)throw Pn("NO_SESSION_TO_OPEN");await A("focus",{sessionId:s})}}]}},{kind:"group",label:"agent",description:"The running agent \u2014 spawn, close, reboot, clear",children:()=>[{kind:"group",label:"spawn",description:"Start an agent instance and focus it \u2014 the ~ key is faster",children:()=>{let e=Uc(),n=e.available.value;if(n.length===0)return[o$("no agents","Nothing to spawn \u2014 create one with :agent init")];return n.map((A)=>{if(A.kind==="deployed")return{kind:"action",label:A.name,description:`deployed \xB7 ${A.tier} \u2014 attach`,workingMessage:`connecting to ${A.name}...`,action:()=>{e.attachDeployment(A.deploymentId)}};let i=e.instancesByAgent.value.get(A.name)??[];return{kind:"action",label:A.name,description:i.length>0?`${i.length} running`:"",workingMessage:`starting ${A.name}...`,action:()=>{e.spawnSibling(A.dir)}}})}},{kind:"group",label:"switch",description:"Go to another running conversation \u2014 the / key is faster",children:()=>{let e=Uc(),n=e.instances.value.filter((A)=>A.exitedAt===null);if(n.length===0)return[o$("nothing running","Start one with :agent spawn")];return n.map((A)=>({kind:"action",label:A.name,description:A.focused?"focused":`${A.sessionId.slice(0,8)}${A.activity?` \xB7 ${A.activity}`:""}`,...A.focused?{invalid:!0}:{},action:()=>{if(A.focused)return;e.focus(A.sessionId)}}))}},{kind:"action",label:"close",description:"Shut down the focused agent instance",workingMessage:"closing instance...",action:()=>Uc().close()},{kind:"action",label:"reboot",description:"Reload the running agent (blueprint rescan + hot-swap)",workingMessage:"rebooting...",action:()=>Uc().reboot()},{kind:"action",label:"clear",description:"Clear the current conversation and start a fresh session",workingMessage:"clearing conversation...",action:()=>Uc().clear()},{kind:"action",label:"model",description:"Set the focused agent's model",action:()=>{let e=Mb();e.text.value="",e.mode.setMode("model")}},{kind:"action",label:"config",description:"Open the agent's axon.config.ts \u2014 modules, engine, policy",workingMessage:"opening agent config...",action:async()=>{let e=bAe();if(!e.available.value)throw Pn("NO_EDITOR_ATTACHED");let n=Uc().projectRoot.value;if(!n)throw Pn("NO_LOCAL_PROJECT");await e.editor("open",g8n(n,"axon.config.ts"))}},{kind:"group",label:"thinking",description:"Set the focused agent's thinking effort",children:ZYa}]},{kind:"action",label:"reload",description:"Reload your config \u2014 main.ts, plugins and extensions",workingMessage:"reloading config...",action:async()=>{let e=nL();await e.reload();let n=e.problems.value.length,A=Mk();if(n>0)A.show(`config reloaded \u2014 ${n} problem${n===1?"":"s"}`,"error");else A.show("config reloaded")}},{kind:"input",label:"init",description:"Scaffold a new agent",placeholder:"agent name",token:"name",workingMessage:"creating agent...",confirm:{choices:()=>[...XKe().locations().map((e)=>({label:e.label})),{label:"watch a new directory..."}]},action:async(e,n)=>{let A=XKe();if(!n)throw Pn("PALETTE_CHOICE_REQUIRED");if(n==="watch a new directory...")throw Pn("NOT_WIRED",{detail:"typing a path for a new watch target isn't wired into this choice step yet \u2014 run `axon watch <dir>` first, then `init` again"});let i=A.locations().find((s)=>s.label===n)?.dir;if(!i)throw Pn("PROJECT_NOT_FOUND",{context:{location:n}});await A.create(e,i),await Uc().select(e)}},{kind:"action",label:"exit",description:"Exit the application",action:()=>UIe().gracefulExit()},{kind:"action",label:"update",description:"Install the latest Axon release and exit",workingMessage:"preparing update...",action:(e)=>e7e().update(e)},{kind:"action",label:"logout",description:"Sign out of your Axon account",workingMessage:"logging out...",action:()=>b8().logout()},{kind:"action",label:"docs",description:"Open Axon documentation",action:()=>{Uhe("https://axon.arclabs.it/docs")}},{kind:"group",label:"module",description:"Agent modules \u2014 install into the focused agent, or remove one",children:()=>[{kind:"group",label:"install",description:"Install a registry module into the running agent",children:()=>VYa("module")},{kind:"group",label:"update",description:"Update this agent's modules",children:()=>{let e=SYa();return e.refresh(),q8t({entries:e.entries.value,checking:e.checking.value,noun:"module"}).map((n)=>{if(n.kind==="message")return o$(n.label,n.description);if(n.kind==="all")return{kind:"action",label:"all",description:`Update ${n.count} modules`,workingMessage:`updating ${n.count} modules...`,action:async()=>{await Uc().updateModules(n.entries.map((i)=>({name:i.name,version:i.latest}))),e.invalidate(),Mk().show(`updated ${n.count} modules`)}};let A=n.entry;return{kind:"action",label:A.name,description:`${A.current} \u2192 ${A.latest}`,workingMessage:`updating ${A.name}...`,keepOpen:!0,action:async()=>{await Uc().updateModules([{name:A.name,version:A.latest}]),e.invalidate(),Mk().show(`updated ${A.name} to ${A.latest}`)}}})}},{kind:"group",label:"uninstall",description:"Remove a module from the running agent",children:()=>{let e=Uc().modules.value;if(e.length===0)return[o$("none installed","This agent has no installed modules")];let n=e.filter(s8n);if(n.length===0)return[o$("none removable","This agent's modules are declared as imports \u2014 remove them from axon.config.ts")];return n.map((A)=>({kind:"action",label:A.packageName,description:A.version?`v${A.version}`:"",workingMessage:`removing ${A.packageName}...`,action:()=>{Uc().uninstallModule(A.packageName)}}))}}]},{kind:"input",label:"attach",description:"Bind to an agent already running at a URL",placeholder:"http://localhost:3010",token:"url",workingMessage:"attaching...",action:async(e)=>{await Uc().attachUrl(e)}},{kind:"group",label:"key",description:"The focused agent's own environment variables",children:()=>[{kind:"input",label:"set",description:"Set a variable in this agent's .env, then reload",placeholder:"NAME value",token:"NAME value",workingMessage:"setting key...",secret:!0,action:async(e)=>{let n=e.trim(),A=n.search(/\s/);if(A<1){Mk().show("usage: :key set NAME value");return}let i=n.slice(0,A),s=n.slice(A+1).trim();if(s===""){Mk().show("usage: :key set NAME value");return}await Uc().setKey(i,s),YIe().invalidate(),Mk().show(`set ${i} \xB7 reloaded`)}},{kind:"group",label:"list",description:"What this agent's .env defines",children:()=>{let e=YIe();if(e.refresh(),e.checking.value&&e.names.value.length===0)return[o$("reading\u2026","Reading this agent's .env")];if(e.names.value.length===0)return[o$("none set","This agent's .env defines nothing yet")];return e.names.value.map((n)=>({kind:"action",label:n,description:"set",invalid:!0,action:()=>{}}))}}]},{kind:"group",label:"cognet",description:"The agent's brain \u2014 move it to a newer version",children:()=>[{kind:"group",label:"update",description:"Update this agent's cognet",children:()=>{let e=GYa();e.refresh();let n=e.entry.value;return q8t({entries:n?[n]:[],checking:e.checking.value,noun:"cognet"}).map((A)=>{if(A.kind==="message")return o$(A.label,A.description);if(A.kind==="all")return{kind:"action",label:"all",description:`Update ${A.count} cognets`,workingMessage:"updating cognet...",action:async()=>{for(let s of A.entries)await Uc().updateCognet(s.name,s.latest);e.invalidate(),Mk().show("updated cognet")}};let i=A.entry;return{kind:"action",label:i.name,description:`${i.current} \u2192 ${i.latest}`,workingMessage:`updating ${i.name}...`,action:async()=>{await Uc().updateCognet(i.name,i.latest),e.invalidate(),Mk().show(`updated ${i.name} to ${i.latest}`)}}})}}]},{kind:"group",label:"ext",description:"Terminal extensions \u2014 commands, keys, palettes, themes",children:()=>[{kind:"group",label:"install",description:"Install a registry extension into your terminal",children:()=>VYa("extension")},{kind:"group",label:"update",description:"Update installed extensions",children:()=>{let e=FYa();return e.refresh(),q8t({entries:e.entries.value,checking:e.checking.value,noun:"extension"}).map((n)=>{if(n.kind==="message")return o$(n.label,n.description);if(n.kind==="all")return{kind:"action",label:"all",description:`Update ${n.count} extensions`,workingMessage:`updating ${n.count} extensions...`,action:async()=>{for(let i of n.entries)await nL().update(i.name,i.latest);e.invalidate(),Mk().show(`updated ${n.count} extensions`)}};let A=n.entry;return{kind:"action",label:A.name,description:`${A.current} \u2192 ${A.latest}`,workingMessage:`updating ${A.name}...`,keepOpen:!0,action:async()=>{await nL().update(A.name,A.latest),e.invalidate(),Mk().show(`updated ${A.name} to ${A.latest}`)}}})}},{kind:"group",label:"uninstall",description:"Remove an extension from your terminal",children:()=>{let e=nL().declared.value;if(e.length===0)return[o$("none installed","Your profile declares no extensions")];return e.map((n)=>({kind:"action",label:n,description:"",workingMessage:`removing ${n}...`,action:async()=>{await Uc().uninstallExtension(n),Mk().show(`removed ${n}`)}}))}}]},{kind:"group",label:"session",description:"This conversation \u2014 fork it, name it, open its log",children:()=>[{kind:"action",label:"pick",description:"Reopen a past conversation \u2014 the ^ key does this",action:()=>{let e=Mb();e.text.value="",e.mode.setMode("session")}},{kind:"action",label:"fork",description:"Copy this conversation \u2014 the copy diverges, this one is untouched",workingMessage:"forking session...",action:async()=>{let e=await Uc().forkSession();Mk().show(`forked \u2192 ${e.sessionId.slice(0,8)} \xB7 open it with ^`)}},{kind:"input",label:"rename",description:"Give this conversation a name",placeholder:"a short name",token:"title",workingMessage:"renaming session...",action:async(e)=>{await Uc().renameSession(e),Mk().show(`renamed \u2192 ${e}`)}},{kind:"action",label:"open",description:"Open this session's .jsonl in the editor",workingMessage:"opening session log...",action:async()=>{let e=Uc(),n=bAe(),A=e.sessionFile.value;if(!A)throw Pn("NO_SESSION_TO_OPEN");if(!n.available.value)throw Pn("NO_EDITOR_ATTACHED");let i=e.home.value;if(i)await n.editorAbout(i,"open",A);else await n.editor("open",A)}}]},{kind:"action",label:"clear",description:"Clear the current conversation and start a fresh session",workingMessage:"clearing conversation...",action:()=>Uc().clear()},{kind:"action",label:"model",description:"Set the focused agent's model",action:()=>{let e=Mb();e.text.value="",e.mode.setMode("model")}},{kind:"group",label:"thinking",description:"Set the focused agent's thinking effort",children:ZYa},{kind:"action",label:"config",description:"Open your main.ts in the editor \u2014 your own commands, keys and plugins",workingMessage:"opening config...",action:async()=>{let e=bAe();if(!e.available.value)throw Pn("NO_EDITOR_ATTACHED");await e.editor("open",g8n(IC().profile.root,"main.ts"))}},{kind:"action",label:"profile",description:"Open your profile.config.ts in the editor \u2014 extensions, theme, paths",workingMessage:"opening profile...",action:async()=>{let e=bAe();if(!e.available.value)throw Pn("NO_EDITOR_ATTACHED");await e.editor("open",g8n(IC().profile.root,"profile.config.ts"))}},{kind:"input",label:"watch",description:"Register a directory as an agent location \u2014 scanned by init and the agent list",placeholder:"~/path/to/directory",token:"dir",workingMessage:"watching directory...",action:async(e)=>{await XKe().watch(e)}},{kind:"group",label:"unwatch",description:"Stop scanning a directory for agents",children:()=>{let e=XKe().watched();if(e.length===0)return[o$("no watched directories")];return e.map((n)=>({kind:"action",label:n.label,description:n.dir,workingMessage:"unwatching directory...",action:async()=>{await XKe().unwatch(n.dir)}}))}},{kind:"group",label:"provider",description:"Manage the inference sources your agents can use",children:[{kind:"group",label:"codex",description:"OpenAI Codex subscription (BYOK)",children:()=>{let e=b8().connections.openai;if(!e.connected.value)return[{kind:"action",label:"connect",description:"Sign in with your OpenAI account",workingMessage:"waiting for browser sign-in...",action:()=>e.connect()}];return[{kind:"action",label:"disconnect",description:"Remove the OpenAI connection from your account",workingMessage:"disconnecting...",action:()=>e.disconnect()}]}},{kind:"group",label:"openrouter",description:"OpenRouter API key (BYOK)",children:()=>{let e=b8().connections.openrouter;if(!e.connected.value)return[{kind:"input",label:"connect",description:"Store this OpenRouter API key in your account vault",placeholder:"paste your OpenRouter API key (openrouter.ai/keys)",token:"key",workingMessage:"verifying and storing key...",action:(n)=>e.connect(n)}];return[{kind:"action",label:"disconnect",description:"Remove the OpenRouter key from your account",workingMessage:"disconnecting...",action:()=>e.disconnect()}]}},{kind:"group",label:"ollama",description:"Local models through an Ollama daemon",children:()=>{let e=b8().connections.ollama;if(!e.connected.value)return[{kind:"action",label:"enable",description:"Use local Ollama models in your agents",workingMessage:"enabling...",action:()=>e.connect()}];return[{kind:"action",label:"disable",description:"Stop using local Ollama models",workingMessage:"disabling...",action:()=>e.disconnect()}]}}]},{kind:"group",label:"theme",description:"How the terminal looks \u2014 pick a theme, or go back to the default",children:()=>[{kind:"group",label:"set",description:"Choose a theme \u2014 previews as you move",children:()=>{let e=nE(),n=e.committedName.value;return e.themes.value.map((A)=>({kind:"action",label:A.name,description:A.name===n?"current":"",preview:()=>{e.preview(A.name)},action:()=>{e.set(A.name)}}))}},{kind:"action",label:"reset",description:`Go back to ${D8t}, the theme Axon ships with`,action:()=>nE().reset()}]},{kind:"group",label:"lines",description:"Turn status lines on and off",children:()=>[{kind:"group",label:"toggle",description:"Flip a line on or off \u2014 the list stays up",children:()=>{let e=r$();return e.listRegistered().map((n)=>{let A=e.isVisible(n);return{kind:"action",label:n,description:A?"on \u2014 press to hide":"off \u2014 press to show",keepOpen:!0,action:()=>A?e.hide(n):e.show(n)}})}},{kind:"group",label:"on",description:"Show a line",children:()=>{let e=r$();return e.listRegistered().filter((n)=>!e.isVisible(n)).map((n)=>({kind:"action",label:n,description:"Show this line",keepOpen:!0,action:()=>e.show(n)}))}},{kind:"group",label:"off",description:"Hide a line",children:()=>{let e=r$();return e.list().filter((n)=>n.visible).map((n)=>({kind:"action",label:n.name,description:"Hide this line",keepOpen:!0,action:()=>e.hide(n.name)}))}}]}]});function o7e(e,n,A,i){return(s)=>{let u=xR(),p={path:e,source:n,...i!==void 0?{arg:i}:{}},d;try{d=A(s)}catch(b){throw u.notify("command:failed",{...p,error:b}),b}if(!(d instanceof Promise)){u.notify("command:ran",p);return}return d.then(()=>{u.notify("command:ran",p)},(b)=>{throw u.notify("command:failed",{...p,error:b}),b})}}var m8n=xt(()=>{RIe()});function Phr(e){if(e==="")return"";let n=e.search(/\s/);if(n<0)return e;if(e.slice(n+1).trim()==="")return e;return`${e.slice(0,n)} ${Hhr}`}var Hhr="\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",tja;var nja=xt(async()=>{Fs();V6e();m8n();A3();await p8n();tja={id:"command",skipDefaultFilter:!0,onCancel:()=>{nE().cancelPreview()},resolve:uA.computed(()=>(e)=>{let n=BYa(e,[...vBt,...F8t.value]);if(n.breadcrumb[0]!=="theme")nE().cancelPreview();function A(s){if(s.kind==="group"||s.kind==="input"){let p=IYa(n.breadcrumb,s.label);return{id:s.label,label:s.label,description:s.description,descendQuery:p,completeQuery:p,action:()=>{}}}let u=[...n.breadcrumb,s.label];return{...s.invalid?{invalid:!0}:{},...s.keepOpen?{keepOpen:!0}:{},...s.choices?{choices:s.choices}:{},...s.preview?{preview:s.preview}:{},id:s.label,label:s.label,description:s.description,workingMessage:s.workingMessage,completeQuery:u.join(" "),action:o7e(u,"palette",s.action)}}if(n.nodes.length===0&&n.exactMatch?.kind==="action"&&!n.input){let s=n.exactMatch;return{items:[A(s)],breadcrumb:G8t(n.breadcrumb),invalid:!1}}if(n.input){let{node:s,value:u}=n.input,p=n.breadcrumb,d=s.secret?Phr(u):u,b=s.secret?void 0:u;return{items:[{id:s.label,label:d||`<${s.token}>`,placeholder:!u,...u?{}:{invalid:!0},description:u?s.description:s.placeholder,workingMessage:s.workingMessage,...s.confirm?{choices:()=>{return s.confirm.choices(u).map((E)=>({id:E.label,label:E.label,description:E.description,workingMessage:s.workingMessage,action:o7e(p,"palette",(y)=>Promise.resolve(s.action(u,E.label,y)),b)}))},action:()=>{}}:{action:o7e(p,"palette",(E)=>Promise.resolve(s.action(u,void 0,E)),b)}}],breadcrumb:G8t(n.breadcrumb),invalid:!1}}let i=n.exactMatch!==null&&n.exactMatch.kind==="action";return{items:n.nodes.map(A),breadcrumb:G8t(n.breadcrumb),invalid:!i}})}});function $hr(){let e=IC(),n=e.cloud.client.registry.models,A=e.store.cache.file(Jhr),i=uA.ref([]),s=uA.ref([]),u=uA.ref(!1),p=uA.ref(null),d=0,b=!1;function E(){if(d>0)return;let S=null;try{S=A.get()}catch{S=null}if(!S?.models?.length)return;i.value=S.models,s.value=S.failures??[],d=S.at??1}function y(){if(b)return;if(b=!0,i.value.length===0)u.value=!0;n.all().then((S)=>{i.value=S.models,s.value=S.failures,d=Date.now();try{A.set({...S,at:d})}catch{}p.value=null}).catch((S)=>{if(i.value.length===0)p.value=S instanceof Error?S:Error(String(S))}).finally(()=>{b=!1,u.value=!1})}function k(){if(E(),d===0||Date.now()-d>Ohr)y()}function x(){if(!p.value)return;p.value=null,y()}return{models:i,failures:s,loading:u,error:p,ensure:k,reset:x}}function rLe(){if(!d8n)d8n=$hr();return d8n}function aja(){rLe().ensure()}var Jhr="models",Ohr=1800000,d8n;var j8t=xt(async()=>{Fs();await a3()});function Whr(){let e=IC().store,n=uA.ref(e.state.get()?.recentModels??[]),A=uA.computed(()=>n.value);function i(s){let u=[s,...n.value.filter((p)=>p!==s)].slice(0,zhr);n.value=u;try{e.state.update((p)=>({...p,recentModels:u}))}catch{}}return{order:A,record:i}}function s7e(){if(!f8n)f8n=Whr();return f8n}var zhr=25,f8n;var Aja=xt(async()=>{Fs();await a3()});function Xhr(){let e=IC(),n=e.ollama,A=e.store.cache.file(Zhr),i=uA.ref(null),s=uA.ref([]),u=uA.ref({}),p=uA.ref(null),d=uA.ref(null),b=0,E=!1;function y(){let U=new Set(s.value.map(($)=>$.name));return n.registry.browse().map(($)=>({...$,installed:U.has($.name),...u.value[$.name]===void 0?{}:{size:u.value[$.name]}}))}function k(){if(b>0)return;try{let U=A.get();if(!U?.sizes)return;u.value=U.sizes,b=U.at??1}catch{}}async function x(){if(E)return;E=!0;try{let U=await n.status();if(i.value=U.running,!U.running){s.value=[];return}s.value=await n.models.list(),d.value=null;let $=n.registry.browse(),V=await Promise.all($.map(async(ee)=>{try{let me=await n.registry.resolve(ee.name);return me?[ee.name,me.size]:null}catch{return null}})),te={};for(let ee of V)if(ee)te[ee[0]]=ee[1];if(Object.keys(te).length>0){u.value=te,b=Date.now();try{A.set({sizes:te,at:b})}catch{}}}catch(U){d.value=U instanceof Error?U:Error(String(U)),i.value=!1}finally{E=!1}}function S(){if(k(),i.value===null||b===0||Date.now()-b>Vhr)x()}async function L(U){if(p.value)throw Error(`already downloading ${p.value.name}`);p.value={name:U,percent:null,status:"starting",bytes:null};try{for await(let $ of n.models.pull(U))if(p.value=ebr(U,$),$.done)break;s.value=await n.models.list()}catch($){throw d.value=$ instanceof Error?$:Error(String($)),$}finally{p.value=null}}return{running:i,installed:s,catalog:y,sizes:u,pulling:p,error:d,ensure:S,refresh:x,pull:L}}function ebr(e,n){return{name:e,percent:n.percent,status:n.status,bytes:n.total!==void 0&&n.completed!==void 0?{completed:n.completed,total:n.total}:null}}function c7e(){if(!h8n)h8n=Xhr();return h8n}var Zhr="ollama-sizes",Vhr=86400000,h8n;var b8n=xt(async()=>{Fs();await a3()});function nbr(e){let n=new Set;for(let A of e)for(let i of A.routes)n.add(i.via);if(n.add("axon"),c7e().running.value)n.add("ollama");return tbr.filter((A)=>n.has(A))}function abr(e,n){let A=0;for(let i of n)if(i.routes.some((s)=>s.via===e))A++;return A}function Abr(e){let n=rLe().models.value,A=abr(e,n),i=uja(e);if(i&&!i.connected.value)return{id:`route:${e}`,label:e,description:`${rja[e]??`${A} models`} \xB7 ${i.hint}`,...i.workingMessage?{workingMessage:i.workingMessage}:{},action:i.connect};return{id:`route:${e}`,label:e,description:rja[e]??`${A} models`,descendQuery:`${e}:`,completeQuery:`${e}:`,action:()=>{}}}function uja(e){let n=b8();switch(e){case"codex":return{connected:n.connections.openai.connected,hint:"not connected \xB7 enter to sign in",workingMessage:"waiting for browser sign-in...",connect:()=>n.connections.openai.connect()};case"ollama":return{connected:n.connections.ollama.connected,hint:"not enabled \xB7 enter to enable",workingMessage:"enabling local models...",connect:()=>n.connections.ollama.connect()};case"openrouter":return{connected:n.connections.openrouter.connected,hint:"no key \xB7 run :provider openrouter connect",connect:()=>{}};default:return null}}function ibr(e){let n=s7e().order.value;if(n.length===0)return[{...C8n(),label:"axon:auto"}];let A=[];for(let i of n.slice(0,rbr)){if(i==="axon:auto"){A.push({...C8n(),label:"axon:auto"});continue}let s=i.indexOf(":");if(s===-1)continue;let u=i.slice(0,s),p=i.slice(s+1),d=uja(u);if(d&&!d.connected.value)continue;let b=e.find((y)=>y.routes.some((k)=>k.via===u&&k.model===p)),E=b?.routes.find((y)=>y.via===u&&y.model===p);if(!b||!E)continue;A.push({...lja(b,E),label:i})}return A}function ija(e){return{id:`header:${e}`,label:e,action:()=>{},header:!0}}function obr(e){return{id:`sep:${e}`,label:"",action:()=>{},separator:!0}}function C8n(){let e=Uc().model.value==="axon:auto";return{id:"axon:auto",label:"auto",chunks:["axon","auto"],completeQuery:"axon:auto",description:e?"(current) axon picks per request":"axon picks per request",action:()=>{return s7e().record("axon:auto"),B8n("axon:auto")},workingMessage:"switching to auto..."}}function lja(e,n){let A=Uc().model.value===`${n.via}:${n.model}`;return{id:`${n.via}:${n.model}`,label:e.id,chunks:[n.via,e.id],completeQuery:`${n.via}:${n.model}`,description:`${A?"(current) ":""}${lbr(e,n)}`,action:()=>{if(n.via==="openrouter"&&!b8().connections.openrouter.connected.value)return Promise.reject(Pn("PROVIDER_NOT_CONNECTED",{detail:"OpenRouter key not connected \u2014 run :provider openrouter connect first",context:{provider:"openrouter"}}));if(n.via==="codex"&&!b8().connections.openai.connected.value)return Promise.reject(Pn("PROVIDER_NOT_CONNECTED",{detail:"OpenAI account not connected \u2014 run :provider codex connect first",context:{provider:"codex"}}));return s7e().record(`${n.via}:${n.model}`),B8n(cbr(n))},workingMessage:`switching to ${ubr(e)} via ${n.via}...`}}function sbr(){let e=c7e(),n=Uc().model.value,A=(s)=>n===`ollama:${s}`;return e.catalog().map((s)=>{let u=s.size===void 0?null:`${(s.size/1e9).toFixed(1)}GB`,p=s.capabilities.filter((d)=>d!=="chat").join(" ");return{installed:s.installed===!0,id:`ollama:${s.name}`,label:s.name,chunks:["ollama",s.name],completeQuery:`ollama:${s.name}`,description:[A(s.name)?"(current)":null,s.installed?"installed":u?`download ${u}`:"download",s.parameters,p||null,s.description].filter(Boolean).join(" \xB7 "),action:async()=>{if(s7e().record(`ollama:${s.name}`),await B8n(`ollama:${s.name}`),!s.installed)e.pull(s.name).catch(()=>{})},workingMessage:s.installed?`switching to ${s.name}...`:`downloading ${s.name}...`}}).sort((s,u)=>Number(u.installed)-Number(s.installed)).map(({installed:s,...u})=>u)}async function B8n(e){await Uc().setModel(e)}function cbr(e){return`${e.via}:${e.model}`}function ubr(e){let n=e.name.indexOf(": ");return n===-1?e.name:e.name.slice(n+2)}function lbr(e,n){let A=b8().connections,i=[];if(n.via==="openrouter"&&!A.openrouter.connected.value)i.push("no key");if(n.via==="codex"&&!A.openai.connected.value)i.push("not connected");if(e.context>0)i.push(gbr(e.context));if(n.via==="axon")i.push(`${sja(n.pricing.inPerMTok)}/${sja(n.pricing.outPerMTok)}`);if(n.via==="openrouter"&&n.pricing)i.push(`${oja(n.pricing.prompt)}/${oja(n.pricing.completion)}`);if(n.via==="codex")i.push("sub");return i.join(" \xB7 ")}function gbr(e){if(e>=1e6)return`${(e/1e6).toFixed(e%1e6===0?0:1)}m`;return`${Math.round(e/1000)}k`}function oja(e){return`$${e.toFixed(e>0&&e<0.01?4:2)}`}function sja(e){let n=e/100;return`\xA3${n.toFixed(n>0&&n<0.01?4:2)}`}var cja,tbr,rbr=5,rja;var gja=xt(async()=>{Fs();qs();await Qk([Ek(),MIe(),j8t(),Aja(),b8n()]);cja={id:"model",maxHeight:8,onEnter:()=>{let e=rLe();e.ensure(),e.reset(),c7e().ensure()},skipDefaultFilter:!0,resolve:uA.computed(()=>(e)=>{let n=Uc(),A=rLe();if(!n.displayName.value)return{items:[{id:"model:no-agent",label:"no agent running",description:"press | to start one first",action:()=>{},invalid:!0}]};let s=[],u=A.models.value.length===0;if(u&&A.error.value)return s.push({id:"models:error",label:"error",description:A.error.value.message,action:()=>{},invalid:!0}),{items:s};if(u&&A.loading.value)return s.push({id:"models:loading",label:"\u2026",description:"loading models...",action:()=>{},invalid:!0}),{items:s};for(let V of A.failures.value)s.push({id:`failure:${V.source}`,label:V.source,description:V.message,action:()=>{},invalid:!0});let p=e.indexOf(":"),d=(p===-1?e:e.slice(0,p)).trim().toLowerCase(),b=p===-1?null:e.slice(p+1).trim().toLowerCase(),E=nbr(A.models.value);if(b===null){let V=ibr(A.models.value),te=E.filter((me)=>me.includes(d)),ee=d.length===0?V:V.filter((me)=>{let be=me.chunks?.[0];return be!==void 0&&be.includes(d)});if(te.length===0&&ee.length===0)return s.push({id:"route:none",label:"no such provider",description:E.join(" \xB7 "),action:()=>{},invalid:!0}),{items:s,invalid:!0};if(ee.length>0){if(s.push(ija("recent"),...ee),te.length>0)s.push(obr("providers"),ija("providers"))}return s.push(...te.map(Abr)),{items:s}}let y=E.filter((V)=>V.includes(d));if(y.length!==1)return s.push({id:"route:ambiguous",label:y.length===0?"no such provider":"which provider?",description:(y.length===0?E:y).join(" \xB7 "),action:()=>{},invalid:!0}),{items:s,invalid:!0};let k=y[0],x=[];if(k==="axon")x.push(C8n());if(k==="ollama")x.push(...sbr());for(let V of A.models.value)for(let te of V.routes)if(te.via===k)x.push(lja(V,te));let S=s7e().order.value,L=(V)=>{let te=S.indexOf(V.id);return te===-1?Number.MAX_SAFE_INTEGER:te},U=x.sort((V,te)=>L(V)-L(te)),$=b.length===0?U:U.filter((V)=>aLe(b,[V.label])!==null);if($.length===0)return s.push({id:"model:none",label:"no match",description:`${k} has no model matching "${b}"`,action:()=>{},invalid:!0}),{items:s,breadcrumb:`${k} \u203A`,invalid:!0};return s.push(...$),{items:s,breadcrumb:`${k} \u203A`}})},tbr=["axon","codex","openrouter","ollama"];rja={axon:"managed inference \xB7 billed to your Axon ledger",codex:"your ChatGPT subscription",openrouter:"your own OpenRouter key",ollama:"models on this machine \xB7 free"}});var pja;var mja=xt(async()=>{Fs();eLe();await aL();pja={id:"help",resolve:uA.computed(()=>()=>{return{items:Object.entries(vne).map(([n,A])=>({id:A,label:`${IBt[A]} ${A}`,description:v8t[A]??n,action:()=>{Mb().mode.setMode(A)}}))}})}});function pbr(e){let n=uA.ref(0);function A(){n.value++}let i=uA.computed(()=>{return n.value,e.history.recent()});function s(u,p){e.history.append(u,p),A()}return{entries:i,append:s}}function SBt(){if(!I8n)I8n=pbr(IC().store);return I8n}var I8n;var E8n=xt(async()=>{Fs();await a3()});var dja;var fja=xt(async()=>{Fs();await Qk([E8n(),aL()]);dja={id:"history",anchor:"bottom",skipDefaultFilter:!0,resolve:uA.computed(()=>()=>{return{items:SBt().entries.value.slice().reverse().map((n)=>({id:n.id,label:n.content,description:n.agentName??void 0,preview:()=>{Mb().previewHistory(n.content)},action:()=>{}}))}})}});function mbr(){return{ordered:[],originSessionId:null,originRoute:null,committed:!1}}function dbr(e,n){let A=new Map(e.map((y)=>[y.sessionId,y])),i=new Map,s=[];for(let y of e){let k=y.parentSessionId,x=k?A.get(k):void 0;if(!x){s.push(y);continue}let S=i.get(x.sessionId);if(S)S.push(y);else i.set(x.sessionId,[y])}let u=new Map(n.map((y,k)=>[y,k])),p=(y)=>u.get(y.sessionId)??Number.MAX_SAFE_INTEGER;s.sort((y,k)=>p(y)-p(k));let d=[],b=new Set,E=(y,k,x)=>{if(b.has(y.sessionId))return;b.add(y.sessionId),d.push({...y,indent:k,last:x});let S=i.get(y.sessionId)??[];S.forEach((L,U)=>E(L,k+1,U===S.length-1))};s.forEach((y,k)=>E(y,0,k===s.length-1));for(let y of e){if(b.has(y.sessionId))continue;b.add(y.sessionId),d.push({...y,indent:0,last:!0})}return d}function fbr(){let e=NBt.value;if(e.committed)return;let n=Uc();if(e.originSessionId&&n.instances.value.some((A)=>A.sessionId===e.originSessionId))n.focus(e.originSessionId);if(e.originRoute)JB().push(e.originRoute)}function hbr(e){let n=()=>{Uc().focus(e.sessionId),JB().push("/")},A=e.exitedAt!==null;return{id:`instance:${e.sessionId}`,label:`${bbr(e)}${e.name}`,completeQuery:e.name,description:Cbr(e),...A?{invalid:!0,action:()=>{}}:{preview:n,action:()=>{NBt.value={...NBt.value,committed:!0},n()}}}}function bbr(e){if(e.indent===0)return"";return`${" ".repeat(e.indent-1)}${e.last?"\u2514\u2500 ":"\u251C\u2500 "}`}function Cbr(e){let n=[];if(e.exitedAt!==null)n.push(`exited ${Bbr(e.exitedAt)}`);else{if(e.focused)n.push("active");if(e.activity)n.push(e.activity)}return n.push(e.sessionId.slice(0,8)),n.join(" \xB7 ")}function Bbr(e){let n=Math.floor((Date.now()-e)/60000);return n<1?"just now":`${n}m ago`}var NBt,hja;var bja=xt(async()=>{Fs();await Ek();NBt=uA.ref(mbr()),hja={id:"instance",maxHeight:8,onEnter:()=>{let n=Uc().instances.value,A=n.find((i)=>i.focused)?.sessionId??null;NBt.value={originSessionId:A,originRoute:JB().currentRoute.value.path,committed:!1,ordered:[...A?[A]:[],...n.filter((i)=>i.sessionId!==A).map((i)=>i.sessionId)]}},onCancel:fbr,resolve:uA.computed(()=>(e)=>{let n=Uc().instances.value;if(n.length===0)return{items:[{id:"instance:none",label:"nothing running",description:"press ~ to start an agent",action:()=>{},invalid:!0}]};return{items:dbr(n,NBt.value.ordered).map(hbr)}})}});function Ibr(e,n){return{id:`agent:${e.name}`,label:e.name,description:n.length>0?`${n.length} running`:void 0,action:()=>Uc().spawnSibling(e.dir),detach:!0,workingMessage:`starting ${e.name}...`}}function Ebr(e){return{id:`deployment:${e.deploymentId}`,label:e.name,description:`running \xB7 ${e.tier}`,action:()=>Uc().attachDeployment(e.deploymentId),detach:!0,workingMessage:`connecting to ${e.name}...`}}function y8n(e){return{id:`header:${e}`,label:e,action:()=>{},header:!0}}function Cja(e){return{id:`sep:${e}`,label:"",action:()=>{},separator:!0}}var Bja;var Ija=xt(async()=>{Fs();await Ek();Bja={id:"agent",maxHeight:8,resolve:uA.computed(()=>(e)=>{let n=Uc(),A=[],i=n.available.value,s=i.filter((p)=>p.kind==="local");if(s.length>0){A.push(y8n("agents"));for(let p of s){let d=n.instancesByAgent.value.get(p.name)??[];A.push(Ibr(p,d))}}let u=i.filter((p)=>p.kind==="deployed");if(u.length>0){A.push(Cja("cloud"),y8n("deployed"));for(let p of u)A.push(Ebr(p))}if(n.deploymentsError.value)A.push(Cja("cloud"),y8n("deployed")),A.push({id:"deployments:error",label:"unavailable",description:n.deploymentsError.value.message,action:()=>{},invalid:!0});return{items:A}})}});function ybr(e){return e.hasEntries||e.running||e.forkedFrom!==null}function Qbr(e){let n=new Map(e.map((y)=>[y.sessionId,y])),A=new Map,i=[];for(let y of e){let k=y.forkedFrom,x=k?n.get(k):void 0;if(!x){i.push(y);continue}let S=A.get(x.sessionId);if(S)S.push(y);else A.set(x.sessionId,[y])}let s=new Map,u=(y)=>{let k=s.get(y.sessionId);if(k!==void 0)return k;s.set(y.sessionId,y.modifiedAt);let x=y.modifiedAt;for(let S of A.get(y.sessionId)??[])x=Math.max(x,u(S));return s.set(y.sessionId,x),x},p=(y,k)=>u(y)-u(k);i.sort(p);for(let y of A.values())y.sort(p);let d=[],b=new Set,E=(y,k,x)=>{if(b.has(y.sessionId))return;b.add(y.sessionId),d.push({...y,indent:k,last:x});let S=A.get(y.sessionId)??[];S.forEach((L,U)=>E(L,k+1,U===S.length-1))};i.forEach((y,k)=>E(y,0,k===i.length-1));for(let y of e){if(b.has(y.sessionId))continue;b.add(y.sessionId),d.push({...y,indent:0,last:!0})}return d}function _br(e){if(e.indent===0)return"";return`${" ".repeat(e.indent-1)}${e.last?"\u2514\u2500 ":"\u251C\u2500 "}`}function wbr(e){let n=[Dbr(e.modifiedAt)];if(e.running)n.push("running");if(e.title)n.push(e.sessionId.slice(0,8));return n.push(kbr(e.sizeBytes)),n.join(" \xB7 ")}function kbr(e){if(e<1024)return`${e}b`;if(e<1048576)return`${Math.round(e/1024)}k`;return`${(e/1048576).toFixed(1)}M`}function Dbr(e){let n=Math.max(0,Math.round((Date.now()-e)/1000));if(n<60)return"just now";if(n<3600)return`${Math.round(n/60)}m ago`;if(n<86400)return`${Math.round(n/3600)}h ago`;return`${Math.round(n/86400)}d ago`}var Eja;var yja=xt(async()=>{Fs();await Ek();Eja={id:"session",maxHeight:8,anchor:"bottom",resolve:uA.computed(()=>(e)=>{let n=Uc(),A=n.home.value,i=A?A.split("/").filter(Boolean).at(-1)??null:null,s=n.displayName.value;if(!s)return{items:[{id:"session:no-agent",label:"no agent running",description:"press ~ to start one first",action:()=>{},invalid:!0}]};let u=n.sessions.value.filter((d)=>d.agent===i&&ybr(d)).slice().reverse();if(u.length===0)return{items:[{id:"session:none",label:"no past sessions",description:`${s} has no history yet`,action:()=>{},invalid:!0}]};return{items:Qbr(u).map((d)=>({id:`session:${d.sessionId}`,label:`${_br(d)}${d.title??d.sessionId.slice(0,8)}`,completeQuery:d.title??d.sessionId.slice(0,8),description:wbr(d),preview:()=>{n.preview.show(d)},action:()=>n.resume(d.agent,d.sessionId),detach:!0}))}})}});var Qja;var _ja=xt(()=>{Fs();A3();Qja={id:"theme",resolve:uA.computed(()=>()=>{let e=nE(),n=e.committedName.value;return{items:e.themes.value.map((i)=>({id:i.name,label:i.name,description:i.name===n?"current":"",current:i.name===n,preview:()=>{e.preview(i.name)},action:()=>{e.set(i.name)}}))}}),onCancel:()=>{nE().cancelPreview()}}});function xbr(){let e=IC().files,n=uA.ref([]),A=uA.ref(!1),i=uA.ref(null),s=uA.ref(!1),u=!1;function p(){if(u||A.value)return;A.value=!0,e.list().then((b)=>{n.value=b,s.value=e.truncated,i.value=null}).catch((b)=>{i.value=b instanceof Error?b:Error(String(b))}).finally(()=>{u=!0,A.value=!1})}function d(){e.invalidate(),u=!1,i.value=null}return{entries:n,loading:A,error:i,truncated:s,root:e.root,ensure:p,invalidate:d}}function _8n(){if(!Q8n)Q8n=xbr();return Q8n}function wja(){_8n().ensure()}var Q8n;var w8n=xt(async()=>{Fs();await a3()});function Fbr(e){let n=e.split("/").filter(Boolean),A=3,i=n.length>3?n.slice(-3):n;return`${n.length>3?"\u2026 \u203A ":""}${i.join(" \u203A ")} \u203A`}function kja(e){return e.startsWith(".")||e.includes("/.")}function vbr(e,n){let A=n===""?"":n;return[...e.filter((u)=>{if(!u.path.startsWith(A))return!1;let p=u.path.slice(A.length);return p.length>0&&!p.includes("/")})].sort((u,p)=>{if(u.directory!==p.directory)return u.directory?-1:1;let d=u.name.startsWith(".");if(d!==p.name.startsWith("."))return d?1:-1;return u.name.localeCompare(p.name)}).slice(0,xja).map((u)=>Fja(u,u.name))}function Sbr(e,n){let A=[];for(let i of e){let s=aLe(n,[i.name,i.path]);if(s===null)continue;A.push({entry:i,score:s})}return A.sort((i,s)=>s.score-i.score||Number(i.entry.directory)-Number(s.entry.directory)||Number(kja(i.entry.path))-Number(kja(s.entry.path))||i.entry.path.length-s.entry.path.length),A.slice(0,xja).map((i)=>Fja(i.entry,i.entry.path))}function Fja(e,n){let A=e.directory?"/":"";return{id:`file:${e.path}`,label:n+A,chunks:[e.name,e.path],completeQuery:e.path+A,...e.directory?{descendQuery:`${e.path}/`}:{},action:e.directory?()=>{}:()=>{Mb().resolveInline(e.path)}}}var Dja,xja=200;var vja=xt(async()=>{Fs();await Qk([w8n(),aL()]);Dja={id:"file",maxHeight:10,skipDefaultFilter:!0,resolve:uA.computed(()=>(e)=>{let n=_8n();if(n.ensure(),n.error.value)return{items:[],status:{kind:"error",message:`cannot read ${n.root} \u2014 ${n.error.value.message}`}};let A=n.entries.value,i=e.trim(),s=i===""||i.endsWith("/"),u=s?vbr(A,i):Sbr(A,i);if(n.loading.value&&u.length===0)return{items:[],status:{kind:"loading",message:"reading working tree..."}};return{items:u,...s&&i!==""?{breadcrumb:Fbr(i)}:{},...n.truncated.value?{status:{kind:"error",message:"tree too large \u2014 results are partial"}}:{}}})}});function Nbr(){if(Sja)return;Sja=!0;for(let e of[tja,cja,pja,dja,hja,Bja,Eja,YYa,JYa,Qja,Dja])fYa(e)}function Nja(e){Nbr();let{mode:n,query:A,setQuery:i}=e,s=e.hint??(()=>null),u=uA.ref(0),p=uA.ref(0),d=uA.ref(!1),b=uA.ref(null),E=uA.computed(()=>N8t(n.value)),y=uA.ref(null),k=3,x=uA.ref(null),S=uA.ref(0),L=uA.computed(()=>E.value?.tabs??null),U=uA.computed(()=>{let Ya=L.value;if(!Ya)return null;return Ya.slice(S.value,S.value+k)});function $(Ya){let ga=L.value;if(!ga)return;let fr=ga.findIndex((Ye)=>Ye.id===Ya);if(fr===-1)return;if(x.value=Ya,fr<S.value)S.value=fr;else if(fr>=S.value+k)S.value=fr-k+1;je()}let V=HC();uA.watch(n,(Ya,ga)=>{if(ga!==void 0&&ga!==Ya)N8t(ga)?.onCancel?.(y.value);let fr=N8t(Ya);if(y.value=fr?.createState?fr.createState():null,fr?.onEnter?.(y.value),x.value=fr?.tabs?.[0]?.id??null,S.value=0,u.value=0,p.value=0,d.value=!1,b.value=null,ga!==void 0&&ga!=="normal"&&Ya==="normal")setTimeout(()=>V(),0)},{immediate:!0});let te=uA.computed(()=>E.value?.resolve.value(A(),x.value,i)??{items:[]}),ee=uA.computed(()=>te.value.items),me=uA.computed(()=>{let Ya=s();if(Ya!==null)return Ya;if(b.value!==null)return b.value;let ga=ee.value;if(E.value?.skipDefaultFilter)return ga;let fr=A().toLowerCase().trim();if(!fr)return ga;let Ye=(SA)=>SA.chunks?aLe(A(),SA.chunks)!==null:SA.label.toLowerCase().includes(fr)||(SA.description?.toLowerCase().includes(fr)??!1),vn=[],mn=[],qa=!1;for(let SA of ga){if(SA.separator){mn=[SA],qa=!1;continue}if(SA.header){mn=[...mn,SA],qa=Ye(SA);continue}if(qa||Ye(SA)){if(mn.length>0){if(vn.length===0&&mn[0]?.separator)mn.shift();vn.push(...mn),mn=[]}vn.push(SA)}}if(fr.length>0&&vn.length>1&&vn.every((SA)=>SA.chunks)){let SA=vn.map((Va,li)=>({item:Va,index:li,score:aLe(A(),Va.chunks)??0}));return SA.sort((Va,li)=>li.score-Va.score||Va.index-li.index),SA.map((Va)=>Va.item)}return vn}),be=uA.computed(()=>{if(gt.value!==null)return 1;if(wa.value!==null)return 1;if(me.value.length===0)return 1;let Ya=E.value?.maxHeight??5;return Math.min(me.value.length,Ya)});uA.watch(me,(Ya,ga)=>{if(!d.value&&Ya.length>0){u.value=Te.value,d.value=!0,nt(),Xe();return}let fr=bYa({items:Ya,previous:ga,selectedIndex:u.value,homeIndex:Te.value});if(fr!==u.value)u.value=fr,nt()});let ce=uA.computed(()=>{let Ya=me.value;for(let ga=0;ga<Ya.length;ga++)if(xJ(Ya,ga))return ga;return 0}),ke=uA.computed(()=>{let Ya=me.value;for(let ga=Ya.length-1;ga>=0;ga--)if(xJ(Ya,ga))return ga;return 0}),Te=uA.computed(()=>{let Ya=me.value;for(let ga=0;ga<Ya.length;ga++)if(Ya[ga].current&&xJ(Ya,ga))return ga;return E.value?.anchor==="bottom"?ke.value:ce.value});function Ze(Ya){let ga=me.value;if(ga[Ya]?.header)return!1;for(let fr=0;fr<=Ya&&fr<ga.length;fr++)if(ga[fr].header)return!0;return!1}function nt(){let Ya=be.value,ga=u.value;if(ga<=p.value)p.value=Ze(ga)?Math.max(0,ga-1):ga;else if(ga>=p.value+Ya)p.value=ga-Ya+1}function je(){p.value=0,d.value=!1,u.value=Te.value,nt()}function Xe(){me.value[u.value]?.preview?.()}let gt=uA.ref(null),Oe=null,_t=uA.ref(0);function tn(){_t.value++}function Ct(){Oe?.abort(),Oe=null,gt.value=null}function Kn(Ya){return Ya instanceof Error?Ya.message:"failed"}async function ma(Ya){Oe=new AbortController;let ga=Oe.signal,fr;try{fr=Ya.action(ga)}catch(vn){Oe=null,gt.value={kind:"error",label:Ya.label,message:Kn(vn)};return}if(!(fr instanceof Promise)){Oe=null;return}if(Ya.detach){if(Oe=null,!Ya.inlineResult)i("");n.value="normal",fr.catch(()=>{});return}let Ye=Ya.label;gt.value={kind:"working",label:Ye,message:Ya.workingMessage??Ya.description??"working...",startedAt:Date.now()};try{if(await fr,!ga.aborted){if(gt.value=null,Ya.keepOpen)return;if(!Ya.inlineResult)i("");n.value="normal"}}catch(vn){if(!ga.aborted)gt.value={kind:"error",label:Ye,message:Kn(vn)}}finally{Oe=null}}function Tt(Ya){if(Ya.choices)try{b.value=Ya.choices(),u.value=0,p.value=0}catch(ga){gt.value={kind:"error",label:Ya.label,message:Kn(ga)}}else if(Ya.descendQuery!==void 0)i(Ya.descendQuery);else ma(Ya)}function na(){if(gt.value!==null)return null;let Ya=me.value[u.value]??null;if(Ya&&xJ(me.value,u.value))Tt(Ya);return Ya}function Ra(Ya){if(gt.value!==null)return null;let ga=me.value[Ya]??null;if(ga&&xJ(me.value,Ya))u.value=Ya,Tt(ga);return ga}function Un(Ya){if(!xJ(me.value,Ya))return;u.value=Ya,nt(),Xe()}fh("tab",(Ya)=>{if(gt.value===null){let ga=me.value[u.value]??null;if(ga&&xJ(me.value,u.value)){let fr=ga.completeQuery??ga.label;if(fr.length>0)i(fr)}}if(Ya)Ya.consumed=!0}),fh("up",(Ya)=>{let ga=me.value,fr=ga.length;if(fr===0)return;for(let Ye=1;Ye<=fr;Ye++){let vn=(u.value-Ye+fr)%fr;if(xJ(ga,vn)){u.value=vn,nt(),Xe();break}}if(Ya)Ya.consumed=!0}),fh("down",(Ya)=>{let ga=me.value,fr=ga.length;if(fr===0)return;for(let Ye=1;Ye<=fr;Ye++){let vn=(u.value+Ye)%fr;if(xJ(ga,vn)){u.value=vn,nt(),Xe();break}}if(Ya)Ya.consumed=!0}),fh("escape",(Ya)=>{if(gt.value?.kind==="working"){if(Ct(),Ya)Ya.consumed=!0;return}if(gt.value!==null){if(Ct(),Ya)Ya.consumed=!0;return}if(b.value!==null){if(b.value=null,u.value=ce.value,p.value=0,Ya)Ya.consumed=!0;return}if(me.value.length===0)return;if(y.value=E.value?.createState?E.value.createState():null,Ya)Ya.consumed=!0});function Ja(){let Ya=me.value;return xJ(Ya,u.value)?Ya[u.value]:null}fh("left",(Ya)=>{let ga=L.value;if(ga&&x.value){let vn=ga.findIndex((mn)=>mn.id===x.value);if($(ga[(vn-1+ga.length)%ga.length].id),Ya)Ya.consumed=!0;return}let fr=E.value?.onLeft,Ye=Ja();if(fr&&Ye){if(fr(Ye),Ya)Ya.consumed=!0}}),fh("right",(Ya)=>{let ga=L.value;if(ga&&x.value){let vn=ga.findIndex((mn)=>mn.id===x.value);if($(ga[(vn+1)%ga.length].id),Ya)Ya.consumed=!0;return}let fr=E.value?.onRight,Ye=Ja();if(fr&&Ye){if(fr(Ye),Ya)Ya.consumed=!0}});let GA=uA.computed(()=>{let Ya=me.value,ga=p.value,fr=null;for(let Ye=0;Ye<=ga&&Ye<Ya.length;Ye++)if(Ya[Ye].header)fr=Ya[Ye].label;if(Ya[ga]?.header)return null;return fr}),bn=uA.computed(()=>te.value.breadcrumb??null),ya=uA.computed(()=>te.value.header??null),wa=uA.computed(()=>te.value.status??null),Aa=uA.computed(()=>te.value.invalid??!1);return{filtered:me,height:be,isRegisteredMode:uA.computed(()=>E.value!==void 0),selectedIndex:uA.computed(()=>u.value),scrollY:uA.computed(()=>p.value),tabs:U,activeTabId:uA.computed(()=>x.value),stickyHeader:GA,breadcrumb:bn,header:ya,status:wa,isInvalidCommand:Aa,hasNothingToRun:uA.computed(()=>me.value.length>0&&Ja()===null),working:uA.computed(()=>gt.value),noMatchSignal:uA.computed(()=>_t.value),signalNoMatch:tn,hasChoiceList:uA.computed(()=>b.value!==null),keepsOpen:uA.computed(()=>Ja()?.keepOpen??!1),hasHint:uA.computed(()=>s()!==null),selectTab:$,reset:je,selectCurrent:na,selectAt:Ra,hoverAt:Un,abortWorking:Ct}}var Sja=!1;var Gja=xt(async()=>{Fs();hYa();_ja();await Qk([nja(),gja(),mja(),fja(),bja(),Ija(),yja(),R8t(),c8n(),vja()])});function H8t(){if(!k8n)k8n=Gbr();return k8n}function Gbr(){let n=IC().mic,A=uA.ref(n.waveform()),i=uA.ref(n.isActive()),s=uA.ref(0),u=null,p=0;function d(){A.value=n.waveform(),i.value=n.isActive(),s.value=i.value?Math.floor((Date.now()-p)/1000):0}function b(){if(u)return;u=setInterval(d,cht.tickMs)}function E(){if(!u)return;clearInterval(u),u=null}return{waveform:uA.computed(()=>A.value),isActive:uA.computed(()=>i.value),elapsedSeconds:uA.computed(()=>s.value),async start(){p=Date.now(),await n.start(),d(),b()},async stop(){let y=await n.stop();return d(),E(),y}}}var k8n;var D8n=xt(async()=>{Fs();PQn();await a3()});function P8t(){if(!x8n)x8n=Mbr();return x8n}function Mbr(){let e=uA.ref(!0);function n(){e.value=!0}function A(i){return i.onScroll(({scrollY:s,maxScroll:u})=>{e.value=s>=u})}return{following:e,attach:n,observe:A}}var x8n;var F8n=xt(()=>{Fs()});function Mja(e){if(e.working==="working")return{kind:"abort-working"};if(e.working!==null)return{kind:"dismiss-error"};if(e.mode==="normal")return{kind:"try-interrupt"};return{kind:"exit-mode"}}function J8t(e){return{id:e.sessionId,name:e.name,focused:e.focused,activity:e.activity}}function Lja(){let e=Uc(),n=Mb(),A=xR(),i=new Set;uA.watch(()=>e.instances.value,(p)=>{let d=new Set(p.map((b)=>b.sessionId));for(let b of p)if(!i.has(b.sessionId))A.notify("agent:ready",{instance:J8t(b)});for(let b of i)if(!d.has(b))A.notify("agent:stopped",{instance:{id:b,name:"",focused:!1,activity:null}});i=d},{immediate:!0}),uA.watch(()=>e.sessionId.value,(p)=>{if(!p)return;let d=e.instances.value.find((b)=>b.sessionId===p);if(d)A.notify("agent:focused",{instance:J8t(d)})});let s=LB();uA.watch(()=>[s.width.value,s.height.value],([p,d])=>{A.notify("tui:resize",{width:p,height:d})}),s.selection.onCopy((p)=>{A.notify("tui:copy",{text:p})});let u=!1;uA.watch(()=>e.activity.value,(p)=>{let d=p==="working";if(u&&!d){let b=e.instances.value.find((E)=>E.focused);if(b)A.notify("message:received",{instance:J8t(b)})}u=d}),uA.watch(()=>n.mode.mode.value,(p,d)=>{if(d===void 0||d===p)return;if(A.notify("mode:changed",{from:d,to:p}),BBt(d))A.notify("palette:closed",{name:d});if(BBt(p))A.notify("palette:opened",{name:p})})}function qja(e){let A=Uc().instances.value.find((i)=>i.focused);if(!A)return;xR().notify("message:sent",{content:e,instance:J8t(A)})}var v8n=xt(async()=>{Fs();eLe();RIe();await Qk([Ek(),aL()])});var Uja={};OA(Uja,{useInput:()=>Mb,DRAFT_MODES:()=>GBt});function Mb(){if(!S8n)S8n=Lbr();return S8n}function Lbr(){let e=HE(),n=HC(),A=uA.ref(""),i=null,s=null,u=cYa(()=>A.value,()=>e.value.path!=="/auth"),p=Nja({mode:u.mode,query:()=>V()??A.value,setQuery:(_t)=>{te(_t)},hint:()=>ee()}),d=H8t(),b=IC(),E=uA.ref(!1),y=uA.ref(null),k=null;function x(){if(E.value=!0,k)clearTimeout(k);k=setTimeout(()=>{E.value=!1,k=null},600)}uA.watch(()=>p.noMatchSignal.value,()=>{x()}),uA.watch(()=>e6().pending.value!==null,(_t)=>{if(_t)A.value="",u.setMode(VKe);else if(A.value="",u.mode.value===VKe)u.setMode("normal")}),uA.watch(()=>TIe().current.value!==null,(_t)=>{if(_t)A.value="",u.setMode(ZKe);else if(u.mode.value===ZKe)A.value="",u.setMode("normal")});let S=null,L=null;function U(_t){L=_t,A.value=_t}uA.watch(A,(_t)=>{if(u.mode.value!=="history")return;if(_t===L)return;S=null,L=null,u.setMode("normal")});function $(){if(!(u.mode.value==="normal"||X6e.some((tn)=>tn.mode===u.mode.value)))return null;for(let tn of X6e){let Ct=rYa(A.value,tn);if(Ct)return{trigger:tn,start:Ct.start,query:Ct.query}}return null}function V(){return $()?.query??null}function te(_t){let tn=$();if(tn){A.value=A.value.slice(0,tn.start)+tn.trigger.key+_t;return}A.value=_t}function ee(){if(u.mode.value!=="normal")return null;let _t=X6e.filter((tn)=>iYa(A.value,tn));if(_t.length===0)return null;return _t.map((tn)=>({id:tn.mode,label:`${IBt[tn.mode]} ${tn.mode}`,description:v8t[tn.mode]??tn.key,action:()=>{A.value=A.value+tn.key}}))}uA.watch(A,(_t)=>{if(u.mode.value!=="normal")return;for(let tn of X6e){if(tn.resolve!=="append")continue;let Ct=oYa(_t,tn);if(Ct===-1)continue;s=tn,i=_t.slice(0,Ct).replace(/ $/,""),u.setMode(tn.mode);return}}),uA.watch(A,()=>{let _t=$();if(_t&&u.mode.value==="normal"){s=_t.trigger,i=null,u.setMode(_t.trigger.mode);return}if(!_t&&s?.resolve==="splice"&&u.mode.value===s.mode)s=null,u.setMode("normal")});function me(_t){let tn=$();if(!tn){s=null,u.setMode("normal");return}A.value=`${A.value.slice(0,tn.start)}${_t} `,s=null,u.setMode("normal")}function be(){let _t=$();if(s=null,!_t)return;A.value=A.value.slice(0,_t.start).replace(/ $/,"")}uA.watch(u.mode,(_t,tn)=>{if(tn==="session"&&_t==="normal")Uc().preview.clear();if(_t==="history")S=A.value;if(tn==="history"&&_t==="normal"){if(L=null,S!==null)A.value=S,S=null}if(_t==="voice"&&tn!=="voice")d.start().catch((Ct)=>{y.value=Ct instanceof Error?Ct:Error(String(Ct)),u.setMode("normal")});if(tn==="voice"&&_t!=="voice"){let Ct=u.voiceExitReason.value;u.voiceExitReason.value=null,ce(Ct)}},{flush:"sync"});async function ce(_t){let tn=await d.stop();if(_t!=="confirm"){if(i!==null)A.value=i,i=null;return}u.processing.value=!0;try{let{text:Ct}=await b.cloud.client.cloud.stt.transcribe(tn),Kn=Ct.trim();if(i!==null)if(Kn){let ma=i.endsWith(" ")||i===""?"":" ";A.value=i+ma+Kn}else A.value=i;else if(Kn)A.value=Kn;i=null}catch(Ct){y.value=Ct instanceof Error?Ct:Error(String(Ct))}finally{u.processing.value=!1}}let ke=0,Te=uA.ref(null),Ze=null;function nt(){if(Te.value="press esc again to clear",Ze)clearTimeout(Ze);Ze=setTimeout(()=>{Te.value=null,Ze=null},Tja)}function je(){if(Ze)clearTimeout(Ze);Ze=null,Te.value=null}uA.watch(A,()=>{if(Te.value!==null)je()});function Xe(){if(xSn(),TIe().current.value){TIe().denyAll(),A.value="",u.setMode("normal");return}if(e6().pending.value){e6().cancel(),A.value="",u.setMode("normal");return}let _t=Mja({mode:u.mode.value,working:p.working.value?.kind??null});if(_t.kind==="abort-working"){p.abortWorking();return}if(_t.kind==="dismiss-error"){p.abortWorking(),A.value="",u.setMode("normal");return}if(_t.kind==="try-interrupt"){if(Uc().interrupt()){setTimeout(()=>n(),0);return}}let tn=Date.now(),Ct=tn-ke<Tja;if(ke=tn,Ct){if(je(),A.value.trim())try{SBt().append(A.value,Uc().selected.value)}catch{}A.value=""}else{let Kn=GBt.has(u.mode.value);if(!Kn)A.value="";if(u.mode.value==="voice")u.voiceExitReason.value="cancel";if(be(),u.setMode("normal"),Kn&&A.value.length>0)nt();else je()}}function gt(){if(xSn(),p.working.value!==null)return;if(e6().pending.value?.kind==="prompt"){e6().submitText(A.value),A.value="",u.setMode("normal");return}if(p.isInvalidCommand.value||p.hasNothingToRun.value){x();return}if(p.hasHint.value&&p.filtered.value.length>0){p.selectCurrent();return}if(u.mode.value!=="normal"&&p.filtered.value.length>0){S=null;let Ct=u.mode.value,Kn=p.hasChoiceList.value,ma=p.keepsOpen.value;if(p.selectCurrent(),ma)return;if(p.hasChoiceList.value||Kn)return;if(p.reset(),u.mode.value===Ct&&p.working.value===null){if(Ct!=="history"&&!GBt.has(Ct))A.value="";u.setMode("normal")}return}if(e.value.path==="/auth"){A.value="";return}if(u.mode.value==="normal"&&A.value.trim()){let Ct=A.value;A.value="",p.reset(),y.value=null,P8t().attach();try{SBt().append(Ct,Uc().selected.value)}catch{}Uc().send(Ct).catch((Kn)=>{y.value=Kn instanceof Error?Kn:Error(String(Kn))}),qja(Ct)}}function Oe(_t){A.value+=_t}return{text:A,inputError:E,sendError:y,escHint:Te,mode:u,palette:p,onEnter:gt,onEscape:Xe,onPrintable:Oe,previewHistory:U,resolveInline:me}}var Tja=400,GBt,S8n;var aL=xt(async()=>{Fs();eLe();F8n();YSn();nLe();$Sn();S8t();pBt();await Qk([Gja(),Ek(),D8n(),a3(),E8n(),v8n()]);GBt=new Set(["normal","voice","file"])});function O8t(e){let n=e.toLowerCase().split("+").map((u)=>u.trim()).filter(Boolean),A=n.pop();if(!A)return e;let i=n.includes("ctrl")||n.includes("control"),s=n.includes("shift");if(i&&s)return`C-S-${A}`;if(i)return`C-${A}`;if(s)return`S-${A}`;return A}function Tbr(e){let n=/^(C-)?(S-)?(.+)$/.exec(e);if(!n)return e;let[,A,i,s]=n,u=[];if(A)u.push("ctrl");if(i)u.push("shift");return u.push(s),u.join("+")}function N8n(e){let n=O8t(e);return qbr.has(n)||n in vne}function Ubr(e){if(!e.name)return null;if(e.ctrl&&e.shift)return`C-S-${e.name}`;if(e.ctrl)return`C-${e.name}`;if(e.shift)return`S-${e.name}`;return e.name}function Rja(){let e=Mb();fh("**",(n)=>{if(n?.consumed)return;let A=Ubr(n??{});if(!A)return;let i=M1.paletteForKey(A);if(i){if(e.text.value.length>0)return;let u=e.mode.mode.value;e.mode.setMode(u===i.name?"normal":i.name),n.consumed=!0;return}let s=M1.keyHandler(A);if(!s){xR().notify("key:pressed",{key:Tbr(A),mode:e.mode.mode.value});return}n.consumed=!0,(async()=>{try{await s()}catch(u){Mk().show(`${A} failed`,"error")}})()})}var qbr;var G8n=xt(async()=>{Fs();V6e();iLe();RIe();eLe();await aL();qbr=new Set(["C-c","C-d","escape","return","enter","tab","up","down","left","right","backspace","delete"])});function u7e(){if(!L8n)L8n=Kbr();return L8n}function Rbr(){return process.env.PWD??process.cwd()}async function q8n(e){try{let n=Bun.spawn(["git",...e],{cwd:Rbr(),stdout:"pipe",stderr:"ignore"}),A=await new Response(n.stdout).text();return await n.exited===0?A.trim():null}catch{return null}}function Kbr(){return{state:$8t,async refresh(){if(M8n)return;M8n=!0;try{let e=await q8n(["rev-parse","--abbrev-ref","HEAD"]);if(e===null){$8t.value=T8n;return}let[n,A]=await Promise.all([q8n(["status","--porcelain"]),q8n(["rev-list","--left-right","--count","HEAD...@{upstream}"])]),i=e==="HEAD"?null:e,s=n?n.split(`
|
|
5048
5048
|
`).filter(Boolean).length:0,[u,p]=A?A.split(/\s+/).map((d)=>Number(d)||0):[0,0];$8t.value={branch:i,dirty:s,ahead:u??0,behind:p??0}}catch{$8t.value=T8n}finally{M8n=!1}}}}var T8n,$8t,M8n=!1,L8n;var Kja=xt(()=>{Fs();T8n={branch:null,dirty:0,ahead:0,behind:0},$8t=uA.ref(T8n)});function Pbr(e){return Hbr[e.toLowerCase()]??e}function Jbr(){if(Yja)return;Yja=!0,xR().register("key:pressed",({key:e})=>{MBt=[...MBt,{key:e,at:Date.now()}].slice(-jbr)})}function jja(){Jbr();let e=Date.now()-Ybr;return MBt=MBt.filter((n)=>n.at>e),MBt.map((n)=>Pbr(n.key))}var Ybr=1500,jbr=10,MBt,Yja=!1,Hbr;var Hja=xt(()=>{RIe();MBt=[],Hbr={enter:"\u23CE",return:"\u23CE",tab:"\u21E5",backspace:"\u232B",delete:"\u2326",escape:"esc",space:"\u2423",up:"\u2191",down:"\u2193",left:"\u2190",right:"\u2192",pageup:"\u21DE",pagedown:"\u21DF",home:"\u21F1",end:"\u21F2"}});var U8n;var Pja=xt(async()=>{Kja();Hja();await Qk([Ek(),MIe(),KIe(),aL()]);U8n={"axon:agent/name":{icon:"agent",on:["agent:focused","agent:ready","agent:stopped"],render:()=>Uc().displayName.value},"axon:agent/model":{icon:"model",on:["agent:focused","agent:ready","message:received"],render:()=>{let e=Uc();return e.contextModel.value??e.manifest.value?.model??null}},"axon:agent/modules":{icon:"modules",on:["agent:ready","agent:focused"],render:()=>{let e=Uc(),n=e.manifest.value;return n?n.modules??null:e.modules.value.length}},"axon:agents/active":{on:["agent:ready","agent:stopped"],render:()=>Uc().instances.value.length},"axon:agents/total":{on:["agent:ready","agent:stopped"],render:()=>Uc().available.value.length},"axon:session/name":{icon:"session",on:["agent:focused","agent:ready","message:received"],render:()=>{let e=Uc(),n=e.sessionId.value??e.manifest.value?.sessionId;if(!n)return null;return e.sessions.value.find((A)=>A.sessionId===n)?.title??n}},"axon:session/id":{on:["agent:focused","agent:ready"],render:()=>{let e=Uc();return e.sessionId.value??e.manifest.value?.sessionId??null}},"axon:session/tokens":{icon:"tokens",on:["message:sent","message:received","agent:focused"],render:()=>{let e=Uc(),n=e.context.value??e.manifest.value?.context??null;return n===null?null:`${Math.round(n/1000)}k`}},"axon:session/messages":{icon:"messages",on:["message:sent","message:received","agent:focused"],render:()=>Uc().session.value.entries.length},"axon:profile/email":{icon:"user",on:["tui:reloaded"],render:()=>b8().identity.value?.email??null},"axon:ext/loaded":{on:["tui:reloaded"],render:()=>nL().sources.value.length},"axon:ext/degraded":{icon:"warning",on:["tui:reloaded"],render:()=>{let e=nL().problems.value.length;return e>0?`${e} config errors`:null}},"axon:process/cwd":{icon:"folder",render:()=>process.env.PWD??process.cwd()},"axon:process/pid":{render:()=>process.pid},"axon:git/branch":{icon:"branch",every:5000,on:["agent:focused"],render:()=>{return u7e().refresh(),u7e().state.value.branch}},"axon:git/dirty":{icon:"changes",every:5000,render:()=>{let{dirty:e}=u7e().state.value;return e>0?`${e}`:null}},"axon:git/ahead":{icon:"ahead",every:5000,render:()=>{let{ahead:e}=u7e().state.value;return e>0?`${e}`:null}},"axon:git/behind":{icon:"behind",every:5000,render:()=>{let{behind:e}=u7e().state.value;return e>0?`${e}`:null}},"axon:agent/status":{on:["agent:ready","agent:focused","message:sent","message:received"],render:()=>Uc().activity.value},"axon:agent/error":{icon:"error",on:["agent:ready","agent:stopped","message:received"],render:()=>{let e=Uc().error.value;if(!e)return null;return(e instanceof Error?e.message:String(e)).split(`
|
|
5049
5049
|
`)[0].slice(0,40)}},"axon:mode":{on:["mode:changed"],render:()=>{try{return Mb().mode.symbol.value}catch{return null}}},"axon:keys":{on:["key:pressed"],every:250,render:()=>{let e=jja();return e.length>0?e.join(""):null}},"axon:clock":{icon:"clock",every:1000,render:()=>{let e=new Date,n=(A)=>String(A).padStart(2,"0");return`${n(e.getHours())}:${n(e.getMinutes())}:${n(e.getSeconds())}`}}}});var R8n;var Jja=xt(()=>{R8n={"axon:space":{left:[]},"axon:status":{left:[["axon:agent/name"],["axon:agent/model"]],right:[["axon:agent/status"],["axon:session/tokens"]]},"axon:git":{left:[["axon:git/branch"]],right:[["axon:git/dirty"],["axon:git/ahead","axon:git/behind"]]},"axon:context":{left:[["axon:process/cwd"]],right:[["axon:agents/active"],["axon:clock"]]},"axon:dev":{left:[["axon:mode"],["axon:agent/name"],["axon:agent/status"]],right:[["axon:git/branch","axon:git/dirty"],["axon:session/tokens"],["axon:clock"]]}}});function $ja(){if(Oja)return;Oja=!0;let e=r$();for(let[n,A]of Object.entries(U8n))e.createComponent(n,A);for(let[n,A]of Object.entries(R8n))e.createLine(n,A)}function zja(){return{components:Object.keys(U8n),lines:Object.keys(R8n)}}var Oja=!1;var K8n=xt(async()=>{t7e();Jja();await Pja()});function Wja(e){return typeof e==="string"?e.split(" ").filter(Boolean):[...e]}function Vja(e,n){if(Array.isArray(e.children))return e.children;return n?e.children():[]}function Zja(e,n){let A=n,i=null;for(let s of e){let u=A.find((p)=>p.label.toLowerCase()===s.toLowerCase());if(!u)return null;i=u,A=u.kind==="group"?Vja(u,!0):[]}return i}function LBt(e){return{id:e.sessionId,name:e.name,focused:e.focused,activity:e.activity}}function Xja(e){let{track:n}=e,A=xR(),i=e6(),s=nE();function u(me){let be=me[me.length-1],ce=typeof be==="object"&&be!==null&&!Array.isArray(be)&&"ms"in be&&typeof be.ms==="number",Te=(ce?me.slice(0,-1):me).map((Ze)=>{if(typeof Ze==="string")return Ze;if(Ze===null||Ze===void 0)return String(Ze);if(typeof Ze==="object")try{return JSON.stringify(Ze)}catch{return String(Ze)}return String(Ze)}).join(" ");return ce?{message:Te,ms:be.ms}:{message:Te}}function p(me){return n(me),me}let d={register(me,be){let ce=Wja(me);if(ce.length===0)throw Pn("COMMAND_INVALID",{detail:"a command needs a path"});if(Zja(ce,vBt))throw Pn("COMMAND_PATH_TAKEN",{detail:`${ce.join(" ")} is a built-in command`,context:{path:ce}});let ke=typeof be==="function"?{run:be}:be;if(typeof ke?.run!=="function")throw Pn("COMMAND_INVALID",{detail:`${ce.join(" ")} needs a run() \u2014 commands.register(path, fn) or commands.register(path, { run })`,context:{path:ce}});return p(M1.command({path:ce,action:ke.run,...ke.description?{description:ke.description}:{},...ke.workingMessage?{workingMessage:ke.workingMessage}:{}}))},async run(me){let be=Wja(me),ce=Zja(be,b());if(!ce||ce.kind!=="action")throw Pn("COMMAND_NOT_FOUND",{detail:be.join(" "),context:{path:be}});await o7e(be,"api",ce.action)(new AbortController().signal)},list(){let me=[],be=(ce,ke)=>{for(let Te of ce){let Ze=[...ke,Te.label];if(Te.kind!=="group"){me.push(Ze);continue}let nt=Vja(Te,!1);if(nt.length===0)me.push(Ze);else be(nt,Ze)}};return be(b(),[]),me}};function b(){return[...vBt,...F8t.value]}let E={register(me,be){if(N8n(me))throw Pn("KEY_CHORD_TAKEN",{detail:`${me} belongs to the terminal`,context:{chord:me}});return p(M1.key(O8t(me),be))},send(me){let be=O8t(me),ce=M1.keyHandler(be);if(ce){ce();return}let ke=M1.paletteForKey(be);if(ke){Mb().mode.setMode(ke.name);return}let Te=vne[me]??vne[be];if(Te){Mb().mode.setMode(Te);return}throw Pn("KEY_CHORD_UNBOUND",{detail:me,context:{chord:me}})}},y={async set(me){let be=Object.values(vne).includes(me)||me==="normal",ce=M1.paletteFor(me)!==null;if(!be&&!ce)throw Pn("MODE_UNKNOWN",{detail:me,context:{mode:me}});Mb().mode.setMode(me)},get(){return Mb().mode.mode.value},symbol(){return Mb().mode.symbol.value}},k={get:()=>Mb().text.value,set:(me)=>{Mb().text.value=me},append:(me)=>{Mb().text.value+=me},clear:()=>{Mb().text.value=""},async submit(){Mb().onEnter()}};function x(){let me=Uc().sessionId.value;if(!me)throw Pn("NO_FOCUSED_AGENT");return me}let S={async targets(){let me=Uc();return me.available.value.map((be)=>({name:be.name,kind:be.kind,instances:me.instances.value.filter((ce)=>ce.name===be.name).map(LBt)}))},list:()=>Uc().instances.value.map(LBt),get(me){let be=Uc().instances.value.find((ce)=>ce.sessionId===me);return be?LBt(be):null},focused(){let me=Uc().instances.value.find((be)=>be.focused);return me?LBt(me):null},async spawn(me){let be=Uc(),ce=await be.spawn(me,{focus:!1});if(!ce)throw Pn("AGENT_SPAWN_NO_INSTANCE",{detail:me,context:{name:me}});let ke=be.instances.value.find((Te)=>Te.sessionId===ce);if(!ke)throw Pn("AGENT_SPAWN_NO_INSTANCE",{detail:me,context:{name:me}});return LBt(ke)},focus(me){if(!S.get(me))throw Pn("INSTANCE_NOT_RUNNING",{detail:me,context:{id:me}});Uc().focus(me)},async stop(me){let be=me??x();if(!S.get(be))throw Pn("INSTANCE_NOT_RUNNING",{detail:be,context:{id:be}});await Uc().stop(be)},async reboot(me){let be=Uc(),ce=me??x();if(!S.get(ce))throw Pn("INSTANCE_NOT_RUNNING",{detail:ce,context:{id:ce}});if(ce!==be.sessionId.value)be.focus(ce);await be.reboot()},async send(me){x(),await Uc().send(me)},interrupt:()=>Uc().interrupt()},L={create(me,be){if(be.key&&N8n(be.key))throw Pn("MODE_KEY_TAKEN",{detail:`${be.key} belongs to the terminal`,context:{key:be.key,name:me}});let ce=p(M1.palette(me,be));return{get name(){return me},open:()=>L.open(me),refresh(){let ke=M1.paletteFor(me);if(ke)ke.cache=null},dispose:ce}},get(me){let be=M1.paletteFor(me);if(!be)return null;return{get name(){return me},open:()=>L.open(me),refresh(){be.cache=null},dispose:()=>{}}},async open(me){if(!M1.paletteFor(me))throw Pn("PALETTE_NOT_FOUND",{detail:me,context:{name:me}});if(L.isOpen)throw Pn("PALETTE_ALREADY_OPEN",{detail:me,context:{name:me}});Mb().mode.setMode(me)},close(){Mb().mode.setMode("normal")},get isOpen(){return BBt(Mb().mode.mode.value)},pick:(me,be)=>i.pick(me,be),confirm:(me)=>i.confirm(me),prompt:(me,be)=>i.prompt(me,be)},U={async nav(me){await Uc().select(me)},hook(me,be){return p(A.register(me,be))},info(...me){let{message:be,ms:ce}=u(me);Mk().show(be,"info",ce)},warn(...me){let{message:be,ms:ce}=u(me);Mk().show(be,"warn",ce)},error(...me){let{message:be,ms:ce}=u(me);Mk().show(be,"error",ce)},get size(){let me=LB();return{width:me.width.value,height:me.height.value}},get cwd(){return process.env.PWD??process.cwd()},get version(){return J6e.version},async exit(){await A.gate("tui:shutdown",{}),process.exit(0)}},$=r$();return $ja(),{tui:U,palette:L,commands:d,keys:E,mode:y,input:k,agents:S,theme:{create(me,be){return p(s.create({name:me,...be}))},set(me){s.set(me)},list:()=>s.themes.value,get active(){return s.active.value}},lines:{create(me,be){return $.createLine(me,be,n)},set:(me)=>$.setStack(me),top:(me,be)=>me===void 0?$.top():$.setTop(me,be),style:(me)=>$.style(me),move:(me,be)=>$.move(me,be),hide:(me)=>$.hide(me),show:(me)=>$.show(me),toggle:(me)=>$.toggle(me),list:()=>$.list()},components:{create(me,be){return p($.createComponent(me,be))},list:()=>$.listComponents()}}}var eHa=xt(async()=>{Fs();qs();I8t();eLe();V6e();RIe();m8n();nLe();iLe();A3();t7e();await Qk([Ek(),aL(),p8n(),G8n(),K8n()])});var j8n={};OA(j8n,{useExtensions:()=>nL});function nL(){if(!Y8n)Y8n=$br();return Y8n}async function Obr(){let{useQuestions:e}=await Promise.resolve().then(() => (nLe(),uYa)),{useInput:n}=await aL().then(() => Uja);e().cancel();let A=n();if(A.mode.mode.value!=="normal")A.text.value="",A.mode.setMode("normal")}function $br(){let e=IC(),n=xR(),A=r$(),i=Xja({track:(p)=>e.extensions.disposers.track(p)});async function s(){try{let p=e.store.profiles.active();if(!p)return;let d=await e.projects.open(p.root),b=e.extensions.sources.map((E)=>E.root);d.generate.registry(b,zja())}catch{}}function u(){let p=globalThis;p.tui=i.tui,p.palette=i.palette,p.commands=i.commands,p.keys=i.keys,p.mode=i.mode,p.input=i.input,p.agents=i.agents,p.theme=i.theme,p.lines=i.lines,p.components=i.components}return{errors:uA.computed(()=>l7e.value),fileErrors:uA.computed(()=>e.extensions.sources.flatMap((p)=>p.files.filter((d)=>d.error!==null).map((d)=>({source:p.label,path:d.path,error:d.error})))),problems:uA.computed(()=>{xbe.value;let p=e.extensions.sources.flatMap((b)=>b.files.filter((E)=>E.error!==null).map((E)=>({label:E.path.split("/").slice(-2).join("/"),error:E.error}))),d=A.faults.value.map((b)=>({label:"lines",error:b}));return[...l7e.value.map((b)=>({label:"profile.config.ts",error:b})),...p,...d]}),loaded:uA.computed(()=>xbe.value),sources:uA.computed(()=>e.extensions.sources),list(){return e.extensions.list()},declared:uA.computed(()=>{return xbe.value,z8t.value,[...e.extensions.declared]}),async install(p){try{return await e.extensions.install(p)}finally{z8t.value++}},async uninstall(p){try{return await e.extensions.uninstall(p)}finally{z8t.value++}},updates(){return e.extensions.updates()},async update(p,d){try{return await e.extensions.update(p,d)}finally{z8t.value++}},async load(p){let d=xbe.value;if(u(),xbe.value)await Obr();if(xbe.value)A.reset();let b=[];if(p?.prepare!==!1)try{await e.profile.ensure()}catch(L){b.push(L)}let E=xbe.value?await e.extensions.reload():await e.extensions.load();b.push(...E.errors),l7e.value=b,xbe.value=!0,s(),await e.refreshSettings();let{useSettings:y}=await hBt().then(() => LSn),k=y();await k.refresh();let{useTheme:x}=await Promise.resolve().then(() => (A3(),USn));x().adopt(k.settings.value.theme),A.icons(k.settings.value.icons??"auto");let S=await n.gate("tui:boot",{});if(S.length>0)l7e.value=[...l7e.value,...S];if(d)n.notify("tui:reloaded",{})},async reload(p){await this.load({prepare:p?.prepare??!1})},watch(){if(g7e)return;g7e=e.extensions.watch(async()=>{await this.reload();let p=this.problems.value.length;if(p>0)Mk().show(`config reloaded \u2014 ${p} problem${p===1?"":"s"}`,"error")})},unwatch(){g7e?.(),g7e=null},async logout(){g7e?.(),g7e=null,e.extensions.unload(),xbe.value=!1,l7e.value=[],A.reset();let{useTheme:p}=await Promise.resolve().then(() => (A3(),USn));p().reset()},hooks:n}}var l7e,xbe,z8t,g7e=null,Y8n;var KIe=xt(async()=>{Fs();RIe();t7e();iLe();await Qk([a3(),eHa(),K8n()]);l7e=uA.ref([]),xbe=uA.ref(!1),z8t=uA.ref(0)});import{readFileSync as aHa,existsSync as AHa}from"fs";import{basename as W8t,join as iHa,resolve as zbr}from"path";function TBt(){return{events:[],kernelEvents:[],entries:[],processes:[]}}function Xbr(e){let n=e?.context;return typeof n?.sessionFile==="string"?n.sessionFile:null}function H8n(e){if(!AHa(e))return[];let n=aHa(e,"utf-8").trim();if(n.length===0)return[];return n.split(`
|
|
5050
|
-
`).map((A)=>JSON.parse(A))}function eCr(e){if(e==="process:attach"||e==="process:detach")return!1;return e.startsWith("kernel:")||e.startsWith("cognet:")||e.startsWith("process:")||e.startsWith("capsule:")}function tCr(e){let n=[],A=[],i=[];for(let s of H8n(e))if(LMe.some((u)=>s.type.startsWith(u)))A.push(s);else if(eCr(s.type))i.push(s);else n.push(s);return{events:n,entries:A,kernelEvents:i,processes:[]}}function tHa(e){let n=e.lastIndexOf("@");return n>0?{name:e.slice(0,n),version:e.slice(n+1)}:{name:e,version:""}}function nCr(e){return zbr(e.paths.root,e.paths.data)}async function aCr(e){let n=Xbr(e);if(!n)return[];for(let A=0;A<10;A++){let i=H8n(n);if(i.some((s)=>s.type.endsWith(":error")||s.type.endsWith(":failed")))return i;await new Promise((s)=>setTimeout(s,30))}return H8n(n)}function p7e(e){return e.source.kind==="remote"?e.source.target.name:e.source.project.name}function nHa(e){let n=iHa(e,"package.json");if(AHa(n))try{let A=JSON.parse(aHa(n,"utf-8")).name;if(A)return A}catch{}return W8t(e)}function ACr(e){let{main:n}=e.kernel.userland;return{...n.pid!==void 0?{pid:n.pid}:{},status:n.status,...n.startedAt!=null?{startedAt:n.startedAt}:{}}}function iCr(e){return e.source.kind==="remote"?{kind:"remote",instance:e,axon:e.source.agent}:{kind:"local",instance:e}}function rCr(e){let n=e.instance,A=uA.shallowRef(TBt()),i=uA.ref("live"),s=uA.ref([]),u=uA.ref(0),p=uA.ref([]),d=uA.ref(!1),b=null,E=0,y=0,k=0;function x(){if(e.kind==="local"){let ce=e.instance.source.kind!=="remote"?e.instance.source.agent:null;if(!ce)throw Error("local cell without an agent");let ke=ce.kind==="process"?ce.current:ce;return{log:ke.session.log,kernelLog:ke.session.kernelLog,entries:ke.session.entries,processes:ce.kind==="process"?$Ke(ke.session.kernelLog,{main:ACr(ce.current)}):$Ke(ke.session.kernelLog)}}let be=e.axon.session;return{log:be.log,kernelLog:be.kernelLog,entries:be.entries,processes:$Ke(be.kernelLog)}}function S(){let be=x();E=be.log.length,y=be.kernelLog.length,k=be.entries.length,A.value={events:[...be.log],kernelEvents:[...be.kernelLog],entries:[...be.entries],processes:be.processes}}S();function L(be){let ce=x();if(be.startsWith("process:")||be.startsWith("capsule:"))A.value={...A.value,processes:ce.processes};let ke=ce.entries.slice(k);if(k=ce.entries.length,ke.length>0)A.value.entries.push(...ke);let Te=ce.kernelLog.slice(y);if(y=ce.kernelLog.length,Te.length>0)A.value.kernelEvents.push(...Te);let Ze=ce.log.slice(E);if(E=ce.log.length,Ze.length>0)A.value.events.push(...Ze);if(ke.length>0||Te.length>0||Ze.length>0)A.value={...A.value}}let U=e.kind==="local"?(()=>{let be=n.source.kind!=="remote"?n.source.agent:null;if(!be)throw Error("local cell without an agent");return be.kind==="process"?be.current.bus.onAny((ce)=>L(ce)):be.bus.onAny((ce)=>L(ce))})():(()=>{let be=0,ce=!1,ke=null,Te=null,Ze=()=>{if(ce)return;ke=e.axon.session.subscribe({onEvent:(je)=>{if(be!==0)be=0,i.value="live";L(je.type)},onLive:()=>{be=0,i.value="live"},onReset:()=>{S()},onClose:()=>{i.value="closed"},onError:()=>{if(ce)return;i.value="reconnecting",nt()}})},nt=()=>{if(ce)return;if(be+=1,be>Vbr){i.value="lost";return}let je=Math.min(Wbr*2**(be-1),Zbr);Te=setTimeout(Ze,je)};return Ze(),()=>{if(ce=!0,Te)clearTimeout(Te);ke?.()}})();async function $(be){if(e.kind==="local"&&n.source.kind==="linked"){let Ze=n.source.agent;d.value=!1;let nt={interrupt:()=>Ze.link.interrupt("user")};b=nt;try{if((await Ze.link.request({type:"cognet:stimulus:text",data:{content:be,channel:"terminal"}})).interrupted)d.value=!0}finally{if(b===nt)b=null}return}let ce=e.kind==="local"?n.source.kind==="local"&&n.source.agent.kind==="process"?n.source.agent.current.axon:null:e.axon;if(!ce)throw Error("cell has no invocation target");let ke=ce.stream({prompt:be,channel:"terminal"}),{stream:Te}=ke;b=ke,d.value=!1;try{for await(let Ze of Te);}finally{if(b===ke)b=null}}async function V(){while(s.value.length>0){let be=s.value;s.value=[];try{await $(be)}catch{}}}async function te(be){if(u.value>0){s.value=[...s.value,be];return}u.value++;let ce=Date.now();try{try{await $(be)}finally{await V()}if(!d.value){let ke=x().entries.at(-1)?.time.seq;if(ke!==void 0)p.value=[...p.value.filter((Te)=>Te.afterSeq!==ke),{afterSeq:ke,durationMs:Date.now()-ce}]}}finally{u.value--}}function ee(){let be=b;if(!be)return!1;return s.value=[],d.value=!0,be.interrupt(),!0}let me=uA.computed(()=>{if(i.value==="reconnecting")return"reconnecting";if(i.value==="closed"||i.value==="lost")return"disconnected";if(A.value.events.findLast((ce)=>ce.type.startsWith("axon:reload:"))?.type==="axon:reload:start")return"rebooting";if(u.value===0||d.value)return null;return"working"});return{instance:n,session:A,activity:me,queued:uA.computed(()=>s.value),busy:uA.computed(()=>u.value>0),turnTimings:uA.computed(()=>p.value),send:te,interrupt:ee,snapshot:S,promptNames(){if(e.kind!=="local"||n.source.kind==="remote")return[];let be=n.source.agent;return be.kind==="process"?be.current.axon.prompts.list():[]},async renderPrompt(be){if(e.kind!=="local"||n.source.kind==="remote")throw Pn("NOT_WIRED",{detail:"prompt rendering is not available on a deployed agent"});let ce=n.source.agent;return ce.kind==="process"?ce.current.axon.prompt(be):await ce.link.prompts({action:"get",name:be})},async renderPromptEntry(be){if(e.kind!=="local"||n.source.kind==="remote")throw Pn("NOT_WIRED",{detail:"prompt rendering is not available on a deployed agent"});let ce=n.source.agent;return ce.kind==="process"?ce.current.axon.prompts.renderEntry(be):await ce.link.prompts({action:"render",entry:be})},get connection(){return i.value},dispose(){U()}}}function oCr(e,n,A){let i=uA.ref("idle"),s=uA.ref(null),u=!1,p=uA.ref(0);function d(){p.value++}let b=new Map;function E(Ni){return b.get(Ni)??null}function y(Ni){let UA=b.get(Ni.sessionId);if(UA)return UA;let EA=rCr(iCr(Ni));return b.set(Ni.sessionId,EA),d(),EA}function k(Ni){let UA=b.get(Ni);if(!UA)return;UA.dispose(),b.delete(Ni),d()}let x=300000,S=new Map,L=new Map,U=uA.ref(0),$=new Set;function V(){let Ni=Date.now()-x;for(let[UA,EA]of S)if(EA.at<=Ni)S.delete(UA)}e.onSpawn((Ni)=>{if(L.set(Ni.sessionId,{sessionId:Ni.sessionId,parentSessionId:Ni.parentSessionId,rootSessionId:Ni.rootSessionId,depth:Ni.depth,name:p7e(Ni)}),S.delete(Ni.sessionId))U.value++;y(Ni)}),e.onStop((Ni)=>{if(u)return;let UA=L.get(Ni);if(UA){let EA=Date.now();S.set(Ni,{view:{...UA,focused:!1,activity:null,exitedAt:EA},at:EA}),U.value++,$.add(setTimeout(()=>{U.value++},x+1000))}k(Ni)});function te(){p.value;let Ni=e.focused;return Ni?b.get(Ni.sessionId)??null:null}let ee=uA.ref([]),me=uA.computed(()=>{return p.value,e.active}),be=uA.computed(()=>{p.value;let Ni=n.profiles.active(),UA=Ni?Ni.agents.list().map((nn)=>({kind:"local",dir:nn,name:nHa(Ni.agents.path(nn))})):[],EA=A.deployments.list().map((nn)=>({kind:"deployed",name:nn.name,deploymentId:nn.deploymentId,tier:nn.tier,warmth:nn.warmth}));return[...UA,...EA]});async function ce(){await A.deployments.refresh(),d()}let ke=uA.computed(()=>{return p.value,A.deployments.error});async function Te(Ni){let UA=A.deployments.list().find((EA)=>EA.deploymentId===Ni);if(!UA)throw Pn("DEPLOYMENT_NOT_CONNECTABLE",{context:{deploymentId:Ni}});i.value="booting",Xe.value=UA.name,gt.value=null,s.value=null,ee.value=[];try{let EA=await e.attach({url:UA.url,name:UA.name,agentId:UA.agentId,deploymentId:UA.deploymentId,tier:UA.tier});y(EA),i.value="idle",ee.value=[],Xe.value=null,li()}catch(EA){throw i.value="error",s.value=EA instanceof Error?EA:Error(String(EA)),EA}finally{d()}}async function Ze(Ni){let UA=Ni.trim();if(UA==="")throw Pn("ATTACH_URL_REQUIRED");i.value="booting",Xe.value=UA,gt.value=null,s.value=null,ee.value=[];try{let EA=await e.attach({url:UA,name:""});y(EA),i.value="idle",ee.value=[],Xe.value=null,li()}catch(EA){throw i.value="error",s.value=EA instanceof Error?EA:Error(String(EA)),EA}finally{d()}}function nt(){d()}let je=uA.computed(()=>{p.value;let Ni=e.focused;if(Ni&&Ni.source.kind==="remote")return Ni.source.target.name;return e.project?.name??null}),Xe=uA.ref(null),gt=uA.ref(null),Oe=uA.ref(null),_t=uA.ref(null),tn=O5a(),Ct=uA.computed(()=>je.value??Xe.value),Kn=uA.computed(()=>Xe.value!==null),ma=uA.computed(()=>{if(p.value,Kn.value)return null;return e.focused?.sessionId??null}),Tt=uA.computed(()=>{p.value;let Ni=e.blueprint,UA=ma.value;if(!Ni||!UA)return null;return iHa(nCr(Ni),"sessions",`${UA}.jsonl`)}),na=uA.computed(()=>{if(p.value,Kn.value)return gt.value;let Ni=e.focused;if(Ni&&Ni.source.kind==="remote")return Ni.source.target.url;return e.project?.root??null}),Ra=uA.computed(()=>{return p.value,nYa(na.value,n.profiles.active()?.agents.root??null)}),Un=uA.computed(()=>{if(p.value,!Kn.value&&!gt.value)return null;let Ni=gt.value;if(!Ni)return null;return n.state.get()?.agentManifests?.[W8t(Ni)]??null}),Ja=uA.computed(()=>{if(p.value,Kn.value){let vs=gt.value;if(!vs)return null;return n.state.get()?.agentModels?.[W8t(vs)]??null}let Ni=e.focused;if(Ni&&Ni.source.kind==="remote"){let vs=Ni.source.target.engine;if(!vs)return null;return x8t({provider:vs.provider,declared:vs.model,resolved:null})}let EA=e.runtime?.kernel.engines,nn=EA?.primary;if(EA&&nn&&EA.has(nn)){let vs=EA.get(nn).binding.capability;return x8t({provider:vs.provider,declared:vs.id,resolved:null})}let ns=gne(e.blueprint?.config.model);if(ns)return x8t({provider:ns.provider??"axon",declared:ns.model,resolved:mn.value});return null}),GA=V5a(),bn=uA.computed(()=>{if(p.value,Kn.value)return null;return GA.step(Z5a(Ye.value.kernelEvents,Ye.value.entries))}),ya=uA.computed(()=>{p.value,U.value,V();let Ni=e.focused?.sessionId??null,UA=e.list().map((ns)=>({sessionId:ns.sessionId,parentSessionId:ns.parentSessionId,rootSessionId:ns.rootSessionId,depth:ns.depth,name:p7e(ns),focused:ns.sessionId===Ni,activity:E(ns.sessionId)?.activity.value??null,exitedAt:null}));if(S.size===0)return UA;let EA=new Map;for(let ns of UA)EA.set(ns.sessionId,ns);for(let[ns,vs]of S)EA.set(ns,vs.view);let nn=[];for(let ns of L.keys()){let vs=EA.get(ns);if(vs)nn.push(vs),EA.delete(ns)}return[...nn,...EA.values()]}),wa=uA.computed(()=>{p.value;let Ni=e.focused?.sessionId??null,UA=new Map;for(let EA of e.recent()){let nn=p7e(EA),ns={sessionId:EA.sessionId,parentSessionId:EA.parentSessionId,rootSessionId:EA.rootSessionId,depth:EA.depth,name:nn,focused:EA.sessionId===Ni,activity:E(EA.sessionId)?.activity.value??null,exitedAt:null},vs=UA.get(nn);if(vs)vs.push(ns);else UA.set(nn,[ns])}return UA}),Aa=uA.computed(()=>{return p.value,e.sessions()}),Ya=uA.ref(null),ga=new Map,fr={id:uA.computed(()=>Ya.value),show(Ni){if(!ga.has(Ni.sessionId))ga.set(Ni.sessionId,tCr(Ni.filePath));Ya.value=Ni.sessionId},clear(){Ya.value=null,ga.clear()}},Ye=uA.computed(()=>{if(Ya.value!==null)return ga.get(Ya.value)??TBt();if(ee.value.length>0)return{...TBt(),events:ee.value};if(Kn.value)return TBt();return te()?.session.value??TBt()}),vn=uA.ref(null),mn=uA.computed(()=>{if(p.value,Kn.value)return null;return $5a(Ye.value.kernelEvents)??vn.value}),qa=uA.computed(()=>{if(p.value,Kn.value)return null;let Ni=mn.value;if(Ni)return Ni;let UA=gne(e.blueprint?.config.model)?.model??null;return UA==="auto"?null:UA});async function SA(){let Ni=z5a(e.blueprint?.config.model);if(!Ni){vn.value=null;return}try{let UA=await A.cloud.cloud.engine.resolve(Ni);vn.value=UA.model}catch{vn.value=null}}let Va=uA.ref([]);async function li(){let Ni=te();if(!Ni)return;while(Va.value.length>0&&te()===Ni){let[UA,...EA]=Va.value;Va.value=EA;try{await Ni.send(UA)}catch{}}}async function yi(Ni,UA){let EA=n.profiles.active(),nn=typeof Ni==="string"?EA?EA.agents.path(Ni):null:Ni.root,ns=typeof Ni==="string"?nn?nHa(nn):Ni:Ni.name,vs=tn.claim();i.value="booting",Xe.value=ns,gt.value=nn,Oe.value=null,_t.value=null,s.value=null,ee.value=[];try{let Fr=await e.spawn(Ni,{...UA,focus:UA?.focus===!1?!1:vs.latest,onProgress:(Sl)=>{if(vs.latest)Oe.value=Sl},onTiming:(Sl)=>{if(vs.latest&&Sl.unit==="modules")_t.value=Sl.durationMs}});if(y(Fr),!vs.latest)return d(),Fr.sessionId;i.value="idle",ee.value=[];try{if(Fr.source.kind==="local"){let Sl=W8t(Fr.source.project.root),Ed=Ja.value,nm={...Ed?{model:Ed}:{},modules:lr.value.length,tools:zo.value?.tools??0,...ma.value?{sessionId:ma.value}:{},...bn.value!==null?{context:bn.value}:{}};n.state.update((Kd)=>({...Kd,lastAgent:Sl,...Ed?{agentModels:{...Kd.agentModels,[Sl]:Ed}}:{},agentManifests:{...Kd.agentManifests,[Sl]:nm}}))}}catch{}return Xe.value=null,gt.value=null,Oe.value=null,SA(),li(),Fr.sessionId}catch(Fr){if(!vs.latest)throw Fr;throw i.value="error",s.value=Fr instanceof Error?Fr:Error(String(Fr)),ee.value=await aCr(Fr),Fr}finally{d()}}async function Ji(Ni){i.value="booting";let UA=e.focused;if(UA)await Gt(UA.sessionId);await yi(Ni)}async function ti(Ni,UA){if(e.get(UA)){Xa(UA);return}await yi(Ni,{session:UA})}async function kr(){let Ni=e.focused;if(!Ni)throw Pn("NO_ACTIVE_AGENT");if(Ni.source.kind!=="local")throw Pn("CLEAR_IMMUTABLE_DEPLOYED",{detail:`${p7e(Ni)} is a deployment \u2014 it owns its session in the cloud, so there is no fresh one to start from the TUI`,context:{name:p7e(Ni)}});let UA=Ni.source.project;await Gt(Ni.sessionId),await yi(UA)}async function Dr(Ni){await yi(Ni)}async function Mi(){let Ni=e.focused;if(!Ni)return;await Gt(Ni.sessionId)}function Xa(Ni){e.focus(Ni),GA.reset(),d(),li()}async function Gt(Ni){try{await e.stop(Ni)}finally{k(Ni),d()}}async function at(Ni){let UA=e.focused;if(!UA)throw Pn("NO_ACTIVE_AGENT");if(UA.source.kind!=="local")throw Pn("MODEL_IMMUTABLE_DEPLOYED",{detail:`${p7e(UA)} is a deployment \u2014 its model is set at deploy time, not from the TUI`,context:{sessionId:UA.sessionId}});let{project:EA,session:nn}=e;if(!EA)throw Pn("NO_FOCUSED_INSTANCE");let ns=Date.now(),vs=Ni;await nn?.commit("axon:model:start",{name:vs});try{let Fr=await EA.model.set(Ni);await nn?.commit("axon:model:complete",{name:vs,durationMs:Date.now()-ns,changed:Fr.changed,dropped:[]});{let Sl=e.runtime?.kernel.engines;if(Sl){if(!Sl.select(Ni))throw Pn("MODEL_UNAVAILABLE",{detail:`no declared provider supplies "${Ni}" \u2014 the choice was saved but the running agent still uses its previous model`,context:{model:Ni}})}}return d(),SA(),Fr}catch(Fr){let Sl=Pn(Fr);throw await nn?.commit("axon:model:failed",{name:vs,error:Sl,durationMs:Date.now()-ns}),Sl}}async function rn(Ni){let UA=e.focused;if(!UA)throw Pn("NO_ACTIVE_AGENT");if(UA.source.kind!=="local")return{changed:!1};let EA=e.project;if(!EA)throw Pn("NO_FOCUSED_INSTANCE");return{changed:!1}}let _a=uA.computed(()=>{return p.value,e.blueprint?.config.model??null});async function fn(){u=!0,i.value="shutting-down";for(let Ni of b.values())Ni.dispose();for(let Ni of $)clearTimeout(Ni);$.clear();try{await e.shutdown()}catch(Ni){throw Ni}}async function Ta(){let Ni=Tt.value;if(!Ni)throw Pn("NO_SESSION_TO_OPEN");let UA=await e.history.fork(Ni);return d(),UA}async function NA(Ni){let UA=Tt.value;if(!UA)throw Pn("NO_SESSION_TO_OPEN");await e.history.rename(UA,Ni),d()}async function Rr(){await e.current?.reload(),d(),te()?.snapshot(),SA()}let lr=uA.computed(()=>{return p.value,e.blueprint?.modules??[]}),zo=uA.computed(()=>{if(p.value,Kn.value)return null;let Ni=e.focused;if(Ni&&Ni.source.kind==="remote"){let EA=Ni.source.target.loaded;return EA?{...EA,durationMs:null}:null}let UA=e.blueprint;if(!UA)return null;return{modules:UA.modules?.length??0,tools:UA.tools?.length??0,durationMs:_t.value}});async function ts(Ni){let UA=e.session,EA=Date.now();await UA?.commit("axon:install:start",{name:Ni,artifact:"extension"});try{let{useExtensions:nn}=await KIe().then(() => j8n),ns=await nn().install(Ni),{name:vs,version:Fr}=tHa(ns.ref);return await UA?.commit("axon:install:complete",{name:vs,version:Fr,durationMs:Date.now()-EA,alreadyInstalled:!ns.declared,artifact:"extension"}),d(),{root:ns.root,ref:ns.ref}}catch(nn){let ns=nn instanceof Error&&"isAxonError"in nn?nn:Pn("EXTENSION_INSTALL_FAILED",{detail:String(nn),context:{source:Ni}});throw await UA?.commit("axon:install:failed",{name:Ni,error:ns,durationMs:Date.now()-EA,artifact:"extension"}),ns}}async function Lu(Ni){let UA=e.session,EA=Date.now(),{name:nn}=tHa(Ni);await UA?.commit("axon:uninstall:start",{name:nn,artifact:"extension"});try{let{useExtensions:ns}=await KIe().then(() => j8n),vs=await ns().uninstall(Ni);return await UA?.commit("axon:uninstall:complete",{name:nn,durationMs:Date.now()-EA,artifact:"extension"}),d(),vs}catch(ns){let vs=ns instanceof Error&&"isAxonError"in ns?ns:Pn("EXTENSION_UNINSTALL_FAILED",{detail:String(ns),context:{source:Ni}});throw await UA?.commit("axon:uninstall:failed",{name:nn,error:vs,durationMs:Date.now()-EA,artifact:"extension"}),vs}}async function Bc(Ni){let{project:UA,session:EA}=e;if(!UA)throw Pn("NO_FOCUSED_INSTANCE",{context:{specifier:Ni}});let nn=Date.now();await EA?.commit("axon:install:start",{name:Ni});try{let[ns]=await UA.modules.install([Ni]);if(!ns)throw Pn("MODULE_INSTALL_FAILED",{detail:"installer returned no result",context:{specifier:Ni}});if(ns.status==="error")throw Pn("MODULE_INSTALL_FAILED",{detail:ns.error,context:{name:ns.name}});if(ns.status==="not-found")return await EA?.commit("axon:install:not-found",{name:Ni,durationMs:Date.now()-nn}),ns;let vs=ns.status==="already-installed";if(await EA?.commit("axon:install:complete",{name:ns.name,version:ns.version,durationMs:Date.now()-nn,alreadyInstalled:vs}),!vs)await Rr();return ns}catch(ns){let vs=Pn(ns);throw await EA?.commit("axon:install:failed",{name:Ni,error:vs,durationMs:Date.now()-nn}),vs}}let fl=uA.computed(()=>{return p.value,e.project?.root??null});async function So(){let Ni=e.project;if(!Ni)return[];return Ni.modules.updates()}async function tb(Ni){let{project:UA,session:EA}=e;if(!UA)throw Pn("NO_FOCUSED_INSTANCE",{context:{names:Ni.map((vs)=>vs.name)}});if(Ni.length===0)return[];let nn=Date.now(),ns=Ni.map((vs)=>vs.name);await EA?.commit("axon:update:start",{names:ns,artifact:"module"});try{let vs=await UA.modules.update(Ni),Fr=vs.filter((Ed)=>Ed.status==="installed"),Sl=vs.filter((Ed)=>Ed.status==="error"||Ed.status==="not-found");if(await EA?.commit("axon:update:complete",{names:ns,artifact:"module",updated:Fr.map((Ed)=>({name:Ed.name,version:Ed.version})),failed:Sl.map((Ed)=>({name:Ed.name,error:Ed.status==="error"?Ed.error:"not in the registry"})),durationMs:Date.now()-nn}),Fr.length>0)await Rr();return vs}catch(vs){let Fr=Pn(vs);throw await EA?.commit("axon:update:failed",{names:ns,artifact:"module",error:Fr,durationMs:Date.now()-nn}),Fr}}async function si(){let Ni=e.project;if(!Ni)return[];return Ni.env.keys()}async function ii(Ni,UA){let{project:EA,session:nn}=e;if(!EA)throw Pn("NO_FOCUSED_INSTANCE",{context:{key:Ni}});let ns=Date.now();await nn?.commit("axon:env:set:start",{key:Ni});try{await EA.env.set(Ni,UA),await nn?.commit("axon:env:set:complete",{key:Ni,durationMs:Date.now()-ns}),await Rr()}catch(vs){let Fr=Pn(vs);throw await nn?.commit("axon:env:set:failed",{key:Ni,error:Fr,durationMs:Date.now()-ns}),Fr}}async function To(Ni){let{project:UA,session:EA}=e;if(!UA)throw Pn("NO_FOCUSED_INSTANCE",{context:{key:Ni}});let nn=Date.now();await EA?.commit("axon:env:set:start",{key:Ni});try{await UA.env.unset(Ni),await EA?.commit("axon:env:set:complete",{key:Ni,durationMs:Date.now()-nn}),await Rr()}catch(ns){let vs=Pn(ns);throw await EA?.commit("axon:env:set:failed",{key:Ni,error:vs,durationMs:Date.now()-nn}),vs}}async function $u(){let Ni=e.project;if(!Ni)return null;return Ni.cognet.updates()}async function Fc(Ni,UA){let{project:EA,session:nn}=e;if(!EA)throw Pn("NO_FOCUSED_INSTANCE",{context:{name:Ni}});let ns=Date.now();await nn?.commit("axon:update:start",{names:[Ni],artifact:"cognet"});try{await EA.cognet.update(UA),await nn?.commit("axon:update:complete",{names:[Ni],artifact:"cognet",updated:[{name:Ni,version:UA}],failed:[],durationMs:Date.now()-ns}),await Rr()}catch(vs){let Fr=Pn(vs);throw await nn?.commit("axon:update:failed",{names:[Ni],artifact:"cognet",error:Fr,durationMs:Date.now()-ns}),Fr}}async function Zu(Ni){let{project:UA,session:EA}=e;if(!UA)throw Pn("NO_FOCUSED_INSTANCE",{context:{name:Ni}});let nn=Date.now();await EA?.commit("axon:uninstall:start",{name:Ni});try{let ns=await UA.modules.uninstall(Ni);if(ns.status==="source-declared"){let vs=Pn("MODULE_SOURCE_DECLARED",{detail:`"${Ni}" is declared as an import in ${ns.path}, not as a registry name \u2014 `+"remove the import and its entry in modules: [...] to uninstall it.",context:{name:Ni,path:ns.path}});return await EA?.commit("axon:uninstall:failed",{name:Ni,error:vs,durationMs:Date.now()-nn}),ns}if(await EA?.commit("axon:uninstall:complete",{name:Ni,durationMs:Date.now()-nn}),ns.status==="removed")await Rr();return ns}catch(ns){let vs=Pn(ns);throw await EA?.commit("axon:uninstall:failed",{name:Ni,error:vs,durationMs:Date.now()-nn}),vs}}async function tc(Ni){let UA=Kn.value?null:te();if(!UA){Va.value=[...Va.value,Ni];return}await UA.send(Ni)}let _g={list(){return te()?.promptNames()??[]},render(Ni){let UA=te();if(!UA)throw Pn("NOT_BOOTED",{detail:"no running agent to render a prompt against"});return UA.renderPrompt(Ni)},async fetch(Ni){let UA=te();if(!UA)throw Pn("NOT_BOOTED",{detail:"no running agent to render a prompt against"});return UA.renderPromptEntry(await A.prompts.entry(Ni))}};function cu(){return te()?.interrupt()??!1}async function wg(Ni,UA){let EA=e.get(Ni);if(!EA)throw Pn("SESSION_NOT_RUNNING",{context:{sessionId:Ni}});if(EA.source.kind!=="local")throw Error(`CAPSULE_NOT_LOCAL: ${Ni} is an attached deployment \u2014 its capsule runs in the cloud, not on this machine`);let nn=EA.source.agent,ns=nn.kind==="process"?await nn.current.kernel.run(UA,{origin:"host"}):await nn.link.run(UA);return{ok:ns.ok,...ns.value!==void 0?{value:ns.value}:{},stdout:ns.stdout,...ns.error?{error:ns.error}:{}}}let to=uA.computed(()=>Kn.value?[...Va.value]:[...te()?.queued.value??[],...Va.value]),Hu=uA.computed(()=>{if(i.value==="booting")return"booting";if(i.value==="shutting-down")return"shutting-down";return te()?.activity.value??null}),Nc=uA.computed(()=>{return p.value,te()?.connection??"live"}),JI=uA.computed(()=>{return p.value,te()?.turnTimings.value??[]});return{active:me,connection:Nc,turnTimings:JI,available:be,refreshAvailable:nt,selected:je,displayName:Ct,switching:Kn,model:_a,sessionId:ma,sessionFile:Tt,forkSession:Ta,renameSession:NA,home:na,homeLabelled:Ra,loaded:zo,engineDescriptor:Ja,manifest:Un,context:bn,contextModel:qa,resolvedModel:mn,bootStage:uA.computed(()=>Oe.value),status:i,activity:Hu,queued:to,error:s,session:Ye,instances:ya,instancesByAgent:wa,sessions:Aa,modules:lr,select:Ji,spawn:yi,attachDeployment:Te,attachUrl:Ze,refreshDeployments:ce,deploymentsError:ke,resume:ti,clear:kr,spawnSibling:Dr,close:Mi,focus:Xa,stop:Gt,setModel:at,setThinking:rn,shutdown:fn,reboot:Rr,send:tc,interrupt:cu,capsule:wg,prompts:_g,preview:fr,installModule:Bc,installExtension:ts,uninstallExtension:Lu,uninstallModule:Zu,projectRoot:fl,moduleUpdates:So,updateModules:tb,cognetUpdate:$u,updateCognet:Fc,envKeys:si,setKey:ii,unsetKey:To,async commit(Ni,UA){let EA=e.session;if(!EA)return;if(typeof EA.commit!=="function")throw Pn("NOT_WIRED",{detail:`the focused agent's session has no commit path, so "${Ni}" cannot be recorded`});await EA.commit(Ni,UA)}}}function Uc(){if(!qBt){let e=IC();qBt=oCr(e.agents,e.store,{deployments:e.deployments,prompts:e.prompts,cloud:e.cloud.client});let n=qBt;Y5a({async focus(A){n.focus(A)},async send(A){await n.send(A)},async interrupt(){n.interrupt()},async capsule(A,i){return n.capsule(A,i)}}),bAe().listen(),qBt.refreshDeployments()}return qBt}var Wbr=500,Zbr=1e4,Vbr=10,qBt;var Ek=xt(async()=>{pRe();Fs();r_();qs();pBt();w8t();W5a();KSn();aYa();await Qk([a3(),B8t()])});function EOa(e){return{session:e?.session??"normal",kernel:e?.kernel??!1,cognet:e?.cognet??!1}}function XEr(e){if(e.endsWith(":error")||e.endsWith(":failed"))return"error";if(VEr.has(e))return"info";return"debug"}function eyr(e){if(e.type!=="axon:error")return!1;let n=e.data.error;if(!n||typeof n!=="object")return!1;let A=n.context;if(!A||typeof A!=="object")return!1;return typeof A.commandId==="string"}function yOa(e,n){if(eyr(e)&&n.session!=="verbose")return!1;return tyr[n.session].has(XEr(e.type))}function QOa(e,n){return n.kernel}function _Oa(e,n){if(e.type==="axon:system:message"&&e.data.type==="hot-reload")return!1;if(e.type==="axon:system:message"&&e.data.type==="format-violation")return!1;if(e.type==="axon:system:malformed")return!1;if(e.type==="axon:agent:done")return!1;return nyr.has(e.type)}function wOa(e,n){if(!n)return!1;let A=n;return e.some((i)=>{if(i.type!=="axon:error")return!1;let s=i.data.error;if(s===n)return!0;if(!s||typeof s!=="object")return!1;let u=s;if(u.message!==A.message)return!1;return u.code===void 0||A.code===void 0||u.code===A.code})}var VEr,tyr,nyr;var hNn=xt(()=>{VEr=new Set(["axon:reload:start","axon:reload:complete","axon:install:start","axon:install:complete","axon:uninstall:start","axon:uninstall:complete","axon:update:start","axon:update:complete","axon:model:complete","axon:session:restored","compress","build:warning","axon:connect:start","axon:connect:step","axon:connect:complete","axon:connect:interrupted"]);tyr={quiet:new Set(["error"]),normal:new Set(["error","info"]),verbose:new Set(["error","info","debug"])};nyr=new Set(["cognet:stimulus:text","cognet:stimulus:audio","cognet:stimulus:visual","cognet:stimulus:vector","cognet:output:text","cognet:output:audio","cognet:output:visual","cognet:output:vector","cognet:action:typescript","cognet:action:result","axon:interrupt","axon:system:message","subagent:start","subagent:end"])});function uyr(){let e=new Map;for(let[n,A]of Object.entries(i2)){for(let[i,s]of Object.entries(A))i2[i]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},A[i]=i2[i],e.set(s[0],s[1]);Object.defineProperty(i2,n,{value:A,enumerable:!1})}return Object.defineProperty(i2,"codes",{value:e,enumerable:!1}),i2.color.close="\x1B[39m",i2.bgColor.close="\x1B[49m",i2.color.ansi=SOa(),i2.color.ansi256=NOa(),i2.color.ansi16m=GOa(),i2.bgColor.ansi=SOa(10),i2.bgColor.ansi256=NOa(10),i2.bgColor.ansi16m=GOa(10),Object.defineProperties(i2,{rgbToAnsi256:{value(n,A,i){if(n===A&&A===i){if(n<8)return 16;if(n>248)return 231;return Math.round((n-8)/247*24)+232}return 16+36*Math.round(n/255*5)+6*Math.round(A/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(n){let A=/[a-f\d]{6}|[a-f\d]{3}/i.exec(n.toString(16));if(!A)return[0,0,0];let[i]=A;if(i.length===3)i=[...i].map((u)=>u+u).join("");let s=Number.parseInt(i,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:(n)=>i2.rgbToAnsi256(...i2.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value(n){if(n<8)return 30+n;if(n<16)return 90+(n-8);let A,i,s;if(n>=232)A=((n-232)*10+8)/255,i=A,s=A;else{n-=16;let d=n%36;A=Math.floor(n/36)/5,i=Math.floor(d/6)/5,s=d%6/5}let u=Math.max(A,i,s)*2;if(u===0)return 30;let p=30+(Math.round(s)<<2|Math.round(i)<<1|Math.round(A));if(u===2)p+=60;return p},enumerable:!1},rgbToAnsi:{value:(n,A,i)=>i2.ansi256ToAnsi(i2.rgbToAnsi256(n,A,i)),enumerable:!1},hexToAnsi:{value:(n)=>i2.ansi256ToAnsi(i2.hexToAnsi256(n)),enumerable:!1}}),i2}var SOa=(e=0)=>(n)=>`\x1B[${n+e}m`,NOa=(e=0)=>(n)=>`\x1B[${38+e};5;${n}m`,GOa=(e=0)=>(n,A,i)=>`\x1B[${38+e};2;${n};${A};${i}m`,i2,PSo,syr,cyr,JSo,lyr,Yne;var MOa=xt(()=>{i2={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},PSo=Object.keys(i2.modifier),syr=Object.keys(i2.color),cyr=Object.keys(i2.bgColor),JSo=[...syr,...cyr];lyr=uyr(),Yne=lyr});import CNn from"process";import gyr from"os";import LOa from"tty";function u$(e,n=globalThis.Deno?globalThis.Deno.args:CNn.argv){let A=e.startsWith("-")?"":e.length===1?"-":"--",i=n.indexOf(A+e),s=n.indexOf("--");return i!==-1&&(s===-1||i<s)}function pyr(){if("FORCE_COLOR"in r2){if(r2.FORCE_COLOR==="true")return 1;if(r2.FORCE_COLOR==="false")return 0;return r2.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(r2.FORCE_COLOR,10),3)}}function myr(e){if(e===0)return!1;return{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function dyr(e,{streamIsTTY:n,sniffFlags:A=!0}={}){let i=pyr();if(i!==void 0)N4t=i;let s=A?N4t:i;if(s===0)return 0;if(A){if(u$("color=16m")||u$("color=full")||u$("color=truecolor"))return 3;if(u$("color=256"))return 2}if("TF_BUILD"in r2&&"AGENT_NAME"in r2)return 1;if(e&&!n&&s===void 0)return 0;let u=s||0;if(r2.TERM==="dumb")return u;if(CNn.platform==="win32"){let p=gyr.release().split(".");if(Number(p[0])>=10&&Number(p[2])>=10586)return Number(p[2])>=14931?3:2;return 1}if("CI"in r2){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((p)=>(p in r2)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((p)=>(p in r2))||r2.CI_NAME==="codeship")return 1;return u}if("TEAMCITY_VERSION"in r2)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r2.TEAMCITY_VERSION)?1:0;if(r2.COLORTERM==="truecolor")return 3;if(r2.TERM==="xterm-kitty")return 3;if(r2.TERM==="xterm-ghostty")return 3;if(r2.TERM==="wezterm")return 3;if("TERM_PROGRAM"in r2){let p=Number.parseInt((r2.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(r2.TERM_PROGRAM){case"iTerm.app":return p>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(r2.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(r2.TERM))return 1;if("COLORTERM"in r2)return 1;return u}function qOa(e,n={}){let A=dyr(e,{streamIsTTY:e&&e.isTTY,...n});return myr(A)}var r2,N4t,fyr,TOa;var UOa=xt(()=>{({env:r2}=CNn);if(u$("no-color")||u$("no-colors")||u$("color=false")||u$("color=never"))N4t=0;else if(u$("color")||u$("colors")||u$("color=true")||u$("color=always"))N4t=1;fyr={stdout:qOa({isTTY:LOa.isatty(1)}),stderr:qOa({isTTY:LOa.isatty(2)})},TOa=fyr});function ROa(e,n,A){let i=e.indexOf(n);if(i===-1)return e;let s=n.length,u=0,p="";do p+=e.slice(u,i)+n+A,u=i+s,i=e.indexOf(n,u);while(i!==-1);return p+=e.slice(u),p}function KOa(e,n,A,i){let s=0,u="";do{let p=e[i-1]==="\r";u+=e.slice(s,p?i-1:i)+n+(p?`\r
|
|
5050
|
+
`).map((A)=>JSON.parse(A))}function eCr(e){if(e==="process:attach"||e==="process:detach")return!1;return e.startsWith("kernel:")||e.startsWith("cognet:")||e.startsWith("process:")||e.startsWith("capsule:")}function tCr(e){let n=[],A=[],i=[];for(let s of H8n(e))if(LMe.some((u)=>s.type.startsWith(u)))A.push(s);else if(eCr(s.type))i.push(s);else n.push(s);return{events:n,entries:A,kernelEvents:i,processes:[]}}function tHa(e){let n=e.lastIndexOf("@");return n>0?{name:e.slice(0,n),version:e.slice(n+1)}:{name:e,version:""}}function nCr(e){return zbr(e.paths.root,e.paths.data)}async function aCr(e){let n=Xbr(e);if(!n)return[];for(let A=0;A<10;A++){let i=H8n(n);if(i.some((s)=>s.type.endsWith(":error")||s.type.endsWith(":failed")))return i;await new Promise((s)=>setTimeout(s,30))}return H8n(n)}function p7e(e){return e.source.kind==="remote"?e.source.target.name:e.source.project.name}function nHa(e){let n=iHa(e,"package.json");if(AHa(n))try{let A=JSON.parse(aHa(n,"utf-8")).name;if(A)return A}catch{}return W8t(e)}function ACr(e){let{main:n}=e.kernel.userland;return{...n.pid!==void 0?{pid:n.pid}:{},status:n.status,...n.startedAt!=null?{startedAt:n.startedAt}:{}}}function iCr(e){return e.source.kind==="remote"?{kind:"remote",instance:e,axon:e.source.agent}:{kind:"local",instance:e}}function rCr(e){let n=e.instance,A=uA.shallowRef(TBt()),i=uA.ref("live"),s=uA.ref([]),u=uA.ref(0),p=uA.ref([]),d=uA.ref(!1),b=null,E=0,y=0,k=0;function x(){if(e.kind==="local"){let ce=e.instance.source.kind!=="remote"?e.instance.source.agent:null;if(!ce)throw Error("local cell without an agent");let ke=ce.kind==="process"?ce.current:ce;return{log:ke.session.log,kernelLog:ke.session.kernelLog,entries:ke.session.entries,processes:ce.kind==="process"?$Ke(ke.session.kernelLog,{main:ACr(ce.current)}):$Ke(ke.session.kernelLog)}}let be=e.axon.session;return{log:be.log,kernelLog:be.kernelLog,entries:be.entries,processes:$Ke(be.kernelLog)}}function S(){let be=x();E=be.log.length,y=be.kernelLog.length,k=be.entries.length,A.value={events:[...be.log],kernelEvents:[...be.kernelLog],entries:[...be.entries],processes:be.processes}}S();function L(be){let ce=x();if(be.startsWith("process:")||be.startsWith("capsule:"))A.value={...A.value,processes:ce.processes};let ke=ce.entries.slice(k);if(k=ce.entries.length,ke.length>0)A.value.entries.push(...ke);let Te=ce.kernelLog.slice(y);if(y=ce.kernelLog.length,Te.length>0)A.value.kernelEvents.push(...Te);let Ze=ce.log.slice(E);if(E=ce.log.length,Ze.length>0)A.value.events.push(...Ze);if(ke.length>0||Te.length>0||Ze.length>0)A.value={...A.value}}let U=e.kind==="local"?(()=>{let be=n.source.kind!=="remote"?n.source.agent:null;if(!be)throw Error("local cell without an agent");return be.kind==="process"?be.current.bus.onAny((ce)=>L(ce)):be.bus.onAny((ce)=>L(ce))})():(()=>{let be=0,ce=!1,ke=null,Te=null,Ze=()=>{if(ce)return;ke=e.axon.session.subscribe({onEvent:(je)=>{if(be!==0)be=0,i.value="live";L(je.type)},onLive:()=>{be=0,i.value="live"},onReset:()=>{S()},onClose:()=>{i.value="closed"},onError:()=>{if(ce)return;i.value="reconnecting",nt()}})},nt=()=>{if(ce)return;if(be+=1,be>Vbr){i.value="lost";return}let je=Math.min(Wbr*2**(be-1),Zbr);Te=setTimeout(Ze,je)};return Ze(),()=>{if(ce=!0,Te)clearTimeout(Te);ke?.()}})();async function $(be){if(e.kind==="local"&&n.source.kind==="linked"){let Ze=n.source.agent;d.value=!1;let nt={interrupt:()=>Ze.link.interrupt("user")};b=nt;try{if((await Ze.link.request({type:"cognet:stimulus:text",data:{content:be,channel:"terminal"}})).interrupted)d.value=!0}finally{if(b===nt)b=null}return}let ce=e.kind==="local"?n.source.kind==="local"&&n.source.agent.kind==="process"?n.source.agent.current.axon:null:e.axon;if(!ce)throw Error("cell has no invocation target");let ke=ce.stream({prompt:be,channel:"terminal"}),{stream:Te}=ke;b=ke,d.value=!1;try{for await(let Ze of Te);}finally{if(b===ke)b=null}}async function V(){while(s.value.length>0){let be=s.value;s.value=[];try{await $(be)}catch{}}}async function te(be){if(u.value>0){s.value=[...s.value,be];return}u.value++;let ce=Date.now();try{try{await $(be)}finally{await V()}if(!d.value){let ke=x().entries.at(-1)?.time.seq;if(ke!==void 0)p.value=[...p.value.filter((Te)=>Te.afterSeq!==ke),{afterSeq:ke,durationMs:Date.now()-ce}]}}finally{u.value--}}function ee(){let be=b;if(!be)return!1;return s.value=[],d.value=!0,be.interrupt(),!0}let me=uA.computed(()=>{if(i.value==="reconnecting")return"reconnecting";if(i.value==="closed"||i.value==="lost")return"disconnected";if(A.value.events.findLast((ce)=>ce.type.startsWith("axon:reload:"))?.type==="axon:reload:start")return"rebooting";if(u.value===0||d.value)return null;return"working"});return{instance:n,session:A,activity:me,queued:uA.computed(()=>s.value),busy:uA.computed(()=>u.value>0),turnTimings:uA.computed(()=>p.value),send:te,interrupt:ee,snapshot:S,promptNames(){if(e.kind!=="local"||n.source.kind==="remote")return[];let be=n.source.agent;return be.kind==="process"?be.current.axon.prompts.list():[]},async renderPrompt(be){if(e.kind!=="local"||n.source.kind==="remote")throw Pn("NOT_WIRED",{detail:"prompt rendering is not available on a deployed agent"});let ce=n.source.agent;return ce.kind==="process"?ce.current.axon.prompt(be):await ce.link.prompts({action:"get",name:be})},async renderPromptEntry(be){if(e.kind!=="local"||n.source.kind==="remote")throw Pn("NOT_WIRED",{detail:"prompt rendering is not available on a deployed agent"});let ce=n.source.agent;return ce.kind==="process"?ce.current.axon.prompts.renderEntry(be):await ce.link.prompts({action:"render",entry:be})},get connection(){return i.value},dispose(){U()}}}function oCr(e,n,A){let i=uA.ref("idle"),s=uA.ref(null),u=!1,p=uA.ref(0);function d(){p.value++}let b=new Map;function E(Ni){return b.get(Ni)??null}function y(Ni){let UA=b.get(Ni.sessionId);if(UA)return UA;let EA=rCr(iCr(Ni));return b.set(Ni.sessionId,EA),d(),EA}function k(Ni){let UA=b.get(Ni);if(!UA)return;UA.dispose(),b.delete(Ni),d()}let x=300000,S=new Map,L=new Map,U=uA.ref(0),$=new Set;function V(){let Ni=Date.now()-x;for(let[UA,EA]of S)if(EA.at<=Ni)S.delete(UA)}e.onSpawn((Ni)=>{if(L.set(Ni.sessionId,{sessionId:Ni.sessionId,parentSessionId:Ni.parentSessionId,rootSessionId:Ni.rootSessionId,depth:Ni.depth,name:p7e(Ni)}),S.delete(Ni.sessionId))U.value++;y(Ni)}),e.onStop((Ni)=>{if(u)return;let UA=L.get(Ni);if(UA){let EA=Date.now();S.set(Ni,{view:{...UA,focused:!1,activity:null,exitedAt:EA},at:EA}),U.value++,$.add(setTimeout(()=>{U.value++},x+1000))}k(Ni)});function te(){p.value;let Ni=e.focused;return Ni?b.get(Ni.sessionId)??null:null}let ee=uA.ref([]),me=uA.computed(()=>{return p.value,e.active}),be=uA.computed(()=>{p.value;let Ni=n.profiles.active(),UA=Ni?Ni.agents.list().map((nn)=>({kind:"local",dir:nn,name:nHa(Ni.agents.path(nn))})):[],EA=A.deployments.list().map((nn)=>({kind:"deployed",name:nn.name,deploymentId:nn.deploymentId,tier:nn.tier,warmth:nn.warmth}));return[...UA,...EA]});async function ce(){await A.deployments.refresh(),d()}let ke=uA.computed(()=>{return p.value,A.deployments.error});async function Te(Ni){let UA=A.deployments.list().find((EA)=>EA.deploymentId===Ni);if(!UA)throw Pn("DEPLOYMENT_NOT_CONNECTABLE",{context:{deploymentId:Ni}});i.value="booting",Xe.value=UA.name,gt.value=null,s.value=null,ee.value=[];try{let EA=await e.attach({url:UA.url,name:UA.name,agentId:UA.agentId,deploymentId:UA.deploymentId,tier:UA.tier});y(EA),i.value="idle",ee.value=[],Xe.value=null,li()}catch(EA){throw i.value="error",s.value=EA instanceof Error?EA:Error(String(EA)),EA}finally{d()}}async function Ze(Ni){let UA=Ni.trim();if(UA==="")throw Pn("ATTACH_URL_REQUIRED");i.value="booting",Xe.value=UA,gt.value=null,s.value=null,ee.value=[];try{let EA=await e.attach({url:UA,name:""});y(EA),i.value="idle",ee.value=[],Xe.value=null,li()}catch(EA){throw i.value="error",s.value=EA instanceof Error?EA:Error(String(EA)),EA}finally{d()}}function nt(){d()}let je=uA.computed(()=>{p.value;let Ni=e.focused;if(Ni&&Ni.source.kind==="remote")return Ni.source.target.name;return e.project?.name??null}),Xe=uA.ref(null),gt=uA.ref(null),Oe=uA.ref(null),_t=uA.ref(null),tn=O5a(),Ct=uA.computed(()=>je.value??Xe.value),Kn=uA.computed(()=>Xe.value!==null),ma=uA.computed(()=>{if(p.value,Kn.value)return null;return e.focused?.sessionId??null}),Tt=uA.computed(()=>{p.value;let Ni=e.blueprint,UA=ma.value;if(!Ni||!UA)return null;return iHa(nCr(Ni),"sessions",`${UA}.jsonl`)}),na=uA.computed(()=>{if(p.value,Kn.value)return gt.value;let Ni=e.focused;if(Ni&&Ni.source.kind==="remote")return Ni.source.target.url;return e.project?.root??null}),Ra=uA.computed(()=>{return p.value,nYa(na.value,n.profiles.active()?.agents.root??null)}),Un=uA.computed(()=>{if(p.value,!Kn.value&&!gt.value)return null;let Ni=gt.value;if(!Ni)return null;return n.state.get()?.agentManifests?.[W8t(Ni)]??null}),Ja=uA.computed(()=>{if(p.value,Kn.value){let vs=gt.value;if(!vs)return null;return n.state.get()?.agentModels?.[W8t(vs)]??null}let Ni=e.focused;if(Ni&&Ni.source.kind==="remote"){let vs=Ni.source.target.engine;if(!vs)return null;return x8t({provider:vs.provider,declared:vs.model,resolved:null})}let EA=e.runtime?.kernel.engines,nn=EA?.primary;if(EA&&nn&&EA.has(nn)){let vs=EA.get(nn).binding.capability;return x8t({provider:vs.provider,declared:vs.id,resolved:null})}let ns=gne(e.blueprint?.config.model);if(ns)return x8t({provider:ns.provider??"axon",declared:ns.model,resolved:mn.value});return null}),GA=V5a(),bn=uA.computed(()=>{if(p.value,Kn.value)return null;return GA.step(Z5a(Ye.value.kernelEvents,Ye.value.entries))}),ya=uA.computed(()=>{p.value,U.value,V();let Ni=e.focused?.sessionId??null,UA=e.list().map((ns)=>({sessionId:ns.sessionId,parentSessionId:ns.parentSessionId,rootSessionId:ns.rootSessionId,depth:ns.depth,name:p7e(ns),focused:ns.sessionId===Ni,activity:E(ns.sessionId)?.activity.value??null,exitedAt:null}));if(S.size===0)return UA;let EA=new Map;for(let ns of UA)EA.set(ns.sessionId,ns);for(let[ns,vs]of S)EA.set(ns,vs.view);let nn=[];for(let ns of L.keys()){let vs=EA.get(ns);if(vs)nn.push(vs),EA.delete(ns)}return[...nn,...EA.values()]}),wa=uA.computed(()=>{p.value;let Ni=e.focused?.sessionId??null,UA=new Map;for(let EA of e.recent()){let nn=p7e(EA),ns={sessionId:EA.sessionId,parentSessionId:EA.parentSessionId,rootSessionId:EA.rootSessionId,depth:EA.depth,name:nn,focused:EA.sessionId===Ni,activity:E(EA.sessionId)?.activity.value??null,exitedAt:null},vs=UA.get(nn);if(vs)vs.push(ns);else UA.set(nn,[ns])}return UA}),Aa=uA.computed(()=>{return p.value,e.sessions()}),Ya=uA.ref(null),ga=new Map,fr={id:uA.computed(()=>Ya.value),show(Ni){if(!ga.has(Ni.sessionId))ga.set(Ni.sessionId,tCr(Ni.filePath));Ya.value=Ni.sessionId},clear(){Ya.value=null,ga.clear()}},Ye=uA.computed(()=>{if(Ya.value!==null)return ga.get(Ya.value)??TBt();if(ee.value.length>0)return{...TBt(),events:ee.value};if(Kn.value)return TBt();return te()?.session.value??TBt()}),vn=uA.ref(null),mn=uA.computed(()=>{if(p.value,Kn.value)return null;return $5a(Ye.value.kernelEvents)??vn.value}),qa=uA.computed(()=>{if(p.value,Kn.value)return null;let Ni=mn.value;if(Ni)return Ni;let UA=gne(e.blueprint?.config.model)?.model??null;return UA==="auto"?null:UA});async function SA(){let Ni=z5a(e.blueprint?.config.model);if(!Ni){vn.value=null;return}try{let UA=await A.cloud.cloud.engine.resolve(Ni);vn.value=UA.model}catch{vn.value=null}}let Va=uA.ref([]);async function li(){let Ni=te();if(!Ni)return;while(Va.value.length>0&&te()===Ni){let[UA,...EA]=Va.value;Va.value=EA;try{await Ni.send(UA)}catch{}}}async function yi(Ni,UA){let EA=n.profiles.active(),nn=typeof Ni==="string"?EA?EA.agents.path(Ni):null:Ni.root,ns=typeof Ni==="string"?nn?nHa(nn):Ni:Ni.name,vs=tn.claim();i.value="booting",Xe.value=ns,gt.value=nn,Oe.value=null,_t.value=null,s.value=null,ee.value=[];try{let Fr=await e.spawn(Ni,{...UA,focus:UA?.focus===!1?!1:vs.latest,onProgress:(Sl)=>{if(vs.latest)Oe.value=Sl},onTiming:(Sl)=>{if(vs.latest&&Sl.unit==="modules")_t.value=Sl.durationMs}});if(y(Fr),!vs.latest)return d(),Fr.sessionId;i.value="idle",ee.value=[];try{if(Fr.source.kind==="local"){let Sl=W8t(Fr.source.project.root),Ed=Ja.value,nm={...Ed?{model:Ed}:{},modules:lr.value.length,tools:zo.value?.tools??0,...ma.value?{sessionId:ma.value}:{},...bn.value!==null?{context:bn.value}:{}};n.state.update((Kd)=>({...Kd,lastAgent:Sl,...Ed?{agentModels:{...Kd.agentModels,[Sl]:Ed}}:{},agentManifests:{...Kd.agentManifests,[Sl]:nm}}))}}catch{}return Xe.value=null,gt.value=null,Oe.value=null,SA(),li(),Fr.sessionId}catch(Fr){if(!vs.latest)throw Fr;throw i.value="error",s.value=Fr instanceof Error?Fr:Error(String(Fr)),ee.value=await aCr(Fr),Fr}finally{d()}}async function Ji(Ni){i.value="booting";let UA=e.focused;if(UA)await Gt(UA.sessionId);await yi(Ni)}async function ti(Ni,UA){if(e.get(UA)){Xa(UA);return}await yi(Ni,{session:UA})}async function kr(){let Ni=e.focused;if(!Ni)throw Pn("NO_ACTIVE_AGENT");if(Ni.source.kind==="remote")throw Pn("CLEAR_IMMUTABLE_DEPLOYED",{detail:`${p7e(Ni)} is a deployment \u2014 it owns its session in the cloud, so there is no fresh one to start from the TUI`,context:{name:p7e(Ni)}});let UA=Ni.source.project;await Gt(Ni.sessionId),await yi(UA)}async function Dr(Ni){await yi(Ni)}async function Mi(){let Ni=e.focused;if(!Ni)return;await Gt(Ni.sessionId)}function Xa(Ni){e.focus(Ni),GA.reset(),d(),li()}async function Gt(Ni){try{await e.stop(Ni)}finally{k(Ni),d()}}async function at(Ni){let UA=e.focused;if(!UA)throw Pn("NO_ACTIVE_AGENT");if(UA.source.kind==="remote")throw Pn("MODEL_IMMUTABLE_DEPLOYED",{detail:`${p7e(UA)} is a deployment \u2014 its model is set at deploy time, not from the TUI`,context:{sessionId:UA.sessionId}});let{project:EA,session:nn}=e;if(!EA)throw Pn("NO_FOCUSED_INSTANCE");let ns=Date.now(),vs=Ni;await nn?.commit("axon:model:start",{name:vs});try{let Fr=await EA.model.set(Ni);await nn?.commit("axon:model:complete",{name:vs,durationMs:Date.now()-ns,changed:Fr.changed,dropped:[]});{let Sl=e.runtime?.kernel.engines;if(Sl){if(!Sl.select(Ni))throw Pn("MODEL_UNAVAILABLE",{detail:`no declared provider supplies "${Ni}" \u2014 the choice was saved but the running agent still uses its previous model`,context:{model:Ni}})}}return d(),SA(),Fr}catch(Fr){let Sl=Pn(Fr);throw await nn?.commit("axon:model:failed",{name:vs,error:Sl,durationMs:Date.now()-ns}),Sl}}async function rn(Ni){let UA=e.focused;if(!UA)throw Pn("NO_ACTIVE_AGENT");if(UA.source.kind==="remote")return{changed:!1};let EA=e.project;if(!EA)throw Pn("NO_FOCUSED_INSTANCE");return{changed:!1}}let _a=uA.computed(()=>{return p.value,e.blueprint?.config.model??null});async function fn(){u=!0,i.value="shutting-down";for(let Ni of b.values())Ni.dispose();for(let Ni of $)clearTimeout(Ni);$.clear();try{await e.shutdown()}catch(Ni){throw Ni}}async function Ta(){let Ni=Tt.value;if(!Ni)throw Pn("NO_SESSION_TO_OPEN");let UA=await e.history.fork(Ni);return d(),UA}async function NA(Ni){let UA=Tt.value;if(!UA)throw Pn("NO_SESSION_TO_OPEN");await e.history.rename(UA,Ni),d()}async function Rr(){await e.current?.reload(),d(),te()?.snapshot(),SA()}let lr=uA.computed(()=>{return p.value,e.blueprint?.modules??[]}),zo=uA.computed(()=>{if(p.value,Kn.value)return null;let Ni=e.focused;if(Ni&&Ni.source.kind==="remote"){let EA=Ni.source.target.loaded;return EA?{...EA,durationMs:null}:null}let UA=e.blueprint;if(!UA)return null;return{modules:UA.modules?.length??0,tools:UA.tools?.length??0,durationMs:_t.value}});async function ts(Ni){let UA=e.session,EA=Date.now();await UA?.commit("axon:install:start",{name:Ni,artifact:"extension"});try{let{useExtensions:nn}=await KIe().then(() => j8n),ns=await nn().install(Ni),{name:vs,version:Fr}=tHa(ns.ref);return await UA?.commit("axon:install:complete",{name:vs,version:Fr,durationMs:Date.now()-EA,alreadyInstalled:!ns.declared,artifact:"extension"}),d(),{root:ns.root,ref:ns.ref}}catch(nn){let ns=nn instanceof Error&&"isAxonError"in nn?nn:Pn("EXTENSION_INSTALL_FAILED",{detail:String(nn),context:{source:Ni}});throw await UA?.commit("axon:install:failed",{name:Ni,error:ns,durationMs:Date.now()-EA,artifact:"extension"}),ns}}async function Lu(Ni){let UA=e.session,EA=Date.now(),{name:nn}=tHa(Ni);await UA?.commit("axon:uninstall:start",{name:nn,artifact:"extension"});try{let{useExtensions:ns}=await KIe().then(() => j8n),vs=await ns().uninstall(Ni);return await UA?.commit("axon:uninstall:complete",{name:nn,durationMs:Date.now()-EA,artifact:"extension"}),d(),vs}catch(ns){let vs=ns instanceof Error&&"isAxonError"in ns?ns:Pn("EXTENSION_UNINSTALL_FAILED",{detail:String(ns),context:{source:Ni}});throw await UA?.commit("axon:uninstall:failed",{name:nn,error:vs,durationMs:Date.now()-EA,artifact:"extension"}),vs}}async function Bc(Ni){let{project:UA,session:EA}=e;if(!UA)throw Pn("NO_FOCUSED_INSTANCE",{context:{specifier:Ni}});let nn=Date.now();await EA?.commit("axon:install:start",{name:Ni});try{let[ns]=await UA.modules.install([Ni]);if(!ns)throw Pn("MODULE_INSTALL_FAILED",{detail:"installer returned no result",context:{specifier:Ni}});if(ns.status==="error")throw Pn("MODULE_INSTALL_FAILED",{detail:ns.error,context:{name:ns.name}});if(ns.status==="not-found")return await EA?.commit("axon:install:not-found",{name:Ni,durationMs:Date.now()-nn}),ns;let vs=ns.status==="already-installed";if(await EA?.commit("axon:install:complete",{name:ns.name,version:ns.version,durationMs:Date.now()-nn,alreadyInstalled:vs}),!vs)await Rr();return ns}catch(ns){let vs=Pn(ns);throw await EA?.commit("axon:install:failed",{name:Ni,error:vs,durationMs:Date.now()-nn}),vs}}let fl=uA.computed(()=>{return p.value,e.project?.root??null});async function So(){let Ni=e.project;if(!Ni)return[];return Ni.modules.updates()}async function tb(Ni){let{project:UA,session:EA}=e;if(!UA)throw Pn("NO_FOCUSED_INSTANCE",{context:{names:Ni.map((vs)=>vs.name)}});if(Ni.length===0)return[];let nn=Date.now(),ns=Ni.map((vs)=>vs.name);await EA?.commit("axon:update:start",{names:ns,artifact:"module"});try{let vs=await UA.modules.update(Ni),Fr=vs.filter((Ed)=>Ed.status==="installed"),Sl=vs.filter((Ed)=>Ed.status==="error"||Ed.status==="not-found");if(await EA?.commit("axon:update:complete",{names:ns,artifact:"module",updated:Fr.map((Ed)=>({name:Ed.name,version:Ed.version})),failed:Sl.map((Ed)=>({name:Ed.name,error:Ed.status==="error"?Ed.error:"not in the registry"})),durationMs:Date.now()-nn}),Fr.length>0)await Rr();return vs}catch(vs){let Fr=Pn(vs);throw await EA?.commit("axon:update:failed",{names:ns,artifact:"module",error:Fr,durationMs:Date.now()-nn}),Fr}}async function si(){let Ni=e.project;if(!Ni)return[];return Ni.env.keys()}async function ii(Ni,UA){let{project:EA,session:nn}=e;if(!EA)throw Pn("NO_FOCUSED_INSTANCE",{context:{key:Ni}});let ns=Date.now();await nn?.commit("axon:env:set:start",{key:Ni});try{await EA.env.set(Ni,UA),await nn?.commit("axon:env:set:complete",{key:Ni,durationMs:Date.now()-ns}),await Rr()}catch(vs){let Fr=Pn(vs);throw await nn?.commit("axon:env:set:failed",{key:Ni,error:Fr,durationMs:Date.now()-ns}),Fr}}async function To(Ni){let{project:UA,session:EA}=e;if(!UA)throw Pn("NO_FOCUSED_INSTANCE",{context:{key:Ni}});let nn=Date.now();await EA?.commit("axon:env:set:start",{key:Ni});try{await UA.env.unset(Ni),await EA?.commit("axon:env:set:complete",{key:Ni,durationMs:Date.now()-nn}),await Rr()}catch(ns){let vs=Pn(ns);throw await EA?.commit("axon:env:set:failed",{key:Ni,error:vs,durationMs:Date.now()-nn}),vs}}async function $u(){let Ni=e.project;if(!Ni)return null;return Ni.cognet.updates()}async function Fc(Ni,UA){let{project:EA,session:nn}=e;if(!EA)throw Pn("NO_FOCUSED_INSTANCE",{context:{name:Ni}});let ns=Date.now();await nn?.commit("axon:update:start",{names:[Ni],artifact:"cognet"});try{await EA.cognet.update(UA),await nn?.commit("axon:update:complete",{names:[Ni],artifact:"cognet",updated:[{name:Ni,version:UA}],failed:[],durationMs:Date.now()-ns}),await Rr()}catch(vs){let Fr=Pn(vs);throw await nn?.commit("axon:update:failed",{names:[Ni],artifact:"cognet",error:Fr,durationMs:Date.now()-ns}),Fr}}async function Zu(Ni){let{project:UA,session:EA}=e;if(!UA)throw Pn("NO_FOCUSED_INSTANCE",{context:{name:Ni}});let nn=Date.now();await EA?.commit("axon:uninstall:start",{name:Ni});try{let ns=await UA.modules.uninstall(Ni);if(ns.status==="source-declared"){let vs=Pn("MODULE_SOURCE_DECLARED",{detail:`"${Ni}" is declared as an import in ${ns.path}, not as a registry name \u2014 `+"remove the import and its entry in modules: [...] to uninstall it.",context:{name:Ni,path:ns.path}});return await EA?.commit("axon:uninstall:failed",{name:Ni,error:vs,durationMs:Date.now()-nn}),ns}if(await EA?.commit("axon:uninstall:complete",{name:Ni,durationMs:Date.now()-nn}),ns.status==="removed")await Rr();return ns}catch(ns){let vs=Pn(ns);throw await EA?.commit("axon:uninstall:failed",{name:Ni,error:vs,durationMs:Date.now()-nn}),vs}}async function tc(Ni){let UA=Kn.value?null:te();if(!UA){Va.value=[...Va.value,Ni];return}await UA.send(Ni)}let _g={list(){return te()?.promptNames()??[]},render(Ni){let UA=te();if(!UA)throw Pn("NOT_BOOTED",{detail:"no running agent to render a prompt against"});return UA.renderPrompt(Ni)},async fetch(Ni){let UA=te();if(!UA)throw Pn("NOT_BOOTED",{detail:"no running agent to render a prompt against"});return UA.renderPromptEntry(await A.prompts.entry(Ni))}};function cu(){return te()?.interrupt()??!1}async function wg(Ni,UA){let EA=e.get(Ni);if(!EA)throw Pn("SESSION_NOT_RUNNING",{context:{sessionId:Ni}});if(EA.source.kind==="remote")throw Pn("CAPSULE_NOT_LOCAL",{detail:`${Ni} is an attached deployment \u2014 its capsule runs in the cloud, not on this machine`,context:{sessionId:Ni}});let nn=EA.source.agent,ns=nn.kind==="process"?await nn.current.kernel.run(UA,{origin:"host"}):await nn.link.run(UA);return{ok:ns.ok,...ns.value!==void 0?{value:ns.value}:{},stdout:ns.stdout,...ns.error?{error:ns.error}:{}}}let to=uA.computed(()=>Kn.value?[...Va.value]:[...te()?.queued.value??[],...Va.value]),Hu=uA.computed(()=>{if(i.value==="booting")return"booting";if(i.value==="shutting-down")return"shutting-down";return te()?.activity.value??null}),Nc=uA.computed(()=>{return p.value,te()?.connection??"live"}),JI=uA.computed(()=>{return p.value,te()?.turnTimings.value??[]});return{active:me,connection:Nc,turnTimings:JI,available:be,refreshAvailable:nt,selected:je,displayName:Ct,switching:Kn,model:_a,sessionId:ma,sessionFile:Tt,forkSession:Ta,renameSession:NA,home:na,homeLabelled:Ra,loaded:zo,engineDescriptor:Ja,manifest:Un,context:bn,contextModel:qa,resolvedModel:mn,bootStage:uA.computed(()=>Oe.value),status:i,activity:Hu,queued:to,error:s,session:Ye,instances:ya,instancesByAgent:wa,sessions:Aa,modules:lr,select:Ji,spawn:yi,attachDeployment:Te,attachUrl:Ze,refreshDeployments:ce,deploymentsError:ke,resume:ti,clear:kr,spawnSibling:Dr,close:Mi,focus:Xa,stop:Gt,setModel:at,setThinking:rn,shutdown:fn,reboot:Rr,send:tc,interrupt:cu,capsule:wg,prompts:_g,preview:fr,installModule:Bc,installExtension:ts,uninstallExtension:Lu,uninstallModule:Zu,projectRoot:fl,moduleUpdates:So,updateModules:tb,cognetUpdate:$u,updateCognet:Fc,envKeys:si,setKey:ii,unsetKey:To,async commit(Ni,UA){let EA=e.session;if(!EA)return;if(typeof EA.commit!=="function")throw Pn("NOT_WIRED",{detail:`the focused agent's session has no commit path, so "${Ni}" cannot be recorded`});await EA.commit(Ni,UA)}}}function Uc(){if(!qBt){let e=IC();qBt=oCr(e.agents,e.store,{deployments:e.deployments,prompts:e.prompts,cloud:e.cloud.client});let n=qBt;Y5a({async focus(A){n.focus(A)},async send(A){await n.send(A)},async interrupt(){n.interrupt()},async capsule(A,i){return n.capsule(A,i)}}),bAe().listen(),qBt.refreshDeployments()}return qBt}var Wbr=500,Zbr=1e4,Vbr=10,qBt;var Ek=xt(async()=>{pRe();Fs();r_();qs();pBt();w8t();W5a();KSn();aYa();await Qk([a3(),B8t()])});function EOa(e){return{session:e?.session??"normal",kernel:e?.kernel??!1,cognet:e?.cognet??!1}}function XEr(e){if(e.endsWith(":error")||e.endsWith(":failed"))return"error";if(VEr.has(e))return"info";return"debug"}function eyr(e){if(e.type!=="axon:error")return!1;let n=e.data.error;if(!n||typeof n!=="object")return!1;let A=n.context;if(!A||typeof A!=="object")return!1;return typeof A.commandId==="string"}function yOa(e,n){if(eyr(e)&&n.session!=="verbose")return!1;return tyr[n.session].has(XEr(e.type))}function QOa(e,n){return n.kernel}function _Oa(e,n){if(e.type==="axon:system:message"&&e.data.type==="hot-reload")return!1;if(e.type==="axon:system:message"&&e.data.type==="format-violation")return!1;if(e.type==="axon:system:malformed")return!1;if(e.type==="axon:agent:done")return!1;return nyr.has(e.type)}function wOa(e,n){if(!n)return!1;let A=n;return e.some((i)=>{if(i.type!=="axon:error")return!1;let s=i.data.error;if(s===n)return!0;if(!s||typeof s!=="object")return!1;let u=s;if(u.message!==A.message)return!1;return u.code===void 0||A.code===void 0||u.code===A.code})}var VEr,tyr,nyr;var hNn=xt(()=>{VEr=new Set(["axon:reload:start","axon:reload:complete","axon:install:start","axon:install:complete","axon:uninstall:start","axon:uninstall:complete","axon:update:start","axon:update:complete","axon:model:complete","axon:session:restored","compress","build:warning","axon:connect:start","axon:connect:step","axon:connect:complete","axon:connect:interrupted"]);tyr={quiet:new Set(["error"]),normal:new Set(["error","info"]),verbose:new Set(["error","info","debug"])};nyr=new Set(["cognet:stimulus:text","cognet:stimulus:audio","cognet:stimulus:visual","cognet:stimulus:vector","cognet:output:text","cognet:output:audio","cognet:output:visual","cognet:output:vector","cognet:action:typescript","cognet:action:result","axon:interrupt","axon:system:message","subagent:start","subagent:end"])});function uyr(){let e=new Map;for(let[n,A]of Object.entries(i2)){for(let[i,s]of Object.entries(A))i2[i]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},A[i]=i2[i],e.set(s[0],s[1]);Object.defineProperty(i2,n,{value:A,enumerable:!1})}return Object.defineProperty(i2,"codes",{value:e,enumerable:!1}),i2.color.close="\x1B[39m",i2.bgColor.close="\x1B[49m",i2.color.ansi=SOa(),i2.color.ansi256=NOa(),i2.color.ansi16m=GOa(),i2.bgColor.ansi=SOa(10),i2.bgColor.ansi256=NOa(10),i2.bgColor.ansi16m=GOa(10),Object.defineProperties(i2,{rgbToAnsi256:{value(n,A,i){if(n===A&&A===i){if(n<8)return 16;if(n>248)return 231;return Math.round((n-8)/247*24)+232}return 16+36*Math.round(n/255*5)+6*Math.round(A/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(n){let A=/[a-f\d]{6}|[a-f\d]{3}/i.exec(n.toString(16));if(!A)return[0,0,0];let[i]=A;if(i.length===3)i=[...i].map((u)=>u+u).join("");let s=Number.parseInt(i,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:(n)=>i2.rgbToAnsi256(...i2.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value(n){if(n<8)return 30+n;if(n<16)return 90+(n-8);let A,i,s;if(n>=232)A=((n-232)*10+8)/255,i=A,s=A;else{n-=16;let d=n%36;A=Math.floor(n/36)/5,i=Math.floor(d/6)/5,s=d%6/5}let u=Math.max(A,i,s)*2;if(u===0)return 30;let p=30+(Math.round(s)<<2|Math.round(i)<<1|Math.round(A));if(u===2)p+=60;return p},enumerable:!1},rgbToAnsi:{value:(n,A,i)=>i2.ansi256ToAnsi(i2.rgbToAnsi256(n,A,i)),enumerable:!1},hexToAnsi:{value:(n)=>i2.ansi256ToAnsi(i2.hexToAnsi256(n)),enumerable:!1}}),i2}var SOa=(e=0)=>(n)=>`\x1B[${n+e}m`,NOa=(e=0)=>(n)=>`\x1B[${38+e};5;${n}m`,GOa=(e=0)=>(n,A,i)=>`\x1B[${38+e};2;${n};${A};${i}m`,i2,PSo,syr,cyr,JSo,lyr,Yne;var MOa=xt(()=>{i2={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},PSo=Object.keys(i2.modifier),syr=Object.keys(i2.color),cyr=Object.keys(i2.bgColor),JSo=[...syr,...cyr];lyr=uyr(),Yne=lyr});import CNn from"process";import gyr from"os";import LOa from"tty";function u$(e,n=globalThis.Deno?globalThis.Deno.args:CNn.argv){let A=e.startsWith("-")?"":e.length===1?"-":"--",i=n.indexOf(A+e),s=n.indexOf("--");return i!==-1&&(s===-1||i<s)}function pyr(){if("FORCE_COLOR"in r2){if(r2.FORCE_COLOR==="true")return 1;if(r2.FORCE_COLOR==="false")return 0;return r2.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(r2.FORCE_COLOR,10),3)}}function myr(e){if(e===0)return!1;return{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function dyr(e,{streamIsTTY:n,sniffFlags:A=!0}={}){let i=pyr();if(i!==void 0)N4t=i;let s=A?N4t:i;if(s===0)return 0;if(A){if(u$("color=16m")||u$("color=full")||u$("color=truecolor"))return 3;if(u$("color=256"))return 2}if("TF_BUILD"in r2&&"AGENT_NAME"in r2)return 1;if(e&&!n&&s===void 0)return 0;let u=s||0;if(r2.TERM==="dumb")return u;if(CNn.platform==="win32"){let p=gyr.release().split(".");if(Number(p[0])>=10&&Number(p[2])>=10586)return Number(p[2])>=14931?3:2;return 1}if("CI"in r2){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((p)=>(p in r2)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((p)=>(p in r2))||r2.CI_NAME==="codeship")return 1;return u}if("TEAMCITY_VERSION"in r2)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r2.TEAMCITY_VERSION)?1:0;if(r2.COLORTERM==="truecolor")return 3;if(r2.TERM==="xterm-kitty")return 3;if(r2.TERM==="xterm-ghostty")return 3;if(r2.TERM==="wezterm")return 3;if("TERM_PROGRAM"in r2){let p=Number.parseInt((r2.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(r2.TERM_PROGRAM){case"iTerm.app":return p>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(r2.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(r2.TERM))return 1;if("COLORTERM"in r2)return 1;return u}function qOa(e,n={}){let A=dyr(e,{streamIsTTY:e&&e.isTTY,...n});return myr(A)}var r2,N4t,fyr,TOa;var UOa=xt(()=>{({env:r2}=CNn);if(u$("no-color")||u$("no-colors")||u$("color=false")||u$("color=never"))N4t=0;else if(u$("color")||u$("colors")||u$("color=true")||u$("color=always"))N4t=1;fyr={stdout:qOa({isTTY:LOa.isatty(1)}),stderr:qOa({isTTY:LOa.isatty(2)})},TOa=fyr});function ROa(e,n,A){let i=e.indexOf(n);if(i===-1)return e;let s=n.length,u=0,p="";do p+=e.slice(u,i)+n+A,u=i+s,i=e.indexOf(n,u);while(i!==-1);return p+=e.slice(u),p}function KOa(e,n,A,i){let s=0,u="";do{let p=e[i-1]==="\r";u+=e.slice(s,p?i-1:i)+n+(p?`\r
|
|
5051
5051
|
`:`
|
|
5052
5052
|
`)+A,s=i+1,i=e.indexOf(`
|
|
5053
5053
|
`,s)}while(i!==-1);return u+=e.slice(s),u}function aIt(e){return byr(e)}var YOa,jOa,BNn,D7e,nIt,HOa,x7e,hyr=(e,n={})=>{if(n.level&&!(Number.isInteger(n.level)&&n.level>=0&&n.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let A=YOa?YOa.level:0;e.level=n.level===void 0?A:n.level},byr=(e)=>{let n=(...A)=>A.join(" ");return hyr(n,e),Object.setPrototypeOf(n,aIt.prototype),n},INn=(e,n,A,...i)=>{if(e==="rgb"){if(n==="ansi16m")return Yne[A].ansi16m(...i);if(n==="ansi256")return Yne[A].ansi256(Yne.rgbToAnsi256(...i));return Yne[A].ansi(Yne.rgbToAnsi(...i))}if(e==="hex")return INn("rgb",n,A,...Yne.hexToRgb(...i));return Yne[A][e](...i)},Cyr,Byr,ENn=(e,n,A)=>{let i,s;if(A===void 0)i=e,s=n;else i=A.openAll+e,s=n+A.closeAll;return{open:e,close:n,openAll:i,closeAll:s,parent:A}},G4t=(e,n,A)=>{let i=(...s)=>Iyr(i,s.length===1?""+s[0]:s.join(" "));return Object.setPrototypeOf(i,Byr),i[BNn]=e,i[D7e]=n,i[nIt]=A,i},Iyr=(e,n)=>{if(e.level<=0||!n)return e[nIt]?"":n;let A=e[D7e];if(A===void 0)return n;let{openAll:i,closeAll:s}=A;if(n.includes("\x1B"))while(A!==void 0)n=ROa(n,A.close,A.open),A=A.parent;let u=n.indexOf(`
|
|
@@ -5337,4 +5337,4 @@ EXAMPLES
|
|
|
5337
5337
|
page, rather than tucked behind a command: a file that runs at boot
|
|
5338
5338
|
is code someone is actively editing, and a config that silently
|
|
5339
5339
|
did nothing is indistinguishable from one that never loaded. This
|
|
5340
|
-
is the whole feedback loop for writing an extension. `),(i3(!0),eIt(bNn,null,DOa(h7(x),(ee,me)=>{return i3(),eIt(bNn,{key:`config-${me}`},[ee.axon?(i3(),f7(c$,{key:0,error:ee.axon},null,8,["error"])):(i3(),f7(xAe,{key:1,message:`${ee.label}: ${ee.message}`},null,8,["message"]))],64)}),128))],8,["scroll-bottom"])}}});FOa.__scopeId="data-v-1ab3a5bb";var vOa=FOa;var Y4t=!1;{let e=process.argv.slice(2),n={version:"2.0.
|
|
5340
|
+
is the whole feedback loop for writing an extension. `),(i3(!0),eIt(bNn,null,DOa(h7(x),(ee,me)=>{return i3(),eIt(bNn,{key:`config-${me}`},[ee.axon?(i3(),f7(c$,{key:0,error:ee.axon},null,8,["error"])):(i3(),f7(xAe,{key:1,message:`${ee.label}: ${ee.message}`},null,8,["message"]))],64)}),128))],8,["scroll-bottom"])}}});FOa.__scopeId="data-v-1ab3a5bb";var vOa=FOa;var Y4t=!1;{let e=process.argv.slice(2),n={version:"2.0.158",cwd:process.cwd()},A={"--version":async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},"--help":async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},help:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},init:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},prepare:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},doctor:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},dev:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},run:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},exec:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},build:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},deploy:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},publish:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},install:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},i:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},uninstall:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},list:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},search:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},clone:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},fork:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},watch:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},unwatch:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},settings:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},login:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},logout:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},update:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},whoami:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},cognet:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},prompt:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},ext:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},extension:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},module:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},attach:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},ps:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},status:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},logs:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},undeploy:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},bench:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)},staff:async function(s){let{dispatchCommand:u}=await tB().then(() => KB);return await u(s)}};for(let[i,s]of Object.entries(A))if(i.startsWith("-")&&e.includes(i)){let u=e.indexOf(i);Y4t=await s({...n,args:e.slice(u+1),command:i})!=="boot";break}if(!Y4t){let i=e.findIndex((u)=>!u.startsWith("-")),s=i===-1?void 0:e[i];if(s&&s in A)Y4t=await A[s]({...n,args:e.slice(i+1),command:s})!=="boot"}}if(!Y4t)tQn({routes:[{path:"/logs/kernel",component:XJa,name:"logs-kernel"},{path:"/logs/session",component:aOa,name:"logs-session"},{path:"/capsule/:id",component:oOa,name:"capsule-id"},{path:"/account",component:uOa,name:"account",meta:{layout:"default"}},{path:"/auth",component:mOa,name:"auth",meta:{layout:"default"}},{path:"/",component:vOa,name:"home",meta:{layout:"default"}}],styles:[rHa,P5a,gHa,bHa,RHa,IHa,PPa,ZPa,iJa,hJa,bJa,yJa,QJa,FJa,MJa,TJa,gJa,dJa,cJa,KJa,vHa,qHa,wHa,OJa,ZJa,tOa,iOa,sOa,gOa,xOa],layouts:new Map([["default",zJa]]),middleware:[j5a],screen:{title:"VTerm"},quitKeys:["C-c"],highlight:{theme:{name:"arcnight",type:"dark",colors:{"editor.background":"#070b10","editor.foreground":"#c7eaff"},tokenColors:[{scope:["variable","variable.other","variable.other.property","variable.other.object.property","variable.other.readwrite","meta.object-literal.key","support.variable.property"],settings:{foreground:"#7cceff"}},{scope:["keyword","keyword.control","keyword.other","storage","storage.type","storage.modifier"],settings:{foreground:"#345a94"}},{scope:["constant.numeric","number"],settings:{foreground:"#326396"}},{scope:["entity.name.type","entity.name.class","constant","support.type"],settings:{foreground:"#3caed5"}},{scope:["entity.name.function","support.function","meta.function-call"],settings:{foreground:"#3caed5"}},{scope:["string","string.quoted","string.template"],settings:{foreground:"#4c6696"}},{scope:["keyword.operator","punctuation.accessor"],settings:{foreground:"#7cceff"}},{scope:["comment","comment.line","comment.block"],settings:{foreground:"#585858",fontStyle:"italic"}},{scope:["punctuation.definition.tag.air"],settings:{foreground:"#2a4a6a"}},{scope:["entity.name.tag.section.air"],settings:{foreground:"#345a94"}},{scope:["entity.name.tag.turn.air"],settings:{foreground:"#3caed5"}},{scope:["entity.name.tag.execute.air"],settings:{foreground:"#00B4D8"}},{scope:["entity.name.tag.stdout.air"],settings:{foreground:"#4c6696"}},{scope:["entity.name.tag.prose.air"],settings:{foreground:"#7cceff"}},{scope:["entity.name.tag.signal.air"],settings:{foreground:"#3caed5"}},{scope:["entity.name.tag.env.air"],settings:{foreground:"#345a94"}},{scope:["entity.name.tag.system.air"],settings:{foreground:"#b43c3c"}},{scope:["entity.name.tag.state.air"],settings:{foreground:"#585858"}},{scope:["entity.other.attribute-name.air"],settings:{foreground:"#4c6696"}},{scope:["string.quoted.double.air"],settings:{foreground:"#326396"}},{scope:["constant.character.entity.air"],settings:{foreground:"#4c6696"}}]}},ui:{cursor:{shape:"line",blink:!0},scrollbar:{thumb:"\u2502",track:"\u2502"}}});
|