@aria-cli/cli 1.0.15 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -0
- package/bin/aria-dev.js +1 -14
- package/bin/aria.js +13 -365
- package/bin/install-owner-lease.js +1 -53
- package/dist/.aria-build-stamp.json +1 -1
- package/dist/cli-context.js +1 -1
- package/dist/commands/index.js +356 -1
- package/dist/config.js +1 -1
- package/dist/ensure-daemon.js +4 -1
- package/dist/history/index.js +321 -1
- package/dist/index.js +503 -1
- package/dist/ink-repl.js +491 -1
- package/dist/local-control-client.js +4 -1
- package/dist/release-notes.d.ts +1 -1
- package/dist/repl-cleanup.js +1 -1
- package/dist/session.js +1 -1
- package/package.json +30 -28
- package/dist/attached-local-control-client-2jz8vmjb.js +0 -1
- package/dist/daemon-service-esj85cr7.js +0 -1
- package/dist/index-00jaxgt2.js +0 -2
- package/dist/index-5v7br509.js +0 -2
- package/dist/index-718zvjhe.js +0 -12
- package/dist/index-76vaj0sr.js +0 -321
- package/dist/index-92syx5hd.js +0 -149
- package/dist/index-9j6r3gr8.js +0 -2
- package/dist/index-g5devafm.js +0 -0
- package/dist/index-j035n0mr.js +0 -2
- package/dist/index-nnqfqvqh.js +0 -2
- package/dist/index-sx36201d.js +0 -5
- package/dist/index-sxga6d5s.js +0 -2
- package/dist/index-wbm34jf5.js +0 -24
- package/dist/index-xjwfqz7t.js +0 -2
- package/dist/index-y2vy5jks.js +0 -4
- package/dist/kernel-0tytvcv0.js +0 -1
- package/dist/runtime-cutover-reset-0nywfrh6.js +0 -1
- package/dist/session-ybzq2j2n.js +0 -1
package/dist/index-92syx5hd.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import{n as mG,o as dG}from"./index-00jaxgt2.js";import{A as iG,p as D3,q as A,r as h3,s as t9,t as oQ,u as nZ,v as cG,w as BG,x as IG,y as MG}from"./index-wbm34jf5.js";import{$ as aG,C as $Q,D as d3,E as p3,F as TG,G as VG,K as DG,L as x,M as hG,N as o,O as EG,P as jG,X as s6,Y as uG,_ as rG}from"./index-76vaj0sr.js";import{ja as pG,ka as xG,la as lG,ma as nG}from"./index-sxga6d5s.js";import{xa as l0,ya as X$}from"./index-nnqfqvqh.js";import{za as i6}from"./index-9j6r3gr8.js";import{useState as E,useCallback as u,useEffect as X1,useRef as F0,useMemo as o6}from"react";import{render as MF,useApp as CF}from"ink";import{useMemo as x_,useState as l_}from"react";import{Box as u_,useStdout as r_}from"ink";import{useState as c3,useCallback as o2,useMemo as m3,useEffect as J2}from"react";import{Box as I2,Static as j_,Text as s2,useApp as c_,useInput as m_}from"ink";import{Box as V5,Text as O0}from"ink";import{toShortName as Bz}from"@aria-cli/models";var T2={colors:{cyan:"cyan",magenta:"magenta",yellow:"yellow",green:"green",blue:"blue",red:"red",white:"white",gray:"gray",dim:"gray"},prompt:{symbol:"❯"},divider:{char:"─"}};function z6($){if(!$||!($ in T2.colors))return T2.colors.white;return T2.colors[$]}function qQ($){return Bz($)}var H8={"opus-4.6":"#B4A0FF","opus-4.5":"#A08AFF","sonnet-4.6":"#5FA8FF","sonnet-4.5":"#4A96FF","haiku-4.5":"#5CE0D0","gemini-3.1-pro":"#FFB84D","gemini-3-pro":"#FFA833","gemini-2.5-pro":"#FF9E22","gemini-3-flash":"#8AE065","gemini-2.5-flash":"#7BD055","gpt-5.4":"#5CD17A","gpt-5.2":"#50C878","gpt-5.1":"#45B86A","gpt-5.3-codex":"#20B2AA","gpt-5.2-codex":"#1CA8A0","gpt-5.1-codex":"#189090"};function DZ($){if(H8[$])return H8[$];let Z=$.replace(/^bedrock-/,"").replace(/^claude-/,"").replace(/-copilot$/,"");if(H8[Z])return H8[Z];let J=Z.split("-");for(let Q=J.length-1;Q>=2;Q--){let X=J.slice(0,Q).join("-");if(H8[X])return H8[X]}return}var HQ={anthropic:{icon:"◆",color:"#B4A0FF"},google:{icon:"▲",color:"#4285F4"},bedrock:{icon:"⬢",color:"#FF9900"},"bedrock-converse":{icon:"⬢",color:"#FF9900"},openai:{icon:"◎",color:"#50C878"},"openai-codex":{icon:"◈",color:"#20B2AA"},"github-copilot":{icon:"⊡",color:"#6E40C9"},local:{icon:"○",color:"gray"}};function WQ($){return HQ[$]??{icon:"○",color:"gray"}}function Iz($){if($.startsWith("bedrock-"))return"bedrock";if($.endsWith("-copilot")){if($.includes("gpt-")&&$.includes("-codex"))return"openai-codex";if($.includes("gemini-"))return"google";return"github-copilot"}if($.startsWith("gemini-"))return"google";if($.includes("-codex"))return"openai-codex";if($.startsWith("gpt-")||$.startsWith("o1")||$.startsWith("o3"))return"openai";if(/^(opus|sonnet|haiku)-/.test($))return"anthropic";return}function NQ($){let Z=Iz($);if(!Z)return;return HQ[Z]}import{jsxDEV as Z0,Fragment as N3}from"react/jsx-dev-runtime";var Mz="balanced";function EZ($){if($<1000)return String($);if($<1e6){let J=$/1000;return J>=100?`${Math.round(J)}k`:`${J.toFixed(1)}k`}let Z=$/1e6;return Z>=100?`${Math.round(Z)}M`:`${Z.toFixed(1)}M`}function E5($){return`$${$.toFixed(2)}`}function Cz($){if($<60)return`${$.toFixed(1)}s`;let Z=Math.floor($/60),J=Math.round($%60);return`${Z}m ${J}s`}function fz($,Z){if(Z<=0)return 0;return Math.min(100,Math.round($/Z*100))}var D5="#B4A0FF",hZ={low:{bars:"▌",color:"blue"},medium:{bars:"▌▌",color:"cyan"},high:{bars:"▌▌▌",color:"yellow"},max:{bars:"▌▌▌▌",color:"magenta"}},Sz={minimal:{symbol:"▸",label:"confirm all",color:"green"},balanced:{symbol:"▸▸",label:"confirm risky",color:"yellow"},high:{symbol:"▸▸▸",label:"auto-approve",color:"magenta"},full:{symbol:"⏵⏵",label:"full bypass",color:"red"}},h5=8,V2=" · ";function j5({arion:$,model:Z,maxContextTokens:J=0,responseTime:Q,metrics:X,showCosts:Y=!0,displayMode:K,activeArion:G,effortLevel:z,autonomyLevel:q=Mz,meshMessageCount:W=0}){let U=z6($.color),F=qQ(Z),O=DZ(F),L=NQ(F),B=K==="debug",S=X&&X.turnCount>0,k=S?X.contextTokens:0,y=J>0?fz(k,J):0,f=Math.min(h5,Math.round(y/100*h5)),M=h5-f,I=S?`${y}%`:"–",R=Sz[q];return Z0(V5,{justifyContent:"space-between",children:[Z0(V5,{children:[Z0(O0,{children:[$.emoji," "]},void 0,!0,void 0,this),Z0(O0,{color:U,bold:!0,children:$.name},void 0,!1,void 0,this),Z0(O0,{dimColor:!0,children:V2},void 0,!1,void 0,this),S?Z0(N3,{children:[L&&Z0(O0,{color:L.color,children:[L.icon," "]},void 0,!0,void 0,this),Z0(O0,{color:O,dimColor:!O,children:F},void 0,!1,void 0,this),z&&Z0(N3,{children:[Z0(O0,{dimColor:!0,children:V2},void 0,!1,void 0,this),Z0(O0,{color:hZ[z].color,children:hZ[z].bars},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z0(O0,{dimColor:!0,children:V2},void 0,!1,void 0,this),Z0(O0,{dimColor:!0,children:["Turn ",X.turnCount]},void 0,!0,void 0,this),Z0(O0,{dimColor:!0,children:V2},void 0,!1,void 0,this),Z0(O0,{color:X.contextStale?void 0:D5,dimColor:X.contextStale,children:[X.contextStale?"~":"",EZ(X.contextTokens)]},void 0,!0,void 0,this),J>0&&Z0(O0,{dimColor:!0,children:["/",EZ(J)]},void 0,!0,void 0,this),B&&Y&&Z0(N3,{children:[Z0(O0,{dimColor:!0,children:V2},void 0,!1,void 0,this),Z0(O0,{dimColor:!0,children:E5(X.estimatedCost)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),B&&Z0(N3,{children:[Z0(O0,{dimColor:!0,children:V2},void 0,!1,void 0,this),Z0(O0,{dimColor:!0,children:Cz(X.wallTimeSeconds)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G&&G!==$.name&&Z0(N3,{children:[Z0(O0,{dimColor:!0,children:V2},void 0,!1,void 0,this),Z0(O0,{dimColor:!0,children:G},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):Z0(N3,{children:[L&&Z0(O0,{color:L.color,children:[L.icon," "]},void 0,!0,void 0,this),Z0(O0,{color:O,dimColor:!O,children:F},void 0,!1,void 0,this),z&&Z0(N3,{children:[Z0(O0,{dimColor:!0,children:V2},void 0,!1,void 0,this),Z0(O0,{color:hZ[z].color,children:hZ[z].bars},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q!==void 0&&Z0(N3,{children:[Z0(O0,{dimColor:!0,children:V2},void 0,!1,void 0,this),Z0(O0,{dimColor:!0,children:[Q.toFixed(1),"s"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Z0(V5,{gap:1,children:[W>0&&Z0(O0,{color:"yellow",bold:!0,children:["msg ",W]},void 0,!0,void 0,this),Z0(O0,{color:R.color,children:[R.symbol," ",R.label]},void 0,!0,void 0,this),Z0(O0,{dimColor:!0,children:"ctx"},void 0,!1,void 0,this),Z0(O0,{color:D5,children:"█".repeat(f)},void 0,!1,void 0,this),Z0(O0,{dimColor:!0,children:"░".repeat(M)},void 0,!1,void 0,this),Z0(O0,{color:D5,children:I},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}import{Box as PQ,Text as c5}from"ink";import{jsxDEV as q6}from"react/jsx-dev-runtime";function m5({userName:$}){if($)return q6(PQ,{children:[q6(c5,{color:T2.colors.cyan,children:$},void 0,!1,void 0,this),q6(c5,{children:[" ",T2.prompt.symbol," "]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);return q6(PQ,{children:q6(c5,{color:T2.colors.cyan,children:[T2.prompt.symbol," "]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{Box as RU,Text as BU}from"ink";import q2,{Chalk as MQ}from"chalk";import CQ from"color-name";import yz from"katex";import{Marked as kz}from"marked";import{markedTerminal as vz}from"marked-terminal";import{highlight as _Q,supportsLanguage as FQ}from"cli-highlight";function d5($,Z){let J=bz(Z);if(!FQ(J)){if(FQ("markdown"))return _Q($,{language:"markdown"});return $}return _Q($,{language:J})}function bz($){let Z={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",sh:"bash",shell:"bash",zsh:"bash",yml:"yaml",py:"python",rb:"ruby",rs:"rust",go:"go",md:"markdown",dockerfile:"docker"},J=$.toLowerCase().trim();return Z[J]??J}import{marked as KU}from"marked";var UQ=["•","◦","▪","▫"];function W1($,Z={}){let J=Fq($),Q=Z.mode==="streaming"?Aq(J):J,{content:X,placeholders:Y}=Tz(Q),K=Dz(Z.colorWordMode),G=new kz;G.use(vz({showSectionPrefix:!1,reflowText:!1,emoji:!1,unescape:!0,width:Z.width??(process.stdout.columns||80),tab:2,hr:()=>q2.dim("─".repeat(Z.width??40))})),G.use({renderer:{text(W){if("tokens"in W&&W.tokens)return this.parser.parseInline(W.tokens);return VQ(W.text,K)},paragraph(W){return this.parser.parseInline(W.tokens)+`
|
|
2
|
-
|
|
3
|
-
`},code(W){let U=A(),F=W.lang||"text";try{return`
|
|
4
|
-
`+d5(W.text,F)+`
|
|
5
|
-
|
|
6
|
-
`}catch{return`
|
|
7
|
-
`+q2.hex(U.colors.info)(W.text)+`
|
|
8
|
-
|
|
9
|
-
`}},codespan(W){let U=A();return q2.hex(U.colors.info)(W.text)},link(W){let U=A(),F=this.parser.parseInline(W.tokens),O=W.href;if(gz())return`\x1B]8;;${O}\x07${q2.hex(U.colors.info).underline(F)}\x1B]8;;\x07`;if(F===O)return q2.hex(U.colors.info).underline(F);return`${q2.hex(U.colors.info).underline(F)} (${q2.dim(O)})`},list(W){let{items:U,ordered:F}=W,O=typeof W.start==="number"?W.start:1,L=this._listDepth??0;return`
|
|
10
|
-
`+U.map((S,k)=>{let y=F?`${O+k}.`:UQ[L%UQ.length],f=" ".repeat(L),M=this._listDepth;this._listDepth=L+1;let I=this.parser.parse(S.tokens).trim();return this._listDepth=M,`${f}${y} ${I}`}).join(`
|
|
11
|
-
`)+`
|
|
12
|
-
|
|
13
|
-
`},blockquote(W){return this.parser.parse(W.tokens).split(`
|
|
14
|
-
`).filter((O)=>O.trim()).map((O)=>q2.dim.italic(`│ ${O}`)).join(`
|
|
15
|
-
`)+`
|
|
16
|
-
|
|
17
|
-
`},table(W){let U=Z.width??(process.stdout.columns||80),F=W.header.length;if(F===0)return`
|
|
18
|
-
`;let O=W.header.map((M)=>this.parser.parseInline(M.tokens)),L=W.rows.map((M)=>M.map((I)=>this.parser.parseInline(I.tokens))),B=Array(F).fill(0),S=Array(F).fill(0);for(let M=0;M<F;M++){let I=[O[M]??"",...L.map((R)=>R[M]??"")];B[M]=F6(O[M]??"");for(let R of I)B[M]=Math.max(B[M],F6(R));S[M]=Mq(I)}let k=F+1+F*2;if(B.reduce((M,I)=>M+I,0)+k>U)Bq(B,U-k,S);let y=(M,I,R)=>M+B.map((j)=>"─".repeat(j+2)).join(I)+R,f=[y("┌","┬","┐")];f.push(...IQ(O,B,W.align)),f.push(y("├","┼","┤"));for(let M=0;M<L.length;M++)if(f.push(...IQ(L[M],B,W.align)),M<L.length-1)f.push(y("├","┼","┤"));return f.push(y("└","┴","┘")),f.join(`
|
|
19
|
-
`)+`
|
|
20
|
-
|
|
21
|
-
`}}});let z=G.parse(X);return hz(z,Y,Vz(Z.mathRenderer),K).replace(/\n{3,}/g,`
|
|
22
|
-
|
|
23
|
-
`).trimEnd()}function gz(){let $=process.env.TERM_PROGRAM??"";return["iTerm.app","WezTerm","Hyper","vscode"].some((J)=>$.includes(J))}function Tz($){let Z=[],J="",Q=0;while(Q<$.length){let X=dz($,Q);if(X){J+=X.segment,Q=X.end;continue}let Y=pz($,Q);if(Y){J+=Y.segment,Q=Y.end;continue}let K=Ez($,Q);if(K){let q=`ARIAMATHTOKEN${Z.length}X`;Z.push({marker:q,original:K.segment,kind:K.kind}),J+=q,Q=K.end;continue}let G=xz($,Q);if(G){let q=`ARIAMATHTOKEN${Z.length}X`;Z.push({marker:q,original:G.segment,kind:"bare_math"}),J+=q,Q=G.end;continue}let z=jZ($,Q);if(z){let q=`ARIAMATHTOKEN${Z.length}X`;Z.push({marker:q,original:z.segment,kind:"latex_command"}),J+=q,Q=z.end;continue}J+=$[Q],Q+=1}return{content:J,placeholders:Z}}function Vz($){if($)return $;let Z=(process.env.ARIA_MARKDOWN_MATH_RENDERER??"").trim().toLowerCase();if(Z==="katex"||Z==="fast")return Z;return"fast"}function Dz($){if($)return $;let Z=(process.env.ARIA_MARKDOWN_COLOR_WORD_MODE??"").trim().toLowerCase();if(Z==="always"||Z==="never"||Z==="auto")return Z;return"auto"}function hz($,Z,J,Q){let X=A(),Y=$;for(let K of Z){let G=uz(K,J),z=G.style?q2.hex(X.colors.info)(G.text):G.text;z=VQ(z,Q),Y=Y.split(K.marker).join(z)}return Y}function Ez($,Z){if($[Z]!=="$"||W8($,Z))return null;if($[Z+1]==="$"&&!W8($,Z+1)){let X=cz($,"$$",Z+2);if(X===-1)return null;if(!$.slice(Z+2,X).trim())return null;return{segment:$.slice(Z,X+2),end:X+2,kind:"display_math"}}let J=jz($,Z+1);if(J===-1)return null;let Q=$.slice(Z+1,J);if(!mz(Q))return null;return{segment:$.slice(Z,J+1),end:J+1,kind:"inline_math"}}function jz($,Z){for(let J=Z;J<$.length;J+=1){let Q=$[J];if(Q===`
|
|
24
|
-
`)return-1;if(Q==="$"&&!W8($,J))return J}return-1}function cz($,Z,J){let Q=$.indexOf(Z,J);while(Q!==-1){if(!W8($,Q))return Q;Q=$.indexOf(Z,Q+Z.length)}return-1}function W8($,Z){let J=0;for(let Q=Z-1;Q>=0&&$[Q]==="\\";Q-=1)J+=1;return J%2===1}function mz($){let Z=$.trim();if(!Z)return!1;if(/\\/.test(Z))return!0;if(/[{}^_=<>+\-*/]/.test(Z))return!0;return!/\s/.test(Z)}function dz($,Z){if(!Uq($,Z))return null;let Q=$.slice(Z).match(/^(```+|~~~+)[^\n]*\n/);if(!Q)return null;let X=Q[1],Y=Z+Q[0].length;while(Y<$.length){let K=$.indexOf(`
|
|
25
|
-
`,Y),G=K===-1?$.length:K;if($.slice(Y,G).trim().startsWith(X)){let q=K===-1?$.length:K+1;return{segment:$.slice(Z,q),end:q}}if(K===-1)break;Y=K+1}return{segment:$.slice(Z),end:$.length}}function pz($,Z){if($[Z]!=="`")return null;let J=1;while($[Z+J]==="`")J+=1;let Q="`".repeat(J),X=$.indexOf(Q,Z+J);if(X===-1)return null;return{segment:$.slice(Z,X+J),end:X+J}}function jZ($,Z){if($[Z]!=="\\")return null;let J=$[Z+1];if(!J)return null;if(/[A-Za-z]/.test(J)){let Q=Z+2;while(Q<$.length&&/[A-Za-z]/.test($[Q]))Q+=1;return{segment:$.slice(Z,Q),end:Q}}if(/[,:;!{}%$#&_ ]/.test(J))return{segment:$.slice(Z,Z+2),end:Z+2};return null}function xz($,Z){if($[Z]!=="\\")return null;let J=jZ($,Z);if(!J)return null;let Q=J.segment.slice(1);if(!lz(Q))return null;let X=J.end;while(X<$.length){let K=$[X];if(K===`
|
|
26
|
-
`||K==="$")break;if(K==="\\"){let G=jZ($,X);if(!G)break;X=G.end;continue}if(/[A-Za-z0-9^_{}()[\]+\-*/=.,:; ]/.test(K)){X+=1;continue}break}let Y=$.slice(Z,X).trimEnd();if(Y.length<=J.segment.length)return null;return{segment:Y,end:Z+Y.length}}function lz($){if(!$)return!1;if(P6[$])return!0;if(u5.has($))return!0;return["frac","binom","sqrt","left","right","text"].includes($)}var P6={alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",varepsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",vartheta:"ϑ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",pi:"π",varpi:"ϖ",rho:"ρ",varrho:"ϱ",sigma:"σ",varsigma:"ς",tau:"τ",upsilon:"υ",phi:"ϕ",varphi:"φ",chi:"χ",psi:"ψ",omega:"ω",Gamma:"Γ",Delta:"Δ",Theta:"Θ",Lambda:"Λ",Xi:"Ξ",Pi:"Π",Sigma:"Σ",Upsilon:"Υ",Phi:"Φ",Psi:"Ψ",Omega:"Ω",int:"∫",sum:"∑",prod:"∏",infty:"∞",partial:"∂",nabla:"∇",times:"×",cdot:"·",pm:"±",mp:"∓",leq:"≤",geq:"≥",neq:"≠",approx:"≈",sim:"∼",to:"→",leftarrow:"←",rightarrow:"→",leftrightarrow:"↔",mapsto:"↦",in:"∈",notin:"∉",subset:"⊂",subseteq:"⊆",supset:"⊃",supseteq:"⊇",cup:"∪",cap:"∩",forall:"∀",exists:"∃",neg:"¬",lnot:"¬",land:"∧",lor:"∨"},u5=new Set(["sin","cos","tan","cot","sec","csc","log","ln","exp","max","min","lim"]),fQ={"0":"⁰","1":"¹","2":"²","3":"³","4":"⁴","5":"⁵","6":"⁶","7":"⁷","8":"⁸","9":"⁹","+":"⁺","-":"⁻","=":"⁼","(":"⁽",")":"⁾",n:"ⁿ",i:"ⁱ",a:"ᵃ",b:"ᵇ",c:"ᶜ",d:"ᵈ",e:"ᵉ",f:"ᶠ",g:"ᵍ",h:"ʰ",j:"ʲ",k:"ᵏ",l:"ˡ",m:"ᵐ",o:"ᵒ",p:"ᵖ",r:"ʳ",s:"ˢ",t:"ᵗ",u:"ᵘ",v:"ᵛ",w:"ʷ",x:"ˣ",y:"ʸ",z:"ᶻ"},SQ={"0":"₀","1":"₁","2":"₂","3":"₃","4":"₄","5":"₅","6":"₆","7":"₇","8":"₈","9":"₉","+":"₊","-":"₋","=":"₌","(":"₍",")":"₎",a:"ₐ",e:"ₑ",h:"ₕ",i:"ᵢ",j:"ⱼ",k:"ₖ",l:"ₗ",m:"ₘ",n:"ₙ",o:"ₒ",p:"ₚ",r:"ᵣ",s:"ₛ",t:"ₜ",u:"ᵤ",v:"ᵥ",x:"ₓ"};function uz($,Z){if(Z==="katex"){let X=$.kind==="display_math",Y=$.kind==="inline_math"?$.original.slice(1,-1):$.kind==="display_math"?$.original.slice(2,-2):$.original,K=nz(Y,X);if(K)return{text:K,style:!0}}if($.kind==="inline_math"){let X=$.original.slice(1,-1);return{text:C1(X),style:!0}}if($.kind==="display_math"){let X=$.original.slice(2,-2);return{text:Zq(X),style:!0}}if($.kind==="bare_math")return{text:C1($.original),style:!0};let J=Jq($.original),Q=J!==$.original;return{text:J,style:Q}}var AQ=new Map,rz=new Set(["math","semantics","mrow","mstyle"]),az={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",ThinSpace:" ",NegativeThinSpace:"",MediumSpace:" ",ApplyFunction:"",InvisibleTimes:"·",InvisibleComma:","};function nz($,Z){let J=$.trim();if(!J)return"";let Q=`${Z?"display":"inline"}:${J}`,X=AQ.get(Q);if(X!==void 0)return X;try{let Y=yz.renderToString(J,{displayMode:Z,throwOnError:!1,strict:"ignore",output:"mathml"}),K=iz(Y,Z);if(K!=null&&K.trim().length>0){let G=K.trimEnd();return AQ.set(Q,G),G}}catch{}return null}function iz($,Z){let J=$.match(/<math[\s\S]*<\/math>/i);if(!J)return null;let Q=J[0].replace(/<annotation[\s\S]*?<\/annotation>/gi,""),X=oz(Q);if(!X)return null;if(Z){let Y=tz(X);if(Y?.name==="mfrac"){let K=H2(Y),G=K[0]?M1(K[0],!1).trim():"",z=K[1]?M1(K[1],!1).trim():"";return kQ(G,z)}}return M1(X,Z)}function oz($){let Z={name:"__root__",attrs:{},children:[]},J=[Z],Q=/<!--[\s\S]*?-->|<[^>]+>|[^<]+/g,X;while((X=Q.exec($))!==null){let K=X[0];if(!K)continue;if(K.startsWith("<!--")||K.startsWith("<?"))continue;if(K.startsWith("</")){if(J.length>1)J.pop();continue}if(K.startsWith("<")){let W=K.endsWith("/>"),U=K.slice(1,K.length-(W?2:1)).trim();if(!U)continue;let F=U.match(/^([^\s/>]+)/);if(!F)continue;let O=F[1];if(!O)continue;let L=O.replace(/^.*:/,"").toLowerCase(),B=sz(U.slice(O.length)),S={name:L,attrs:B,children:[]},k=J[J.length-1];if(k)k.children.push(S);if(!W)J.push(S);continue}let G=bQ(K),z=yQ(G);if(!z)continue;let q=J[J.length-1];if(q)q.children.push(z)}return H2(Z).find((K)=>K.name==="math")??null}function sz($){let Z={},J=/([A-Za-z_:][A-Za-z0-9:._-]*)\s*=\s*("([^"]*)"|'([^']*)')/g,Q;while((Q=J.exec($))!==null){let X=Q[1];if(!X)continue;let Y=Q[3]??Q[4]??"",K=X.replace(/^.*:/,"").toLowerCase();Z[K]=bQ(Y)}return Z}function bQ($){return $.replace(/&#x([0-9a-fA-F]+);/g,(Z,J)=>{let Q=Number.parseInt(J,16);return Number.isFinite(Q)?String.fromCodePoint(Q):""}).replace(/&#([0-9]+);/g,(Z,J)=>{let Q=Number.parseInt(J,10);return Number.isFinite(Q)?String.fromCodePoint(Q):""}).replace(/&([A-Za-z][A-Za-z0-9]+);/g,(Z,J)=>az[J]??J)}function yQ($){return $.replace(/[\u200b\u2061\u2062\u2063\u2064]/g,"").replace(/\s+/g," ").trim()}function tz($){let Z=$;while(rz.has(Z.name)){let J=H2(Z);if(J.length!==1)break;Z=J[0]}return Z}function H2($){return $.children.filter((Z)=>typeof Z!=="string")}function p5($){let Z="";for(let J of $.children)if(typeof J==="string")Z+=J;else Z+=p5(J);return yQ(Z)}function M1($,Z){switch($.name){case"math":case"semantics":case"mrow":case"mstyle":case"mpadded":case"mphantom":case"none":return H6($,Z);case"mi":case"mn":case"mtext":return p5($);case"mo":{let J=p5($);return ez(J)}case"mspace":return" ";case"mfrac":{let J=H2($),Q=J[0]?M1(J[0],!1).trim():"",X=J[1]?M1(J[1],!1).trim():"";return`${Q}⁄${X}`.trim()}case"msup":{let J=H2($),Q=J[0]?M1(J[0],!1):"",X=J[1]?M1(J[1],!1):"";return`${Q}${OQ(X)}`}case"msub":{let J=H2($),Q=J[0]?M1(J[0],!1):"",X=J[1]?M1(J[1],!1):"";return`${Q}${wQ(X)}`}case"msubsup":{let J=H2($),Q=J[0]?M1(J[0],!1):"",X=J[1]?M1(J[1],!1):"",Y=J[2]?M1(J[2],!1):"";return`${Q}${wQ(X)}${OQ(Y)}`}case"msqrt":{let J=H6($,!1);return J?`√(${J})`:"√"}case"mroot":{let J=H2($),Q=J[0]?M1(J[0],!1):"",X=J[1]?M1(J[1],!1):"";return X?`${X}√(${Q})`:`√(${Q})`}case"mfenced":{let J=$.attrs.open??"(",Q=$.attrs.close??")",X=H6($,!1);return`${J}${X}${Q}`}case"mtable":{let Q=H2($).filter((X)=>X.name==="mtr").map((X)=>M1(X,Z).trim()).filter((X)=>X.length>0);if(Q.length===0)return"";if(Z)return Q.join(`
|
|
27
|
-
`);return`[${Q.join("; ")}]`}case"mtr":return H2($).filter((Q)=>Q.name==="mtd").map((Q)=>M1(Q,Z).trim()).filter((Q)=>Q.length>0).join(" ");case"mtd":return H6($,Z);case"annotation":return"";default:return H6($,Z)}}function H6($,Z){let J=$.children.map((Q)=>{if(typeof Q==="string")return Q;return M1(Q,Z)});return $q(J.join(""))}function ez($){if(!$)return"";if($==="−")return"-";return $}function $q($){return $.replace(/[\u200b\u2061\u2062\u2063\u2064]/g,"").replace(/([∫∑∏])([A-Za-z0-9α-ωΑ-Ω])/g,"$1 $2").replace(/([\u00B2\u00B3\u00B9\u2070-\u209F])([A-Za-zα-ωΑ-Ω])/g,"$1 $2").replace(/([)\]])([A-Za-zα-ωΑ-Ω])/g,"$1 $2").replace(/\s*([+\-−=≈≠≤≥<>×÷·∪∩])\s*/g," $1 ").replace(/\s*,\s*/g,", ").replace(/\s*;\s*/g,"; ").replace(/\s*:\s*/g,": ").replace(/\(\s+/g,"(").replace(/\s+\)/g,")").replace(/\s+/g," ").trim()}function OQ($){let Z=$.replace(/\s+/g,"");if(!Z)return"";return cZ(`{${Z}}`,fQ,"^")}function wQ($){let Z=$.replace(/\s+/g,"");if(!Z)return"";return cZ(`{${Z}}`,SQ,"_")}function Zq($){let Z=$.trim();if(!Z)return"";let J=qq(Z,"frac");if(J){let Q=C1(J.arg1).trim(),X=C1(J.arg2).trim();return kQ(Q,X)}return Z.split(`
|
|
28
|
-
`).map((Q)=>C1(Q)).join(`
|
|
29
|
-
`)}function C1($){let Z=$.trim();return Z=Qq(Z),Z=Z.replace(/\\left\s*/g,"").replace(/\\right\s*/g,""),Z=W6(Z,"text",(J)=>C1(J)),Z=W6(Z,"sqrt",(J)=>`√(${C1(J)})`),Z=W6(Z,"mathrm",(J)=>C1(J)),Z=W6(Z,"mathbf",(J)=>C1(J)),Z=W6(Z,"mathit",(J)=>C1(J)),Z=N6(Z,"textcolor",(J,Q)=>{return BQ(J,C1(Q))}),Z=N6(Z,"color",(J,Q)=>{return BQ(J,C1(Q))}),Z=N6(Z,"colorbox",(J,Q)=>{return _q(J,C1(Q))}),Z=N6(Z,"frac",(J,Q)=>{return`${C1(J)}⁄${C1(Q)}`}),Z=N6(Z,"binom",(J,Q)=>{return`C(${C1(J)}, ${C1(Q)})`}),Z=Xq(Z),Z=Yq(Z),Z=Kq(Z),Z=Gq(Z),Z=Z.replace(/\s{2,}/g," ").trim(),Z}function Jq($){if(!$.startsWith("\\"))return $;let Z=$.slice(1);if($==="\\,")return" ";if($==="\\;")return" ";if($==="\\:")return" ";if($==="\\!")return"";if($==="\\ ")return" ";if($==="\\{")return"{";if($==="\\}")return"}";if($==="\\%")return"%";if($==="\\$")return"$";if($==="\\#")return"#";if($==="\\_")return"_";if($==="\\&")return"&";if(P6[Z])return P6[Z];if(u5.has(Z))return Z;return $}function Qq($){return $.replace(/\\,/g," ").replace(/\\;/g," ").replace(/\\:/g," ").replace(/\\!/g,"").replace(/\\qquad/g," ").replace(/\\quad/g," ").replace(/~+/g," ").replace(/\\ /g," ")}function Xq($){let Z=$,J=Object.keys(P6).sort((Q,X)=>X.length-Q.length);for(let Q of J){let X=P6[Q],Y=new RegExp(`\\\\${RQ(Q)}\\b`,"g");Z=Z.replace(Y,X)}for(let Q of u5){let X=new RegExp(`\\\\${RQ(Q)}\\b`,"g");Z=Z.replace(X,Q)}return Z}function Yq($){return $.replace(/\\([{}%$#&_])/g,"$1")}function Kq($){return $.replace(/\\\{/g,"__ARIA_ESCAPED_LBRACE__").replace(/\\\}/g,"__ARIA_ESCAPED_RBRACE__").replace(/[{}]/g,"").replaceAll("__ARIA_ESCAPED_LBRACE__","{").replaceAll("__ARIA_ESCAPED_RBRACE__","}")}function Gq($){let Z=$;return Z=Z.replace(/([A-Za-z0-9α-ωΑ-Ω)\]])\^(\{[^{}]*\}|.)/g,(J,Q,X)=>{return`${Q}${cZ(X,fQ,"^")}`}),Z=Z.replace(/([A-Za-z0-9α-ωΑ-Ω)\]])_(\{[^{}]*\}|.)/g,(J,Q,X)=>{return`${Q}${cZ(X,SQ,"_")}`}),Z}function cZ($,Z,J){let Q=zq($);if(!Q)return"";let X="";for(let Y of Q){let K=Z[Y];if(!K)return`${J}(${Q})`;X+=K}return X}function zq($){if($.startsWith("{")&&$.endsWith("}"))return $.slice(1,-1);return $}function W6($,Z,J){let Q="",X=0,Y=`\\${Z}`;while(X<$.length){if(r5($,Y,X)){let K=_6($,X+Y.length);if(K){Q+=J(K.value),X=K.end;continue}}Q+=$[X],X+=1}return Q}function N6($,Z,J){let Q="",X=0,Y=`\\${Z}`;while(X<$.length){if(r5($,Y,X)){let K=_6($,X+Y.length);if(K){let G=_6($,K.end);if(G){Q+=J(K.value,G.value),X=G.end;continue}}}Q+=$[X],X+=1}return Q}function qq($,Z){let J=`\\${Z}`,Q=x5($,0);if(!r5($,J,Q))return null;let X=_6($,Q+J.length);if(!X)return null;let Y=_6($,X.end);if(!Y)return null;if(x5($,Y.end)!==$.length)return null;return{arg1:X.value,arg2:Y.value}}function _6($,Z){let J=x5($,Z);if(J>=$.length)return null;if($[J]==="{"){let Q=Hq($,J);if(Q===-1)return null;return{value:$.slice(J+1,Q),end:Q+1}}if($[J]==="\\"){let Q=jZ($,J);if(Q)return{value:Q.segment,end:Q.end}}return{value:$[J],end:J+1}}function r5($,Z,J){if(!$.startsWith(Z,J))return!1;let Q=$[J+Z.length];return!Q||!/[A-Za-z]/.test(Q)}function x5($,Z){let J=Z;while(J<$.length&&/\s/.test($[J]))J+=1;return J}function Hq($,Z){let J=0;for(let Q=Z;Q<$.length;Q+=1){let X=$[Q];if(X==="{"&&!W8($,Q))J+=1;if(X==="}"&&!W8($,Q)){if(J-=1,J===0)return Q}}return-1}function kQ($,Z){let J=Math.max(l5($),l5(Z),1),Q="─".repeat(J),X=LQ($,J),Y=LQ(Z,J);return`${X}
|
|
30
|
-
${Q}
|
|
31
|
-
${Y}`}function l5($){return Array.from($).length}function LQ($,Z){let J=l5($);if(J>=Z)return $;let Q=Math.floor((Z-J)/2),X=Z-J-Q;return`${" ".repeat(Q)}${$}${" ".repeat(X)}`}function RQ($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vQ($){let Z={},J=CQ;for(let[Q,X]of Object.entries(J)){let Y=Q.toLowerCase(),[K,G,z]=X;if(K===0&&G===0&&z===0){Z[Y]=(q)=>$.blackBright(q);continue}Z[Y]=(q)=>$.rgb(K,G,z)(q)}if(Z.gray&&!Z.grey)Z.grey=Z.gray;if(Z.grey&&!Z.gray)Z.gray=Z.grey;return Z}var gQ=vQ(q2),TQ=vQ(new MQ({level:3})),Wq=Object.keys(gQ).sort(($,Z)=>Z.length-$.length),Nq=new RegExp(`\\b(${Wq.join("|")})\\b`,"gi"),Pq=new MQ({level:3});function BQ($,Z){let J=$.trim().toLowerCase(),Q=TQ[J];if(Q)return Q(Z);return Z}function _q($,Z){let J=$.trim().toLowerCase(),X=CQ[J];if(X){let[Y,K,G]=X;return Pq.bgRgb(Y,K,G)(Z)}return Z}function VQ($,Z="auto"){if(Z==="never")return $;let J=Z==="always"?TQ:gQ;return $.replace(Nq,(Q)=>{let X=J[Q.toLowerCase()];return X?X(Q):Q})}function Fq($){let Z=$.split(`
|
|
32
|
-
`);return Z.map((J,Q)=>{let X=J.match(/^(\d+)\.\s+(.+)$/);if(!X)return J;let Y=Q===0||!Z[Q-1].trim(),K=Q===Z.length-1||!Z[Q+1].trim();if(!Y||!K)return J;return`${X[1]}\\. ${X[2]}`}).join(`
|
|
33
|
-
`)}function Uq($,Z){return Z===0||$[Z-1]===`
|
|
34
|
-
`}function Aq($){let Z=$.split(`
|
|
35
|
-
`),J=[];for(let Q=0;Q<Z.length;Q+=1){let X=Z[Q]??"",Y=Z[Q+1]??"";if(Oq(X)&&wq(Y)){let K=Q;while(K<Z.length&&Lq(Z[K]??""))J.push(Rq(Z[K])),K+=1;Q=K-1;continue}J.push(X)}return J.join(`
|
|
36
|
-
`)}function Oq($){let Z=$.trim();if(!Z.includes("|"))return!1;if(/^[-:|\s]+$/.test(Z))return!1;let J=DQ(Z);return J.length>=2&&J.some((Q)=>Q.length>0)}function wq($){let Z=DQ($.trim());return Z.length>=2&&Z.every((J)=>/^:?-{3,}:?$/.test(J))}function Lq($){let Z=$.trim();return Z.length>0&&Z.includes("|")}function DQ($){let Z=$.trim();if(Z.startsWith("|"))Z=Z.slice(1);if(Z.endsWith("|"))Z=Z.slice(0,-1);return Z.split("|").map((J)=>J.trim())}function Rq($){return $.replace(/\|/g,"\\|")}var hQ=/\x1b\[[0-9;]*m|\x1b\]8;;[^\x07]*\x07/g;function EQ($){return $.replace(hQ,"")}function F6($){return EQ($).length}function Bq($,Z,J){let X=$.reduce((q,W)=>q+W,0);if(X<=Z)return;let Y=Iq(J,Z,3),K=Z,G=K/X;for(let q=0;q<$.length;q++)$[q]=Math.max(Y[q]??3,Math.floor($[q]*G));let z=$.reduce((q,W)=>q+W,0);while(z>K){let q=0;for(let W=1;W<$.length;W++)if($[W]>$[q])q=W;if($[q]<=(Y[q]??3))break;$[q]--,z--}while(z>K){let q=0;for(let W=1;W<$.length;W++)if($[W]>$[q])q=W;if($[q]<=3)break;$[q]--,z--}}function Iq($,Z,J){let Q=$.map((Y)=>Math.max(Y,J)),X=Q.reduce((Y,K)=>Y+K,0);while(X>Z){let Y=-1;for(let K=0;K<Q.length;K++){if(Q[K]<=J)continue;if(Y===-1||Q[K]>Q[Y])Y=K}if(Y===-1)break;Q[Y]--,X--}return Q}function Mq($){let Q=3,X=3;for(let Y of $){let K=cQ(Y);Q=Math.max(Q,F6(K)),X=Math.max(X,Cq(K))}return Math.min(Math.max(3,X),24)}function Cq($){return EQ($).split(/\s+/).reduce((Z,J)=>Math.max(Z,J.length),0)}function jQ($,Z){let J=cQ($);if(Z<=0||!J)return[J||""];if(J.includes(`
|
|
37
|
-
`)){let U=[];for(let F of J.split(`
|
|
38
|
-
`))U.push(...jQ(F,Z));return U}if(F6(J)<=Z)return[J];let Q=[],X=0,Y=new RegExp(hQ.source,"g"),K;while((K=Y.exec(J))!==null){if(K.index>X)Q.push({ansi:!1,value:J.slice(X,K.index)});Q.push({ansi:!0,value:K[0]}),X=Y.lastIndex}if(X<J.length)Q.push({ansi:!1,value:J.slice(X)});let G=[],z="",q=0,W=(U)=>{for(let F=0;F<U.length;F+=Z){if(z&&q>0)G.push(z);z=U.slice(F,F+Z),q=z.length}};for(let U of Q){if(U.ansi){z+=U.value;continue}let F=U.value.split(/(\s+)/);for(let O of F){if(!O)continue;let L=O.length,B=!O.trim();if(B&&q===0)continue;if(q+L<=Z)z+=O,q+=L;else if(q===0)W(O);else if(B)G.push(z),z="",q=0;else if(G.push(z),z="",q=0,L>Z)W(O);else z=O,q=L}}if(z||G.length===0)G.push(z);return G}function cQ($){return $.replace(/\s*\n+\s*/g," ").replace(/\(\s+/g,"(").replace(/\s+\)/g,")").replace(/\[\s+/g,"[").replace(/\s+\]/g,"]").replace(/[ \t]{2,}/g," ").trim()}function fq($,Z,J){let Q=F6($);if(Q>=Z)return $;let X=Z-Q;if(J==="right")return" ".repeat(X)+$;if(J==="center"){let Y=Math.floor(X/2);return" ".repeat(Y)+$+" ".repeat(X-Y)}return $+" ".repeat(X)}function IQ($,Z,J){let Q=$.map((K,G)=>jQ(K,Z[G])),X=Math.max(...Q.map((K)=>K.length),1),Y=[];for(let K=0;K<X;K++){let G=Q.map((z,q)=>fq(z[K]??"",Z[q],J[q]??null));Y.push("│ "+G.join(" │ ")+" │")}return Y}import{jsxDEV as SU}from"react/jsx-dev-runtime";import{useCallback as uZ,useEffect as nQ,useRef as rZ,useState as P3}from"react";import{Box as A6,Text as aZ}from"ink";import{useEffect as vq,useRef as t5,useState as gq}from"react";import{Text as Tq,useInput as Vq}from"ink";import P8 from"chalk";import{useState as yq}from"react";import{useRef as mQ}from"react";var dQ=2000;function U6($,Z,J){let Q=mQ(0),X=mQ(void 0);return()=>{let Y=Date.now();if(Y-Q.current<=dQ&&X.current){if(X.current)clearTimeout(X.current),X.current=void 0;Z(),$(!1)}else J?.(),$(!0),X.current=setTimeout(()=>$(!1),dQ);Q.current=Y}}import Sq from"string-width";class S1{measuredText;selection;offset;constructor($,Z=0,J=0){this.measuredText=$;this.selection=J;this.offset=Math.max(0,Math.min(this.measuredText.text.length,Z))}static fromText($,Z,J=0,Q=0){return new S1(new a5($,Z-1),J,Q)}render($,Z,J){let{line:Q,column:X}=this.getPosition();return this.measuredText.getWrappedText().map((Y,K,G)=>{let z=Y;if(Z&&K===G.length-1){let q=Math.max(0,Y.length-6);z=Z.repeat(q)+Y.slice(q)}if(Q!=K)return z.trimEnd();return z.slice(0,X)+J(z[X]||$)+z.trimEnd().slice(X+1)}).join(`
|
|
39
|
-
`)}left(){return new S1(this.measuredText,this.offset-1)}right(){return new S1(this.measuredText,this.offset+1)}up(){let{line:$,column:Z}=this.getPosition();if($==0)return new S1(this.measuredText,0,0);let J=this.getOffset({line:$-1,column:Z});return new S1(this.measuredText,J,0)}down(){let{line:$,column:Z}=this.getPosition();if($>=this.measuredText.lineCount-1)return new S1(this.measuredText,this.text.length,0);let J=this.getOffset({line:$+1,column:Z});return new S1(this.measuredText,J,0)}startOfLine(){let{line:$}=this.getPosition();return new S1(this.measuredText,this.getOffset({line:$,column:0}),0)}endOfLine(){let{line:$}=this.getPosition(),Z=this.measuredText.getLineLength($),J=this.getOffset({line:$,column:Z});return new S1(this.measuredText,J,0)}nextWord(){let $=this;while($.isOverWordChar()&&!$.isAtEnd())$=$.right();while(!$.isOverWordChar()&&!$.isAtEnd())$=$.right();return $}prevWord(){let $=this;if(!$.left().isOverWordChar())$=$.left();while(!$.isOverWordChar()&&!$.isAtStart())$=$.left();if($.isOverWordChar())while($.left().isOverWordChar()&&!$.isAtStart())$=$.left();return $}modifyText($,Z=""){let J=this.offset,Q=$.offset,X=this.text.slice(0,J)+Z+this.text.slice(Q);return S1.fromText(X,this.columns,J+Z.length)}insert($){return this.modifyText(this,$)}del(){if(this.isAtEnd())return this;return this.modifyText(this.right())}backspace(){if(this.isAtStart())return this;let $=this.offset,J=this.left().offset,Q=this.text.slice(0,J)+this.text.slice($);return S1.fromText(Q,this.columns,J)}deleteToLineStart(){return this.startOfLine().modifyText(this)}deleteToLineEnd(){if(this.text[this.offset]===`
|
|
40
|
-
`)return this.modifyText(this.right());return this.modifyText(this.endOfLine())}deleteWordBefore(){if(this.isAtStart())return this;return this.prevWord().modifyText(this)}deleteWordAfter(){if(this.isAtEnd())return this;return this.modifyText(this.nextWord())}isOverWordChar(){let $=this.text[this.offset]??"";return/\w/.test($)}equals($){return this.offset===$.offset&&this.measuredText==$.measuredText}isAtStart(){return this.offset==0}isAtEnd(){return this.offset==this.text.length}get text(){return this.measuredText.text}get columns(){return this.measuredText.columns+1}getPosition(){return this.measuredText.getPositionFromOffset(this.offset)}getOffset($){return this.measuredText.getOffsetFromPosition($)}}class N8{text;startOffset;isPrecededByNewline;endsWithNewline;constructor($,Z,J,Q=!1){this.text=$;this.startOffset=Z;this.isPrecededByNewline=J;this.endsWithNewline=Q}equals($){return this.text===$.text&&this.startOffset===$.startOffset}get length(){return this.text.length+(this.endsWithNewline?1:0)}}class a5{text;columns;wrappedLines;constructor($,Z){this.text=$;this.columns=Z;this.wrappedLines=this.measureWrappedText()}measureWrappedText(){if(this.text.length===0)return[new N8("",0,!0,!1)];let $=[],Z=0;while(Z<this.text.length){let J=Z,Q=Z===0||this.text[Z-1]===`
|
|
41
|
-
`,X=0,Y=Z,K=-1;while(Y<this.text.length){let G=this.text[Y];if(G===`
|
|
42
|
-
`){$.push(new N8(this.text.slice(J,Y),J,Q,!0)),Z=Y+1;break}let z=this.text.codePointAt(Y),q=String.fromCodePoint(z),W=Sq(q);if(X+W>this.columns){let U;if(K>=J&&K+1<Y)U=K+1;else if(Y>J)U=Y;else U=Y+q.length;$.push(new N8(this.text.slice(J,U),J,Q,!1)),Z=U;break}if(G===" "||G==="\t")K=Y;X+=W,Y+=q.length}if(Y>=this.text.length&&Z===J)$.push(new N8(this.text.slice(J),J,Q,!1)),Z=this.text.length}if(this.text.length>0&&this.text[this.text.length-1]===`
|
|
43
|
-
`)$.push(new N8("",this.text.length,!0,!1));return $}getWrappedText(){return this.wrappedLines.map(($)=>$.isPrecededByNewline?$.text:$.text.trimStart())}getLine($){return this.wrappedLines[Math.max(0,Math.min($,this.wrappedLines.length-1))]}getOffsetFromPosition($){let Z=this.getLine($.line),J=Z.startOffset+$.column;if(Z.text.length===0&&Z.endsWithNewline)return Z.startOffset;let Q=Z.startOffset+Z.text.length,X=Z.endsWithNewline?Q+1:Q;return Math.min(J,X)}getLineLength($){let Z=this.getLine($),J=this.getLine($+1);if(J.equals(Z))return this.text.length-Z.startOffset;return J.startOffset-Z.startOffset-1}getPositionFromOffset($){let Z=this.wrappedLines;for(let Q=0;Q<Z.length;Q++){let X=Z[Q],Y=Z[Q+1];if($>=X.startOffset&&(!Y||$<Y.startOffset)){let K=X.isPrecededByNewline?0:X.text.length-X.text.trimStart().length,G=Math.max(0,Math.min($-X.startOffset-K,X.text.length));return{line:Q,column:G}}}let J=Z.length-1;return{line:J,column:this.wrappedLines[J].text.length}}get lineCount(){return this.wrappedLines.length}equals($){return this.text===$.text&&this.columns===$.columns}}import{execSync as n5}from"child_process";import{readFileSync as bq}from"fs";var i5="/tmp/claude_cli_latest_screenshot.png",pQ="No image found in clipboard. Use Cmd + Ctrl + Shift + 4 to copy a screenshot to clipboard.";function o5(){if(process.platform!=="darwin")return null;try{n5("osascript -e 'the clipboard as «class PNGf»'",{stdio:"ignore"}),n5(`osascript -e 'set png_data to (the clipboard as «class PNGf»)' -e 'set fp to open for access POSIX file "${i5}" with write permission' -e 'write png_data to fp' -e 'close access fp'`,{stdio:"ignore"});let Z=bq(i5).toString("base64");return n5(`rm -f "${i5}"`,{stdio:"ignore"}),Z}catch{return null}}function e($,Z){return Z.escape||$==="\x1B"}var kq="[Image pasted]";function xQ($){return function(Z){return(new Map($).get(Z)??(()=>{}))(Z)}}function s5({value:$,onChange:Z,onSubmit:J,onExit:Q,onExitMessage:X,onMessage:Y,onHistoryUp:K,onHistoryDown:G,onHistoryReset:z,onDoubleEscape:q,mask:W="",multiline:U=!1,cursorChar:F,invert:O,columns:L,onImagePaste:B,disableCursorMovementForUpDownKeys:S=!1,externalOffset:k,onOffsetChange:y}){let f=k,M=y,I=S1.fromText($,L,f),[R,j]=yq(null);function Q0(){if(!R)return;clearTimeout(R),j(null),Y?.(!1)}let w1=U6((i)=>{Q0(),X?.(i,"Ctrl-C")},()=>Q?.(),()=>{if($)Z(""),z?.()}),P1=U6((i)=>{Q0(),Y?.(!!$&&i,"Press Escape again to clear")},()=>{if(q?.())return;if($)Z("")});function H0(){return S1.fromText("",L,0)}let o1=U6((i)=>X?.(i,"Ctrl-D"),()=>Q?.());function L1(){if(Q0(),I.text==="")return o1(),I;return I.del()}function s1(){let i=o5();if(i===null){if(process.platform!=="darwin")return I;return Y?.(!0,pQ),Q0(),j(setTimeout(()=>{Y?.(!1)},4000)),I}return B?.(i),I.insert(kq)}let D1=xQ([["a",()=>I.startOfLine()],["b",()=>I.left()],["c",w1],["d",L1],["e",()=>I.endOfLine()],["f",()=>I.right()],["h",()=>{return Q0(),I.backspace()}],["k",()=>I.deleteToLineEnd()],["l",()=>H0()],["n",()=>t1()],["p",()=>z1()],["u",()=>I.deleteToLineStart()],["v",s1],["w",()=>I.deleteWordBefore()]]),R1=xQ([["b",()=>I.prevWord()],["f",()=>I.nextWord()],["d",()=>I.deleteWordAfter()]]);function L0(i){if(U&&I.offset>0&&I.text[I.offset-1]==="\\")return I.backspace().insert(`
|
|
44
|
-
`);if(i.meta||i.shift)return I.insert(`
|
|
45
|
-
`);J?.($)}function z1(){if(S)return K?.(),I;let i=I.up();if(i.equals(I))K?.();return i}function t1(){if(S)return G?.(),I;let i=I.down();if(i.equals(I))G?.();return i}function e1(i,s){if(s.shift&&s.delete||i==="\x1B[3;2~"){let l=I.deleteWordBefore();if(!I.equals(l)){if(M(l.offset),I.text!==l.text)Z(l.text)}return}if(s.meta&&(s.backspace||s.delete||i==="")){let l=I.deleteWordBefore();if(!I.equals(l)){if(M(l.offset),I.text!==l.text)Z(l.text)}return}if(s.backspace||s.delete||i==="\b"||i===""||i==="\b"){let l=I.backspace();if(!I.equals(l)){if(M(l.offset),I.text!==l.text)Z(l.text)}return}let C0=v$(i,s)(i);if(C0){if(!I.equals(C0)){if(M(C0.offset),I.text!==C0.text)Z(C0.text)}}}function v$(i,s){if(e(i,s))return P1;if(s.backspace||s.delete)return Q0(),()=>I.backspace();switch(!0){case(s.leftArrow&&(s.ctrl||s.meta||s.fn)):return()=>I.prevWord();case(s.rightArrow&&(s.ctrl||s.meta||s.fn)):return()=>I.nextWord();case s.ctrl:return D1;case s.home:return()=>I.startOfLine();case s.end:return()=>I.endOfLine();case s.pageDown:return()=>I.endOfLine();case s.pageUp:return()=>I.startOfLine();case s.return:return()=>L0(s);case s.meta:return R1;case s.tab:return()=>{};case s.upArrow:return z1;case s.downArrow:return t1;case s.leftArrow:return()=>I.left();case s.rightArrow:return()=>I.right()}return function(C0){switch(!0){case(C0=="\x1B[H"||C0=="\x1B[1~"):return I.startOfLine();case(C0=="\x1B[F"||C0=="\x1B[4~"):return I.endOfLine();case(C0==="\b"||C0===""||C0==="\b"):return Q0(),I.backspace();default:return I.insert(C0.replace(/\r/g,`
|
|
46
|
-
`))}}}return{onInput:e1,renderedValue:I.render(F,W,O),offset:f,setOffset:M}}import{jsxDEV as hq}from"react/jsx-dev-runtime";var lQ="[200~",mZ="\x1B[201~",dZ="[201~";function Dq($){let Z=$,J=!1,Q=!1;if(Z.startsWith(lQ))Z=Z.slice(lQ.length),J=!0;if(Z.endsWith(mZ))Z=Z.slice(0,-mZ.length),Q=!0;else if(Z.endsWith(dZ))Z=Z.slice(0,-dZ.length),Q=!0;else{let X=Z.indexOf(mZ);if(X!==-1)Z=Z.slice(0,X)+Z.slice(X+mZ.length),Q=!0;else{let Y=Z.indexOf(dZ);if(Y!==-1)Z=Z.slice(0,Y)+Z.slice(Y+dZ.length),Q=!0}}return{text:Z,hasBracketStart:J,hasBracketEnd:Q}}function _8({value:$,placeholder:Z="",focus:J=!0,mask:Q,multiline:X=!1,highlightPastedText:Y=!1,showCursor:K=!0,onChange:G,onSubmit:z,onExit:q,onHistoryUp:W,onHistoryDown:U,onExitMessage:F,onMessage:O,onHistoryReset:L,onDoubleEscape:B,columns:S,onImagePaste:k,onPaste:y,isDimmed:f=!1,disableCursorMovementForUpDownKeys:M=!1,cursorOffset:I,onChangeCursorOffset:R}){let[w1,P1]=gq(0),H0=S??process.stdout.columns??80,o1=I??w1,L1=R??P1,{onInput:s1,renderedValue:D1}=s5({value:$,onChange:G,onSubmit:z,onExit:q,onExitMessage:F,onMessage:O,onHistoryReset:L,onHistoryUp:W,onHistoryDown:U,onDoubleEscape:B,focus:J,mask:Q,multiline:X,cursorChar:K?" ":"",highlightPastedText:Y,invert:P8.inverse,themeText:(X0)=>P8.hex(A().colors.text)(X0),columns:H0,onImagePaste:k,disableCursorMovementForUpDownKeys:M,externalOffset:o1,onOffsetChange:L1}),R1=t5([]),L0=t5(null),z1=t5(!1),t1=()=>{if(L0.current)clearTimeout(L0.current),L0.current=null},e1=()=>{let X0=R1.current.join("");if(R1.current=[],t1(),z1.current=!1,!X0||!y)return;Promise.resolve().then(()=>y(X0))},v$=()=>{t1(),L0.current=setTimeout(()=>{e1()},100)},i=(X0)=>{R1.current.push(X0),v$()},s=()=>L0.current!==null||z1.current;vq(()=>()=>{t1(),R1.current=[],z1.current=!1},[]);let C0=(X0)=>{return Boolean(X0.return||X0.escape||X0.tab||X0.ctrl||X0.meta||X0.upArrow||X0.downArrow||X0.leftArrow||X0.rightArrow||X0.pageUp||X0.pageDown||X0.backspace||X0.delete)};Vq((X0,b0)=>{let{text:p0,hasBracketStart:h1,hasBracketEnd:c0}=Dq(X0);if(h1&&y)z1.current=!0;if(z1.current&&y){if(C0(b0)){e1();return}if(p0)i(p0);if(c0)e1();return}if(c0&&s()){if(p0)i(p0);e1();return}if(b0.backspace||b0.delete||p0==="\b"||p0===""||p0==="\b"){s1(p0,{...b0,backspace:!0});return}if(!p0&&!C0(b0))return;if(y&&s()&&C0(b0)){e1();return}if(y&&(p0.length>800||s())){i(p0);return}s1(p0,b0)},{isActive:J});let R0=Z?P8.hex(A().colors.textMuted)(Z):void 0;if(K&&J)R0=Z.length>0?P8.inverse(Z[0])+P8.hex(A().colors.textMuted)(Z.slice(1)):P8.inverse(" ");let u0=$.length==0&&Z;return hq(Tq,{wrap:"truncate-end",dimColor:f,children:u0?R0:D1},void 0,!1,void 0,this)}import{useSyncExternalStore as Eq}from"react";function rQ(){return{columns:process.stdout.columns||80,rows:process.stdout.rows||24}}var pZ=rQ(),xZ=!1,lZ=new Set;function e5(){let $=rQ();if($.columns===pZ.columns&&$.rows===pZ.rows)return!1;return pZ=$,!0}function jq(){for(let $ of lZ)$()}function aQ(){if(!e5())return;jq()}function cq(){if(xZ)return;process.stdout.on("resize",aQ),xZ=!0}function mq(){if(!xZ||lZ.size!==0)return;process.stdout.off("resize",aQ),xZ=!1}function dq($){return lZ.add($),e5(),cq(),()=>{lZ.delete($),mq()}}function uQ(){return e5(),pZ}function K1(){return Eq(dq,uQ,uQ)}import{jsxDEV as A$,Fragment as lq}from"react/jsx-dev-runtime";var pq="image/png",iQ="[Image pasted]";function xq($){return`data:${pq};base64,${$}`}function $7({userName:$,value:Z,onChange:J,onSubmit:Q,onTrigger:X,onExit:Y,isStreaming:K=!1,isDisabled:G=!1,focus:z,history:q=[],onSaveInput:W,onDoubleEscape:U}){let{columns:F}=K1(),O=F-6,L=nZ()&&oQ(),[B,S]=P3(-1),[k,y]=P3(""),[f,M]=P3(q),[I,R]=P3(Z.length),[j,Q0]=P3(null),[w1,P1]=P3(null),[H0,o1]=P3({show:!1}),[L1,s1]=P3({show:!1}),D1=rZ(Z),R1=rZ(I),L0=rZ(j),z1=rZ(w1);D1.current=Z,R1.current=I,L0.current=j,z1.current=w1,nQ(()=>{if(q.length>0)M((l)=>{let R0=[...l];for(let u0 of q)if(!R0.includes(u0))R0.push(u0);return R0.slice(0,100)})},[q]),nQ(()=>{if(f.length===0&&B>=0)S(-1)},[f.length]);let t1=uZ(()=>{if(f.length===0)return;if(B===-1)y(Z);let l=Math.min(B+1,f.length-1);if(S(l),l>=0&&l<f.length){let R0=f[l];J(R0),R(R0.length)}},[f,B,Z,J]),e1=uZ(()=>{if(B<0)return;let l=B-1;if(S(l),l===-1)J(k),R(k.length);else if(l>=0&&l<f.length){let R0=f[l];J(R0),R(R0.length)}else if(l>=f.length)S(-1),J(k),R(k.length)},[B,k,f,J]),v$=uZ((l)=>{S(-1);let R0=l==="/"||l.startsWith("/")&&!Z.startsWith("/"),u0=l.match(/@([\p{L}\p{N}_-]*)$/u),X0=Z.match(/@[\p{L}\p{N}_-]*$/u),b0=u0&&!X0;if(J(l),R0)X("command",l.slice(1));else if(b0)X("mention",u0[1])},[Z,J,X]),i=uZ((l)=>{let R0=D1.current,u0=L0.current,X0=z1.current,b0=l!==R0&&(u0!==null||X0!==null)?R0:l;if(u0){let Q2=`[Pasted text +${(u0.match(/\r\n|\r|\n/g)||[]).length} lines] `;if(b0.includes(Q2))b0=b0.replaceAll(Q2,u0)}if(X0&&b0.includes(iQ))b0=b0.replaceAll(iQ,"");let p0=X0!==null,h1=b0.trim();if(!h1&&!p0)return;if(p0){let c0=xq(X0);b0=h1?`${b0}
|
|
47
|
-
|
|
48
|
-
${c0}`:c0}if(h1)W?.(h1),M((c0)=>[h1,...c0.filter((Q2)=>Q2!==h1)].slice(0,100));D1.current="",R1.current=0,L0.current=null,z1.current=null,J(""),Q0(null),P1(null),s1({show:!1}),Q(b0)},[Q,W,J]);function s(l){z1.current=l,P1(l),s1({show:!0,text:"Image attached. Press Enter to send."})}function C0(l){let R0=D1.current,u0=R1.current,X0=l.replace(/\r/g,`
|
|
49
|
-
`),p0=`[Pasted text +${(X0.match(/\r\n|\r|\n/g)||[]).length} lines] `,h1=R0.slice(0,u0)+p0+R0.slice(u0);D1.current=h1,J(h1);let c0=u0+p0.length;R1.current=c0,R(u0+p0.length),L0.current=X0,Q0(X0)}return A$(A6,{flexDirection:"column",children:[A$(A6,{borderStyle:"single",borderLeft:!1,borderRight:!1,borderDimColor:!0,width:"100%",children:A$(A6,{children:[A$(m5,{userName:$},void 0,!1,void 0,this),A$(_8,{multiline:!0,value:Z,onChange:v$,onSubmit:i,onHistoryUp:t1,onHistoryDown:e1,onHistoryReset:()=>S(-1),onDoubleEscape:U,onExit:Y,onExitMessage:(l,R0)=>o1({show:l,key:R0}),onMessage:(l,R0)=>s1({show:l,text:R0}),onImagePaste:s,onPaste:C0,columns:O,isDimmed:G,focus:z!==!1,showCursor:!0,cursorOffset:I,onChangeCursorOffset:R},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),A$(A6,{flexDirection:"row",justifyContent:"space-between",paddingX:2,children:A$(A6,{justifyContent:"flex-start",gap:1,children:H0.show?A$(aZ,{dimColor:!0,children:["Press ",H0.key," again to exit"]},void 0,!0,void 0,this):L1.show?A$(aZ,{dimColor:!0,children:L1.text},void 0,!1,void 0,this):A$(lq,{children:[A$(aZ,{dimColor:!0,children:"/ for commands · @ to mention · esc to undo"},void 0,!1,void 0,this),A$(aZ,{dimColor:!0,children:L?"shift + ⏎ for newline":"\\⏎ for newline"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{Static as AS,Box as OS}from"ink";import*as QK from"react";import{Box as k3,Text as w2}from"ink";import pW from"wrap-ansi";import{Box as O6,Text as Z7}from"ink";import{jsxDEV as _3}from"react/jsx-dev-runtime";var uq=process.platform==="darwin"?"⏺":"●";function iZ({param:{text:$},userName:Z,columns:J,addMargin:Q=!1,showPrefix:X=!0}){let Y=A(),K=Z||"User",G=Math.max(J-4,20);return _3(O6,{flexDirection:"column",marginTop:Q?1:0,width:"100%",children:[X&&_3(O6,{flexDirection:"row",children:_3(Z7,{bold:!0,color:Y.colors.primary,children:["\uD83E\uDD84 ",K]},void 0,!0,void 0,this)},void 0,!1,void 0,this),_3(O6,{flexDirection:"row",width:"100%",marginTop:X?1:0,children:[_3(O6,{minWidth:2,children:_3(Z7,{color:Y.colors.primary,children:uq},void 0,!1,void 0,this)},void 0,!1,void 0,this),_3(O6,{flexShrink:1,width:G,children:_3(Z7,{wrap:"wrap",children:$?W1($,{width:G}):""},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}import{Box as oq,Text as Q7}from"ink";var rq=/data:image\/[a-zA-Z0-9.+-]+;base64,[a-zA-Z0-9+/=\n\r]+/g;function aq(){return(process.env.TERM_PROGRAM??"").toLowerCase()==="iterm.app"}function nq(){return aq()&&Boolean(process.stdout?.isTTY)}function oZ($){let J=$.trim().match(/^data:(image\/[a-zA-Z0-9.+-]+);base64,([a-zA-Z0-9+/=\n\r]+)$/);if(!J)return null;let[,Q,X]=J;if(!Q||!X)return null;try{let Y=X.replace(/\s+/g,""),K=Buffer.from(Y,"base64");if(K.length===0)return null;return{buffer:K,mimeType:Q}}catch{return null}}function sQ($){let Z=oZ($);if(!Z)return null;return iq(Z.buffer,Z.mimeType)}function iq($,Z="image/png"){if(!nq())return null;let J=$.toString("base64");return`\x1B]1337;File=inline=1;preserveAspectRatio=1;size=${$.length};type=${Z}:${J}\x07`}function J7($){let Z=[],J=0;for(let Q of $.matchAll(rq)){let X=Q.index??0,Y=Q[0]??"";if(!Y)continue;if(X>J)Z.push({type:"text",text:$.slice(J,X)});Z.push({type:"image",dataUri:Y}),J=X+Y.length}if(J<$.length)Z.push({type:"text",text:$.slice(J)});return Z.length>0?Z:[{type:"text",text:$}]}import{jsxDEV as sZ}from"react/jsx-dev-runtime";function tQ({dataUri:$,userName:Z,showPrefix:J=!0}){let Q=A(),Y=`\uD83E\uDD84 ${Z||"User"}`,K=sQ($);return sZ(oq,{flexDirection:"column",width:"100%",children:[J&&sZ(Q7,{bold:!0,color:Q.colors.primary,children:Y},void 0,!1,void 0,this),K?sZ(Q7,{children:K},void 0,!1,void 0,this):sZ(Q7,{dimColor:!0,children:"[Image attachment]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useRef as JH}from"react";import{Box as tZ,Text as R6}from"ink";var w6=[{present:"Accomplishing",past:"Accomplished"},{present:"Actioning",past:"Actioned"},{present:"Actualizing",past:"Actualized"},{present:"Absquatulating",past:"Absquatulated"},{present:"Bamboozling",past:"Bamboozled"},{present:"Brewing",past:"Brewed"},{present:"Calculating",past:"Calculated"},{present:"Cerebrating",past:"Cerebrated"},{present:"Churning",past:"Churned"},{present:"Coalescing",past:"Coalesced"},{present:"Cogitating",past:"Cogitated"},{present:"Confabulating",past:"Confabulated"},{present:"Conjuring",past:"Conjured"},{present:"Considering",past:"Considered"},{present:"Contemplating",past:"Contemplated"},{present:"Cooking",past:"Cooked"},{present:"Crafting",past:"Crafted"},{present:"Crunching",past:"Crunched"},{present:"Deliberating",past:"Deliberated"},{present:"Determining",past:"Determined"},{present:"Dillydallying",past:"Dillydallied"},{present:"Discombobulating",past:"Discombobulated"},{present:"Doing",past:"Done"},{present:"Effecting",past:"Effected"},{present:"Finagling",past:"Finagled"},{present:"Fizzwizzling",past:"Fizzwizzled"},{present:"Flummoxing",past:"Flummoxed"},{present:"Forging",past:"Forged"},{present:"Frobnicating",past:"Frobnicated"},{present:"Gallivanting",past:"Gallivanted"},{present:"Generating",past:"Generated"},{present:"Hatching",past:"Hatched"},{present:"Herding",past:"Herded"},{present:"Honking",past:"Honked"},{present:"Hornswoggling",past:"Hornswoggled"},{present:"Hustling",past:"Hustled"},{present:"Ideating",past:"Ideated"},{present:"Inferring",past:"Inferred"},{present:"Lollygagging",past:"Lollygagged"},{present:"Manifesting",past:"Manifested"},{present:"Marinating",past:"Marinated"},{present:"Moseying",past:"Moseyed"},{present:"Mulling",past:"Mulled"},{present:"Mustering",past:"Mustered"},{present:"Musing",past:"Mused"},{present:"Noodling",past:"Noodled"},{present:"Perambulating",past:"Perambulated"},{present:"Percolating",past:"Percolated"},{present:"Pondering",past:"Pondered"},{present:"Prestidigitating",past:"Prestidigitated"},{present:"Processing",past:"Processed"},{present:"Puttering",past:"Puttered"},{present:"Reflecting",past:"Reflected"},{present:"Reticulating",past:"Reticulated"},{present:"Ruminating",past:"Ruminated"},{present:"Schlepping",past:"Schlepped"},{present:"Shenaniganing",past:"Shenaniganed"},{present:"Shucking",past:"Shucked"},{present:"Skedaddling",past:"Skedaddled"},{present:"Snozzwangling",past:"Snozzwangled"},{present:"Simmering",past:"Simmered"},{present:"Smooshing",past:"Smooshed"},{present:"Spinning",past:"Spun"},{present:"Stewing",past:"Stewed"},{present:"Synthesizing",past:"Synthesized"},{present:"Thaumaturging",past:"Thaumaturged"},{present:"Thinking",past:"Thought"},{present:"Transmogrifying",past:"Transmogrified"},{present:"Transmuting",past:"Transmuted"},{present:"Vibing",past:"Vibed"},{present:"Weaving",past:"Woven"},{present:"Working",past:"Worked"},{present:"Chrysalizing",past:"Chrysalized"},{present:"Fluttering",past:"Fluttered"},{present:"Harmonizing",past:"Harmonized"},{present:"Metamorphosing",past:"Metamorphosed"},{present:"Orchestrating",past:"Orchestrated"},{present:"Catching",past:"Caught"},{present:"Evolving",past:"Evolved"},{present:"Mega Evolving",past:"Mega Evolved"},{present:"Summoning",past:"Summoned"},{present:"Charging",past:"Charged"},{present:"Fusing",past:"Fused"},{present:"Kamehameha-ing",past:"Kamehameha'd"},{present:"Powering Up",past:"Powered Up"},{present:"Spirit Bombing",past:"Spirit Bombed"},{present:"Transcending",past:"Transcended"},{present:"Gear Shifting",past:"Gear Shifted"},{present:"Gum-Gum-ing",past:"Gum-Gum'd"},{present:"Navigating",past:"Navigated"},{present:"Plundering",past:"Plundered"},{present:"Sailing",past:"Sailed"},{present:"Setting Sail",past:"Set Sail"},{present:"Catapulting",past:"Catapulted"},{present:"Mobilizing",past:"Mobilized"},{present:"Newtypeing",past:"Newtyped"},{present:"Trans-Am-ing",past:"Trans-Am'd"},{present:"Assembling",past:"Assembled"},{present:"Hulking",past:"Hulked"},{present:"Snapping",past:"Snapped"},{present:"Vibranium-ing",past:"Vibranium'd"},{present:"Alchemizing",past:"Alchemized"},{present:"Assimilating",past:"Assimilated"},{present:"Astral Projecting",past:"Astral Projected"},{present:"Beaming",past:"Beamed"},{present:"Cloaking",past:"Cloaked"},{present:"Dematerializing",past:"Dematerialized"},{present:"Enchanting",past:"Enchanted"},{present:"Engaging",past:"Engaged"},{present:"Ensorcelling",past:"Ensorcelled"},{present:"Holographing",past:"Holographed"},{present:"Hyperjumping",past:"Hyperjumped"},{present:"Morphing",past:"Morphed"},{present:"Nebulizing",past:"Nebulized"},{present:"Phasing",past:"Phased"},{present:"Quantum Leaping",past:"Quantum Leapt"},{present:"Shapeshifting",past:"Shapeshifted"},{present:"Spellcasting",past:"Spellcast"},{present:"Teleporting",past:"Teleported"},{present:"Terraforming",past:"Terraformed"},{present:"Time Traveling",past:"Time Traveled"},{present:"Time Warping",past:"Time Warped"},{present:"Transforming",past:"Transformed"},{present:"Warping",past:"Warped"},{present:"Wormholing",past:"Wormholed"},{present:"Bepuzzling",past:"Bepuzzled"},{present:"Blorbulating",past:"Blorbulated"},{present:"Cattywampusing",past:"Cattywampused"},{present:"Cromulating",past:"Cromulated"},{present:"Discorbuflating",past:"Discorbuflated"},{present:"Embiggenating",past:"Embiggenated"},{present:"Flibbertigibbeting",past:"Flibbertigibbeted"},{present:"Flonkifying",past:"Flonkified"},{present:"Frobscottling",past:"Frobscottled"},{present:"Glorpifying",past:"Glorpified"},{present:"Gobsmacking",past:"Gobsmacked"},{present:"Higgledy-piggling",past:"Higgledy-piggled"},{present:"Jiggery-pokerying",past:"Jiggery-pokeried"},{present:"Kerfuffling",past:"Kerfuffled"},{present:"Malarkeying",past:"Malarkeyed"},{present:"Mumblewumbling",past:"Mumblewumbled"},{present:"Phantasmagoring",past:"Phantasmagored"},{present:"Quibberflasting",past:"Quibberflasted"},{present:"Quorfluxing",past:"Quorfluxed"},{present:"Rigmaroling",past:"Rigmaroled"},{present:"Skullduggering",past:"Skullduggered"},{present:"Snizzleworfing",past:"Snizzleworfed"},{present:"Snorfulating",past:"Snorfulated"},{present:"Spatchcocking",past:"Spatchcocked"},{present:"Tomfoolering",past:"Tomfoolered"},{present:"Wibbling",past:"Wibbled"},{present:"Wumboozling",past:"Wumboozled"},{present:"Yoinking",past:"Yoinked"},{present:"Zippledorping",past:"Zippledorped"},{present:"Zorbinating",past:"Zorbinated"},{present:"Awakening",past:"Awakened"},{present:"Bankai-ing",past:"Bankai'd"},{present:"Rasengan-ing",past:"Rasengan'd"},{present:"Unleashing",past:"Unleashed"}];function V$(){return w6[Math.floor(Math.random()*w6.length)]??w6[0]}var sq=new Set(["file","web"]),tq={ls:"list",rm:"remove",cp:"copy",mv:"move",cd:"change_dir",mkdir:"make_dir"},eq=new Set(["arion","delegation","knowledge","patch","processes","process","quest","skill","stdin","tool","user","worker"]);function $X($,Z=!1){let J=tq[$]??$,Q=J.split("_").filter((Y)=>!sq.has(Y.toLowerCase()));if(Q.length===0)return Z?eQ(J.toLowerCase()):L6(J);let X=Z?$H(Q):-1;return Q.map((Y,K)=>K===X?eQ(Y.toLowerCase()):L6(Y.toLowerCase())).join(" ")}function $H($){let Z=$.findIndex((J)=>!eq.has(J.toLowerCase()));return Z>=0?Z:0}var ZH=new Set(["glob","grep","run","get","set","put","stop","spin","forget"]);function eQ($){if($.endsWith("e")&&$.length>2)return L6($.slice(0,-1))+"ing";if(ZH.has($))return L6($)+$[$.length-1]+"ing";return L6($)+"ing"}function L6($){return $.charAt(0).toUpperCase()+$.slice(1)}import{jsxDEV as D$}from"react/jsx-dev-runtime";var QH=1/0;function XH($){if($===void 0||$===null)return"";if($<=0)return"< 1s";if($<60)return`${$}s`;let Z=Math.floor($/60),J=$%60;return`${Z}m ${J}s`}function X7({content:$,expanded:Z=!1,durationSeconds:J,verb:Q,arionName:X,arionEmoji:Y,arionColor:K,isLive:G=!1,maxLines:z=QH}){let q=A(),W=JH(V$()),U=Q||W.current.present,F=Q||W.current.past,O=XH(J);return D$(tZ,{flexDirection:"column",children:[!!(Y&&X)&&D$(tZ,{marginBottom:1,children:D$(R6,{color:K||q.colors.textMuted,bold:!0,children:[Y," ",X]},void 0,!0,void 0,this)},void 0,!1,void 0,this),D$(R6,{color:q.colors.textMuted,children:["✻"," ",G?U:F,G?"…":O?` for ${O}`:""]},void 0,!0,void 0,this),G&&$&&D$(ZX,{content:$,maxLines:z,isLive:!0},void 0,!1,void 0,this),!G&&Z&&$&&D$(ZX,{content:$,maxLines:z,isLive:!1},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ZX({content:$,maxLines:Z,isLive:J}){let Q=A(),{columns:X}=K1(),Y=Math.max(X-4,20),G=W1($,{width:Y,mode:J?"streaming":"final"}).split(`
|
|
50
|
-
`),z=G.slice(0,Z),q=G.length-z.length;return D$(tZ,{children:[D$(R6,{color:Q.colors.textMuted,children:" ⎿ "},void 0,!1,void 0,this),D$(tZ,{flexDirection:"column",width:Y,children:[z.map((W,U)=>D$(R6,{color:Q.colors.textMuted,wrap:"wrap",children:W},U,!1,void 0,this)),q>0&&D$(R6,{color:Q.colors.textMuted,children:["…"," (+",q," line",q!==1?"s":"",")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}import{Box as $K,Text as h7}from"ink";import{Box as YX,Text as eZ}from"ink";import{Box as KH,Text as GH}from"ink";import zH from"react";import{useEffect as JX,useRef as YH}from"react";function QX($,Z){let J=YH($);JX(()=>{J.current=$},[$]),JX(()=>{function Q(){J.current()}let X=setInterval(Q,Z);return()=>clearInterval(X)},[Z])}import{jsxDEV as XX}from"react/jsx-dev-runtime";var qH=process.platform==="darwin"?"⏺":"●";function Y7({isError:$=!1,isUnresolved:Z=!1,shouldAnimate:J=!0,...Q}){let X=Z||Q.isQueued||!1,[Y,K]=zH.useState(!0);QX(()=>{if(!J)return;K((z)=>!z)},600);let G=X?A().colors.textMuted:$?A().colors.error:A().colors.success;return XX(KH,{minWidth:2,children:XX(GH,{color:G,children:Y?qH:" "},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as X4}from"react/jsx-dev-runtime";function HH($){return $.split(/,\s*(?=\w+:\s)/).map((J)=>J.replace(/^\w+:\s*/,"")).join(" ")}function WH($,Z){let J=$.replace(/\s+/g," ").trim();if(J.length<=Z)return J;return J.slice(0,Z-1)+"…"}function KX({displayName:$,args:Z,status:J,durationMs:Q,verbose:X}){let Y=A(),K=J==="pending"||J==="running",G=J==="error",z;if(Z)if(typeof Z==="string")if(X)z=Z;else{let q=HH(Z),W=process.stdout.columns||80,U=2+$.length+1,F=Math.max(20,W-U);z=WH(q,F)}else z=Z;return X4(YX,{flexDirection:"row",children:[X4(Y7,{shouldAnimate:K,isError:G,isUnresolved:K},void 0,!1,void 0,this),X4(eZ,{bold:!0,children:$},void 0,!1,void 0,this),z!=null&&(typeof z==="string"?X4(eZ,{children:[" ",z]},void 0,!0,void 0,this):X4(YX,{children:[X4(eZ,{children:" "},void 0,!1,void 0,this),z]},void 0,!0,void 0,this)),X&&Q!=null?X4(eZ,{color:Y.colors.textMuted,children:[" · ",(Q/1000).toFixed(1),"s"]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this)}import{Box as K7,Text as NH}from"ink";import{jsxDEV as $9}from"react/jsx-dev-runtime";function G7({children:$}){return $9(K7,{flexDirection:"column",children:$9(K7,{flexDirection:"row",children:[$9(NH,{children:[" ","⎿"," "]},void 0,!0,void 0,this),$9(K7,{flexDirection:"column",flexGrow:1,children:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{Box as PH,Text as _H}from"ink";import{jsxDEV as z7,Fragment as FH}from"react/jsx-dev-runtime";function GX({durationMs:$,usage:Z}){let J=[];if(Z&&Z.totalTokens>0)J.push(`+${EZ(Z.totalTokens)} tokens`),J.push(E5(Z.estimatedCost));if($)J.push(`${($/1000).toFixed(1)}s`);if(J.length===0)return z7(FH,{},void 0,!1,void 0,this);return z7(PH,{children:z7(_H,{dimColor:!0,children:J.join(" · ")},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import qX from"react";import{jsxDEV as UH}from"react/jsx-dev-runtime";var zX=process.stdout.columns||80,HX=qX.createContext({terminalWidth:zX,contentWidth:Math.max(zX-5,1)});function Z9({value:$,children:Z}){return UH(HX.Provider,{value:$,children:Z},void 0,!1,void 0,this)}function F3(){return qX.useContext(HX)}import{Text as U8}from"ink";import{Text as WX}from"ink";import{jsxDEV as NX}from"react/jsx-dev-runtime";function C(){return NX(WX,{children:[" ","⎿"," ",NX(WX,{color:A().colors.error,children:"No (tell ARIA what to do differently)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{Box as LH,Text as RH}from"ink";import{Box as q7,Text as AH}from"ink";import OH from"chalk";function b1($){return $.length>80?$.slice(0,80)+"…":$}function D2($){return $.split(`
|
|
51
|
-
`).map(b1).join(`
|
|
52
|
-
`)}import{jsxDEV as J9}from"react/jsx-dev-runtime";var H7=3;function wH($,Z){let J=$.split(`
|
|
53
|
-
`);if(J.length<=H7)return J.map(b1).join(`
|
|
54
|
-
`);return[...J.slice(0,H7).map(b1),OH.grey(`… +${Z-H7} lines`)].join(`
|
|
55
|
-
`)}function F8({content:$,lines:Z,verbose:J,isError:Q}){return J9(q7,{justifyContent:"space-between",width:"100%",children:J9(q7,{flexDirection:"row",children:J9(q7,{flexDirection:"column",children:J9(AH,{color:Q?A().colors.error:void 0,children:J?$.trim():wH($.trim(),Z)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as Q9}from"react/jsx-dev-runtime";function BH({content:$,verbose:Z}){let{stdout:J,stdoutLines:Q,stderr:X,stderrLines:Y}=$;return Q9(LH,{flexDirection:"column",children:[J!==""?Q9(F8,{content:J,lines:Q,verbose:Z},void 0,!1,void 0,this):null,X!==""?Q9(F8,{content:X,lines:Y,verbose:Z,isError:!0},void 0,!1,void 0,this):null,J===""&&X===""?Q9(RH,{color:A().colors.textMuted,children:"(No content)"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)}var PX=BH;import{jsxDEV as U3}from"react/jsx-dev-runtime";var A3={displayName(){return"Bash"},renderInput($){if(typeof $.command==="string"){let Z=$.command;if(Z.includes(`"$(cat <<'EOF'`)){let J=Z.match(/^(.*?)"?\$\(cat <<'EOF'\n([\s\S]*?)\n\s*EOF\n\s*\)"(.*)$/);if(J&&J[1]&&J[2])return`${J[1].trim()} "${J[2].trim()}"${(J[3]||"").trim()}`}return Z}if(typeof $.program==="string"){let Z=Array.isArray($.args)?" "+$.args.join(" "):"";return`${$.program}${Z}`}if(typeof $.input==="string"){let Z=$.input.length>40?$.input.slice(0,40)+"…":$.input;return`stdin → ${$.pid??""} "${Z}"`}if($.signal!=null)return`kill ${$.signal} ${$.pid}`;if(typeof $.timeoutMs==="number"||typeof $.timeout==="number")return`wait ${$.pid}`;if($.pid!=null&&Object.keys($).length<=2)return`pid ${$.pid}`;return""},renderRejection(){return U3(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}){if($==null)return U3(U8,{children:"(No content)"},void 0,!1,void 0,this);if(typeof $==="string")return U3(U8,{children:$||"(No content)"},void 0,!1,void 0,this);let J=$;if(typeof J.stdout==="string"||typeof J.stderr==="string"){let Q={stdout:J.stdout??"",stdoutLines:typeof J.stdoutLines==="number"?J.stdoutLines:(J.stdout??"").split(`
|
|
56
|
-
`).length,stderr:J.stderr??"",stderrLines:typeof J.stderrLines==="number"?J.stderrLines:(J.stderr??"").split(`
|
|
57
|
-
`).length};return U3(PX,{content:Q,verbose:Z},void 0,!1,void 0,this)}if(J.pid!=null)return U3(U8,{children:["pid: ",String(J.pid)]},void 0,!0,void 0,this);if(J.signal!=null||J.killed!=null)return U3(U8,{children:[J.killed?"Killed":"Signal sent",J.signal?` (${String(J.signal)})`:""]},void 0,!0,void 0,this);if(J.exitCode!=null)return U3(U8,{children:["Exit code: ",String(J.exitCode)]},void 0,!0,void 0,this);return U3(U8,{children:JSON.stringify($)},void 0,!1,void 0,this)}};import{Box as UX,Text as M6}from"ink";import{relative as P7}from"path";import{Box as N7,Text as I6}from"ink";import{Box as B6,Text as K$}from"ink";import*as _X from"react";import{useMemo as IH}from"react";import{jsxDEV as x0}from"react/jsx-dev-runtime";function MH($,Z){let J=[],Q="";for(let X of $)if([...Q].length<Z)Q+=X;else J.push(Q),Q=X;if(Q)J.push(Q);return J}function CH({patch:$,dim:Z,width:J,overrideTheme:Q}){return IH(()=>fH($.lines,$.oldStart,J,Z,Q),[$.lines,$.oldStart,J,Z,Q]).map((Y,K)=>x0(B6,{children:Y},K,!1,void 0,this))}function fH($,Z,J,Q,X){let Y=A(),K=SH($.map((q)=>{if(q.startsWith("+"))return{code:"+"+q.slice(1),i:0,type:"add"};if(q.startsWith("-"))return{code:"-"+q.slice(1),i:0,type:"remove"};return{code:q,i:0,type:"nochange"}}),Z),z=Math.max(...K.map(({i:q})=>q)).toString().length;return K.flatMap(({type:q,code:W,i:U})=>{return MH(W,J-z).map((O,L)=>{let B=`${q}-${U}-${L}`;switch(q){case"add":return x0(K$,{children:[x0(W7,{i:L===0?U:void 0,width:z},void 0,!1,void 0,this),x0(K$,{color:X?Y.colors.text:void 0,backgroundColor:Q?Y.colors.diffAddedDimmed:Y.colors.diffAdded,dimColor:Q,children:O},void 0,!1,void 0,this)]},B,!0,void 0,this);case"remove":return x0(K$,{children:[x0(W7,{i:L===0?U:void 0,width:z},void 0,!1,void 0,this),x0(K$,{color:X?Y.colors.text:void 0,backgroundColor:Q?Y.colors.diffRemovedDimmed:Y.colors.diffRemoved,dimColor:Q,children:O},void 0,!1,void 0,this)]},B,!0,void 0,this);case"nochange":return x0(K$,{children:[x0(W7,{i:L===0?U:void 0,width:z},void 0,!1,void 0,this),x0(K$,{color:X?Y.colors.text:void 0,dimColor:Q,children:O},void 0,!1,void 0,this)]},B,!0,void 0,this)}})})}function W7({i:$,width:Z}){return x0(K$,{color:A().colors.textMuted,children:[$!==void 0?$.toString().padStart(Z):" ".repeat(Z)," "]},void 0,!0,void 0,this)}function SH($,Z){let J=Z,Q=[],X=[...$];while(X.length>0){let{code:Y,type:K}=X.shift(),G={code:Y,type:K,i:J};switch(K){case"nochange":J++,Q.push(G);break;case"add":J++,Q.push(G);break;case"remove":{Q.push(G);let z=0;while(X[0]?.type==="remove"){J++;let{code:q,type:W}=X.shift(),U={code:q,type:W,i:J};Q.push(U),z++}J-=z;break}}}return Q}function bH($){let Z=[];for(let J of $.lines)switch(J.type){case"added":Z.push("+"+J.content);break;case"removed":Z.push("-"+J.content);break;default:Z.push(" "+J.content);break}return{lines:Z,oldStart:$.oldStart}}function Y4({diff:$,width:Z=60,showHeader:J=!0,maxLines:Q=50,dim:X=!1}){let Y=A(),K=$.hunks.reduce((W,U)=>W+U.lines.length,0),G=K>Q,z=G?Math.floor(Q/$.hunks.length):void 0,q=G?$.hunks.reduce((W,U)=>W+Math.min(U.lines.length,z),0):K;return x0(B6,{flexDirection:"column",width:Z,children:[J&&x0(B6,{marginBottom:1,children:[x0(K$,{bold:!0,children:$.filePath},void 0,!1,void 0,this),x0(K$,{color:Y.colors.textMuted,children:[" ","(",x0(K$,{color:Y.colors.success,children:["+",$.additions]},void 0,!0,void 0,this)," / ",x0(K$,{color:Y.colors.error,children:["-",$.deletions]},void 0,!0,void 0,this),")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),$.hunks.map((W,U)=>{let F=z&&W.lines.length>z?{...W,lines:W.lines.slice(0,z)}:W,O=bH(F);return x0(_X.Fragment,{children:[U>0&&x0(B6,{paddingY:0,children:x0(K$,{color:Y.colors.textMuted,children:"..."},void 0,!1,void 0,this)},void 0,!1,void 0,this),x0(CH,{patch:O,dim:X,width:Z},void 0,!1,void 0,this)]},U,!0,void 0,this)}),G&&x0(B6,{marginTop:1,children:x0(K$,{color:Y.colors.textMuted,children:["... ",K-q," more lines"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as h$,Fragment as FX}from"react/jsx-dev-runtime";function yH($,Z){return $.flatMap((J,Q)=>Q?[Z(Q),J]:[J])}function kH($,Z){let J=[],Q=$.oldStart,X=$.newStart,Y=0,K=0;for(let G of $.lines){let z=G.slice(1);if(G.startsWith("+"))J.push({type:"added",content:z,newLineNo:X++}),Y++;else if(G.startsWith("-"))J.push({type:"removed",content:z,oldLineNo:Q++}),K++;else J.push({type:"unchanged",content:z,oldLineNo:Q++,newLineNo:X++})}return{filePath:Z,hunks:[{oldStart:$.oldStart,oldLines:$.oldLines,newStart:$.newStart,newLines:$.newLines,lines:J}],additions:Y,deletions:K}}function X9({filePath:$,structuredPatch:Z,verbose:J}){let{columns:Q}=K1(),X=Z.reduce((q,W)=>q+W.lines.filter((U)=>U.startsWith("+")).length,0),Y=Z.reduce((q,W)=>q+W.lines.filter((U)=>U.startsWith("-")).length,0),K=Z.flatMap((q)=>q.lines.filter((W)=>W.startsWith("+")||W.startsWith("-"))),G=2,z=J||K.length<=2;return h$(N7,{flexDirection:"column",children:[h$(I6,{children:[X>0?h$(FX,{children:["Added ",h$(I6,{bold:!0,children:X},void 0,!1,void 0,this)," ",X>1?"lines":"line"]},void 0,!0,void 0,this):null,X>0&&Y>0?", ":null,Y>0?h$(FX,{children:["removed ",h$(I6,{bold:!0,children:Y},void 0,!1,void 0,this)," ",Y>1?"lines":"line"]},void 0,!0,void 0,this):null,!z?h$(I6,{color:A().colors.textMuted,children:[" (",K.length," diff lines)"]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this),z&&yH(Z.map((q)=>h$(N7,{flexDirection:"column",paddingLeft:5,children:h$(Y4,{diff:kH(q,$),showHeader:!1,dim:!1,width:Q-12},void 0,!1,void 0,this)},q.newStart,!1,void 0,this)),(q)=>h$(N7,{paddingLeft:5,children:h$(I6,{color:A().colors.textMuted,children:"..."},void 0,!1,void 0,this)},`ellipsis-${q}`,!1,void 0,this))]},void 0,!0,void 0,this)}import{jsxDEV as h2}from"react/jsx-dev-runtime";var Y9={displayName($){let Z=$?.old_string??$?.oldText??"",J=$?.new_string??$?.newText??"";if(Z==="")return"Create";if(J==="")return"Delete";return"Edit"},renderInput($,{verbose:Z}){let J=String($?.file_path??$?.path??"");if(J)return Z?J:P7(process.cwd(),J);if(typeof $?.patch==="string"){let X=[...$.patch.matchAll(/^\*\*\*\s+(?:Update|Add|Delete|Rename)\s+(.+)$/gm)].map((Y)=>Y[1]??"").filter(Boolean).slice(0,3);if(X.length>0)return X.map((Y)=>Z?Y:P7(process.cwd(),Y)).join(", ");return"patch"}return""},renderOutput($,{verbose:Z}){if($==null)return h2(M6,{children:"(No content)"},void 0,!1,void 0,this);if(typeof $==="string")return h2(M6,{children:$},void 0,!1,void 0,this);let J=$;if(J.structuredPatch)return h2(X9,{filePath:J.filePath??J.path,structuredPatch:J.structuredPatch,verbose:Z},void 0,!1,void 0,this);if(J.path!=null){let Q=Z?String(J.path):P7(process.cwd(),String(J.path)),X=J.replacements!=null?Number(J.replacements):void 0,Y=X!=null?` (${X} replacement${X!==1?"s":""})`:"";return h2(UX,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:h2(UX,{flexDirection:"row",children:h2(M6,{children:["Edited ",h2(M6,{bold:!0,children:Q},void 0,!1,void 0,this),Y]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}return h2(M6,{children:JSON.stringify($)},void 0,!1,void 0,this)},renderRejection(){return h2(C,{},void 0,!1,void 0,this)}};import{Box as O$,Text as C6}from"ink";import{extname as OX,relative as DH}from"path";import{highlight as AX,supportsLanguage as vH}from"cli-highlight";import{Text as gH}from"ink";import{useMemo as TH}from"react";import{jsxDEV as VH}from"react/jsx-dev-runtime";function E$({code:$,language:Z}){let J=TH(()=>{try{if(Z&&vH(Z))return AX($,{language:Z});return AX($,{language:"markdown"})}catch{return $}},[$,Z]);return VH(gH,{children:J},void 0,!1,void 0,this)}import{jsxDEV as G1}from"react/jsx-dev-runtime";var A8=3,_7={displayName(){return"Read"},renderInput($,{verbose:Z}){let J=String($?.file_path??$?.path??""),{file_path:Q,path:X,...Y}=$;return[["path",Z?J:DH(process.cwd(),J)],...Object.entries(Y).filter(([G])=>G!=="file_path"&&G!=="path")].map(([G,z])=>`${G}: ${JSON.stringify(z)}`).join(", ")},renderOutput($,{verbose:Z},J){let Q=J??{},X=String(Q.file_path??Q.path??""),Y=X?OX(X).slice(1):"";if($==null)return G1(O$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:G1(O$,{flexDirection:"row",children:G1(C6,{children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string"){let G=$||"(No content)",z=G.split(`
|
|
58
|
-
`);return G1(O$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:G1(O$,{flexDirection:"row",children:G1(O$,{flexDirection:"column",children:[G1(E$,{code:Z?G:D2(z.slice(0,A8).filter((q)=>q.trim()!=="").join(`
|
|
59
|
-
`)),language:Y},void 0,!1,void 0,this),!Z&&z.length>A8&&G1(C6,{color:A().colors.textMuted,children:["... (+",z.length-A8," lines)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}let K=$;if(K.type==="media"||K.type==="image")return G1(O$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:G1(O$,{flexDirection:"row",children:G1(C6,{children:"Read image"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(K.type==="text"&&K.file){let G=K.file,z=G.content||"(No content)";return G1(O$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:G1(O$,{flexDirection:"row",children:G1(O$,{flexDirection:"column",children:[G1(E$,{code:Z?z:D2(z.split(`
|
|
60
|
-
`).slice(0,A8).filter((q)=>q.trim()!=="").join(`
|
|
61
|
-
`)),language:OX(G.filePath).slice(1)},void 0,!1,void 0,this),!Z&&G.numLines>A8&&G1(C6,{color:A().colors.textMuted,children:["... (+",G.numLines-A8," lines)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}return G1(O$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:G1(O$,{flexDirection:"row",children:G1(C6,{children:JSON.stringify($)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},renderRejection(){return G1(C,{},void 0,!1,void 0,this)}};import{Box as K9,Text as O3}from"ink";import{EOL as hH}from"os";import{extname as EH,relative as F7}from"path";import{jsxDEV as j1}from"react/jsx-dev-runtime";var U7=3,A7={displayName:()=>"Write",renderInput($,{verbose:Z}){let J=String($?.file_path??$?.path??"");if(!J)return"";let Q=Z?J:F7(process.cwd(),J),X=typeof $?.content==="string"?` (${$.content.length} bytes)`:"";return Q+X},renderRejection(){return j1(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}){if($==null)return j1(O3,{children:"(No content)"},void 0,!1,void 0,this);if(typeof $==="string")return j1(O3,{children:$},void 0,!1,void 0,this);let J=$;if(J.structuredPatch)return j1(X9,{filePath:J.filePath??J.path,structuredPatch:J.structuredPatch,verbose:Z},void 0,!1,void 0,this);if(J.path!=null&&J.action!=null){let Q=Z?String(J.path):F7(process.cwd(),String(J.path)),X=J.bytesWritten!=null?Number(J.bytesWritten):void 0,Y=String(J.action),K=X!=null?`${X} bytes to `:"";return j1(K9,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:j1(K9,{flexDirection:"row",children:j1(O3,{children:["Wrote ",K,j1(O3,{bold:!0,children:Q},void 0,!1,void 0,this)," (",Y,")"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if(J.type==="create"&&J.filePath!=null){let Q=J.content||"",X=Q||"(No content)",Y=Q.split(hH).length;return j1(K9,{flexDirection:"column",children:[j1(O3,{children:["Wrote ",Y," lines to"," ",j1(O3,{bold:!0,children:Z?J.filePath:F7(process.cwd(),J.filePath)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j1(K9,{flexDirection:"column",paddingLeft:5,children:[j1(E$,{code:Z?X:D2(X.split(`
|
|
62
|
-
`).slice(0,U7).filter((K)=>K.trim()!=="").join(`
|
|
63
|
-
`)),language:EH(J.filePath).slice(1)},void 0,!1,void 0,this),!Z&&Y>U7&&j1(O3,{color:A().colors.textMuted,children:["... (+",Y-U7," lines)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}return j1(O3,{children:JSON.stringify($)},void 0,!1,void 0,this)}};import{Box as z9,Text as K4}from"ink";import{isAbsolute as mH,relative as O7,resolve as dH}from"path";import{Box as jH,Text as cH}from"ink";import{jsxDEV as wX}from"react/jsx-dev-runtime";function G9({costUSD:$,durationMs:Z,debug:J}){if(!J)return null;let Q=(Z/1000).toFixed(1);return wX(jH,{flexDirection:"column",minWidth:23,width:23,children:wX(cH,{dimColor:!0,children:["Cost: $",$.toFixed(4)," (",Q,"s)"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as G$}from"react/jsx-dev-runtime";var LX={displayName(){return"Grep"},renderInput({pattern:$,path:Z,include:J},{verbose:Q}){let X=Z?mH(Z)?Z:dH(process.cwd(),Z):void 0,Y=X?O7(process.cwd(),X):void 0;return`pattern: "${$}"${Y||Q?`, path: "${Q?X:Y}"`:""}${J?`, include: "${J}"`:""}`},renderRejection(){return G$(C,{},void 0,!1,void 0,this)},renderOutput($){let Z=0,J=0,Q=0,X=!1,Y=[];if($!=null&&typeof $==="object"&&!Array.isArray($)){let G=$;if(Array.isArray(G.matches)){let z=new Set;for(let q of G.matches){let W=q,U=typeof W.filePath==="string"?W.filePath:typeof W.file==="string"?W.file:typeof W.path==="string"?W.path:void 0;if(U)z.add(U)}Z=G.matches.length,J=z.size,X=!!G.truncated;for(let q of z)Y.push(O7(process.cwd(),q))}else if(typeof G.numFiles==="number")J=G.numFiles,Q=typeof G.durationMs==="number"?G.durationMs:0}else if(Array.isArray($)){let G=new Set;for(let z of $)if(z!=null&&typeof z==="object"){let q=z,W=typeof q.filePath==="string"?q.filePath:typeof q.file==="string"?q.file:typeof q.path==="string"?q.path:void 0;if(W)G.add(W)}Z=$.length,J=G.size||$.length;for(let z of G)Y.push(O7(process.cwd(),z))}let K=4;return G$(z9,{flexDirection:"column",children:[G$(z9,{flexDirection:"row",children:[G$(K4,{bold:!0,children:[Z," "]},void 0,!0,void 0,this),G$(K4,{children:[Z===1?"match":"matches"," in "]},void 0,!0,void 0,this),G$(K4,{bold:!0,children:[J," "]},void 0,!0,void 0,this),G$(K4,{children:J===1?"file":"files"},void 0,!1,void 0,this),X&&G$(K4,{color:"yellow",children:" (truncated)"},void 0,!1,void 0,this),Q>0&&G$(G9,{costUSD:0,durationMs:Q,debug:!1},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y.slice(0,K).map((G,z)=>G$(z9,{paddingLeft:2,children:G$(K4,{dimColor:!0,children:G},void 0,!1,void 0,this)},z,!1,void 0,this)),Y.length>K&&G$(z9,{paddingLeft:2,children:G$(K4,{dimColor:!0,children:["+",Y.length-K," more files"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}};import{Box as RX,Text as w7}from"ink";import{isAbsolute as pH,relative as xH,resolve as lH}from"path";import{jsxDEV as G4}from"react/jsx-dev-runtime";var BX={displayName(){return"Search"},renderInput({pattern:$,path:Z},{verbose:J}){let Q=Z?pH(Z)?Z:lH(process.cwd(),Z):void 0,X=Q?xH(process.cwd(),Q):void 0;return`pattern: "${$}"${X||J?`, path: "${J?Q:X}"`:""}`},renderRejection(){return G4(C,{},void 0,!1,void 0,this)},renderOutput($){let Z=0,J=0;if(Array.isArray($))Z=$.length;else if(typeof $==="string")try{let Q=JSON.parse($);Z=Q.numFiles??0,J=Q.durationMs??0}catch{Z=0}else if($!=null&&typeof $==="object"){let Q=$;Z=typeof Q.numFiles==="number"?Q.numFiles:0,J=typeof Q.durationMs==="number"?Q.durationMs:0}return G4(RX,{justifyContent:"space-between",width:"100%",children:[G4(RX,{flexDirection:"row",children:[G4(w7,{children:"Found "},void 0,!1,void 0,this),G4(w7,{bold:!0,children:[Z," "]},void 0,!0,void 0,this),G4(w7,{children:Z===0||Z>1?"files":"file"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J>0&&G4(G9,{costUSD:0,durationMs:J,debug:!1},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}};import{Box as E2,Text as z4}from"ink";import{isAbsolute as uH,relative as rH,resolve as aH}from"path";import{jsxDEV as f1}from"react/jsx-dev-runtime";var j2=3,IX=1000,nH=`There are more than ${IX} files in the repository. Use the LS tool (passing a specific path), Bash tool, and other tools to explore nested directories. The first ${IX} files and directories are included below:
|
|
64
|
-
|
|
65
|
-
`,q9={displayName(){return"List"},renderInput({path:$},{verbose:Z}){let J=$?uH($)?$:aH(process.cwd(),$):void 0,Q=J?rH(process.cwd(),J):".";return`path: "${Z?$:Q}"`},renderRejection(){return f1(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}){if(typeof $==="string"){let J=$.replace(nH,"");if(!J)return null;let Q=J.split(`
|
|
66
|
-
`).filter((X)=>X.trim()!=="");return f1(E2,{justifyContent:"space-between",width:"100%",children:f1(E2,{children:f1(E2,{flexDirection:"column",paddingLeft:0,children:[Q.slice(0,Z?void 0:j2).map((X,Y)=>f1(z4,{children:Z?X:b1(X)},Y,!1,void 0,this)),!Z&&Q.length>j2&&f1(z4,{color:A().colors.textMuted,children:["... (+",Q.length-j2," items)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if($!=null&&typeof $==="object"&&!Array.isArray($)){let J=$,Q=Array.isArray(J.entries)?J.entries:[],X=typeof J.total==="number"?J.total:Q.length;if(Q.length===0)return f1(z4,{children:"(empty directory)"},void 0,!1,void 0,this);let Y=Q.map((K)=>{let G=K.type==="dir"||K.type==="directory"?"/":"";return`${K.name}${G}`});return f1(E2,{justifyContent:"space-between",width:"100%",children:f1(E2,{children:f1(E2,{flexDirection:"column",paddingLeft:0,children:[Y.slice(0,Z?void 0:j2).map((K,G)=>f1(z4,{children:Z?K:b1(K)},G,!1,void 0,this)),!Z&&X>j2&&f1(z4,{color:A().colors.textMuted,children:["... (+",X-j2," items)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if(Array.isArray($)){let J=$.map(String);return f1(E2,{justifyContent:"space-between",width:"100%",children:f1(E2,{children:f1(E2,{flexDirection:"column",paddingLeft:0,children:[J.slice(0,Z?void 0:j2).map((Q,X)=>f1(z4,{children:Z?Q:b1(Q)},X,!1,void 0,this)),!Z&&J.length>j2&&f1(z4,{color:A().colors.textMuted,children:["... (+",J.length-j2," items)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}return null}};import{Box as iH,Text as MX}from"ink";import{jsxDEV as O8}from"react/jsx-dev-runtime";var CX={displayName:()=>"mcp",renderInput($){return Object.entries($).map(([Z,J])=>`${Z}: ${JSON.stringify(J)}`).join(", ")},renderRejection(){return O8(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}){if(Array.isArray($))return O8(iH,{flexDirection:"column",children:$.map((Q,X)=>{if(Q.type==="image")return O8(MX,{children:"[Image]"},X,!1,void 0,this);let Y=(Q.text||"").split(`
|
|
67
|
-
`).length;return O8(F8,{content:Q.text||"",lines:Y,verbose:Z},X,!1,void 0,this)})},void 0,!1,void 0,this);if(!$)return O8(MX,{color:A().colors.textMuted,children:"(No content)"},void 0,!1,void 0,this);let J=$.split(`
|
|
68
|
-
`).length;return O8(F8,{content:$,lines:J,verbose:Z},void 0,!1,void 0,this)}};import{Box as oH,Text as fX}from"ink";import{jsxDEV as L7}from"react/jsx-dev-runtime";var SX={displayName:()=>"Think",renderInput($){return $.thought},renderRejection(){return L7(oH,{flexDirection:"row",height:1,overflow:"hidden",children:[L7(fX,{children:[" ","⎿ "]},void 0,!0,void 0,this),L7(fX,{color:A().colors.error,children:"Thought cancelled"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},renderOutput(){return null}};import{Box as sH,Text as tH}from"ink";import{jsxDEV as H9}from"react/jsx-dev-runtime";function eH($){if($==null)return"(No content)";if(typeof $==="string")return $||"(No content)";if(typeof $==="object"){let Z=$;if(typeof Z.formattedContext==="string"&&Z.formattedContext)return Z.formattedContext;if(typeof Z.content==="string")return Z.content||"(No content)";if(Array.isArray(Z.memories)){let J=Z.memories;if(J.length===0)return"(No memories found)";let Q=typeof Z.count==="number"?Z.count:J.length,X=J.map((Y)=>{let K=typeof Y.content==="string"?Y.content:JSON.stringify(Y.content),G=typeof Y.network==="string"?` [${Y.network}]`:"";return`• ${K}${G}`});return`${Q} memories:
|
|
69
|
-
${X.join(`
|
|
70
|
-
`)}`}return JSON.stringify($)}return String($)}function $W({content:$,isEmpty:Z}){let{contentWidth:J}=F3();return H9(sH,{flexDirection:"column",width:"100%",children:H9(tH,{color:Z?A().colors.textMuted:void 0,children:Z?$:W1($,{width:J})},void 0,!1,void 0,this)},void 0,!1,void 0,this)}var W9={displayName(){return"Read Memory"},renderInput($){return Object.entries($).map(([Z,J])=>`${Z}: ${JSON.stringify(J)}`).join(", ")},renderRejection(){return H9(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}={verbose:!1}){let J=eH($),Q=3,X=J.split(`
|
|
71
|
-
`),Y=!Z&&X.length>3,K=D2(Y?[...X.slice(0,3),`… +${X.length-3} lines`].join(`
|
|
72
|
-
`):J);return H9($W,{content:K,isEmpty:J==="(No content)"},void 0,!1,void 0,this)}};import{Box as bX,Text as ZW}from"ink";import{jsxDEV as N9}from"react/jsx-dev-runtime";var f6={displayName(){return"Write Memory"},renderInput($){return Object.entries($).map(([Z,J])=>`${Z}: ${JSON.stringify(J)}`).join(", ")},renderRejection(){return N9(C,{},void 0,!1,void 0,this)},renderOutput(){return N9(bX,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:N9(bX,{flexDirection:"row",children:N9(ZW,{children:"Updated memory"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{EOL as JW}from"os";import{jsxDEV as QW}from"react/jsx-dev-runtime";var R7={displayName(){return"Task"},renderInput($,{verbose:Z}){let J=typeof $.prompt==="string"?$.prompt:typeof $.task==="string"?$.task:"";if(!J)return"";let Q=typeof $.arion==="string"?`@${$.arion} `:"",X=J.split(JW);return Q+W1(!Z&&X.length>1?X[0]+"…":J)},renderRejection(){return QW(C,{},void 0,!1,void 0,this)},renderOutput(){return null}};import{Text as B7}from"ink";import{relative as XW}from"path";import{jsxDEV as P9}from"react/jsx-dev-runtime";var yX={displayName(){return"Read Notebook"},renderInput($,{verbose:Z}){return`notebook_path: ${Z?$.notebook_path:XW(process.cwd(),$.notebook_path)}`},renderRejection(){return P9(C,{},void 0,!1,void 0,this)},renderOutput($){if(!$)return P9(B7,{children:"No cells found in notebook"},void 0,!1,void 0,this);if($.length<1||!$[0])return P9(B7,{children:"No cells found in notebook"},void 0,!1,void 0,this);return P9(B7,{children:["Read ",$.length," cells"]},void 0,!0,void 0,this)}};import{Box as I7,Text as _9}from"ink";import{relative as YW}from"path";import{jsxDEV as c2}from"react/jsx-dev-runtime";var kX={displayName(){return"Edit Notebook"},renderInput($,{verbose:Z}){let J=Z?$.notebook_path:YW(process.cwd(),$.notebook_path??""),Q=$.new_source?$.new_source.slice(0,30)+"…":"";return`${J} cell:${$.cell_number??"?"}${Q?` "${Q}"`:""}`},renderRejection(){return c2(C,{},void 0,!1,void 0,this)},renderOutput($){if(!$||typeof $!=="object")return c2(_9,{children:"(No content)"},void 0,!1,void 0,this);let{cell_number:Z,new_source:J,language:Q,error:X}=$;if(X)return c2(I7,{flexDirection:"column",children:c2(_9,{color:"red",children:X},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Y=2,K=J.split(`
|
|
73
|
-
`),G=K.length>Y,z=G?K.slice(0,Y).join(`
|
|
74
|
-
`):J;return c2(I7,{flexDirection:"column",children:[c2(_9,{children:["Updated cell ",Z,":"]},void 0,!0,void 0,this),c2(I7,{marginLeft:2,children:c2(E$,{code:z,language:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this),G&&c2(_9,{color:"gray",children:["... (+",K.length-Y," lines)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}};import{Box as KW,Text as vX}from"ink";import{jsxDEV as S6}from"react/jsx-dev-runtime";var M7=3,gX={displayName(){return"Architect"},renderInput($){return Object.entries($).map(([Z,J])=>`${Z}: ${JSON.stringify(J)}`).join(", ")},renderOutput($,{verbose:Z}={verbose:!1}){if(!$||!Array.isArray($))return S6(vX,{children:"(No content)"},void 0,!1,void 0,this);let J=$.map((K)=>K.text).join(`
|
|
75
|
-
`),Q=J.split(`
|
|
76
|
-
`),X=!Z&&Q.length>M7,Y=D2(X?Q.slice(0,M7).join(`
|
|
77
|
-
`):J);return S6(KW,{flexDirection:"column",gap:1,children:[S6(E$,{code:Y,language:"markdown"},void 0,!1,void 0,this),X&&S6(vX,{color:A().colors.textMuted,children:["... (+",Q.length-M7," lines)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},renderRejection(){return S6(C,{},void 0,!1,void 0,this)}};import{Text as TX}from"ink";import{jsxDEV as VX}from"react/jsx-dev-runtime";var DX={displayName:()=>"Stickers",renderInput($){if(typeof $.prompt==="string")return $.prompt.length>50?$.prompt.slice(0,50)+"…":$.prompt;return""},renderRejection(){return VX(TX,{children:[" ⎿ ",VX(TX,{color:A().colors.error,children:"No (Sticker request cancelled)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},renderOutput(){return null}};import{Box as b6,Text as w8}from"ink";import{jsxDEV as z$}from"react/jsx-dev-runtime";function hX($,Z=80){return $.length>Z?$.slice(0,Z-1)+"…":$}function GW($){if($<1024)return`${$}B`;if($<1048576)return`${($/1024).toFixed(1)}KB`;return`${($/1048576).toFixed(1)}MB`}function zW({preview:$}){let{contentWidth:Z}=F3(),J=Math.max(Z-4,1);return z$(w8,{color:A().colors.textMuted,dimColor:!0,children:W1($,{width:J})},void 0,!1,void 0,this)}var EX={displayName(){return"Fetch"},renderInput($){if($.url)return hX(String($.url));return Object.entries($).map(([Z,J])=>`${Z}: ${JSON.stringify(J)}`).join(", ")},renderRejection(){return z$(C,{},void 0,!1,void 0,this)},renderOutput($){if(!$||typeof $==="string"){let z=typeof $==="string"?$:"(No content)";return z$(b6,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:z$(b6,{flexDirection:"row",children:z$(w8,{color:A().colors.textMuted,children:z},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}let Z=A(),J=$.finalUrl||"",Q=$.status,X=Q&&Q>=200&&Q<300?Z.colors.success:Q&&Q>=400?Z.colors.error:Z.colors.warning,Y=$.content?$.content.slice(0,200).split(`
|
|
78
|
-
`)[0]:"",K=$.contentBytes?GW($.contentBytes):"",G=$.fromCache?" (cached)":"";return z$(b6,{flexDirection:"column",children:[z$(b6,{flexDirection:"row",children:[Q!=null&&z$(w8,{color:X,bold:!0,children:[Q," "]},void 0,!0,void 0,this),J&&z$(w8,{color:Z.colors.textMuted,children:hX(J,60)},void 0,!1,void 0,this),K&&z$(w8,{color:Z.colors.textMuted,children:[" ","(",K,G,")"]},void 0,!0,void 0,this),$.truncated&&z$(w8,{color:Z.colors.warning,children:" [truncated]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y&&z$(b6,{flexDirection:"row",paddingLeft:4,children:z$(zW,{preview:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}};import{Box as L8,Text as q4}from"ink";import{jsxDEV as c1}from"react/jsx-dev-runtime";function C7($,Z=80){return $.length>Z?$.slice(0,Z-1)+"…":$}function qW({preview:$}){let{contentWidth:Z}=F3(),J=Math.max(Z-4,1);return c1(q4,{color:A().colors.textMuted,dimColor:!0,children:W1($,{width:J})},void 0,!1,void 0,this)}var jX={displayName(){return"Browse"},renderInput($){if($.url)return C7(String($.url));return Object.entries($).map(([Z,J])=>`${Z}: ${JSON.stringify(J)}`).join(", ")},renderRejection(){return c1(C,{},void 0,!1,void 0,this)},renderOutput($){if(!$||typeof $==="string"){let K=typeof $==="string"?$:"(No content)";return c1(L8,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:c1(L8,{flexDirection:"row",children:c1(q4,{color:A().colors.textMuted,children:K},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}let Z=A(),J=$.finalUrl||$.url||"",Q=$.title||"",X=$.content?$.content.slice(0,200).split(`
|
|
79
|
-
`)[0]:"",Y=$.fromCache?" (cached)":"";return c1(L8,{flexDirection:"column",children:[c1(L8,{flexDirection:"row",children:[Q?c1(q4,{bold:!0,children:Q},void 0,!1,void 0,this):c1(q4,{color:Z.colors.textMuted,children:C7(J,60)},void 0,!1,void 0,this),Y&&c1(q4,{color:Z.colors.textMuted,children:Y},void 0,!1,void 0,this),$.truncated&&c1(q4,{color:Z.colors.warning,children:" [truncated]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q&&J&&c1(L8,{flexDirection:"row",paddingLeft:4,children:c1(q4,{color:Z.colors.textMuted,children:C7(J,60)},void 0,!1,void 0,this)},void 0,!1,void 0,this),X&&c1(L8,{flexDirection:"row",paddingLeft:4,children:c1(qW,{preview:X},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}};import{Box as R8,Text as w3}from"ink";import{jsxDEV as m1}from"react/jsx-dev-runtime";function HW($){try{return new URL($).hostname.replace(/^www\./,"")}catch{return $.length>50?$.slice(0,47)+"…":$}}var cX={displayName(){return"Search"},renderInput($){if($.query)return`"${$.query}"`;return Object.entries($).map(([Z,J])=>`${Z}: ${JSON.stringify(J)}`).join(", ")},renderRejection(){return m1(C,{},void 0,!1,void 0,this)},renderOutput($){if(!$||typeof $==="string"){let K=typeof $==="string"?$:"(No results)";return m1(R8,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:m1(R8,{flexDirection:"row",children:m1(w3,{color:A().colors.textMuted,children:K},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}let Z=A(),J=$.results||[],Q=$.query||"",X=2,Y=J.slice(0,X);return m1(R8,{flexDirection:"column",children:[m1(R8,{flexDirection:"row",children:[m1(w3,{children:"Found "},void 0,!1,void 0,this),m1(w3,{bold:!0,children:[J.length," "]},void 0,!0,void 0,this),m1(w3,{children:J.length===1?"result":"results"},void 0,!1,void 0,this),Q&&m1(w3,{color:Z.colors.textMuted,children:[" for '",Q,"'"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Y.map((K,G)=>m1(R8,{flexDirection:"row",paddingLeft:4,children:[m1(w3,{bold:!0,children:K.title.length>60?K.title.slice(0,57)+"…":K.title},void 0,!1,void 0,this),m1(w3,{color:Z.colors.textMuted,children:[" (",HW(K.url),")"]},void 0,!0,void 0,this)]},G,!0,void 0,this)),J.length>X&&m1(R8,{flexDirection:"row",paddingLeft:4,children:m1(w3,{color:Z.colors.textMuted,children:["+",J.length-X," more"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}};import{Box as B8,Text as f7}from"ink";import{jsxDEV as W2}from"react/jsx-dev-runtime";var mX={displayName(){return"Learn"},renderInput($,Z){let J;if(typeof $.source==="string")J=$.source;else if($.source&&typeof $.source==="object")J=$.source.type||$.source.command||$.source.path||"unknown";else J="unknown";let Q=$.name??"";return Q?`${J}: ${Q}`:J},renderRejection(){return W2(C,{},void 0,!1,void 0,this)},renderOutput($){if($==null)return W2(B8,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:W2(B8,{flexDirection:"row",children:W2(f7,{children:"Learned"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string")return W2(B8,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:W2(B8,{flexDirection:"row",children:W2(f7,{children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Z=$,J=Z.name??"unknown",Q=Z.type??"",X=Q?` ${Q}`:"";return W2(B8,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:W2(B8,{flexDirection:"row",children:W2(f7,{children:["Learned",X," ",J]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as F9,Text as dX}from"ink";import{jsxDEV as H4}from"react/jsx-dev-runtime";var pX={displayName(){return"Learn Tool"},renderInput($,Z){return $.name??"tool"},renderRejection(){return H4(C,{},void 0,!1,void 0,this)},renderOutput($){if(!$||typeof $!=="object")return H4(F9,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:H4(F9,{flexDirection:"row",children:H4(dX,{children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Z=$.name??"unknown";return H4(F9,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:H4(F9,{flexDirection:"row",children:H4(dX,{children:["Learned tool ",Z]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as U9,Text as xX}from"ink";import{jsxDEV as W4}from"react/jsx-dev-runtime";var lX={displayName(){return"Learn Skill"},renderInput($,Z){return $.name??"skill"},renderRejection(){return W4(C,{},void 0,!1,void 0,this)},renderOutput($){if(!$||typeof $!=="object")return W4(U9,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:W4(U9,{flexDirection:"row",children:W4(xX,{children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Z=$.name??"unknown";return W4(U9,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:W4(U9,{flexDirection:"row",children:W4(xX,{children:["Learned skill ",Z]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as I8,Text as S7}from"ink";import{basename as WW}from"path";import{jsxDEV as N2}from"react/jsx-dev-runtime";var uX={displayName(){return"Create Tool"},renderInput($,Z){return $.name??"tool"},renderRejection(){return N2(C,{},void 0,!1,void 0,this)},renderOutput($){if($==null)return N2(I8,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:N2(I8,{flexDirection:"row",children:N2(S7,{children:"Created tool"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string")return N2(I8,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:N2(I8,{flexDirection:"row",children:N2(S7,{children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Z=$,J=Z.name??(typeof Z.scriptPath==="string"?WW(Z.scriptPath):"unknown");return N2(I8,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:N2(I8,{flexDirection:"row",children:N2(S7,{children:["Created tool ",J]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as A9,Text as rX}from"ink";import{jsxDEV as N4}from"react/jsx-dev-runtime";var aX={displayName(){return"Create Skill"},renderInput($,Z){return $.name??"skill"},renderRejection(){return N4(C,{},void 0,!1,void 0,this)},renderOutput($){if(!$||typeof $!=="object")return N4(A9,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:N4(A9,{flexDirection:"row",children:N4(rX,{children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Z=$.name??"unknown";return N4(A9,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:N4(A9,{flexDirection:"row",children:N4(rX,{children:["Created skill ",Z]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as O9,Text as nX}from"ink";import{jsxDEV as P4}from"react/jsx-dev-runtime";var iX={displayName(){return"Use Skill"},renderInput($,Z){return $.name??"skill"},renderRejection(){return P4(C,{},void 0,!1,void 0,this)},renderOutput($){if(!$||typeof $!=="object")return P4(O9,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:P4(O9,{flexDirection:"row",children:P4(nX,{children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Z=$.skill?.name??"unknown";return P4(O9,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:P4(O9,{flexDirection:"row",children:P4(nX,{children:["Loaded skill ",Z]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as _4,Text as w9}from"ink";import{jsxDEV as w$}from"react/jsx-dev-runtime";function NW($){let Z=A();switch($){case"active":case"in_progress":return Z.colors.success;case"blocked":return Z.colors.warning;case"done":case"closed":return Z.colors.textMuted;default:return Z.colors.text}}var oX={displayName(){return"Quest List"},renderInput($){if($.status)return`status: ${$.status}`;return"all quests"},renderRejection(){return w$(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}){let J=$?.quests??[],Q=$?.count??J.length;if(!Z)return w$(_4,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:w$(_4,{flexDirection:"row",children:w$(w9,{children:[Q," quest",Q!==1?"s":""]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(J.length===0)return w$(_4,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:w$(_4,{flexDirection:"row",children:w$(w9,{children:"0 quests"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return w$(_4,{flexDirection:"column",children:[w$(_4,{children:w$(w9,{children:[Q," quest",Q!==1?"s":""]},void 0,!0,void 0,this)},void 0,!1,void 0,this),J.map((X)=>w$(_4,{flexDirection:"row",paddingLeft:4,children:w$(w9,{color:NW(X.status),children:["P",X.priority," [",X.status,"] ",X.id," ",X.title]},void 0,!0,void 0,this)},X.id,!1,void 0,this))]},void 0,!0,void 0,this)}};import{Box as y6,Text as k6}from"ink";import{jsxDEV as j$}from"react/jsx-dev-runtime";function PW($){let Z=A();switch($){case"created":return Z.colors.success;case"updated":return Z.colors.info;case"failed":return Z.colors.error;default:return Z.colors.text}}var sX={displayName(){return"Quest Update"},renderInput($){if($.quests&&Array.isArray($.quests)){let J=$.quests.length;return`${J} quest${J!==1?"s":""}`}let Z=[];if($.action)Z.push($.action);if($.title)Z.push($.title);if($.id)Z.push($.id);return Z.join(" ")||"quest update"},renderRejection(){return j$(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}){let J=[];if($!=null&&typeof $==="object"){let z=$;if(Array.isArray(z.quests))J=z.quests}let Q=J.filter((z)=>z.action==="created").length,X=J.filter((z)=>z.action==="updated").length,Y=J.filter((z)=>z.action==="failed").length,K=A(),G=[];if(Q>0)G.push(`${Q} created`);if(X>0)G.push(`${X} updated`);if(Y>0)G.push(`${Y} failed`);if(G.length===0)G.push("0 changes");if(!Z)return j$(y6,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:j$(y6,{flexDirection:"row",children:G.map((z,q)=>{let W=z.includes("created")?K.colors.success:z.includes("updated")?K.colors.info:z.includes("failed")?K.colors.error:K.colors.text;return j$(k6,{children:[q>0?", ":"",j$(k6,{color:W,children:z},void 0,!1,void 0,this)]},q,!0,void 0,this)})},void 0,!1,void 0,this)},void 0,!1,void 0,this);return j$(y6,{flexDirection:"column",children:[j$(y6,{children:G.map((z,q)=>{let W=z.includes("created")?K.colors.success:z.includes("updated")?K.colors.info:z.includes("failed")?K.colors.error:K.colors.text;return j$(k6,{children:[q>0?", ":"",j$(k6,{color:W,children:z},void 0,!1,void 0,this)]},q,!0,void 0,this)})},void 0,!1,void 0,this),J.map((z)=>j$(y6,{flexDirection:"row",paddingLeft:4,children:j$(k6,{color:PW(z.action),children:["[",z.action,"] ",z.id," ",z.title,z.error?` -- ${z.error}`:""]},void 0,!0,void 0,this)},z.id,!1,void 0,this))]},void 0,!0,void 0,this)}};import{Box as F4,Text as L9}from"ink";import{jsxDEV as L$}from"react/jsx-dev-runtime";var tX=120,eX={displayName(){return"Ask User"},renderInput($){let Z;if(typeof $.question==="string")Z=$.question;else{let J=$.questions?.[0];Z=typeof J==="string"?J:typeof J?.question==="string"?J.question:"asking user..."}if(Z.length>tX)return Z.slice(0,tX)+"…";return Z},renderRejection(){return L$(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}){if(typeof $==="string")return L$(F4,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:L$(F4,{flexDirection:"row",children:L$(L9,{children:"Received answer"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let J=$?.answers??[],Q=J.length;if(!Z)return L$(F4,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:L$(F4,{flexDirection:"row",children:L$(L9,{children:["Received ",Q," answer",Q!==1?"s":""]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return L$(F4,{flexDirection:"column",children:[L$(F4,{children:L$(L9,{children:["Received ",Q," answer",Q!==1?"s":""]},void 0,!0,void 0,this)},void 0,!1,void 0,this),J.map((X,Y)=>L$(F4,{flexDirection:"row",paddingLeft:4,children:L$(L9,{children:typeof X==="string"?X:X?.answer??JSON.stringify(X)},void 0,!1,void 0,this)},Y,!1,void 0,this))]},void 0,!0,void 0,this)}};import{Box as M8,Text as b7}from"ink";import{jsxDEV as P2}from"react/jsx-dev-runtime";var $Y={displayName(){return"Hatch Arion"},renderInput($,Z){if($.name)return`${$.name}`;return Object.entries($).map(([J,Q])=>`${J}: ${JSON.stringify(Q)}`).join(", ")},renderRejection(){return P2(C,{},void 0,!1,void 0,this)},renderOutput($,Z){let J=A();if(!$)return P2(M8,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:P2(M8,{flexDirection:"row",children:P2(b7,{color:J.colors.textMuted,children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string")return P2(M8,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:P2(M8,{flexDirection:"row",children:P2(b7,{color:J.colors.success,children:$.includes("hatched")?$:`${$} has hatched!`},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Q=$.emoji||"",X=$.name||"Arion";return P2(M8,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:P2(M8,{flexDirection:"row",children:P2(b7,{color:J.colors.success,children:[Q,Q?" ":"",X," has hatched!"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as R9,Text as ZY}from"ink";import{jsxDEV as U4}from"react/jsx-dev-runtime";var JY={displayName(){return"Rest Arion"},renderInput($,Z){if($.name)return`${$.name}`;return Object.entries($).map(([J,Q])=>`${J}: ${JSON.stringify(Q)}`).join(", ")},renderRejection(){return U4(C,{},void 0,!1,void 0,this)},renderOutput($,Z){let J=A();if($==null)return U4(R9,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:U4(R9,{flexDirection:"row",children:U4(ZY,{color:J.colors.textMuted,children:"Arion is now resting"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Q=typeof $==="string"?$:$.message||`${$.name||"Arion"} is now resting`;return U4(R9,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:U4(R9,{flexDirection:"row",children:U4(ZY,{color:J.colors.textMuted,children:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as B9,Text as QY}from"ink";import{jsxDEV as A4}from"react/jsx-dev-runtime";var XY={displayName(){return"Wake Arion"},renderInput($,Z){if($.name)return`${$.name}`;return Object.entries($).map(([J,Q])=>`${J}: ${JSON.stringify(Q)}`).join(", ")},renderRejection(){return A4(C,{},void 0,!1,void 0,this)},renderOutput($,Z){let J=A();if($==null)return A4(B9,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:A4(B9,{flexDirection:"row",children:A4(QY,{color:J.colors.success,children:"Arion is now awake"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Q=typeof $==="string"?$:$.message||`${$.name||"Arion"} is now awake`;return A4(B9,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:A4(B9,{flexDirection:"row",children:A4(QY,{color:J.colors.success,children:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as I9,Text as YY}from"ink";import{jsxDEV as O4}from"react/jsx-dev-runtime";var KY={displayName(){return"Retire Arion"},renderInput($,Z){if($.name)return`${$.name}`;return Object.entries($).map(([J,Q])=>`${J}: ${JSON.stringify(Q)}`).join(", ")},renderRejection(){return O4(C,{},void 0,!1,void 0,this)},renderOutput($,Z){let J=A();if($==null)return O4(I9,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:O4(I9,{flexDirection:"row",children:O4(YY,{color:J.colors.warning,children:"Arion has been retired"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Q=typeof $==="string"?$:$.message||`${$.name||"Arion"} has been retired`;return O4(I9,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:O4(I9,{flexDirection:"row",children:O4(YY,{color:J.colors.warning,children:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as C8,Text as M9}from"ink";import{jsxDEV as c$}from"react/jsx-dev-runtime";var GY={displayName(){return"Spawn Worker"},renderInput($,Z){if($.task)return`${$.task}`;return Object.entries($).map(([J,Q])=>`${J}: ${JSON.stringify(Q)}`).join(", ")},renderRejection(){return c$(C,{},void 0,!1,void 0,this)},renderOutput($,Z){let J=A();if(!$)return c$(C8,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:c$(C8,{flexDirection:"row",children:c$(M9,{color:J.colors.textMuted,children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string")return c$(C8,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:c$(C8,{flexDirection:"row",children:c$(M9,{children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Q=$.id||"unknown";return c$(C8,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:c$(C8,{flexDirection:"row",children:[c$(M9,{children:"Spawned worker "},void 0,!1,void 0,this),c$(M9,{bold:!0,children:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}};import{Box as L3,Text as f8}from"ink";import{jsxDEV as d1}from"react/jsx-dev-runtime";function _W($,Z){switch($){case"completed":return Z.colors.success;case"running":return Z.colors.info;case"failed":return Z.colors.error;default:return Z.colors.textMuted}}var zY={displayName(){return"Check Delegation"},renderInput($,Z){if($.id)return`${$.id}`;return Object.entries($).map(([J,Q])=>`${J}: ${JSON.stringify(Q)}`).join(", ")},renderRejection(){return d1(C,{},void 0,!1,void 0,this)},renderOutput($,Z){let J=A();if(!$)return d1(L3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:d1(L3,{flexDirection:"row",children:d1(f8,{color:J.colors.textMuted,children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string")return d1(L3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:d1(L3,{flexDirection:"row",children:d1(f8,{children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let{id:Q,status:X,result:Y,error:K}=$,G=_W(X,J);return d1(L3,{flexDirection:"column",children:[d1(L3,{flexDirection:"row",children:[Q&&d1(f8,{bold:!0,children:[Q," "]},void 0,!0,void 0,this),d1(f8,{color:G,children:X||"unknown"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X==="completed"&&Y&&d1(L3,{flexDirection:"row",paddingLeft:4,children:d1(f8,{color:J.colors.textMuted,children:b1(Y)},void 0,!1,void 0,this)},void 0,!1,void 0,this),X==="failed"&&K&&d1(L3,{flexDirection:"row",paddingLeft:4,children:d1(f8,{color:J.colors.error,children:b1(K)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}};import{Box as R3,Text as w4}from"ink";import{jsxDEV as y1}from"react/jsx-dev-runtime";function C9($,Z=60){return $.length>Z?$.slice(0,Z-1)+"…":$}function FW($){let Z=$.action||"unknown";switch(Z){case"launch":return $.url?`launch and navigate to ${C9(String($.url))}`:"launch";case"navigate":return $.url?`navigate to ${C9(String($.url))}`:"navigate";case"click":return $.selector?`click ${$.selector}`:"click";case"type":return $.selector?`type into ${$.selector}`:"type";default:return Z}}var qY={displayName(){return"Browser"},renderInput($,Z){return FW($)},renderRejection(){return y1(C,{},void 0,!1,void 0,this)},renderOutput($,Z){let J=A();if(!$)return y1(R3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:y1(R3,{flexDirection:"row",children:y1(w4,{color:J.colors.textMuted,children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string")return y1(R3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:y1(R3,{flexDirection:"row",children:y1(w4,{children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Q=$.title||"",X=$.url||"";return y1(R3,{flexDirection:"column",children:[y1(R3,{flexDirection:"row",children:Q?y1(w4,{bold:!0,children:Q},void 0,!1,void 0,this):X?y1(w4,{color:J.colors.textMuted,children:C9(X)},void 0,!1,void 0,this):y1(w4,{color:J.colors.success,children:"Done"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q&&X&&y1(R3,{flexDirection:"row",paddingLeft:4,children:y1(w4,{color:J.colors.textMuted,children:C9(X)},void 0,!1,void 0,this)},void 0,!1,void 0,this),$.error&&y1(R3,{flexDirection:"row",paddingLeft:4,children:y1(w4,{color:J.colors.error,children:$.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}};import{Box as p1,Text as q$}from"ink";import{jsxDEV as I0}from"react/jsx-dev-runtime";function UW($){let Z=$.action||"unknown";switch(Z){case"spawn":return $.command?`spawn: ${$.command}`:"spawn";case"read":return $.pid!=null?`read pid ${$.pid}`:"read";case"write":return $.pid!=null?`write to pid ${$.pid}`:"write";case"kill":return $.pid!=null?`kill pid ${$.pid}`:"kill";case"list":return"list processes";default:return Z}}var HY={displayName(){return"Process"},renderInput($,Z){return UW($)},renderRejection(){return I0(C,{},void 0,!1,void 0,this)},renderOutput($,Z){let J=A();if(!$)return I0(p1,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:I0(p1,{flexDirection:"row",children:I0(q$,{color:J.colors.textMuted,children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string")return I0(p1,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:I0(p1,{flexDirection:"row",children:I0(q$,{children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if($.action==="spawn"||$.pid!=null&&!$.output&&!$.sessions)return I0(p1,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:I0(p1,{flexDirection:"row",children:[I0(q$,{children:"Spawned process "},void 0,!1,void 0,this),I0(q$,{bold:!0,children:$.pid},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);if($.action==="read"||$.output!=null){let Q=($.output||"").split(`
|
|
80
|
-
`),X=Q.length>3?Q.slice(0,3).map(b1).join(`
|
|
81
|
-
`)+`
|
|
82
|
-
... +${Q.length-3} more lines`:($.output||"").split(`
|
|
83
|
-
`).map(b1).join(`
|
|
84
|
-
`);return I0(p1,{flexDirection:"column",children:I0(p1,{flexDirection:"row",children:I0(q$,{children:X},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if($.action==="list"||$.sessions){let Q=$.sessions||[];if(Q.length===0)return I0(p1,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:I0(p1,{flexDirection:"row",children:I0(q$,{color:J.colors.textMuted,children:"No active processes"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let X=2;return I0(p1,{flexDirection:"column",children:[I0(p1,{flexDirection:"row",children:[I0(q$,{bold:!0,children:[Q.length," "]},void 0,!0,void 0,this),I0(q$,{children:Q.length===1?"process":"processes"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q.slice(0,X).map((Y,K)=>I0(p1,{flexDirection:"row",paddingLeft:4,children:[I0(q$,{bold:!0,children:[Y.pid," "]},void 0,!0,void 0,this),I0(q$,{children:[Y.command||""," "]},void 0,!0,void 0,this),I0(q$,{color:Y.status==="running"?J.colors.success:J.colors.textMuted,children:Y.status||""},void 0,!1,void 0,this)]},K,!0,void 0,this)),Q.length>X&&I0(q$,{color:J.colors.textMuted,children:["... (+",Q.length-X," more)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}return I0(p1,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:I0(p1,{flexDirection:"row",children:I0(q$,{children:JSON.stringify($)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as y7,Text as S8}from"ink";import{jsxDEV as _2}from"react/jsx-dev-runtime";var WY={displayName(){return"Search"},renderInput($,{verbose:Z}){let J=$.query;if(!J)return Object.entries($).filter(([,X])=>X!==void 0).map(([X,Y])=>`${X}: ${JSON.stringify(Y)}`).join(", ");let Q=[`"${J}"`];if(Z&&$.sources?.length)Q.push(`sources: [${$.sources.join(", ")}]`);return Q.join(" ")},renderRejection(){return _2(C,{},void 0,!1,void 0,this)},renderOutput($){let Z=A();if(!$||typeof $==="string"){let G=typeof $==="string"?$:"(No results)";return _2(y7,{flexDirection:"row",width:"100%",children:_2(S8,{color:Z.colors.textMuted,children:G},void 0,!1,void 0,this)},void 0,!1,void 0,this)}let J=$.results??[],Q=$.platform,X=J.length===0?null:null,Y=new Map;for(let G of J)Y.set(G.source,(Y.get(G.source)??0)+1);let K=[...Y.entries()].map(([G,z])=>`${z} ${G}`).join(", ");return _2(y7,{flexDirection:"column",children:_2(y7,{flexDirection:"row",children:[_2(S8,{children:"Found "},void 0,!1,void 0,this),_2(S8,{bold:!0,children:[J.length," "]},void 0,!0,void 0,this),_2(S8,{children:J.length===1?"result":"results"},void 0,!1,void 0,this),Q&&_2(S8,{color:Z.colors.textMuted,children:[" ","on ",Q.os,"/",Q.arch]},void 0,!0,void 0,this),K&&J.length>0&&_2(S8,{color:Z.colors.textMuted,children:[" (",K,")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}};import{Box as k1,Text as r0}from"ink";import{jsxDEV as Y0}from"react/jsx-dev-runtime";function AW($){if($<60)return`${$}s`;if($<3600)return`${Math.floor($/60)}m`;if($<86400)return`${Math.floor($/3600)}h ${Math.floor($%3600/60)}m`;return`${Math.floor($/86400)}d`}var NY={displayName(){return"Self Diagnose"},renderInput($){let Z=[];if($.focus)Z.push(`focus: ${$.focus}`);if($.sections?.length)Z.push(`${$.sections.length} sections`);else Z.push("all sections");return Z.join(", ")},renderRejection(){return Y0(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}){if(!$||typeof $!=="object")return null;let J=$,Q=J._meta,X=A();if(!Z){let Y=[];if(Q)Y.push(`${Q.sections_returned.length}/6 sections · ${Q.elapsed_ms}ms`);if(Q?.errors.length)Y.push(`${Q.errors.length} errors`);let K=J.errors&&J.errors.length>0||J.crashes&&J.crashes.length>0||J.runtime&&(J.runtime.socket_dirs>100||J.runtime.relaunch_pending);return Y0(r0,{color:K?X.colors.warning:X.colors.success,children:Y.join(" · ")||"done"},void 0,!1,void 0,this)}return Y0(k1,{flexDirection:"column",children:[J.runtime&&Y0(k1,{paddingLeft:2,flexDirection:"column",children:[Y0(r0,{bold:!0,children:"runtime"},void 0,!1,void 0,this),Y0(k1,{paddingLeft:2,children:Y0(r0,{children:["PID ",J.runtime.pid," · up ",AW(J.runtime.uptime_s)," · heap"," ",J.runtime.heap_mb,"MB · RSS ",J.runtime.rss_mb,"MB"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),(J.runtime.socket_dirs>100||J.runtime.relaunch_pending)&&Y0(k1,{paddingLeft:2,children:[J.runtime.socket_dirs>100&&Y0(r0,{color:X.colors.error,children:["⚠ socket leak: ",J.runtime.socket_dirs," dirs in sock/"]},void 0,!0,void 0,this),J.runtime.relaunch_pending&&Y0(r0,{color:X.colors.error,children:"⚠ stuck restart pending"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),J.errors!==void 0&&Y0(k1,{paddingLeft:2,flexDirection:"column",children:[Y0(r0,{bold:!0,color:J.errors&&J.errors.length>0?X.colors.error:X.colors.success,children:"errors"},void 0,!1,void 0,this),Y0(k1,{paddingLeft:2,flexDirection:"column",children:J.errors&&J.errors.length>0?J.errors.map((Y,K)=>Y0(r0,{color:X.colors.error,children:["[",Y.source,"] ",Y.timestamp?Y.timestamp.slice(11,19):"?"," ",Y.severity," ",Y.category,": ",Y.message.slice(0,80)]},K,!0,void 0,this)):Y0(r0,{color:X.colors.success,children:"none"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J.crashes!==void 0&&Y0(k1,{paddingLeft:2,flexDirection:"column",children:[Y0(r0,{bold:!0,color:J.crashes&&J.crashes.length>0?X.colors.error:X.colors.success,children:"crashes"},void 0,!1,void 0,this),Y0(k1,{paddingLeft:2,flexDirection:"column",children:J.crashes&&J.crashes.length>0?J.crashes.map((Y,K)=>Y0(r0,{color:X.colors.error,children:[Y.file," ",Y.timestamp?Y.timestamp.slice(0,19):""," ",Y.error_message??""]},K,!0,void 0,this)):Y0(r0,{color:X.colors.success,children:"none"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J.databases&&Y0(k1,{paddingLeft:2,flexDirection:"column",children:[Y0(r0,{bold:!0,children:"databases"},void 0,!1,void 0,this),Y0(k1,{paddingLeft:2,flexDirection:"column",children:J.databases.map((Y,K)=>{let G=Y.wal_mb&&parseFloat(Y.wal_mb)>1;return Y0(r0,{color:G?X.colors.warning:void 0,children:[Y.name,": ",Y.size_mb,"MB",Y.wal_mb?` (WAL ${Y.wal_mb}MB${G?" ⚠":""})`:"",Y.schema_version!==void 0?` schema:v${Y.schema_version}`:""]},K,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J.daemon&&J.daemon.length>0&&Y0(k1,{paddingLeft:2,flexDirection:"column",children:[Y0(r0,{bold:!0,children:"daemon"},void 0,!1,void 0,this),Y0(k1,{paddingLeft:2,flexDirection:"column",children:J.daemon.map((Y,K)=>Y0(r0,{children:[Y.source,": ",Y.entries.length," entries"]},K,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J.network&&Y0(k1,{paddingLeft:2,flexDirection:"column",children:[Y0(r0,{bold:!0,children:"network"},void 0,!1,void 0,this),Y0(k1,{paddingLeft:2,flexDirection:"column",children:[Y0(r0,{children:["node: ",J.network.display_name??"unknown"," · port"," ",J.network.listen_port??"?"," · endpoint"," ",J.network.external_endpoint??"none"]},void 0,!0,void 0,this),Y0(r0,{children:["peers: ",J.network.peer_count," · TLS:"," ",J.network.tls_certs_present?"✓":"✗"," · trusted CAs:"," ",J.network.trusted_cas]},void 0,!0,void 0,this),J.network.peers.length>0&&J.network.peers.map((Y,K)=>Y0(r0,{color:Y.status==="connected"?X.colors.success:X.colors.warning,children:[Y.name||Y.node_id.slice(0,8),": ",Y.status]},K,!0,void 0,this)),J.network.recent_diagnostics.length>0&&Y0(r0,{dimColor:!0,children:[J.network.recent_diagnostics.length," recent diagnostic events"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Q?.errors&&Q.errors.length>0&&Y0(k1,{paddingLeft:2,flexDirection:"column",children:[Y0(r0,{bold:!0,color:X.colors.error,children:"collection errors"},void 0,!1,void 0,this),Q.errors.map((Y,K)=>Y0(k1,{paddingLeft:2,children:Y0(r0,{color:X.colors.error,children:Y},void 0,!1,void 0,this)},K,!1,void 0,this))]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}};import{Box as m2,Text as x1}from"ink";import{relative as PY}from"path";import{jsxDEV as g0}from"react/jsx-dev-runtime";function OW($){return"counts"in $&&Array.isArray($.counts)}function wW($){let Z=[];if(Z.push(`"${$.pattern}"`),$.file_type)Z.push(`-t ${$.file_type}`);if($.path)Z.push($.path);return Z.join(" ")}var _Y={displayName(){return"Ripgrep"},renderInput($,{verbose:Z}={}){let J=wW($),Q=Z&&$.extra_args&&$.extra_args.length>0?` [${$.extra_args.join(" ")}]`:"";return`${J}${Q}`},renderRejection(){return g0(C,{},void 0,!1,void 0,this)},renderOutput($){let Z=A();if(!$||typeof $!=="object")return g0(x1,{color:Z.colors.textMuted,children:String($??"No result")},void 0,!1,void 0,this);if(!("counts"in $)&&!("matches"in $)){let G=$.message;return g0(x1,{color:Z.colors.textMuted,children:typeof G==="string"?G:"Search complete"},void 0,!1,void 0,this)}if(OW($)){let{counts:G,total:z}=$,q=Math.min(5,G.length),W=G.length-q;return g0(m2,{flexDirection:"column",children:[g0(m2,{flexDirection:"row",children:[g0(x1,{bold:!0,children:z},void 0,!1,void 0,this),g0(x1,{children:" matches across "},void 0,!1,void 0,this),g0(x1,{bold:!0,children:G.length},void 0,!1,void 0,this),g0(x1,{children:" files"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.slice(0,q).map((U,F)=>g0(m2,{paddingLeft:2,children:g0(x1,{color:Z.colors.textMuted,children:[PY(process.cwd(),U.file),": ",U.count]},void 0,!0,void 0,this)},F,!1,void 0,this)),W>0&&g0(m2,{paddingLeft:2,children:g0(x1,{color:Z.colors.textMuted,children:["+",W," more files"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}let{matches:J}=$;if(J.length===0)return g0(m2,{children:g0(x1,{color:Z.colors.textMuted,children:"No matches found"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Q=new Map;for(let G of J){if(!Q.has(G.file))Q.set(G.file,[]);Q.get(G.file).push(G)}let X=Array.from(Q.entries()),Y=Math.min(3,X.length),K=X.length-Y;return g0(m2,{flexDirection:"column",children:[g0(m2,{flexDirection:"row",children:[g0(x1,{bold:!0,children:J.length},void 0,!1,void 0,this),g0(x1,{children:" matches in "},void 0,!1,void 0,this),g0(x1,{bold:!0,children:X.length},void 0,!1,void 0,this),g0(x1,{children:" files"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X.slice(0,Y).map(([G,z],q)=>g0(m2,{paddingLeft:2,children:g0(x1,{color:Z.colors.textMuted,children:[PY(process.cwd(),G),": ",z.length]},void 0,!0,void 0,this)},q,!1,void 0,this)),K>0&&g0(m2,{paddingLeft:2,children:g0(x1,{color:Z.colors.textMuted,children:["+",K," more files"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}};import{Box as d2,Text as l1}from"ink";import{relative as FY}from"path";import{jsxDEV as T0}from"react/jsx-dev-runtime";function LW($){return"counts"in $&&Array.isArray($.counts)}function RW($){let Z=[];if(Z.push(`"${$.pattern}"`),$.fuzzy!==void 0&&$.fuzzy!==!1)if(typeof $.fuzzy==="number")Z.push(`fuzzy:${$.fuzzy}`);else Z.push("fuzzy");if($.bool)Z.push("bool");if($.file_type)Z.push(`-t ${$.file_type}`);if($.path&&$.path!==".")Z.push($.path);return Z.join(" ")}var UY={displayName(){return"Ugrep"},renderInput($,{verbose:Z}={}){let J=RW($),Q=[];if(Z){if($.ignore_case)Q.push("-i");if($.smart_case)Q.push("-j");if($.fixed_strings)Q.push("-F");if($.word_regexp)Q.push("-w");if($.files_only)Q.push("-l");if($.count)Q.push("-c");if($.context!==void 0)Q.push(`-C ${$.context}`);if($.neg_pattern)Q.push(`-N "${$.neg_pattern}"`);if($.decompress)Q.push("-z");if($.glob)Q.push(`-g "${$.glob}"`);if($.extra_args&&$.extra_args.length>0)Q.push(`[${$.extra_args.join(" ")}]`)}return Q.length>0?`${J} ${Q.join(" ")}`:J},renderRejection(){return T0(C,{},void 0,!1,void 0,this)},renderOutput($){let Z=A();if(!$||typeof $!=="object")return T0(l1,{color:Z.colors.textMuted,children:String($??"No result")},void 0,!1,void 0,this);if(!("counts"in $)&&!("matches"in $)){let G=$.message;return T0(l1,{color:Z.colors.textMuted,children:typeof G==="string"?G:"Search complete"},void 0,!1,void 0,this)}if(LW($)){let{counts:G,total:z}=$,q=Math.min(5,G.length),W=G.length-q;return T0(d2,{flexDirection:"column",children:[T0(d2,{flexDirection:"row",children:[T0(l1,{bold:!0,children:z},void 0,!1,void 0,this),T0(l1,{children:" matches across "},void 0,!1,void 0,this),T0(l1,{bold:!0,children:G.length},void 0,!1,void 0,this),T0(l1,{children:" files"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.slice(0,q).map((U,F)=>T0(d2,{paddingLeft:2,children:T0(l1,{color:Z.colors.textMuted,children:[FY(process.cwd(),U.file),": ",U.count]},void 0,!0,void 0,this)},F,!1,void 0,this)),W>0&&T0(d2,{paddingLeft:2,children:T0(l1,{color:Z.colors.textMuted,children:["+",W," more files"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}let{matches:J}=$;if(J.length===0)return T0(d2,{children:T0(l1,{color:Z.colors.textMuted,children:"No matches found"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Q=new Map;for(let G of J){if(!Q.has(G.file))Q.set(G.file,[]);Q.get(G.file).push(G)}let X=Array.from(Q.entries()),Y=Math.min(3,X.length),K=X.length-Y;return T0(d2,{flexDirection:"column",children:[T0(d2,{flexDirection:"row",children:[T0(l1,{bold:!0,children:J.length},void 0,!1,void 0,this),T0(l1,{children:" matches in "},void 0,!1,void 0,this),T0(l1,{bold:!0,children:X.length},void 0,!1,void 0,this),T0(l1,{children:" files"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X.slice(0,Y).map(([G,z],q)=>T0(d2,{paddingLeft:2,children:T0(l1,{color:Z.colors.textMuted,children:[FY(process.cwd(),G),": ",z.length]},void 0,!0,void 0,this)},q,!1,void 0,this)),K>0&&T0(d2,{paddingLeft:2,children:T0(l1,{color:Z.colors.textMuted,children:["+",K," more files"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}};import{Box as w0,Text as P0}from"ink";import{relative as AY}from"path";import{jsxDEV as h}from"react/jsx-dev-runtime";function OY($){if(!$)return"•";let Z=$.toLowerCase();if(Z.includes("function")||Z==="fn")return"\uD835\uDC53";if(Z.includes("class"))return"\uD835\uDC36";if(Z.includes("method"))return"\uD835\uDC5A";if(Z.includes("type")||Z==="interface"||Z==="enum")return"\uD835\uDC47";if(Z.includes("const")||Z==="variable"||Z==="var")return"\uD835\uDC50";return"•"}function BW($){let{command:Z,query:J,files:Q,language:X,max_results:Y,exact:K,reranker:G,path:z,...q}=$,W=[];if(Z)W.push(`${Z}`);if(J)W.push(`"${J}"`);if(Q){let U=Array.isArray(Q)?Q.join(", "):Q;W.push(U)}if(X)W.push(`lang: ${X}`);if(Y)W.push(`max: ${Y}`);if(K)W.push("exact");return W.join(" ")}var wY={displayName(){return"Probe"},renderInput($,{verbose:Z}){return BW($)},renderRejection(){return h(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}={},J){let Q=A();if(!$)return h(w0,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:h(w0,{flexDirection:"row",children:h(P0,{color:Q.colors.textMuted,children:"No results"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string"){let Y=$.split(`
|
|
85
|
-
`).slice(0,3);return h(w0,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:h(w0,{flexDirection:"column",children:[Y.map((K,G)=>h(P0,{color:Q.colors.textMuted,children:K.length>80?K.slice(0,77)+"…":K},G,!1,void 0,this)),$.split(`
|
|
86
|
-
`).length>3&&h(P0,{color:Q.colors.textMuted,children:["... (+",$.split(`
|
|
87
|
-
`).length-3," lines)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}if(typeof $!=="object"||$===null)return h(w0,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:h(w0,{flexDirection:"row",children:h(P0,{color:Q.colors.textMuted,children:"No results"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let X=$;if(typeof X.raw==="string"){let Y=X.raw.split(`
|
|
88
|
-
`).slice(0,3);return h(w0,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:h(w0,{flexDirection:"column",children:[Y.map((K,G)=>h(P0,{color:Q.colors.textMuted,children:K.length>80?K.slice(0,77)+"…":K},G,!1,void 0,this)),X.raw.split(`
|
|
89
|
-
`).length>3&&h(P0,{color:Q.colors.textMuted,children:["... (+",X.raw.split(`
|
|
90
|
-
`).length-3," lines)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}if(Array.isArray(X.symbols)&&X.symbols.length>0){let Y=X.symbols.filter((z)=>z!=null&&typeof z==="object"),K=5,G=Y.slice(0,5);return h(w0,{flexDirection:"column",children:[h(w0,{flexDirection:"row",children:[h(P0,{children:"Found "},void 0,!1,void 0,this),h(P0,{bold:!0,children:[Y.length," "]},void 0,!0,void 0,this),h(P0,{children:Y.length===1?"symbol":"symbols"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.map((z,q)=>h(w0,{flexDirection:"row",paddingLeft:2,children:[h(P0,{children:[OY(z.kind)," "]},void 0,!0,void 0,this),h(P0,{bold:!0,children:z.name||"(unnamed)"},void 0,!1,void 0,this),z.line!==void 0&&h(P0,{color:Q.colors.textMuted,children:[" :",z.line]},void 0,!0,void 0,this)]},q,!0,void 0,this)),Y.length>5&&h(w0,{flexDirection:"row",paddingLeft:2,children:h(P0,{color:Q.colors.textMuted,children:["+",Y.length-5," more"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}if(Array.isArray(X.results)&&X.results.length>0){let Y=X.results.filter((z)=>z!=null&&typeof z==="object"),K=3,G=Y.slice(0,3);return h(w0,{flexDirection:"column",children:[h(w0,{flexDirection:"row",children:[h(P0,{children:"Found "},void 0,!1,void 0,this),h(P0,{bold:!0,children:[Y.length," "]},void 0,!0,void 0,this),h(P0,{children:Y.length===1?"result":"results"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.map((z,q)=>h(w0,{flexDirection:"column",paddingLeft:2,children:[h(w0,{flexDirection:"row",children:h(P0,{bold:!0,children:[AY(process.cwd(),z.file||""),z.line!==void 0?`:${z.line}`:""]},void 0,!0,void 0,this)},void 0,!1,void 0,this),z.code&&h(P0,{color:Q.colors.textMuted,children:z.code.length>60?z.code.slice(0,60)+"…":z.code},void 0,!1,void 0,this)]},q,!0,void 0,this)),Y.length>3&&h(w0,{flexDirection:"row",paddingLeft:2,children:h(P0,{color:Q.colors.textMuted,children:["+",Y.length-3," more"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}if(Array.isArray($)){let Y=$.filter((q)=>q!=null&&typeof q==="object");if(Y.length===0)return h(w0,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:h(w0,{flexDirection:"row",children:h(P0,{color:Q.colors.textMuted,children:"No results"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let K=Y[0];if(K.kind!==void 0||K.name&&!K.file){let W=Y.slice(0,5);return h(w0,{flexDirection:"column",children:[h(w0,{flexDirection:"row",children:[h(P0,{children:"Found "},void 0,!1,void 0,this),h(P0,{bold:!0,children:[Y.length," "]},void 0,!0,void 0,this),h(P0,{children:Y.length===1?"symbol":"symbols"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W.map((U,F)=>h(w0,{flexDirection:"row",paddingLeft:2,children:[h(P0,{children:[OY(U.kind)," "]},void 0,!0,void 0,this),h(P0,{bold:!0,children:U.name||"(unnamed)"},void 0,!1,void 0,this),U.line!==void 0&&h(P0,{color:Q.colors.textMuted,children:[":",U.line]},void 0,!0,void 0,this)]},F,!0,void 0,this)),Y.length>5&&h(w0,{flexDirection:"row",paddingLeft:2,children:h(P0,{color:Q.colors.textMuted,children:["+",Y.length-5," more"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}let G=3,z=Y.slice(0,G);return h(w0,{flexDirection:"column",children:[h(w0,{flexDirection:"row",children:[h(P0,{children:"Found "},void 0,!1,void 0,this),h(P0,{bold:!0,children:[Y.length," "]},void 0,!0,void 0,this),h(P0,{children:Y.length===1?"result":"results"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.map((q,W)=>h(w0,{flexDirection:"column",paddingLeft:2,children:[h(w0,{flexDirection:"row",children:h(P0,{bold:!0,children:[AY(process.cwd(),q.file||q.path||""),q.line!==void 0?`:${q.line}`:""]},void 0,!0,void 0,this)},void 0,!1,void 0,this),typeof q.code==="string"&&h(P0,{color:Q.colors.textMuted,children:q.code.length>60?q.code.slice(0,60)+"…":q.code},void 0,!1,void 0,this)]},W,!0,void 0,this)),Y.length>G&&h(w0,{flexDirection:"row",paddingLeft:2,children:h(P0,{color:Q.colors.textMuted,children:["+",Y.length-G," more"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}return h(w0,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:h(w0,{flexDirection:"row",children:h(P0,{color:Q.colors.textMuted,children:"No results"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as k7,Text as F2}from"ink";import{jsxDEV as J$}from"react/jsx-dev-runtime";var LY=3,RY={displayName(){return"AST Grep"},renderInput($,{verbose:Z}={verbose:!1}){let{pattern:J,language:Q,rewrite:X,path:Y}=$;if(!J)return"(No pattern)";let K="";if(X)K=`"${J}" → "${X}"`;else K=`"${J}"`;if(Q)K+=` ${Q}`;if(Z&&Y)K+=` @ ${Y}`;return K},renderRejection(){return J$(C,{},void 0,!1,void 0,this)},renderOutput($){let Z=A();if($==null)return J$(F2,{color:Z.colors.textMuted,children:"(No output)"},void 0,!1,void 0,this);let J=$;if(typeof J.raw==="string"){let Q=J.raw.split(`
|
|
91
|
-
`),X=Q.slice(0,2).join(`
|
|
92
|
-
`),Y=Q.length-2;return J$(k7,{flexDirection:"column",gap:0,children:[J$(F2,{color:Z.colors.success,children:"Rewrites applied"},void 0,!1,void 0,this),J$(F2,{color:Z.colors.textMuted,children:X},void 0,!1,void 0,this),Y>0&&J$(F2,{color:Z.colors.textMuted,children:["... (+",Y," lines)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}if(Array.isArray(J.matches)){let Q=J.matches;if(Q.length===0)return J$(F2,{color:Z.colors.textMuted,children:"No matches found"},void 0,!1,void 0,this);let X=Q.slice(0,LY),Y=Q.length-LY;return J$(k7,{flexDirection:"column",gap:0,children:[J$(F2,{color:Z.colors.success,children:[Q.length," AST ",Q.length===1?"match":"matches"]},void 0,!0,void 0,this),X.map((K,G)=>{let{file:z,line:q,text:W}=K,U=z||"unknown";if(q!=null)U+=`:${q}`;let F=W?String(W):"(no text)";if(F.length>60)F=F.slice(0,57)+"...";return J$(k7,{flexDirection:"row",gap:1,children:[J$(F2,{bold:!0,children:U},void 0,!1,void 0,this),J$(F2,{color:Z.colors.textMuted,children:F},void 0,!1,void 0,this)]},G,!0,void 0,this)}),Y>0&&J$(F2,{color:Z.colors.textMuted,children:["+",Y," more"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}return J$(F2,{children:JSON.stringify($)},void 0,!1,void 0,this)}};import{Box as _0,Text as n}from"ink";import{jsxDEV as g,Fragment as f9}from"react/jsx-dev-runtime";function IW($){if(!$||typeof $!=="object")return!1;let Z=$;return"definition"in Z||"callers"in Z||"callees"in Z}function MW($){switch($?.toLowerCase()){case"function":return"\uD835\uDC53 ";case"class":return"\uD835\uDC36 ";case"method":return"\uD835\uDC5A ";case"interface":return"\uD835\uDC3C ";case"enum":return"\uD835\uDC38 ";case"type":return"\uD835\uDC47 ";case"module":return"\uD83D\uDCE6 ";case"file":return"\uD83D\uDCC4 ";default:return"• "}}function CW($,Z,J){let Q=MW($.label),X=$.file_path?$.file_path.length>40?"…"+$.file_path.slice(-37):$.file_path:"";return g(_0,{flexDirection:"row",paddingLeft:4,children:[g(n,{children:Q},void 0,!1,void 0,this),g(n,{bold:!0,children:$.name},void 0,!1,void 0,this),X&&g(n,{color:J.colors.textMuted,children:[" (",X,")"]},void 0,!0,void 0,this)]},Z,!0,void 0,this)}function BY($,Z,J,Q){return g(_0,{flexDirection:"row",paddingLeft:4,children:[g(n,{color:Q.colors.textMuted,children:[Z," "]},void 0,!0,void 0,this),g(n,{children:$.name},void 0,!1,void 0,this),$.file&&g(n,{color:Q.colors.textMuted,children:[" (",$.file,")"]},void 0,!0,void 0,this)]},J,!0,void 0,this)}function fW($){if(!$||typeof $!=="object")return!1;return Array.isArray($.results)}function SW($){if(!$||typeof $!=="object")return!1;let Z=$;return Array.isArray(Z.inbound)||Array.isArray(Z.outbound)||!!Z.node}function bW($){if(!$||typeof $!=="object")return!1;return Array.isArray($.affected)}function yW($){if(!$||typeof $!=="object")return!1;return Array.isArray($.components)}function kW($){if(!$||typeof $!=="object")return!1;return typeof $.status==="string"}var IY={displayName(){return"Code Graph"},renderInput($){let Z=$.action||"unknown",J=[];if($.name)J.push(`"${$.name}"`);if($.file)J.push(`file: ${$.file}`);if($.path)J.push(`path: ${$.path}`);if($.project)J.push(`project: ${$.project}`);if($.query)J.push(`query: "${$.query}"`);if($.depth)J.push(`depth: ${$.depth}`);if($.direction)J.push(`dir: ${$.direction}`);let Q=J.length>0?` ${J.join(" ")}`:"";return`${Z}${Q}`},renderRejection(){return g(C,{},void 0,!1,void 0,this)},renderOutput($,Z,J){let Q=A(),X=J?.action||"query";if(!$)return g(_0,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:g(_0,{flexDirection:"row",children:g(n,{color:Q.colors.textMuted,children:"(No results)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string"){let G=$.length>100?$.slice(0,97)+"…":$;return g(_0,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:g(_0,{flexDirection:"row",children:g(n,{color:Q.colors.textMuted,children:[X,": ",G]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if("raw"in $&&typeof $.raw==="string"){let G=$.raw.length>100?$.raw.slice(0,97)+"…":$.raw;return g(_0,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:g(_0,{flexDirection:"row",children:g(n,{color:Q.colors.textMuted,children:[X,": ",G]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if(fW($)){let G=$.results||[],z=$.total??G.length,q=3,W=G.slice(0,3);return g(_0,{flexDirection:"column",children:[g(_0,{flexDirection:"row",children:[g(n,{bold:!0,children:z},void 0,!1,void 0,this),g(n,{children:[" ",z===1?"symbol":"symbols"," found"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W.map((U,F)=>CW(U,F,Q)),G.length>3&&g(_0,{flexDirection:"row",paddingLeft:4,children:g(n,{color:Q.colors.textMuted,children:["+",G.length-3," more"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}if(SW($)){let G=$.inbound||[],z=$.outbound||[],q=3,W=G.slice(0,3),U=z.slice(0,3);return g(_0,{flexDirection:"column",children:[g(_0,{flexDirection:"row",children:[g(n,{children:"Call chain: "},void 0,!1,void 0,this),g(n,{bold:!0,children:G.length},void 0,!1,void 0,this),g(n,{children:" inbound, "},void 0,!1,void 0,this),g(n,{bold:!0,children:z.length},void 0,!1,void 0,this),g(n,{children:" outbound"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W.length>0&&g(f9,{children:[g(_0,{flexDirection:"row",paddingLeft:2,children:g(n,{color:Q.colors.textMuted,children:"Callers:"},void 0,!1,void 0,this)},void 0,!1,void 0,this),W.map((F,O)=>BY(F,"←",O,Q)),G.length>3&&g(_0,{flexDirection:"row",paddingLeft:4,children:g(n,{color:Q.colors.textMuted,children:["+",G.length-3," more"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U.length>0&&g(f9,{children:[g(_0,{flexDirection:"row",paddingLeft:2,children:g(n,{color:Q.colors.textMuted,children:"Callees:"},void 0,!1,void 0,this)},void 0,!1,void 0,this),U.map((F,O)=>BY(F,"→",O,Q)),z.length>3&&g(_0,{flexDirection:"row",paddingLeft:4,children:g(n,{color:Q.colors.textMuted,children:["+",z.length-3," more"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}if(bW($)){let G=$.affected||[],z=3,q=G.slice(0,3);return g(_0,{flexDirection:"column",children:[g(_0,{flexDirection:"row",children:[g(n,{bold:!0,children:G.length},void 0,!1,void 0,this),g(n,{children:[" ",G.length===1?"symbol":"symbols"," affected"]},void 0,!0,void 0,this),$.depth&&g(f9,{children:[g(n,{color:Q.colors.textMuted,children:" (depth: "},void 0,!1,void 0,this),g(n,{color:Q.colors.textMuted,children:$.depth},void 0,!1,void 0,this),g(n,{color:Q.colors.textMuted,children:")"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.map((W,U)=>g(_0,{flexDirection:"row",paddingLeft:4,children:[g(n,{children:["• ",W.name]},void 0,!0,void 0,this),W.file&&g(n,{color:Q.colors.textMuted,children:[" (",W.file,")"]},void 0,!0,void 0,this)]},U,!0,void 0,this)),G.length>3&&g(_0,{flexDirection:"row",paddingLeft:4,children:g(n,{color:Q.colors.textMuted,children:["+",G.length-3," more"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}if(yW($)){let G=$.components||[];return g(_0,{flexDirection:"column",children:g(_0,{flexDirection:"row",children:[g(n,{children:"Architecture overview"},void 0,!1,void 0,this),G.length>0&&g(f9,{children:[g(n,{color:Q.colors.textMuted,children:" ("},void 0,!1,void 0,this),g(n,{color:Q.colors.textMuted,children:G.length},void 0,!1,void 0,this),g(n,{color:Q.colors.textMuted,children:" components)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}if(kW($))if($.status?.toLowerCase().includes("index")&&typeof $.node_count==="number"&&typeof $.edge_count==="number")return g(_0,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:g(_0,{flexDirection:"row",children:[g(n,{color:Q.colors.success,children:"Indexed: "},void 0,!1,void 0,this),g(n,{bold:!0,children:$.node_count},void 0,!1,void 0,this),g(n,{children:" nodes, "},void 0,!1,void 0,this),g(n,{bold:!0,children:$.edge_count},void 0,!1,void 0,this),g(n,{children:" edges"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);else return g(_0,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:g(_0,{flexDirection:"row",children:g(n,{color:Q.colors.warning,children:"Not indexed"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(IW($)){let G=!!$.definition,z=Array.isArray($.callers)&&$.callers.length>0,q=Array.isArray($.callees)&&$.callees.length>0;return g(_0,{flexDirection:"column",children:[g(_0,{flexDirection:"row",children:g(n,{children:"Context 360°"},void 0,!1,void 0,this)},void 0,!1,void 0,this),G&&$.definition&&g(_0,{flexDirection:"row",paddingLeft:4,children:[g(n,{color:Q.colors.info,children:"\uD83D\uDCCD "},void 0,!1,void 0,this),g(n,{children:$.definition.name||"definition"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z&&$.callers&&g(_0,{flexDirection:"row",paddingLeft:4,children:[g(n,{color:Q.colors.textMuted,children:"← "},void 0,!1,void 0,this),g(n,{children:[$.callers.length," callers"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q&&$.callees&&g(_0,{flexDirection:"row",paddingLeft:4,children:[g(n,{color:Q.colors.textMuted,children:"→ "},void 0,!1,void 0,this),g(n,{children:[$.callees.length," callees"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}let Y=JSON.stringify($),K=Y.length>100?Y.slice(0,97)+"…":Y;return g(_0,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:g(_0,{flexDirection:"row",children:g(n,{color:Q.colors.textMuted,children:[X,": ",K]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as U1,Text as a0}from"ink";import{relative as CY}from"path";import{jsxDEV as J0}from"react/jsx-dev-runtime";var f0={File:"\uD83D\uDCC4",Module:"\uD83D\uDCE6",Namespace:"\uD83D\uDCE6",Package:"\uD83D\uDCE6",Class:"\uD835\uDC36",Method:"\uD835\uDC5A",Property:"\uD83D\uDD39",Field:"\uD83D\uDD39",Constructor:"⚙",Enum:"\uD83D\uDCCB",Interface:"\uD835\uDC3C",Function:"\uD835\uDC53",Variable:"\uD835\uDC63",Constant:"\uD83D\uDD12",String:'"',Number:"#",Boolean:"✓",Array:"[]",Object:"{}",Key:"\uD83D\uDD11",Null:"∅",EnumMember:"\uD83D\uDCCB",Struct:"\uD83D\uDCE6",Event:"⚡",Operator:"⊕",TypeParameter:"T"};function vW($){if($.startsWith("file://"))return $.slice(7);return $}function MY($,Z,J){let Q=CY(process.cwd(),vW($));if(Z!==void 0&&J!==void 0)return`${Q}:${Z+1}:${J+1}`;else if(Z!==void 0)return`${Q}:${Z+1}`;return Q}function gW($){let Z="";if(typeof $==="string")Z=$;else if($&&typeof $==="object"){let Q=$;if(typeof Q.value==="string")Z=Q.value}let J=Z.split(`
|
|
93
|
-
`);return J.length>0?J[0].trim():""}function TW($,Z=80){return $.length>Z?$.slice(0,Z-1)+"…":$}var fY={displayName(){return"LSP"},renderInput($,{verbose:Z}){let J=String($?.action??""),Q=String($?.file??""),X=typeof $?.line==="number"?$.line:void 0,Y=typeof $?.character==="number"?$.character:void 0,K=$?.new_name?String($.new_name):"",G=Q?Z?Q:CY(process.cwd(),Q):"";if(J==="rename"&&X!==void 0&&Y!==void 0&&K)return`${J} ${G}:${X+1}:${Y+1} → ${K}`;else if(X!==void 0&&Y!==void 0&&G)return`${J} ${G}:${X+1}:${Y+1}`;else if(G)return`${J} ${G}`;return J},renderOutput($,{verbose:Z}={},J){let X=String((J??{})?.action??"");if($==null)return J0(U1,{children:J0(a0,{color:A().colors.textMuted,children:"(No result)"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(X==="definition"||X==="references"){let Y=[];if($!=null&&typeof $==="object"&&!Array.isArray($)){let W=$;if(typeof W.uri==="string")Y=[W]}else if(Array.isArray($))Y=$.map((W)=>W!=null&&typeof W==="object"?W:{});if(Y.length===0)return J0(U1,{children:J0(a0,{color:A().colors.textMuted,children:"(No result)"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(X==="definition"){let W=Y[0];if(!W)return J0(U1,{children:J0(a0,{color:A().colors.textMuted,children:"(No result)"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let U=typeof W.uri==="string"?W.uri:"",F=typeof W.range?.start?.line==="number"?W.range.start.line:void 0,O=typeof W.range?.start?.character==="number"?W.range.start.character:void 0;return J0(U1,{children:J0(a0,{children:["→ ",J0(a0,{bold:!0,children:MY(U,F,O)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}let K=Y.length,G=Z?Y.length:Math.min(5,Y.length),z=Y.slice(0,G),q=K>G;return J0(U1,{flexDirection:"column",children:[J0(U1,{children:J0(a0,{children:[J0(a0,{bold:!0,children:K},void 0,!1,void 0,this)," reference",K!==1?"s":""]},void 0,!0,void 0,this)},void 0,!1,void 0,this),z.length>0&&J0(U1,{flexDirection:"column",marginLeft:2,children:z.map((W,U)=>{if(!W)return null;let F=typeof W.uri==="string"?W.uri:"",O=typeof W.range?.start?.line==="number"?W.range.start.line:void 0,L=typeof W.range?.start?.character==="number"?W.range.start.character:void 0;return J0(a0,{color:A().colors.textMuted,children:MY(F,O,L)},U,!1,void 0,this)})},void 0,!1,void 0,this),q&&J0(U1,{marginLeft:2,children:J0(a0,{color:A().colors.textMuted,children:["+",K-G," more"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}if(X==="hover"){if($!=null&&typeof $==="object"){let K=$.contents;if(K){let G=gW(K),z=TW(G);return J0(U1,{children:J0(a0,{children:J0(a0,{bold:!0,children:z},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}}return J0(U1,{children:J0(a0,{color:A().colors.textMuted,children:"(No hover info)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if(X==="symbols"){let Y=[];if(Array.isArray($))Y=$.map((U)=>U!=null&&typeof U==="object"?U:{});if(Y.length===0)return J0(U1,{children:J0(a0,{color:A().colors.textMuted,children:"(No symbols)"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let K=Y.length,G=Z?Y.length:Math.min(5,Y.length),z=Y.slice(0,G),q=K>G,W=(U)=>{if(typeof U==="string")return f0[U]||"•";else if(typeof U==="number")return{"1":f0.File||"•","2":f0.Module||"•","3":f0.Namespace||"•","4":f0.Package||"•","5":f0.Class||"•","6":f0.Method||"•","7":f0.Property||"•","8":f0.Field||"•","9":f0.Constructor||"•","10":f0.Enum||"•","11":f0.Interface||"•","12":f0.Function||"•","13":f0.Variable||"•","14":f0.Constant||"•","15":f0.String||"•","16":f0.Number||"•","17":f0.Boolean||"•","18":f0.Array||"•","19":f0.Object||"•","20":f0.Key||"•","21":f0.Null||"•","22":f0.EnumMember||"•","23":f0.Struct||"•","24":f0.Event||"•","25":f0.Operator||"•","26":f0.TypeParameter||"•"}[String(U)]||"•";return"•"};return J0(U1,{flexDirection:"column",children:[J0(U1,{children:J0(a0,{children:[J0(a0,{bold:!0,children:K},void 0,!1,void 0,this)," symbol",K!==1?"s":""]},void 0,!0,void 0,this)},void 0,!1,void 0,this),z.length>0&&J0(U1,{flexDirection:"column",marginLeft:2,children:z.map((U,F)=>{let O=W(U.kind),L=String(U.name??"");return J0(a0,{children:[O," ",L]},F,!0,void 0,this)})},void 0,!1,void 0,this),q&&J0(U1,{marginLeft:2,children:J0(a0,{color:A().colors.textMuted,children:["+",K-G," more"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}if(X==="rename"){if($!=null&&typeof $==="object"){let K=$.changes;if(K!=null&&typeof K==="object"){let G=Object.keys(K).length,z=0;for(let q of Object.values(K))if(Array.isArray(q))z+=q.length;return J0(U1,{children:J0(a0,{children:["Renamed in ",J0(a0,{bold:!0,children:G},void 0,!1,void 0,this)," file",G!==1?"s":""," (",J0(a0,{bold:!0,children:z},void 0,!1,void 0,this)," edit",z!==1?"s":"",")"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}}return J0(U1,{children:J0(a0,{color:A().colors.textMuted,children:"(Rename failed)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}return J0(U1,{children:J0(a0,{children:JSON.stringify($)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},renderRejection(){return J0(C,{},void 0,!1,void 0,this)}};import{Box as v7,Text as e0}from"ink";import{relative as S9}from"path";import{jsxDEV as V0}from"react/jsx-dev-runtime";var SY={displayName(){return"FastRipgrep"},renderInput($,{verbose:Z}){let{command:J,pattern:Q,path:X}=$;if(J==="search"&&Q){let Y=X?S9(process.cwd(),X):void 0;return`search "${Q}"${Y||Z?` in ${Z&&X?X:Y||"."}`:""}`}if(J==="status"){let Y=X?S9(process.cwd(),X):void 0;return`status${Y||Z?` for ${Z&&X?X:Y||"."}`:""}`}if(J==="index"||J==="init"){let Y=X?S9(process.cwd(),X):void 0;return`${J}${Y||Z?` at ${Z&&X?X:Y||"."}`:""}`}if(J==="update")return`update index${X?` at ${Z?X:S9(process.cwd(),X)}`:""}`;return J},renderRejection(){return V0(C,{},void 0,!1,void 0,this)},renderOutput($){let Z=A();if($==null)return V0(e0,{color:Z.colors.textMuted,children:"No output"},void 0,!1,void 0,this);if(typeof $==="string"){let J=$.trim().split(`
|
|
94
|
-
`);return V0(e0,{color:Z.colors.textMuted,children:J[0]},void 0,!1,void 0,this)}if(typeof $==="object"&&!Array.isArray($)){let J=$;if(Array.isArray(J.matches)){let Q=J.matches,X=new Set,Y=0;for(let G of Q){if(typeof G.file==="string")X.add(G.file);else if(typeof G.path==="string")X.add(G.path);Y++}let K=X.size;if(K===0)return V0(e0,{color:Z.colors.textMuted,children:"No matches"},void 0,!1,void 0,this);return V0(v7,{flexDirection:"row",children:[V0(e0,{children:"Found "},void 0,!1,void 0,this),V0(e0,{bold:!0,children:Y},void 0,!1,void 0,this),V0(e0,{children:[" ",Y===1?"match":"matches"," in "]},void 0,!0,void 0,this),V0(e0,{bold:!0,children:K},void 0,!1,void 0,this),V0(e0,{children:[" ",K===1?"file":"files"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}if(Array.isArray(J.counts)&&typeof J.total==="number"){let{counts:Q,total:X}=J,Y=Q.length;if(Y===0)return V0(e0,{color:Z.colors.textMuted,children:"No matches"},void 0,!1,void 0,this);return V0(v7,{flexDirection:"row",children:[V0(e0,{children:"Found "},void 0,!1,void 0,this),V0(e0,{bold:!0,children:X},void 0,!1,void 0,this),V0(e0,{children:[" ",X===1?"match":"matches"," in "]},void 0,!0,void 0,this),V0(e0,{bold:!0,children:Y},void 0,!1,void 0,this),V0(e0,{children:[" ",Y===1?"file":"files"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}if(typeof J.indexed==="boolean"||typeof J.files==="number"){let Q=J.indexed===!0,X=typeof J.files==="number"?J.files:0;if(Q)return V0(v7,{flexDirection:"row",children:[V0(e0,{children:"Index: "},void 0,!1,void 0,this),V0(e0,{bold:!0,children:X},void 0,!1,void 0,this),V0(e0,{children:" files indexed"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);else return V0(e0,{color:Z.colors.textMuted,children:"Not indexed"},void 0,!1,void 0,this)}if(typeof J.message==="string")return V0(e0,{color:Z.colors.textMuted,children:J.message},void 0,!1,void 0,this);return V0(e0,{color:Z.colors.textMuted,children:"Command completed"},void 0,!1,void 0,this)}return V0(e0,{color:Z.colors.textMuted,children:"Done"},void 0,!1,void 0,this)}};import{Box as m$,Text as S0}from"ink";import{relative as g7}from"path";import{jsxDEV as K0}from"react/jsx-dev-runtime";var bY={displayName(){return"Fuzzy Find"},renderInput($,{verbose:Z}){let{action:J,query:Q,patterns:X,constraints:Y,path:K}=$;if(J==="grep"&&Q){let G=`grep "${Q}"`;if(Y)G+=` [${Y}]`;if(K&&Z)G+=` in ${K}`;return G}if(J==="find_files"){let G=`find_files${Q?` "${Q}"`:""}`;if(Y)G+=` [${Y}]`;if(K&&Z)G+=` in ${K}`;return G}if(J==="multi_grep"&&X){let z=`multi_grep ${X.map((q)=>`"${q}"`).join(" ")}`;if(Y)z+=` [${Y}]`;if(K&&Z)z+=` in ${K}`;return z}return J},renderRejection(){return K0(C,{},void 0,!1,void 0,this)},renderOutput($){let Z=A();if($==null)return K0(S0,{color:Z.colors.textMuted,children:"No results"},void 0,!1,void 0,this);if(typeof $==="string"){let J=$.trim().split(`
|
|
95
|
-
`);return K0(S0,{color:Z.colors.textMuted,children:J[0]},void 0,!1,void 0,this)}if(typeof $==="object"&&!Array.isArray($)){let J=$;if(Array.isArray(J.results)){let Q=J.results;if(Q.length===0)return K0(S0,{color:Z.colors.textMuted,children:"No matches"},void 0,!1,void 0,this);let X=new Map;for(let q of Q){let W=typeof q.file==="string"?q.file:"unknown";X.set(W,(X.get(W)||0)+1)}let Y=X.size,K=Q.length,G=Array.from(X.entries()).slice(0,3),z=G.map(([q])=>g7(process.cwd(),q));return K0(m$,{flexDirection:"column",children:[K0(m$,{flexDirection:"row",children:[K0(S0,{children:"Found "},void 0,!1,void 0,this),K0(S0,{bold:!0,children:K},void 0,!1,void 0,this),K0(S0,{children:[" ",K===1?"match":"matches"," in "]},void 0,!0,void 0,this),K0(S0,{bold:!0,children:Y},void 0,!1,void 0,this),K0(S0,{children:[" ",Y===1?"file":"files"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G.length>0&&K0(m$,{flexDirection:"column",marginLeft:2,children:[G.map(([q,W],U)=>K0(m$,{flexDirection:"row",children:[K0(S0,{color:Z.colors.textMuted,children:[z[U],": "]},void 0,!0,void 0,this),K0(S0,{color:Z.colors.textMuted,bold:!0,children:W},void 0,!1,void 0,this)]},U,!0,void 0,this)),Y>3&&K0(S0,{color:Z.colors.textMuted,children:["... and ",Y-3," more"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}if(Array.isArray(J.files)){let Q=J.files;if(Q.length===0)return K0(S0,{color:Z.colors.textMuted,children:"No files found"},void 0,!1,void 0,this);let X=Q.slice(0,5).map((Y)=>g7(process.cwd(),Y));return K0(m$,{flexDirection:"column",children:[K0(m$,{flexDirection:"row",children:[K0(S0,{children:"Found "},void 0,!1,void 0,this),K0(S0,{bold:!0,children:Q.length},void 0,!1,void 0,this),K0(S0,{children:[" ",Q.length===1?"file":"files"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),K0(m$,{flexDirection:"column",marginLeft:2,children:[X.map((Y,K)=>K0(S0,{color:Z.colors.textMuted,children:Y},K,!1,void 0,this)),Q.length>5&&K0(S0,{color:Z.colors.textMuted,children:["... and ",Q.length-5," more"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}}if(Array.isArray($)){if($.length===0)return K0(S0,{color:Z.colors.textMuted,children:"No results"},void 0,!1,void 0,this);if(typeof $[0]==="string"){let J=$,Q=J.slice(0,5).map((X)=>g7(process.cwd(),X));return K0(m$,{flexDirection:"column",children:[K0(m$,{flexDirection:"row",children:[K0(S0,{children:"Found "},void 0,!1,void 0,this),K0(S0,{bold:!0,children:J.length},void 0,!1,void 0,this),K0(S0,{children:[" ",J.length===1?"file":"files"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),K0(m$,{flexDirection:"column",marginLeft:2,children:[Q.map((X,Y)=>K0(S0,{color:Z.colors.textMuted,children:X},Y,!1,void 0,this)),J.length>5&&K0(S0,{color:Z.colors.textMuted,children:["... and ",J.length-5," more"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}return K0(m$,{flexDirection:"row",children:[K0(S0,{children:"Found "},void 0,!1,void 0,this),K0(S0,{bold:!0,children:$.length},void 0,!1,void 0,this),K0(S0,{children:[" ",$.length===1?"result":"results"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}return K0(S0,{color:Z.colors.textMuted,children:"Done"},void 0,!1,void 0,this)}};import{Box as v6,Text as n0}from"ink";import{jsxDEV as M0}from"react/jsx-dev-runtime";var yY={displayName(){return"Serena"},renderInput($,{verbose:Z}){let{action:J,name_path:Q,pattern:X,new_name:Y,relative_path:K}=$;if(J==="find_symbol"&&Q){let G=`find_symbol "${Q}"`;if(K&&Z)G+=` in ${K}`;return G}if(J==="find_references"&&Q)return`find_references "${Q}"`;if(J==="search"&&X){let G=`search "${X}"`;if(K&&Z)G+=` in ${K}`;return G}if(J==="rename"&&Q&&Y)return`rename "${Q}" → "${Y}"`;if(J==="overview")return`overview${K?` of ${K}`:""}`;if(J==="replace_body"&&Q)return`replace_body "${Q}"`;if(J==="insert_after"&&Q)return`insert_after "${Q}"`;if(J==="insert_before"&&Q)return`insert_before "${Q}"`;return J},renderRejection(){return M0(C,{},void 0,!1,void 0,this)},renderOutput($){let Z=A();if($==null)return M0(n0,{color:Z.colors.textMuted,children:"No output"},void 0,!1,void 0,this);if(typeof $==="string"){let Q=$.trim().split(`
|
|
96
|
-
`).slice(0,2).join(`
|
|
97
|
-
`);return M0(n0,{color:Z.colors.textMuted,children:Q},void 0,!1,void 0,this)}if(typeof $==="object"&&!Array.isArray($)){let J=$;if(Array.isArray(J.results)){let Q=J.results;if(Q.length===0)return M0(n0,{color:Z.colors.textMuted,children:"No results"},void 0,!1,void 0,this);let X=Q.slice(0,3);return M0(v6,{flexDirection:"column",children:[M0(v6,{flexDirection:"row",children:[M0(n0,{children:"Found "},void 0,!1,void 0,this),M0(n0,{bold:!0,children:Q.length},void 0,!1,void 0,this),M0(n0,{children:[" ",Q.length===1?"result":"results"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M0(v6,{flexDirection:"column",marginLeft:2,children:[X.map((Y,K)=>{if(Y!=null&&typeof Y==="object"){let G=Y,z=G.name||G.symbol_name||G.qualified_name,q=G.file||G.path;if(z&&q)return M0(n0,{color:Z.colors.textMuted,children:[typeof z==="string"?z:"",typeof q==="string"?` (${q})`:""]},K,!0,void 0,this);if(z)return M0(n0,{color:Z.colors.textMuted,children:typeof z==="string"?z:""},K,!1,void 0,this)}return M0(n0,{color:Z.colors.textMuted,children:["Result ",K+1]},K,!0,void 0,this)}),Q.length>3&&M0(n0,{color:Z.colors.textMuted,children:["... and ",Q.length-3," more"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}if(typeof J.raw==="string"){let X=J.raw.trim().split(`
|
|
98
|
-
`).slice(0,2).join(`
|
|
99
|
-
`);return M0(n0,{color:Z.colors.textMuted,children:X},void 0,!1,void 0,this)}if(typeof J.success==="boolean")if(J.success){let Q=typeof J.message==="string"?J.message:"Success";return M0(n0,{color:Z.colors.success,children:Q},void 0,!1,void 0,this)}else{let Q=typeof J.error==="string"?J.error:"Failed";return M0(n0,{color:Z.colors.error,children:Q},void 0,!1,void 0,this)}if(typeof J.message==="string")return M0(n0,{color:Z.colors.textMuted,children:J.message},void 0,!1,void 0,this);if(J.name&&J.kind)return M0(v6,{flexDirection:"row",children:[M0(n0,{color:Z.colors.textMuted,children:[typeof J.kind==="string"?J.kind:"Symbol",":"]},void 0,!0,void 0,this),M0(n0,{children:[" ",typeof J.name==="string"?J.name:""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);return M0(n0,{color:Z.colors.textMuted,children:"Completed"},void 0,!1,void 0,this)}if(Array.isArray($)){if($.length===0)return M0(n0,{color:Z.colors.textMuted,children:"No results"},void 0,!1,void 0,this);return M0(v6,{flexDirection:"row",children:[M0(n0,{children:"Found "},void 0,!1,void 0,this),M0(n0,{bold:!0,children:$.length},void 0,!1,void 0,this),M0(n0,{children:[" ",$.length===1?"result":"results"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}return M0(n0,{color:Z.colors.textMuted,children:"Done"},void 0,!1,void 0,this)}};import{Box as d$,Text as U2}from"ink";import{jsxDEV as i0}from"react/jsx-dev-runtime";function T7($,Z=60){return $.length>Z?$.slice(0,Z-1)+"…":$}var kY={displayName(){return"Quip"},renderInput($,{verbose:Z}={}){let J=String($.action??"read"),Q=$.query?T7(String($.query)):"",X=$.threadId?T7(String($.threadId)):"",Y=[J];if(Q)Y.push(`query: ${Q}`);else if(X)Y.push(`threadId: ${X}`);return i0(d$,{flexDirection:"row",children:i0(U2,{children:Y.join(", ")},void 0,!1,void 0,this)},void 0,!1,void 0,this)},renderRejection(){return i0(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}={}){let J=A();if($==null)return i0(d$,{flexDirection:"column",children:i0(U2,{color:J.colors.textMuted,children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string")return i0(d$,{flexDirection:"column",children:i0(U2,{children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Q=$;if(Q.success===!1)return i0(d$,{flexDirection:"column",children:i0(U2,{color:J.colors.error,children:String(Q.message??"Error reading Quip document")},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(Q.success===!0){let X=Q.data;if(X?.output&&typeof X.output==="string"){let Y=X.output.split(`
|
|
100
|
-
`),G=Y.slice(0,2).join(`
|
|
101
|
-
`);return i0(d$,{flexDirection:"column",children:[i0(d$,{flexDirection:"row",children:i0(U2,{color:J.colors.textMuted,dimColor:!0,children:T7(G,80)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Y.length>2&&i0(d$,{flexDirection:"row",paddingLeft:0,children:i0(U2,{color:J.colors.textMuted,children:["... (",Y.length-2," more lines)"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}if(Q.message)return i0(d$,{flexDirection:"column",children:i0(U2,{children:String(Q.message)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if(typeof Q.message==="string"&&Q.message.toLowerCase().includes("created"))return i0(d$,{flexDirection:"column",children:i0(U2,{color:J.colors.success,children:Q.message},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(Q.message)return i0(d$,{flexDirection:"column",children:i0(U2,{children:String(Q.message)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return i0(d$,{flexDirection:"column",children:i0(U2,{color:J.colors.textMuted,children:"(No response)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as A2,Text as O2}from"ink";import{jsxDEV as $1}from"react/jsx-dev-runtime";function vY($,Z=40){return $.length>Z?$.slice(0,Z-1)+"…":$}var gY={displayName(){return"Quip Comment"},renderInput($,{verbose:Z}={}){let J=$.threadId?vY(String($.threadId),30):"",Q=$.content?vY(String($.content),40):"",X=[];if(J)X.push(`thread: ${J}`);if(Q)X.push(`"${Q}"`);return $1(A2,{flexDirection:"row",children:$1(O2,{children:X.length>0?X.join(" "):"Posting comment..."},void 0,!1,void 0,this)},void 0,!1,void 0,this)},renderRejection(){return $1(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}={}){let J=A();if($==null)return $1(A2,{flexDirection:"column",children:$1(O2,{color:J.colors.textMuted,children:"(No response)"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string"){if($.toLowerCase().includes("posted")||$.toLowerCase().includes("success"))return $1(A2,{flexDirection:"column",children:$1(O2,{color:J.colors.success,children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this);return $1(A2,{flexDirection:"column",children:$1(O2,{children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)}let Q=$;if(Q.success===!1)return $1(A2,{flexDirection:"column",children:$1(O2,{color:J.colors.error,children:String(Q.message??"Error posting comment")},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(Q.success===!0){let X=Q.message??"Comment posted";return $1(A2,{flexDirection:"column",children:$1(O2,{color:J.colors.success,children:X},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if(Q.message){if(String(Q.message).toLowerCase().includes("posted"))return $1(A2,{flexDirection:"column",children:$1(O2,{color:J.colors.success,children:String(Q.message)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(String(Q.message).toLowerCase().includes("error")||String(Q.message).toLowerCase().includes("failed"))return $1(A2,{flexDirection:"column",children:$1(O2,{color:J.colors.error,children:String(Q.message)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return $1(A2,{flexDirection:"column",children:$1(O2,{children:String(Q.message)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}return $1(A2,{flexDirection:"column",children:$1(O2,{color:J.colors.textMuted,children:"(Comment posted)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as TY,Text as b8}from"ink";import{jsxDEV as p2}from"react/jsx-dev-runtime";var VY={displayName(){return"Quip Create"},renderInput($,{verbose:Z}={}){let J=typeof $.title==="string"?$.title:"";return p2(TY,{flexDirection:"row",children:[p2(b8,{children:J?`"${J.slice(0,50)}"`:"new document"},void 0,!1,void 0,this),Z&&typeof $.folderId==="string"&&p2(b8,{color:A().colors.textMuted,children:[" in ",$.folderId]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},renderRejection(){return p2(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}={}){let J=A();if(!$||typeof $!=="object")return p2(b8,{color:J.colors.textMuted,children:typeof $==="string"?$:"No result"},void 0,!1,void 0,this);let Q=$,X=Q.success!==!1,Y=typeof Q.message==="string"?Q.message:"";if(!X)return p2(b8,{color:J.colors.error,children:Y||"Failed to create document"},void 0,!1,void 0,this);return p2(TY,{flexDirection:"row",children:[p2(b8,{color:J.colors.success,children:"✓ Document created"},void 0,!1,void 0,this),Y&&p2(b8,{color:J.colors.textMuted,children:[" — ",Y.slice(0,60)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}};import{Box as L4,Text as R4}from"ink";import{jsxDEV as u1}from"react/jsx-dev-runtime";var DY={displayName(){return"Slack Read"},renderInput($,{verbose:Z}={}){let J=$?.channel??"",Q=$?.limit??$?.max_messages??"",X=[];if(J)X.push(`#${String(J).replace(/^#/,"")}`);if(Q)X.push(`limit:${Q}`);return X.join(", ")||"Slack messages"},renderRejection(){return u1(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}={}){let J=A();if($==null)return u1(L4,{flexDirection:"column",children:u1(R4,{color:J.colors.textMuted,children:"No messages"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Q=$??{},X=Q.data??Q,Y=Array.isArray(X.messages)?X.messages:[],K=String(X.channelId??X.channel_id??X.channel??"");if(!Y.length)return u1(L4,{flexDirection:"column",children:u1(R4,{color:J.colors.textMuted,children:"No messages"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let G=K?`#${K.replace(/^#/,"")}`:"channel",z=Y.length;return u1(L4,{flexDirection:"column",children:[u1(L4,{marginBottom:1,children:[u1(R4,{bold:!0,children:[z," "]},void 0,!0,void 0,this),u1(R4,{children:["message",z===1?"":"s"," from ",G]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Y.slice(0,3).map((q,W)=>{let U=q??{},F=String(U.user??U.username??"unknown"),O=String(U.text??U.message??""),L=O.length>60?O.substring(0,60)+"…":O;return u1(L4,{flexDirection:"column",paddingLeft:2,marginBottom:W<2?1:0,children:u1(L4,{children:[u1(R4,{bold:!0,children:[F,": "]},void 0,!0,void 0,this),u1(R4,{dimColor:!0,children:L},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},W,!1,void 0,this)}),Y.length>3&&u1(L4,{paddingLeft:2,marginTop:1,children:u1(R4,{color:J.colors.textMuted,children:["+",Y.length-3," more message",Y.length-3===1?"":"s"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}};import{Box as g6,Text as T6}from"ink";import{jsxDEV as p$}from"react/jsx-dev-runtime";var hY={displayName(){return"Slack Send"},renderInput($,{verbose:Z}={}){let J=$?.channel??"",Q=String($?.text??""),X=Q.length>40?Q.substring(0,40)+"…":Q,Y=[];if(J)Y.push(`#${String(J).replace(/^#/,"")}`);if(X)Y.push(`"${X}"`);return Y.join(" → ")||"Send message"},renderRejection(){return p$(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}={}){let J=A();if($==null)return p$(g6,{flexDirection:"column",children:p$(T6,{color:J.colors.error,children:"Failed to send message"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Q=$??{},X=Q.success!==!1&&Q.success!==null,Y=String(Q.message??Q.error??""),K=Q.data??Q,G=String(K.channelId??K.channel_id??K.channel??""),z=String(K.ts??K.timestamp??"");if(!X)return p$(g6,{flexDirection:"column",children:p$(T6,{color:J.colors.error,children:["Failed to send message",Y?`: ${Y}`:""]},void 0,!0,void 0,this)},void 0,!1,void 0,this);let q=G?`#${G.replace(/^#/,"")}`:"channel";return p$(g6,{flexDirection:"column",children:[p$(g6,{children:[p$(T6,{color:J.colors.success,children:"✓ Sent to "},void 0,!1,void 0,this),p$(T6,{bold:!0,color:J.colors.success,children:q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z&&Z&&p$(g6,{marginTop:1,paddingLeft:2,children:p$(T6,{color:J.colors.textMuted,children:["timestamp: ",z]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}};import{Box as V7,Text as D7}from"ink";import{jsxDEV as B4}from"react/jsx-dev-runtime";var EY={displayName(){return"Slack React"},renderInput($,{verbose:Z}={}){let J=String($?.name??$?.emoji??""),Q=String($?.channel??""),Y=[J.startsWith(":")?J:`:${J}:`];if(Q)Y.push(`#${Q.replace(/^#/,"")}`);return Y.join(" in ")||"Add reaction"},renderRejection(){return B4(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}={}){let J=A();if($==null)return B4(V7,{flexDirection:"column",children:B4(D7,{color:J.colors.error,children:"Failed to add reaction"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Q=$??{},X=Q.success!==!1&&Q.success!==null,Y=String(Q.message??Q.error??""),K=Q.data??Q,G=String(K.emoji??K.name??K.reaction??"");if(!X)return B4(V7,{flexDirection:"column",children:B4(D7,{color:J.colors.error,children:["Failed to add reaction",Y?`: ${Y}`:""]},void 0,!0,void 0,this)},void 0,!1,void 0,this);let z=G.startsWith(":")?G:`:${G}:`;return B4(V7,{flexDirection:"column",children:B4(D7,{color:J.colors.success,children:["✓ Added ",z]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}};import{Box as R$,Text as B$}from"ink";import{jsxDEV as D0}from"react/jsx-dev-runtime";var jY={displayName(){return"Outlook Read"},renderInput($,{verbose:Z}={}){let J=A(),Q=String($?.folder??""),X=$?.search??$?.search_query,Y=$?.filter,K=[];if(Q)K.push(`folder: ${Q}`);if(X)K.push(`search: ${String(X)}`);if(Y)K.push(`filter: ${String(Y)}`);return D0(R$,{flexDirection:"row",children:D0(B$,{children:K.length>0?K.join(", "):"Reading emails..."},void 0,!1,void 0,this)},void 0,!1,void 0,this)},renderRejection(){return D0(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}={}){let J=A();if($==null)return D0(R$,{flexDirection:"column",children:D0(B$,{children:"(No emails found)"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Q=$;if(Q.success===!1)return D0(R$,{flexDirection:"column",children:D0(B$,{color:J.colors.error,children:String(Q.message??"Error reading emails")},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(Q.success===!0){let X=Q.data??{};if(Array.isArray(X?.messages)){let K=X.messages;if(K.length===0)return D0(R$,{flexDirection:"column",children:D0(B$,{children:"(No emails)"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let G=K.length,z=K.slice(0,3);return D0(R$,{flexDirection:"column",children:[D0(B$,{children:[G," email",G!==1?"s":""]},void 0,!0,void 0,this),z.map((q,W)=>D0(R$,{flexDirection:"row",marginTop:W===0?0:0,children:D0(R$,{children:[D0(B$,{bold:!0,children:q.subject||"(No subject)"},void 0,!1,void 0,this),q.from&&D0(B$,{color:J.colors.textMuted,children:[" from ",q.from]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},W,!1,void 0,this)),G>3&&D0(B$,{color:J.colors.textMuted,children:["... and ",G-3," more"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}if(X?.subject){let K=X.subject,G=X?.from;return D0(R$,{flexDirection:"column",children:[D0(R$,{flexDirection:"row",children:D0(B$,{bold:!0,children:String(K)},void 0,!1,void 0,this)},void 0,!1,void 0,this),G&&D0(R$,{flexDirection:"row",children:D0(B$,{color:J.colors.textMuted,children:["from ",String(G)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}let Y=typeof Q.data==="string"?Q.data:JSON.stringify(Q.data,null,2);return D0(R$,{flexDirection:"column",children:D0(B$,{children:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this)}return D0(R$,{flexDirection:"column",children:D0(B$,{children:JSON.stringify($)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as I4,Text as M4}from"ink";import{jsxDEV as r1}from"react/jsx-dev-runtime";var cY={displayName(){return"Outlook Send"},renderInput($,{verbose:Z}={}){let J=A(),Q=String($?.to??""),X=String($?.subject??"");if(X.length>40)X=X.substring(0,40)+"...";return r1(I4,{flexDirection:"row",children:r1(M4,{children:["to: ",Q,X&&` — "${X}"`]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},renderRejection(){return r1(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}={}){let J=A();if($==null)return r1(I4,{flexDirection:"column",children:r1(M4,{color:J.colors.error,children:"Failed to send email"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Q=$;if(Q.success===!1)return r1(I4,{flexDirection:"column",children:r1(M4,{color:J.colors.error,children:String(Q.message??"Failed to send email")},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(Q.success===!0){let X=String(Q.message??"Email sent");return r1(I4,{flexDirection:"column",children:r1(M4,{color:J.colors.success,children:X},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if(typeof $==="string"){if($.toLowerCase().includes("sent")||$.toLowerCase().includes("success"))return r1(I4,{flexDirection:"column",children:r1(M4,{color:J.colors.success,children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this);return r1(I4,{flexDirection:"column",children:r1(M4,{color:J.colors.error,children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)}return r1(I4,{flexDirection:"column",children:r1(M4,{children:JSON.stringify($)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as C4,Text as B3}from"ink";import{jsxDEV as v1}from"react/jsx-dev-runtime";var mY={displayName(){return"Outlook Reply"},renderInput($,{verbose:Z}={}){let J=A(),Q=String($?.messageId??$?.message_id??""),X=Boolean($?.replyAll??$?.reply_all??!1),Y=Q.length>20?Q.substring(0,20)+"...":Q;return v1(C4,{flexDirection:"row",children:v1(B3,{children:[Y,X&&v1(B3,{color:J.colors.textMuted,children:" [reply-all]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},renderRejection(){return v1(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}={}){let J=A();if($==null)return v1(C4,{flexDirection:"column",children:v1(B3,{color:J.colors.error,children:"Failed to send reply"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Q=$;if(Q.success===!1)return v1(C4,{flexDirection:"column",children:v1(B3,{color:J.colors.error,children:String(Q.message??"Failed to send reply")},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(Q.success===!0){let X=String(Q.message??"Reply sent");return v1(C4,{flexDirection:"column",children:v1(B3,{color:J.colors.success,children:X},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if(typeof $==="string"){if($.toLowerCase().includes("sent")||$.toLowerCase().includes("success")||$.toLowerCase().includes("reply"))return v1(C4,{flexDirection:"column",children:v1(B3,{color:J.colors.success,children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this);return v1(C4,{flexDirection:"column",children:v1(B3,{color:J.colors.error,children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)}return v1(C4,{flexDirection:"column",children:v1(B3,{children:JSON.stringify($)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as b9,Text as I3}from"ink";import{jsxDEV as Q$,Fragment as DW}from"react/jsx-dev-runtime";function VW($){if(!$.startsWith("client-"))return $.replace(/^@/,"");return $.slice(0,15)+"…"}var dY={displayName(){return"Message"},renderInput($){let Z=String($?.to??""),J=$?.type??"quest",Q=[];if(Z)Q.push(`@${VW(Z)}`);if(J&&J!=="quest")Q.push(String(J));return Q.join(" ")||"Send message"},renderRejection(){return Q$(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}={},J){let Q=A(),X=String(J?.content??"");if($==null)return Q$(b9,{flexDirection:"column",children:[Q$(I3,{color:Q.colors.error,children:"Failed to send message"},void 0,!1,void 0,this),X&&Q$(I3,{dimColor:!0,children:X},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let Y=$??{},K=Y.success!==!1&&Y.success!==null,G=String(Y.message??Y.error??""),z=Y.data??Y,q=String(z.messageId??z.message_id??z.id??"");if(!K)return Q$(b9,{flexDirection:"column",children:[Q$(I3,{color:Q.colors.error,children:["✗ ",G||"Failed to deliver"]},void 0,!0,void 0,this),X&&Q$(I3,{dimColor:!0,children:X},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return Q$(b9,{flexDirection:"column",children:[Q$(b9,{children:[Q$(I3,{color:Q.colors.success,children:"✓ Sent"},void 0,!1,void 0,this),q&&Q$(DW,{children:[Q$(I3,{children:" "},void 0,!1,void 0,this),Q$(I3,{color:Q.colors.textMuted,dimColor:!0,children:q},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),X&&Q$(I3,{children:X},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}};import{Box as M3,Text as x$}from"ink";import{jsxDEV as o0}from"react/jsx-dev-runtime";function hW({msg:$}){let{contentWidth:Z}=F3(),J=String($.from??$.sender??"Unknown"),Q=String($.content??$.text??""),X=W1(Q,{width:Z,mode:"final"}),Y=process.platform==="darwin"?"⏺":"●";return o0(M3,{flexDirection:"column",children:[o0(M3,{flexDirection:"row",marginBottom:1,children:[o0(x$,{children:"\uD83D\uDCEC "},void 0,!1,void 0,this),o0(x$,{bold:!0,color:"cyan",children:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o0(M3,{flexDirection:"row",children:[o0(M3,{minWidth:2,children:o0(x$,{color:"cyan",children:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this),o0(M3,{flexShrink:1,width:Z,children:o0(x$,{children:X},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function EW({msg:$,verbose:Z}){let J=A(),Q=String($.from??$.sender??"Unknown"),X=String($.type??"quest"),Y=String($.content??$.text??""),K=Z||Y.length<=80?Y:Y.substring(0,80)+"…";return o0(M3,{flexDirection:"row",children:[o0(x$,{bold:!0,children:Q},void 0,!1,void 0,this),o0(x$,{children:" "},void 0,!1,void 0,this),o0(x$,{color:J.colors.textMuted,children:["[",X,"]"]},void 0,!0,void 0,this),o0(x$,{children:" "},void 0,!1,void 0,this),o0(x$,{children:K},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function jW($){if($==null)return[];let Z=$;if(typeof $==="string")try{Z=JSON.parse($)}catch{return[]}let J=Z.data??Z;return Array.isArray(J.messages)?J.messages:[]}var pY={displayName(){return"Inbox"},renderInput($){let Z=$?.from,J=$?.type,Q=$?.unreadOnly,X=[];if(Z)X.push(`from: ${String(Z)}`);if(J)X.push(`type: [${String(J)}]`);if(Q===!0)X.push("unread only");return X.length>0?X.join(" "):"Check messages"},renderRejection(){return o0(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}={}){let J=A(),Q=jW($);if(Q.length===0)return o0(x$,{color:J.colors.textMuted,children:"No messages"},void 0,!1,void 0,this);let X=Q[0];if(Q.length===1&&X&&X.type==="incoming")return o0(hW,{msg:X},void 0,!1,void 0,this);let Y=Q.length;return o0(M3,{flexDirection:"column",children:[o0(x$,{children:[Y," message",Y!==1?"s":""]},void 0,!0,void 0,this),o0(M3,{flexDirection:"column",marginTop:1,paddingLeft:2,children:Q.map((K,G)=>o0(EW,{msg:K,verbose:Z??!1},G,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}};import{Box as y9,Text as f4}from"ink";import{jsxDEV as I$}from"react/jsx-dev-runtime";var xY={displayName(){return"Search Messages"},renderInput($,{verbose:Z}={}){let J=String($?.query??"");return J?`"${J}"`:"Search messages"},renderRejection(){return I$(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}={}){let J=A();if($==null)return I$(f4,{color:J.colors.textMuted,children:"No results"},void 0,!1,void 0,this);let Q=$??{},X=Q.data??Q,Y=Array.isArray(X.messages)?X.messages:Array.isArray(X.results)?X.results:[];if(!Y||Y.length===0)return I$(f4,{color:J.colors.textMuted,children:"No results"},void 0,!1,void 0,this);let K=Y.length,G=Math.min(3,Y.length),z=Y.slice(0,G);return I$(y9,{flexDirection:"column",children:[I$(f4,{children:[K," result",K!==1?"s":""]},void 0,!0,void 0,this),z.length>0&&I$(y9,{flexDirection:"column",marginTop:1,paddingLeft:2,children:z.map((q,W)=>{let U=String(q.from??q.sender??"Unknown"),F=String(q.content??q.text??""),O=F.length>40?F.substring(0,40)+"…":F;return I$(y9,{flexDirection:"row",children:[I$(f4,{bold:!0,children:U},void 0,!1,void 0,this),I$(f4,{children:" "},void 0,!1,void 0,this),I$(f4,{color:J.colors.textMuted,children:O},void 0,!1,void 0,this)]},W,!0,void 0,this)})},void 0,!1,void 0,this),Y.length>G&&I$(y9,{marginTop:1,paddingLeft:2,children:I$(f4,{color:J.colors.textMuted,children:["... and ",Y.length-G," more"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}};import{Box as k9,Text as S4}from"ink";import{jsxDEV as M$}from"react/jsx-dev-runtime";var lY={displayName(){return"Thread"},renderInput($,{verbose:Z}={}){let J=String($?.messageId??$?.message_id??"");return J?`messageId: ${J}`:"Get thread"},renderRejection(){return M$(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}={}){let J=A();if($==null)return M$(S4,{color:J.colors.textMuted,children:"No messages in thread"},void 0,!1,void 0,this);let Q=$??{},X=Q.data??Q,Y=Array.isArray(X.messages)?X.messages:[];if(!Y||Y.length===0)return M$(S4,{color:J.colors.textMuted,children:"No messages in thread"},void 0,!1,void 0,this);let K=Y.length,G=Math.min(3,Y.length),z=Y.slice(0,G);return M$(k9,{flexDirection:"column",children:[M$(S4,{children:[K," message",K!==1?"s":""," in thread"]},void 0,!0,void 0,this),z.length>0&&M$(k9,{flexDirection:"column",marginTop:1,paddingLeft:2,children:z.map((q,W)=>{let U=String(q.from??q.sender??"Unknown"),F=String(q.content??q.text??""),O=F.length>40?F.substring(0,40)+"…":F;return M$(k9,{flexDirection:"row",children:[M$(S4,{bold:!0,children:U},void 0,!1,void 0,this),M$(S4,{children:" "},void 0,!1,void 0,this),M$(S4,{color:J.colors.textMuted,children:O},void 0,!1,void 0,this)]},W,!0,void 0,this)})},void 0,!1,void 0,this),Y.length>G&&M$(k9,{marginTop:1,paddingLeft:2,children:M$(S4,{color:J.colors.textMuted,children:["... and ",Y.length-G," more"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}};import{Box as V6,Text as D6}from"ink";import{jsxDEV as l$}from"react/jsx-dev-runtime";var uY={displayName(){return"Clients"},renderInput($,{verbose:Z}={}){return"List clients"},renderRejection(){return l$(C,{},void 0,!1,void 0,this)},renderOutput($,{verbose:Z}={}){let J=A();if($==null)return l$(V6,{flexDirection:"column",children:l$(D6,{children:"No clients connected"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Q=$??{},X=Q.data??Q,Y=Array.isArray(X.clients)?X.clients:[];if(!Y||Y.length===0)return l$(V6,{flexDirection:"column",children:l$(D6,{children:"No clients connected"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let K=Y.length,G=Y.map((z)=>String(z.name??z.displayName??z.id??"Unknown")).slice(0,10);return l$(V6,{flexDirection:"column",children:[l$(D6,{children:[K," client",K!==1?"s":""," connected"]},void 0,!0,void 0,this),G.length>0&&l$(V6,{flexDirection:"column",marginTop:1,paddingLeft:2,children:G.map((z,q)=>l$(D6,{color:J.colors.textMuted,children:["• ",z]},q,!0,void 0,this))},void 0,!1,void 0,this),Y.length>10&&l$(V6,{marginTop:1,paddingLeft:2,children:l$(D6,{color:J.colors.textMuted,children:["... and ",Y.length-10," more"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}};import{Box as C3,Text as y8}from"ink";import{jsxDEV as g1,Fragment as cW}from"react/jsx-dev-runtime";var rY={displayName(){return"Remote Delegate"},renderInput($,Z={}){let J=[];if($.node_id)J.push($.node_id);if($.task){let Q=$.task.length>40?`${$.task.slice(0,40)}...`:$.task;J.push(Q)}return J.length>0?J.join(": "):Object.entries($).map(([Q,X])=>`${Q}: ${JSON.stringify(X)}`).join(", ")},renderRejection(){return g1(C,{},void 0,!1,void 0,this)},renderOutput($,Z={}){let J=A();if(!$)return g1(C3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:g1(C3,{flexDirection:"row",children:g1(y8,{color:J.colors.textMuted,children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string")return g1(C3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:g1(C3,{flexDirection:"row",children:g1(y8,{children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if($.error)return g1(C3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:g1(C3,{flexDirection:"row",children:g1(y8,{color:J.colors.error,children:$.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return g1(C3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:g1(C3,{flexDirection:"row",children:[g1(y8,{color:J.colors.success,children:"Delegated to node"},void 0,!1,void 0,this),$.quest_id&&g1(cW,{children:[g1(y8,{children:" "},void 0,!1,void 0,this),g1(y8,{color:J.colors.textMuted,children:$.quest_id},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}};import{Box as f3,Text as v9}from"ink";import{jsxDEV as H$}from"react/jsx-dev-runtime";var aY={displayName(){return"Pause"},renderInput($,Z={}){if($.id)return $.id;return Object.entries($).map(([J,Q])=>`${J}: ${JSON.stringify(Q)}`).join(", ")},renderRejection(){return H$(C,{},void 0,!1,void 0,this)},renderOutput($,Z={}){let J=A();if(!$)return H$(f3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:H$(f3,{flexDirection:"row",children:H$(v9,{color:J.colors.textMuted,children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string")return H$(f3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:H$(f3,{flexDirection:"row",children:H$(v9,{children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if($.error)return H$(f3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:H$(f3,{flexDirection:"row",children:H$(v9,{color:J.colors.error,children:$.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return H$(f3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:H$(f3,{flexDirection:"row",children:H$(v9,{color:J.colors.success,children:"Paused"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as S3,Text as k8}from"ink";import{jsxDEV as T1,Fragment as mW}from"react/jsx-dev-runtime";var nY={displayName(){return"Resume"},renderInput($,Z={}){if($.id)return $.id;return Object.entries($).map(([J,Q])=>`${J}: ${JSON.stringify(Q)}`).join(", ")},renderRejection(){return T1(C,{},void 0,!1,void 0,this)},renderOutput($,Z={}){let J=A();if(!$)return T1(S3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:T1(S3,{flexDirection:"row",children:T1(k8,{color:J.colors.textMuted,children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string")return T1(S3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:T1(S3,{flexDirection:"row",children:T1(k8,{children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if($.error)return T1(S3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:T1(S3,{flexDirection:"row",children:T1(k8,{color:J.colors.error,children:$.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return T1(S3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:T1(S3,{flexDirection:"row",children:[T1(k8,{color:J.colors.success,children:"Resumed"},void 0,!1,void 0,this),$.quest_id&&T1(mW,{children:[T1(k8,{children:" "},void 0,!1,void 0,this),T1(k8,{color:J.colors.textMuted,children:$.quest_id},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}};import{Box as W$,Text as b4}from"ink";import{jsxDEV as Z1}from"react/jsx-dev-runtime";var iY={displayName(){return"Quest Report"},renderInput($,Z={}){if($.quest_id)return $.quest_id;return Object.entries($).map(([J,Q])=>`${J}: ${JSON.stringify(Q)}`).join(", ")},renderRejection(){return Z1(C,{},void 0,!1,void 0,this)},renderOutput($,Z={}){let J=A();if(!$)return Z1(W$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:Z1(W$,{flexDirection:"row",children:Z1(b4,{color:J.colors.textMuted,children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string")return Z1(W$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:Z1(W$,{flexDirection:"row",children:Z1(b4,{children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if($.error)return Z1(W$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:Z1(W$,{flexDirection:"row",children:Z1(b4,{color:J.colors.error,children:$.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if($.data){let{commits:Q,filesChanged:X,cost:Y}=$.data,K=[];if(Q!==void 0)K.push(`${Q} commit${Q!==1?"s":""}`);if(X!==void 0)K.push(`${X} file${X!==1?"s":""} changed`);return Z1(W$,{flexDirection:"column",children:[K.length>0&&Z1(W$,{flexDirection:"row",children:Z1(b4,{children:K.join(", ")},void 0,!1,void 0,this)},void 0,!1,void 0,this),Y!==void 0&&Z1(W$,{flexDirection:"row",children:Z1(b4,{color:J.colors.textMuted,children:["Cost: ",Y]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}if($.message)return Z1(W$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:Z1(W$,{flexDirection:"row",children:Z1(b4,{children:$.message},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return Z1(W$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:Z1(W$,{flexDirection:"row",children:Z1(b4,{color:J.colors.textMuted,children:"(No data)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as a1,Text as b3}from"ink";import{jsxDEV as m0}from"react/jsx-dev-runtime";var oY={displayName(){return"Network"},renderInput($,Z={}){if($.action)return $.action;return Object.entries($).map(([J,Q])=>`${J}: ${JSON.stringify(Q)}`).join(", ")},renderRejection(){return m0(C,{},void 0,!1,void 0,this)},renderOutput($,Z={}){let J=A();if(!$)return m0(a1,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:m0(a1,{flexDirection:"row",children:m0(b3,{color:J.colors.textMuted,children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string")return m0(a1,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:m0(a1,{flexDirection:"row",children:m0(b3,{children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if($.error)return m0(a1,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:m0(a1,{flexDirection:"row",children:m0(b3,{color:J.colors.error,children:$.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if($.inviteToken){let Q=$.inviteToken.length>20?`${$.inviteToken.slice(0,20)}...`:$.inviteToken;return m0(a1,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:m0(a1,{flexDirection:"row",children:m0(b3,{color:J.colors.success,children:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if($.peers&&Array.isArray($.peers)){let Q=$.peers.map((X)=>X.displayName||X.nodeId||"unknown").slice(0,3);return m0(a1,{flexDirection:"column",children:[m0(a1,{flexDirection:"row",children:m0(b3,{children:[$.peers.length," peer",$.peers.length!==1?"s":""]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Q.length>0&&m0(a1,{flexDirection:"row",children:m0(b3,{color:J.colors.textMuted,children:Q.join(", ")},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}if($.message)return m0(a1,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:m0(a1,{flexDirection:"row",children:m0(b3,{children:$.message},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return m0(a1,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:m0(a1,{flexDirection:"row",children:m0(b3,{color:J.colors.success,children:"Success"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as N$,Text as y4}from"ink";import{jsxDEV as J1}from"react/jsx-dev-runtime";var sY={displayName(){return"Deploy"},renderInput($,Z={}){let J=[];if($.target)J.push($.target);if($.branch)J.push(`(${$.branch})`);return J.length>0?J.join(" "):Object.entries($).map(([Q,X])=>`${Q}: ${JSON.stringify(X)}`).join(", ")},renderRejection(){return J1(C,{},void 0,!1,void 0,this)},renderOutput($,Z={}){let J=A();if(!$)return J1(N$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:J1(N$,{flexDirection:"row",children:J1(y4,{color:J.colors.textMuted,children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string")return J1(N$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:J1(N$,{flexDirection:"row",children:J1(y4,{children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if($.error)return J1(N$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:J1(N$,{flexDirection:"row",children:J1(y4,{color:J.colors.error,children:$.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if($.host&&$.port)return J1(N$,{flexDirection:"column",children:[J1(N$,{flexDirection:"row",children:J1(y4,{color:J.colors.success,children:["Deployed to ",$.host,":",$.port]},void 0,!0,void 0,this)},void 0,!1,void 0,this),$.fingerprint&&J1(N$,{flexDirection:"row",children:J1(y4,{color:J.colors.textMuted,children:$.fingerprint},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if($.message)return J1(N$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:J1(N$,{flexDirection:"row",children:J1(y4,{children:$.message},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return J1(N$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:J1(N$,{flexDirection:"row",children:J1(y4,{color:J.colors.success,children:"Deployed"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as P$,Text as k4}from"ink";import{jsxDEV as Q1}from"react/jsx-dev-runtime";var tY={displayName(){return"History"},renderInput($,Z={}){let J=[];if($.action)J.push($.action);if($.query)J.push(`"${$.query}"`);return J.length>0?J.join(" "):Object.entries($).map(([Q,X])=>`${Q}: ${JSON.stringify(X)}`).join(", ")},renderRejection(){return Q1(C,{},void 0,!1,void 0,this)},renderOutput($,Z={}){let J=A();if(!$)return Q1(P$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:Q1(P$,{flexDirection:"row",children:Q1(k4,{color:J.colors.textMuted,children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string")return Q1(P$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:Q1(P$,{flexDirection:"row",children:Q1(k4,{children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if($.error)return Q1(P$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:Q1(P$,{flexDirection:"row",children:Q1(k4,{color:J.colors.error,children:$.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if($.data?.sessions&&Array.isArray($.data.sessions)){let Q=$.data.sessions,X=Q.slice(0,3).map((Y)=>{let K=Y.title||Y.id||"untitled";return b1(K.slice(0,50))});return Q1(P$,{flexDirection:"column",children:[Q1(P$,{flexDirection:"row",children:Q1(k4,{children:[Q.length," session",Q.length!==1?"s":""]},void 0,!0,void 0,this)},void 0,!1,void 0,this),X.length>0&&Q1(P$,{flexDirection:"row",children:Q1(k4,{color:J.colors.textMuted,children:X.join(", ")},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}if($.message)return Q1(P$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:Q1(P$,{flexDirection:"row",children:Q1(k4,{children:$.message},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return Q1(P$,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:Q1(P$,{flexDirection:"row",children:Q1(k4,{color:J.colors.success,children:"Success"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};import{Box as y3,Text as g9}from"ink";import{jsxDEV as _$}from"react/jsx-dev-runtime";var eY={displayName(){return"Restart"},renderInput($,Z={}){if($.reason)return $.reason;return Object.entries($).map(([J,Q])=>`${J}: ${JSON.stringify(Q)}`).join(", ")},renderRejection(){return _$(C,{},void 0,!1,void 0,this)},renderOutput($,Z={}){let J=A();if(!$)return _$(y3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:_$(y3,{flexDirection:"row",children:_$(g9,{color:J.colors.textMuted,children:"(No content)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(typeof $==="string")return _$(y3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:_$(y3,{flexDirection:"row",children:_$(g9,{children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);if($.error)return _$(y3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:_$(y3,{flexDirection:"row",children:_$(g9,{color:J.colors.error,children:$.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this);return _$(y3,{justifyContent:"space-between",overflowX:"hidden",width:"100%",children:_$(y3,{flexDirection:"row",children:_$(g9,{color:J.colors.warning,children:"Restarting..."},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}};var h6={bash:A3,exec:A3,spawn:A3,execute_command:A3,file_edit:Y9,edit_file:Y9,file_read:_7,read_file:_7,file_write:A7,write_file:A7,grep:LX,search:WY,glob:BX,web_search:cX,rg:_Y,ug:UY,frg:SY,fff:bY,probe:wY,sg:RY,lsp:fY,cbm:IY,serena:yY,list_dir:q9,ls:q9,web_fetch:EX,browse:jX,recall:W9,recall_knowledge:W9,remember:f6,forget:f6,reflect:f6,memory_read:W9,memory_write:f6,learn:mX,learn_tool:pX,learn_skill:lX,create_tool:uX,create_skill:aX,use_skill:iX,ask_user:eX,quest_list:oX,quest_update:sX,kill:A3,write_stdin:A3,list_processes:q9,wait_process:A3,spawn_worker:GY,apply_patch:Y9,delegate_arion:R7,check_delegation:zY,hatch_arion:$Y,rest_arion:JY,wake_arion:XY,retire_arion:KY,mcp:CX,think:SX,agent:R7,notebook_read:yX,notebook_edit:kX,architect:gX,sticker_request:DX,browser:qY,process:HY,self_diagnose:NY,check_quip_documents:kY,send_quip_comment:gY,create_quip_document:VY,check_slack_messages:DY,send_slack_message:hY,react_slack_message:EY,check_outlook_messages:jY,send_outlook_message:cY,reply_outlook_message:mY,send_message:dY,check_messages:pY,search_messages:xY,get_thread:lY,list_clients:uY,delegate_remote:rY,pause_delegation:aY,resume_delegation:nY,quest_report:iY,manage_network:oY,deploy:sY,session_history:tY,restart:eY};import{jsxDEV as C$}from"react/jsx-dev-runtime";var dW=5;function JK({item:$,verbose:Z}){let J=h6[$.toolName.toLowerCase()],Q=process.stdout.columns||80,X=Math.max(Q-dW,1),Y={terminalWidth:Q,contentWidth:X};if($.id.includes("synthetic_inbox_")&&$.output!=null)return C$(Z9,{value:Y,children:E7(J,$.output,Z,$.input)??C$(h7,{children:typeof $.output==="string"?$.output:JSON.stringify($.output)},void 0,!1,void 0,this)},void 0,!1,void 0,this);let K=ZK(()=>J?.displayName($.input))??$.toolName,G=ZK(()=>J?.renderInput($.input,{verbose:Z}));return C$($K,{flexDirection:"column",children:[C$(KX,{displayName:K,args:G,status:$.status,durationMs:$.durationMs,verbose:Z},void 0,!1,void 0,this),$.output!=null&&$.status!=="error"&&C$(G7,{children:C$(Z9,{value:Y,children:E7(J,$.output,Z,$.input)??C$(h7,{children:typeof $.output==="string"?$.output:JSON.stringify($.output)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),$.status==="error"&&C$(G7,{children:C$(Z9,{value:Y,children:$.output!=null&&E7(J,$.output,Z,$.input)||C$(h7,{color:"red",children:$.error??"Tool error"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Z&&$.usage&&C$($K,{marginLeft:2,children:C$(GX,{durationMs:$.durationMs,usage:{inputTokens:$.usage.inputTokens??0,outputTokens:$.usage.outputTokens??0,totalTokens:($.usage.inputTokens??0)+($.usage.outputTokens??0),estimatedCost:0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ZK($){try{return $()}catch{return}}function E7($,Z,J,Q){if(!$?.renderOutput)return null;try{return $.renderOutput(Z,{verbose:J},Q)??null}catch{return null}}import{jsxDEV as s0}from"react/jsx-dev-runtime";var T9=QK.memo(function({item:Z,displayMode:J,showPrefix:Q,previewTailLines:X}){let Y=J==="debug",{columns:K}=K1();switch(Z.kind){case"user-message":return s0(iZ,{param:{type:"text",text:Z.text},userName:Z.userName,columns:K,addMargin:Q,showPrefix:Q},void 0,!1,void 0,this);case"user-image":return s0(tQ,{dataUri:Z.dataUri,userName:Z.userName,showPrefix:Q},void 0,!1,void 0,this);case"assistant-text":{let G=process.platform==="darwin"?"⏺":"●",z=Z.arion?.color??"cyan",q=Math.max(K-4,20),W=W1(Z.text,{width:q,mode:Z.committed?"final":"streaming"}),U=!Z.committed&&X?Math.max(X-(Q&&Z.arion?1:0),1):void 0,F=U!=null?xW(W,q,U):W;return s0(k3,{flexDirection:"column",children:[Q&&Z.arion&&s0(k3,{flexDirection:"row",marginBottom:1,children:[s0(w2,{children:[Z.arion.emoji," "]},void 0,!0,void 0,this),s0(w2,{bold:!0,color:z,children:Z.arion.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),s0(k3,{flexDirection:"row",children:[s0(k3,{minWidth:2,children:s0(w2,{color:z,children:G},void 0,!1,void 0,this)},void 0,!1,void 0,this),s0(k3,{flexShrink:1,width:q,children:s0(w2,{children:F},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}case"thinking":{if(!Z.content&&Z.durationSec!=null)return s0(k3,{flexDirection:"column",children:[Q&&Z.arion&&s0(k3,{flexDirection:"row",marginBottom:1,children:[s0(w2,{children:[Z.arion.emoji," "]},void 0,!0,void 0,this),s0(w2,{bold:!0,color:Z.arion.color,children:Z.arion.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),s0(w2,{dimColor:!0,children:["✻"," Thought for ",Z.durationSec.toFixed(1),"s"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);if(!Z.content)return null;return s0(X7,{content:Z.content,expanded:Y,durationSeconds:Z.durationSec,arionName:Q?Z.arion?.name:void 0,arionEmoji:Q?Z.arion?.emoji:void 0,arionColor:Q?Z.arion?.color:void 0,isLive:!Z.committed},void 0,!1,void 0,this)}case"tool-execution":return s0(JK,{item:Z,verbose:Y},void 0,!1,void 0,this);case"error":{let G=A();return s0(k3,{flexDirection:"column",children:[s0(w2,{color:G.colors.error,children:Z.message},void 0,!1,void 0,this),Z.suggestion&&s0(w2,{dimColor:!0,children:[" Suggestion: ",Z.suggestion]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}case"handoff":return s0(w2,{dimColor:!0,children:[Z.direction==="outgoing"?"→":"←"," Handoff to ",Z.target]},void 0,!0,void 0,this)}});function xW($,Z,J){return $.split(`
|
|
102
|
-
`).flatMap((X)=>pW(X,Z,{hard:!1,trim:!1,wordWrap:!0}).split(`
|
|
103
|
-
`)).slice(-J).join(`
|
|
104
|
-
`)}function j7($,Z){if(Z==="debug")return $;return $.flatMap((J)=>{if(J.kind==="thinking"){if(Z==="minimal")return[];if(J.durationSec==null)return[];return[{...J,content:""}]}return[J]})}import{jsxDEV as IS}from"react/jsx-dev-runtime";import{Box as lW,Text as uW}from"ink";import{useEffect as rW,useRef as SS,useState as aW}from"react";import{jsxDEV as YK}from"react/jsx-dev-runtime";var XK=process.platform==="darwin"?["·","✢","✳","∗","✻","✽"]:["·","✢","*","∗","✻","✽"],kS=w6.map(($)=>$.present);function v8(){let $=[...XK,...[...XK].reverse()],[Z,J]=aW(0);return rW(()=>{let Q=setInterval(()=>{J((X)=>(X+1)%$.length)},120);return()=>clearInterval(Q)},[$.length]),YK(lW,{flexWrap:"nowrap",height:1,width:2,children:YK(uW,{color:A().colors.primary,children:$[Z]},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{useEffect as nW,useRef as c7,useState as m7}from"react";import{Box as u$,Text as f$,useInput as KK}from"ink";import{loginWithGitHubCopilotDeviceFlow as iW}from"@aria-cli/auth";import{jsxDEV as h0}from"react/jsx-dev-runtime";function d7({provider:$,profileLabel:Z,onCancel:J,isActive:Q=!0,onComplete:X,verificationUri:Y,userCode:K,onApprove:G}){let z=A(),[q,W]=m7("starting"),[U,F]=m7(""),[O,L]=m7(null),B=c7(!1),S=c7(!1),k=c7(null),y=process.stdin.isTTY??!1;return KK((f,M)=>{if(!e(f,M))return;k.current?.abort(),J()},{isActive:Q&&y}),KK((f,M)=>{if(!(M.return||f==="\r"))return;if(!Y||!K||!G)return;W("starting"),Promise.resolve(G()).catch((I)=>{let R=I instanceof Error?I.message:String(I);F(R),W("error")})},{isActive:Q&&y}),nW(()=>{if(B.current)return;if(B.current=!0,Y&&K&&G){L({verificationUri:Y,userCode:K,expiresAt:Date.now()+300000,intervalMs:5000}),W("waiting");return}let f=new AbortController;return k.current=f,W("starting"),iW({profileLabel:Z,signal:f.signal,onDeviceCode:(M)=>{L(M),W("waiting")}}).then((M)=>{if(S.current||f.signal.aborted)return;if(M.success)W("success"),S.current=!0,setTimeout(()=>{X?.({success:!0,message:M.message})},1000);else F(M.message),W("error")},(M)=>{if(S.current||f.signal.aborted)return;let I=M instanceof Error?M.message:String(M);F(I),W("error")}),()=>{f.abort()}},[G,X,Z,K,Y]),h0(u$,{flexDirection:"column",borderStyle:"round",borderColor:z.colors.secondary,paddingX:1,paddingY:1,width:64,children:[h0(u$,{marginBottom:1,children:h0(f$,{bold:!0,children:["Sign in to ",$]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Z&&h0(u$,{marginBottom:1,children:h0(f$,{color:z.colors.textMuted,children:["Profile: github-copilot:",Z]},void 0,!0,void 0,this)},void 0,!1,void 0,this),q==="starting"&&h0(u$,{gap:1,children:[h0(v8,{},void 0,!1,void 0,this),h0(f$,{children:"Requesting GitHub device code..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q==="waiting"&&O&&h0(u$,{flexDirection:"column",children:[h0(f$,{children:"Authorize this device in your browser:"},void 0,!1,void 0,this),h0(u$,{marginTop:1,children:h0(f$,{color:z.colors.primary,children:O.verificationUri},void 0,!1,void 0,this)},void 0,!1,void 0,this),h0(u$,{marginTop:1,children:h0(f$,{children:["Code: ",h0(f$,{bold:!0,children:O.userCode},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),h0(u$,{marginTop:1,gap:1,children:[h0(v8,{},void 0,!1,void 0,this),h0(f$,{children:Y&&K&&G?"Press Enter after approving in GitHub, or Esc to cancel.":"Waiting for GitHub authorization..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q==="success"&&h0(f$,{color:z.colors.success,children:["✓"," Logged in to ",$]},void 0,!0,void 0,this),q==="error"&&h0(u$,{flexDirection:"column",children:[h0(f$,{color:z.colors.error,children:["✗"," ",U]},void 0,!0,void 0,this),h0(u$,{marginTop:1,children:h0(f$,{color:z.colors.textMuted,children:"Press Esc to dismiss"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q!=="success"&&q!=="error"&&h0(u$,{marginTop:1,children:h0(f$,{color:z.colors.textMuted,children:"Esc Cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useRef as GK,useState as oW}from"react";import{Box as V9,Text as g8,useInput as sW}from"ink";import{jsxDEV as r$}from"react/jsx-dev-runtime";function tW({status:$}){let Z=A();if($==="connected")return r$(g8,{color:Z.colors.success,children:["✓"," available"]},void 0,!0,void 0,this);return r$(g8,{color:Z.colors.textMuted,children:["·"," requires login"]},void 0,!0,void 0,this)}function p7({options:$,onSelect:Z,onCancel:J,isActive:Q=!0}){let X=A(),[Y,K]=oW(0),G=GK(0),z=GK(!1),q=process.stdin.isTTY??!1,W=(U)=>{K((F)=>{let O=U(F);return G.current=O,O})};return sW((U,F)=>{if(z.current)return;if(F.upArrow)W((O)=>Math.max(0,O-1));else if(F.downArrow)W((O)=>Math.min($.length-1,O+1));else if(F.return)z.current=!0,Z($[G.current]);else if(e(U,F))z.current=!0,J()},{isActive:Q&&q}),r$(V9,{flexDirection:"column",borderStyle:"round",borderColor:X.colors.secondary,paddingX:1,paddingY:1,width:72,children:[r$(V9,{marginBottom:1,children:r$(g8,{bold:!0,children:"Select GitHub Copilot login source:"},void 0,!1,void 0,this)},void 0,!1,void 0,this),$.map((U,F)=>{let O=F===Y,L=O?"▸":" ";return r$(V9,{gap:1,children:[r$(g8,{color:O?X.colors.primary:void 0,children:L},void 0,!1,void 0,this),r$(g8,{color:O?X.colors.primary:void 0,bold:O,children:U.label.padEnd(44)},void 0,!1,void 0,this),r$(tW,{status:U.status},void 0,!1,void 0,this)]},U.id,!0,void 0,this)}),r$(V9,{marginTop:1,children:r$(g8,{color:X.colors.textMuted,children:["↑↓"," Navigate Enter Select Esc Cancel"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useState as D9,useEffect as eW,useRef as zK,useCallback as $N}from"react";import{Box as h9,Text as x2,useInput as ZN,useStdout as JN}from"ink";import QN from"gradient-string";import{jsxDEV as F$}from"react/jsx-dev-runtime";var XN=` · ·
|
|
105
|
-
· ·
|
|
106
|
-
( \uD83E\uDD8B )
|
|
107
|
-
· ·
|
|
108
|
-
· ·`,qK=` █████╗ ██████╗ ██╗ █████╗
|
|
109
|
-
██╔══██╗██╔══██╗██║██╔══██╗
|
|
110
|
-
███████║██████╔╝██║███████║
|
|
111
|
-
██╔══██║██╔══██╗██║██╔══██║
|
|
112
|
-
██║ ██║██║ ██║██║██║ ██║
|
|
113
|
-
╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═╝`,YN="─────────────────",KN="A R I A",GN="─────────────────",zN="✦ Adaptive Reasoning Intelligence Agent ✦";function x7({onComplete:$,skipAnimation:Z=!1,version:J="dev",whatsNew:Q=[]}){let X=A(),{stdout:Y}=JN(),K=Y?.columns||80,[G,z]=D9(Z?"complete":"butterfly"),[q,W]=D9(Z),[U,F]=D9(Z),[O,L]=D9(Z),B=zK(!1),S=zK([]),k=$N(()=>{if(!B.current)B.current=!0,$()},[$]);ZN(()=>{if(G!=="complete")S.current.forEach(clearTimeout),S.current=[],z("complete"),W(!0),F(!0),L(!0),k()}),eW(()=>{if(Z){k();return}let M=[];return M.push(setTimeout(()=>{z("logo"),W(!0)},400)),M.push(setTimeout(()=>{z("gradient"),L(!0)},800)),M.push(setTimeout(()=>{z("tagline"),F(!0)},1200)),M.push(setTimeout(()=>{z("complete"),k()},1600)),S.current=M,()=>{M.forEach(clearTimeout)}},[Z,k]);let y=QN([X.banner.gradient.start,X.banner.gradient.middle,X.banner.gradient.end]),f=()=>{if(!q)return null;if(O)return y(qK);return qK};return F$(h9,{flexDirection:"column",alignItems:"center",width:K,paddingY:1,children:[F$(x2,{color:X.colors.primary,children:XN},void 0,!1,void 0,this),q&&F$(x2,{children:f()},void 0,!1,void 0,this),U&&F$(h9,{flexDirection:"column",alignItems:"center",children:[F$(x2,{dimColor:!0,children:YN},void 0,!1,void 0,this),F$(x2,{bold:!0,children:KN},void 0,!1,void 0,this),F$(x2,{dimColor:!0,children:GN},void 0,!1,void 0,this),F$(x2,{color:X.colors.primary,children:zN},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U&&F$(h9,{marginTop:1,children:F$(x2,{dimColor:!0,children:["v",J]},void 0,!0,void 0,this)},void 0,!1,void 0,this),U&&Q.length>0&&F$(h9,{flexDirection:"column",alignItems:"center",marginTop:1,children:[F$(x2,{bold:!0,color:X.colors.secondary,children:"What's New"},void 0,!1,void 0,this),Q.map((M,I)=>F$(x2,{dimColor:!0,children:["• ",M]},I,!0,void 0,this))]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}import{Box as Qb,Text as Xb,useStdout as Yb}from"ink";import{jsxDEV as zb}from"react/jsx-dev-runtime";import{Box as Wb,Text as Nb}from"ink";import{jsxDEV as Fb}from"react/jsx-dev-runtime";import{useState as wb,useRef as Lb}from"react";import{Box as Bb,Text as Ib,useInput as Mb}from"ink";import{jsxDEV as yb}from"react/jsx-dev-runtime";import{useState as HN,useRef as HK}from"react";import{Box as E6,Text as v4,useInput as WN}from"ink";import{AUTONOMY_LEVELS as E9}from"@aria-cli/aria";import{jsxDEV as S$}from"react/jsx-dev-runtime";var NN={minimal:"Confirm all tool calls",balanced:"Confirm dangerous only",high:"Auto-approve everything",full:"Auto-approve everything"};function l7({currentLevel:$,onSelect:Z,onCancel:J,isActive:Q=!0}){let X=A(),Y=E9.indexOf($),K=Y>=0?Y:0,[G,z]=HN(K),q=HK(K),W=HK(!1),U=(O)=>{z((L)=>{let B=O(L);return q.current=B,B})},F=process.stdin.isTTY??!1;return WN((O,L)=>{if(W.current)return;if(L.upArrow)U((B)=>Math.max(0,B-1));else if(L.downArrow)U((B)=>Math.min(E9.length-1,B+1));else if(L.return)W.current=!0,Z(E9[q.current]);else if(e(O,L))W.current=!0,J()},{isActive:Q&&F}),S$(E6,{flexDirection:"column",borderStyle:"round",borderColor:X.colors.secondary,paddingX:1,paddingY:1,width:48,children:[S$(E6,{marginBottom:1,children:S$(v4,{bold:!0,children:"Autonomy Level"},void 0,!1,void 0,this)},void 0,!1,void 0,this),S$(E6,{marginBottom:1,children:S$(v4,{children:["Current: ",S$(v4,{bold:!0,children:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),E9.map((O,L)=>{let B=L===G,S=B?"●":"○",k=O==="high"||O==="full";return S$(E6,{gap:1,children:[S$(v4,{color:B?X.colors.primary:void 0,children:S},void 0,!1,void 0,this),S$(v4,{color:B?X.colors.primary:k?X.colors.warning:void 0,bold:B,children:O.padEnd(10)},void 0,!1,void 0,this),S$(v4,{color:X.colors.textMuted,children:NN[O]},void 0,!1,void 0,this)]},O,!0,void 0,this)}),S$(E6,{marginTop:1,children:S$(v4,{color:X.colors.textMuted,children:["↑↓"," Navigate Enter Select Esc Cancel"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{Box as mb,Text as db}from"ink";import{jsxDEV as lb}from"react/jsx-dev-runtime";import{Box as j9,Text as g4}from"ink";import{jsxDEV as a$}from"react/jsx-dev-runtime";var PN=1,_N=20,u7={model_call:"model_call",tool_execution:"tool_exec",handoff:"handoff",approval:"approval",session_phase:"session",runner_phase:"runner"};function FN($){if($<1000)return`${Math.round($)}ms`;if($<60000)return`${($/1000).toFixed(1)}s`;let Z=Math.floor($/60000),J=Math.round($%60000/1000);return`${Z}m ${J}s`}function WK($,Z,J){let Q=Math.round(Z*$),X=Math.max(PN,Math.round(J*$)),Y=Math.max(0,$-Q-X);return"░".repeat(Q)+"█".repeat(X)+"░".repeat(Y)}function r7({spans:$,width:Z}){let J=A(),Q=Z??_N,X=$.filter((W)=>W.endTime!==void 0||W.durationMs!==void 0);if(X.length===0)return a$(j9,{children:a$(g4,{dimColor:!0,children:"(no completed spans)"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let Y=X.map((W)=>{let U=W.durationMs??W.endTime-W.startTime,F=W.endTime??W.startTime+U;return{...W,durationMs:U,endTime:F}}),K=Math.min(...Y.map((W)=>W.startTime)),z=Math.max(...Y.map((W)=>W.endTime))-K;if(z<=0)return a$(j9,{flexDirection:"column",children:Y.map((W)=>a$(g4,{dimColor:!0,children:[u7[W.spanType]??W.spanType," ","█"," 0ms (",W.name,")"]},W.spanId,!0,void 0,this))},void 0,!1,void 0,this);let q=Math.max(...Y.map((W)=>{let U=u7[W.spanType]??W.spanType;return(W.parentSpanId!==void 0?2:0)+U.length}));return a$(j9,{flexDirection:"column",children:Y.map((W)=>{let U=W.parentSpanId!==void 0,F=U?" ":"",O=u7[W.spanType]??W.spanType,L=(F+O).padEnd(q),B=(W.startTime-K)/z,S=W.durationMs/z,k=WK(Q,B,S),y=FN(W.durationMs),f=W.spanType==="tool_execution"&&W.name?` (${W.name})`:"";return a$(j9,{children:[a$(g4,{color:J.colors.textMuted,children:[" ",L]},void 0,!0,void 0,this),a$(g4,{children:" "},void 0,!1,void 0,this),a$(g4,{color:U?J.colors.info:J.colors.success,children:k},void 0,!1,void 0,this),a$(g4,{children:" "},void 0,!1,void 0,this),a$(g4,{dimColor:!0,children:[y,f]},void 0,!0,void 0,this)]},W.spanId,!0,void 0,this)})},void 0,!1,void 0,this)}import{Box as NK,Text as c9}from"ink";import{jsxDEV as T8}from"react/jsx-dev-runtime";function PK($){if($<1000)return`${Math.round($)}ms`;return`${($/1000).toFixed(2)}s`}function a7({report:$}){let Z=A();if(!$||$.phases.length===0)return null;return T8(NK,{flexDirection:"column",marginTop:1,children:[T8(c9,{color:Z.colors.textMuted,children:[" Pipeline timing (",PK($.totalMs),")"]},void 0,!0,void 0,this),$.phases.map((J)=>T8(NK,{children:[T8(c9,{color:Z.colors.info,children:[" ",J.phase.padEnd(24)]},void 0,!0,void 0,this),T8(c9,{color:Z.colors.text,children:[" ",PK(J.durationMs)]},void 0,!0,void 0,this),T8(c9,{color:Z.colors.textMuted,children:[" (",J.pct,"%)"]},void 0,!0,void 0,this)]},`${J.phase}:${J.durationMs}`,!0,void 0,this))]},void 0,!0,void 0,this)}import{useRef as UN}from"react";import{Box as AN,Text as _K}from"ink";import ON from"gradient-string";import{jsxDEV as i7}from"react/jsx-dev-runtime";var n7=["#5f97cd","#7baed4","#97c4db","#7baed4"],FK=process.platform==="darwin"?["·","✢","✳","∗","✻","✽"]:["·","✢","*","∗","✻","✽"];function UK($){if($<60)return`${$}s`;let Z=Math.floor($/60),J=$%60;return`${Z}m ${J}s`}function wN($){if($>=1000)return`${($/1000).toFixed(1)}k tokens`;return`${$} tokens`}function o7({state:$,elapsedSeconds:Z,totalTokens:J,thoughtForSeconds:Q,currentVerb:X}){let Y=[...FK,...[...FK].reverse()],K=Math.floor(Date.now()/120)%Y.length,G=UN(V$().present),z=X||G.current,q=A(),W=K%n7.length,U=[...n7.slice(W),...n7.slice(0,W)],F=ON(U),O=`${Y[K]} ${z}…`,L=F(O),B=UK(Z),S=wN(J),k;if($==="thinking")k="(thinking)";else if(Q&&Q>0)k=`(${B} · ↓ ${S} · thought for ${UK(Q)})`;else k=`(${B} · ↓ ${S} · esc to cancel)`;return i7(AN,{flexDirection:"row",marginTop:1,children:[i7(_K,{children:[L," "]},void 0,!0,void 0,this),i7(_K,{color:q.colors.textMuted,children:k},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useInput as IP}from"ink";import{Box as MK,Text as CK}from"ink";import{useMemo as dN}from"react";import{basename as pN,extname as xN,isAbsolute as lN,resolve as XJ}from"path";import{Box as LN,Text as AK}from"ink";import{jsxDEV as m9}from"react/jsx-dev-runtime";function s7($){return $>=70?"high":$>=30?"moderate":"low"}function RN($){let Z=A();switch($){case"low":return{highlightColor:Z.colors.success,textColor:Z.colors.primary};case"moderate":return{highlightColor:Z.colors.warning,textColor:Z.colors.warning};case"high":return{highlightColor:Z.colors.error,textColor:Z.colors.error}}}function L2($){if($===null)return A().colors.primary;let Z=s7($);return RN(Z).textColor}function BN({riskScore:$}){let Z=s7($);return m9(AK,{color:L2($),children:["Risk: ",Z]},void 0,!0,void 0,this)}function n$({title:$,riskScore:Z}){return m9(LN,{flexDirection:"column",children:[m9(AK,{bold:!0,color:A().colors.primary,children:$},void 0,!1,void 0,this),Z!==null&&m9(BN,{riskScore:Z},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function R2($,Z){}import{existsSync as MN,readFileSync as CN}from"fs";import{useMemo as OK}from"react";import{Box as t7,Text as fN}from"ink";import{relative as SN}from"path";import{structuredPatch as IN}from"diff";function d9($,Z,J,Q=3){let X=IN($,$,Z,J,"","",{context:Q}),Y=0,K=0,G=X.hunks.map((z)=>{let q=[],W=z.oldStart,U=z.newStart;for(let F of z.lines){let O=F.slice(1);if(F.startsWith("+"))q.push({type:"added",content:O,newLineNo:U++}),Y++;else if(F.startsWith("-"))q.push({type:"removed",content:O,oldLineNo:W++}),K++;else q.push({type:"unchanged",content:O,oldLineNo:W++,newLineNo:U++})}return{oldStart:z.oldStart,oldLines:z.oldLines,newStart:z.newStart,newLines:z.newLines,lines:q}});return{filePath:$,hunks:G,additions:Y,deletions:K}}import{jsxDEV as j6}from"react/jsx-dev-runtime";function wK({file_path:$,new_string:Z,old_string:J,verbose:Q,useBorder:X=!0,width:Y}){let K=OK(()=>MN($)?CN($,"utf8"):"",[$]),G=OK(()=>{let z=K.replace(J,Z);return d9($,K,z)},[$,K,J,Z]);return j6(t7,{flexDirection:"column",children:j6(t7,{borderColor:A().colors.secondary,borderStyle:X?"round":void 0,flexDirection:"column",paddingX:1,children:[j6(t7,{paddingBottom:1,children:j6(fN,{bold:!0,children:Q?$:SN(process.cwd(),$)},void 0,!1,void 0,this)},void 0,!1,void 0,this),j6(Y4,{diff:G,dim:!1,width:Y,showHeader:!1},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import uN from"chalk";import{Box as jN,Text as cN}from"ink";import{Box as bN,Text as e7}from"ink";import{jsxDEV as p9}from"react/jsx-dev-runtime";var yN="❯",kN="▾",vN="✔";function LK({isFocused:$,isSelected:Z,smallPointer:J,children:Q}){let X=A();return p9(bN,{gap:1,children:[$&&p9(e7,{color:X.colors.primary,children:J?kN:yN},void 0,!1,void 0,this),p9(e7,{color:$?X.colors.primary:void 0,bold:Z,children:Q},void 0,!1,void 0,this),Z&&p9(e7,{color:X.colors.success,children:vN},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{isDeepStrictEqual as gN}from"node:util";import{useReducer as TN,useCallback as ZJ,useMemo as VN,useState as DN,useEffect as JJ}from"react";class x9 extends Map{first;constructor($){let Z=[],J,Q,X=0;for(let Y of $){let K={...Y,previous:Q,next:void 0,index:X};if(Q)Q.next=K;J||=K;let G="value"in Y?Y.value:$J(Y);Z.push([G,K]),X++,Q=K}super(Z);this.first=J}}var hN=($,Z)=>{switch(Z.type){case"focus-next-option":{if(!$.focusedValue)return $;let J=$.optionMap.get($.focusedValue);if(!J)return $;let Q=J.next;while(Q&&!("value"in Q))Q=Q.next;if(!Q)return $;if(!(Q.index>=$.visibleToIndex))return{...$,focusedValue:Q.value};let Y=Math.min($.optionMap.size,$.visibleToIndex+1),K=Y-$.visibleOptionCount;return{...$,focusedValue:Q.value,visibleFromIndex:K,visibleToIndex:Y}}case"focus-previous-option":{if(!$.focusedValue)return $;let J=$.optionMap.get($.focusedValue);if(!J)return $;let Q=J.previous;while(Q&&!("value"in Q))Q=Q.previous;if(!Q)return $;if(!(Q.index<=$.visibleFromIndex))return{...$,focusedValue:Q.value};let Y=Math.max(0,$.visibleFromIndex-1),K=Y+$.visibleOptionCount;return{...$,focusedValue:Q.value,visibleFromIndex:Y,visibleToIndex:K}}case"select-focused-option":return{...$,previousValue:$.value,value:$.focusedValue};case"reset":return Z.state;case"set-focus":return{...$,focusedValue:Z.value}}},QJ=($)=>$.flatMap((Z)=>{if("options"in Z){let J=QJ(Z.options),Q=J.flatMap((Y)=>("value"in Y)?Y.value:[]);return[...Z.header!==void 0?[{header:Z.header,optionValues:Q}]:[],...J]}return Z}),RK=({visibleOptionCount:$,defaultValue:Z,options:J})=>{let Q=QJ(J),X=typeof $==="number"?Math.min($,Q.length):Q.length,Y=new x9(Q),K=Y.first,G=K&&"value"in K?K.value:void 0;return{optionMap:Y,visibleOptionCount:X,focusedValue:G,visibleFromIndex:0,visibleToIndex:X,previousValue:Z,value:Z}},BK=({visibleOptionCount:$=5,options:Z,defaultValue:J,onChange:Q,onFocus:X,focusValue:Y})=>{let K=QJ(Z),[G,z]=TN(hN,{visibleOptionCount:$,defaultValue:J,options:Z},RK),[q,W]=DN(K);if(K!==q&&!gN(K,q))z({type:"reset",state:RK({visibleOptionCount:$,defaultValue:J,options:Z})}),W(K);let U=ZJ(()=>{z({type:"focus-next-option"})},[]),F=ZJ(()=>{z({type:"focus-previous-option"})},[]),O=ZJ(()=>{z({type:"select-focused-option"})},[]),L=VN(()=>{return K.map((B,S)=>({...B,index:S})).slice(G.visibleFromIndex,G.visibleToIndex)},[K,G.visibleFromIndex,G.visibleToIndex]);return JJ(()=>{if(G.value&&G.previousValue!==G.value)Q?.(G.value)},[G.previousValue,G.value,Z,Q]),JJ(()=>{if(G.focusedValue)X?.(G.focusedValue)},[G.focusedValue,X]),JJ(()=>{if(Y)z({type:"set-focus",value:Y})},[Y]),{focusedValue:G.focusedValue,visibleFromIndex:G.visibleFromIndex,visibleToIndex:G.visibleToIndex,value:G.value,visibleOptions:L,focusNextOption:U,focusPreviousOption:F,selectFocusedOption:O}};import{useInput as EN}from"ink";var IK=({isDisabled:$=!1,state:Z})=>{EN((J,Q)=>{if(Q.downArrow)Z.focusNextOption();if(Q.upArrow)Z.focusPreviousOption();if(Q.return)Z.selectFocusedOption()},{isActive:!$})};import{jsxDEV as l9,Fragment as mN}from"react/jsx-dev-runtime";var $J=($)=>`HEADER-${$.optionValues.join(",")}`;function i$({isDisabled:$=!1,visibleOptionCount:Z=5,highlightText:J,options:Q,defaultValue:X,onChange:Y,onFocus:K,focusValue:G}){let z=BK({visibleOptionCount:Z,options:Q,defaultValue:X,onChange:Y,onFocus:K,focusValue:G});IK({isDisabled:$,state:z});let q=A();return l9(jN,{flexDirection:"column",children:z.visibleOptions.map((W)=>{let U="value"in W?W.value:$J(W),F=!$&&z.focusedValue!==void 0&&("value"in W?z.focusedValue===W.value:W.optionValues.includes(z.focusedValue)),O=!!z.value&&("value"in W?z.value===W.value:W.optionValues.includes(z.value)),L="header"in W,B="label"in W?W.label:W.header,S=B;if(J&&B.includes(J)){let k=B.indexOf(J);S=l9(mN,{children:[B.slice(0,k),l9(cN,{color:q.colors.primary,bold:!0,children:J},void 0,!1,void 0,this),B.slice(k+J.length)]},void 0,!0,void 0,this)}return l9(LK,{isFocused:F,isSelected:O,smallPointer:L,children:S},U,!1,void 0,this)})},void 0,!1,void 0,this)}import{jsxDEV as T4}from"react/jsx-dev-runtime";function rN($){return(lN($)?XJ($):XJ(process.cwd(),$)).startsWith(XJ(process.cwd()))}function aN($){let Z=rN($)?[{label:"Yes, and don't ask again this session",value:"yes-dont-ask-again"}]:[];return[{label:"Yes",value:"yes"},...Z,{label:`No, and provide instructions (${uN.bold.hex(A().colors.warning)("esc")})`,value:"no"}]}function fK({toolUseConfirm:$,onDone:Z,verbose:J}){let{columns:Q}=K1(),{file_path:X,new_string:Y,old_string:K}=$.input,G=dN(()=>({completion_type:"str_replace_single",language_name:nN(X)}),[X]);return R2($,G),T4(MK,{flexDirection:"column",borderStyle:"round",borderColor:L2($.riskScore),marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[T4(n$,{title:"Edit file",riskScore:$.riskScore},void 0,!1,void 0,this),T4(wK,{file_path:X,new_string:Y,old_string:K,verbose:J,width:Q-12},void 0,!1,void 0,this),T4(MK,{flexDirection:"column",children:[T4(CK,{children:["Do you want to make this edit to ",T4(CK,{bold:!0,children:pN(X)},void 0,!1,void 0,this),"?"]},void 0,!0,void 0,this),T4(i$,{options:aN(X),onChange:(z)=>{switch(z){case"yes":Z(),$.onAllow("temporary");break;case"yes-dont-ask-again":Z(),$.onAllow("permanent");break;case"no":Z(),$.onReject();break}}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function nN($){let Z=xN($);return Z?Z.slice(1):"unknown"}import{Box as YJ,Text as KJ}from"ink";import{useMemo as oN}from"react";import c6 from"chalk";function iN($){let J=$.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,"");if(/&&|\|\||[;|]/.test(J))return!0;if(/`/.test(J))return!0;if(/\$\(/.test(J))return!0;return!1}function SK({toolUseConfirm:$,command:Z}){let J=!iN(Z)&&$.commandPrefix&&!$.commandPrefix.commandInjectionDetected,Q=m6($),X=J&&Q!==null,Y=[];if(X)Y=[{label:`Yes, and don't ask again for ${c6.bold(Q)} commands in ${c6.bold(process.cwd())}`,value:"yes-dont-ask-again-prefix"}];else if(J)Y=[{label:`Yes, and don't ask again for ${c6.bold(Z)} commands in ${c6.bold(process.cwd())}`,value:"yes-dont-ask-again-full"}];return[{label:"Yes",value:"yes"},...Y,{label:`No, and provide instructions (${c6.bold.hex(A().colors.warning)("esc")})`,value:"no"}]}import{jsxDEV as v3}from"react/jsx-dev-runtime";function bK({toolUseConfirm:$,onDone:Z}){let J=A(),{command:Q}=$.tool.inputSchema.parse($.input),X=oN(()=>({completion_type:"tool_use_single",language_name:"none"}),[]);return R2($,X),v3(YJ,{flexDirection:"column",borderStyle:"round",borderColor:J.colors.primary,marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[v3(n$,{title:"Bash command",riskScore:$.riskScore},void 0,!1,void 0,this),v3(YJ,{flexDirection:"column",paddingX:2,paddingY:1,children:[v3(KJ,{children:$.tool.renderToolUseMessage({command:Q},{verbose:!1})},void 0,!1,void 0,this),v3(KJ,{color:J.colors.textMuted,children:$.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),v3(YJ,{flexDirection:"column",children:[v3(KJ,{children:"Do you want to proceed?"},void 0,!1,void 0,this),v3(i$,{options:SK({toolUseConfirm:$,command:Q}),onChange:(Y)=>{switch(Y){case"yes":$.onAllow("temporary"),Z();break;case"yes-dont-ask-again-prefix":{if(m6($)!==null)$.onAllow("permanent"),Z();break}case"yes-dont-ask-again-full":$.onAllow("permanent"),Z();break;case"no":$.onReject(),Z();break}}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}import{Box as GJ,Text as u9}from"ink";import{useMemo as sN}from"react";import zJ from"chalk";import{jsxDEV as l2}from"react/jsx-dev-runtime";function r9({toolUseConfirm:$,onDone:Z,verbose:J}){let Q=A(),X=$.tool.userFacingName($.input),Y=X.endsWith(" (MCP)")?X.slice(0,-6):X,K=sN(()=>({completion_type:"tool_use_single",language_name:"none"}),[]);return R2($,K),l2(GJ,{flexDirection:"column",borderStyle:"round",borderColor:L2($.riskScore),marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[l2(n$,{title:"Tool use",riskScore:$.riskScore},void 0,!1,void 0,this),l2(GJ,{flexDirection:"column",paddingX:2,paddingY:1,children:[l2(u9,{children:[Y,"(",$.tool.renderToolUseMessage($.input,{verbose:J}),")",X.endsWith(" (MCP)")?l2(u9,{color:Q.colors.textMuted,children:" (MCP)"},void 0,!1,void 0,this):""]},void 0,!0,void 0,this),l2(u9,{color:Q.colors.textMuted,children:$.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l2(GJ,{flexDirection:"column",children:[l2(u9,{children:"Do you want to proceed?"},void 0,!1,void 0,this),l2(i$,{options:[{label:"Yes",value:"yes"},{label:`Yes, and don't ask again for ${zJ.bold(Y)} commands in ${zJ.bold(process.cwd())}`,value:"yes-dont-ask-again"},{label:`No, and provide instructions (${zJ.bold.hex(A().colors.warning)("esc")})`,value:"no"}],onChange:(G)=>{switch(G){case"yes":$.onAllow("temporary"),Z();break;case"yes-dont-ask-again":$.onAllow("permanent"),Z();break;case"no":$.onReject(),Z();break}}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}import{Box as HJ,Text as vK}from"ink";import{useMemo as gK}from"react";import{basename as QP,extname as XP}from"path";import{existsSync as YP}from"fs";import KP from"chalk";import{existsSync as tN,readFileSync as eN}from"fs";import{useMemo as qJ}from"react";import{Box as yK,Text as $P}from"ink";import{extname as ZP,relative as JP}from"path";import{jsxDEV as d6}from"react/jsx-dev-runtime";function kK({file_path:$,content:Z,verbose:J,width:Q}){let X=qJ(()=>tN($),[$]),Y=qJ(()=>{if(!X)return"";return eN($,"utf8")},[$,X]),K=qJ(()=>{if(!X)return null;return d9($,Y,Z)},[X,$,Y,Z]);return d6(yK,{borderColor:A().colors.secondary,borderStyle:"round",flexDirection:"column",paddingX:1,children:[d6(yK,{paddingBottom:1,children:d6($P,{bold:!0,children:J?$:JP(process.cwd(),$)},void 0,!1,void 0,this)},void 0,!1,void 0,this),K?d6(Y4,{diff:K,dim:!1,width:Q,showHeader:!1},void 0,!1,void 0,this):d6(E$,{code:Z||"(No content)",language:ZP($).slice(1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as g3}from"react/jsx-dev-runtime";function TK({toolUseConfirm:$,onDone:Z,verbose:J}){let{file_path:Q,content:X}=$.input,Y=gK(()=>YP(Q),[Q]),K=gK(()=>({completion_type:"write_file_single",language_name:GP(Q)}),[Q]),{columns:G}=K1();return R2($,K),g3(HJ,{flexDirection:"column",borderStyle:"round",borderColor:L2($.riskScore),marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[g3(n$,{title:`${Y?"Edit":"Create"} file`,riskScore:$.riskScore},void 0,!1,void 0,this),g3(HJ,{flexDirection:"column",children:g3(kK,{file_path:Q,content:X,verbose:J,width:G-12},void 0,!1,void 0,this)},void 0,!1,void 0,this),g3(HJ,{flexDirection:"column",children:[g3(vK,{children:["Do you want to ",Y?"make this edit to":"create"," ",g3(vK,{bold:!0,children:QP(Q)},void 0,!1,void 0,this),"?"]},void 0,!0,void 0,this),g3(i$,{options:[{label:"Yes",value:"yes"},{label:"Yes, and don't ask again this session",value:"yes-dont-ask-again"},{label:`No, and provide instructions (${KP.bold.hex(A().colors.warning)("esc")})`,value:"no"}],onChange:(z)=>{switch(z){case"yes":$.onAllow("temporary"),Z();break;case"yes-dont-ask-again":$.onAllow("permanent"),Z();break;case"no":$.onReject(),Z();break}}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function GP($){let Z=XP($);return Z?Z.slice(1):"unknown"}import{Box as WJ,Text as VK}from"ink";import{useMemo as zP}from"react";import qP from"chalk";import{isAbsolute as HP,resolve as DK}from"path";import{jsxDEV as u2}from"react/jsx-dev-runtime";function a9($){return HP($)?DK($):DK(process.cwd(),$)}function WP($){return a9($).startsWith(a9(process.cwd()))}var NP=!1;function PP(){NP=!0}var _P=new Set(["Edit","file_edit","str_replace_editor","Write","file_write","create_file","Read","file_read","read_file"]),FP=new Set(["Glob","glob","Grep","grep","LS","ls"]),UP=new Set(["NotebookEdit","notebook_edit","NotebookRead","notebook_read"]),AP=new Set(["Glob","glob","Grep","grep","LS","ls"]);function OP($){let Z=$.tool.name;if(_P.has(Z))return"file_path";if(FP.has(Z))return"path";if(UP.has(Z))return"notebook_path";return null}function wP($){return AP.has($.tool.name)}function LP($){let Z=OP($),J=$.input;if(Z&&Z in J)if(typeof J[Z]==="string")return a9(J[Z]);else return a9(process.cwd());return null}function hK({toolUseConfirm:$,onDone:Z,verbose:J}){let Q=LP($);if(!Q)return u2(r9,{toolUseConfirm:$,onDone:Z,verbose:J},void 0,!1,void 0,this);return u2(BP,{toolUseConfirm:$,path:Q,onDone:Z,verbose:J},void 0,!1,void 0,this)}function RP($,Z){if($.tool.isReadOnly())return[];return WP(Z)?[{label:"Yes, and don't ask again for file edits this session",value:"yes-dont-ask-again"}]:[]}function BP({toolUseConfirm:$,path:Z,onDone:J,verbose:Q}){let X=$.tool.userFacingName($.input),K=`${$.tool.isReadOnly()?"Read":"Edit"} ${wP($)?"files":"file"}`,G=zP(()=>({completion_type:"tool_use_single",language_name:"none"}),[]);return R2($,G),u2(WJ,{flexDirection:"column",borderStyle:"round",borderColor:L2($.riskScore),marginTop:1,paddingLeft:1,paddingRight:1,paddingBottom:1,children:[u2(n$,{title:K,riskScore:$.riskScore},void 0,!1,void 0,this),u2(WJ,{flexDirection:"column",paddingX:2,paddingY:1,children:u2(VK,{children:[X,"(",$.tool.renderToolUseMessage($.input,{verbose:Q}),")"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),u2(WJ,{flexDirection:"column",children:[u2(VK,{children:"Do you want to proceed?"},void 0,!1,void 0,this),u2(i$,{options:[{label:"Yes",value:"yes"},...RP($,Z),{label:`No, and provide instructions (${qP.bold.hex(A().colors.warning)("esc")})`,value:"no"}],onChange:(z)=>{switch(z){case"yes":$.onAllow("temporary"),J();break;case"yes-dont-ask-again":PP(),$.onAllow("permanent"),J();break;case"no":$.onReject(),J();break}}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as yP}from"react/jsx-dev-runtime";var MP=new Set(["Edit","file_edit","str_replace_editor"]),CP=new Set(["Write","file_write","create_file"]),fP=new Set(["Bash","bash","execute_command"]),SP=new Set(["Glob","glob","Grep","grep","LS","ls","Read","file_read","read_file","NotebookRead","notebook_read","NotebookEdit","notebook_edit"]);function bP($){if(MP.has($))return fK;if(CP.has($))return TK;if(fP.has($))return bK;if(SP.has($))return hK;return r9}function m6($){return $.commandPrefix&&!$.commandPrefix.commandInjectionDetected&&$.commandPrefix.commandPrefix||null}function NJ({toolUseConfirm:$,onDone:Z,verbose:J}){IP((X,Y)=>{if(Y.ctrl&&X==="c")Z(),$.onReject()});let Q=bP($.tool.name);return yP(Q,{toolUseConfirm:$,onDone:Z,verbose:J},void 0,!1,void 0,this)}import{useState as EK,useEffect as jK}from"react";import{Box as n9,Text as V8,useInput as kP}from"ink";import{jsxDEV as B2}from"react/jsx-dev-runtime";function PJ($){return/\s/.test($.trimStart())}function vP($){return $.trimStart().split(/\s+/,1)[0]??""}function _J({commands:$,initialFilter:Z="",onSelect:J,onHandOffInput:Q,onCancel:X}){let[Y,K]=EK(0),[G,z]=EK(Z),q=vP(G).toLowerCase(),W=$.filter((O)=>O.name.toLowerCase().includes(q));jK(()=>{K((O)=>Math.min(O,Math.max(0,W.length-1)))},[W.length]),jK(()=>{if(!Q||!PJ(G))return;Q(`/${G}`)},[G,Q]);let U=W.length>0?Math.min(Y,W.length-1):0,F=process.stdin.isTTY??!1;return kP((O,L)=>{if(e(O,L)){X();return}if(L.return&&PJ(G)&&Q){Q(`/${G}`);return}if(L.return&&W.length>0){J(W[U]);return}if(L.upArrow){K((B)=>Math.max(0,B-1));return}if(L.downArrow){K((B)=>Math.min(W.length-1,B+1));return}if(L.backspace||L.delete){z((B)=>B.slice(0,-1));return}if(O&&!L.ctrl&&!L.meta){let B=G+O;if(Q&&PJ(B)){Q(`/${B}`);return}z(B)}},{isActive:F}),B2(n9,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,children:[B2(n9,{marginBottom:1,children:[B2(V8,{bold:!0,children:"Commands"},void 0,!1,void 0,this),G&&B2(V8,{dimColor:!0,children:[" /",G]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W.map((O,L)=>B2(n9,{children:[B2(V8,{inverse:L===U,children:["/",O.name]},void 0,!0,void 0,this),B2(V8,{dimColor:!0,children:[" ",O.description]},void 0,!0,void 0,this)]},O.name,!0,void 0,this)),W.length===0&&B2(V8,{dimColor:!0,children:"No matching commands"},void 0,!1,void 0,this),B2(n9,{marginTop:1,children:B2(V8,{dimColor:!0,children:"↑↓ navigate ⏎ select esc cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useState as cK,useEffect as gP}from"react";import{Box as i9,Text as V4,useInput as TP}from"ink";import{jsxDEV as o$}from"react/jsx-dev-runtime";function FJ({arions:$,initialFilter:Z="",statusFilter:J="all",onSelect:Q,onCancel:X}){let[Y,K]=cK(0),[G,z]=cK(Z),q=$.filter((F)=>{if(J==="active"&&F.isResting)return!1;if(J==="resting"&&!F.isResting)return!1;return F.name.toLowerCase().includes(G.toLowerCase())});gP(()=>{K((F)=>Math.min(F,Math.max(0,q.length-1)))},[q.length]);let W=q.length>0?Math.min(Y,q.length-1):0,U=process.stdin.isTTY??!1;return TP((F,O)=>{if(e(F,O)){X();return}if(O.return&&q.length>0){Q(q[W]);return}if(O.upArrow){K((L)=>Math.max(0,L-1));return}if(O.downArrow){K((L)=>Math.min(q.length-1,L+1));return}if(O.backspace||O.delete){z((L)=>L.slice(0,-1));return}if(F&&!O.ctrl&&!O.meta)z((L)=>L+F)},{isActive:U}),o$(i9,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,children:[o$(i9,{marginBottom:1,children:[o$(V4,{bold:!0,children:J==="active"?"Active Arions":J==="resting"?"Resting Arions":"Arions"},void 0,!1,void 0,this),G&&o$(V4,{dimColor:!0,children:[" @",G]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.length===0&&o$(V4,{dimColor:!0,children:$.length===0?"No arions available. Create one with /hatch":J==="active"?"No active arions":J==="resting"?"No resting arions":"No matching arions"},void 0,!1,void 0,this),q.map((F,O)=>{let L=z6(F.color),B=F.isActive?" (active)":F.isResting?" (resting)":"";return o$(i9,{children:[o$(V4,{inverse:O===W,children:[F.emoji," ",o$(V4,{color:L,children:F.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o$(V4,{dimColor:!0,children:[" ",F.description,B]},void 0,!0,void 0,this)]},F.name,!0,void 0,this)}),o$(i9,{marginTop:1,children:o$(V4,{dimColor:!0,children:"↑↓ navigate ⏎ select esc cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useState as UJ,useEffect as VP,useMemo as DP}from"react";import{Box as T3,Text as V1,useInput as hP}from"ink";import{jsxDEV as d0}from"react/jsx-dev-runtime";var EP={anthropic:"Anthropic","openai-codex":"OpenAI Codex",google:"Google",bedrock:"AWS Bedrock","bedrock-converse":"AWS Bedrock (Converse)","github-copilot":"GitHub Copilot",openai:"OpenAI",local:"Local"},mK=["anthropic","openai-codex","google","bedrock","bedrock-converse","github-copilot","openai","local"];function jP($){return EP[$]||$}function dK($){let Z=mK.indexOf($);return Z>=0?Z:mK.length}function cP($,Z,J){let Q=new Map;for(let K of $){let G=K.provider||"other",z=Q.get(G)??[];z.push(K),Q.set(G,z)}let X={powerful:0,balanced:1,fast:2,ensemble:3},Y=[...Q.entries()].sort(([K],[G])=>dK(K)-dK(G));for(let[K,G]of Y){Z.push({type:"header",label:jP(K),provider:K});let z=(F)=>{if(!F)return"balanced";let O=F.toLowerCase();if(O.includes("deep"))return"powerful";if(O.includes("quick"))return"fast";return"balanced"},q=[/^claude-opus-|^opus-|^bedrock-opus-/,/^claude-sonnet-|^sonnet-|^bedrock-sonnet-/,/^claude-haiku-|^haiku-|^bedrock-haiku-/,/^claude-/,/^gpt-/,/^o[0-9]/,/^gemini-/],W=(F)=>{let O=F.toLowerCase();for(let L=0;L<q.length;L++)if(q[L].test(O))return L;return q.length},U=[...G].sort((F,O)=>{let L=W(F.name),B=W(O.name);if(L!==B)return L-B;return O.name.localeCompare(F.name)});for(let F of U)J.push(Z.length),Z.push({type:"model",model:F})}}var p6=["low","medium","high","max"],mP={low:"▌",medium:"▌▌",high:"▌▌▌",max:"▌▌▌▌"},dP={low:"Low",medium:"Medium",high:"High",max:"Max"},pK={low:"blue",medium:"cyan",high:"yellow",max:"magenta"};function AJ({models:$,initialFilter:Z="",effortLevel:J,onSelect:Q,onCancel:X}){let[Y,K]=UJ(Z),[G,z]=UJ(J??"high"),W=$.filter((f)=>f.name.toLowerCase().includes(Y.toLowerCase())),{items:U,selectableIndices:F}=DP(()=>{if(!W.some((R)=>R.provider))return{items:W.map((R)=>({type:"model",model:R})),selectableIndices:W.map((R,j)=>j)};let M=[],I=[];return cP(W,M,I),{items:M,selectableIndices:I}},[W]),O=F.findIndex((f)=>{let M=U[f];return M?.type==="model"&&M.model.isCurrent}),[L,B]=UJ(O>=0?O:0);VP(()=>{B((f)=>Math.min(f,Math.max(0,F.length-1)))},[F.length]);let S=F.length>0?Math.min(L,F.length-1):0,k=process.stdin.isTTY??!1;hP((f,M)=>{if(e(f,M)){X();return}if(M.return&&F.length>0){let I=F[S],R=U[I];if(R.type==="model")Q(R.model,G);return}if(M.leftArrow){z((I)=>{let R=p6.indexOf(I);return p6[Math.max(0,R-1)]});return}if(M.rightArrow){z((I)=>{let R=p6.indexOf(I);return p6[Math.min(p6.length-1,R+1)]});return}if(M.upArrow){B((I)=>Math.max(0,I-1));return}if(M.downArrow){B((I)=>Math.min(F.length-1,I+1));return}if(M.backspace||M.delete){K((I)=>I.slice(0,-1));return}if(f&&!M.ctrl&&!M.meta)K((I)=>I+f)},{isActive:k});let y=F.length>0?` [${S+1}/${F.length}]`:"";return d0(T3,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,children:[d0(T3,{marginBottom:1,children:[d0(V1,{bold:!0,children:"Model"},void 0,!1,void 0,this),d0(V1,{dimColor:!0,children:y},void 0,!1,void 0,this),d0(V1,{children:" "},void 0,!1,void 0,this),Y?d0(V1,{color:"cyan",children:Y},void 0,!1,void 0,this):d0(V1,{dimColor:!0,children:"Type to search..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W.length===0&&d0(V1,{dimColor:!0,children:"No matching models"},void 0,!1,void 0,this),(()=>{let f=U.reduce((M,I)=>{if(I.type!=="model")return M;return Math.max(M,I.model.name.length)},0);return U.map((M,I)=>{if(M.type==="header"){let P1=WQ(M.provider);return d0(T3,{marginTop:I>0?1:0,children:[d0(V1,{color:P1.color,children:[P1.icon," "]},void 0,!0,void 0,this),d0(V1,{bold:!0,color:P1.color,children:M.label},void 0,!1,void 0,this)]},`header-${M.label}-${I}`,!0,void 0,this)}if(M.type==="hint")return d0(T3,{marginTop:1,children:d0(V1,{dimColor:!0,italic:!0,children:M.label},void 0,!1,void 0,this)},"hint",!1,void 0,this);let R=F[S]===I,j=M.model.description,Q0=M.model.name.padEnd(f),w1=DZ(M.model.name);return d0(T3,{children:[d0(V1,{inverse:R,color:R?void 0:w1,dimColor:R?!1:!w1,children:[M.model.isCurrent?"●":"○"," ",Q0]},void 0,!0,void 0,this),j&&d0(V1,{dimColor:!0,children:[" ",M.model.description]},void 0,!0,void 0,this)]},M.model.value??`${M.model.provider}-${M.model.name}`,!0,void 0,this)})})(),d0(T3,{marginTop:1,flexDirection:"column",children:[d0(T3,{children:[d0(V1,{color:pK[G],children:[mP[G]," "]},void 0,!0,void 0,this),d0(V1,{color:pK[G],bold:!0,children:[dP[G]," effort"]},void 0,!0,void 0,this),G==="high"&&d0(V1,{dimColor:!0,children:" (default)"},void 0,!1,void 0,this),d0(V1,{dimColor:!0,children:" ← → to adjust"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),d0(T3,{marginTop:0,children:d0(V1,{dimColor:!0,children:"↑↓ navigate ← → effort ⏎ select esc cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}import{useState as OJ,useEffect as pP}from"react";import{Box as D8,Text as s$,useInput as xP}from"ink";import lP from"ink-spinner";import{jsxDEV as A1}from"react/jsx-dev-runtime";function wJ({memories:$,mode:Z="browse",isLoading:J=!1,onSelect:Q,onCancel:X}){let[Y,K]=OJ(0),[G,z]=OJ(""),[q,W]=OJ(0),U=8,F=$.filter((M)=>M.content.toLowerCase().includes(G.toLowerCase())),O=Math.max(1,Math.ceil(F.length/8)),L=F.slice(q*8,(q+1)*8);pP(()=>{K((M)=>Math.min(M,Math.max(0,L.length-1)))},[L.length]);let B=L.length>0?Math.min(Y,L.length-1):0,S=process.stdin.isTTY??!1;xP((M,I)=>{if(e(M,I)){X();return}if(I.return&&L.length>0&&Z==="forget"){Q?.(L[B]);return}if(I.upArrow){K((R)=>Math.max(0,R-1));return}if(I.downArrow){K((R)=>Math.min(L.length-1,R+1));return}if(I.leftArrow&&q>0){W((R)=>R-1),K(0);return}if(I.rightArrow&&q<O-1){W((R)=>R+1),K(0);return}if(I.backspace||I.delete){z((R)=>R.slice(0,-1)),W(0),K(0);return}if(M&&!I.ctrl&&!I.meta)z((R)=>R+M),W(0),K(0)},{isActive:S});function k(M){let I=M instanceof Date?M:new Date(M);if(isNaN(I.getTime()))return"unknown";let j=new Date().getTime()-I.getTime(),Q0=Math.floor(j/86400000);if(Q0===0)return"today";if(Q0===1)return"yesterday";if(Q0<7)return`${Q0}d ago`;if(Q0<30)return`${Math.floor(Q0/7)}w ago`;return`${Math.floor(Q0/30)}mo ago`}function y(M,I){if(M.length<=I)return M;return M.slice(0,I-3)+"..."}return A1(D8,{flexDirection:"column",borderStyle:"round",borderColor:Z==="forget"?"red":"cyan",paddingX:1,children:[A1(D8,{marginBottom:1,children:[A1(s$,{bold:!0,color:Z==="forget"?"red":"cyan",children:Z==="forget"?"Select Memory to Delete":"Memories"},void 0,!1,void 0,this),G&&A1(s$,{dimColor:!0,children:[' (filter: "',G,'")']},void 0,!0,void 0,this),A1(s$,{dimColor:!0,children:[" - ",F.length," memories"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),J&&A1(D8,{children:[A1(s$,{color:"cyan",children:A1(lP,{type:"dots"},void 0,!1,void 0,this)},void 0,!1,void 0,this),A1(s$,{dimColor:!0,children:" Loading memories..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!J&&F.length===0&&A1(s$,{dimColor:!0,children:$.length===0?"No memories stored yet. Use /remember to add some.":"No memories match your filter."},void 0,!1,void 0,this),!J&&L.map((M,I)=>{let R=I===B,j=k(M.createdAt),Q0=y(M.content,60);return A1(D8,{flexDirection:"row",children:[A1(s$,{inverse:R,children:[R?">":" "," ",Q0]},void 0,!0,void 0,this),A1(s$,{dimColor:!0,children:[" [",j,"]"]},void 0,!0,void 0,this),M.network&&A1(s$,{dimColor:!0,children:[" (",M.network,")"]},void 0,!0,void 0,this)]},M.id,!0,void 0,this)}),!J&&O>1&&A1(D8,{marginTop:1,children:A1(s$,{dimColor:!0,children:["Page ",q+1,"/",O]},void 0,!0,void 0,this)},void 0,!1,void 0,this),A1(D8,{marginTop:1,children:A1(s$,{dimColor:!0,children:Z==="forget"?"type to filter arrows navigate enter delete esc cancel":"type to filter arrows navigate esc close"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useState as LJ,useEffect as xK}from"react";import{Box as h8,Text as r2,useInput as uP}from"ink";import{jsxDEV as n1}from"react/jsx-dev-runtime";function rP($){let J=Date.now()-$.getTime(),Q=Math.floor(J/60000),X=Math.floor(J/3600000),Y=Math.floor(J/86400000);if(Q<1)return"just now";if(Q<60)return`${Q}m ago`;if(X<24)return`${X}h ago`;if(Y<7)return`${Y}d ago`;return $.toLocaleDateString()}function RJ({sessions:$,onSelect:Z,onCancel:J,onSearch:Q,onPageChange:X}){let{columns:Y}=K1(),[K,G]=LJ(0),[z,q]=LJ(""),[W,U]=LJ(0),F=8,O=Math.max(1,Math.ceil($.length/8)),L=$.slice(W*8,(W+1)*8);xK(()=>{G((f)=>Math.min(f,Math.max(0,L.length-1)))},[L.length]),xK(()=>{U((f)=>Math.min(f,Math.max(0,O-1)))},[O]);let B=L.length>0?Math.min(K,L.length-1):0,S=process.stdin.isTTY??!1;uP((f,M)=>{if(e(f,M))J();else if(M.return&&L.length>0)Z(L[B].id);else if(M.upArrow)G((I)=>Math.max(0,I-1));else if(M.downArrow)G((I)=>Math.min(L.length-1,I+1));else if(M.leftArrow&&W>0)U((I)=>I-1),G(0);else if(M.leftArrow&&W===0)X?.("prev"),G(0);else if(M.rightArrow&&W<O-1)U((I)=>I+1),G(0);else if(M.rightArrow&&W===O-1)X?.("next"),G(0);else if(M.backspace||M.delete){let I=z.slice(0,-1);q(I),U(0),G(0),Q(I)}else if(f&&!M.ctrl&&!M.meta){let I=z+f;q(I),U(0),G(0),Q(I)}},{isActive:S});function k(f,M){if(f.length<=M)return f;return f.slice(0,M-3)+"..."}let y=Math.max(30,Math.min(120,Y-28));return n1(h8,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,children:[n1(h8,{marginBottom:1,children:[n1(r2,{bold:!0,color:"cyan",children:"Sessions"},void 0,!1,void 0,this),z&&n1(r2,{dimColor:!0,children:[' (filter: "',z,'")']},void 0,!0,void 0,this),n1(r2,{dimColor:!0,children:[" - ",$.length," sessions"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),$.length===0?n1(r2,{dimColor:!0,children:z?"No sessions match your filter.":"No sessions yet."},void 0,!1,void 0,this):L.map((f,M)=>{let I=M===B,R=rP(f.updatedAt),j=f.title??f.preview??"Untitled session",Q0=W*8+M;return n1(h8,{flexDirection:"column",marginBottom:M<L.length-1?1:0,children:[n1(h8,{flexDirection:"row",children:[n1(r2,{inverse:I,children:[I?">":" "," ",Q0+1,". ",k(j,y)]},void 0,!0,void 0,this),n1(r2,{dimColor:!0,children:[" [",R,"]"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),n1(r2,{dimColor:!0,children:[" ",f.arion," | ",f.model," | ",f.messageCount," messages"]},void 0,!0,void 0,this)]},f.id,!0,void 0,this)}),$.length>0&&O>1&&n1(h8,{marginTop:1,children:n1(r2,{dimColor:!0,children:["Page ",W+1,"/",O]},void 0,!0,void 0,this)},void 0,!1,void 0,this),n1(h8,{marginTop:1,children:n1(r2,{dimColor:!0,children:"type to search arrows navigate enter resume esc cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useState as BJ,useEffect as o9,useMemo as aP}from"react";import{Box as s9,Text as V3,useInput as nP}from"ink";import{jsxDEV as b$}from"react/jsx-dev-runtime";function iP($,Z){if($.length<=Z)return $;return $.slice(0,Z-3)+"…"}function oP($){switch($){case"user":return"\uD83D\uDC64";case"assistant":return"\uD83E\uDD16";case"system":return"⚙️";case"tool":return"\uD83D\uDD27";default:return" "}}function sP($){switch($){case"user":return"cyan";case"assistant":return"green";case"system":return"yellow";case"tool":return"gray";default:return"white"}}function IJ({messages:$,onSelect:Z,onCancel:J}){let{columns:Q,rows:X}=K1(),[Y,K]=BJ(0),[G,z]=BJ(""),q=aP(()=>{if(!G)return $;let k=G.toLowerCase();return $.filter((y)=>y.text.toLowerCase().includes(k)||y.role.toLowerCase().includes(k)||y.arion&&y.arion.toLowerCase().includes(k))},[$,G]);o9(()=>{K((k)=>Math.min(k,Math.max(0,q.length-1)))},[q.length]),o9(()=>{if(!G){let k=q.reduce((y,f,M)=>f.role==="user"?M:y,0);K(k)}},[]);let W=Math.max(4,X-10),[U,F]=BJ(0);o9(()=>{if(Y<U)F(Y);else if(Y>=U+W)F(Y-W+1)},[Y,W,U]),o9(()=>{let k=q.reduce((y,f,M)=>f.role==="user"?M:y,0);F(Math.max(0,k-W+2))},[G]);let O=q.slice(U,U+W),L=q.length>0?Math.min(Y,q.length-1):0,B=process.stdin.isTTY??!1;nP((k,y)=>{if(e(k,y))J();else if(y.return&&q.length>0){let f=q[L];if(f&&f.role==="user")Z(f.index,f.text)}else if(y.upArrow)K((f)=>Math.max(0,f-1));else if(y.downArrow)K((f)=>Math.min(q.length-1,f+1));else if(y.backspace||y.delete){let f=G.slice(0,-1);z(f),K(0)}else if(k&&!y.ctrl&&!y.meta){let f=G+k;z(f),K(0)}},{isActive:B});let S=Math.max(30,Math.min(120,Q-16));return b$(s9,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,children:[b$(s9,{marginBottom:1,children:[b$(V3,{bold:!0,color:"cyan",children:"Edit Message"},void 0,!1,void 0,this),G?b$(V3,{dimColor:!0,children:[" ",'(search: "',G,'") — ',q.length,"/",$.length," messages"]},void 0,!0,void 0,this):b$(V3,{dimColor:!0,children:[" — ",$.length," messages · select a user message to edit"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),U>0&&b$(V3,{dimColor:!0,children:[" ↑ ",U," more above"]},void 0,!0,void 0,this),q.length===0?b$(V3,{dimColor:!0,children:G?`No messages match "${G}".`:"No messages."},void 0,!1,void 0,this):O.map((k,y)=>{let M=U+y===L,I=k.role==="user",R=oP(k.role),j=sP(k.role),Q0=M?"❯":" ",w1=iP(k.text.replace(/\n/g," ").trim()||"(empty)",S);return b$(s9,{flexDirection:"row",children:b$(V3,{inverse:M,color:M?void 0:j,dimColor:!I&&!M,bold:I,children:[Q0," ",R," ",w1]},void 0,!0,void 0,this)},`${k.index}-${y}`,!1,void 0,this)}),U+W<q.length&&b$(V3,{dimColor:!0,children:[" ↓ ",q.length-U-W," more below"]},void 0,!0,void 0,this),b$(s9,{marginTop:1,children:b$(V3,{dimColor:!0,children:"type to search · ↑↓ navigate · enter select user message · esc cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import tP,{useState as eP,useMemo as MJ}from"react";import{Box as O1,Text as a,useInput as $_}from"ink";import{jsxDEV as D}from"react/jsx-dev-runtime";var Z_={standard:"Standard",claude:"Claude",accessible:"Accessible"},J_=["standard","claude","accessible"];function lK($){if($.includes("daltonized")||$.includes("accessible"))return"accessible";if($.startsWith("claude-"))return"claude";return"standard"}function Q_($){let Z=$.colors.text.replace("#",""),J=parseInt(Z.slice(0,2),16),Q=parseInt(Z.slice(2,4),16),X=parseInt(Z.slice(4,6),16);return(J*299+Q*587+X*114)/1000<128}function X_($){return h3().map((Z)=>{let J=t9(Z);return{name:Z,displayName:J.displayName,isCurrent:Z===$,isLight:Q_(J),category:lK(Z)}})}function Y_({theme:$}){let Z=$.colors,J=Z.primary,Q=Z.info,X=Z.success,Y=Z.textMuted,K=Z.text;return D(O1,{flexDirection:"column",children:[D(a,{color:Y,children:"// fetch a user by ID"},void 0,!1,void 0,this),D(O1,{children:[D(a,{color:J,children:"async function "},void 0,!1,void 0,this),D(a,{color:K,children:"fetchUser"},void 0,!1,void 0,this),D(a,{color:K,children:"("},void 0,!1,void 0,this),D(a,{color:K,children:"id"},void 0,!1,void 0,this),D(a,{color:K,children:": "},void 0,!1,void 0,this),D(a,{color:X,children:"string"},void 0,!1,void 0,this),D(a,{color:K,children:") {"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D(O1,{children:[D(a,{color:K,children:" "},void 0,!1,void 0,this),D(a,{color:J,children:"const "},void 0,!1,void 0,this),D(a,{color:K,children:"res = "},void 0,!1,void 0,this),D(a,{color:J,children:"await "},void 0,!1,void 0,this),D(a,{color:K,children:"fetch("},void 0,!1,void 0,this),D(a,{color:Q,children:"`/api/users/${"},void 0,!1,void 0,this),D(a,{color:K,children:"id"},void 0,!1,void 0,this),D(a,{color:Q,children:"}`"},void 0,!1,void 0,this),D(a,{color:K,children:")"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D(O1,{children:[D(a,{color:K,children:" "},void 0,!1,void 0,this),D(a,{color:J,children:"if "},void 0,!1,void 0,this),D(a,{color:K,children:"(!res.ok) "},void 0,!1,void 0,this),D(a,{color:J,children:"throw new "},void 0,!1,void 0,this),D(a,{color:X,children:"Error"},void 0,!1,void 0,this),D(a,{color:K,children:"("},void 0,!1,void 0,this),D(a,{color:Q,children:"`HTTP ${"},void 0,!1,void 0,this),D(a,{color:K,children:"res.status"},void 0,!1,void 0,this),D(a,{color:Q,children:"}`"},void 0,!1,void 0,this),D(a,{color:K,children:")"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D(O1,{children:[D(a,{color:K,children:" "},void 0,!1,void 0,this),D(a,{color:J,children:"return "},void 0,!1,void 0,this),D(a,{color:K,children:"res.json() "},void 0,!1,void 0,this),D(a,{color:J,children:"as "},void 0,!1,void 0,this),D(a,{color:X,children:"Promise"},void 0,!1,void 0,this),D(a,{color:K,children:"<"},void 0,!1,void 0,this),D(a,{color:X,children:"User"},void 0,!1,void 0,this),D(a,{color:K,children:">"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D(a,{color:K,children:"}"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function K_({theme:$}){let{colors:Z,symbols:J}=$;return D(O1,{flexDirection:"column",borderStyle:"single",borderColor:Z.secondary,paddingX:1,children:[D(a,{bold:!0,color:Z.primary,children:[J.prompt," ",$.displayName]},void 0,!0,void 0,this),D(O1,{marginTop:1,flexDirection:"column",children:D(Y_,{theme:$},void 0,!1,void 0,this)},void 0,!1,void 0,this),D(O1,{marginTop:1,flexDirection:"column",children:[D(a,{color:Z.success,children:[J.success," Tests passed (3/3)"]},void 0,!0,void 0,this),D(a,{color:Z.error,children:[J.error," Error: connection refused"]},void 0,!0,void 0,this),D(a,{color:Z.warning,children:[J.warning," Deprecated API call"]},void 0,!0,void 0,this),D(O1,{children:D(a,{color:Z.diffAdded,children:"+ const data = await fetch(url);"},void 0,!1,void 0,this)},void 0,!1,void 0,this),D(O1,{children:D(a,{color:Z.diffRemoved,children:"- const data = http.get(url);"},void 0,!1,void 0,this)},void 0,!1,void 0,this),D(a,{color:Z.textMuted,children:[J.info," 1.2k tokens ",J.bullet," $0.01 ",J.bullet," 0.8s"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function CJ({onSelect:$,onCancel:Z}){let J=MJ(()=>A().name,[]),Q=MJ(()=>X_(J),[J]),{items:X,selectableIndices:Y}=MJ(()=>{let B=[],S=[],k=new Map;for(let y of Q){let f=k.get(y.category)??[];f.push(y),k.set(y.category,f)}for(let y of J_){let f=k.get(y);if(!f?.length)continue;B.push({type:"header",label:Z_[y]??y});for(let M of f)S.push(B.length),B.push({type:"theme",option:M})}return{items:B,selectableIndices:S}},[Q]),K=Y.findIndex((B)=>{let S=X[B];return S?.type==="theme"&&S.option.isCurrent}),[G,z]=eP(K>=0?K:0),q=Y.length>0?Math.min(G,Y.length-1):0,W=X[Y[q]],U=W?.type==="theme"?W.option.name:null;if(U)D3(U);let F=tP.useCallback(()=>{D3(J),Z()},[J,Z]),O=process.stdin.isTTY??!1;$_((B,S)=>{if(e(B,S)){F();return}if(S.return&&Y.length>0){let k=Y[q],y=X[k];if(y.type==="theme")$({name:y.option.name,displayName:y.option.displayName});return}if(S.upArrow){z((k)=>Math.max(0,k-1));return}if(S.downArrow){z((k)=>Math.min(Y.length-1,k+1));return}},{isActive:O});let L=A();return D(O1,{flexDirection:"column",borderStyle:"round",borderColor:L.colors.primary,paddingX:1,children:[D(O1,{marginBottom:1,children:[D(a,{bold:!0,color:L.colors.primary,children:"Theme"},void 0,!1,void 0,this),D(a,{color:L.colors.textMuted,children:[" ",L.symbols.arrow," select a color theme"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),D(O1,{children:[D(O1,{flexDirection:"column",width:38,children:X.map((B,S)=>{if(B.type==="header")return D(O1,{marginTop:S>0?1:0,children:D(a,{bold:!0,color:L.colors.textMuted,children:B.label},void 0,!1,void 0,this)},`header-${B.label}`,!1,void 0,this);let k=Y[q]===S,{option:y}=B;return D(O1,{children:D(a,{inverse:k,color:k?L.colors.primary:L.colors.text,children:[y.isCurrent?"●":"○"," ",y.displayName]},void 0,!0,void 0,this)},y.name,!1,void 0,this)})},void 0,!1,void 0,this),D(O1,{flexDirection:"column",flexGrow:1,marginLeft:2,children:D(K_,{theme:L},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D(O1,{marginTop:1,children:D(a,{color:L.colors.textMuted,children:["↑↓"," navigate ","⏎"," select esc cancel"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useState as uK,useEffect as G_,useMemo as z_}from"react";import{Box as fJ,Text as E3,useInput as q_}from"ink";import{jsxDEV as t$}from"react/jsx-dev-runtime";function H_($,Z){let J=Z.trim().toLowerCase();if(!J)return!0;return[$.displayNameSnapshot,$.nodeId,$.host,$.port?.toString(),$.principalFingerprint,$.transport,$.status].filter((X)=>typeof X==="string"&&X.length>0).map((X)=>X.toLowerCase()).some((X)=>X.includes(J))}function SJ($,Z){if(Z<=0)return 0;return Math.min($,Z-1)}function bJ({peers:$,sameHomeClientsAvailable:Z=!1,onSelect:J,onCancel:Q}){let[X,Y]=uK(0),[K,G]=uK(""),z=A(),q=z_(()=>$.filter((O)=>H_(O,K)),[$,K]);G_(()=>{Y((O)=>SJ(O,q.length))},[q.length]);let W=SJ(X,q.length),U=process.stdin.isTTY??!1;q_((O,L)=>{if(e(O,L)){Q();return}if(L.return){if(q.length>0)J(q[W]);return}if(L.upArrow){Y((B)=>Math.max(0,B-1));return}if(L.downArrow){Y((B)=>SJ(B+1,q.length));return}if(L.backspace||L.delete){G((B)=>B.slice(0,-1)),Y(0);return}if(O&&!L.ctrl&&!L.meta){G((B)=>B+O),Y(0);return}},{isActive:U});let F=(O)=>`${O.slice(0,4)} ${O.slice(4,8)} ${O.slice(8,12)} ${O.slice(12,16)}`;return t$(fJ,{flexDirection:"column",borderStyle:"round",borderColor:z.colors.secondary,paddingX:1,children:[t$(E3,{bold:!0,color:z.colors.primary,children:[" ","Nearby Peers"," "]},void 0,!0,void 0,this),K?t$(E3,{dimColor:!0,children:[' (filter: "',K,'")']},void 0,!0,void 0,this):null,q.length===0&&t$(E3,{dimColor:!0,children:K?"No peers match your filter.":Z?"No peer nodes. Use /clients for same-home terminals.":"Scanning... no peers found yet"},void 0,!1,void 0,this),q.map((O,L)=>t$(fJ,{children:[t$(E3,{inverse:L===W,color:L===W?z.colors.primary:void 0,children:[L===W?" ▸ ":" ",O.displayNameSnapshot]},void 0,!0,void 0,this),O.status==="connected"?t$(E3,{color:"green",children:" ✓ connected"},void 0,!1,void 0,this):t$(E3,{dimColor:!0,children:[" ",O.host,":",O.port]},void 0,!0,void 0,this),O.principalFingerprint?t$(E3,{color:z.colors.secondary,children:[" ",F(O.principalFingerprint)]},void 0,!0,void 0,this):null]},`${O.displayNameSnapshot}-${O.nodeId}-${L}`,!0,void 0,this)),t$(fJ,{marginTop:q.length>0?1:0,children:t$(E3,{dimColor:!0,children:"type to search ↑↓ navigate ⏎ connect esc cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as W_,useMemo as N_,useState as rK}from"react";import{Box as yJ,Text as E8,useInput as P_}from"ink";import{jsxDEV as a2}from"react/jsx-dev-runtime";function __($,Z){let J=Z.trim().toLowerCase();if(!J)return!0;return $.displayLabel.toLowerCase().includes(J)||$.clientId.toLowerCase().includes(J)||$.clientKind.toLowerCase().includes(J)}function kJ($,Z){if(Z<=0)return 0;return Math.min($,Z-1)}function vJ({clients:$,onSelect:Z,onCancel:J}){let[Q,X]=rK(0),[Y,K]=rK(""),G=A(),z=N_(()=>$.filter((U)=>__(U,Y)),[$,Y]);W_(()=>{X((U)=>kJ(U,z.length))},[z.length]);let q=kJ(Q,z.length),W=process.stdin.isTTY??!1;return P_((U,F)=>{if(e(U,F)){J();return}if(F.return){if(z.length>0&&!z[q]?.self)Z(z[q]);return}if(F.upArrow){X((O)=>Math.max(0,O-1));return}if(F.downArrow){X((O)=>kJ(O+1,z.length));return}if(F.backspace||F.delete){K((O)=>O.slice(0,-1)),X(0);return}if(U&&!F.ctrl&&!F.meta)K((O)=>O+U),X(0)},{isActive:W}),a2(yJ,{flexDirection:"column",borderStyle:"round",borderColor:G.colors.secondary,paddingX:1,children:[a2(E8,{bold:!0,color:G.colors.primary,children:[" ","Same-Home Clients"," "]},void 0,!0,void 0,this),Y?a2(E8,{dimColor:!0,children:[' (filter: "',Y,'")']},void 0,!0,void 0,this):null,z.length===0&&a2(E8,{dimColor:!0,children:"No same-home clients found."},void 0,!1,void 0,this),z.map((U,F)=>a2(yJ,{flexDirection:"column",children:[a2(E8,{inverse:F===q,color:F===q?G.colors.primary:void 0,children:[F===q?" ▸ ":" ",U.displayLabel]},void 0,!0,void 0,this),a2(E8,{dimColor:!0,children:[" ",U.clientId,U.self?" self · not sendable":""]},void 0,!0,void 0,this)]},`${U.clientId}-${F}`,!0,void 0,this)),a2(yJ,{marginTop:z.length>0?1:0,children:a2(E8,{dimColor:!0,children:"type to search ↑↓ navigate ⏎ select esc cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{Box as e9,Text as n2,useInput as F_}from"ink";import{jsxDEV as U$}from"react/jsx-dev-runtime";function gJ({inviteToken:$,inviteLabel:Z,expiresAt:J,onClose:Q}){let X=A(),Y=process.stdin.isTTY??!1;return F_((K,G)=>{if(G.return||e(K,G))Q()},{isActive:Y}),U$(e9,{flexDirection:"column",borderStyle:"round",borderColor:X.colors.secondary,paddingX:1,paddingY:1,children:[U$(n2,{bold:!0,color:X.colors.primary,children:"Internet Invite"},void 0,!1,void 0,this),Z?U$(n2,{children:["Label: ",U$(n2,{bold:!0,children:Z},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,J?U$(n2,{dimColor:!0,children:["Expires: ",J]},void 0,!0,void 0,this):null,U$(e9,{marginTop:1,flexDirection:"column",children:[U$(n2,{children:"Share this token:"},void 0,!1,void 0,this),U$(n2,{children:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U$(e9,{marginTop:1,flexDirection:"column",children:[U$(n2,{children:"Join with:"},void 0,!1,void 0,this),U$(n2,{children:`aria pairing join ${$}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U$(e9,{marginTop:1,children:U$(n2,{dimColor:!0,children:"Press Enter or Esc to close."},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useState as U_}from"react";import{Box as $5,Text as x6,useInput as A_}from"ink";import{jsxDEV as i2}from"react/jsx-dev-runtime";function TJ({onSubmit:$,onCancel:Z,error:J}){let[Q,X]=U_(""),Y=A(),K=process.stdin.isTTY??!1;return A_((G,z)=>{if(e(G,z)){Z();return}if(z.return){let q=Q.trim();if(q.length>0)$(q);return}if(z.backspace||z.delete){X((q)=>q.slice(0,-1));return}if(G&&!z.ctrl&&!z.meta)X((q)=>q+G)},{isActive:K}),i2($5,{flexDirection:"column",borderStyle:"round",borderColor:Y.colors.secondary,paddingX:1,paddingY:1,children:[i2(x6,{bold:!0,color:Y.colors.primary,children:"Join Invite"},void 0,!1,void 0,this),i2(x6,{children:"Paste the invite token and press Enter."},void 0,!1,void 0,this),i2($5,{marginTop:1,children:i2(x6,{children:Q||" "},void 0,!1,void 0,this)},void 0,!1,void 0,this),J?i2($5,{marginTop:1,children:i2(x6,{color:Y.colors.error,children:J},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,i2($5,{marginTop:1,children:i2(x6,{dimColor:!0,children:"Type token, Enter to join, Esc to cancel."},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useState as O_,useRef as w_}from"react";import{Box as l6,Text as D4,useInput as L_}from"ink";import{jsxDEV as y$}from"react/jsx-dev-runtime";function VJ({request:$,onAccept:Z,onReject:J}){let[Q,X]=O_("accept"),Y=w_(!1),K=A(),G=process.stdin.isTTY??!1,z=(q)=>`${q.slice(0,4)} ${q.slice(4,8)} ${q.slice(8,12)} ${q.slice(12,16)}`;return L_((q,W)=>{if(Y.current)return;if(W.return){if(Y.current=!0,Q==="accept")Z();else J();return}if(e(q,W)){Y.current=!0,J();return}if(W.leftArrow||W.rightArrow||W.tab)X((U)=>U==="accept"?"reject":"accept")},{isActive:G}),y$(l6,{flexDirection:"column",borderStyle:"round",borderColor:K.colors.warning,paddingX:2,paddingY:1,children:[y$(D4,{bold:!0,color:K.colors.warning,children:[" ","Connection Request"," "]},void 0,!0,void 0,this),y$(l6,{marginTop:1,children:y$(D4,{children:[y$(D4,{bold:!0,children:$.displayNameSnapshot??$.nodeId},void 0,!1,void 0,this)," wants to connect"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),y$(l6,{children:y$(D4,{dimColor:!0,children:["Fingerprint: ",z($.principalFingerprint)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),y$(l6,{marginTop:1,gap:2,children:[y$(D4,{inverse:Q==="accept",color:Q==="accept"?K.colors.success:void 0,children:[" ","Accept"," "]},void 0,!0,void 0,this),y$(D4,{inverse:Q==="reject",color:Q==="reject"?K.colors.error:void 0,children:[" ","Reject"," "]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),y$(l6,{marginTop:1,children:y$(D4,{dimColor:!0,children:"←→ select ⏎ confirm esc reject"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as R_,useState as B_,useRef as aK}from"react";import{Box as Z5,Text as h4,useInput as I_}from"ink";import{jsxDEV as k$}from"react/jsx-dev-runtime";function M_({status:$}){let Z=A();switch($){case"connected":return k$(h4,{color:Z.colors.success,children:["✓"," connected"]},void 0,!0,void 0,this);case"expired":return k$(h4,{color:Z.colors.error,children:["✗"," expired"]},void 0,!0,void 0,this);case"none":return k$(h4,{color:Z.colors.textMuted,children:["·"," not connected"]},void 0,!0,void 0,this)}}function nK({providers:$,onSelect:Z,onCancel:J,isActive:Q=!0}){let X=A(),[Y,K]=B_(0),G=aK(0),z=aK(!1);R_(()=>{z.current=!1,G.current=0,K(0)},[$]);let q=(U)=>{K((F)=>{let O=U(F);return G.current=O,O})},W=process.stdin.isTTY??!1;return I_((U,F)=>{if(z.current)return;if(F.upArrow)q((O)=>Math.max(0,O-1));else if(F.downArrow)q((O)=>Math.min($.length-1,O+1));else if(F.return)z.current=!0,Z($[G.current]);else if(e(U,F))z.current=!0,J()},{isActive:Q&&W}),k$(Z5,{flexDirection:"column",borderStyle:"round",borderColor:X.colors.secondary,paddingX:1,paddingY:1,width:56,children:[k$(Z5,{marginBottom:1,children:k$(h4,{bold:!0,children:"Select a provider:"},void 0,!1,void 0,this)},void 0,!1,void 0,this),$.map((U,F)=>{let O=F===Y,L=O?"▸":" ";return k$(Z5,{gap:1,children:[k$(h4,{color:O?X.colors.primary:void 0,children:L},void 0,!1,void 0,this),k$(h4,{color:O?X.colors.primary:void 0,bold:O,children:U.label.padEnd(28)},void 0,!1,void 0,this),k$(M_,{status:U.status},void 0,!1,void 0,this)]},U.id,!0,void 0,this)}),k$(Z5,{marginTop:1,children:k$(h4,{color:X.colors.textMuted,children:["↑↓"," Navigate Enter Select Esc Cancel"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as C_,useRef as DJ,useState as J5}from"react";import{Box as e$,Text as $2,useInput as f_}from"ink";import{collectOAuthAuthorizationCode as S_,loginWithOAuth as b_}from"@aria-cli/auth";import{jsxDEV as E0}from"react/jsx-dev-runtime";function iK({provider:$,onCancel:Z,isActive:J=!0,onComplete:Q,authorizeUrl:X,expectedState:Y,onCodeSubmit:K}){let G=A(),[z,q]=J5("starting"),[W,U]=J5(""),[F,O]=J5(""),[L,B]=J5(""),S=DJ(null),k=DJ(!1),y=DJ(!1),f=process.stdin.isTTY??!1;f_((I,R)=>{if(e(I,R))Z()},{isActive:J&&f}),C_(()=>{if(k.current)return;k.current=!0,q("waiting");let I=new Promise((j)=>{S.current=j}),R=(j)=>{U(j),q("manual")};if(X&&K){U(X),S_($,{authorizeUrl:X,expectedState:Y,onManualFallback:R,manualCodePromise:I}).then(async(j)=>{if(y.current)return;q("exchanging"),await K(j),y.current=!0,q("success")},(j)=>{if(y.current)return;let Q0=j instanceof Error?j.message:String(j);O(Q0),q("error")});return}b_($,{onManualFallback:R,manualCodePromise:I}).then((j)=>{if(y.current)return;if(j.success)q("success"),y.current=!0,setTimeout(()=>{Q?.({success:!0,message:j.message})},1000);else O(j.message),q("error")},(j)=>{if(y.current)return;let Q0=j instanceof Error?j.message:String(j);O(Q0),q("error")})},[Y,X,K,Q,$]);let M=(I)=>{let R=I.trim();if(!R)return;if(q("exchanging"),S.current)S.current(R),S.current=null};return E0(e$,{flexDirection:"column",borderStyle:"round",borderColor:G.colors.secondary,paddingX:1,paddingY:1,width:64,children:[E0(e$,{marginBottom:1,children:E0($2,{bold:!0,children:["Sign in to ",$]},void 0,!0,void 0,this)},void 0,!1,void 0,this),(z==="starting"||z==="waiting")&&E0(e$,{gap:1,children:[E0(v8,{},void 0,!1,void 0,this),E0($2,{children:"Opening browser to sign in..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z==="manual"&&E0(e$,{flexDirection:"column",children:[E0($2,{children:"Open this URL in your browser:"},void 0,!1,void 0,this),E0(e$,{marginTop:1,children:E0($2,{color:G.colors.primary,wrap:"wrap",children:W},void 0,!1,void 0,this)},void 0,!1,void 0,this),E0(e$,{marginTop:1,children:E0($2,{children:"Paste the authorization code below:"},void 0,!1,void 0,this)},void 0,!1,void 0,this),E0(e$,{marginTop:1,children:[E0($2,{color:G.colors.textMuted,children:"> "},void 0,!1,void 0,this),E0(_8,{value:L,onChange:B,onSubmit:M,placeholder:"paste code here",focus:J,showCursor:!0},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z==="exchanging"&&E0(e$,{gap:1,children:[E0(v8,{},void 0,!1,void 0,this),E0($2,{children:"Exchanging code for tokens..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z==="success"&&E0($2,{color:G.colors.success,children:["✓"," Logged in to ",$]},void 0,!0,void 0,this),z==="error"&&E0(e$,{flexDirection:"column",children:[E0($2,{color:G.colors.error,children:["✗"," ",F]},void 0,!0,void 0,this),E0(e$,{marginTop:1,children:E0($2,{color:G.colors.textMuted,children:"Press Esc to dismiss"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z!=="success"&&z!=="error"&&E0(e$,{marginTop:1,children:E0($2,{color:G.colors.textMuted,children:"Esc Cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as y_,useRef as oK,useState as k_}from"react";import{Box as j8,Text as j3,useInput as v_}from"ink";import{jsxDEV as i1}from"react/jsx-dev-runtime";function g_({status:$}){let Z=A();if($==="connected")return i1(j3,{color:Z.colors.success,children:["✓"," connected"]},void 0,!0,void 0,this);if($==="available")return i1(j3,{color:Z.colors.success,children:["✓"," available"]},void 0,!0,void 0,this);return i1(j3,{color:Z.colors.textMuted,children:"·"},void 0,!1,void 0,this)}function c8({options:$,onSelect:Z,onCancel:J,title:Q="Select login method:",isActive:X=!0}){let Y=A(),[K,G]=k_(0),z=oK(0),q=oK(!1),W=process.stdin.isTTY??!1;y_(()=>{q.current=!1,z.current=0,G(0)},[$]);let U=(F)=>{G((O)=>{let L=F(O);return z.current=L,L})};return v_((F,O)=>{if(q.current)return;if(O.upArrow)U((L)=>Math.max(0,L-1));else if(O.downArrow)U((L)=>Math.min($.length-1,L+1));else if(O.return)q.current=!0,Z($[z.current]);else if(e(F,O))q.current=!0,J()},{isActive:X&&W}),i1(j8,{flexDirection:"column",borderStyle:"round",borderColor:Y.colors.secondary,paddingX:1,paddingY:1,width:64,children:[i1(j8,{marginBottom:1,children:i1(j3,{bold:!0,children:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this),$.map((F,O)=>{let L=O===K,B=L?"▸":" ";return i1(j8,{flexDirection:"column",children:[i1(j8,{gap:1,children:[i1(j3,{color:L?Y.colors.primary:void 0,children:B},void 0,!1,void 0,this),i1(j3,{color:L?Y.colors.primary:void 0,bold:L,children:F.label},void 0,!1,void 0,this),i1(g_,{status:F.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F.description&&i1(j8,{marginLeft:3,children:i1(j3,{color:Y.colors.textMuted,dimColor:!0,children:F.description},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},F.id,!0,void 0,this)}),i1(j8,{marginTop:1,children:i1(j3,{color:Y.colors.textMuted,children:["↑↓"," Navigate Enter Select Esc Cancel"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as T_}from"react/jsx-dev-runtime";function sK({options:$,onSelect:Z,onCancel:J,isActive:Q=!0}){return T_(c8,{options:$,onSelect:Z,onCancel:J,title:"Select Anthropic login method:",isActive:Q},void 0,!1,void 0,this)}import{useRef as V_,useState as D_}from"react";import{Box as u6,Text as m8,useInput as h_}from"ink";import{jsxDEV as Z2}from"react/jsx-dev-runtime";function d8({title:$,hint:Z,onSubmit:J,onCancel:Q,isActive:X=!0}){let Y=A(),[K,G]=D_(""),z=V_(!1),q=process.stdin.isTTY??!1;h_((U,F)=>{if(z.current)return;if(e(U,F)){z.current=!0,Q();return}if(F.return){if(K.trim().length>0)z.current=!0,J(K.trim());return}if(F.backspace||F.delete){G((O)=>O.slice(0,-1));return}if(F.upArrow||F.downArrow||F.leftArrow||F.rightArrow||F.tab)return;if(U&&!F.ctrl&&!F.meta)G((O)=>O+U)},{isActive:X&&q});let W=K.length>0?K.slice(0,4)+"•".repeat(Math.max(0,K.length-4)):"";return Z2(u6,{flexDirection:"column",borderStyle:"round",borderColor:Y.colors.secondary,paddingX:1,paddingY:1,width:64,children:[Z2(u6,{marginBottom:1,children:Z2(m8,{bold:!0,children:$},void 0,!1,void 0,this)},void 0,!1,void 0,this),Z&&Z2(u6,{marginBottom:1,children:Z2(m8,{color:Y.colors.textMuted,dimColor:!0,children:Z},void 0,!1,void 0,this)},void 0,!1,void 0,this),Z2(u6,{children:[Z2(m8,{color:Y.colors.primary,children:["▸"," "]},void 0,!0,void 0,this),Z2(m8,{children:W||" "},void 0,!1,void 0,this),Z2(m8,{color:Y.colors.textMuted,children:"_"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z2(u6,{marginTop:1,children:Z2(m8,{color:Y.colors.textMuted,children:"Enter Submit Esc Cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function tK($,Z,J={}){let Q=J.userName||"User",X=[],Y=new Map;function K(G,z){for(let q of G.content)switch(q.type){case"text":{if(G.role==="user"){let W=J7(q.text);for(let U of W)if(U.type==="image"&&oZ(U.dataUri))X.push({kind:"user-image",id:`${G.id}-image-${X.length}`,dataUri:U.dataUri,userName:Q,committed:z});else if(U.type==="text"&&U.text.length>0)X.push({kind:"user-message",id:`${G.id}-text-${X.length}`,text:U.text,userName:Q,committed:z})}else if(G.role==="system"&&q.text.length>0)X.push({kind:"user-message",id:`${G.id}-text-${X.length}`,text:q.text,userName:"System",committed:z});else if(G.role==="assistant"&&q.text.trim())X.push({kind:"assistant-text",id:`${G.id}-text-${X.length}`,text:q.text,arion:G.arion?{name:G.arion.name,emoji:G.arion.emoji||"\uD83E\uDD8B",color:G.arion.color||"cyan"}:void 0,committed:z});break}case"thinking":{if(q.content?.trim())X.push({kind:"thinking",id:`${G.id}-thinking-${X.length}`,content:q.content,durationSec:q.durationMs!=null?q.durationMs/1000:void 0,arion:G.arion?{name:G.arion.name,emoji:G.arion.emoji||"\uD83E\uDD8B",color:G.arion.color||"cyan"}:void 0,committed:z});break}case"tool_use":{let W={kind:"tool-execution",id:`${G.id}-tool-${q.id}`,toolName:q.name,input:q.arguments,output:void 0,status:"pending",durationMs:void 0,usage:void 0,committed:z};Y.set(q.id,W),X.push(W);break}case"tool_result":{let W=Y.get(q.toolUseId);if(W){if(W.output=q.resultData??q.content,W.status=q.status==="error"?"error":"complete",q.status==="error")W.error=typeof q.content==="string"?q.content:"Tool error";if(q.durationMs!=null)W.durationMs=q.durationMs;if(q.usage)W.usage={inputTokens:q.usage.inputTokens??0,outputTokens:q.usage.outputTokens??0};if(!z)W.committed=!1}break}case"handoff":{X.push({kind:"handoff",id:`${G.id}-handoff-${X.length}`,target:q.target,direction:q.direction==="from"?"incoming":"outgoing",committed:z});break}case"error":{X.push({kind:"error",id:`${G.id}-error-${X.length}`,message:q.content,suggestion:q.suggestion,committed:z});break}}}for(let G of $)K(G,!0);for(let G of Z)K(G,!1);return X}import{DEFAULT_SAFETY_CONFIG as d_}from"@aria-cli/aria";import{useReducer as E_,useEffect as hJ,useRef as ZG}from"react";var eK={kind:"idle"};function $G($,Z){switch(Z.type){case"STREAM_START":return{kind:"composing",verb:Z.verb};case"THINKING_START":if($.kind!=="composing"&&$.kind!=="idle")return $;return{kind:"thinking",verb:Z.verb,startedAt:Z.startedAt};case"THINKING_END":if($.kind!=="thinking")return $;return{kind:"composing",verb:Z.verb,thoughtForSeconds:Z.durationSeconds};case"TOOL_START":{let J=new Map($.kind==="tool_running"?$.tools:[]);return J.set(Z.callId,Z.displayName),{kind:"tool_running",tools:J}}case"TOOL_END":{if($.kind!=="tool_running")return $;let J=new Map($.tools);if(J.delete(Z.callId),J.size===0)return{kind:"composing",verb:Z.verb};return{kind:"tool_running",tools:J}}case"STREAM_END":return{kind:"idle"};default:return $}}function JG($,Z){let[J,Q]=E_($G,eK),X=ZG(!1);hJ(()=>{if(Z&&!X.current)Q({type:"STREAM_START",verb:V$()});else if(!Z&&X.current)Q({type:"STREAM_END"});X.current=Z},[Z]);let Y=ZG(null);return hJ(()=>{if($!==Y.current){if(Y.current!==null)Q({type:"STREAM_END"});Y.current=$}},[$]),hJ(()=>{if(!$)return;let K=()=>Q({type:"THINKING_START",verb:V$(),startedAt:Date.now()}),G=(W)=>Q({type:"THINKING_END",verb:V$(),durationSeconds:Math.round(W.durationMs/1000)}),z=(W)=>Q({type:"TOOL_START",callId:W.id,displayName:$X(W.name,!0)}),q=(W)=>Q({type:"TOOL_END",callId:W.id,verb:V$()});return $.on("thinking_start",K),$.on("thinking_end",G),$.on("tool_start",z),$.on("tool_result",q),()=>{$.off("thinking_start",K),$.off("thinking_end",G),$.off("tool_start",z),$.off("tool_result",q)}},[$]),J}function Q5($){let Z=typeof $.nodeId==="string"?$.nodeId.trim():"",J=typeof $.transport==="string"?$.transport:"unknown";if(Z)return`node:${Z}`;let Q=typeof $.principalFingerprint==="string"?$.principalFingerprint.trim():"";if(Q)return`principal:${Q}`;return`endpoint:${J}:${$.host}:${$.port}:${$.displayNameSnapshot}`}function QG($,Z){let J=new Map;for(let Q of[...$,...Z]){let X=Q5(Q);if(!J.has(X))J.set(X,Q)}return[...J.values()]}import{jsxDEV as p,Fragment as p_}from"react/jsx-dev-runtime";function EJ({session:$,model:Z,maxContextTokens:J,banner:Q,messages:X=[],previewMessages:Y=[],isStreaming:K=!1,queuedMessage:G,onCancelQueuedMessage:z,responseTime:q,commands:W=[],arions:U=[],models:F=[],memories:O=[],memoryBrowserMode:L="browse",isLoadingMemories:B=!1,userName:S,metrics:k,displayMode:y="standard",displayConfig:f,showThinking:M=!0,showCosts:I=!0,showTraces:R=!1,spans:j=[],pipelineTiming:Q0,activeArion:w1,onSubmit:P1,onCommand:H0,onSelectArion:o1,onSelectModel:L1,onSelectTheme:s1,onSelectMemory:D1,onOpenMemoryBrowser:R1,onToggleThinking:L0,onToggleCosts:z1,onToggleTraces:t1,onCycleDisplayMode:e1,sessions:v$=[],onSelectSession:i,onLoadSessions:s,onSearchSessions:C0,onLoadMoreSessions:l,staticRenderEpoch:R0,openSessionOverlaySignal:u0,openThemeOverlaySignal:X0,inputHistory:b0=[],onSaveInput:p0,obsCtx:h1,onCancel:c0,approvalRequest:Q2,onApprovalChoice:z5,effortLevel:E4,showAutonomySelector:q5,autonomyLevel:t6,onAutonomySelect:l8,onAutonomyCancel:e6,onCycleAutonomy:j4,onCycleEffort:g$,loginPickerProviders:c4,onLoginProviderSelect:$Z,onLoginPickerCancel:ZZ,copilotSourceOptions:u8,onCopilotSourceSelect:JZ,onCopilotSourceCancel:Z3,oauthProvider:x3,oauthAuthorizeUrl:r8,oauthExpectedState:M2,onOAuthComplete:H5,onOAuthCodeSubmit:a8,onOAuthCancel:J3,copilotDeviceProvider:n8,copilotDeviceProfileLabel:W5,copilotDeviceVerificationUri:l3,copilotDeviceUserCode:QZ,onCopilotDeviceComplete:m4,onCopilotDeviceApprove:XZ,onCopilotDeviceCancel:d4,anthropicMethodOptions:i8,onAnthropicMethodSelect:p4,onAnthropicMethodCancel:YZ,anthropicKeyInputVisible:x4,onAnthropicKeySubmit:KZ,onAnthropicKeyCancel:l4,anthropicSetupTokenVisible:GZ,onAnthropicSetupTokenSubmit:u4,onAnthropicSetupTokenCancel:o8,openaiMethodOptions:u3,onOpenAIMethodSelect:zZ,onOpenAIMethodCancel:r4,openaiKeyInputVisible:qZ,onOpenAIKeySubmit:a4,onOpenAIKeyCancel:HZ,googleMethodOptions:r3,onGoogleMethodSelect:WZ,onGoogleMethodCancel:n4,googleKeyInputVisible:NZ,onGoogleKeySubmit:i4,onGoogleKeyCancel:PZ,authInteractionOptions:a3,authInteractionTitle:N5,onAuthInteractionSelect:o4,onAuthInteractionCancel:_Z,authInteractionInput:Q3,onAuthInteractionInputSubmit:FZ,onAuthInteractionInputCancel:s4,nearbyPeers:t4=[],localClients:e4=[],onSelectPeer:P5,onSelectClient:s8,onPeerCancel:UZ,onClientsCancel:n3,openPeersOverlaySignal:AZ,openClientsOverlaySignal:t8,inviteShare:X3,onInviteShareClose:OZ,openJoinInviteOverlaySignal:C2,onJoinInviteSubmit:wZ,onJoinInviteCancel:_5,joinInviteError:F5,incomingPairRequest:i3,onAcceptPairRequest:U5,onRejectPairRequest:A5,onCancelPairing:LZ,openMessageEditOverlaySignal:RZ,editableMessages:Y3,onEditMessage:$8,prefillInput:Z8,onPrefillConsumed:O5,meshMessageCount:w5=0,runtimeSocket:ZQ=null,clientId:e8=null,clientAuthToken:X2=null,resolveCredentials:BZ}){let{exit:f2}=c_(),{columns:$6,rows:Z6}=K1(),[J8,t0]=c3(""),[c,t]=c3("none"),[K3,Q8]=c3(""),[X8,o3]=c3(""),[s3,S2]=c3("become"),[L5,t3]=c3("all"),[J6,R5]=c3(!1),Y2=Boolean(a3||i8||u3||r3),B5=Boolean(Q3||x4||GZ||qZ||NZ),IZ=Boolean(x3||n8||c4||u8);J2(()=>{if(Y2)t("login-method");else if(B5)t("login-input");else if(IZ)t("login");else if(c==="login"||c==="login-method"||c==="login-input")t("none")},[Y2,B5,IZ]);let Q6=o2(()=>{t("session"),setTimeout(()=>s?.(),0)},[s]);J2(()=>{if(u0===void 0)return;Q6()},[u0,Q6]),J2(()=>{if(X0===void 0)return;t("theme")},[X0]);let[e3,$4]=c3([]);J2(()=>{if(AZ===void 0)return;$4([...t4]),t("peers")},[AZ]),J2(()=>{if(t8===void 0)return;t("clients")},[t8]),J2(()=>{if(X3)t("invite-share");else if(c==="invite-share")t("none")},[X3,c]),J2(()=>{if(C2===void 0)return;t("join-invite")},[C2]),J2(()=>{if(RZ===void 0)return;if(Y3&&Y3.length>0)t("message-edit")},[RZ]),J2(()=>{if(Z8!==void 0)t0(Z8),O5?.()},[Z8]),J2(()=>{if(c!=="peers")return;$4((v)=>{let z0=new Set(v.map(Q5)),k0=t4.filter((z3)=>!z0.has(Q5(z3)));return k0.length>0?[...v,...k0]:v})},[c,t4]),J2(()=>{if(i3&&c==="none"&&!K)t("pair-request");else if(!i3&&c==="pair-request")t("none")},[i3,c,K]);let I5=process.stdin.isTTY??!1;m_((v,z0)=>{if(v==="\x03"||z0.ctrl&&v==="c"){if(K&&c0){c0();return}f2()}if(e(v,z0)){if(Q2)return;if(c!=="none"){H1();return}if(LZ){LZ();return}if(K&&G&&z)z();else if(K&&c0)c0();else t0("");return}if(z0.upArrow&&K&&G&&z){z();return}if(z0.ctrl&&v==="\x1C"&&c==="none"){e1?.();return}if(z0.ctrl&&v==="t"&&c==="none"){L0?.();return}if(z0.ctrl&&v==="g"&&c==="none"){z1?.();return}if(z0.ctrl&&v==="s"&&c==="none"){t1?.();return}if(z0.tab&&v!=="\t"&&c==="none"){j4?.();return}if(z0.ctrl&&v==="\x05"&&c==="none"){g$?.();return}if(z0.ctrl&&v==="\x1F"&&c==="none"){R5((k0)=>!k0);return}},{isActive:I5});let b2=$.getPrimary(),M5=b2?.name||"ARIA",Y$=b2?.color||"cyan",C5=b2?.emoji||"\uD83E\uDD8B",y2=JG(h1??null,K??!1),f5=(c==="none"&&!Q2?4:0)+(!f||f.showStatusBar?1:0),X6=Math.max(Z6-f5,1),G3=o2((v,z0)=>{if(v==="command")t("command"),Q8(z0);else if(v==="mention")t("arion"),o3(z0),S2("mention")},[]),S5=o2((v)=>{t("none"),t0("");let z0=v.requiresArgs===!0||(v.args?.length??0)>0;if(v.name==="become")t("arion"),S2("become"),t3("all");else if(v.name==="rest")t("arion"),S2("rest"),t3("active");else if(v.name==="wake")t("arion"),S2("wake"),t3("resting");else if(v.name==="model")t("model");else if(v.name==="theme")t("theme");else if(v.name==="memories")R1?.("browse"),t("memory");else if(v.name==="forget")R1?.("forget"),t("memory");else if(v.name==="resume")Q6();else if(v.name==="exit")f2();else if(z0){t0(`/${v.name} `);return}else H0(v.name)},[H0,R1,f2]),MZ=o2((v)=>{if(t("none"),s3==="mention"){let z0=J8.replace(/@\w*$/,"");t0(z0+"@"+v.name+" ")}else o1?.(v.name,s3)},[s3,J8,o1]),Y6=o2((v,z0)=>{t("none"),L1?.(v.value??v.name,z0)},[L1]),K6=o2((v)=>{t("none"),s1?.(v)},[s1]),q1=o2((v)=>{t("none"),D1?.(v)},[D1]),H1=o2(()=>{if(t("none"),s3!=="mention")t0("");Q8(""),o3("")},[s3]),K2=o2((v)=>{t("none"),t0(v),Q8("")},[]),G0=m3(()=>tK(X,Y,{userName:S}),[X,Y,S]),B1=m3(()=>j7(G0,y),[G0,y]),Z4=m3(()=>B1.filter((v)=>v.committed),[B1]),J4=m3(()=>B1.filter((v)=>!v.committed),[B1]),$$=K&&G?G:null,Y8=$$!==null,k2=y2.kind!=="idle",b5=Math.max($6-4,20),JQ=m3(()=>{if(!$$)return 0;return Math.max(W1($$,{width:b5}).split(`
|
|
114
|
-
`).length,1)},[b5,$$]),CZ=(Y8?4+JQ:0)+(k2?2:0),_1=Math.max(X6-CZ,1),m=m3(()=>{let v=new Map,z0="";for(let k0 of B1){let z3=k0.kind==="user-message"||k0.kind==="user-image"?`user:${k0.userName}`:k0.kind==="assistant-text"?`assistant:${k0.arion?.name??"ARIA"}`:k0.kind==="thinking"?`assistant:${k0.arion?.name??"ARIA"}`:k0.kind==="tool-execution"?"tool":k0.kind,F1=k0.kind==="user-message"||k0.kind==="user-image"||k0.kind==="assistant-text"||k0.kind==="thinking";if(v.set(k0.id,F1&&z3!==z0),F1)z0=z3}return v},[B1]),K8=m3(()=>{let v=new Map;for(let z0=0;z0<B1.length;z0++){let k0=B1[z0],z3=z0>0?B1[z0-1]:void 0,F1=k0.kind==="tool-execution"&&z3?.kind==="tool-execution";v.set(k0.id,z0>0&&!F1)}return v},[B1]),fZ=m3(()=>{let v=[];if(Q)v.push({id:"header",_kind:"banner"});for(let z0 of Z4)v.push({...z0,_kind:"item"});return v},[Q,Z4]);return p(p_,{children:[p(j_,{items:fZ,children:(v)=>{if(v._kind==="banner")return p(I2,{width:"100%",justifyContent:"center",children:Q},v.id,!1,void 0,this);return p(I2,{flexDirection:"column",marginTop:K8.get(v.id)?1:0,children:p(T9,{item:v,displayMode:y,showPrefix:m.get(v.id)??!1},void 0,!1,void 0,this)},v.id,!1,void 0,this)}},`static-${R0}`,!1,void 0,this),p(I2,{flexDirection:"column",width:"100%",children:[p(I2,{flexDirection:"column",maxHeight:X6,justifyContent:"flex-end",overflowY:"hidden",children:[J4.length>0&&p(I2,{flexDirection:"column",maxHeight:_1,overflowY:"hidden",children:J4.map((v)=>p(I2,{flexDirection:"column",marginTop:K8.get(v.id)?1:0,children:p(T9,{item:v,displayMode:y,showPrefix:m.get(v.id)??!1,previewTailLines:_1},void 0,!1,void 0,this)},v.id,!1,void 0,this))},void 0,!1,void 0,this),Y8&&p(I2,{marginTop:1,flexDirection:"column",children:[p(iZ,{param:{type:"text",text:$$??""},userName:S??"User",columns:$6,showPrefix:!0,addMargin:!1},void 0,!1,void 0,this),p(s2,{dimColor:!0,children:" ↑ queued — press esc or ↑ to cancel and edit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),R&&j.length>0&&p(r7,{spans:j},void 0,!1,void 0,this),f?.showPipelineTiming&&Q0&&Q0.phases.length>0&&p(a7,{report:Q0},void 0,!1,void 0,this),J6&&p(I2,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,marginY:1,children:[p(s2,{bold:!0,dimColor:!0,children:"Hotkeys"},void 0,!1,void 0,this),p(s2,{dimColor:!0,children:" Ctrl+\\ — cycle display mode"},void 0,!1,void 0,this),p(s2,{dimColor:!0,children:" Ctrl+t — toggle thinking blocks"},void 0,!1,void 0,this),p(s2,{dimColor:!0,children:" Ctrl+g — toggle cost display"},void 0,!1,void 0,this),p(s2,{dimColor:!0,children:" Ctrl+e — cycle effort level"},void 0,!1,void 0,this),p(s2,{dimColor:!0,children:" Ctrl+s — toggle trace waterfall"},void 0,!1,void 0,this),p(s2,{dimColor:!0,children:" Escape — cancel streaming / close overlay / clear input"},void 0,!1,void 0,this),p(s2,{dimColor:!0,children:" Ctrl+/ — toggle this help"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),k2&&p(o7,{state:y2.kind==="thinking"?"thinking":"composing",elapsedSeconds:Math.floor(k?.wallTimeSeconds??0),totalTokens:k?.totalTokens??0,thoughtForSeconds:y2.kind==="composing"?y2.thoughtForSeconds:void 0,currentVerb:y2.kind==="tool_running"?[...new Set(y2.tools.values())].join(" · "):y2.verb.present},void 0,!1,void 0,this)]},void 0,!0,void 0,this),p(I2,{flexDirection:"column",flexShrink:0,children:[q5&&l8&&e6&&p(l7,{currentLevel:t6??d_.autonomy,onSelect:l8,onCancel:e6},void 0,!1,void 0,this),c4&&$Z&&ZZ&&p(nK,{providers:c4,onSelect:$Z,onCancel:ZZ},void 0,!1,void 0,this),u8&&JZ&&Z3&&p(p7,{options:u8,onSelect:JZ,onCancel:Z3},void 0,!1,void 0,this),c==="login-method"&&a3&&o4&&_Z&&p(c8,{options:a3,onSelect:(v)=>o4(v.id),onCancel:_Z,title:N5??"Choose an option:",isActive:c==="login-method"},void 0,!1,void 0,this),c==="login-method"&&i8&&p4&&YZ&&p(sK,{options:i8,onSelect:p4,onCancel:YZ,isActive:c==="login-method"},void 0,!1,void 0,this),c==="login-input"&&Q3&&FZ&&s4&&p(d8,{title:Q3.title,hint:Q3.hint,onSubmit:FZ,onCancel:s4,isActive:c==="login-input"},void 0,!1,void 0,this),c==="login-input"&&x4&&KZ&&l4&&p(d8,{title:"Enter Anthropic API key",hint:"Paste your sk-ant-api03-* key",onSubmit:KZ,onCancel:l4,isActive:c==="login-input"},void 0,!1,void 0,this),c==="login-input"&&GZ&&u4&&o8&&p(d8,{title:"Enter setup token",hint:"From `claude setup-token` or admin provisioning",onSubmit:u4,onCancel:o8,isActive:c==="login-input"},void 0,!1,void 0,this),c==="login-method"&&u3&&zZ&&r4&&p(c8,{options:u3,onSelect:zZ,onCancel:r4,title:"Select OpenAI login method:",isActive:c==="login-method"},void 0,!1,void 0,this),c==="login-input"&&qZ&&a4&&HZ&&p(d8,{title:"Enter OpenAI API key",hint:"Paste your sk-* key",onSubmit:a4,onCancel:HZ,isActive:c==="login-input"},void 0,!1,void 0,this),c==="login-method"&&r3&&WZ&&n4&&p(c8,{options:r3,onSelect:WZ,onCancel:n4,title:"Select Google login method:",isActive:c==="login-method"},void 0,!1,void 0,this),c==="login-input"&&NZ&&i4&&PZ&&p(d8,{title:"Enter Google API key",hint:"Paste your AIza* key",onSubmit:i4,onCancel:PZ,isActive:c==="login-input"},void 0,!1,void 0,this),c==="login"&&x3&&H5&&J3&&p(iK,{provider:x3,onCancel:J3,...r8&&a8?{authorizeUrl:r8,expectedState:M2??void 0,onCodeSubmit:a8}:{onComplete:H5},isActive:c==="login"},void 0,!1,void 0,this),c==="login"&&n8&&m4&&d4&&p(d7,{provider:n8,profileLabel:W5??void 0,...l3&&QZ&&XZ?{verificationUri:l3,userCode:QZ,onApprove:XZ}:{onComplete:m4},onCancel:d4},void 0,!1,void 0,this),p(I2,{flexDirection:"column",children:[c==="command"&&p(_J,{commands:W,initialFilter:K3,onSelect:S5,onHandOffInput:K2,onCancel:H1},void 0,!1,void 0,this),c==="arion"&&p(FJ,{arions:U,initialFilter:X8,statusFilter:L5,onSelect:MZ,onCancel:H1},void 0,!1,void 0,this),c==="model"&&p(AJ,{models:F,effortLevel:E4,onSelect:Y6,onCancel:H1},void 0,!1,void 0,this),c==="theme"&&p(CJ,{onSelect:K6,onCancel:H1},void 0,!1,void 0,this),c==="invite-share"&&X3&&p(gJ,{inviteToken:X3.inviteToken,inviteLabel:X3.inviteLabel,expiresAt:X3.expiresAt,onClose:()=>{t("none"),OZ?.()}},void 0,!1,void 0,this),c==="join-invite"&&p(TJ,{error:F5,onSubmit:(v)=>{t("none"),wZ?.(v)},onCancel:()=>{t("none"),_5?.()}},void 0,!1,void 0,this),c==="memory"&&p(wJ,{memories:O,mode:L,isLoading:B,onSelect:q1,onCancel:H1},void 0,!1,void 0,this),c==="peers"&&p(bJ,{peers:e3.length>0?e3:t4,sameHomeClientsAvailable:e4.length>0,onSelect:(v)=>{t("none"),P5?.(v)},onCancel:H1},void 0,!1,void 0,this),c==="clients"&&p(vJ,{clients:e4,onSelect:(v)=>{t("none"),t0(`/send ${v.clientId} `),s8?.(v)},onCancel:()=>{t("none"),n3?.()}},void 0,!1,void 0,this),c==="pair-request"&&i3&&p(VJ,{request:i3,onAccept:()=>{t("none"),U5?.()},onReject:()=>{t("none"),A5?.()}},void 0,!1,void 0,this),c==="session"&&p(RJ,{sessions:v$,onSelect:(v)=>{t("none"),i?.(v)},onCancel:H1,onSearch:(v)=>C0?.(v),onPageChange:(v)=>l?.(v)},void 0,!1,void 0,this),c==="message-edit"&&Y3&&p(IJ,{messages:Y3,onSelect:(v,z0)=>{t("none"),$8?.(v,z0)},onCancel:H1},void 0,!1,void 0,this),c==="none"&&!Q2&&p($7,{userName:S,value:J8,onChange:t0,onSubmit:P1,onTrigger:G3,onExit:()=>f2(),history:b0,onSaveInput:p0,focus:c==="none",isStreaming:K,onDoubleEscape:()=>{if(Y3&&Y3.length>0)return t("message-edit"),!0;return!1}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),(!f||f.showStatusBar)&&p(j5,{arion:{name:M5,emoji:C5,color:Y$,traits:b2?.personality?.traits?.slice(0,2)},model:Z,maxContextTokens:J,responseTime:q,metrics:k,displayMode:y,showCosts:I,activeArion:w1,effortLevel:E4,autonomyLevel:t6,meshMessageCount:w5},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as X5}from"react/jsx-dev-runtime";function a_($){let Z=h6[$.toLowerCase()];return{name:$,userFacingName(J){if(Z)return Z.displayName(J);return $},renderToolUseMessage(J,Q){if(Z)return Z.renderInput(J,Q);return JSON.stringify(J)},isReadOnly(){return!1},inputSchema:{parse(J){return J??{}}}}}var n_={message:{id:"aria-approval"}};function i_($){switch($){case"low":return 0.2;case"moderate":return 0.5;case"high":return 0.9}}function XG($){let{stdout:Z}=r_(),J=Z?.columns??80,[Q]=l_(!1),X=x_(()=>{if(!$.approvalRequest)return null;let{toolName:Y,input:K,riskLevel:G,resolve:z}=$.approvalRequest;return{assistantMessage:n_,tool:a_(Y),description:`${Y} requires approval`,input:K??{},commandPrefix:null,riskScore:i_(G),onAbort(){z(!1)},onAllow(q){z(!0)},onReject(){z(!1)}}},[$.approvalRequest]);if(X)return X5(u_,{flexDirection:"column",width:"100%",children:[X5(EJ,{...$},void 0,!1,void 0,this),X5(NJ,{toolUseConfirm:X,onDone:()=>{},verbose:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return X5(EJ,{...$},void 0,!1,void 0,this)}import{execFile as o_}from"node:child_process";import{existsSync as GG,readdirSync as zG}from"node:fs";import{dirname as s_,join as Y5,resolve as t_}from"node:path";import{fileURLToPath as e_}from"node:url";var $F=s_(e_(import.meta.url));function ZF(){let $=$F;for(let Z=0;Z<10;Z++){let J=Y5($,".comms","sounds","wav");if(GG(J))return J;let Q=t_($,"..");if(Q===$)break;$=Q}return null}var a6=ZF();function j0($){if(!a6)return[];try{return zG(a6).filter((Z)=>new RegExp($).test(Z)).map((Z)=>Y5(a6,Z))}catch{return[]}}function YG($){if(!a6)return[];let Z=Y5(a6,"cloned");try{return zG(Z).filter((J)=>new RegExp($).test(J)).map((J)=>Y5(Z,J))}catch{return[]}}function t2($){if($.length===0)return null;return $[Math.floor(Math.random()*$.length)]}var jJ=!0;function cJ($){jJ=$}function qG(){return jJ}function e2($){if(!jJ||!$||!GG($))return;o_("afplay",[$],()=>{})}var $3={acknowledge:()=>j0("^(peasant|orc|human|dwarf|elf|troll)_acknowledge"),annoyed:()=>j0("^(peasant|orc|goblin_sapper|human|troll|ogre)_selected"),grumpy:()=>j0("^(goblin_sapper|ogre|ogre_mage)_selected"),dark:()=>[...j0("^ogre_mage_selected"),...j0("^ogre_selected"),...j0("^troll_selected")],defeat:()=>YG("^defeat_"),error:()=>YG("^error_"),readyToWork:()=>[...j0("^peasant_selected"),...j0("^orc_selected"),...j0("^human_selected"),...j0("^dwarf_selected")],fleetUp:()=>[...j0("^orc_acknowledge"),...j0("^troll_acknowledge"),...j0("^ogre_acknowledge"),...j0("^human_acknowledge"),...j0("^knight_acknowledge")],fleetDown:()=>[...j0("^ogre_mage_acknowledge"),...j0("^ship_acknowledge"),...j0("^horde_ship_acknowledge")],questDone:()=>[...j0("^jobs_done"),...j0("^orc_work_completed"),...j0("^peasant_selected"),...j0("^orc_selected"),...j0("^human_selected"),...j0("^peasant_acknowledge"),...j0("^orc_acknowledge")]},KG=0,r6=0,JF=15000;function QF(){let $=Date.now();if($-KG>JF)r6=1;else r6++;if(KG=$,r6<=1)e2(t2($3.acknowledge()));else if(r6===2)e2(t2($3.annoyed()));else if(r6===3)e2(t2($3.grumpy()));else e2(t2($3.dark()))}function HG(){e2(t2($3.readyToWork()))}function WG(){e2(t2($3.fleetDown()))}function NG(){QF()}function PG(){e2(t2($3.questDone()))}function _G($){switch($.type){case"error":e2(t2($3.error()));break;case"guardrail_rejected":e2(t2($3.defeat()));break}}var mJ=[{name:"become",description:"Switch to another arion",usage:"/become <name>",args:["<name>"],requiresArgs:!0},{name:"arions",description:"List all arions",args:[]},{name:"hatch",description:"Create a new arion",usage:"/hatch <name> [description]",args:["<name>","[description]"],requiresArgs:!0},{name:"rest",description:"Put an arion to rest",usage:"/rest <name>",args:["<name>"],requiresArgs:!0},{name:"wake",description:"Wake a resting arion",usage:"/wake <name>",args:["<name>"],requiresArgs:!0},{name:"model",description:"Change or view current AI model",args:["[name]"]},{name:"autonomy",description:"Change permission approval policy",usage:"/autonomy [level]",args:["[level]"]},{name:"sound",description:"Toggle Warcraft sound notifications on/off",usage:"/sound [on|off]",args:["[on|off]"]},{name:"remember",description:"Store a memory",usage:"/remember <text>",args:["<text>"],requiresArgs:!0},{name:"recall",description:"Search memories",usage:"/recall <query>",args:["<query>"],requiresArgs:!0},{name:"recall_knowledge",description:"Search learned tools (skills, procedures, techniques)",usage:"/recall_knowledge <topic>",args:["<topic>"],requiresArgs:!0},{name:"send",description:"Send a peer or same-home client message through the runtime transport",usage:"/send <peer-name|node-id|client-id> <message>",args:["<peer-name|node-id|client-id>","<message>"],requiresArgs:!0},{name:"forget",description:"Delete a memory",usage:"/forget <id>",args:["<id>"],requiresArgs:!0},{name:"memories",description:"Browse all memories",args:[]},{name:"resume",description:"Resume a previous session",args:["[session-id]"]},{name:"fork",description:"Fork the current session into a new branch",usage:"/fork [session-id] [message-count] [--stay]",args:["[session-id]","[message-count]","[--stay]"]},{name:"clear",description:"Clear the screen",args:[]},{name:"login",description:"Authenticate with provider (bedrock, anthropic, openai, google, copilot)",usage:"/login [provider] [api-key|--profile <label>|--source <gh|device>]",args:["[provider]","[api-key|flags]"]},{name:"logout",description:"Disconnect a provider or clear all credentials",usage:"/logout [provider|all]",args:["[provider|all]"]},{name:"help",description:"Show available commands",args:[]},{name:"restart",description:"Restart ARIA",usage:"/restart [reason]",args:["[reason]"]},{name:"terminal-setup",description:"Install Shift+Enter newline key binding for supported terminals",usage:"/terminal-setup",args:[]},{name:"theme",description:"View or change the color theme",usage:"/theme [name]",args:["[name]"]},{name:"invite",description:"Create an internet invite token",usage:"/invite [label]",args:["[label]"]},{name:"join",description:"Accept an internet invite token",usage:"/join [token]",args:["[token]"]},{name:"peers",description:"Show nearby peers and connect",args:[]},{name:"clients",description:"Show same-home attached clients",args:[]},{name:"exit",description:"Exit ARIA",args:[]}];import{autonomyToConfirmation as fF,AUTONOMY_LEVELS as G5,DEFAULT_SAFETY_CONFIG as SF,isPrivateLanIP as bF}from"@aria-cli/aria";import{parseMessage as yF,recoverCrashedSessions as kF,NoopOTELAdapter as vF,HttpOTELAdapter as gF,JsonlEventLogger as TF}from"@aria-cli/aria";import{resolveTrustedRuntimeErrorMessage as nJ}from"@aria-cli/tools";import{getCliModels as VF,getCliSelectableModels as iJ,getDefaultModelByTier as oJ,getModelByShortName as kG,MODEL_REGISTRY as DF,selectRunnableModelVariant as x8,toShortName as hF}from"@aria-cli/models";import{MemoriaPool as EF}from"@aria-cli/aria";import{getErrorMessage as sJ,log as N0}from"@aria-cli/types";import{NO_RELAUNCH_ENV as YF,RELAUNCH_EXIT_CODE as KF,RESUME_ARION_ENV as FG,RESUME_SESSION_ENV as pJ,RESTART_KIND_ENV as _D,clearRelaunchMarker as FD,readRelaunchMarker as UD,writeRelaunchMarker as GF}from"@aria-cli/types";import{NO_RELAUNCH_ENV as LD,RELAUNCH_EXIT_CODE as RD,RESUME_ARION_ENV as BD,RESUME_SESSION_ENV as ID,RESTART_KIND_ENV as MD}from"@aria-cli/types";function lJ($){GF($)}function zF($){if(!$||typeof $!=="object")return!1;let Z=$;return Z.code==="EPIPE"||Z.code==="EIO"||Z.code==="ERR_STREAM_DESTROYED"}function dJ($){try{process.stderr.write($)}catch(Z){if(zF(Z))return;throw Z}}var UG=process.env[pJ]??null,xJ=process.env[FG]||"ARIA";function n6($){let Z=$?.trim()||null;if(UG=Z,Z)process.env[pJ]=Z;else delete process.env[pJ]}function K5(){return UG}function uJ($){xJ=$||"ARIA",process.env[FG]=xJ}function qF(){return xJ}function HF(){return process.env[YF]==="true"}async function AG($,Z){if(!HF())throw Error("Restart requires RelaunchSupervisor; detached self-spawn has been removed.");let J=$||"Restart requested";if(Z!==void 0)n6(Z);let Q=K5(),X=qF();dJ(`[aria] Relaunch requested: ${J} (session=${Q?.slice(0,8)??"none"}, arion=${X})
|
|
115
|
-
`);let Y=process.ppid||process.pid;lJ({sessionId:Q,arionName:X,pid:Y,timestamp:new Date().toISOString()});try{let K=process.send;if(typeof K==="function"){let G=`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;if(await new Promise((q)=>{let W=!1,U=setTimeout(()=>{if(W)return;W=!0,process.off("message",F),q(!1)},120),F=(O)=>{if(!O||typeof O!=="object")return;let L=O;if(L.type!=="aria-relaunch-ack")return;if(L.nonce!==G)return;if(W)return;W=!0,clearTimeout(U),process.off("message",F),q(!0)};process.on("message",F),K({type:"aria-relaunch",nonce:G,resumeSessionId:Q,arionName:X},(O)=>{if(O&&!W)W=!0,clearTimeout(U),process.off("message",F),q(!1)})}))dJ(`[aria] IPC handoff acknowledged by supervisor
|
|
116
|
-
`);else dJ(`[aria] IPC ack timeout — disk marker will be used as fallback
|
|
117
|
-
`)}}catch{}throw process.exit(KF),Error("Unreachable")}import{randomUUID as p8}from"crypto";function rJ($){return $.trim().toLowerCase()}function wG($){let Z=$.trim();if(!Z.startsWith("/"))return null;let J=Z.indexOf(" ");if(J===-1){let Y=Z.slice(1);return{command:OG(Y)??rJ(Y),args:""}}let Q=Z.slice(1,J);return{command:OG(Q)??rJ(Q),args:Z.slice(J+1).trim()}}var WF=["help","arions","exit","hatch","remember","recall","recall_knowledge","send","model","become","rest","wake","memories","forget","clear","autonomy","resume","fork","restart","login","logout","terminal-setup","theme","invite","join"],NF=new Map(WF.map(($)=>[$.toLowerCase(),$]));function OG($){return NF.get(rJ($))??null}import{ArionManager as UF,ArionStorage as AF,DEFAULT_SAFETY_CONFIG as OF}from"@aria-cli/aria";import{getDefaultModelByTier as wF}from"@aria-cli/models";import{existsSync as PF,readFileSync as vD,readdirSync as _F}from"node:fs";import FF from"node:path";function aJ($,Z){let J=Z.trim();if(!J)return"ARIA";let Q=FF.join($,"arions");if(!PF(Q))return J;try{let X=J.toLowerCase();for(let Y of _F(Q,{withFileTypes:!0}))if(Y.isDirectory()&&Y.name.toLowerCase()===X)return Y.name}catch{}return J}async function LF($){let Z=new AF($.ariaDir),J=new UF(Z,$.memoriaFactory);return J.setRouter($.router),await J.initialize(),J}function LG($,Z){let J=Z.trim().toLowerCase();return $.find((Q)=>Q.shortName.toLowerCase()===J||typeof Q.id==="string"&&Q.id.toLowerCase()===J)}function RG($){return wF($??"balanced")}function CG($){let Z=$.cli,J=aJ(Z.ariaDir,$.activeArionName??Z.config.activeArion??"ARIA"),Q,X=[...Z.availableModels],Y=null,K=new Map,G=async()=>{return Y??=LF(Z),Y},z=async()=>{let S=await(await G()).get(J);if(!S)throw Error(`Unable to resolve active Arion ${J}`);return S},q=async()=>{let B=await z(),S=K.get(B.name);if(S)return S;let y=await(await G()).getMemoria(B);if(!y)throw Error(`Memoria is unavailable for Arion ${B.name}`);return K.set(B.name,y),y},W={list:async()=>(await G()).list(),hatch:async(B)=>(await G()).hatch(B),get:async(B)=>(await G()).get(B),wake:async(B)=>{await(await G()).wake(B)},rest:async(B,S)=>{await(await G()).rest(B,S)}},U={async getTheme(){return l0().theme??A().name},async setTheme(B){let S=B.trim();if(!h3().includes(S))throw Error(`Unknown theme: ${B}`);let k=l0();return k.theme=S,X$(k),D3(S),{theme:S}},async getAutonomy(){return l0().autonomy??OF.autonomy},async setAutonomy(B){if(!["minimal","balanced","high","full"].includes(B))throw Error(`Invalid autonomy level: ${B}`);let S=l0();return S.autonomy=B,X$(S),{autonomy:B}},async getActiveArion(){return J},async setActiveArion(B){let S=B.trim()||"ARIA",k=aJ(Z.ariaDir,S);try{let M=await(await G()).get(S);if(M?.name)k=M.name}catch{}let y=l0();y.activeArion=k,X$(y),J=k}},F={async listAvailable(){return X},async refresh(B){return X=[...await Z.refreshAvailableModels(B)],X},async getCurrentModel(){if(Q)return Q;let B=l0();try{let S=await z();if(typeof S.preferredModel==="string"&&S.preferredModel.trim().length>0)return Q=S.preferredModel.trim(),Q}catch{}return Q=RG(B.preferredTier??Z.config.preferredTier)?.shortName,Q},async setCurrentModel(B){let S=LG(X,B)??LG(await Z.refreshAvailableModels(!0),B);if(!S)throw Error(`Unknown model: ${B}`);Q=S.shortName;let k=l0();k.preferredTier=S.tier,X$(k),X=[...await Z.refreshAvailableModels(!1)];try{let y=await G(),f=await z();await y.setPreferredModel(f.name,S.shortName)}catch{}return{currentModel:S.shortName,tier:S.tier}},async getSessionModel(){return Q}};(async()=>{try{let B=await z();if(typeof B.preferredModel==="string"&&B.preferredModel.trim().length>0){Q=B.preferredModel.trim();return}}catch{}Q=RG(l0().preferredTier??Z.config.preferredTier)?.shortName})();let O={async status(){return{providers:BG()}},async login(B){let S=typeof B.args==="string"?B.args:"";return IG(S)},async logout(B){let S=typeof B.args==="string"?B.args:"";return MG(S)}},L=new Proxy({},{get(B,S){return async(...k)=>{let y=await q(),f=y[S];if(typeof f!=="function")throw Error(`Memoria method ${String(S)} is unavailable`);return f.apply(y,k)}}});return{arionManager:$.overrides?.arionManager??W,auth:$.overrides?.auth??O,config:$.overrides?.config??U,memoria:$.overrides?.memoria??L,modelDiscovery:$.overrides?.modelDiscovery??F}}function fG($){let Z=$();if(!Z)throw Error("Late-bound service target is unavailable");return Z}function SG($){return new Proxy({},{get(Z,J){if(J==="then")return;let X=fG($)[J];if(typeof X!=="function")throw Error(`Late-bound service method ${String(J)} is unavailable`);return(...Y)=>X.apply(fG($),Y)},has(Z,J){return typeof $()?.[J]==="function"},ownKeys(){let Z=$();return Reflect.ownKeys(Z??{}).filter((J)=>typeof Z?.[J]==="function")},getOwnPropertyDescriptor(Z,J){let Q=$();if(typeof Q?.[J]!=="function")return;return{configurable:!0,enumerable:!0,writable:!1,value:Q[J]}}})}import{useReducer as RF,useMemo as bG,useCallback as BF}from"react";function IF($,Z){switch(Z.type){case"START_TURN":return{items:$.items,streamCursor:$.items.length};case"UPDATE_STREAM":{if($.streamCursor===null)return $;return{items:[...$.items.slice(0,$.streamCursor),...Z.snapshot],streamCursor:$.streamCursor}}case"COMMIT_TURN":{let J=$.streamCursor??$.items.length,Q=[...$.items.slice(0,J),...Z.flushed];return{items:Q,streamCursor:Q.length}}case"END_TURN":return{items:$.items,streamCursor:null};case"APPEND_COMMITTED":{if($.streamCursor!==null){let J=$.items.slice(0,$.streamCursor),Q=$.items.slice($.streamCursor);return{items:[...J,...Z.items,...Q],streamCursor:$.streamCursor+Z.items.length}}return{items:[...$.items,...Z.items],streamCursor:null}}case"RESET":return{items:Z.items??[],streamCursor:null};case"DISCARD_STREAMING":{if($.streamCursor===null)return $;return{items:$.items.slice(0,$.streamCursor),streamCursor:null}}case"FUNCTIONAL_UPDATE":{if($.streamCursor!==null){let J=$.items.slice(0,$.streamCursor),Q=$.items.slice($.streamCursor),X=Z.updater(J);return{items:[...X,...Q],streamCursor:X.length}}return{items:Z.updater($.items),streamCursor:null}}case"COMMIT_AND_END":{let J=$.streamCursor??$.items.length;return{items:[...$.items.slice(0,J),...Z.flushed],streamCursor:null}}default:return $}}function yG($){let Z=$?{items:$,streamCursor:null}:{items:[],streamCursor:null},J=IF,[Q,X]=RF(J,Z),Y=bG(()=>Q.streamCursor!==null?Q.items.slice(0,Q.streamCursor):Q.items,[Q.items,Q.streamCursor]),K=bG(()=>Q.streamCursor!==null?Q.items.slice(Q.streamCursor):[],[Q.items,Q.streamCursor]),G=Q.streamCursor!==null,z=BF((q)=>{if(typeof q==="function")X({type:"FUNCTIONAL_UPDATE",updater:q});else X({type:"RESET",items:q})},[X]);return{items:Q.items,committedItems:Y,streamingItems:K,isStreaming:G,dispatch:X,setItems:z}}import{jsxDEV as eJ}from"react/jsx-dev-runtime";function tJ($){return $!=null&&typeof $==="object"&&"code"in $&&$.code==="ARIA_SESSION_EXPIRED"}function vG($){try{let Z=typeof $==="string"?$:JSON.stringify($);if(!Z)return"";return Z.length>160?`${Z.slice(0,160)}...`:Z}catch{return""}}function jF($){let Z=TG(),J=Z?`phase="${Z.label}" (active for ${Z.ageMs.toFixed(0)}ms)`:"phase=unknown (no phase set)",Q=`[InkREPL][WARN] Event loop stall detected: ${$.toFixed(0)}ms (threshold ${$Q}ms) ${J}
|
|
118
|
-
`,X=Error("[InkREPL] Event loop watchdog detection stack").stack??"[stack unavailable]";try{process.stderr.write(Q),process.stderr.write(`${X}
|
|
119
|
-
`)}catch{}}function cF($){if(!process.env.DEBUG)return;try{let Z=($/1000).toFixed(1);process.stderr.write(`[InkREPL][DEBUG] System sleep/suspend detected: ${Z}s
|
|
120
|
-
`)}catch{}}function mF($){if($==="high"||$==="dangerous")return"high";if($==="moderate")return"moderate";return"low"}function dF($){for(let Z=$.length-1;Z>=0;Z--)if($[Z]?.role==="assistant")return $[Z].content;return""}function pF($){return`${$.provider}/${$.shortName}`}function xF($,Z,J){let Q=$.trim().toLowerCase();if(!Q)return;let X=[...Z].sort((F,O)=>F.shortName.localeCompare(O.shortName)),Y=X.find((F)=>{return`${F.provider}/${F.shortName}`.toLowerCase()===Q});if(Y)return Y;let K=X.find((F)=>F.shortName.toLowerCase()===Q);if(K)return x8(K,J);let G=X.find((F)=>F.shortName.toLowerCase().startsWith(Q));if(G)return x8(G,J);let z=X.find((F)=>{return`${F.provider}/${F.shortName}`.toLowerCase().startsWith(Q)});if(z)return z;let q=X.find((F)=>F.tier.toLowerCase()===Q);if(q)return x8(q,J);let W=X.find((F)=>F.displayName.toLowerCase().includes(Q));if(W)return x8(W,J);let U=X.find((F)=>F.provider.toLowerCase().includes(Q));return U?x8(U,J):void 0}async function Mh($,Z,J){let Q=Array($.length),X=[],Y=async()=>{if(X.length===0)return;let G=(await Promise.allSettled(X.map((z)=>J(z.call)))).map((z,q)=>z.status==="fulfilled"?z.value:{id:X[q].call.id,result:`Tool error: ${z.reason?.message||"Unknown error"}`,isError:!0});for(let z=0;z<X.length;z++)Q[X[z].index]=G[z];X=[]};for(let K=0;K<$.length;K++){let G=$[K];if(Z.get(G.name)?.isReadOnly)X.push({index:K,call:G});else await Y(),Q[K]=await J(G)}return await Y(),Q}var N1={sessionId:null,sessionHistory:null,memoriaSession:null,memoriaFactory:null,jsonlLogger:null};function gG($,Z,J){let Q=J>1?`Run paused: answer question ${Z+1} of ${J} to continue.`:"Run paused: answer the question below to continue.",X=Array.isArray($.options)&&$.options.length>0?`
|
|
121
|
-
Options: ${$.options.join(" | ")}`:"";return`${Q}
|
|
122
|
-
${$.question}${X}`}function lF({session:$,manager:Z,router:J,aria:Q,attachedLocalControl:X,cliContext:Y,sessionHistory:K,initialModel:G="sonnet-4.5",inputHistory:z=[],onSaveInput:q,initialMessage:W,resumeSessionId:U,cachedUserName:F,initialAvailableModels:O=VF(),refreshAvailableModels:L,credentialHints:B,authResolver:S}){let{exit:k}=CF(),{committedItems:y,streamingItems:f,isStreaming:M,dispatch:I,setItems:R}=yG(),j=l0(),Q0=j.preferredTier||"balanced",P1=oJ(Q0,B)?.shortName||G,[H0,o1]=E(P1),L1=F0(P1),[s1,D1]=E(j.effortLevel??"high"),R1=M,L0=F0(!1),z1=F0(!1),t1=F0(!1),e1=F0(!1),v$=F0(Promise.resolve()),i=F0(null),[s,C0]=E(null),[l,R0]=E(),[u0,X0]=E([]),[b0,p0]=E(F??null),[h1,c0]=E(0),[Q2,z5]=E([]),[E4,q5]=E("browse"),[t6,l8]=E(!1),[e6,j4]=E([]),[g$,c4]=E(O),[$Z,ZZ]=E(void 0),[u8,JZ]=E(void 0),Z3=F0(0),x3=F0(""),r8=F0(0),M2=F0(null),H5=100,a8=j.autonomy??SF.autonomy,J3=F0(a8),[n8,W5]=E(a8),l3=u((H)=>{J3.current=H,W5(H),X$({...l0(),autonomy:H})},[]),[QZ,m4]=E(!1),[XZ,d4]=E(null),[i8,p4]=E(null),[YZ,x4]=E(null),[KZ,l4]=E(null),[GZ,u4]=E(null),[o8,u3]=E(null),[zZ,r4]=E(null),[qZ,a4]=E(null),[HZ,r3]=E(null),[WZ,n4]=E(null),[NZ,i4]=E(null),[PZ,a3]=E(!1),[N5,o4]=E(!1),[_Z,Q3]=E(null),[FZ,s4]=E(!1),[t4,e4]=E(null),[P5,s8]=E(!1),[UZ,n3]=E(null),[AZ,t8]=E(null),[X3,OZ]=E(null),[C2,wZ]=E(null),[_5,F5]=E([]),[i3,U5]=E([]),[A5,LZ]=E(void 0),[RZ,Y3]=E(void 0),[$8,Z8]=E(null),[O5,w5]=E(void 0),[ZQ,e8]=E(null),[X2,BZ]=E(null),f2=F0(null),$6=F0(0),[Z6,J8]=E(null);X1(()=>{L1.current=H0},[H0]),X1(()=>{G3.current=$.getPrimary()?.name||j.activeArion||"ARIA"},[$,j.activeArion]);let[t0,c]=E(null),t=u((H)=>new Promise((_)=>{$6.current+=1,J8({id:$6.current,toolName:H.toolName,input:H.input,riskLevel:H.riskLevel,...H.issues?{issues:H.issues}:{},resolve:_})}),[]),K3=u((H)=>{$.addToHistory(H)},[$]),Q8=u((H)=>{let _=DG(H);if(K&&G0.current)K.addConversationMessage(G0.current,_);if(N1.jsonlLogger?.log({type:"user_message",content:H,id:_.id}),z1.current)z1.current=!1;else R((N)=>[...N,_]);K3({role:"user",content:H})},[K3,K]),X8=u((H)=>{let _=H&&typeof H==="object"&&"diagnostic"in H?H.diagnostic:void 0;N1.jsonlLogger?.log({type:"error",error:{message:nJ(sJ(H),_)??sJ(H),..._===void 0?{}:{diagnostic:_}}})},[]),o3=u((H,_)=>{let N=dF(H).trim();if(!N)return;K3({role:"assistant",content:N,..._?{arion:_}:{}})},[K3]),[s3,S2]=E({turnCount:0,totalTokens:0,estimatedCost:0,wallTimeSeconds:0,contextTokens:0,contextStale:!1}),[L5,t3]=E(0),[J6,R5]=E(null);X1(()=>{let H=!1;return(async()=>{try{let _=process.env.ARIA_HOME??`${process.env.HOME}/.aria`,{resolveRuntimeRootDirectory:N,findRuntimeOwnerRecordByAriaHome:P}=await import("@aria-cli/server"),w=N(),b=P(w,_)?.runtimeSocket??null;if(!H)R5(b)}catch{}})(),()=>{H=!0}},[]);let[Y2]=E(()=>{let H=nG(),_=l0(),N=_.theme;if(!N&&H.display.theme){N=H.display.theme;try{X$({..._,theme:N})}catch(P){N0.warn("[Theme] YAML→JSON migration failed (non-fatal):",P.message)}}if(N)if(h3().includes(N))D3(N);else N0.warn(`[Theme] Invalid theme "${N}" in config, using default`);return H}),B5=F0(Y2.persistence.otelEndpoint?new gF(Y2.persistence.otelEndpoint):new vF),[IZ,Q6]=E(Y2.display.mode),[e3,$4]=E(()=>{let{mode:H,syntaxHighlighting:_,maxToolOutputLines:N,maxThinkingPreview:P,...w}=Y2.display;return w}),[I5,b2]=E(void 0),[M5,Y$]=E([]),[C5,y2]=E(0),[f5,X6]=E(),G3=F0($.getPrimary()?.name||j.activeArion||"ARIA"),[S5,MZ]=E(null),Y6=F0(0),K6=F0(0),q1=F0(null),H1=F0(null);X1(()=>{let H=l0().soundEnabled;return cJ(H!==!1),HG(),()=>{WG()}},[]),X1(()=>{return VG({thresholdMs:$Q,onStall:jF,onSleep:cF})},[]);let K2=F0([]),G0=F0(null),B1=F0(null),Z4=F0(null);if(!Z4.current){let H=process.env.ARIA_HOME??`${process.env.HOME}/.aria`,_=new EF(H,J,()=>G0.current);Z4.current=_.toFactory()}X1(()=>{return()=>{let H=G0.current;(async()=>{if(H&&K)try{K.markCompleted(H)}catch(N){N0.warn("[InkREPL] SessionHistory completion mark failed:",N)}if(H&&B1.current)try{await B1.current.endSession(H)}catch(N){N0.warn("[InkREPL] Memoria session end failed (non-critical):",N)}await Z4.current?.closeAll()})().catch((N)=>{N0.warn("[InkREPL] MemoriaPool cleanup failed:",N?.message)})}},[]);let J4=F0(null),$$=F0(null),Y8=F0(null),k2=u(async(H)=>{let _=Date.now()+20000;while(Date.now()<_){if(H?.aborted)return null;let P=(J4.current??await(Y8.current??Promise.resolve(null)))?.control??$$.current??null;if(P)return P;await new Promise((w)=>setTimeout(w,250))}return $$.current??null},[]),b5=u(async()=>{if($$.current)return $$.current;let H=await k2();if(H)return H;return null},[k2]),JQ=u(()=>{return $$.current},[]),CZ=u((H)=>{J4.current=H,$$.current=H.control,Y8.current=Promise.resolve(H),N0.debug(`[InkREPL] Attached TUI local client to runtime ${H.runtimeId} on port ${H.port} (${H.ownership}, node ${H.nodeId})`);try{let _=`${process.env.ARIA_HOME??`${process.env.HOME}/.aria`}/run`,N=`${_}/agent-bridge.json`,P=`${N}.${process.pid}.tmp`,w=i6("fs"),b=J6??(()=>{try{let T=(()=>{throw new Error("Cannot require module "+"@anthropic-ai/claude-code");})(),V=process.cwd(),d=`${process.env.ARIA_HOME??`${process.env.HOME}/.aria`}`;return T.findRuntimeOwnerRecordByAriaHome?.(V,d)?.runtimeSocket??null}catch{return null}})();w.mkdirSync(_,{recursive:!0}),w.writeFileSync(P,JSON.stringify({socketPath:b,clientId:H.attachedClientId??null,nodeId:H.nodeId,pid:process.pid,updatedAt:new Date().toISOString()},null,2)),w.renameSync(P,N),N0.debug(`[InkREPL] Wrote agent-bridge.json (clientId=${H.attachedClientId}, socket=${b})`)}catch(_){N0.debug(`[InkREPL] Failed to write agent-bridge.json: ${_ instanceof Error?_.message:String(_)}`)}},[J6]);X1(()=>{return CZ(X),()=>{Y8.current=Promise.resolve(null),J4.current?.release(),J4.current=null,$$.current=null}},[X,CZ]);let _1=o6(()=>{if(!K||!Y)return null;let H=new Proxy({},{get(N,P){return async(...w)=>{let b=$.getPrimary(),V=(b&&typeof $.getArionMemoria==="function"?await $.getArionMemoria(b):null)??Q.components.memoria,$0=V[P];if(typeof $0!=="function")throw Error(`Memoria method ${String(P)} is unavailable`);return $0.apply(V,w)}}}),_=SG(()=>$$.current);return new iG({cli:Y,localControl:_,sessionLedger:K,...CG({cli:Y,activeArionName:$.getPrimary()?.name??Y.config.activeArion??"ARIA",overrides:{memoria:H,arionManager:{list:()=>Z.list(),hatch:(N)=>Z.hatch(N),get:async(N)=>{return(await Z.list()).find((w)=>w.name.toLowerCase()===N.toLowerCase())??null},wake:(N)=>Z.wake(N),rest:(N)=>$.dismiss(N)},config:{async getTheme(){return A()},async setTheme(N){if(!h3().includes(N))throw Error(`Unknown theme: ${N}`);D3(N);let w=l0();return w.theme=N,X$(w),{theme:N}},async getAutonomy(){return J3.current},async setAutonomy(N){if(!G5.includes(N))throw Error(`Invalid autonomy level: ${N}`);return l3(N),{autonomy:N}},async getActiveArion(){return G3.current??$.getPrimary()?.name??Y.config.activeArion},async setActiveArion(N){G3.current=N;let P=l0();P.activeArion=N,X$(P)}},modelDiscovery:{async listAvailable(){return g$},async refresh(N){if(!L)return g$;let P=await L(N);return c4(P),P},async getCurrentModel(){return H0},async setCurrentModel(N){let P=xF(N,g$,B);if(!P)throw Error(`Unknown model: ${N}`);o1(P.shortName),L1.current=P.shortName;let w=$.getPrimary();if(w)await Z.setPreferredModel(w.name,P.shortName);let b=l0();return b.preferredTier=P.tier,X$(b),{currentModel:P.shortName,tier:P.tier}}}}}),system:{async restart(N){return{accepted:!0,reason:typeof N.reason==="string"&&N.reason.trim().length>0?N.reason.trim():"Restart requested"}},async terminalSetup(){if(!nZ())return{supported:!1,message:"terminal-setup is supported only in iTerm2 (macOS) and VSCode terminal."};return{supported:!0,output:cG().trim()}}}})},[Q,g$,Y,Z,H0,L,$,K,l3]),m=u(async(H,_)=>{if(!_1)throw Error(`Headless kernel unavailable for ${H}`);let N=null,P=null;for await(let w of _1.dispatch({kind:"request",requestId:`${H}:${p8()}`,op:H,input:_}))if(w.kind==="interaction.required")N=w;else if(w.kind==="result")P=w;return{interactionFrame:N,resultFrame:P}},[_1]);X1(()=>{let H=!1,_=async()=>{try{let P=await m("client.inbox.list",{limit:100,unreadOnly:!0}).catch(()=>null),w=P?null:await m("message.inbox.list",{limit:100,unreadOnly:!0}),b=P??w,V=(b?.resultFrame?.ok&&Array.isArray(b.resultFrame.result.events)?b.resultFrame.result.events:[]).length;if(!H)t3(V)}catch(P){if(tJ(P)){H=!0,clearInterval(N);return}if(!H)t3(0)}};_();let N=setInterval(()=>{if(!H)_()},3000);return()=>{H=!0,clearInterval(N)}},[m]),X1(()=>{let H=!1,_=X?.control;if(!_?.subscribeDirectClientInbox)return;let N=X?.nodeId,P=X?.attachedClientId,w=new Map,b=30000;return(async()=>{while(!H){try{let V=_.subscribeDirectClientInbox({afterCreatedAt:Date.now()});for await(let d of V){if(H)break;if(d.senderNodeId===N)continue;if(d.senderClientId&&P&&d.senderClientId===P)continue;if(d.recipientClientId&&P&&d.recipientClientId!==P)continue;let $0=`${d.senderNodeId}\x00${d.content}`,B0=Date.now(),Y1=w.get($0);if(Y1&&B0-Y1.ts<b){Y1.count++,Y1.ts=B0;continue}if(w.set($0,{ts:B0,count:1}),w.size>200){for(let[Q4,W3]of w)if(B0-W3.ts>=b)w.delete(Q4)}let G2=d.senderDisplayNameSnapshot?.trim()||d.senderNodeId||"Unknown",q0=d.senderClientId?.match(/^client-pid-(\d+)$/)?.[1],g2=q0?`${G2} (pid ${q0})`:G2,U0=typeof d.content==="string"?d.content:JSON.stringify(d.content),A0=g2!=="Unknown"?g2:d.senderNodeId||"unknown",[v0,z2]=hG(g2,A0,U0,d.id);if(K&&G0.current)K.addConversationMessage(G0.current,v0),K.addConversationMessage(G0.current,z2);if(R((Q4)=>[...Q4,v0,z2]),!L0.current)z1.current=!0,YQ.current(`[Incoming message from "${g2}" (${A0})]
|
|
123
|
-
|
|
124
|
-
${U0}
|
|
125
|
-
|
|
126
|
-
[Reply using send_message with to="${A0}"]`)}}catch{}if(!H)await new Promise((V)=>setTimeout(V,2000))}})(),()=>{H=!0}},[X]),X1(()=>{return()=>{if(q1.current)clearInterval(q1.current)}},[]),X1(()=>{N1.sessionHistory=K??null,N1.memoriaFactory=Z4.current},[K]);let K8=F0(void 0),fZ=F0(null),v=F0(void 0);X1(()=>{let H=!1;return(async()=>{try{let _=await Q.recallUserName();if(H)return;p0(_);let N=$.getPrimary(),P;if(N){if(P=await $.getArionMemoria(N)??Q.components.memoria,N.preferredModel)o1(N.preferredModel)}else P=Q.components.memoria;let w=await P.count();if(H)return;c0(w)}catch{}})(),()=>{H=!0}},[Q,$]),X1(()=>{let H=!1;return(async()=>{try{let{resultFrame:_}=await m("arion.list",{});if(!_)throw Error("arion.list produced no result frame");if(!_.ok)throw Error(_.error.message);let N=_.result.arions??[];if(H)return;X0(N.map((P)=>({name:P.name,emoji:P.emoji,color:P.color,description:P.personality?.traits?.slice(0,2).join(", ")||"",isActive:$.isActive(P.name),isResting:P.status==="resting"})))}catch(_){if(H)return;R((N)=>[...N,o(`Failed to load arions: ${_.message}`)])}})(),()=>{H=!0}},[m,$]),X1(()=>{let H=!0,_=null,N=async(w,b)=>{if(!_1)return null;let T=null;for await(let V of _1.dispatch({kind:"request",requestId:`${w}:${p8()}`,op:w,input:b}))if(V.kind==="result")T=V;return T};return(async()=>{let w=async()=>{try{let[b,T,V]=await Promise.all([N("peer.list",{}),N("peer.list_nearby",{}),N("client.list",{})]);if(!H||!b?.ok||!T?.ok||!V?.ok)return;let d=b.result.peers??[],$0=T.result.peers??[],B0=V.result.clients??[],Y1=$0.map((q0)=>({displayNameSnapshot:q0.displayNameSnapshot,nodeId:q0.nodeId,host:q0.host,port:q0.port,principalFingerprint:q0.principalFingerprint,version:q0.version,tlsCaFingerprint:q0.tlsCaFingerprint,transport:q0.transport,status:q0.status})),G2=d.filter((q0)=>q0.transportState==="connected").map((q0)=>({displayNameSnapshot:q0.displayNameSnapshot??q0.nodeId,nodeId:q0.nodeId,version:"runtime",transport:"wan",status:"connected"}));F5(QG(Y1,G2)),U5(B0.map((q0)=>({clientId:q0.clientId,clientKind:q0.clientKind,displayLabel:q0.displayLabel,self:q0.self})))}catch(b){if(tJ(b)){if(H=!1,_)clearInterval(_);_=null;return}}};if(await w(),_=setInterval(w,30000),!H&&_)clearInterval(_),_=null})(),()=>{if(H=!1,_)clearInterval(_)}},[_1]),X1(()=>{let H=!0;if(!L)return;return L(!0).then((_)=>{if(H)c4(_)}).catch((_)=>{N0.debug("[InkREPL] Background model refresh failed:",_.message)}),()=>{H=!1}},[L]);let z0=o6(()=>new Set(DF.map((H)=>`${H.provider}:${H.id}`)),[]),k0=o6(()=>iJ(g$),[g$]),z3=k0.map((H)=>({name:H.shortName,value:pF(H),description:H.description||"",provider:H.provider,isCurrent:H.shortName===H0,knownModel:z0.has(`${H.provider}:${H.id}`)})),F1=u(async()=>{try{let{resultFrame:H}=await m("arion.list",{});if(!H)throw Error("arion.list produced no result frame");if(!H.ok)throw Error(H.error.message);let _=H.result.arions??[];X0(_.map((N)=>({name:N.name,emoji:N.emoji,color:N.color,description:N.personality?.traits?.slice(0,2).join(", ")||"",isActive:$.isActive(N.name),isResting:N.status==="resting"})))}catch(H){N0.warn("Failed to refresh arions list:",H.message)}},[m,$]),Z$=u(async()=>{let H=$.getPrimary();if(H){let _=await $.getArionMemoria(H);if(_)return _}return Q.components.memoria},[$,Q]),SZ=u(async()=>{l8(!0);try{let H=await Z$(),_=await H.list({limit:100});z5(_.map((P)=>({id:P.id,content:P.content,network:P.network,createdAt:P.createdAt??new Date,importance:P.importance})));let N=await H.count();c0(N)}catch(H){z5([]),R((_)=>[..._,o(`Failed to load memories: ${H.message}`)])}finally{l8(!1)}},[Z$]),oG=u(()=>{if(!K)return;try{let _=Z3.current*100,N=K.listSessions(100,_);j4(N)}catch(H){N0.warn("Failed to load sessions:",H)}},[K]),sG=u((H)=>{if(!K)return;try{let _=H.trim();if(x3.current=_,Z3.current=0,M2.current)clearTimeout(M2.current),M2.current=null;if(!_){j4(K.listSessions(100,0));return}let N=++r8.current;M2.current=setTimeout(()=>{try{let P=K.searchSessionsFts(_,100,0);if(N!==r8.current)return;if(x3.current!==_)return;j4(P)}catch(P){N0.warn("Failed to execute scheduled session search:",P)}},120)}catch(_){N0.warn("Failed to search sessions:",_)}},[K]);X1(()=>{return()=>{if(M2.current)clearTimeout(M2.current),M2.current=null}},[]);let tG=u((H)=>{if(!K)return;try{let _=H==="next"?Z3.current+1:Math.max(0,Z3.current-1),N=_*100,P=x3.current,w=P?K.searchSessionsFts(P,100,N):K.listSessions(100,N);if(H==="next"&&w.length===0)return;Z3.current=_,j4(w)}catch(_){N0.warn("Failed to paginate sessions:",_)}},[K]);X1(()=>{let H=new AbortController;return(async()=>{if(!K)return;try{let N=await Z$();if(H.signal.aborted)return;let P=await kF({sessionHistory:K,memoria:N,router:J,signal:H.signal});if(!H.signal.aborted&&P.recovered>0)N0.debug(`[InkREPL] Recovered learning from ${P.recovered} incomplete session${P.recovered===1?"":"s"}.`)}catch(N){N0.warn("[InkREPL] Crash recovery failed:",N)}})(),()=>{H.abort()}},[K,Z$,J]);let y5=u(async(H)=>{try{let _=await Z$();if("session"in _&&typeof _.session==="function")_.session(H);if("endSession"in _&&typeof _.endSession==="function")B1.current=_,N1.memoriaSession=B1.current}catch(_){N0.warn("[InkREPL] Memoria session start failed (non-critical):",_)}},[Z$]),k5=u(async(H)=>{if(!H||!B1.current)return;try{await B1.current.endSession(H)}catch(_){N0.warn("[InkREPL] Memoria session end failed (non-critical):",_)}},[]),bZ=u((H)=>{K2.current=s6(EG(H).filter((_)=>_.role!=="system"))},[]),G8=u((H)=>{if(!K)return;let _=K.loadSessionMessages(H);if(!_)return;bZ(_.messages)},[K,bZ]),z8=u(()=>{y2((H)=>H+1)},[]),{columns:eG,rows:$z}=K1(),QQ=F0(!0);X1(()=>{if(QQ.current){QQ.current=!1;return}let H=setTimeout(()=>{process.stdout.write("\x1B[2J\x1B[H"),z8()},100);return()=>clearTimeout(H)},[eG,$z,z8]);let yZ=u((H,_)=>{try{lJ({sessionId:H,arionName:_,pid:process.ppid||process.pid,timestamp:new Date().toISOString()})}catch(N){N0.debug(`[InkREPL] Failed to publish relaunch marker: ${N instanceof Error?N.message:String(N)}`)}},[]),q3=u(async(H)=>{if(!K)return;if(L0.current)return;try{d3("ink-repl:resume:session.load");let{resultFrame:_}=await m("session.load",{sessionId:H});if(p3(),!_)throw Error("session.load produced no result frame");if(!_.ok){R((V)=>[...V,o(_.error.message||`Session not found: ${H}`)]);return}let N=_.result,P=N.session;if(!P){R((V)=>[...V,o(`Session not found: ${H}`)]);return}let w=P.messages,b=K.getSessionRuntimeState(H);if(!b||b.stateStatus!=="completed"){d3("ink-repl:resume:jsonlCrashRecovery");let V=process.env.ARIA_HOME??`${process.env.HOME}/.aria`,d=P.arion||$.getPrimary()?.name||"ARIA",$0=aG(V,d,H),{messages:B0,backfillMessages:Y1}=rG(P.messages,$0);if(w=B0,Y1.length>0){for(let G2 of Y1)K.addConversationMessage(H,G2);N0.debug(`[InkREPL] JSONL→SQLite backfill: ${Y1.length} messages recovered`)}p3()}$.clearHistory(),G0.current=H,n6(H),uJ(P.arion||$.getPrimary()?.name||"ARIA"),yZ(H,P.arion||$.getPrimary()?.name||"ARIA"),N1.sessionId=H,await new Promise((V)=>setTimeout(V,0)),d3("ink-repl:resume:setSessionMessages"),bZ(w),p3(),z8(),R([x(`Resumed session (${w.length} messages from ${P.arion})`),...w]),Y$([]),b2(void 0),d3("ink-repl:resume:appendSessionHistory");for(let V of w){if(V.role==="tool")continue;let d=V.content.filter(($0)=>$0.type==="text").map(($0)=>$0.text).join("");if(V.role==="assistant"&&!d)continue;K3({role:V.role,content:d,arion:V.arion?.name})}if(p3(),N.pendingInteraction)await fZ.current?.({pendingInteraction:{interactionId:N.pendingInteraction.interactionId,source:N.pendingInteraction.source,interaction:N.pendingInteraction.prompt},startedAt:Date.now(),abortSignal:new AbortController().signal})}catch(_){p3(),R((N)=>[...N,o(`Error resuming session: ${sJ(_)}`)])}},[K,$,k5,y5,m,yZ,K3,bZ,z8]),XQ=u(async(H)=>{let _=Array.isArray(H.result.messages)?s6(structuredClone(H.result.messages.filter((b)=>b.role!=="system"))):K2.current,N=K2.current.length,P=_.slice(N);if(P.length>0){let b=jG(P,{arion:H.respondingArionName?{name:H.respondingArionName,emoji:"\uD83E\uDD8B"}:void 0}),T=G0.current;if(K&&T)K.addConversationMessages(T,b);R((V)=>[...V,...b])}K2.current=_;let w=H.result.usage;if(S2((b)=>({...b,...typeof H.result.turnCount==="number"?{turnCount:H.result.turnCount}:{},...typeof w?.totalTokens==="number"?{totalTokens:w.totalTokens}:{},...typeof w?.estimatedCost==="number"?{estimatedCost:w.estimatedCost}:{}})),H.result.state)return H.result.state;if(!H.result.success)throw Object.assign(Error(nJ(H.result.error??"Run resume failed",H.result.diagnostic)??H.result.error??"Run resume failed"),{...H.result.diagnostic===void 0?{}:{diagnostic:H.result.diagnostic}});o3(_,H.respondingArionName),R0((Date.now()-H.startedAt)/1000);try{let T=await(await Z$()).count();c0(T)}catch(b){N0.warn("Memory finalization failed:",b)}return await F1(),null},[o3,Z$,F1,K]),kZ=u(async(H)=>{if(!_1)throw Error("Headless run kernel unavailable for REPL resume");if(!await k2(H.abortSignal))throw Error("Local runtime control unavailable for REPL resume");let N=null,P=null;for await(let w of _1.dispatch({kind:"interaction.respond",requestId:`${G0.current??"session"}:interaction:${p8()}`,interactionId:H.interactionId,response:H.response},{signal:H.abortSignal})){if(H.abortSignal?.aborted)break;if(w.kind==="interaction.required")N={interactionId:w.interactionId,source:w.source,interaction:w.interaction};else if(w.kind==="result")P=w}if(H.abortSignal?.aborted)return N;if(!P)throw Error("Headless run interaction produced no result frame");if(P.ok)return await XQ({result:P.result,respondingArionName:H.respondingArionName,startedAt:H.startedAt}),null;if(P.error.code==="INTERACTION_REQUIRED")return N;throw Object.assign(Error(P.error.message),{...P.error.details===void 0?{}:{diagnostic:P.error.details}})},[_1,XQ,k2]),vZ=u(async(H)=>{let _=H.pendingInteraction;while(_?.interaction.kind==="tool_approval"&&!H.abortSignal.aborted){let N=await t({toolName:_.interaction.toolName,input:_.interaction.toolInput,riskLevel:mF(_.interaction.riskLevel),..._.interaction.issues?.length?{issues:_.interaction.issues}:{}});_=await kZ({interactionId:_.interactionId,response:{kind:"confirm",approved:N},respondingArionName:H.respondingArionName,startedAt:H.startedAt,abortSignal:H.abortSignal})}if(H.abortSignal.aborted)return;if(_?.interaction.kind==="questionnaire"){let N=_.interaction.questions;c({interactionId:_.interactionId,questions:N,answers:[],...H.respondingArionName?{respondingArionName:H.respondingArionName}:{},startedAt:H.startedAt}),R((P)=>[...P,x(gG(N[0],0,N.length))]),Y$([]),await F1();return}if(_){let N=_.interaction.kind==="tool_approval"?`Run paused: approval required for ${_.interaction.toolName}${vG(_.interaction.toolInput)?` (${vG(_.interaction.toolInput)})`:""}.`:"Run paused and requires interaction to continue.";R((P)=>[...P,x(N)]),Y$([]),await F1()}},[F1,t,kZ]);fZ.current=vZ;let v2=u((H)=>{if(L0.current){i.current=i.current?i.current+`
|
|
127
|
-
|
|
128
|
-
`+H:H,C0(i.current);return}(async()=>{if(t0){Q8(H);let U0=[...t0.answers,H];if(U0.length<t0.questions.length){c({...t0,answers:U0}),R((v0)=>[...v0,x(gG(t0.questions[U0.length],U0.length,t0.questions.length))]);return}H1.current=new AbortController;let A0=H1.current.signal;L0.current=!0,I({type:"START_TURN"}),c(null);try{let v0=await kZ({interactionId:t0.interactionId,response:{kind:"questionnaire",answers:U0},respondingArionName:t0.respondingArionName,startedAt:t0.startedAt,abortSignal:A0});await vZ({pendingInteraction:v0,respondingArionName:t0.respondingArionName,startedAt:t0.startedAt,abortSignal:A0})}catch(v0){X8(v0),R((z2)=>[...z2,o(`Error: ${v0.message}`)])}finally{H1.current=null,L0.current=!1,I({type:"DISCARD_STREAMING"}),Y$([])}return}let _=wG(H);if(_&&K8.current){await K8.current(_.command,_.args);return}NG(),H1.current=new AbortController;let N=H1.current.signal;L0.current=!0,I({type:"START_TURN"});let P=yF(H);if(K&&!G0.current)try{let A0=$.getPrimary()?.name||"ARIA";G0.current=K.createSession(A0,H0),n6(G0.current),uJ(A0),yZ(G0.current,A0),N1.sessionId=G0.current;try{let v0=process.send;if(typeof v0==="function")v0({type:"aria-relaunch",resumeSessionId:G0.current,arionName:A0})}catch{}await y5(G0.current)}catch(U0){N0.warn("[InkREPL] SQLite session creation failed (non-fatal):",U0)}if(!N1.jsonlLogger&&Y2.persistence.jsonlEnabled){let U0=$.getPrimary()?.name||"ARIA",v0=`${process.env.ARIA_HOME??`${process.env.HOME}/.aria`}/arions/${U0}/logs`;N1.jsonlLogger=new TF({logDir:v0,sessionId:G0.current||p8(),retentionDays:Y2.persistence.jsonlRetentionDays,maxSizeMb:Y2.persistence.jsonlMaxSizeMb}),N1.jsonlLogger.rotate().catch((z2)=>{N0.warn("[InkREPL] JSONL log rotation failed:",z2)})}for(let U0 of P.mentions)if(!$.isActive(U0))try{await $.activate(U0)}catch(A0){let v0=A0.message?.toLowerCase()||"";if(!v0.includes("not found")&&!v0.includes("unknown"))N0.warn(`Failed to activate @${U0}:`,A0.message)}let w=[];for(let U0 of P.mentions){let A0=$.getActiveArions().find((v0)=>v0.name.toLowerCase()===U0.toLowerCase());if(A0)w.push(A0)}if(w.length===0){let U0=$.getPrimary();if(U0)w.push(U0)}Q8(H),Y$([]),b2(void 0);let b=Date.now();if(t3(0),Y6.current=b,S2({turnCount:0,totalTokens:0,estimatedCost:0,wallTimeSeconds:0,contextTokens:0,contextStale:!1}),q1.current)clearInterval(q1.current);K6.current=0,q1.current=null;let T=new uG,V=100,d=!1,$0=setInterval(()=>{let U0=Math.floor((Date.now()-Y6.current)/1000);if(U0!==K6.current)K6.current=U0,q0={...q0??{},wallTimeSeconds:U0};if(q0)S2((A0)=>({...A0,...q0})),q0=null;if(d&&T.hasPendingContent())I({type:"UPDATE_STREAM",snapshot:[...T.snapshot()]}),d=!1},V),B0,Y1=[],G2=V$(),q0=null;try{if(B0=(await $.getRespondingArions(H,w,[]))[0]?.arion||$.getPrimary(),X6(B0?.name),G3.current=B0?.name,B0)T.setArion({name:B0.name,emoji:B0.emoji??"\uD83E\uDD8B",color:B0.color??void 0});T.setVerb(G2.present);let A0=l0();if(!_1)throw Error("Headless run kernel unavailable for REPL submit");let v0=await k2(N);if(N.aborted)return;if(!v0)throw Error("Local runtime control unavailable for REPL submit");Y1=s6([...K2.current]);let z2=G0.current,Q4=null,W3=null,Lz=fF(J3.current).length>0?"pause":"approve",Rz={task:H,arion:G3.current||B0?.name||A0.activeArion||"ARIA",cwd:process.cwd(),...Y1.length>0?{history:Y1}:{},...L1.current?{requestedModel:L1.current}:{},...A0.preferredTier?{preferredTier:A0.preferredTier}:{},autonomy:J3.current,approvalMode:Lz};for await(let W0 of _1.dispatch({kind:"request",requestId:z2??p8(),op:"run.start",input:Rz},{signal:N})){if(N.aborted)break;if(W0.kind==="interaction.required"){Q4={interactionId:W0.interactionId,source:W0.source,interaction:W0.interaction};continue}if(W0.kind==="result"){W3=W0;continue}let r=W0.event;if(N1.jsonlLogger?.log(r),_G(r),r.type==="handoff_start"||r.type==="handoff_result"){if(r.type==="handoff_result"){let y0=$.getActiveArions().find((I1)=>I1.name.toLowerCase()===r.target.toLowerCase());if(y0)B0=y0,T.setArion({name:y0.name,emoji:y0.emoji??"\uD83E\uDD8B",color:y0.color??void 0})}}if(r.type==="span_start"){let y0="parentSpanId"in r&&typeof r.parentSpanId==="string"?r.parentSpanId:void 0;Y$((I1)=>[...I1,{spanId:r.spanId,spanType:r.spanType,name:r.name,startTime:Date.now(),...y0?{parentSpanId:y0}:{}}])}if(r.type==="span_end")Y$((y0)=>y0.map((I1)=>I1.spanId===r.spanId?{...I1,endTime:Date.now(),durationMs:r.durationMs}:I1));if(r.type==="pipeline_timing")b2(r.report);if(r.type==="error")throw Error(nJ(r.error.message,"diagnostic"in r.error?r.error.diagnostic:void 0)??r.error.message);if(r.type==="usage_update"){let y0=r.usage;if(typeof y0.inputTokens==="number"&&typeof y0.outputTokens==="number")T.setTokenUsage({input:y0.inputTokens,output:y0.outputTokens});if(q0={...q0??{},...typeof y0.totalTokens==="number"?{totalTokens:y0.totalTokens}:{},...typeof y0.estimatedCost==="number"?{estimatedCost:y0.estimatedCost}:{},...typeof y0.inputTokens==="number"?{contextTokens:y0.inputTokens}:{},contextStale:!1},"model"in r&&typeof r.model==="string"){let I1=hF(r.model);if(I1!==H0)o1(I1),L1.current=I1}}if(r.type==="turn_complete")q0={...q0??{},turnCount:r.turnNumber};if(r.type==="tool_result")q0={...q0??{},contextStale:!0};if(T.ingest(r)==="flush"){let y0=T.flush(),I1=G0.current;if(K&&I1)for(let VZ of y0)K.addConversationMessage(I1,VZ);I({type:"COMMIT_TURN",flushed:y0}),d=!1}else d=!0}if(MZ(null),PG(),clearInterval($0),d&&T.hasPendingContent())I({type:"UPDATE_STREAM",snapshot:[...T.snapshot()]}),d=!1;if(q1.current)clearInterval(q1.current),q1.current=null;if(S2((W0)=>({...W0,wallTimeSeconds:(Date.now()-Y6.current)/1000})),T.hasPendingContent()){let W0=T.flush(),r=G0.current;if(K&&r)for(let E1 of W0)K.addConversationMessage(r,E1);I({type:"COMMIT_AND_END",flushed:W0})}else I({type:"COMMIT_AND_END",flushed:[]});Y$([]),R0((Date.now()-b)/1000),await new Promise((W0)=>setTimeout(W0,0));let TZ=T.getSnapshotMessages()?.filter((W0)=>W0.role!=="system"),T5=!!(TZ&&TZ.length>0);if(T5){let W0=performance.now();d3("ink-repl:structuredClone");let r=structuredClone(TZ),E1=performance.now();d3("ink-repl:repairToolCallPairing"),K2.current=s6(r);let y0=performance.now();p3();let I1=E1-W0,VZ=y0-E1;if(process.env.DEBUG&&I1+VZ>100)try{process.stderr.write(`[InkREPL][DIAG] post-processing: structuredClone=${I1.toFixed(0)}ms repairToolCallPairing=${VZ.toFixed(0)}ms (${TZ.length} msgs)
|
|
129
|
-
`)}catch{}}else if(K&&G0.current)d3("ink-repl:refreshSessionMessagesFromStorage"),G8(G0.current),p3();if(N.aborted){if(T.hasPendingContent()){let W0=T.flush(),r=G0.current;if(K&&r)for(let E1 of W0)K.addConversationMessage(r,E1);I({type:"COMMIT_AND_END",flushed:W0})}else I({type:"DISCARD_STREAMING"});if(K&&G0.current)G8(G0.current);if(Y$([]),L0.current=!1,H1.current=null,q1.current)clearInterval(q1.current),q1.current=null}if(!N.aborted){if(L0.current=!1,!W3)throw Error("Headless run produced no result frame");if(Q4){if(T.hasPendingContent()){let W0=T.flush(),r=G0.current;if(K&&r)for(let E1 of W0)K.addConversationMessage(r,E1);if(R((E1)=>[...E1,...W0]),!T5&&r)G8(r)}await vZ({pendingInteraction:Q4,...B0?.name?{respondingArionName:B0.name}:{},startedAt:b,abortSignal:N})}else{if(!W3.ok)throw Object.assign(Error(W3.error.message),{...W3.error.details===void 0?{}:{diagnostic:W3.error.details}});if(T.hasPendingContent()){let W0=T.flush(),r=G0.current;if(K&&r)for(let E1 of W0)K.addConversationMessage(r,E1);if(R((E1)=>[...E1,...W0]),!T5&&r)G8(r)}o3(K2.current,B0?.name),Z$().then((W0)=>W0.count()).then((W0)=>c0(W0)).catch((W0)=>N0.warn("Memory finalization failed:",W0)),F1().catch((W0)=>N0.warn("Arion list refresh failed:",W0))}}}catch(U0){X8(U0),clearInterval($0);try{if(T.hasPendingContent()){let A0=T.flush(),v0=G0.current;if(K&&v0){for(let z2 of A0)K.addConversationMessage(v0,z2);G8(v0)}I({type:"COMMIT_AND_END",flushed:A0})}else I({type:"DISCARD_STREAMING"})}catch(A0){N0.warn("[InkREPL] Failed to persist messages on error path:",A0?.message)}if(MZ(null),q1.current)clearInterval(q1.current),q1.current=null;L0.current=!1,Y$([]),R((A0)=>[...A0,o(`Error: ${U0.message}`)])}let g2=i.current;if(g2)i.current=null,C0(null),setTimeout(()=>v2(g2),0)})().catch((_)=>{X8(_),L0.current=!1,I({type:"DISCARD_STREAMING"}),R((P)=>[...P,o(`Error: ${_.message}`)]);let N=i.current;if(N)i.current=null,C0(null),setTimeout(()=>v2(N),0)})},[J,$,Z,b0,F1,Q,Z$,o3,y5,vZ,_1,yZ,X8,H0,kZ,K,G8,S,k2]),YQ=F0(v2);YQ.current=v2,X1(()=>{let H=U||K5();if(!H){v$.current=Promise.resolve();return}if(H&&!e1.current)e1.current=!0,v$.current=q3(H)},[U,q3]),X1(()=>{if(!W||t1.current)return;let H=!1;return(async()=>{if(U||K5())await v$.current;if(H||t1.current)return;t1.current=!0,await v2(W)})(),()=>{H=!0}},[W,v2,U]);let Zz=u(()=>{if(H1.current){if(H1.current.abort(),H1.current=null,L0.current=!1,I({type:"DISCARD_STREAMING"}),q1.current)clearInterval(q1.current),q1.current=null}},[]),Jz=u(()=>{let H=i.current;if(!H)return;i.current=null,C0(null),g5(H)},[]),Qz=u(()=>{Q6((H)=>{let _=pG(H);return $4((N)=>{let P=xG(H,N);return lG(_,P)}),_})},[]),Xz=u(()=>{$4((H)=>({...H,showThinking:!H.showThinking}))},[]),Yz=u(()=>{$4((H)=>({...H,showCosts:!H.showCosts}))},[]),Kz=u(()=>{$4((H)=>({...H,showTraces:!H.showTraces}))},[]),KQ=u(async(H,_)=>{switch(H){case"help":{let N=mJ.map((P)=>`/${P.name} - ${P.description}`).join(`
|
|
130
|
-
`);R((P)=>[...P,x(N)]);break}case"arions":{try{let{resultFrame:N}=await m("arion.list",{});if(!N)throw Error("arion.list produced no result frame");if(!N.ok)throw Error(N.error.message);let w=(N.result.arions??[]).map((b)=>`${b.emoji} ${b.name} (${b.status})`).join(`
|
|
131
|
-
`);R((b)=>[...b,x(w||"No arions found")])}catch(N){R((P)=>[...P,o(`Failed to list arions: ${N.message}`)])}break}case"sound":{let N=_?.trim().toLowerCase();if(N==="on"||N==="off"){let P=N==="on";cJ(P);let w=l0();w.soundEnabled=P,X$(w),R((b)=>[...b,x(`Sound notifications ${P?"enabled":"disabled"}.`)])}else{let P=qG()?"on":"off";R((w)=>[...w,x(`Sound notifications: ${P}
|
|
132
|
-
Usage: /sound on | /sound off`)])}break}case"exit":{k();break}case"hatch":{let N=_?.trim();if(!N){R((P)=>[...P,x(`Usage: /hatch <name> [description]
|
|
133
|
-
Example: /hatch Luna a dreamy, creative assistant
|
|
134
|
-
|
|
135
|
-
Describe the arion you want to create and ARIA will help design and hatch them.`)]);break}try{let P=N.split(/\s+/),w=P[0],b=P.slice(1).join(" "),{resultFrame:T}=await m("arion.hatch",{name:w,...b?{description:b}:{}});if(!T)throw Error("arion.hatch produced no result frame");if(!T.ok)throw Error(T.error.message);let V=T.result.prompt;if(!V)throw Error("arion.hatch did not return a prompt");await v2(V)}catch(P){R((w)=>[...w,o(`Error: ${P.message}`)])}break}case"remember":{try{let{resultFrame:N}=await m("memory.remember",{text:_??""});if(!N)throw Error("memory.remember produced no result frame");if(!N.ok)throw Error(N.error.message);let P=N.result;R((b)=>[...b,x(String(P.message??"Memory saved."))]);let w=P.data?.count;if(typeof w==="number")c0(w)}catch(N){R((P)=>[...P,o(`Error remembering: ${N.message}`)])}break}case"recall":{try{let{resultFrame:N}=await m("memory.recall",{query:_??""});if(!N)throw Error("memory.recall produced no result frame");if(!N.ok)throw Error(N.error.message);let P=N.result,w=P.memories,b=String(P.message??"No memories found.");if(Array.isArray(w)&&w.length>0){let T=w.map((V,d)=>{let $0=V,B0=typeof $0.content==="string"?$0.content:String(V),Y1=B0.length>80?B0.slice(0,80)+"...":B0,G2=typeof $0.confidence==="number"?`(${Math.round($0.confidence*100)}%) `:"",q0=$0.createdAt instanceof Date?$0.createdAt.toISOString().slice(0,10):String($0.createdAt??"").slice(0,10),g2=typeof $0.id==="string"?$0.id.slice(0,8):"unknown",U0=typeof $0.network==="string"&&$0.network.trim().length>0?$0.network:"default";return`[${d+1}] ${G2}${Y1} [${U0}] ${q0} (${g2})`}).join(`
|
|
136
|
-
`);b=`Found ${w.length} memories:
|
|
137
|
-
${T}`}R((T)=>[...T,x(b)])}catch(N){R((P)=>[...P,o(`Error recalling: ${N.message}`)])}break}case"recall_knowledge":{if(_?.trim())try{let{resultFrame:N}=await m("memory.recall_knowledge",{topic:_.trim(),limit:5});if(!N)throw Error("memory.recall_knowledge produced no result frame");if(!N.ok)throw Error(N.error.message);let P=N.result,w=Array.isArray(P.tools)?P.tools:[];if(w.length===0)R((b)=>[...b,x(`No tools found for: "${_.trim()}"`)]);else{let b=w.map((T,V)=>{let d=T.description.length>80?T.description.slice(0,80)+"...":T.description;return`[${V+1}] ${T.name} - ${d}`}).join(`
|
|
138
|
-
`);R((T)=>[...T,x(`Found ${w.length} tool items:
|
|
139
|
-
${b}`)])}}catch(N){R((P)=>[...P,o(`Error recalling tools: ${N.message}`)])}else R((N)=>[...N,x(`Usage: /recall_knowledge <topic>
|
|
140
|
-
Searches stored tools (skills, procedures, techniques) by topic.`)]);break}case"send":{try{let N=$.getPrimary()?.name??"ARIA",{resultFrame:P}=await m("message.send",{args:_??"",senderName:N});if(!P)throw Error("message.send produced no result frame");let w=P.ok?P.result:{message:P.error.message};R((b)=>[...b,P.ok?x(w.message??"Message sent."):o(w.message??"Failed to send message.")])}catch(N){R((P)=>[...P,o(`Failed to send peer message: ${N.message}`)])}break}case"clear":{if(L0.current)break;let N=G0.current;if(N)await k5(N);if($.clearHistory(),K2.current=[],G0.current=null,n6(null),N1.sessionId=null,N1.jsonlLogger)N1.jsonlLogger.close().catch((P)=>{N0.warn("[InkREPL] JSONL logger close failed:",P?.message??P)}),N1.jsonlLogger=null;Y$([]),b2(void 0),process.stdout.write("\x1B[2J\x1B[H"),z8(),R([x("Conversation cleared.")]);break}case"resume":{if(_?.trim())await q3(_.trim());else ZZ((N)=>(N??0)+1);break}case"fork":{if(L0.current)break;let N=_?.trim().split(/\s+/).filter(Boolean)??[],P=N.includes("--stay"),w=N.filter((V)=>V!=="--stay"),b=G0.current,T;if(w.length===1&&/^\d+$/.test(w[0]))T=parseInt(w[0],10);else if(w.length>=1&&w[0]){if(b=w[0],w[1]&&/^\d+$/.test(w[1]))T=parseInt(w[1],10)}if(!b){R((V)=>[...V,x("No active session to fork. Start a conversation first or specify a session ID: /fork <session-id>")]);break}try{let{resultFrame:V}=await m("session.fork",{sessionId:b,...T!==void 0?{messageLimit:T}:{}});if(!V)throw Error("session.fork produced no result frame");if(!V.ok)throw Error(V.error.message);let d=V.result;if(P)R(($0)=>[...$0,x(`\uD83C\uDF74 Forked → ${d.newSessionId.slice(0,8)} (${d.messagesCopied} msgs). Resume it later with /resume ${d.newSessionId.slice(0,8)}`)]);else R(($0)=>[...$0,x(`\uD83C\uDF74 Forked ${d.sourceSessionId.slice(0,8)}→${d.newSessionId.slice(0,8)} (${d.messagesCopied} msgs)`)]),await q3(d.newSessionId)}catch(V){R((d)=>[...d,o(`Fork failed: ${V.message}`)])}break}case"rest":{let N=_?.trim();if(!N){R((P)=>[...P,x("Usage: /rest <arion-name>")]);break}try{let{resultFrame:P}=await m("arion.rest",{name:N});if(!P)throw Error("arion.rest produced no result frame");if(!P.ok)throw Error(P.error.message);R((w)=>[...w,x(`${N} is now resting.`)]),await F1()}catch(P){R((w)=>[...w,o(`Cannot rest ${N}: ${P.message}`)])}break}case"wake":{let N=_?.trim();if(!N){R((P)=>[...P,x("Usage: /wake <arion-name>")]);break}try{let{resultFrame:P}=await m("arion.wake",{name:N});if(!P)throw Error("arion.wake produced no result frame");if(!P.ok)throw Error(P.error.message);R((w)=>[...w,x(`${N} is now awake.`)]),await F1()}catch(P){R((w)=>[...w,o(`Cannot wake ${N}: ${P.message}`)])}break}case"become":{let N=_?.trim();if(!N){R((P)=>[...P,x("Usage: /become <arion-name>")]);break}try{let{resultFrame:P}=await m("arion.become",{name:N});if(!P)throw Error("arion.become produced no result frame");if(!P.ok)throw Error(P.error.message);let w=P.result.arion;if(!w)throw Error(`Arion ${N} not found`);let T=l0().preferredTier||"balanced",V=oJ(T,B),d=w.preferredModel||V?.shortName||G;G3.current=w.name,X6(w.name),o1(d),L1.current=d,R((Y1)=>[...Y1,x(`Switched to ${w.name} (model: ${d})`)]);let B0=await(await Z$()).count();c0(B0),await F1()}catch(P){R((w)=>[...w,o(`Cannot become ${N}: ${P.message}`)])}break}case"model":{let N=_?.trim()||"",P=N.toLowerCase();if(P==="refresh"){R((w)=>[...w,x("Discovering models from all providers...")]);try{let{resultFrame:w}=await m("model.refresh",{});if(!w)throw Error("model.refresh produced no result frame");if(!w.ok)throw Error(w.error.message);let b=w.result.models??g$,T=iJ(b);R((V)=>[...V,x(`Updated model catalog (${T.length} selectable models)`)])}catch(w){R((b)=>[...b,o(`Discovery failed: ${w.message}`)])}break}if(!P||P==="list")try{let{resultFrame:w}=await m("model.list",{});if(!w)throw Error("model.list produced no result frame");if(!w.ok)throw Error(w.error.message);let b=w.result.models??g$,T=w.result.currentModel??H0,d=iJ(b).map(($0)=>` ${$0.shortName.toLowerCase()===T.toLowerCase()?"→ ":" "}${$0.provider}/${$0.shortName} (${$0.tier})`).join(`
|
|
141
|
-
`);R(($0)=>[...$0,x(`Current model: ${T}
|
|
142
|
-
|
|
143
|
-
Available models:
|
|
144
|
-
${d}
|
|
145
|
-
|
|
146
|
-
Use /model <name> or /model <provider>/<name> to switch.`)])}catch(w){R((b)=>[...b,o(`Model listing failed: ${w.message}`)])}else try{let{resultFrame:w}=await m("model.set",{model:N});if(!w)throw Error("model.set produced no result frame");if(!w.ok)throw Error(w.error.message);let b=w.result.currentModel??N;R((T)=>[...T,x(`Switched model to ${b}`)])}catch(w){R((b)=>[...b,o(`Unknown model: ${N}. Use /model list to see available models. ${w.message}`)])}break}case"autonomy":{if(_&&_.trim())try{let N=_.trim().toLowerCase(),{resultFrame:P}=await m("config.autonomy.set",{autonomy:N});if(!P)throw Error("config.autonomy.set produced no result frame");if(!P.ok)throw Error(P.error.message);R((w)=>[...w,x(`Autonomy level set to: ${N}`)])}catch(N){R((P)=>[...P,o(`Invalid autonomy level: ${_.trim().toLowerCase()}. ${N.message}`)])}else m4(!0);break}case"memories":{try{let{resultFrame:N}=await m("memory.list",{limit:20});if(!N)throw Error("memory.list produced no result frame");if(!N.ok)throw Error(N.error.message);let P=N.result,w=typeof P.count==="number"?P.count:0;if(w===0)R((b)=>[...b,x("No memories stored. Use /remember to store memories.")]);else{let T=(Array.isArray(P.memories)?P.memories:[]).map((V)=>` [${V.id.slice(0,8)}] ${V.content.slice(0,80)}${V.content.length>80?"...":""}`).join(`
|
|
147
|
-
`);R((V)=>[...V,x(`Memories (${w} total):
|
|
148
|
-
${T}`)])}}catch(N){R((P)=>[...P,o(`Failed to list memories: ${N.message}`)])}break}case"forget":{try{let{resultFrame:N}=await m("memory.forget",{id:_??""});if(!N)throw Error("memory.forget produced no result frame");if(!N.ok)throw Error(N.error.message);let P=N.result;if(R((w)=>[...w,x(String(P.message??"Memory deleted."))]),typeof P.count==="number")c0(P.count)}catch(N){R((P)=>[...P,o(`Failed to delete memory: ${N.message}`)])}break}case"restart":{let N=_?.trim()||"User requested /restart";R((P)=>[...P,x("Restarting ARIA...")]),setTimeout(()=>{(async()=>{try{let{resultFrame:P}=await m("system.restart",{reason:N});if(!P)throw Error("system.restart produced no result frame");if(!P.ok)throw Error(P.error.message)}catch(P){R((w)=>[...w,o(`Restart preparation failed: ${P.message}`)])}try{await AG(N,G0.current)}catch(P){R((w)=>[...w,o(`Restart failed: ${P.message}`)])}})()},100);break}case"terminal-setup":{try{let{resultFrame:N}=await m("system.terminal_setup",{});if(!N)throw Error("system.terminal_setup produced no result frame");if(!N.ok)throw Error(N.error.message);let P=N.result;R((w)=>[...w,x(P.supported===!1?P.message??"terminal-setup is unavailable.":P.output??"")])}catch(N){R((P)=>[...P,o(`terminal-setup failed: ${N.message}`)])}break}case"login":{try{await T$("auth.login",_??"")}catch(N){R((P)=>[...P,o(`Login failed: ${N.message}`)])}break}case"logout":{try{await T$("auth.logout",_??"")}catch(N){R((P)=>[...P,o(`Logout failed: ${N.message}`)])}break}case"theme":{let N=(_??"").trim().toLowerCase();if(!N){JZ((P)=>(P??0)+1);break}try{let{resultFrame:P}=await m("config.theme.set",{theme:N});if(!P)throw Error("config.theme.set produced no result frame");if(!P.ok)throw Error(P.error.message);R((w)=>[...w,x(`Theme changed to ${t9(N)?.displayName??N} (${N})`)])}catch(P){let w=h3();R((b)=>[...b,o(`Unknown theme "${N}". Available: ${w.join(", ")}. ${P.message}`)])}break}case"invite":{await Nz(_?.trim());break}case"join":{let N=_?.trim();if(N)await zQ(N);else e8(null),w5((P)=>(P??0)+1);break}case"peers":{LZ((N)=>(N??0)+1);break}case"clients":{Y3((N)=>(N??0)+1);break}default:{R((N)=>[...N,x(`Unknown command: /${H}. Type /help for available commands.`)]);break}}},[Z,J,Q,H0,g$,k0,B,m,k,Z$,v2,q3,k5,G,L,F1,$,z8]);K8.current=KQ;let Gz=u(async(H,_)=>{if(_==="mention")return;try{if(_==="become"){let{resultFrame:N}=await m("arion.become",{name:H});if(!N)throw Error("arion.become produced no result frame");if(!N.ok)throw Error(N.error.message);let P=N.result.arion;if(!P)throw Error(`Arion ${H} not found`);let b=l0().preferredTier||"balanced",T=oJ(b,B),V=P.preferredModel?kG(P.preferredModel):void 0,d=(V?x8(V,B).shortName:void 0)||T?.shortName||G;o1(d),L1.current=d,R((Y1)=>[...Y1,x(`Switched to ${P.name} (model: ${d})`)]);let B0=await(await Z$()).count();c0(B0)}else if(_==="rest"){let{resultFrame:N}=await m("arion.rest",{name:H});if(!N)throw Error("arion.rest produced no result frame");if(!N.ok)throw Error(N.error.message);R((P)=>[...P,x(`${H} is now resting`)])}else if(_==="wake"){let{resultFrame:N}=await m("arion.wake",{name:H});if(!N)throw Error("arion.wake produced no result frame");if(!N.ok)throw Error(N.error.message);R((P)=>[...P,x(`${H} is now awake`)])}await F1()}catch(N){R((P)=>[...P,o(`Error: ${N.message}`)])}},[B,m,Z$,G,F1]),GQ=u(async(H,_)=>{let{resultFrame:N}=await m("model.set",{model:H});if(!N)throw Error("model.set produced no result frame");if(!N.ok)throw Error(N.error.message);let P=N.result.currentModel??H;if(_){D1(_);let w=l0();w.effortLevel=_,X$(w)}R((w)=>[...w,x(`Switched to ${P}`)])},[m]);v.current=GQ;let v5=u(async(H)=>{try{let{resultFrame:_}=await m("config.theme.set",{theme:H.name});if(!_)throw Error("config.theme.set produced no result frame");if(!_.ok)throw Error(_.error.message);R((N)=>[...N,x(`Theme changed to ${H.displayName} (${H.name})`)])}catch(_){R((N)=>[...N,o(`Theme change failed: ${_.message}`)])}},[m]),zz=F0(v5);zz.current=v5;let qz=u(async(H)=>{if(H.status==="connected"){try{}catch{}R((P)=>[...P,x(`✓ Already connected to ${H.displayNameSnapshot} (same identity, shared server on port ${H.port}).`)]);return}let _=H.host&&bF(H.host);if(H.transport!=="wan"&&H.host&&!_){R((P)=>[...P,o(`Rejected: ${H.host} is not a private LAN address.`)]);return}try{if(!H.principalFingerprint)throw Error(`${H.displayNameSnapshot} did not advertise a principal fingerprint`);if(!H.tlsCaFingerprint)throw Error(`${H.displayNameSnapshot} did not advertise a TLS fingerprint`);if(!H.host||!H.port)throw Error(`${H.displayNameSnapshot} did not advertise a control endpoint`);let{resultFrame:P}=await m("peer.connect",{nodeId:H.nodeId,displayName:H.displayNameSnapshot,principalFingerprint:H.principalFingerprint,controlEndpoint:{host:H.host,port:H.port,tlsCaFingerprint:H.tlsCaFingerprint,tlsServerIdentity:H.principalFingerprint,protocolVersion:1},transport:H.transport});if(!P)throw Error("peer.connect produced no result frame");if(!P.ok)throw Error(P.error.message);let w=P.result.invite;if(!w)throw Error("peer.connect returned no invite payload");R((b)=>[...b,x(w.mode==="wan_pair"?`Paired with ${w.displayNameSnapshot??w.nodeId}. Awaiting verified ingress before the runtime marks the peer active.`:`Paired with ${w.displayNameSnapshot??w.nodeId}. WG tunnel will connect when accepted.`)])}catch(P){R((w)=>[...w,o(`Failed to connect to ${H.displayNameSnapshot}: ${P.message}`)])}},[m]),Hz=u(async()=>{if(!X2)return;let{id:H,nodeId:_,displayNameSnapshot:N}=X2,P=N??_;BZ(null),R((w)=>[...w,x(`Accepting connection from ${P}...`)]);try{let{resultFrame:w}=await m("peer.pending.respond",{requestId:H,accepted:!0});if(!w)throw Error("peer.pending.respond produced no result frame");if(!w.ok)throw Error(w.error.message);let b=w.result.response??{};if(b.error)throw Error(b.error);if(b.accepted)R((T)=>[...T,x(`Connected to ${P}. Tunnel established.`)])}catch(w){R((b)=>[...b,o(`Failed to accept connection: ${w.message}`)])}},[m,X2]),Wz=u(()=>{if(!X2)return;let{id:H,nodeId:_,displayNameSnapshot:N}=X2,P=N??_;BZ(null),R((w)=>[...w,x(`Rejected connection from ${P}.`)]),m("peer.pending.respond",{requestId:H,accepted:!1}).catch(()=>{})},[m,X2]),Nz=u(async(H)=>{try{let{resultFrame:_}=await m("peer.invite",{...H?.trim()?{inviteLabel:H.trim()}:{}});if(!_)throw Error("peer.invite produced no result frame");if(!_.ok)throw Error(_.error.message);let N=_.result.invite;if(!N)throw Error("peer.invite returned no invite payload");Z8(N)}catch(_){R((N)=>[...N,o(`Failed to create invite: ${_.message}`)])}},[m]),zQ=u(async(H)=>{try{let{resultFrame:_}=await m("peer.accept_invite",{inviteToken:H});if(!_)throw Error("peer.accept_invite produced no result frame");if(!_.ok)throw Error(_.error.message);let N=_.result.accepted;if(!N)throw Error("peer.accept_invite returned no accepted payload");e8(null),R((P)=>[...P,x(`Paired with ${N.displayNameSnapshot??N.nodeId}.`)])}catch(_){let N=`Failed to accept invite: ${_.message}`;e8(N),R((P)=>[...P,o(N)])}},[m]);X1(()=>{let H=!0,_=null;return(async()=>{if(_=setInterval(async()=>{try{let{resultFrame:w}=await m("peer.pending.list",{});if(!H||!w?.ok)return;let b=w.result.requests??[];if(b.length&&!X2)BZ(b[0])}catch(w){if(tJ(w)){if(_)clearInterval(_);f2.current=null;return}}},5000),f2.current=_,!H)clearInterval(_),_=null,f2.current=null})(),()=>{if(H=!1,_)clearInterval(_);f2.current=null}},[m,X2]);let Pz=u(async(H)=>{q5(H),await SZ()},[SZ]),_z=u(async(H)=>{if(E4==="forget")try{let{resultFrame:_}=await m("memory.forget",{id:H.id});if(!_)throw Error("memory.forget produced no result frame");if(!_.ok)throw Error(_.error.message);let N=H.content.length>50?H.content.slice(0,50)+"...":H.content;R((P)=>[...P,x(`Forgot: "${N}"`)]),await SZ()}catch(_){R((N)=>[...N,o(`Error forgetting: ${_.message}`)])}},[m,E4,SZ]),q8=u(()=>{d4(null),p4(null),x4(null),l4(null),u4(null),u3(null),r4(null),a4(null),r3(null),n4(null),i4(null),a3(!1),o4(!1),Q3(null),s4(!1),e4(null),s8(!1),n3(null),t8(null),OZ(null),wZ(null)},[]),G6=u((H)=>{let _=H,N=_.success!==!1,P=_.message??(N?"Authentication updated.":"Auth failed.");R((w)=>[...w,N?x(P):o(P)])},[]),gZ=u(async(H)=>{if(q8(),H.interaction.kind==="selection"){n3({interactionId:H.interactionId,interaction:H.interaction}),OZ(H.interaction.prompt),t8(H.interaction.options.map((_)=>({id:_.id,label:_.label,description:_.description,method:_.id,status:_.description?.includes("connected")?"connected":_.description?.includes("available")?"available":"none"})));return}if(H.interaction.kind==="credential_input"){let _=H.interaction.fields[0];if(!_)throw Error("Auth interaction requires at least one credential field");if(H.interaction.mode==="oauth_authorization_code"&&H.interaction.authorizeUrl&&H.interaction.provider){n3({interactionId:H.interactionId,interaction:H.interaction}),x4(H.interaction.provider),l4(H.interaction.authorizeUrl),u4(H.interaction.expectedState??null),u3(_.key);return}n3({interactionId:H.interactionId,interaction:H.interaction}),wZ({title:_.label,hint:H.interaction.prompt,fieldKey:_.key});return}if(H.interaction.kind==="oauth_device"){n3({interactionId:H.interactionId,interaction:H.interaction}),r4(H.interaction.provider??"github-copilot"),a4(H.interaction.profileLabel??null),r3(H.interaction.verificationUri),n4(H.interaction.userCode);return}},[G6,q8,_1]),T$=u(async(H,_)=>{q8();let{interactionFrame:N,resultFrame:P}=await m(H,{args:_});if(N&&N.source==="auth"){await gZ(N);return}if(!P)throw Error(`${H} produced no result frame`);if(P.ok){G6(P.result);return}throw Error(P.error.message)},[G6,q8,m,gZ]),H3=u(async(H)=>{if(!UZ)throw Error("No pending auth interaction to respond to");let{interactionId:_}=UZ,N=null,P=null;for await(let w of _1.dispatch({kind:"interaction.respond",requestId:`auth:${p8()}`,interactionId:_,response:H}))if(w.kind==="interaction.required"&&w.source==="auth")N=w;else if(w.kind==="result")P=w;if(N){await gZ(N);return}if(q8(),!P)throw Error("auth interaction produced no result frame");if(P.ok){G6(P.result);return}if(P.error.code==="INTERACTION_REQUIRED")return;R((w)=>[...w,o(`Login failed: ${P.error.message}`)])},[G6,q8,_1,UZ,gZ]),Fz=o6(()=>kG(H0)?.maxContextTokens,[H0]),Uz=o6(()=>{return y.map((H,_)=>{let P=(Array.isArray(H.content)?H.content:[H.content]).filter((w)=>typeof w==="object"&&w!==null&&("type"in w)&&w.type==="text").map((w)=>w.text).join("").trim();if(!P||H.role==="system")return null;return{index:_,role:H.role,text:P,arion:H.arion?.name,createdAt:H.createdAt}}).filter((H)=>H!==null)},[y]),[Az,uF]=E(void 0),[Oz,g5]=E(void 0),wz=u(async(H,_)=>{if(!G0.current||L0.current)return;let N=0;for(let w=0;w<H;w++){let b=y[w];if(b&&b.role!=="system")N++}let P=N;try{let{resultFrame:w}=await m("session.fork",{sessionId:G0.current,messageLimit:P});if(!w?.ok){let T=w?.error?.message??"Fork failed";R((V)=>[...V,o(`Edit failed: ${T}`)]);return}let b=w.result;await q3(b.newSessionId),g5(_)}catch(w){R((b)=>[...b,o(`Edit failed: ${w.message}`)])}},[y,m,q3]);return eJ(XG,{staticRenderEpoch:C5,session:$,model:H0,maxContextTokens:Fz,banner:eJ(x7,{onComplete:()=>{},skipAnimation:!0,version:mG,whatsNew:dG},void 0,!1,void 0,this),messages:y,previewMessages:f,isStreaming:R1,queuedMessage:s,onCancelQueuedMessage:Jz,responseTime:l,commands:mJ,arions:u0,models:z3,memories:Q2,memoryBrowserMode:E4,isLoadingMemories:t6,userName:b0,memoryCount:h1,metrics:s3,displayMode:IZ,displayConfig:e3,showThinking:e3.showThinking,showCosts:e3.showCosts,showTraces:e3.showTraces,pipelineTiming:I5,spans:M5,activeArion:f5,onSubmit:v2,onCommand:KQ,onSelectArion:Gz,onSelectModel:GQ,onSelectMemory:_z,onOpenMemoryBrowser:Pz,onToggleThinking:Xz,onToggleCosts:Yz,onToggleTraces:Kz,onCycleDisplayMode:Qz,sessions:e6,onSelectSession:q3,onLoadSessions:oG,onSearchSessions:sG,onLoadMoreSessions:tG,openSessionOverlaySignal:$Z,openThemeOverlaySignal:u8,inviteShare:$8?{inviteToken:$8.inviteToken,inviteLabel:$8.pendingInvite.inviteLabel,expiresAt:$8.pendingInvite.expiresAt??null}:null,onInviteShareClose:()=>{Z8(null)},openJoinInviteOverlaySignal:O5,onJoinInviteSubmit:zQ,onJoinInviteCancel:()=>{e8(null)},joinInviteError:ZQ,onSelectTheme:v5,inputHistory:z,onSaveInput:q,openMessageEditOverlaySignal:Az,editableMessages:Uz,onEditMessage:wz,prefillInput:Oz,onPrefillConsumed:()=>g5(void 0),obsCtx:S5,onCancel:Zz,approvalRequest:Z6,onApprovalChoice:(H)=>{if(Z6)Z6.resolve(H),J8(null)},effortLevel:s1,showAutonomySelector:QZ,autonomyLevel:n8,onAutonomySelect:(H)=>{l3(H),m4(!1),R((_)=>[..._,x(`Autonomy level set to: ${H}`)])},onCycleAutonomy:()=>{let H=G5.indexOf(J3.current),_=G5[(H+1)%G5.length];l3(_)},onCycleEffort:()=>{let H=["low","medium","high","max"],_=H.indexOf(s1),N=H[(_+1)%H.length];D1(N);let P=l0();P.effortLevel=N,X$(P)},onAutonomyCancel:()=>{m4(!1)},authInteractionOptions:AZ,authInteractionTitle:X3,onAuthInteractionSelect:async(H)=>{await H3({kind:"selection",selected:H})},onAuthInteractionCancel:async()=>{await H3({kind:"cancel"})},authInteractionInput:C2?{title:C2.title,...C2.hint?{hint:C2.hint}:{}}:null,onAuthInteractionInputSubmit:async(H)=>{if(!C2)return;await H3({kind:"credential_input",values:{[C2.fieldKey]:H}})},onAuthInteractionInputCancel:async()=>{await H3({kind:"cancel"})},loginPickerProviders:XZ,onLoginProviderSelect:async(H)=>{d4(null),await T$("auth.login",H.id)},onLoginPickerCancel:()=>{d4(null)},anthropicMethodOptions:NZ,onAnthropicMethodSelect:async(H)=>{i4(null),await T$("auth.login",`anthropic --method ${H.id}`)},onAnthropicMethodCancel:()=>i4(null),anthropicKeyInputVisible:PZ,onAnthropicKeySubmit:async(H)=>{a3(!1),await T$("auth.login",`anthropic ${H}`)},onAnthropicKeyCancel:()=>a3(!1),anthropicSetupTokenVisible:N5,onAnthropicSetupTokenSubmit:async(H)=>{o4(!1),await T$("auth.login",`anthropic --setup-token ${H}`)},onAnthropicSetupTokenCancel:()=>o4(!1),openaiMethodOptions:_Z,onOpenAIMethodSelect:async(H)=>{Q3(null),await T$("auth.login",`openai --method ${H.id}`)},onOpenAIMethodCancel:()=>Q3(null),openaiKeyInputVisible:FZ,onOpenAIKeySubmit:async(H)=>{s4(!1),await T$("auth.login",`openai ${H}`)},onOpenAIKeyCancel:()=>s4(!1),googleMethodOptions:t4,onGoogleMethodSelect:async(H)=>{e4(null),await T$("auth.login",`google --method ${H.id}`)},onGoogleMethodCancel:()=>e4(null),googleKeyInputVisible:P5,onGoogleKeySubmit:async(H)=>{s8(!1),await T$("auth.login",`google ${H}`)},onGoogleKeyCancel:()=>s8(!1),copilotSourceOptions:i8,onCopilotSourceSelect:async(H)=>{p4(null),await T$("auth.login",`github-copilot --from ${H.id}`)},onCopilotSourceCancel:()=>p4(null),oauthProvider:YZ,oauthAuthorizeUrl:KZ,oauthExpectedState:GZ,onOAuthComplete:(H)=>{x4(null),l4(null),u4(null),u3(null),R((_)=>[..._,H.success?x(H.message):o(H.message)])},onOAuthCodeSubmit:async(H)=>{if(!o8)throw Error("No pending OAuth field key");await H3({kind:"credential_input",values:{[o8]:H}})},onOAuthCancel:async()=>{await H3({kind:"cancel"})},copilotDeviceProvider:zZ,copilotDeviceProfileLabel:qZ,copilotDeviceVerificationUri:HZ,copilotDeviceUserCode:WZ,onCopilotDeviceComplete:(H)=>{r4(null),a4(null),r3(null),n4(null),R((_)=>[..._,H.success?x(H.message):o(H.message)])},onCopilotDeviceApprove:async()=>{await H3({kind:"oauth_device",acknowledged:!0})},onCopilotDeviceCancel:async()=>{await H3({kind:"cancel"})},nearbyPeers:_5,localClients:i3,onSelectPeer:qz,onSelectClient:()=>{},onPeerCancel:()=>{},onClientsCancel:()=>{},openPeersOverlaySignal:A5,openClientsOverlaySignal:RZ,incomingPairRequest:X2,onAcceptPairRequest:Hz,onRejectPairRequest:Wz,onCancelPairing:void 0,meshMessageCount:L5,runtimeSocket:J6,clientId:X.attachedClientId??null,clientAuthToken:X.attachedClientAuthToken??null,resolveCredentials:async()=>{try{let{createResilientAttachedClient:H}=await import("./attached-local-control-client-2jz8vmjb.js"),{resolveRuntimeRootDirectory:_,findRuntimeOwnerRecordByAriaHome:N}=await import("@aria-cli/server"),P=_(),w=process.env.ARIA_HOME??`${process.env.HOME}/.aria`,b=N(P,w);if(!b?.runtimeSocket)return null;let T=await H({runtimeSocket:b.runtimeSocket,clientKind:"local-api"});return{clientId:T.getClientId(),clientAuthToken:T.getClientAuthToken()}}catch{return null}}},void 0,!1,void 0,this)}async function Ch($,Z,J,Q,X,Y,K=[],G,z,q,W,U,F,O,L,B){let{waitUntilExit:S,unmount:k}=MF(eJ(lF,{session:$,manager:Z,router:J,aria:Q,attachedLocalControl:X,cliContext:Y,sessionHistory:z,inputHistory:K,onSaveInput:G,initialMessage:q,resumeSessionId:U,cachedUserName:W,initialAvailableModels:F,refreshAvailableModels:O,credentialHints:L,authResolver:B},void 0,!1,void 0,this),{exitOnCtrlC:!1,patchConsole:!0}),y,f,M=!1,I=()=>{if(!y)y=()=>{process.exit(0)},process.on("SIGINT",y);if(!f)f=setTimeout(()=>{N0.debug("[InkREPL] Graceful shutdown timed out after 5s — forcing exit"),process.exit(0)},5000),f.unref?.()},R=()=>{if(M)return;M=!0,process.removeListener("SIGINT",R),I(),X?.release().catch((j)=>{N0.warn("[InkREPL] Local-control release during SIGINT failed:",j?.message??j)}),k()};process.on("SIGINT",R);try{await S(),I();try{let{sessionId:j,sessionHistory:Q0,memoriaSession:w1,memoriaFactory:P1}=N1;if(Q0&&j)try{Q0.markCompleted(j)}catch(H0){N0.warn("[InkREPL] Failed to mark session completed:",H0?.message??H0)}if(w1&&j)try{await w1.endSession(j)}catch(H0){N0.warn("[InkREPL] Failed to end Memoria session:",H0?.message??H0)}if(P1)try{await P1.closeAll()}catch(H0){N0.warn("[InkREPL] Failed to close Memoria factory:",H0?.message??H0)}if(N1.jsonlLogger){try{await N1.jsonlLogger.close()}catch(H0){N0.warn("[InkREPL] Failed to close JSONL logger:",H0?.message??H0)}N1.jsonlLogger=null}}finally{if(f)clearTimeout(f),f=void 0}}finally{if(process.removeListener("SIGINT",R),y)process.removeListener("SIGINT",y)}try{await Q.shutdown()}catch(j){N0.warn("[InkREPL] Shutdown failed:",j?.message)}}
|
|
149
|
-
export{Mh as l,Ch as m};
|