@sylphx/flow 0.2.9 → 0.2.11
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/dist/chunk-1ej6vegq.js +23 -0
- package/dist/{chunk-gmmm7xpw.js.map → chunk-1ej6vegq.js.map} +3 -3
- package/dist/{chunk-2j2gmjg5.js → chunk-5hcagq8j.js} +6 -6
- package/dist/{chunk-9qzv4trv.js → chunk-dpba9y5x.js} +1 -1
- package/dist/{chunk-vc4xy6dm.js → chunk-pzp2kw7j.js} +1 -1
- package/dist/{chunk-e74zv5ct.js → chunk-r19ma0z2.js} +1 -1
- package/dist/{chunk-weshapwk.js → chunk-s323r5xg.js} +1 -1
- package/dist/index.js +3 -3
- package/drizzle/0000_wooden_lady_bullseye.sql +52 -0
- package/drizzle/0001_material_pyro.sql +85 -0
- package/drizzle/meta/0000_snapshot.json +310 -0
- package/drizzle/meta/0001_snapshot.json +906 -0
- package/drizzle/meta/_journal.json +20 -0
- package/package.json +2 -1
- package/dist/chunk-gmmm7xpw.js +0 -23
- /package/dist/{chunk-2j2gmjg5.js.map → chunk-5hcagq8j.js.map} +0 -0
- /package/dist/{chunk-9qzv4trv.js.map → chunk-dpba9y5x.js.map} +0 -0
- /package/dist/{chunk-vc4xy6dm.js.map → chunk-pzp2kw7j.js.map} +0 -0
- /package/dist/{chunk-e74zv5ct.js.map → chunk-r19ma0z2.js.map} +0 -0
- /package/dist/{chunk-weshapwk.js.map → chunk-s323r5xg.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{c as X2,d as sJ}from"./chunk-d6k94684.js";import{e as n8,f as gN,g as sBA,h as mE,i as ZF,k as hw,l as A0A,m as Gk,n as tBA,o as AE,p as tE,q as CN,r as Hk}from"./chunk-rsagxdqj.js";import{s as Rw}from"./chunk-
|
|
2
|
+
import{c as X2,d as sJ}from"./chunk-d6k94684.js";import{e as n8,f as gN,g as sBA,h as mE,i as ZF,k as hw,l as A0A,m as Gk,n as tBA,o as AE,p as tE,q as CN,r as Hk}from"./chunk-rsagxdqj.js";import{s as Rw}from"./chunk-5hcagq8j.js";import{t as sH,u as gR}from"./chunk-585jp0rg.js";import{v as uG,w as ev}from"./chunk-r19ma0z2.js";import{A as tv,B as s6,x as ov,y as FG,z as sv}from"./chunk-dpba9y5x.js";import{C as KD,D as Tj,E as n6,F as o6,G as sA,H as lv,I as Sv,J as mv,K as jv,L as iv,M as xv}from"./chunk-s323r5xg.js";import"./chunk-sgafqzer.js";import{P as gi,Q as ai,R as sj,S as tj}from"./chunk-cjy100rr.js";import{U as Di,V as _i,W as nj,X as _R,Y as oj}from"./chunk-7h737bp8.js";import"./chunk-372bgp30.js";import"./chunk-rvx8bgqk.js";import"./chunk-f676awyz.js";import{ca as CA,da as Qi,ea as Ei}from"./chunk-pzp2kw7j.js";import{fa as n7,ga as Qg,ha as Uf,ia as jJ,ja as d8,ka as x8,la as bw,ma as H2,na as Ua,oa as TI,pa as SE,qa as J2,ra as kx,sa as zx,ta as gJ,ua as BJ,va as t4}from"./chunk-1ej6vegq.js";import"./chunk-51kpynby.js";import{Aa as Rv,ya as $E,za as d6}from"./chunk-6eb5a8kv.js";import{Ca as g0A,Fa as uN}from"./chunk-z61qdct1.js";import{Ga as AG}from"./chunk-057m762a.js";import{Ha as Ew}from"./chunk-mtrcdhzn.js";import"./chunk-etqfkn4f.js";import"./chunk-cv1nhr27.js";import{Pb as PD,Qb as La}from"./chunk-ceyg2zjg.js";import{Rb as GA,Sb as N,Tb as T1,Ub as xD}from"./chunk-f9yb2zk3.js";var P1=N((IyA)=>{class h5 extends Error{constructor(A,D,_){super(_);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=D,this.exitCode=A,this.nestedError=void 0}}class kW extends h5{constructor(A){super(1,"commander.invalidArgument",A);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}IyA.CommanderError=h5;IyA.InvalidArgumentError=kW});var Q6=N((FyA)=>{var{InvalidArgumentError:yyA}=P1();class zW{constructor(A,D){switch(this.description=D||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,A[0]){case"<":this.required=!0,this._name=A.slice(1,-1);break;case"[":this.required=!1,this._name=A.slice(1,-1);break;default:this.required=!0,this._name=A;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(A,D){if(D===this.defaultValue||!Array.isArray(D))return[A];return D.push(A),D}default(A,D){return this.defaultValue=A,this.defaultValueDescription=D,this}argParser(A){return this.parseArg=A,this}choices(A){return this.argChoices=A.slice(),this.parseArg=(D,_)=>{if(!this.argChoices.includes(D))throw new yyA(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(D,_);return D},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function wyA(A){let D=A.name()+(A.variadic===!0?"...":"");return A.required?"<"+D+">":"["+D+"]"}FyA.Argument=zW;FyA.humanReadableArgName=wyA});var l5=N((GyA)=>{var{humanReadableArgName:zyA}=Q6();class GW{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(A){this.helpWidth=this.helpWidth??A.helpWidth??80}visibleCommands(A){let D=A.commands.filter((g)=>!g._hidden),_=A._getHelpCommand();if(_&&!_._hidden)D.push(_);if(this.sortSubcommands)D.sort((g,a)=>{return g.name().localeCompare(a.name())});return D}compareOptions(A,D){let _=(g)=>{return g.short?g.short.replace(/^-/,""):g.long.replace(/^--/,"")};return _(A).localeCompare(_(D))}visibleOptions(A){let D=A.options.filter((g)=>!g.hidden),_=A._getHelpOption();if(_&&!_.hidden){let g=_.short&&A._findOption(_.short),a=_.long&&A._findOption(_.long);if(!g&&!a)D.push(_);else if(_.long&&!a)D.push(A.createOption(_.long,_.description));else if(_.short&&!g)D.push(A.createOption(_.short,_.description))}if(this.sortOptions)D.sort(this.compareOptions);return D}visibleGlobalOptions(A){if(!this.showGlobalOptions)return[];let D=[];for(let _=A.parent;_;_=_.parent){let g=_.options.filter((a)=>!a.hidden);D.push(...g)}if(this.sortOptions)D.sort(this.compareOptions);return D}visibleArguments(A){if(A._argsDescription)A.registeredArguments.forEach((D)=>{D.description=D.description||A._argsDescription[D.name()]||""});if(A.registeredArguments.find((D)=>D.description))return A.registeredArguments;return[]}subcommandTerm(A){let D=A.registeredArguments.map((_)=>zyA(_)).join(" ");return A._name+(A._aliases[0]?"|"+A._aliases[0]:"")+(A.options.length?" [options]":"")+(D?" "+D:"")}optionTerm(A){return A.flags}argumentTerm(A){return A.name()}longestSubcommandTermLength(A,D){return D.visibleCommands(A).reduce((_,g)=>{return Math.max(_,this.displayWidth(D.styleSubcommandTerm(D.subcommandTerm(g))))},0)}longestOptionTermLength(A,D){return D.visibleOptions(A).reduce((_,g)=>{return Math.max(_,this.displayWidth(D.styleOptionTerm(D.optionTerm(g))))},0)}longestGlobalOptionTermLength(A,D){return D.visibleGlobalOptions(A).reduce((_,g)=>{return Math.max(_,this.displayWidth(D.styleOptionTerm(D.optionTerm(g))))},0)}longestArgumentTermLength(A,D){return D.visibleArguments(A).reduce((_,g)=>{return Math.max(_,this.displayWidth(D.styleArgumentTerm(D.argumentTerm(g))))},0)}commandUsage(A){let D=A._name;if(A._aliases[0])D=D+"|"+A._aliases[0];let _="";for(let g=A.parent;g;g=g.parent)_=g.name()+" "+_;return _+D+" "+A.usage()}commandDescription(A){return A.description()}subcommandDescription(A){return A.summary()||A.description()}optionDescription(A){let D=[];if(A.argChoices)D.push(`choices: ${A.argChoices.map((_)=>JSON.stringify(_)).join(", ")}`);if(A.defaultValue!==void 0){if(A.required||A.optional||A.isBoolean()&&typeof A.defaultValue==="boolean")D.push(`default: ${A.defaultValueDescription||JSON.stringify(A.defaultValue)}`)}if(A.presetArg!==void 0&&A.optional)D.push(`preset: ${JSON.stringify(A.presetArg)}`);if(A.envVar!==void 0)D.push(`env: ${A.envVar}`);if(D.length>0){let _=`(${D.join(", ")})`;if(A.description)return`${A.description} ${_}`;return _}return A.description}argumentDescription(A){let D=[];if(A.argChoices)D.push(`choices: ${A.argChoices.map((_)=>JSON.stringify(_)).join(", ")}`);if(A.defaultValue!==void 0)D.push(`default: ${A.defaultValueDescription||JSON.stringify(A.defaultValue)}`);if(D.length>0){let _=`(${D.join(", ")})`;if(A.description)return`${A.description} ${_}`;return _}return A.description}formatItemList(A,D,_){if(D.length===0)return[];return[_.styleTitle(A),...D,""]}groupItems(A,D,_){let g=new Map;return A.forEach((a)=>{let Q=_(a);if(!g.has(Q))g.set(Q,[])}),D.forEach((a)=>{let Q=_(a);if(!g.has(Q))g.set(Q,[]);g.get(Q).push(a)}),g}formatHelp(A,D){let _=D.padWidth(A,D),g=D.helpWidth??80;function a(u,G){return D.formatItem(u,_,G,D)}let Q=[`${D.styleTitle("Usage:")} ${D.styleUsage(D.commandUsage(A))}`,""],I=D.commandDescription(A);if(I.length>0)Q=Q.concat([D.boxWrap(D.styleCommandDescription(I),g),""]);let C=D.visibleArguments(A).map((u)=>{return a(D.styleArgumentTerm(D.argumentTerm(u)),D.styleArgumentDescription(D.argumentDescription(u)))});if(Q=Q.concat(this.formatItemList("Arguments:",C,D)),this.groupItems(A.options,D.visibleOptions(A),(u)=>u.helpGroupHeading??"Options:").forEach((u,G)=>{let J=u.map((z)=>{return a(D.styleOptionTerm(D.optionTerm(z)),D.styleOptionDescription(D.optionDescription(z)))});Q=Q.concat(this.formatItemList(G,J,D))}),D.showGlobalOptions){let u=D.visibleGlobalOptions(A).map((G)=>{return a(D.styleOptionTerm(D.optionTerm(G)),D.styleOptionDescription(D.optionDescription(G)))});Q=Q.concat(this.formatItemList("Global Options:",u,D))}return this.groupItems(A.commands,D.visibleCommands(A),(u)=>u.helpGroup()||"Commands:").forEach((u,G)=>{let J=u.map((z)=>{return a(D.styleSubcommandTerm(D.subcommandTerm(z)),D.styleSubcommandDescription(D.subcommandDescription(z)))});Q=Q.concat(this.formatItemList(G,J,D))}),Q.join(`
|
|
3
3
|
`)}displayWidth(A){return HW(A).length}styleTitle(A){return A}styleUsage(A){return A.split(" ").map((D)=>{if(D==="[options]")return this.styleOptionText(D);if(D==="[command]")return this.styleSubcommandText(D);if(D[0]==="["||D[0]==="<")return this.styleArgumentText(D);return this.styleCommandText(D)}).join(" ")}styleCommandDescription(A){return this.styleDescriptionText(A)}styleOptionDescription(A){return this.styleDescriptionText(A)}styleSubcommandDescription(A){return this.styleDescriptionText(A)}styleArgumentDescription(A){return this.styleDescriptionText(A)}styleDescriptionText(A){return A}styleOptionTerm(A){return this.styleOptionText(A)}styleSubcommandTerm(A){return A.split(" ").map((D)=>{if(D==="[options]")return this.styleOptionText(D);if(D[0]==="["||D[0]==="<")return this.styleArgumentText(D);return this.styleSubcommandText(D)}).join(" ")}styleArgumentTerm(A){return this.styleArgumentText(A)}styleOptionText(A){return A}styleArgumentText(A){return A}styleSubcommandText(A){return A}styleCommandText(A){return A}padWidth(A,D){return Math.max(D.longestOptionTermLength(A,D),D.longestGlobalOptionTermLength(A,D),D.longestSubcommandTermLength(A,D),D.longestArgumentTermLength(A,D))}preformatted(A){return/\n[^\S\r\n]/.test(A)}formatItem(A,D,_,g){let Q=" ".repeat(2);if(!_)return Q+A;let I=A.padEnd(D+A.length-g.displayWidth(A)),C=2,w=(this.helpWidth??80)-D-C-2,u;if(w<this.minWidthToWrap||g.preformatted(_))u=_;else u=g.boxWrap(_,w).replace(/\n/g,`
|
|
4
4
|
`+" ".repeat(D+C));return Q+I+" ".repeat(C)+u.replace(/\n/g,`
|
|
5
5
|
${Q}`)}boxWrap(A,D){if(D<this.minWidthToWrap)return A;let _=A.split(/\r\n|\n/),g=/[\s]*[^\s]+/g,a=[];return _.forEach((Q)=>{let I=Q.match(g);if(I===null){a.push("");return}let C=[I.shift()],y=this.displayWidth(C[0]);I.forEach((w)=>{let u=this.displayWidth(w);if(y+u<=D){C.push(w),y+=u;return}a.push(C.join(""));let G=w.trimStart();C=[G],y=this.displayWidth(G)}),a.push(C.join(""))}),a.join(`
|
|
@@ -429,8 +429,8 @@ Please report this to https://github.com/markedjs/marked.`,A){let g="<p>An error
|
|
|
429
429
|
`).length,C=g.split(`
|
|
430
430
|
`).length;return{lines:D,summary:`Updated ${Q} with ${I} ${hQ(I,"addition")} and ${C} ${hQ(C,"removal")}`}}),bash:aQ("Bash",(A)=>{let D=A.command?String(A.command):"",_=A.cwd?String(A.cwd):"",g=A.run_in_background,a=x4(D,80);if(g)a+=" [background]";if(_&&_!==process.cwd())a+=` [in ${Mf(_)}]`;return a},(A)=>{if(typeof A==="object"&&A!==null&&"mode"in A&&A.mode==="background"){let{bash_id:_,message:g}=A;return{lines:[`bash_id: ${_}`],summary:g}}if(typeof A==="object"&&A!==null&&"stdout"in A){let{stdout:_,stderr:g,exitCode:a}=A,Q=g&&a!==0?g:_,I=Q?Q.split(`
|
|
431
431
|
`).filter((C)=>C.trim()):[];return{lines:I,summary:I.length>0?void 0:"Command completed"}}let D=lQ(A);return{lines:D,summary:D.length>0?void 0:"Command completed"}}),"bash-output":aQ("BashOutput",(A)=>A.bash_id?String(A.bash_id):"",(A)=>{if(typeof A==="object"&&A!==null&&"bash_id"in A){let{stdout:D,stderr:_,exitCode:g,isRunning:a,duration:Q}=A,I=_&&g!==0?_:D,C=I?I.split(`
|
|
432
|
-
`).filter((u)=>u.trim()):[],y=a?"Still running":`Completed (exit: ${g})`,w=Math.floor(Q/1000);return{lines:C,summary:`${y} - ${w}s`}}return{lines:lQ(A)}}),"kill-bash":aQ("KillBash",(A)=>A.bash_id?String(A.bash_id):"",(A)=>{if(typeof A==="object"&&A!==null&&"message"in A){let{message:D}=A;return{lines:[],summary:D}}return{lines:lQ(A)}}),grep:aQ("Search",(A)=>{let D=A.pattern?String(A.pattern):"",_=A.glob?String(A.glob):"",g=A.type?String(A.type):"",a=A.path?String(A.path):"",Q=`"${x4(D,40)}"`;if(_)Q+=` in ${_}`;else if(g)Q+=` [${g}]`;if(a&&!oH(a))Q+=` [${Mf(a)}]`;return Q},(A)=>{if(typeof A!=="object"||A===null)return{lines:lQ(A)};let D=A;if("matches"in D){let _=D.matches;return{lines:_.map((a)=>`${a.file}:${a.line}: ${a.content}`),summary:`Found ${_.length} ${hQ(_.length,"match","matches")}`}}if("files"in D){let _=D.files;return{lines:_,summary:`Found ${_.length} ${hQ(_.length,"file")}`}}if("count"in D&&!("matches"in D)&&!("files"in D))return{lines:[],summary:`Found ${D.count} ${hQ(D.count,"match","matches")}`};return{lines:lQ(A)}}),glob:aQ("Search",(A)=>{let D=A.pattern?String(A.pattern):"",_=A.path?String(A.path):"";return _&&!oH(_)?`${D} in ${Mf(_)}`:D},(A)=>{if(typeof A==="object"&&A!==null&&"files"in A){let _=A.files;return{lines:_,summary:`Found ${_.length} ${hQ(_.length,"file")}`}}let D=lQ(A);return{lines:D,summary:`Found ${D.length} ${hQ(D.length,"file")}`}}),updateTodos:aQ("Tasks",(A)=>{let D=A.todos;if(!D||D.length===0)return"";let _=D.filter((Q)=>!Q.id).length,g=D.filter((Q)=>Q.id).length,a=[];if(_>0)a.push(`${_} new`);if(g>0)a.push(`${g} updated`);return a.join(", ")},(A)=>{if(typeof A==="object"&&A!==null&&"summary"in A){let{summary:D,changes:_,total:g}=A;return{lines:_||[],summary:`${D} • ${g} active`}}return{lines:lQ(A)}})},$j=(A)=>{return EqA[A]||null};var fB=GA(YD(),1);function IqA(A){let{name:D,status:_,duration:g,args:a,error:Q}=A;return fB.jsxDEV(j,{flexDirection:"column",children:[fB.jsxDEV(j,{children:[_==="running"&&fB.jsxDEV(fB.Fragment,{children:[fB.jsxDEV(UB,{color:"#FFD700"},void 0,!1,void 0,this),fB.jsxDEV($,{children:" "},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_==="completed"&&fB.jsxDEV($,{color:"#00FF88",children:"✓ "},void 0,!1,void 0,this),_==="failed"&&fB.jsxDEV($,{color:"#FF3366",children:"✗ "},void 0,!1,void 0,this),fB.jsxDEV($,{color:"white",children:D},void 0,!1,void 0,this),g!==void 0&&(_==="completed"||_==="running")&&fB.jsxDEV($,{dimColor:!0,children:[" ",g,"ms"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),_==="failed"&&Q&&fB.jsxDEV(j,{marginLeft:2,children:fB.jsxDEV($,{color:"#FF3366",children:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Vj(A){let D=$j(A.name);if(!D)return fB.jsxDEV(IqA,{...A},void 0,!1,void 0,this);return fB.jsxDEV(D,{...A},void 0,!1,void 0,this)}var yB=GA(YD(),1);function r4({part:A,isLastInStream:D=!1}){let[_,g]=d4.useState(void 0),a=A.type,Q=A.type==="reasoning"&&"completed"in A?A.completed:!0,I=A.type==="tool"?A.status:null,C=(A.type==="reasoning"||A.type==="tool")&&"startTime"in A?A.startTime:null;if(d4.useEffect(()=>{if((a==="reasoning"&&!Q&&C||a==="tool"&&I==="running"&&C)&&C){g(Date.now()-C);let u=setInterval(()=>{g(Date.now()-C)},1000);return()=>clearInterval(u)}else{g(void 0);return}},[a,Q,I,C]),A.type==="text")return yB.jsxDEV(j,{flexDirection:"column",marginLeft:2,marginBottom:1,children:[yB.jsxDEV(nH,{children:A.content},void 0,!1,void 0,this),D&&yB.jsxDEV(j,{children:yB.jsxDEV($,{color:"#FFD700",children:"▊"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(A.type==="reasoning")if("completed"in A?A.completed:!0){let w=A.duration?Math.round(A.duration/1000):0;return yB.jsxDEV(j,{flexDirection:"column",marginLeft:2,marginBottom:1,children:yB.jsxDEV(j,{children:yB.jsxDEV($,{dimColor:!0,children:["Thought ",w,"s"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}else{let w=_?Math.round(_/1000):0;return yB.jsxDEV(j,{flexDirection:"column",marginLeft:2,marginBottom:1,children:yB.jsxDEV(j,{children:[yB.jsxDEV(UB,{color:"#FFD700"},void 0,!1,void 0,this),yB.jsxDEV($,{dimColor:!0,children:[" Thinking... ",w,"s"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}if(A.type==="error")return yB.jsxDEV(j,{marginLeft:2,marginBottom:1,children:yB.jsxDEV($,{color:"red",children:A.error},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(A.type==="tool"){let y=A.status==="running"?_:A.duration;return yB.jsxDEV(j,{marginLeft:2,marginBottom:1,children:yB.jsxDEV(Vj,{name:A.name,status:A.status,duration:y,args:A.args,result:A.result,error:A.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)}return null}function Pj(A){let{input:D,cursor:_,isStreaming:g,pendingInput:a,pendingCommand:Q,filteredFileInfo:I,filteredCommands:C,multiSelectionPage:y,multiSelectionAnswers:w,multiSelectChoices:u,selectionFilter:G,isFilterMode:J,selectedCommandIndex:z,selectedFileIndex:q,skipNextSubmit:X,lastEscapeTime:M,inputResolver:U,commandSessionRef:W,abortControllerRef:Y,cachedOptions:c,setInput:l,setCursor:m,setShowEscHint:o,setMultiSelectionPage:_A,setSelectedCommandIndex:P,setMultiSelectionAnswers:x,setMultiSelectChoices:d,setSelectionFilter:e,setIsFilterMode:p,setSelectedFileIndex:HA,setPendingInput:BA,setPendingCommand:$A,addLog:KA,addMessage:vA,addAttachment:SA,setAttachmentTokenCount:wA,createCommandContext:iA,currentSessionId:UA,currentSession:yA,createSession:JA}=A;KB(async(VA,R)=>{if(R.escape&&g){if(Y.current)KA("[abort] Cancelling AI response..."),Y.current.abort(),Y.current=null;return}if(R.escape){let h=Date.now();if(h-M.current<500&&M.current>0){l(""),m(0),M.current=0,o(!1);return}if(D.length>0)o(!0),setTimeout(()=>{o(!1)},2000);M.current=h}if(a&&U.current){if(a.type==="selection"){let h=a.questions,i=h.length===1,IA=h[y],qA=h.length,kA=IA.options.filter((mA)=>mA.label.toLowerCase().includes(G.toLowerCase())||mA.value&&mA.value.toLowerCase().includes(G.toLowerCase())),ED=kA.length-1;if(R.downArrow){P((mA)=>mA<ED?mA+1:mA);return}if(R.upArrow){P((mA)=>mA>0?mA-1:0);return}if(R.escape&&(J||G.length>0)){if(J)p(!1),KA("[filter] Exited filter mode, filter text preserved");else if(G.length>0)e(""),P(0),KA("[filter] Cleared filter text");return}if(VA&&!R.return&&!R.escape&&!R.tab&&!R.ctrl){if(J||VA!==" "){e((mA)=>mA+VA),p(!0),P(0);return}}if(R.backspace||R.delete){if(G.length>0){if(e((mA)=>mA.slice(0,-1)),G.length===1)p(!1);P(0);return}}if(!i){if(R.tab&&!R.shift){_A((GD)=>(GD+1)%qA),P(0),e(""),p(!1);let mA=(y+1)%qA,WA=h[mA];if(WA.multiSelect)if(w[WA.id]){let GD=w[WA.id];d(new Set(Array.isArray(GD)?GD:[]))}else if(WA.preSelected)d(new Set(WA.preSelected));else d(new Set);else d(new Set);return}if(R.shift&&R.tab){_A((GD)=>(GD-1+qA)%qA),P(0),e(""),p(!1);let mA=(y-1+qA)%qA,WA=h[mA];if(WA.multiSelect)if(w[WA.id]){let GD=w[WA.id];d(new Set(Array.isArray(GD)?GD:[]))}else if(WA.preSelected)d(new Set(WA.preSelected));else d(new Set);else d(new Set);return}}if(!i&&R.ctrl&&R.return){if(h.every((WA)=>w[WA.id]))KA(`[selection] Submitting answers: ${JSON.stringify(w)}`),U.current(w),U.current=null,BA(null),_A(0),x({}),d(new Set),e(""),p(!1);else KA("[selection] Cannot submit: not all questions answered");return}if(VA===" "&&IA.multiSelect&&!J){let mA=kA[z];if(mA){let WA=mA.value||mA.label;d((GD)=>{let C_=new Set(GD);if(C_.has(WA))C_.delete(WA),KA(`[multi-select] Unchecked: ${WA}`);else C_.add(WA),KA(`[multi-select] Checked: ${WA}`);return C_})}return}if(R.return){if(IA.multiSelect){if(u.size===0){KA("[multi-select] No choices selected, skipping");return}let mA=Array.from(u);if(KA(`[multi-select] Q${y+1}: ${mA.join(", ")}`),!W.current)W.current=UA||JA("openrouter","anthropic/claude-3.5-sonnet");if(vA(W.current,"user",mA.join(", ")),i)U.current({[IA.id]:mA}),U.current=null,BA(null),_A(0),x({}),d(new Set),e(""),p(!1);else{let WA={...w,[IA.id]:mA};if(x(WA),d(new Set),h.every((C_)=>WA[C_.id]))KA(`[selection] All answered, auto-submitting: ${JSON.stringify(WA)}`),U.current(WA),U.current=null,BA(null),_A(0),x({}),e(""),p(!1);else{let C_=h.findIndex((cD,OD)=>OD>y&&!WA[cD.id]);if(C_!==-1)_A(C_);P(0),e("")}}}else{let mA=kA[z];if(mA){let WA=mA.value||mA.label;if(KA(`[selection] Q${y+1}: ${WA}`),!W.current)W.current=UA||JA("openrouter","anthropic/claude-3.5-sonnet");if(vA(W.current,"user",mA.label),i)U.current({[IA.id]:WA}),U.current=null,BA(null),_A(0),x({}),e(""),p(!1);else{let GD={...w,[IA.id]:WA};if(x(GD),h.every((cD)=>GD[cD.id]))KA(`[selection] All answered, auto-submitting: ${JSON.stringify(GD)}`),U.current(GD),U.current=null,BA(null),_A(0),x({}),e(""),p(!1);else{let cD=h.findIndex((OD,w_)=>w_>y&&!GD[OD.id]);if(cD!==-1)_A(cD);P(0),e("")}}}}return}if(R.escape){KA("[selection] Cancelled"),U.current({}),U.current=null,BA(null),_A(0),x({}),d(new Set),e(""),p(!1);return}}}if(Q&&!a){let h=Q.command.args?.[0],i=h?`${Q.command.id}:${h.name}`:"",IA=i?c.get(i)||[]:[],qA=IA.length-1;if(R.downArrow){P((kA)=>kA<qA?kA+1:kA);return}if(R.upArrow){P((kA)=>kA>0?kA-1:0);return}if(R.return){let kA=IA[z];if(kA){let ED=await Q.command.execute(iA([kA.id]));if(UA)vA(UA,"assistant",ED);$A(null),P(0)}return}if(R.escape){if(UA)vA(UA,"assistant","Command cancelled");$A(null),P(0);return}}if(I.hasAt&&I.files.length>0&&!a){if(R.downArrow){HA((h)=>h<I.files.length-1?h+1:h);return}if(R.upArrow){HA((h)=>h>0?h-1:0);return}if(R.tab||R.return){let h=I.files[q];if(h){SA({path:h.path,relativePath:h.relativePath,size:h.size}),(async()=>{try{let{readFile:ED}=await import("node:fs/promises"),{countTokens:mA}=await import("./chunk-585jp0rg.js"),WA=await ED(h.path,"utf8"),GD=await mA(WA,yA?.model);wA(h.path,GD)}catch(ED){console.error("Failed to count tokens:",ED)}})();let i=D.slice(0,I.atIndex),IA=D.slice(I.atIndex+1+I.query.length),qA=`${i}@${h.relativePath} ${IA}`,kA=i.length+h.relativePath.length+2;l(qA),m(kA),HA(0)}return}}else if(C.length>0&&!a){if(R.downArrow){P((h)=>h<C.length-1?h+1:h);return}if(R.upArrow){P((h)=>h>0?h-1:0);return}if(R.tab){let h=C[z];if(h){let IA=(await import("./chunk-2j2gmjg5.js").then((ED)=>ED.commands)).some((ED)=>ED.label===h.label),qA=h.args&&h.args.length>0,kA=IA&&qA?`${h.label} `:h.label;KA(`[useInput] Tab autocomplete fill: ${kA}`),l(kA),m(kA.length),P(0)}return}if(R.return){let h=C[z];if(h){if(X.current=!0,l(""),P(0),KA(`[useInput] Enter autocomplete execute: ${h.label}`),!W.current)W.current=UA||JA("openrouter","anthropic/claude-3.5-sonnet");vA(W.current,"user",h.label);let i=await h.execute(iA([]));if(i)vA(W.current,"assistant",i)}return}if(R.escape){l(""),P(0);return}}},{isActive:!0})}var bI=GA(KD(),1),SQ=new Map,p4=new Map,n4=new Map;function CqA(A,D,_){return`${A}:${D}:${_.substring(0,100)}`}function cj(A){let[D,_]=bI.useState(0),g=bI.useRef(0),a=bI.useRef(0),Q=bI.useRef(null),I=A?.id??null,C=A?.messages.length??0,y=A?.model??"";return bI.useEffect(()=>{if(!A||!I){_(0),g.current=0,a.current=0,Q.current=null;return}if(Q.current!==I)g.current=0,a.current=0,Q.current=I;(async()=>{try{let{countTokens:u}=await import("./chunk-585jp0rg.js"),{SYSTEM_PROMPT:G}=await import("./chunk-9qzv4trv.js"),{getAISDKTools:J}=await import("./chunk-weshapwk.js"),z=0,q=`system:${A.model}`;if(p4.has(q))z+=p4.get(q);else{let Y=await u(G,A.model);p4.set(q,Y),z+=Y}let X=`tools:${A.model}`;if(n4.has(X))z+=n4.get(X);else{let Y=J(),c=JSON.stringify(Y),l=await u(c,A.model);n4.set(X,l),z+=l}let M=A.messages.length;if(M===g.current){_(a.current);return}if(g.current>0)z+=a.current-(p4.get(q)||0)-(n4.get(X)||0);let U=A.messages.slice(g.current),W=g.current;for(let Y=0;Y<U.length;Y++){let c=U[Y],l=W+Y,m="";if(c.content&&Array.isArray(c.content))m=c.content.filter((_A)=>_A.type==="text").map((_A)=>_A.content).join(`
|
|
433
|
-
`);else if(c.content)m=String(c.content);let o=CqA(A.id,l,m);if(SQ.has(o))z+=SQ.get(o);else{let _A=await u(m,A.model);SQ.set(o,_A),z+=_A}if(c.attachments&&c.attachments.length>0)for(let _A of c.attachments)try{let P=`${A.id}:${l}:att:${_A.path}`;if(SQ.has(P))z+=SQ.get(P);else{let{readFile:x}=await import("node:fs/promises"),d=await x(_A.path,"utf8"),e=await u(d,A.model);SQ.set(P,e),z+=e}}catch(P){}}if(g.current=M,a.current=z,_(z),SQ.size>1e4){let Y=Array.from(SQ.entries());SQ.clear(),Y.slice(-5000).forEach(([c,l])=>SQ.set(c,l))}}catch(u){console.error("Failed to calculate token usage:",u)}})()},[I,C,y]),D}var $8=GA(KD(),1);function bj(){let[A,D]=$8.useState([]),[_,g]=$8.useState(!1);return $8.useEffect(()=>{(async()=>{g(!0);try{let Q=await fR(process.cwd());D(Q)}catch(Q){console.error("Failed to load project files:",Q)}finally{g(!1)}})()},[]),{projectFiles:A,filesLoading:_}}var hj=GA(KD(),1);function lj({setPendingInput:A,setMultiSelectionPage:D,setMultiSelectionAnswers:_,setSelectionFilter:g,setSelectedCommandIndex:a,setAskQueueLength:Q,inputResolver:I,addDebugLog:C}){hj.useEffect(()=>{return n6((y)=>{return new Promise((w)=>{C(`[ask tool] Waiting for user selection (${y.questions.length} question${y.questions.length>1?"s":""})`),I.current=w,A(y),D(0),_({}),g(""),a(0)})}),Tj((y)=>{Q(y)}),()=>{o6()}},[C,A,D,_,g,a,Q,I])}var Sj=GA(KD(),1);function mj({currentSessionId:A,aiConfig:D,createSession:_}){Sj.useEffect(()=>{if(!A&&D?.defaultProvider&&D?.defaultModel)_(D.defaultProvider,D.defaultModel)},[A,D,_])}function o4(A,D,_=10){let g=Math.max(0,Math.min(D-Math.floor(_/2),A.length-_)),a=A.slice(g,g+_),Q=g>0,I=g+_<A.length,C=g,y=A.length-g-_;return{visibleItems:a,scrollOffset:g,hasItemsAbove:Q,hasItemsBelow:I,itemsAboveCount:C,itemsBelowCount:y}}var _D=GA(YD(),1);function jj({pendingInput:A,multiSelectionPage:D,multiSelectionAnswers:_,multiSelectChoices:g,selectionFilter:a,isFilterMode:Q,selectedCommandIndex:I,askQueueLength:C}){if(A.type!=="selection")return null;let y=A.questions,w=y.length===1,u=y[D],G=Object.keys(_).length,J=y.length,z=y.every((q)=>_[q.id]);return _D.jsxDEV(j,{flexDirection:"column",children:[A.prompt&&_D.jsxDEV(j,{marginBottom:1,children:_D.jsxDEV($,{dimColor:!0,children:A.prompt},void 0,!1,void 0,this)},void 0,!1,void 0,this),C>0&&_D.jsxDEV(j,{marginBottom:1,children:_D.jsxDEV($,{color:"#FFD700",children:["[+",C," pending]"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),!w&&_D.jsxDEV(j,{marginBottom:1,children:[_D.jsxDEV($,{color:"#00D9FF",children:"Progress: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00FF88",bold:!0,children:[G,"/",J]},void 0,!0,void 0,this),_D.jsxDEV($,{dimColor:!0,children:" completed"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y.map((q,X)=>{let M=X===D,U=_[q.id],W=U?q.options.find((Y)=>(Y.value||Y.label)===U):null;return _D.jsxDEV(j,{marginBottom:1,flexDirection:"column",children:[_D.jsxDEV(j,{children:[!w&&_D.jsxDEV($,{color:"#00D9FF",children:["Q",X+1,". "]},void 0,!0,void 0,this),_D.jsxDEV($,{bold:M,color:M?"#00D9FF":"gray",children:q.question},void 0,!1,void 0,this),M&&!w&&_D.jsxDEV($,{color:"#00FF88",children:" ← "},void 0,!1,void 0,this)]},void 0,!0,void 0,this),M?_D.jsxDEV(j,{marginLeft:4,flexDirection:"column",marginTop:1,children:[_D.jsxDEV(j,{marginBottom:1,children:[_D.jsxDEV($,{dimColor:!0,children:"\uD83D\uDD0D "},void 0,!1,void 0,this),Q?_D.jsxDEV(_D.Fragment,{children:[_D.jsxDEV($,{color:"#00FF88",children:a},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00FF88",children:"▊"},void 0,!1,void 0,this),_D.jsxDEV($,{dimColor:!0,children:" (Esc to exit, type to continue)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):a?_D.jsxDEV(_D.Fragment,{children:[_D.jsxDEV($,{color:"#00D9FF",children:a},void 0,!1,void 0,this),_D.jsxDEV($,{dimColor:!0,children:" (type to edit, Esc to clear)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):_D.jsxDEV($,{dimColor:!0,children:"(type to filter)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),(()=>{if(!q.options||!Array.isArray(q.options))return _D.jsxDEV(j,{children:[_D.jsxDEV($,{color:"red",children:"⚠ Error: No options available for this question"},void 0,!1,void 0,this),_D.jsxDEV($,{dimColor:!0,children:["Question data: ",JSON.stringify(q)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);let Y=q.options.filter((l)=>l.label.toLowerCase().includes(a.toLowerCase())||l.value&&l.value.toLowerCase().includes(a.toLowerCase()));if(Y.length===0)return _D.jsxDEV($,{color:"yellow",children:"⚠ No matches found"},void 0,!1,void 0,this);let c=o4(Y,I);return _D.jsxDEV(_D.Fragment,{children:[c.hasItemsAbove&&_D.jsxDEV(j,{marginBottom:1,children:_D.jsxDEV($,{dimColor:!0,children:["... ",c.itemsAboveCount," more above"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),c.visibleItems.map((l,m)=>{let o=c.scrollOffset+m,_A=l.value||l.label,P=q.multiSelect&&g.has(_A),x=o===I?"▶ ":" ",d=q.multiSelect?P?"[✓] ":"[ ] ":"";return _D.jsxDEV(j,{paddingY:0,children:_D.jsxDEV($,{color:o===I?"#00FF88":"gray",bold:o===I,children:[x,d,l.label]},void 0,!0,void 0,this)},l.value||l.label,!1,void 0,this)}),c.hasItemsBelow&&_D.jsxDEV(j,{marginTop:1,children:_D.jsxDEV($,{dimColor:!0,children:["... ",c.itemsBelowCount," more below"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)})()]},void 0,!0,void 0,this):_D.jsxDEV(j,{marginLeft:4,children:U?_D.jsxDEV(_D.Fragment,{children:[_D.jsxDEV($,{color:"#00FF88",children:"✓ "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00FF88",children:Array.isArray(U)?U.join(", "):W?.label||U},void 0,!1,void 0,this)]},void 0,!0,void 0,this):_D.jsxDEV($,{dimColor:!0,children:"(not answered yet)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},q.id,!0,void 0,this)}),_D.jsxDEV(j,{marginTop:1,flexDirection:"column",children:_D.jsxDEV(j,{children:[!w&&!Q&&_D.jsxDEV(_D.Fragment,{children:[_D.jsxDEV($,{dimColor:!0,children:"Tab: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00D9FF",children:"Next"},void 0,!1,void 0,this),_D.jsxDEV($,{dimColor:!0,children:" · Shift+Tab: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00D9FF",children:"Previous"},void 0,!1,void 0,this),_D.jsxDEV($,{dimColor:!0,children:" · "},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_D.jsxDEV($,{dimColor:!0,children:"↑↓: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00D9FF",children:"Navigate"},void 0,!1,void 0,this),!Q&&y[D]?.multiSelect?_D.jsxDEV(_D.Fragment,{children:[_D.jsxDEV($,{dimColor:!0,children:" · Space: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00FF88",children:"Toggle"},void 0,!1,void 0,this),_D.jsxDEV($,{dimColor:!0,children:" · Enter: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:g.size>0?"#00FF88":"gray",children:["Confirm",g.size===0&&" (select at least one)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):!Q?_D.jsxDEV(_D.Fragment,{children:[_D.jsxDEV($,{dimColor:!0,children:" · Enter: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00FF88",children:"Select"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):_D.jsxDEV(_D.Fragment,{children:[_D.jsxDEV($,{dimColor:!0,children:" · Space/Type: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00FF88",children:"Filter"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!w&&!Q&&_D.jsxDEV(_D.Fragment,{children:[_D.jsxDEV($,{dimColor:!0,children:" · "},void 0,!1,void 0,this),_D.jsxDEV($,{dimColor:!0,children:"Ctrl+Enter: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:z?"#00FF88":"gray",children:["Submit",!z&&" (answer all first)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),_D.jsxDEV($,{dimColor:!0,children:" · Esc: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#FF3366",children:Q?"Exit filter":a?"Clear filter":"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var x_=GA(YD(),1);function ij({pendingCommand:A,currentlyLoading:D,loadError:_,cachedOptions:g,selectedCommandIndex:a,onSelect:Q}){return x_.jsxDEV(j,{flexDirection:"column",children:[x_.jsxDEV(j,{marginBottom:1,children:x_.jsxDEV($,{dimColor:!0,children:["Select ",A.command.args?.[0]?.name||"option",":"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),D?x_.jsxDEV(j,{children:[x_.jsxDEV(UB,{color:"#FFD700"},void 0,!1,void 0,this),x_.jsxDEV($,{color:"gray",children:" Loading options..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):_?x_.jsxDEV(j,{flexDirection:"column",children:[x_.jsxDEV(j,{marginBottom:1,children:x_.jsxDEV($,{color:"red",children:"Failed to load options"},void 0,!1,void 0,this)},void 0,!1,void 0,this),x_.jsxDEV(j,{marginBottom:1,children:x_.jsxDEV($,{dimColor:!0,children:_},void 0,!1,void 0,this)},void 0,!1,void 0,this),x_.jsxDEV(j,{children:x_.jsxDEV($,{dimColor:!0,children:"Press Esc to cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):(()=>{let I=A.command.args?.[0],C=I?`${A.command.id}:${I.name}`:"",y=C?g.get(C)||[]:[];if(y.length===0)return x_.jsxDEV(j,{flexDirection:"column",children:[x_.jsxDEV(j,{marginBottom:1,children:x_.jsxDEV($,{color:"yellow",children:"No options available"},void 0,!1,void 0,this)},void 0,!1,void 0,this),x_.jsxDEV(j,{children:x_.jsxDEV($,{dimColor:!0,children:"Press Esc to cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let w=o4(y,a);return x_.jsxDEV(x_.Fragment,{children:[w.hasItemsAbove&&x_.jsxDEV(j,{marginBottom:1,children:x_.jsxDEV($,{dimColor:!0,children:["... ",w.itemsAboveCount," more above"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),w.visibleItems.map((u,G)=>{let J=w.scrollOffset+G;return x_.jsxDEV(j,{paddingY:0,onClick:()=>Q(u),children:x_.jsxDEV($,{color:J===a?"#00FF88":"gray",bold:J===a,children:[J===a?"> ":" ",u.label]},void 0,!0,void 0,this)},u.value||u.label,!1,void 0,this)}),w.hasItemsBelow&&x_.jsxDEV(j,{marginTop:1,children:x_.jsxDEV($,{dimColor:!0,children:["... ",w.itemsBelowCount," more below"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),x_.jsxDEV(j,{marginTop:1,children:x_.jsxDEV($,{dimColor:!0,children:"↑↓ Navigate · Enter 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)}var hE=GA(YD(),1);function xj({files:A,selectedFileIndex:D,filesLoading:_}){if(_)return hE.jsxDEV(j,{marginTop:1,children:[hE.jsxDEV(UB,{color:"#FFD700"},void 0,!1,void 0,this),hE.jsxDEV($,{color:"gray",children:" Loading files..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(A.length===0)return null;return hE.jsxDEV(j,{flexDirection:"column",marginTop:1,children:[hE.jsxDEV(j,{marginBottom:1,children:hE.jsxDEV($,{dimColor:!0,children:"Files (↑↓ to select, Tab/Enter to attach):"},void 0,!1,void 0,this)},void 0,!1,void 0,this),A.map((g,a)=>hE.jsxDEV(j,{marginLeft:2,children:hE.jsxDEV($,{color:a===D?"#00FF88":"gray",bold:a===D,children:[a===D?"> ":" ",g.relativePath]},void 0,!0,void 0,this)},g.path,!1,void 0,this))]},void 0,!0,void 0,this)}var ra=GA(YD(),1);function dj({commands:A,selectedCommandIndex:D,currentlyLoading:_,loadError:g}){if(_)return ra.jsxDEV(j,{marginTop:1,children:[ra.jsxDEV(UB,{color:"#FFD700"},void 0,!1,void 0,this),ra.jsxDEV($,{color:"gray",children:" Loading options..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(g)return ra.jsxDEV(j,{flexDirection:"column",marginTop:1,children:[ra.jsxDEV(j,{children:ra.jsxDEV($,{color:"red",children:"Failed to load options"},void 0,!1,void 0,this)},void 0,!1,void 0,this),ra.jsxDEV(j,{marginTop:1,children:ra.jsxDEV($,{dimColor:!0,children:g},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(A.length===0)return null;let a=5,Q=A.length,I=Math.max(0,D-Math.floor(a/2)),C=Math.min(Q,I+a);if(C===Q)I=Math.max(0,C-a);let y=A.slice(I,C);return ra.jsxDEV(j,{flexDirection:"column",marginTop:1,children:[I>0&&ra.jsxDEV(j,{children:ra.jsxDEV($,{dimColor:!0,children:[" ↑ ",I," more above"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),y.map((w,u)=>{let G=I+u;return ra.jsxDEV(j,{children:[ra.jsxDEV($,{color:G===D?"#00FF88":"gray",bold:G===D,children:[G===D?"> ":" ",w.label]},void 0,!0,void 0,this),w.description&&ra.jsxDEV($,{dimColor:!0,children:[" ",w.description]},void 0,!0,void 0,this)]},w.id,!0,void 0,this)}),C<Q&&ra.jsxDEV(j,{children:ra.jsxDEV($,{dimColor:!0,children:[" ↓ ",Q-C," more below"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var TA=GA(YD(),1);function tH({commandFromPalette:A}){let[D,_]=pD.useState(""),[g,a]=pD.useState(0),[Q,I]=pD.useState(!1),[C,y]=pD.useState([]),[w,u]=pD.useState(!1),[G,J]=pD.useState(""),z=pD.useRef(null),q=pD.useRef({chunks:[],timeout:null}),X=sA((T)=>T.debugLogs),M=sA((T)=>T.addDebugLog),[U,W]=pD.useState(!1),[Y,c]=pD.useState(!1),[l,m]=pD.useState(0),[o,_A]=pD.useState(null),P=pD.useRef(!1),x=pD.useRef(0),[d,e]=pD.useState(!1),{pendingAttachments:p,attachmentTokens:HA,validTags:BA,addAttachment:$A,clearAttachments:KA,setAttachmentTokenCount:vA}=wR(D),{projectFiles:SA,filesLoading:wA}=bj(),[iA,UA]=pD.useState(0),[yA,JA]=pD.useState(null),VA=pD.useRef(null),[R,h]=pD.useState(""),[i,IA]=pD.useState(!1),[qA,kA]=pD.useState(0),[ED,mA]=pD.useState({}),[WA,GD]=pD.useState(new Set),[C_,cD]=pD.useState(0),OD=(T)=>{M(T)},w_=sA((T)=>T.navigateTo),R_=sA((T)=>T.aiConfig),bD=sA((T)=>T.currentSessionId),DD=sA((T)=>T.createSession),Fg=sA((T)=>T.updateSessionModel),B_=sA((T)=>T.updateSessionProvider),X_=sA((T)=>T.updateSessionTitle),Va=sA((T)=>T.updateProvider),Dg=sA((T)=>T.setAIConfig),d_=sA((T)=>T.setCurrentSession),O_=sA((T)=>T.addMessage),ID=sA((T)=>T.setSelectedProvider),yD=sA((T)=>T.setSelectedModel),XD=sA((T)=>T.updateNotificationSettings),$D=sA((T)=>T.notificationSettings),$_=sA((T)=>T.sessions),{sendMessage:Tg,currentSession:dD}=DR(),{saveConfig:Ia}=LI(),Pa=cj(dD);mj({currentSessionId:bD,aiConfig:R_,createSession:DD}),lj({setPendingInput:JA,setMultiSelectionPage:kA,setMultiSelectionAnswers:mA,setSelectionFilter:h,setSelectedCommandIndex:m,setAskQueueLength:cD,inputResolver:VA,addDebugLog:M});let[ca,ba]=pD.useState(new Map),[ug,Zg]=pD.useState(null),[vg,l0]=pD.useState(null),S_=pD.useRef(null),Wa=(T)=>({args:T,sendMessage:(b)=>{if(!S_.current)S_.current=bD||DD("openrouter","anthropic/claude-3.5-sonnet");O_(S_.current,"assistant",b)},triggerAIResponse:async(b,r)=>{_(""),await S0(b,r)},waitForInput:(b)=>{return new Promise((r)=>{if(OD(`[waitForInput] Waiting for ${b.type} input`),VA.current=r,JA(b),b.type==="selection"){kA(0),mA({});let QA=b.questions[0];if(QA?.multiSelect&&QA.preSelected)GD(new Set(QA.preSelected));else GD(new Set);m(0),h(""),IA(!1)}})},getConfig:()=>sA.getState().aiConfig,saveConfig:(b)=>Ia(b),getCurrentSession:()=>dD,updateProvider:(b,r)=>Va(b,r),setAIConfig:(b)=>Dg(b),updateSessionModel:(b,r)=>Fg(b,r),updateSessionProvider:(b,r,QA)=>B_(b,r,QA),setUISelectedProvider:(b)=>ID(b),setUISelectedModel:(b)=>yD(b),createSession:(b,r)=>DD(b,r),getSessions:()=>$_,getCurrentSessionId:()=>bD,setCurrentSession:(b)=>d_(b),navigateTo:(b)=>w_(b),addLog:(b)=>OD(b),notificationSettings:$D,updateNotificationSettings:(b)=>XD(b),updateOutput:(b)=>OD(b)}),oB=()=>{if(!D.startsWith("/"))return;let T=D.split(" "),b=T[0],r=Rw.find((QA)=>QA.label===b);if(r&&r.args&&r.args.length>0){let n=T.slice(1).filter((ZA)=>ZA.trim()!=="").length;if(n<r.args.length){let ZA=r.args[n];return ZA.required?`[${ZA.name}]`:`<${ZA.name}>`}}return};pD.useEffect(()=>{l0(null)},[D]),pD.useEffect(()=>{if(!D.startsWith("/"))return;let T=D.split(" "),b=T[0],r=Rw.find((QA)=>QA.label===b);if(r&&r.args&&T.length>1){let QA=T.slice(1).filter((wD)=>wD.trim()!==""),pA=T[T.length-1]===""?QA.length:Math.max(0,QA.length-1),uD=r.args[pA];if(uD&&uD.loadOptions){let wD=`${r.id}:${uD.name}:${QA.join(",")}`;if(!ca.has(wD)&&ug!==wD){Zg(wD);let N_=Wa([]);uD.loadOptions(QA,N_).then((ND)=>{ba((TD)=>new Map(TD).set(wD,ND)),Zg(null)}).catch((ND)=>{let TD=ND instanceof Error?ND.message:String(ND);OD(`Error loading ${wD}: ${TD}`),l0(TD),Zg(null)})}}}},[D,ug]);let Ga=pD.useMemo(()=>{let T=D.slice(0,g),b=T.lastIndexOf("@");if(b===-1)return{files:[],query:"",hasAt:!1,atIndex:-1};if(b>0){let n=T[b-1];if(!/\s/.test(n))return{files:[],query:"",hasAt:!1,atIndex:b}}let r=T.slice(b+1);if(r.includes(" "))return{files:[],query:"",hasAt:!1,atIndex:b};return{files:yR(SA,r).slice(0,10),query:r,hasAt:!0,atIndex:b}},[D,g,SA]),ng=pD.useMemo(()=>{if(!D.startsWith("/"))return[];let T=D.split(" "),b=T[0],r=Rw.find((n)=>n.label===b);if(r&&r.args&&T.length>1){let n=T.slice(1).filter((ND)=>ND.trim()!==""),ZA=T[T.length-1],pA=ZA==="",uD=pA?n.length:Math.max(0,n.length-1),wD=pA?"":ZA,N_=r.args[uD];if(N_){let ND=`${r.id}:${N_.name}:${n.join(",")}`,TD=ca.get(ND)||[];if(TD.length>0)return TD.filter((jD)=>jD.label.toLowerCase().includes(wD.toLowerCase())||jD.value&&jD.value.toLowerCase().includes(wD.toLowerCase())).map((jD)=>{let tD=pA?[...n,jD.value||jD.label]:[...n.slice(0,-1),jD.value||jD.label];return{id:`${ND}-${jD.value||jD.label}`,label:`${b} ${tD.join(" ")}`,description:"",args:r.args,execute:async(hD)=>{return await r.execute(Wa(tD))}}})}}let QA=D.slice(1).toLowerCase();return Rw.filter((n)=>n.label.toLowerCase().includes(`/${QA}`)||n.description.toLowerCase().includes(QA))},[D,ca]),Ca=pD.useMemo(()=>oB(),[D]);Pj({input:D,cursor:g,isStreaming:Q,pendingInput:yA,pendingCommand:o,filteredFileInfo:Ga,filteredCommands:ng,multiSelectionPage:qA,multiSelectionAnswers:ED,multiSelectChoices:WA,selectionFilter:R,isFilterMode:i,selectedCommandIndex:l,selectedFileIndex:iA,skipNextSubmit:P,lastEscapeTime:x,inputResolver:VA,commandSessionRef:S_,abortControllerRef:z,cachedOptions:ca,setInput:_,setCursor:a,setShowEscHint:e,setMultiSelectionPage:kA,setSelectedCommandIndex:m,setMultiSelectionAnswers:mA,setMultiSelectChoices:GD,setSelectionFilter:h,setIsFilterMode:IA,setSelectedFileIndex:UA,setPendingInput:JA,setPendingCommand:_A,addLog:OD,addMessage:O_,addAttachment:$A,setAttachmentTokenCount:vA,createCommandContext:Wa,currentSessionId:bD,currentSession:dD,createSession:DD}),pD.useEffect(()=>{m(0)},[ng.length]),pD.useEffect(()=>{UA(0)},[Ga.files.length]);let S0=pD.useCallback(async(T,b)=>{if(!R_?.defaultProvider||!R_?.defaultModel){if(bD)O_(bD,"user",T,b),O_(bD,"assistant","No AI provider configured. Use /provider to configure a provider first.");return}I(!0),y([]),OD("Starting message send..."),z.current=new AbortController;let r=()=>{let QA=q.current;if(QA.chunks.length===0)return;let n=QA.chunks.join("");QA.chunks=[],y((ZA)=>{let pA=[...ZA],uD=pA[pA.length-1];if(uD&&uD.type==="text")pA[pA.length-1]={type:"text",content:uD.content+n};else pA.push({type:"text",content:n});return pA})};try{await Tg(T,(QA)=>{if(q.current.chunks.push(QA),q.current.timeout)clearTimeout(q.current.timeout);q.current.timeout=setTimeout(()=>{r(),q.current.timeout=null},50)},(QA,n,ZA)=>{y((pA)=>[...pA,{type:"tool",toolId:QA,name:n,status:"running",args:ZA,startTime:Date.now()}])},(QA,n,ZA,pA)=>{y((uD)=>uD.map((wD)=>wD.type==="tool"&&wD.toolId===QA?{...wD,status:"completed",duration:pA,result:ZA}:wD))},async()=>{if(q.current.timeout)clearTimeout(q.current.timeout),q.current.timeout=null;if(r(),I(!1),y([]),bD){let n=sA.getState().sessions.find((ZA)=>ZA.id===bD);if(n){let ZA=n.messages.filter((wD)=>wD.role==="user").length,pA=!!n.title&&n.title!=="New Chat";if(ZA===1&&!pA){let{generateSessionTitleWithStreaming:wD}=await import("./chunk-e74zv5ct.js"),N_=n.provider,ND=n.model,TD=R_?.providers?.[N_];if(TD){u(!0),J("");try{let jD=await wD(T,N_,ND,TD,(tD)=>{J((hD)=>hD+tD)});u(!1),X_(bD,jD)}catch(jD){if(process.env.DEBUG)OD(`[Title] Error: ${jD instanceof Error?jD.message:"Unknown"}`);u(!1);let{generateSessionTitle:tD}=await import("./chunk-e74zv5ct.js"),hD=tD(T);X_(bD,hD)}}}}}},void 0,b,()=>{y((QA)=>[...QA,{type:"reasoning",content:"",startTime:Date.now()}])},(QA)=>{y((n)=>{let ZA=[...n],pA=ZA[ZA.length-1];if(pA&&pA.type==="reasoning")ZA[ZA.length-1]={...pA,content:pA.content+QA};return ZA})},(QA)=>{y((n)=>{let ZA=[...n],pA=ZA[ZA.length-1];if(pA&&pA.type==="reasoning")ZA[ZA.length-1]={...pA,completed:!0,duration:QA};return ZA})},(QA,n,ZA,pA)=>{y((uD)=>uD.map((wD)=>wD.type==="tool"&&wD.toolId===QA?{...wD,status:"failed",error:ZA,duration:pA}:wD))},(QA)=>{y((n)=>[...n,{type:"error",error:QA}])},z.current.signal)}catch(QA){OD(`[sendUserMessageToAI] Error: ${QA instanceof Error?QA.message:String(QA)}`),I(!1),y([])}},[R_,bD,Tg,O_,OD,X_,$D]),JQ=pD.useCallback(async(T)=>{if(!T.trim())return;if(Q)return;if(yA&&yA.type==="text"&&VA.current){if(OD(`[handleSubmit] Resolving text input: ${T}`),!S_.current)S_.current=bD||DD("openrouter","anthropic/claude-3.5-sonnet");O_(S_.current,"user",T.trim()),VA.current(T.trim()),VA.current=null,JA(null),_("");return}if(T.startsWith("/")&&ng.length>0){OD(`[handleSubmit] Skipping, autocomplete active (${ng.length} suggestions)`);return}if(P.current){OD(`[handleSubmit] Skipping due to skipNextSubmit flag: ${T}`),P.current=!1;return}OD(`[handleSubmit] Processing: ${T}`);let b=T.trim();if(b.startsWith("/")){let QA=b.split(" "),n=QA[0],ZA=QA.slice(1),pA=Rw.find((uD)=>uD.label===n);if(!pA){if(_(""),!S_.current)S_.current=bD||DD("openrouter","anthropic/claude-3.5-sonnet");O_(S_.current,"user",b),O_(S_.current,"assistant",`Unknown command: ${n}. Type /help for available commands.`);return}if(_(""),!S_.current)S_.current=bD||DD("openrouter","anthropic/claude-3.5-sonnet");O_(S_.current,"user",b);try{let uD=await pA.execute(Wa(ZA));if(uD)O_(S_.current,"assistant",uD)}catch(uD){O_(S_.current,"assistant",`Error: ${uD instanceof Error?uD.message:"Command failed"}`)}_A(null);return}_("");let r=[...p];KA(),await S0(b,r)},[Q,yA,VA,S_,bD,DD,O_,ng,P,OD,KA,p,_,S0]);return TA.jsxDEV(j,{flexDirection:"row",flexGrow:1,children:TA.jsxDEV(j,{flexDirection:"column",flexGrow:1,width:"70%",children:[TA.jsxDEV(j,{flexShrink:0,children:[TA.jsxDEV($,{color:"#00D9FF",children:"▌ CHAT"},void 0,!1,void 0,this),dD&&TA.jsxDEV(TA.Fragment,{children:[TA.jsxDEV($,{color:"#00D9FF",children:" · "},void 0,!1,void 0,this),w?TA.jsxDEV(TA.Fragment,{children:[TA.jsxDEV($,{color:"white",children:G},void 0,!1,void 0,this),TA.jsxDEV($,{color:"#FFD700",children:"▊"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):TA.jsxDEV($,{color:"white",children:dD.title||"New Chat"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),TA.jsxDEV(j,{flexDirection:"column",flexGrow:!dD||dD.messages.length===0&&!Q?0:1,minHeight:0,children:!dD?TA.jsxDEV(j,{paddingY:1,flexDirection:"column",children:[TA.jsxDEV(j,{paddingBottom:2,children:[TA.jsxDEV($,{color:"#00D9FF",children:"▌"},void 0,!1,void 0,this),TA.jsxDEV($,{bold:!0,color:"white",children:" WELCOME"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),TA.jsxDEV(j,{paddingBottom:1,children:TA.jsxDEV($,{dimColor:!0,children:"No AI provider configured yet."},void 0,!1,void 0,this)},void 0,!1,void 0,this),TA.jsxDEV(j,{paddingBottom:1,children:TA.jsxDEV($,{dimColor:!0,children:"Configure a provider to start chatting:"},void 0,!1,void 0,this)},void 0,!1,void 0,this),TA.jsxDEV(j,{paddingLeft:2,paddingBottom:1,children:[TA.jsxDEV($,{color:"#00D9FF",children:"/provider"},void 0,!1,void 0,this),TA.jsxDEV($,{dimColor:!0,children:" - Manage AI providers"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),TA.jsxDEV(j,{paddingLeft:2,paddingBottom:1,children:[TA.jsxDEV($,{color:"#00D9FF",children:"/help"},void 0,!1,void 0,this),TA.jsxDEV($,{dimColor:!0,children:" - Show all available commands"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):dD.messages.length===0&&!Q?null:TA.jsxDEV(j,{flexDirection:"column",children:[dD.messages.map((T,b)=>TA.jsxDEV(j,{paddingTop:1,flexDirection:"column",children:T.role==="user"?TA.jsxDEV(TA.Fragment,{children:[TA.jsxDEV(j,{children:TA.jsxDEV($,{color:"#00D9FF",children:"▌ YOU"},void 0,!1,void 0,this)},void 0,!1,void 0,this),T.content&&Array.isArray(T.content)?T.content.map((r,QA)=>TA.jsxDEV(r4,{part:r},QA,!1,void 0,this)):TA.jsxDEV(j,{marginLeft:2,children:TA.jsxDEV($,{children:String(T.content||"")},void 0,!1,void 0,this)},void 0,!1,void 0,this),T.attachments&&T.attachments.length>0?TA.jsxDEV(j,{flexDirection:"column",marginTop:1,children:T.attachments.map((r,QA)=>TA.jsxDEV(j,{marginLeft:2,children:[TA.jsxDEV($,{dimColor:!0,children:"Attached("},void 0,!1,void 0,this),TA.jsxDEV($,{color:"#00D9FF",children:r.relativePath},void 0,!1,void 0,this),TA.jsxDEV($,{dimColor:!0,children:")"},void 0,!1,void 0,this),HA.has(r.path)&&TA.jsxDEV(TA.Fragment,{children:[TA.jsxDEV($,{dimColor:!0,children:" "},void 0,!1,void 0,this),TA.jsxDEV($,{dimColor:!0,children:[sH(HA.get(r.path))," Tokens"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},QA,!0,void 0,this))},void 0,!1,void 0,this):null]},void 0,!0,void 0,this):TA.jsxDEV(TA.Fragment,{children:[TA.jsxDEV(j,{children:TA.jsxDEV($,{color:"#00FF88",children:"▌ SYLPHX"},void 0,!1,void 0,this)},void 0,!1,void 0,this),T.content&&Array.isArray(T.content)?T.content.map((r,QA)=>TA.jsxDEV(r4,{part:r},QA,!1,void 0,this)):TA.jsxDEV(j,{marginLeft:2,children:TA.jsxDEV($,{children:String(T.content||"")},void 0,!1,void 0,this)},void 0,!1,void 0,this),T.usage&&TA.jsxDEV(j,{marginLeft:2,children:TA.jsxDEV($,{dimColor:!0,children:[T.usage.promptTokens.toLocaleString()," → ",T.usage.completionTokens.toLocaleString()]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},b,!1,void 0,this)),Q&&TA.jsxDEV(j,{paddingTop:1,flexDirection:"column",children:[TA.jsxDEV(j,{children:TA.jsxDEV($,{color:"#00FF88",children:"▌ SYLPHX"},void 0,!1,void 0,this)},void 0,!1,void 0,this),C.length===0&&TA.jsxDEV(j,{marginLeft:2,children:[TA.jsxDEV(UB,{color:"#FFD700"},void 0,!1,void 0,this),TA.jsxDEV($,{dimColor:!0,children:" Thinking..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),C.map((T,b)=>{let r=b===C.length-1,QA=T.type==="tool"?`tool-${T.toolId}`:T.type==="reasoning"?`reasoning-${T.startTime}`:`${T.type}-${b}`;return TA.jsxDEV(r4,{part:T,isLastInStream:r&&T.type==="text"},QA,!1,void 0,this)})]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),TA.jsxDEV(EG,{},void 0,!1,void 0,this),TA.jsxDEV(j,{flexDirection:"column",flexShrink:0,paddingTop:1,children:[TA.jsxDEV(j,{children:TA.jsxDEV($,{color:"#00D9FF",children:"▌ YOU"},void 0,!1,void 0,this)},void 0,!1,void 0,this),yA&&yA.type==="selection"?TA.jsxDEV(jj,{pendingInput:yA,multiSelectionPage:qA,multiSelectionAnswers:ED,multiSelectChoices:WA,selectionFilter:R,isFilterMode:i,selectedCommandIndex:l,askQueueLength:C_},void 0,!1,void 0,this):o?TA.jsxDEV(ij,{pendingCommand:o,currentlyLoading:ug,loadError:vg,cachedOptions:ca,selectedCommandIndex:l,onSelect:async(T)=>{let b=await o.command.execute(Wa([T.value||T.label]));if(bD)O_(bD,"assistant",b);_A(null),m(0)}},void 0,!1,void 0,this):Q?TA.jsxDEV(j,{flexDirection:"column",children:[TA.jsxDEV($,{dimColor:!0,children:"Waiting for response..."},void 0,!1,void 0,this),TA.jsxDEV(j,{marginTop:1,children:TA.jsxDEV($,{color:"yellow",children:"Press ESC to cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):TA.jsxDEV(TA.Fragment,{children:[p.length>0?TA.jsxDEV(j,{flexDirection:"column",marginBottom:1,children:[TA.jsxDEV(j,{marginBottom:1,children:TA.jsxDEV($,{dimColor:!0,children:["Attachments (",p.length,"):"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),p.map((T,b)=>TA.jsxDEV(j,{marginLeft:2,children:[TA.jsxDEV($,{color:"#00D9FF",children:T.relativePath},void 0,!1,void 0,this),TA.jsxDEV($,{dimColor:!0,children:" ("},void 0,!1,void 0,this),T.size?TA.jsxDEV(TA.Fragment,{children:[TA.jsxDEV($,{dimColor:!0,children:[(T.size/1024).toFixed(1),"KB"]},void 0,!0,void 0,this),HA.has(T.path)&&TA.jsxDEV($,{dimColor:!0,children:", "},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,HA.has(T.path)?TA.jsxDEV($,{dimColor:!0,children:[sH(HA.get(T.path))," Tokens"]},void 0,!0,void 0,this):null,TA.jsxDEV($,{dimColor:!0,children:")"},void 0,!1,void 0,this)]},b,!0,void 0,this))]},void 0,!0,void 0,this):null,yA?.type==="text"&&yA.prompt&&TA.jsxDEV(j,{marginBottom:1,children:TA.jsxDEV($,{dimColor:!0,children:yA.prompt},void 0,!1,void 0,this)},void 0,!1,void 0,this),TA.jsxDEV(j,{marginLeft:2,children:TA.jsxDEV(hv,{value:yA?.type==="selection"?R:D,onChange:yA?.type==="selection"?(T)=>{h(T),m(0)}:_,cursor:yA?.type==="selection"?void 0:g,onCursorChange:yA?.type==="selection"?void 0:a,onSubmit:JQ,placeholder:yA?.type==="selection"?"Type to filter options...":yA?.type==="text"?yA.placeholder||"Type your response...":"Type your message, / for commands, @ for files...",showCursor:!0,hint:Ca,validTags:BA,disableUpDownArrows:Ga.hasAt||D.startsWith("/")&&ng.length>0},void 0,!1,void 0,this)},void 0,!1,void 0,this),d&&TA.jsxDEV(j,{marginTop:1,children:TA.jsxDEV($,{color:"yellow",children:"Press ESC again to clear input"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Ga.hasAt?TA.jsxDEV(xj,{files:Ga.files,selectedFileIndex:iA,filesLoading:wA},void 0,!1,void 0,this):null,D.startsWith("/")&&!Ga.hasAt&&ng.length>0?TA.jsxDEV(dj,{commands:ng,selectedCommandIndex:l,currentlyLoading:ug,loadError:vg},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),TA.jsxDEV(j,{flexShrink:0,paddingTop:1,flexDirection:"row",children:dD&&TA.jsxDEV(kG,{provider:dD.provider,model:dD.model,apiKey:R_?.providers?.[dD.provider]?.apiKey,usedTokens:Pa},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var BQ=GA(YD(),1);function eH(){let A=sA((g)=>g.debugLogs),D=sA((g)=>g.clearDebugLogs),_=sA((g)=>g.navigateTo);return KB((g,a)=>{if(a.escape){_("chat");return}if(g==="c"||g==="C"){D();return}}),BQ.jsxDEV(j,{flexDirection:"column",flexGrow:1,children:[BQ.jsxDEV(j,{flexShrink:0,paddingBottom:1,children:[BQ.jsxDEV($,{color:"#00D9FF",children:"▌ DEBUG LOGS"},void 0,!1,void 0,this),BQ.jsxDEV($,{dimColor:!0,children:[" · ",A.length," entries"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),BQ.jsxDEV(j,{flexGrow:1,flexDirection:"column",paddingY:1,children:A.length===0?BQ.jsxDEV(j,{children:BQ.jsxDEV($,{dimColor:!0,children:"No logs yet..."},void 0,!1,void 0,this)},void 0,!1,void 0,this):A.slice(-100).map((g,a)=>BQ.jsxDEV($,{dimColor:!0,children:g},a,!1,void 0,this))},void 0,!1,void 0,this),BQ.jsxDEV(j,{flexShrink:0,paddingTop:1,children:BQ.jsxDEV($,{dimColor:!0,children:"Esc Back · C Clear logs"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var s4=GA(KD(),1);var V8=GA(KD(),1);var pj=GA(YD(),1),fqA="\x1B[?1049h",yqA="\x1B[?1049l";function wqA(){let{stdout:A}=e1(),[D,_]=V8.useState({columns:A.columns||100,rows:A.rows||30});return V8.useEffect(()=>{_({columns:A.columns||100,rows:A.rows||30});function g(){let{columns:a,rows:Q}=A;_({columns:a||100,rows:Q||30})}return A.on("resize",g),()=>{A.off("resize",g)}},[A]),[D.columns,D.rows]}function rj({children:A,...D}){let[_,g]=wqA();return V8.useEffect(()=>{return process.stdout.write(fqA),process.stdout.write("\x1B[2J"),process.stdout.write("\x1B[H"),()=>{process.stdout.write(yqA)}},[]),pj.jsxDEV(j,{width:_,height:g,flexDirection:"column",...D,children:A},void 0,!1,void 0,this)}var PA=GA(YD(),1);function AJ(){let[A,D]=s4.useState("agents"),[_,g]=s4.useState("browse"),[a,Q]=s4.useState(0),I=sA((P)=>P.currentAgentId),C=sA((P)=>P.enabledRuleIds),y=sA((P)=>P.sessions),w=sA((P)=>P.aiConfig),u=sA((P)=>P.notificationSettings),G=sA((P)=>P.updateNotificationSettings),J=sA((P)=>P.navigateTo),z=nj(),q=sj();KB((P,x)=>{if(x.escape){if(_==="edit"){g("browse");return}J("chat");return}if(x.tab){let d=["agents","rules","sessions","providers","notifications","keybindings"],p=(d.indexOf(A)+1)%d.length;D(d[p]),Q(0);return}if(x.return){if(_==="browse")g("edit");else M();return}if(_==="browse"){let d=parseInt(P);if(d>=1&&d<=6){D(["agents","rules","sessions","providers","notifications","keybindings"][d-1]),Q(0);return}}if(_==="edit"){if(x.upArrow){Q((d)=>Math.max(0,d-1));return}if(x.downArrow){let d=X();Q((e)=>Math.min(d,e+1));return}if(P===" "){M();return}}});let X=()=>{switch(A){case"agents":return z.length-1;case"rules":return q.length-1;case"notifications":return 3;default:return 0}},M=()=>{switch(A){case"agents":if(z[a])oj(z[a].id),g("browse");break;case"rules":if(q[a])tj(q[a].id);break;case"notifications":let x=["osNotifications","terminalNotifications","sound","autoGenerateTitle"][a];if(x){let d=sA.getState().notificationSettings;G({[x]:!d[x]})}break}},U=()=>{return PA.jsxDEV(j,{flexDirection:"column",paddingX:2,paddingTop:1,children:[PA.jsxDEV(j,{marginBottom:2,children:[PA.jsxDEV($,{color:"#00D9FF",children:"AGENTS"},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:[z.length," available"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),PA.jsxDEV(j,{flexDirection:"column",children:z.map((P,x)=>{let d=P.id===I,e=_==="edit"&&a===x;return PA.jsxDEV(j,{marginBottom:1,paddingY:0,children:[PA.jsxDEV($,{dimColor:!0,children:[x+1," "]},void 0,!0,void 0,this),PA.jsxDEV($,{bold:d||e,color:d?"#00FF88":e?"#00D9FF":"white",children:P.metadata.name},void 0,!1,void 0,this),d&&PA.jsxDEV(PA.Fragment,{children:[PA.jsxDEV($,{dimColor:!0,children:" "},void 0,!1,void 0,this),PA.jsxDEV($,{color:"#00FF88",children:"●"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),e&&_==="edit"&&PA.jsxDEV(PA.Fragment,{children:[PA.jsxDEV($,{dimColor:!0,children:" "},void 0,!1,void 0,this),PA.jsxDEV($,{color:"#00D9FF",children:"◄"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},P.id,!0,void 0,this)})},void 0,!1,void 0,this),_==="edit"&&PA.jsxDEV(j,{marginTop:2,children:PA.jsxDEV($,{dimColor:!0,italic:!0,children:"↑↓ Navigate ENTER/SPACE Switch ESC Cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},W=()=>{return PA.jsxDEV(j,{flexDirection:"column",paddingX:2,paddingTop:1,children:[PA.jsxDEV(j,{marginBottom:2,children:[PA.jsxDEV($,{color:"#00D9FF",children:"RULES"},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:[C.length,"/",q.length," enabled"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),PA.jsxDEV(j,{flexDirection:"column",children:q.map((P,x)=>{let d=C.includes(P.id),e=_==="edit"&&a===x;return PA.jsxDEV(j,{marginBottom:1,paddingY:0,children:[PA.jsxDEV($,{dimColor:!0,children:[x+1," "]},void 0,!0,void 0,this),PA.jsxDEV($,{bold:e,color:e?"#00D9FF":d?"#00FF88":"gray",children:P.id},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),PA.jsxDEV($,{color:d?"#00FF88":"#FF3366",children:d?"ON":"OFF"},void 0,!1,void 0,this),e&&_==="edit"&&PA.jsxDEV(PA.Fragment,{children:[PA.jsxDEV($,{dimColor:!0,children:" "},void 0,!1,void 0,this),PA.jsxDEV($,{color:"#00D9FF",children:"◄"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},P.id,!0,void 0,this)})},void 0,!1,void 0,this),_==="edit"&&PA.jsxDEV(j,{marginTop:2,children:PA.jsxDEV($,{dimColor:!0,italic:!0,children:"↑↓ Navigate SPACE Toggle ESC Cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},Y=()=>{return PA.jsxDEV(j,{flexDirection:"column",paddingX:2,paddingTop:1,children:[PA.jsxDEV(j,{marginBottom:2,children:[PA.jsxDEV($,{color:"#00D9FF",children:"SESSIONS"},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:[y.length," total"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),PA.jsxDEV(j,{flexDirection:"column",children:y.slice(0,15).map((P,x)=>{return PA.jsxDEV(j,{marginBottom:1,children:[PA.jsxDEV($,{dimColor:!0,children:[x+1," "]},void 0,!0,void 0,this),PA.jsxDEV($,{color:"#00FF88",children:P.title||"New Chat"},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:[" ",P.messages.length," msg"]},void 0,!0,void 0,this)]},P.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},c=()=>{let P=Object.entries(w?.providers||{});return PA.jsxDEV(j,{flexDirection:"column",paddingX:2,paddingTop:1,children:[PA.jsxDEV(j,{marginBottom:2,children:[PA.jsxDEV($,{color:"#00D9FF",children:"PROVIDERS"},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:[P.length," configured"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),PA.jsxDEV(j,{flexDirection:"column",children:P.map(([x,d],e)=>{return PA.jsxDEV(j,{marginBottom:1,flexDirection:"column",children:[PA.jsxDEV(j,{children:[PA.jsxDEV($,{dimColor:!0,children:[e+1," "]},void 0,!0,void 0,this),PA.jsxDEV($,{bold:!0,color:"#00FF88",children:x},void 0,!1,void 0,this)]},void 0,!0,void 0,this),d.defaultModel&&PA.jsxDEV(j,{marginLeft:4,children:PA.jsxDEV($,{dimColor:!0,children:d.defaultModel},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},x,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},l=()=>{let P=[{key:"osNotifications",label:"OS Notifications",value:u.osNotifications},{key:"terminalNotifications",label:"Terminal",value:u.terminalNotifications},{key:"sound",label:"Sound",value:u.sound},{key:"autoGenerateTitle",label:"Auto-Generate Title (LLM)",value:u.autoGenerateTitle}];return PA.jsxDEV(j,{flexDirection:"column",paddingX:2,paddingTop:1,children:[PA.jsxDEV(j,{marginBottom:2,children:[PA.jsxDEV($,{color:"#00D9FF",children:"NOTIFICATIONS"},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:[P.filter((x)=>x.value).length,"/4 enabled"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),PA.jsxDEV(j,{flexDirection:"column",children:P.map((x,d)=>{let e=_==="edit"&&a===d;return PA.jsxDEV(j,{marginBottom:1,children:[PA.jsxDEV($,{dimColor:!0,children:[d+1," "]},void 0,!0,void 0,this),PA.jsxDEV($,{bold:e,color:e?"#00D9FF":"white",children:x.label},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),PA.jsxDEV($,{color:x.value?"#00FF88":"#FF3366",children:x.value?"ON":"OFF"},void 0,!1,void 0,this),e&&_==="edit"&&PA.jsxDEV(PA.Fragment,{children:[PA.jsxDEV($,{dimColor:!0,children:" "},void 0,!1,void 0,this),PA.jsxDEV($,{color:"#00D9FF",children:"◄"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},x.key,!0,void 0,this)})},void 0,!1,void 0,this),_==="edit"&&PA.jsxDEV(j,{marginTop:2,children:PA.jsxDEV($,{dimColor:!0,italic:!0,children:"↑↓ Navigate SPACE Toggle ESC Cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},m=()=>{return PA.jsxDEV(j,{flexDirection:"column",paddingX:2,paddingTop:1,children:[PA.jsxDEV(j,{marginBottom:2,children:PA.jsxDEV($,{color:"#00D9FF",children:"KEYBOARD SHORTCUTS"},void 0,!1,void 0,this)},void 0,!1,void 0,this),PA.jsxDEV(j,{flexDirection:"column",children:[{keys:"ESC",action:"Exit dashboard / Cancel edit"},{keys:"TAB",action:"Switch section"},{keys:"1-6",action:"Quick select section"},{keys:"ENTER",action:"Edit mode / Confirm"},{keys:"↑↓",action:"Navigate items (edit mode)"},{keys:"SPACE",action:"Toggle/Select (edit mode)"}].map((x,d)=>{return PA.jsxDEV(j,{marginBottom:1,children:[PA.jsxDEV($,{color:"#00FF88",children:x.keys},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:" → "},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:x.action},void 0,!1,void 0,this)]},d,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},o=()=>{switch(A){case"agents":return U();case"rules":return W();case"sessions":return Y();case"providers":return c();case"notifications":return l();case"keybindings":return m();default:return null}};return PA.jsxDEV(rj,{flexDirection:"column",children:[PA.jsxDEV(j,{flexShrink:0,paddingX:2,paddingY:1,children:[PA.jsxDEV($,{bold:!0,color:"#00D9FF",children:"SYLPHX FLOW"},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:" Control Panel"},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),_==="edit"&&PA.jsxDEV($,{color:"#FFD700",children:"EDIT MODE"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),PA.jsxDEV(j,{flexGrow:1,minHeight:0,flexDirection:"row",children:[PA.jsxDEV(j,{width:"25%",flexShrink:0,flexDirection:"column",paddingX:2,paddingY:1,children:[{id:"agents",label:"Agents",num:1},{id:"rules",label:"Rules",num:2},{id:"sessions",label:"Sessions",num:3},{id:"providers",label:"Providers",num:4},{id:"notifications",label:"Notifications",num:5},{id:"keybindings",label:"Keybindings",num:6}].map((P)=>{let x=A===P.id;return PA.jsxDEV(j,{marginBottom:1,children:[PA.jsxDEV($,{dimColor:!0,children:[P.num," "]},void 0,!0,void 0,this),PA.jsxDEV($,{bold:x,color:x?"#00FF88":"white",children:P.label},void 0,!1,void 0,this),x&&PA.jsxDEV(PA.Fragment,{children:[PA.jsxDEV($,{dimColor:!0,children:" "},void 0,!1,void 0,this),PA.jsxDEV($,{color:"#00FF88",children:"●"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},P.id,!0,void 0,this)})},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1,minHeight:0,flexDirection:"column",children:o()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),PA.jsxDEV(j,{flexShrink:0,paddingX:2,paddingY:1,children:[PA.jsxDEV($,{dimColor:!0,children:"TAB"},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:" Next "},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:"ENTER"},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:" Edit "},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:"ESC"},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:" Exit"},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,italic:!0,children:"Press number keys 1-6 for quick navigation"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var ej=GA(KD(),1);function Ai(){ej.useEffect(()=>{(async()=>{try{let g=await(await t4()).getRecentSessions(20),a=sA.setState;a({sessions:g})}catch(_){console.error("Failed to load sessions from database:",_)}})();let D=sA.subscribe((_)=>_.sessions.length,(_,g)=>{if(_>g){let a=sA.setState,I=[...sA.getState().sessions].sort((C,y)=>y.updated-C.updated);a({sessions:I})}});return()=>{D()}},[])}var rg=GA(YD(),1);function FqA(){let A=sA((y)=>y.currentScreen),D=sA((y)=>y.isLoading),_=sA((y)=>y.error),g=sA((y)=>y.setError),[a,Q]=P8.useState(null),{loadConfig:I}=LI();Ai();let C=(y)=>{Q(y)};if(P8.useEffect(()=>{let y=process.cwd();Di(()=>sA),gi(()=>sA),_i(y).catch((w)=>{console.error("Failed to initialize agent manager:",w)}),ai(y).catch((w)=>{console.error("Failed to initialize rule manager:",w)}),I().catch((w)=>{console.error("Failed to load config:",w)})},[]),P8.useEffect(()=>{if(_){let y=setTimeout(()=>{g(null)},5000);return()=>clearTimeout(y)}},[_,g]),A==="dashboard")return rg.jsxDEV(AJ,{},void 0,!1,void 0,this);return rg.jsxDEV(j,{flexDirection:"column",width:"100%",height:"100%",paddingX:1,children:[rg.jsxDEV(j,{paddingY:1,children:[rg.jsxDEV($,{bold:!0,color:"#00D9FF",children:"SYLPHX FLOW"},void 0,!1,void 0,this),rg.jsxDEV($,{dimColor:!0,children:" │ "},void 0,!1,void 0,this),rg.jsxDEV($,{dimColor:!0,children:"AI Development Assistant"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_&&rg.jsxDEV(j,{paddingY:1,children:[rg.jsxDEV($,{color:"#FF3366",children:"▌"},void 0,!1,void 0,this),rg.jsxDEV($,{color:"#FF3366",bold:!0,children:" ERROR "},void 0,!1,void 0,this),rg.jsxDEV($,{color:"gray",children:_},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D&&rg.jsxDEV(j,{paddingY:1,children:[rg.jsxDEV($,{color:"#FFD700",children:"▌"},void 0,!1,void 0,this),rg.jsxDEV($,{color:"#FFD700",bold:!0,children:" LOADING"},void 0,!1,void 0,this),rg.jsxDEV($,{color:"gray",children:"..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),rg.jsxDEV(j,{flexDirection:"column",flexGrow:1,minHeight:0,children:[A==="chat"&&rg.jsxDEV(tH,{commandFromPalette:a},void 0,!1,void 0,this),A==="provider-management"&&rg.jsxDEV(e7,{},void 0,!1,void 0,this),A==="model-selection"&&rg.jsxDEV(DG,{},void 0,!1,void 0,this),A==="command-palette"&&rg.jsxDEV(_G,{onCommand:C},void 0,!1,void 0,this),A==="logs"&&rg.jsxDEV(eH,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function DJ(){return rg.jsxDEV(FqA,{},void 0,!1,void 0,this)}var Bi=GA(KD(),1);var QQ=GA(YD(),1);class _J extends Bi.default.Component{constructor(A){super(A);this.state={hasError:!1,error:null}}static getDerivedStateFromError(A){return{hasError:!0,error:A}}componentDidCatch(A,D){console.error("React Error Boundary caught error:",A),console.error("Error info:",D)}render(){if(this.state.hasError)return QQ.jsxDEV(j,{flexDirection:"column",padding:1,children:[QQ.jsxDEV(j,{marginBottom:1,children:QQ.jsxDEV($,{color:"red",bold:!0,children:"[ERROR] Application Error"},void 0,!1,void 0,this)},void 0,!1,void 0,this),QQ.jsxDEV(j,{marginBottom:1,children:QQ.jsxDEV($,{color:"yellow",children:"The application encountered an error and needs to restart."},void 0,!1,void 0,this)},void 0,!1,void 0,this),this.state.error&&QQ.jsxDEV(j,{flexDirection:"column",marginBottom:1,children:[QQ.jsxDEV($,{color:"gray",children:["Error: ",this.state.error.message]},void 0,!0,void 0,this),this.state.error.stack&&QQ.jsxDEV($,{color:"gray",dimColor:!0,children:this.state.error.stack.split(`
|
|
432
|
+
`).filter((u)=>u.trim()):[],y=a?"Still running":`Completed (exit: ${g})`,w=Math.floor(Q/1000);return{lines:C,summary:`${y} - ${w}s`}}return{lines:lQ(A)}}),"kill-bash":aQ("KillBash",(A)=>A.bash_id?String(A.bash_id):"",(A)=>{if(typeof A==="object"&&A!==null&&"message"in A){let{message:D}=A;return{lines:[],summary:D}}return{lines:lQ(A)}}),grep:aQ("Search",(A)=>{let D=A.pattern?String(A.pattern):"",_=A.glob?String(A.glob):"",g=A.type?String(A.type):"",a=A.path?String(A.path):"",Q=`"${x4(D,40)}"`;if(_)Q+=` in ${_}`;else if(g)Q+=` [${g}]`;if(a&&!oH(a))Q+=` [${Mf(a)}]`;return Q},(A)=>{if(typeof A!=="object"||A===null)return{lines:lQ(A)};let D=A;if("matches"in D){let _=D.matches;return{lines:_.map((a)=>`${a.file}:${a.line}: ${a.content}`),summary:`Found ${_.length} ${hQ(_.length,"match","matches")}`}}if("files"in D){let _=D.files;return{lines:_,summary:`Found ${_.length} ${hQ(_.length,"file")}`}}if("count"in D&&!("matches"in D)&&!("files"in D))return{lines:[],summary:`Found ${D.count} ${hQ(D.count,"match","matches")}`};return{lines:lQ(A)}}),glob:aQ("Search",(A)=>{let D=A.pattern?String(A.pattern):"",_=A.path?String(A.path):"";return _&&!oH(_)?`${D} in ${Mf(_)}`:D},(A)=>{if(typeof A==="object"&&A!==null&&"files"in A){let _=A.files;return{lines:_,summary:`Found ${_.length} ${hQ(_.length,"file")}`}}let D=lQ(A);return{lines:D,summary:`Found ${D.length} ${hQ(D.length,"file")}`}}),updateTodos:aQ("Tasks",(A)=>{let D=A.todos;if(!D||D.length===0)return"";let _=D.filter((Q)=>!Q.id).length,g=D.filter((Q)=>Q.id).length,a=[];if(_>0)a.push(`${_} new`);if(g>0)a.push(`${g} updated`);return a.join(", ")},(A)=>{if(typeof A==="object"&&A!==null&&"summary"in A){let{summary:D,changes:_,total:g}=A;return{lines:_||[],summary:`${D} • ${g} active`}}return{lines:lQ(A)}})},$j=(A)=>{return EqA[A]||null};var fB=GA(YD(),1);function IqA(A){let{name:D,status:_,duration:g,args:a,error:Q}=A;return fB.jsxDEV(j,{flexDirection:"column",children:[fB.jsxDEV(j,{children:[_==="running"&&fB.jsxDEV(fB.Fragment,{children:[fB.jsxDEV(UB,{color:"#FFD700"},void 0,!1,void 0,this),fB.jsxDEV($,{children:" "},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_==="completed"&&fB.jsxDEV($,{color:"#00FF88",children:"✓ "},void 0,!1,void 0,this),_==="failed"&&fB.jsxDEV($,{color:"#FF3366",children:"✗ "},void 0,!1,void 0,this),fB.jsxDEV($,{color:"white",children:D},void 0,!1,void 0,this),g!==void 0&&(_==="completed"||_==="running")&&fB.jsxDEV($,{dimColor:!0,children:[" ",g,"ms"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),_==="failed"&&Q&&fB.jsxDEV(j,{marginLeft:2,children:fB.jsxDEV($,{color:"#FF3366",children:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Vj(A){let D=$j(A.name);if(!D)return fB.jsxDEV(IqA,{...A},void 0,!1,void 0,this);return fB.jsxDEV(D,{...A},void 0,!1,void 0,this)}var yB=GA(YD(),1);function r4({part:A,isLastInStream:D=!1}){let[_,g]=d4.useState(void 0),a=A.type,Q=A.type==="reasoning"&&"completed"in A?A.completed:!0,I=A.type==="tool"?A.status:null,C=(A.type==="reasoning"||A.type==="tool")&&"startTime"in A?A.startTime:null;if(d4.useEffect(()=>{if((a==="reasoning"&&!Q&&C||a==="tool"&&I==="running"&&C)&&C){g(Date.now()-C);let u=setInterval(()=>{g(Date.now()-C)},1000);return()=>clearInterval(u)}else{g(void 0);return}},[a,Q,I,C]),A.type==="text")return yB.jsxDEV(j,{flexDirection:"column",marginLeft:2,marginBottom:1,children:[yB.jsxDEV(nH,{children:A.content},void 0,!1,void 0,this),D&&yB.jsxDEV(j,{children:yB.jsxDEV($,{color:"#FFD700",children:"▊"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(A.type==="reasoning")if("completed"in A?A.completed:!0){let w=A.duration?Math.round(A.duration/1000):0;return yB.jsxDEV(j,{flexDirection:"column",marginLeft:2,marginBottom:1,children:yB.jsxDEV(j,{children:yB.jsxDEV($,{dimColor:!0,children:["Thought ",w,"s"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}else{let w=_?Math.round(_/1000):0;return yB.jsxDEV(j,{flexDirection:"column",marginLeft:2,marginBottom:1,children:yB.jsxDEV(j,{children:[yB.jsxDEV(UB,{color:"#FFD700"},void 0,!1,void 0,this),yB.jsxDEV($,{dimColor:!0,children:[" Thinking... ",w,"s"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}if(A.type==="error")return yB.jsxDEV(j,{marginLeft:2,marginBottom:1,children:yB.jsxDEV($,{color:"red",children:A.error},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(A.type==="tool"){let y=A.status==="running"?_:A.duration;return yB.jsxDEV(j,{marginLeft:2,marginBottom:1,children:yB.jsxDEV(Vj,{name:A.name,status:A.status,duration:y,args:A.args,result:A.result,error:A.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)}return null}function Pj(A){let{input:D,cursor:_,isStreaming:g,pendingInput:a,pendingCommand:Q,filteredFileInfo:I,filteredCommands:C,multiSelectionPage:y,multiSelectionAnswers:w,multiSelectChoices:u,selectionFilter:G,isFilterMode:J,selectedCommandIndex:z,selectedFileIndex:q,skipNextSubmit:X,lastEscapeTime:M,inputResolver:U,commandSessionRef:W,abortControllerRef:Y,cachedOptions:c,setInput:l,setCursor:m,setShowEscHint:o,setMultiSelectionPage:_A,setSelectedCommandIndex:P,setMultiSelectionAnswers:x,setMultiSelectChoices:d,setSelectionFilter:e,setIsFilterMode:p,setSelectedFileIndex:HA,setPendingInput:BA,setPendingCommand:$A,addLog:KA,addMessage:vA,addAttachment:SA,setAttachmentTokenCount:wA,createCommandContext:iA,currentSessionId:UA,currentSession:yA,createSession:JA}=A;KB(async(VA,R)=>{if(R.escape&&g){if(Y.current)KA("[abort] Cancelling AI response..."),Y.current.abort(),Y.current=null;return}if(R.escape){let h=Date.now();if(h-M.current<500&&M.current>0){l(""),m(0),M.current=0,o(!1);return}if(D.length>0)o(!0),setTimeout(()=>{o(!1)},2000);M.current=h}if(a&&U.current){if(a.type==="selection"){let h=a.questions,i=h.length===1,IA=h[y],qA=h.length,kA=IA.options.filter((mA)=>mA.label.toLowerCase().includes(G.toLowerCase())||mA.value&&mA.value.toLowerCase().includes(G.toLowerCase())),ED=kA.length-1;if(R.downArrow){P((mA)=>mA<ED?mA+1:mA);return}if(R.upArrow){P((mA)=>mA>0?mA-1:0);return}if(R.escape&&(J||G.length>0)){if(J)p(!1),KA("[filter] Exited filter mode, filter text preserved");else if(G.length>0)e(""),P(0),KA("[filter] Cleared filter text");return}if(VA&&!R.return&&!R.escape&&!R.tab&&!R.ctrl){if(J||VA!==" "){e((mA)=>mA+VA),p(!0),P(0);return}}if(R.backspace||R.delete){if(G.length>0){if(e((mA)=>mA.slice(0,-1)),G.length===1)p(!1);P(0);return}}if(!i){if(R.tab&&!R.shift){_A((GD)=>(GD+1)%qA),P(0),e(""),p(!1);let mA=(y+1)%qA,WA=h[mA];if(WA.multiSelect)if(w[WA.id]){let GD=w[WA.id];d(new Set(Array.isArray(GD)?GD:[]))}else if(WA.preSelected)d(new Set(WA.preSelected));else d(new Set);else d(new Set);return}if(R.shift&&R.tab){_A((GD)=>(GD-1+qA)%qA),P(0),e(""),p(!1);let mA=(y-1+qA)%qA,WA=h[mA];if(WA.multiSelect)if(w[WA.id]){let GD=w[WA.id];d(new Set(Array.isArray(GD)?GD:[]))}else if(WA.preSelected)d(new Set(WA.preSelected));else d(new Set);else d(new Set);return}}if(!i&&R.ctrl&&R.return){if(h.every((WA)=>w[WA.id]))KA(`[selection] Submitting answers: ${JSON.stringify(w)}`),U.current(w),U.current=null,BA(null),_A(0),x({}),d(new Set),e(""),p(!1);else KA("[selection] Cannot submit: not all questions answered");return}if(VA===" "&&IA.multiSelect&&!J){let mA=kA[z];if(mA){let WA=mA.value||mA.label;d((GD)=>{let C_=new Set(GD);if(C_.has(WA))C_.delete(WA),KA(`[multi-select] Unchecked: ${WA}`);else C_.add(WA),KA(`[multi-select] Checked: ${WA}`);return C_})}return}if(R.return){if(IA.multiSelect){if(u.size===0){KA("[multi-select] No choices selected, skipping");return}let mA=Array.from(u);if(KA(`[multi-select] Q${y+1}: ${mA.join(", ")}`),!W.current)W.current=UA||JA("openrouter","anthropic/claude-3.5-sonnet");if(vA(W.current,"user",mA.join(", ")),i)U.current({[IA.id]:mA}),U.current=null,BA(null),_A(0),x({}),d(new Set),e(""),p(!1);else{let WA={...w,[IA.id]:mA};if(x(WA),d(new Set),h.every((C_)=>WA[C_.id]))KA(`[selection] All answered, auto-submitting: ${JSON.stringify(WA)}`),U.current(WA),U.current=null,BA(null),_A(0),x({}),e(""),p(!1);else{let C_=h.findIndex((cD,OD)=>OD>y&&!WA[cD.id]);if(C_!==-1)_A(C_);P(0),e("")}}}else{let mA=kA[z];if(mA){let WA=mA.value||mA.label;if(KA(`[selection] Q${y+1}: ${WA}`),!W.current)W.current=UA||JA("openrouter","anthropic/claude-3.5-sonnet");if(vA(W.current,"user",mA.label),i)U.current({[IA.id]:WA}),U.current=null,BA(null),_A(0),x({}),e(""),p(!1);else{let GD={...w,[IA.id]:WA};if(x(GD),h.every((cD)=>GD[cD.id]))KA(`[selection] All answered, auto-submitting: ${JSON.stringify(GD)}`),U.current(GD),U.current=null,BA(null),_A(0),x({}),e(""),p(!1);else{let cD=h.findIndex((OD,w_)=>w_>y&&!GD[OD.id]);if(cD!==-1)_A(cD);P(0),e("")}}}}return}if(R.escape){KA("[selection] Cancelled"),U.current({}),U.current=null,BA(null),_A(0),x({}),d(new Set),e(""),p(!1);return}}}if(Q&&!a){let h=Q.command.args?.[0],i=h?`${Q.command.id}:${h.name}`:"",IA=i?c.get(i)||[]:[],qA=IA.length-1;if(R.downArrow){P((kA)=>kA<qA?kA+1:kA);return}if(R.upArrow){P((kA)=>kA>0?kA-1:0);return}if(R.return){let kA=IA[z];if(kA){let ED=await Q.command.execute(iA([kA.id]));if(UA)vA(UA,"assistant",ED);$A(null),P(0)}return}if(R.escape){if(UA)vA(UA,"assistant","Command cancelled");$A(null),P(0);return}}if(I.hasAt&&I.files.length>0&&!a){if(R.downArrow){HA((h)=>h<I.files.length-1?h+1:h);return}if(R.upArrow){HA((h)=>h>0?h-1:0);return}if(R.tab||R.return){let h=I.files[q];if(h){SA({path:h.path,relativePath:h.relativePath,size:h.size}),(async()=>{try{let{readFile:ED}=await import("node:fs/promises"),{countTokens:mA}=await import("./chunk-585jp0rg.js"),WA=await ED(h.path,"utf8"),GD=await mA(WA,yA?.model);wA(h.path,GD)}catch(ED){console.error("Failed to count tokens:",ED)}})();let i=D.slice(0,I.atIndex),IA=D.slice(I.atIndex+1+I.query.length),qA=`${i}@${h.relativePath} ${IA}`,kA=i.length+h.relativePath.length+2;l(qA),m(kA),HA(0)}return}}else if(C.length>0&&!a){if(R.downArrow){P((h)=>h<C.length-1?h+1:h);return}if(R.upArrow){P((h)=>h>0?h-1:0);return}if(R.tab){let h=C[z];if(h){let IA=(await import("./chunk-5hcagq8j.js").then((ED)=>ED.commands)).some((ED)=>ED.label===h.label),qA=h.args&&h.args.length>0,kA=IA&&qA?`${h.label} `:h.label;KA(`[useInput] Tab autocomplete fill: ${kA}`),l(kA),m(kA.length),P(0)}return}if(R.return){let h=C[z];if(h){if(X.current=!0,l(""),P(0),KA(`[useInput] Enter autocomplete execute: ${h.label}`),!W.current)W.current=UA||JA("openrouter","anthropic/claude-3.5-sonnet");vA(W.current,"user",h.label);let i=await h.execute(iA([]));if(i)vA(W.current,"assistant",i)}return}if(R.escape){l(""),P(0);return}}},{isActive:!0})}var bI=GA(KD(),1),SQ=new Map,p4=new Map,n4=new Map;function CqA(A,D,_){return`${A}:${D}:${_.substring(0,100)}`}function cj(A){let[D,_]=bI.useState(0),g=bI.useRef(0),a=bI.useRef(0),Q=bI.useRef(null),I=A?.id??null,C=A?.messages.length??0,y=A?.model??"";return bI.useEffect(()=>{if(!A||!I){_(0),g.current=0,a.current=0,Q.current=null;return}if(Q.current!==I)g.current=0,a.current=0,Q.current=I;(async()=>{try{let{countTokens:u}=await import("./chunk-585jp0rg.js"),{SYSTEM_PROMPT:G}=await import("./chunk-dpba9y5x.js"),{getAISDKTools:J}=await import("./chunk-s323r5xg.js"),z=0,q=`system:${A.model}`;if(p4.has(q))z+=p4.get(q);else{let Y=await u(G,A.model);p4.set(q,Y),z+=Y}let X=`tools:${A.model}`;if(n4.has(X))z+=n4.get(X);else{let Y=J(),c=JSON.stringify(Y),l=await u(c,A.model);n4.set(X,l),z+=l}let M=A.messages.length;if(M===g.current){_(a.current);return}if(g.current>0)z+=a.current-(p4.get(q)||0)-(n4.get(X)||0);let U=A.messages.slice(g.current),W=g.current;for(let Y=0;Y<U.length;Y++){let c=U[Y],l=W+Y,m="";if(c.content&&Array.isArray(c.content))m=c.content.filter((_A)=>_A.type==="text").map((_A)=>_A.content).join(`
|
|
433
|
+
`);else if(c.content)m=String(c.content);let o=CqA(A.id,l,m);if(SQ.has(o))z+=SQ.get(o);else{let _A=await u(m,A.model);SQ.set(o,_A),z+=_A}if(c.attachments&&c.attachments.length>0)for(let _A of c.attachments)try{let P=`${A.id}:${l}:att:${_A.path}`;if(SQ.has(P))z+=SQ.get(P);else{let{readFile:x}=await import("node:fs/promises"),d=await x(_A.path,"utf8"),e=await u(d,A.model);SQ.set(P,e),z+=e}}catch(P){}}if(g.current=M,a.current=z,_(z),SQ.size>1e4){let Y=Array.from(SQ.entries());SQ.clear(),Y.slice(-5000).forEach(([c,l])=>SQ.set(c,l))}}catch(u){console.error("Failed to calculate token usage:",u)}})()},[I,C,y]),D}var $8=GA(KD(),1);function bj(){let[A,D]=$8.useState([]),[_,g]=$8.useState(!1);return $8.useEffect(()=>{(async()=>{g(!0);try{let Q=await fR(process.cwd());D(Q)}catch(Q){console.error("Failed to load project files:",Q)}finally{g(!1)}})()},[]),{projectFiles:A,filesLoading:_}}var hj=GA(KD(),1);function lj({setPendingInput:A,setMultiSelectionPage:D,setMultiSelectionAnswers:_,setSelectionFilter:g,setSelectedCommandIndex:a,setAskQueueLength:Q,inputResolver:I,addDebugLog:C}){hj.useEffect(()=>{return n6((y)=>{return new Promise((w)=>{C(`[ask tool] Waiting for user selection (${y.questions.length} question${y.questions.length>1?"s":""})`),I.current=w,A(y),D(0),_({}),g(""),a(0)})}),Tj((y)=>{Q(y)}),()=>{o6()}},[C,A,D,_,g,a,Q,I])}var Sj=GA(KD(),1);function mj({currentSessionId:A,aiConfig:D,createSession:_}){Sj.useEffect(()=>{if(!A&&D?.defaultProvider&&D?.defaultModel)_(D.defaultProvider,D.defaultModel)},[A,D,_])}function o4(A,D,_=10){let g=Math.max(0,Math.min(D-Math.floor(_/2),A.length-_)),a=A.slice(g,g+_),Q=g>0,I=g+_<A.length,C=g,y=A.length-g-_;return{visibleItems:a,scrollOffset:g,hasItemsAbove:Q,hasItemsBelow:I,itemsAboveCount:C,itemsBelowCount:y}}var _D=GA(YD(),1);function jj({pendingInput:A,multiSelectionPage:D,multiSelectionAnswers:_,multiSelectChoices:g,selectionFilter:a,isFilterMode:Q,selectedCommandIndex:I,askQueueLength:C}){if(A.type!=="selection")return null;let y=A.questions,w=y.length===1,u=y[D],G=Object.keys(_).length,J=y.length,z=y.every((q)=>_[q.id]);return _D.jsxDEV(j,{flexDirection:"column",children:[A.prompt&&_D.jsxDEV(j,{marginBottom:1,children:_D.jsxDEV($,{dimColor:!0,children:A.prompt},void 0,!1,void 0,this)},void 0,!1,void 0,this),C>0&&_D.jsxDEV(j,{marginBottom:1,children:_D.jsxDEV($,{color:"#FFD700",children:["[+",C," pending]"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),!w&&_D.jsxDEV(j,{marginBottom:1,children:[_D.jsxDEV($,{color:"#00D9FF",children:"Progress: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00FF88",bold:!0,children:[G,"/",J]},void 0,!0,void 0,this),_D.jsxDEV($,{dimColor:!0,children:" completed"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y.map((q,X)=>{let M=X===D,U=_[q.id],W=U?q.options.find((Y)=>(Y.value||Y.label)===U):null;return _D.jsxDEV(j,{marginBottom:1,flexDirection:"column",children:[_D.jsxDEV(j,{children:[!w&&_D.jsxDEV($,{color:"#00D9FF",children:["Q",X+1,". "]},void 0,!0,void 0,this),_D.jsxDEV($,{bold:M,color:M?"#00D9FF":"gray",children:q.question},void 0,!1,void 0,this),M&&!w&&_D.jsxDEV($,{color:"#00FF88",children:" ← "},void 0,!1,void 0,this)]},void 0,!0,void 0,this),M?_D.jsxDEV(j,{marginLeft:4,flexDirection:"column",marginTop:1,children:[_D.jsxDEV(j,{marginBottom:1,children:[_D.jsxDEV($,{dimColor:!0,children:"\uD83D\uDD0D "},void 0,!1,void 0,this),Q?_D.jsxDEV(_D.Fragment,{children:[_D.jsxDEV($,{color:"#00FF88",children:a},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00FF88",children:"▊"},void 0,!1,void 0,this),_D.jsxDEV($,{dimColor:!0,children:" (Esc to exit, type to continue)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):a?_D.jsxDEV(_D.Fragment,{children:[_D.jsxDEV($,{color:"#00D9FF",children:a},void 0,!1,void 0,this),_D.jsxDEV($,{dimColor:!0,children:" (type to edit, Esc to clear)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):_D.jsxDEV($,{dimColor:!0,children:"(type to filter)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),(()=>{if(!q.options||!Array.isArray(q.options))return _D.jsxDEV(j,{children:[_D.jsxDEV($,{color:"red",children:"⚠ Error: No options available for this question"},void 0,!1,void 0,this),_D.jsxDEV($,{dimColor:!0,children:["Question data: ",JSON.stringify(q)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);let Y=q.options.filter((l)=>l.label.toLowerCase().includes(a.toLowerCase())||l.value&&l.value.toLowerCase().includes(a.toLowerCase()));if(Y.length===0)return _D.jsxDEV($,{color:"yellow",children:"⚠ No matches found"},void 0,!1,void 0,this);let c=o4(Y,I);return _D.jsxDEV(_D.Fragment,{children:[c.hasItemsAbove&&_D.jsxDEV(j,{marginBottom:1,children:_D.jsxDEV($,{dimColor:!0,children:["... ",c.itemsAboveCount," more above"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),c.visibleItems.map((l,m)=>{let o=c.scrollOffset+m,_A=l.value||l.label,P=q.multiSelect&&g.has(_A),x=o===I?"▶ ":" ",d=q.multiSelect?P?"[✓] ":"[ ] ":"";return _D.jsxDEV(j,{paddingY:0,children:_D.jsxDEV($,{color:o===I?"#00FF88":"gray",bold:o===I,children:[x,d,l.label]},void 0,!0,void 0,this)},l.value||l.label,!1,void 0,this)}),c.hasItemsBelow&&_D.jsxDEV(j,{marginTop:1,children:_D.jsxDEV($,{dimColor:!0,children:["... ",c.itemsBelowCount," more below"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)})()]},void 0,!0,void 0,this):_D.jsxDEV(j,{marginLeft:4,children:U?_D.jsxDEV(_D.Fragment,{children:[_D.jsxDEV($,{color:"#00FF88",children:"✓ "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00FF88",children:Array.isArray(U)?U.join(", "):W?.label||U},void 0,!1,void 0,this)]},void 0,!0,void 0,this):_D.jsxDEV($,{dimColor:!0,children:"(not answered yet)"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},q.id,!0,void 0,this)}),_D.jsxDEV(j,{marginTop:1,flexDirection:"column",children:_D.jsxDEV(j,{children:[!w&&!Q&&_D.jsxDEV(_D.Fragment,{children:[_D.jsxDEV($,{dimColor:!0,children:"Tab: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00D9FF",children:"Next"},void 0,!1,void 0,this),_D.jsxDEV($,{dimColor:!0,children:" · Shift+Tab: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00D9FF",children:"Previous"},void 0,!1,void 0,this),_D.jsxDEV($,{dimColor:!0,children:" · "},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_D.jsxDEV($,{dimColor:!0,children:"↑↓: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00D9FF",children:"Navigate"},void 0,!1,void 0,this),!Q&&y[D]?.multiSelect?_D.jsxDEV(_D.Fragment,{children:[_D.jsxDEV($,{dimColor:!0,children:" · Space: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00FF88",children:"Toggle"},void 0,!1,void 0,this),_D.jsxDEV($,{dimColor:!0,children:" · Enter: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:g.size>0?"#00FF88":"gray",children:["Confirm",g.size===0&&" (select at least one)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):!Q?_D.jsxDEV(_D.Fragment,{children:[_D.jsxDEV($,{dimColor:!0,children:" · Enter: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00FF88",children:"Select"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):_D.jsxDEV(_D.Fragment,{children:[_D.jsxDEV($,{dimColor:!0,children:" · Space/Type: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#00FF88",children:"Filter"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!w&&!Q&&_D.jsxDEV(_D.Fragment,{children:[_D.jsxDEV($,{dimColor:!0,children:" · "},void 0,!1,void 0,this),_D.jsxDEV($,{dimColor:!0,children:"Ctrl+Enter: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:z?"#00FF88":"gray",children:["Submit",!z&&" (answer all first)"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),_D.jsxDEV($,{dimColor:!0,children:" · Esc: "},void 0,!1,void 0,this),_D.jsxDEV($,{color:"#FF3366",children:Q?"Exit filter":a?"Clear filter":"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var x_=GA(YD(),1);function ij({pendingCommand:A,currentlyLoading:D,loadError:_,cachedOptions:g,selectedCommandIndex:a,onSelect:Q}){return x_.jsxDEV(j,{flexDirection:"column",children:[x_.jsxDEV(j,{marginBottom:1,children:x_.jsxDEV($,{dimColor:!0,children:["Select ",A.command.args?.[0]?.name||"option",":"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),D?x_.jsxDEV(j,{children:[x_.jsxDEV(UB,{color:"#FFD700"},void 0,!1,void 0,this),x_.jsxDEV($,{color:"gray",children:" Loading options..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):_?x_.jsxDEV(j,{flexDirection:"column",children:[x_.jsxDEV(j,{marginBottom:1,children:x_.jsxDEV($,{color:"red",children:"Failed to load options"},void 0,!1,void 0,this)},void 0,!1,void 0,this),x_.jsxDEV(j,{marginBottom:1,children:x_.jsxDEV($,{dimColor:!0,children:_},void 0,!1,void 0,this)},void 0,!1,void 0,this),x_.jsxDEV(j,{children:x_.jsxDEV($,{dimColor:!0,children:"Press Esc to cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):(()=>{let I=A.command.args?.[0],C=I?`${A.command.id}:${I.name}`:"",y=C?g.get(C)||[]:[];if(y.length===0)return x_.jsxDEV(j,{flexDirection:"column",children:[x_.jsxDEV(j,{marginBottom:1,children:x_.jsxDEV($,{color:"yellow",children:"No options available"},void 0,!1,void 0,this)},void 0,!1,void 0,this),x_.jsxDEV(j,{children:x_.jsxDEV($,{dimColor:!0,children:"Press Esc to cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let w=o4(y,a);return x_.jsxDEV(x_.Fragment,{children:[w.hasItemsAbove&&x_.jsxDEV(j,{marginBottom:1,children:x_.jsxDEV($,{dimColor:!0,children:["... ",w.itemsAboveCount," more above"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),w.visibleItems.map((u,G)=>{let J=w.scrollOffset+G;return x_.jsxDEV(j,{paddingY:0,onClick:()=>Q(u),children:x_.jsxDEV($,{color:J===a?"#00FF88":"gray",bold:J===a,children:[J===a?"> ":" ",u.label]},void 0,!0,void 0,this)},u.value||u.label,!1,void 0,this)}),w.hasItemsBelow&&x_.jsxDEV(j,{marginTop:1,children:x_.jsxDEV($,{dimColor:!0,children:["... ",w.itemsBelowCount," more below"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),x_.jsxDEV(j,{marginTop:1,children:x_.jsxDEV($,{dimColor:!0,children:"↑↓ Navigate · Enter 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)}var hE=GA(YD(),1);function xj({files:A,selectedFileIndex:D,filesLoading:_}){if(_)return hE.jsxDEV(j,{marginTop:1,children:[hE.jsxDEV(UB,{color:"#FFD700"},void 0,!1,void 0,this),hE.jsxDEV($,{color:"gray",children:" Loading files..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(A.length===0)return null;return hE.jsxDEV(j,{flexDirection:"column",marginTop:1,children:[hE.jsxDEV(j,{marginBottom:1,children:hE.jsxDEV($,{dimColor:!0,children:"Files (↑↓ to select, Tab/Enter to attach):"},void 0,!1,void 0,this)},void 0,!1,void 0,this),A.map((g,a)=>hE.jsxDEV(j,{marginLeft:2,children:hE.jsxDEV($,{color:a===D?"#00FF88":"gray",bold:a===D,children:[a===D?"> ":" ",g.relativePath]},void 0,!0,void 0,this)},g.path,!1,void 0,this))]},void 0,!0,void 0,this)}var ra=GA(YD(),1);function dj({commands:A,selectedCommandIndex:D,currentlyLoading:_,loadError:g}){if(_)return ra.jsxDEV(j,{marginTop:1,children:[ra.jsxDEV(UB,{color:"#FFD700"},void 0,!1,void 0,this),ra.jsxDEV($,{color:"gray",children:" Loading options..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(g)return ra.jsxDEV(j,{flexDirection:"column",marginTop:1,children:[ra.jsxDEV(j,{children:ra.jsxDEV($,{color:"red",children:"Failed to load options"},void 0,!1,void 0,this)},void 0,!1,void 0,this),ra.jsxDEV(j,{marginTop:1,children:ra.jsxDEV($,{dimColor:!0,children:g},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(A.length===0)return null;let a=5,Q=A.length,I=Math.max(0,D-Math.floor(a/2)),C=Math.min(Q,I+a);if(C===Q)I=Math.max(0,C-a);let y=A.slice(I,C);return ra.jsxDEV(j,{flexDirection:"column",marginTop:1,children:[I>0&&ra.jsxDEV(j,{children:ra.jsxDEV($,{dimColor:!0,children:[" ↑ ",I," more above"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),y.map((w,u)=>{let G=I+u;return ra.jsxDEV(j,{children:[ra.jsxDEV($,{color:G===D?"#00FF88":"gray",bold:G===D,children:[G===D?"> ":" ",w.label]},void 0,!0,void 0,this),w.description&&ra.jsxDEV($,{dimColor:!0,children:[" ",w.description]},void 0,!0,void 0,this)]},w.id,!0,void 0,this)}),C<Q&&ra.jsxDEV(j,{children:ra.jsxDEV($,{dimColor:!0,children:[" ↓ ",Q-C," more below"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var TA=GA(YD(),1);function tH({commandFromPalette:A}){let[D,_]=pD.useState(""),[g,a]=pD.useState(0),[Q,I]=pD.useState(!1),[C,y]=pD.useState([]),[w,u]=pD.useState(!1),[G,J]=pD.useState(""),z=pD.useRef(null),q=pD.useRef({chunks:[],timeout:null}),X=sA((T)=>T.debugLogs),M=sA((T)=>T.addDebugLog),[U,W]=pD.useState(!1),[Y,c]=pD.useState(!1),[l,m]=pD.useState(0),[o,_A]=pD.useState(null),P=pD.useRef(!1),x=pD.useRef(0),[d,e]=pD.useState(!1),{pendingAttachments:p,attachmentTokens:HA,validTags:BA,addAttachment:$A,clearAttachments:KA,setAttachmentTokenCount:vA}=wR(D),{projectFiles:SA,filesLoading:wA}=bj(),[iA,UA]=pD.useState(0),[yA,JA]=pD.useState(null),VA=pD.useRef(null),[R,h]=pD.useState(""),[i,IA]=pD.useState(!1),[qA,kA]=pD.useState(0),[ED,mA]=pD.useState({}),[WA,GD]=pD.useState(new Set),[C_,cD]=pD.useState(0),OD=(T)=>{M(T)},w_=sA((T)=>T.navigateTo),R_=sA((T)=>T.aiConfig),bD=sA((T)=>T.currentSessionId),DD=sA((T)=>T.createSession),Fg=sA((T)=>T.updateSessionModel),B_=sA((T)=>T.updateSessionProvider),X_=sA((T)=>T.updateSessionTitle),Va=sA((T)=>T.updateProvider),Dg=sA((T)=>T.setAIConfig),d_=sA((T)=>T.setCurrentSession),O_=sA((T)=>T.addMessage),ID=sA((T)=>T.setSelectedProvider),yD=sA((T)=>T.setSelectedModel),XD=sA((T)=>T.updateNotificationSettings),$D=sA((T)=>T.notificationSettings),$_=sA((T)=>T.sessions),{sendMessage:Tg,currentSession:dD}=DR(),{saveConfig:Ia}=LI(),Pa=cj(dD);mj({currentSessionId:bD,aiConfig:R_,createSession:DD}),lj({setPendingInput:JA,setMultiSelectionPage:kA,setMultiSelectionAnswers:mA,setSelectionFilter:h,setSelectedCommandIndex:m,setAskQueueLength:cD,inputResolver:VA,addDebugLog:M});let[ca,ba]=pD.useState(new Map),[ug,Zg]=pD.useState(null),[vg,l0]=pD.useState(null),S_=pD.useRef(null),Wa=(T)=>({args:T,sendMessage:(b)=>{if(!S_.current)S_.current=bD||DD("openrouter","anthropic/claude-3.5-sonnet");O_(S_.current,"assistant",b)},triggerAIResponse:async(b,r)=>{_(""),await S0(b,r)},waitForInput:(b)=>{return new Promise((r)=>{if(OD(`[waitForInput] Waiting for ${b.type} input`),VA.current=r,JA(b),b.type==="selection"){kA(0),mA({});let QA=b.questions[0];if(QA?.multiSelect&&QA.preSelected)GD(new Set(QA.preSelected));else GD(new Set);m(0),h(""),IA(!1)}})},getConfig:()=>sA.getState().aiConfig,saveConfig:(b)=>Ia(b),getCurrentSession:()=>dD,updateProvider:(b,r)=>Va(b,r),setAIConfig:(b)=>Dg(b),updateSessionModel:(b,r)=>Fg(b,r),updateSessionProvider:(b,r,QA)=>B_(b,r,QA),setUISelectedProvider:(b)=>ID(b),setUISelectedModel:(b)=>yD(b),createSession:(b,r)=>DD(b,r),getSessions:()=>$_,getCurrentSessionId:()=>bD,setCurrentSession:(b)=>d_(b),navigateTo:(b)=>w_(b),addLog:(b)=>OD(b),notificationSettings:$D,updateNotificationSettings:(b)=>XD(b),updateOutput:(b)=>OD(b)}),oB=()=>{if(!D.startsWith("/"))return;let T=D.split(" "),b=T[0],r=Rw.find((QA)=>QA.label===b);if(r&&r.args&&r.args.length>0){let n=T.slice(1).filter((ZA)=>ZA.trim()!=="").length;if(n<r.args.length){let ZA=r.args[n];return ZA.required?`[${ZA.name}]`:`<${ZA.name}>`}}return};pD.useEffect(()=>{l0(null)},[D]),pD.useEffect(()=>{if(!D.startsWith("/"))return;let T=D.split(" "),b=T[0],r=Rw.find((QA)=>QA.label===b);if(r&&r.args&&T.length>1){let QA=T.slice(1).filter((wD)=>wD.trim()!==""),pA=T[T.length-1]===""?QA.length:Math.max(0,QA.length-1),uD=r.args[pA];if(uD&&uD.loadOptions){let wD=`${r.id}:${uD.name}:${QA.join(",")}`;if(!ca.has(wD)&&ug!==wD){Zg(wD);let N_=Wa([]);uD.loadOptions(QA,N_).then((ND)=>{ba((TD)=>new Map(TD).set(wD,ND)),Zg(null)}).catch((ND)=>{let TD=ND instanceof Error?ND.message:String(ND);OD(`Error loading ${wD}: ${TD}`),l0(TD),Zg(null)})}}}},[D,ug]);let Ga=pD.useMemo(()=>{let T=D.slice(0,g),b=T.lastIndexOf("@");if(b===-1)return{files:[],query:"",hasAt:!1,atIndex:-1};if(b>0){let n=T[b-1];if(!/\s/.test(n))return{files:[],query:"",hasAt:!1,atIndex:b}}let r=T.slice(b+1);if(r.includes(" "))return{files:[],query:"",hasAt:!1,atIndex:b};return{files:yR(SA,r).slice(0,10),query:r,hasAt:!0,atIndex:b}},[D,g,SA]),ng=pD.useMemo(()=>{if(!D.startsWith("/"))return[];let T=D.split(" "),b=T[0],r=Rw.find((n)=>n.label===b);if(r&&r.args&&T.length>1){let n=T.slice(1).filter((ND)=>ND.trim()!==""),ZA=T[T.length-1],pA=ZA==="",uD=pA?n.length:Math.max(0,n.length-1),wD=pA?"":ZA,N_=r.args[uD];if(N_){let ND=`${r.id}:${N_.name}:${n.join(",")}`,TD=ca.get(ND)||[];if(TD.length>0)return TD.filter((jD)=>jD.label.toLowerCase().includes(wD.toLowerCase())||jD.value&&jD.value.toLowerCase().includes(wD.toLowerCase())).map((jD)=>{let tD=pA?[...n,jD.value||jD.label]:[...n.slice(0,-1),jD.value||jD.label];return{id:`${ND}-${jD.value||jD.label}`,label:`${b} ${tD.join(" ")}`,description:"",args:r.args,execute:async(hD)=>{return await r.execute(Wa(tD))}}})}}let QA=D.slice(1).toLowerCase();return Rw.filter((n)=>n.label.toLowerCase().includes(`/${QA}`)||n.description.toLowerCase().includes(QA))},[D,ca]),Ca=pD.useMemo(()=>oB(),[D]);Pj({input:D,cursor:g,isStreaming:Q,pendingInput:yA,pendingCommand:o,filteredFileInfo:Ga,filteredCommands:ng,multiSelectionPage:qA,multiSelectionAnswers:ED,multiSelectChoices:WA,selectionFilter:R,isFilterMode:i,selectedCommandIndex:l,selectedFileIndex:iA,skipNextSubmit:P,lastEscapeTime:x,inputResolver:VA,commandSessionRef:S_,abortControllerRef:z,cachedOptions:ca,setInput:_,setCursor:a,setShowEscHint:e,setMultiSelectionPage:kA,setSelectedCommandIndex:m,setMultiSelectionAnswers:mA,setMultiSelectChoices:GD,setSelectionFilter:h,setIsFilterMode:IA,setSelectedFileIndex:UA,setPendingInput:JA,setPendingCommand:_A,addLog:OD,addMessage:O_,addAttachment:$A,setAttachmentTokenCount:vA,createCommandContext:Wa,currentSessionId:bD,currentSession:dD,createSession:DD}),pD.useEffect(()=>{m(0)},[ng.length]),pD.useEffect(()=>{UA(0)},[Ga.files.length]);let S0=pD.useCallback(async(T,b)=>{if(!R_?.defaultProvider||!R_?.defaultModel){if(bD)O_(bD,"user",T,b),O_(bD,"assistant","No AI provider configured. Use /provider to configure a provider first.");return}I(!0),y([]),OD("Starting message send..."),z.current=new AbortController;let r=()=>{let QA=q.current;if(QA.chunks.length===0)return;let n=QA.chunks.join("");QA.chunks=[],y((ZA)=>{let pA=[...ZA],uD=pA[pA.length-1];if(uD&&uD.type==="text")pA[pA.length-1]={type:"text",content:uD.content+n};else pA.push({type:"text",content:n});return pA})};try{await Tg(T,(QA)=>{if(q.current.chunks.push(QA),q.current.timeout)clearTimeout(q.current.timeout);q.current.timeout=setTimeout(()=>{r(),q.current.timeout=null},50)},(QA,n,ZA)=>{y((pA)=>[...pA,{type:"tool",toolId:QA,name:n,status:"running",args:ZA,startTime:Date.now()}])},(QA,n,ZA,pA)=>{y((uD)=>uD.map((wD)=>wD.type==="tool"&&wD.toolId===QA?{...wD,status:"completed",duration:pA,result:ZA}:wD))},async()=>{if(q.current.timeout)clearTimeout(q.current.timeout),q.current.timeout=null;if(r(),I(!1),y([]),bD){let n=sA.getState().sessions.find((ZA)=>ZA.id===bD);if(n){let ZA=n.messages.filter((wD)=>wD.role==="user").length,pA=!!n.title&&n.title!=="New Chat";if(ZA===1&&!pA){let{generateSessionTitleWithStreaming:wD}=await import("./chunk-r19ma0z2.js"),N_=n.provider,ND=n.model,TD=R_?.providers?.[N_];if(TD){u(!0),J("");try{let jD=await wD(T,N_,ND,TD,(tD)=>{J((hD)=>hD+tD)});u(!1),X_(bD,jD)}catch(jD){if(process.env.DEBUG)OD(`[Title] Error: ${jD instanceof Error?jD.message:"Unknown"}`);u(!1);let{generateSessionTitle:tD}=await import("./chunk-r19ma0z2.js"),hD=tD(T);X_(bD,hD)}}}}}},void 0,b,()=>{y((QA)=>[...QA,{type:"reasoning",content:"",startTime:Date.now()}])},(QA)=>{y((n)=>{let ZA=[...n],pA=ZA[ZA.length-1];if(pA&&pA.type==="reasoning")ZA[ZA.length-1]={...pA,content:pA.content+QA};return ZA})},(QA)=>{y((n)=>{let ZA=[...n],pA=ZA[ZA.length-1];if(pA&&pA.type==="reasoning")ZA[ZA.length-1]={...pA,completed:!0,duration:QA};return ZA})},(QA,n,ZA,pA)=>{y((uD)=>uD.map((wD)=>wD.type==="tool"&&wD.toolId===QA?{...wD,status:"failed",error:ZA,duration:pA}:wD))},(QA)=>{y((n)=>[...n,{type:"error",error:QA}])},z.current.signal)}catch(QA){OD(`[sendUserMessageToAI] Error: ${QA instanceof Error?QA.message:String(QA)}`),I(!1),y([])}},[R_,bD,Tg,O_,OD,X_,$D]),JQ=pD.useCallback(async(T)=>{if(!T.trim())return;if(Q)return;if(yA&&yA.type==="text"&&VA.current){if(OD(`[handleSubmit] Resolving text input: ${T}`),!S_.current)S_.current=bD||DD("openrouter","anthropic/claude-3.5-sonnet");O_(S_.current,"user",T.trim()),VA.current(T.trim()),VA.current=null,JA(null),_("");return}if(T.startsWith("/")&&ng.length>0){OD(`[handleSubmit] Skipping, autocomplete active (${ng.length} suggestions)`);return}if(P.current){OD(`[handleSubmit] Skipping due to skipNextSubmit flag: ${T}`),P.current=!1;return}OD(`[handleSubmit] Processing: ${T}`);let b=T.trim();if(b.startsWith("/")){let QA=b.split(" "),n=QA[0],ZA=QA.slice(1),pA=Rw.find((uD)=>uD.label===n);if(!pA){if(_(""),!S_.current)S_.current=bD||DD("openrouter","anthropic/claude-3.5-sonnet");O_(S_.current,"user",b),O_(S_.current,"assistant",`Unknown command: ${n}. Type /help for available commands.`);return}if(_(""),!S_.current)S_.current=bD||DD("openrouter","anthropic/claude-3.5-sonnet");O_(S_.current,"user",b);try{let uD=await pA.execute(Wa(ZA));if(uD)O_(S_.current,"assistant",uD)}catch(uD){O_(S_.current,"assistant",`Error: ${uD instanceof Error?uD.message:"Command failed"}`)}_A(null);return}_("");let r=[...p];KA(),await S0(b,r)},[Q,yA,VA,S_,bD,DD,O_,ng,P,OD,KA,p,_,S0]);return TA.jsxDEV(j,{flexDirection:"row",flexGrow:1,children:TA.jsxDEV(j,{flexDirection:"column",flexGrow:1,width:"70%",children:[TA.jsxDEV(j,{flexShrink:0,children:[TA.jsxDEV($,{color:"#00D9FF",children:"▌ CHAT"},void 0,!1,void 0,this),dD&&TA.jsxDEV(TA.Fragment,{children:[TA.jsxDEV($,{color:"#00D9FF",children:" · "},void 0,!1,void 0,this),w?TA.jsxDEV(TA.Fragment,{children:[TA.jsxDEV($,{color:"white",children:G},void 0,!1,void 0,this),TA.jsxDEV($,{color:"#FFD700",children:"▊"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):TA.jsxDEV($,{color:"white",children:dD.title||"New Chat"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),TA.jsxDEV(j,{flexDirection:"column",flexGrow:!dD||dD.messages.length===0&&!Q?0:1,minHeight:0,children:!dD?TA.jsxDEV(j,{paddingY:1,flexDirection:"column",children:[TA.jsxDEV(j,{paddingBottom:2,children:[TA.jsxDEV($,{color:"#00D9FF",children:"▌"},void 0,!1,void 0,this),TA.jsxDEV($,{bold:!0,color:"white",children:" WELCOME"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),TA.jsxDEV(j,{paddingBottom:1,children:TA.jsxDEV($,{dimColor:!0,children:"No AI provider configured yet."},void 0,!1,void 0,this)},void 0,!1,void 0,this),TA.jsxDEV(j,{paddingBottom:1,children:TA.jsxDEV($,{dimColor:!0,children:"Configure a provider to start chatting:"},void 0,!1,void 0,this)},void 0,!1,void 0,this),TA.jsxDEV(j,{paddingLeft:2,paddingBottom:1,children:[TA.jsxDEV($,{color:"#00D9FF",children:"/provider"},void 0,!1,void 0,this),TA.jsxDEV($,{dimColor:!0,children:" - Manage AI providers"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),TA.jsxDEV(j,{paddingLeft:2,paddingBottom:1,children:[TA.jsxDEV($,{color:"#00D9FF",children:"/help"},void 0,!1,void 0,this),TA.jsxDEV($,{dimColor:!0,children:" - Show all available commands"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):dD.messages.length===0&&!Q?null:TA.jsxDEV(j,{flexDirection:"column",children:[dD.messages.map((T,b)=>TA.jsxDEV(j,{paddingTop:1,flexDirection:"column",children:T.role==="user"?TA.jsxDEV(TA.Fragment,{children:[TA.jsxDEV(j,{children:TA.jsxDEV($,{color:"#00D9FF",children:"▌ YOU"},void 0,!1,void 0,this)},void 0,!1,void 0,this),T.content&&Array.isArray(T.content)?T.content.map((r,QA)=>TA.jsxDEV(r4,{part:r},QA,!1,void 0,this)):TA.jsxDEV(j,{marginLeft:2,children:TA.jsxDEV($,{children:String(T.content||"")},void 0,!1,void 0,this)},void 0,!1,void 0,this),T.attachments&&T.attachments.length>0?TA.jsxDEV(j,{flexDirection:"column",marginTop:1,children:T.attachments.map((r,QA)=>TA.jsxDEV(j,{marginLeft:2,children:[TA.jsxDEV($,{dimColor:!0,children:"Attached("},void 0,!1,void 0,this),TA.jsxDEV($,{color:"#00D9FF",children:r.relativePath},void 0,!1,void 0,this),TA.jsxDEV($,{dimColor:!0,children:")"},void 0,!1,void 0,this),HA.has(r.path)&&TA.jsxDEV(TA.Fragment,{children:[TA.jsxDEV($,{dimColor:!0,children:" "},void 0,!1,void 0,this),TA.jsxDEV($,{dimColor:!0,children:[sH(HA.get(r.path))," Tokens"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},QA,!0,void 0,this))},void 0,!1,void 0,this):null]},void 0,!0,void 0,this):TA.jsxDEV(TA.Fragment,{children:[TA.jsxDEV(j,{children:TA.jsxDEV($,{color:"#00FF88",children:"▌ SYLPHX"},void 0,!1,void 0,this)},void 0,!1,void 0,this),T.content&&Array.isArray(T.content)?T.content.map((r,QA)=>TA.jsxDEV(r4,{part:r},QA,!1,void 0,this)):TA.jsxDEV(j,{marginLeft:2,children:TA.jsxDEV($,{children:String(T.content||"")},void 0,!1,void 0,this)},void 0,!1,void 0,this),T.usage&&TA.jsxDEV(j,{marginLeft:2,children:TA.jsxDEV($,{dimColor:!0,children:[T.usage.promptTokens.toLocaleString()," → ",T.usage.completionTokens.toLocaleString()]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},b,!1,void 0,this)),Q&&TA.jsxDEV(j,{paddingTop:1,flexDirection:"column",children:[TA.jsxDEV(j,{children:TA.jsxDEV($,{color:"#00FF88",children:"▌ SYLPHX"},void 0,!1,void 0,this)},void 0,!1,void 0,this),C.length===0&&TA.jsxDEV(j,{marginLeft:2,children:[TA.jsxDEV(UB,{color:"#FFD700"},void 0,!1,void 0,this),TA.jsxDEV($,{dimColor:!0,children:" Thinking..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),C.map((T,b)=>{let r=b===C.length-1,QA=T.type==="tool"?`tool-${T.toolId}`:T.type==="reasoning"?`reasoning-${T.startTime}`:`${T.type}-${b}`;return TA.jsxDEV(r4,{part:T,isLastInStream:r&&T.type==="text"},QA,!1,void 0,this)})]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),TA.jsxDEV(EG,{},void 0,!1,void 0,this),TA.jsxDEV(j,{flexDirection:"column",flexShrink:0,paddingTop:1,children:[TA.jsxDEV(j,{children:TA.jsxDEV($,{color:"#00D9FF",children:"▌ YOU"},void 0,!1,void 0,this)},void 0,!1,void 0,this),yA&&yA.type==="selection"?TA.jsxDEV(jj,{pendingInput:yA,multiSelectionPage:qA,multiSelectionAnswers:ED,multiSelectChoices:WA,selectionFilter:R,isFilterMode:i,selectedCommandIndex:l,askQueueLength:C_},void 0,!1,void 0,this):o?TA.jsxDEV(ij,{pendingCommand:o,currentlyLoading:ug,loadError:vg,cachedOptions:ca,selectedCommandIndex:l,onSelect:async(T)=>{let b=await o.command.execute(Wa([T.value||T.label]));if(bD)O_(bD,"assistant",b);_A(null),m(0)}},void 0,!1,void 0,this):Q?TA.jsxDEV(j,{flexDirection:"column",children:[TA.jsxDEV($,{dimColor:!0,children:"Waiting for response..."},void 0,!1,void 0,this),TA.jsxDEV(j,{marginTop:1,children:TA.jsxDEV($,{color:"yellow",children:"Press ESC to cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):TA.jsxDEV(TA.Fragment,{children:[p.length>0?TA.jsxDEV(j,{flexDirection:"column",marginBottom:1,children:[TA.jsxDEV(j,{marginBottom:1,children:TA.jsxDEV($,{dimColor:!0,children:["Attachments (",p.length,"):"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),p.map((T,b)=>TA.jsxDEV(j,{marginLeft:2,children:[TA.jsxDEV($,{color:"#00D9FF",children:T.relativePath},void 0,!1,void 0,this),TA.jsxDEV($,{dimColor:!0,children:" ("},void 0,!1,void 0,this),T.size?TA.jsxDEV(TA.Fragment,{children:[TA.jsxDEV($,{dimColor:!0,children:[(T.size/1024).toFixed(1),"KB"]},void 0,!0,void 0,this),HA.has(T.path)&&TA.jsxDEV($,{dimColor:!0,children:", "},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,HA.has(T.path)?TA.jsxDEV($,{dimColor:!0,children:[sH(HA.get(T.path))," Tokens"]},void 0,!0,void 0,this):null,TA.jsxDEV($,{dimColor:!0,children:")"},void 0,!1,void 0,this)]},b,!0,void 0,this))]},void 0,!0,void 0,this):null,yA?.type==="text"&&yA.prompt&&TA.jsxDEV(j,{marginBottom:1,children:TA.jsxDEV($,{dimColor:!0,children:yA.prompt},void 0,!1,void 0,this)},void 0,!1,void 0,this),TA.jsxDEV(j,{marginLeft:2,children:TA.jsxDEV(hv,{value:yA?.type==="selection"?R:D,onChange:yA?.type==="selection"?(T)=>{h(T),m(0)}:_,cursor:yA?.type==="selection"?void 0:g,onCursorChange:yA?.type==="selection"?void 0:a,onSubmit:JQ,placeholder:yA?.type==="selection"?"Type to filter options...":yA?.type==="text"?yA.placeholder||"Type your response...":"Type your message, / for commands, @ for files...",showCursor:!0,hint:Ca,validTags:BA,disableUpDownArrows:Ga.hasAt||D.startsWith("/")&&ng.length>0},void 0,!1,void 0,this)},void 0,!1,void 0,this),d&&TA.jsxDEV(j,{marginTop:1,children:TA.jsxDEV($,{color:"yellow",children:"Press ESC again to clear input"},void 0,!1,void 0,this)},void 0,!1,void 0,this),Ga.hasAt?TA.jsxDEV(xj,{files:Ga.files,selectedFileIndex:iA,filesLoading:wA},void 0,!1,void 0,this):null,D.startsWith("/")&&!Ga.hasAt&&ng.length>0?TA.jsxDEV(dj,{commands:ng,selectedCommandIndex:l,currentlyLoading:ug,loadError:vg},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),TA.jsxDEV(j,{flexShrink:0,paddingTop:1,flexDirection:"row",children:dD&&TA.jsxDEV(kG,{provider:dD.provider,model:dD.model,apiKey:R_?.providers?.[dD.provider]?.apiKey,usedTokens:Pa},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var BQ=GA(YD(),1);function eH(){let A=sA((g)=>g.debugLogs),D=sA((g)=>g.clearDebugLogs),_=sA((g)=>g.navigateTo);return KB((g,a)=>{if(a.escape){_("chat");return}if(g==="c"||g==="C"){D();return}}),BQ.jsxDEV(j,{flexDirection:"column",flexGrow:1,children:[BQ.jsxDEV(j,{flexShrink:0,paddingBottom:1,children:[BQ.jsxDEV($,{color:"#00D9FF",children:"▌ DEBUG LOGS"},void 0,!1,void 0,this),BQ.jsxDEV($,{dimColor:!0,children:[" · ",A.length," entries"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),BQ.jsxDEV(j,{flexGrow:1,flexDirection:"column",paddingY:1,children:A.length===0?BQ.jsxDEV(j,{children:BQ.jsxDEV($,{dimColor:!0,children:"No logs yet..."},void 0,!1,void 0,this)},void 0,!1,void 0,this):A.slice(-100).map((g,a)=>BQ.jsxDEV($,{dimColor:!0,children:g},a,!1,void 0,this))},void 0,!1,void 0,this),BQ.jsxDEV(j,{flexShrink:0,paddingTop:1,children:BQ.jsxDEV($,{dimColor:!0,children:"Esc Back · C Clear logs"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var s4=GA(KD(),1);var V8=GA(KD(),1);var pj=GA(YD(),1),fqA="\x1B[?1049h",yqA="\x1B[?1049l";function wqA(){let{stdout:A}=e1(),[D,_]=V8.useState({columns:A.columns||100,rows:A.rows||30});return V8.useEffect(()=>{_({columns:A.columns||100,rows:A.rows||30});function g(){let{columns:a,rows:Q}=A;_({columns:a||100,rows:Q||30})}return A.on("resize",g),()=>{A.off("resize",g)}},[A]),[D.columns,D.rows]}function rj({children:A,...D}){let[_,g]=wqA();return V8.useEffect(()=>{return process.stdout.write(fqA),process.stdout.write("\x1B[2J"),process.stdout.write("\x1B[H"),()=>{process.stdout.write(yqA)}},[]),pj.jsxDEV(j,{width:_,height:g,flexDirection:"column",...D,children:A},void 0,!1,void 0,this)}var PA=GA(YD(),1);function AJ(){let[A,D]=s4.useState("agents"),[_,g]=s4.useState("browse"),[a,Q]=s4.useState(0),I=sA((P)=>P.currentAgentId),C=sA((P)=>P.enabledRuleIds),y=sA((P)=>P.sessions),w=sA((P)=>P.aiConfig),u=sA((P)=>P.notificationSettings),G=sA((P)=>P.updateNotificationSettings),J=sA((P)=>P.navigateTo),z=nj(),q=sj();KB((P,x)=>{if(x.escape){if(_==="edit"){g("browse");return}J("chat");return}if(x.tab){let d=["agents","rules","sessions","providers","notifications","keybindings"],p=(d.indexOf(A)+1)%d.length;D(d[p]),Q(0);return}if(x.return){if(_==="browse")g("edit");else M();return}if(_==="browse"){let d=parseInt(P);if(d>=1&&d<=6){D(["agents","rules","sessions","providers","notifications","keybindings"][d-1]),Q(0);return}}if(_==="edit"){if(x.upArrow){Q((d)=>Math.max(0,d-1));return}if(x.downArrow){let d=X();Q((e)=>Math.min(d,e+1));return}if(P===" "){M();return}}});let X=()=>{switch(A){case"agents":return z.length-1;case"rules":return q.length-1;case"notifications":return 3;default:return 0}},M=()=>{switch(A){case"agents":if(z[a])oj(z[a].id),g("browse");break;case"rules":if(q[a])tj(q[a].id);break;case"notifications":let x=["osNotifications","terminalNotifications","sound","autoGenerateTitle"][a];if(x){let d=sA.getState().notificationSettings;G({[x]:!d[x]})}break}},U=()=>{return PA.jsxDEV(j,{flexDirection:"column",paddingX:2,paddingTop:1,children:[PA.jsxDEV(j,{marginBottom:2,children:[PA.jsxDEV($,{color:"#00D9FF",children:"AGENTS"},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:[z.length," available"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),PA.jsxDEV(j,{flexDirection:"column",children:z.map((P,x)=>{let d=P.id===I,e=_==="edit"&&a===x;return PA.jsxDEV(j,{marginBottom:1,paddingY:0,children:[PA.jsxDEV($,{dimColor:!0,children:[x+1," "]},void 0,!0,void 0,this),PA.jsxDEV($,{bold:d||e,color:d?"#00FF88":e?"#00D9FF":"white",children:P.metadata.name},void 0,!1,void 0,this),d&&PA.jsxDEV(PA.Fragment,{children:[PA.jsxDEV($,{dimColor:!0,children:" "},void 0,!1,void 0,this),PA.jsxDEV($,{color:"#00FF88",children:"●"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),e&&_==="edit"&&PA.jsxDEV(PA.Fragment,{children:[PA.jsxDEV($,{dimColor:!0,children:" "},void 0,!1,void 0,this),PA.jsxDEV($,{color:"#00D9FF",children:"◄"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},P.id,!0,void 0,this)})},void 0,!1,void 0,this),_==="edit"&&PA.jsxDEV(j,{marginTop:2,children:PA.jsxDEV($,{dimColor:!0,italic:!0,children:"↑↓ Navigate ENTER/SPACE Switch ESC Cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},W=()=>{return PA.jsxDEV(j,{flexDirection:"column",paddingX:2,paddingTop:1,children:[PA.jsxDEV(j,{marginBottom:2,children:[PA.jsxDEV($,{color:"#00D9FF",children:"RULES"},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:[C.length,"/",q.length," enabled"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),PA.jsxDEV(j,{flexDirection:"column",children:q.map((P,x)=>{let d=C.includes(P.id),e=_==="edit"&&a===x;return PA.jsxDEV(j,{marginBottom:1,paddingY:0,children:[PA.jsxDEV($,{dimColor:!0,children:[x+1," "]},void 0,!0,void 0,this),PA.jsxDEV($,{bold:e,color:e?"#00D9FF":d?"#00FF88":"gray",children:P.id},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),PA.jsxDEV($,{color:d?"#00FF88":"#FF3366",children:d?"ON":"OFF"},void 0,!1,void 0,this),e&&_==="edit"&&PA.jsxDEV(PA.Fragment,{children:[PA.jsxDEV($,{dimColor:!0,children:" "},void 0,!1,void 0,this),PA.jsxDEV($,{color:"#00D9FF",children:"◄"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},P.id,!0,void 0,this)})},void 0,!1,void 0,this),_==="edit"&&PA.jsxDEV(j,{marginTop:2,children:PA.jsxDEV($,{dimColor:!0,italic:!0,children:"↑↓ Navigate SPACE Toggle ESC Cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},Y=()=>{return PA.jsxDEV(j,{flexDirection:"column",paddingX:2,paddingTop:1,children:[PA.jsxDEV(j,{marginBottom:2,children:[PA.jsxDEV($,{color:"#00D9FF",children:"SESSIONS"},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:[y.length," total"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),PA.jsxDEV(j,{flexDirection:"column",children:y.slice(0,15).map((P,x)=>{return PA.jsxDEV(j,{marginBottom:1,children:[PA.jsxDEV($,{dimColor:!0,children:[x+1," "]},void 0,!0,void 0,this),PA.jsxDEV($,{color:"#00FF88",children:P.title||"New Chat"},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:[" ",P.messages.length," msg"]},void 0,!0,void 0,this)]},P.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},c=()=>{let P=Object.entries(w?.providers||{});return PA.jsxDEV(j,{flexDirection:"column",paddingX:2,paddingTop:1,children:[PA.jsxDEV(j,{marginBottom:2,children:[PA.jsxDEV($,{color:"#00D9FF",children:"PROVIDERS"},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:[P.length," configured"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),PA.jsxDEV(j,{flexDirection:"column",children:P.map(([x,d],e)=>{return PA.jsxDEV(j,{marginBottom:1,flexDirection:"column",children:[PA.jsxDEV(j,{children:[PA.jsxDEV($,{dimColor:!0,children:[e+1," "]},void 0,!0,void 0,this),PA.jsxDEV($,{bold:!0,color:"#00FF88",children:x},void 0,!1,void 0,this)]},void 0,!0,void 0,this),d.defaultModel&&PA.jsxDEV(j,{marginLeft:4,children:PA.jsxDEV($,{dimColor:!0,children:d.defaultModel},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},x,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},l=()=>{let P=[{key:"osNotifications",label:"OS Notifications",value:u.osNotifications},{key:"terminalNotifications",label:"Terminal",value:u.terminalNotifications},{key:"sound",label:"Sound",value:u.sound},{key:"autoGenerateTitle",label:"Auto-Generate Title (LLM)",value:u.autoGenerateTitle}];return PA.jsxDEV(j,{flexDirection:"column",paddingX:2,paddingTop:1,children:[PA.jsxDEV(j,{marginBottom:2,children:[PA.jsxDEV($,{color:"#00D9FF",children:"NOTIFICATIONS"},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:[P.filter((x)=>x.value).length,"/4 enabled"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),PA.jsxDEV(j,{flexDirection:"column",children:P.map((x,d)=>{let e=_==="edit"&&a===d;return PA.jsxDEV(j,{marginBottom:1,children:[PA.jsxDEV($,{dimColor:!0,children:[d+1," "]},void 0,!0,void 0,this),PA.jsxDEV($,{bold:e,color:e?"#00D9FF":"white",children:x.label},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),PA.jsxDEV($,{color:x.value?"#00FF88":"#FF3366",children:x.value?"ON":"OFF"},void 0,!1,void 0,this),e&&_==="edit"&&PA.jsxDEV(PA.Fragment,{children:[PA.jsxDEV($,{dimColor:!0,children:" "},void 0,!1,void 0,this),PA.jsxDEV($,{color:"#00D9FF",children:"◄"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},x.key,!0,void 0,this)})},void 0,!1,void 0,this),_==="edit"&&PA.jsxDEV(j,{marginTop:2,children:PA.jsxDEV($,{dimColor:!0,italic:!0,children:"↑↓ Navigate SPACE Toggle ESC Cancel"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},m=()=>{return PA.jsxDEV(j,{flexDirection:"column",paddingX:2,paddingTop:1,children:[PA.jsxDEV(j,{marginBottom:2,children:PA.jsxDEV($,{color:"#00D9FF",children:"KEYBOARD SHORTCUTS"},void 0,!1,void 0,this)},void 0,!1,void 0,this),PA.jsxDEV(j,{flexDirection:"column",children:[{keys:"ESC",action:"Exit dashboard / Cancel edit"},{keys:"TAB",action:"Switch section"},{keys:"1-6",action:"Quick select section"},{keys:"ENTER",action:"Edit mode / Confirm"},{keys:"↑↓",action:"Navigate items (edit mode)"},{keys:"SPACE",action:"Toggle/Select (edit mode)"}].map((x,d)=>{return PA.jsxDEV(j,{marginBottom:1,children:[PA.jsxDEV($,{color:"#00FF88",children:x.keys},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:" → "},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:x.action},void 0,!1,void 0,this)]},d,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},o=()=>{switch(A){case"agents":return U();case"rules":return W();case"sessions":return Y();case"providers":return c();case"notifications":return l();case"keybindings":return m();default:return null}};return PA.jsxDEV(rj,{flexDirection:"column",children:[PA.jsxDEV(j,{flexShrink:0,paddingX:2,paddingY:1,children:[PA.jsxDEV($,{bold:!0,color:"#00D9FF",children:"SYLPHX FLOW"},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:" Control Panel"},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),_==="edit"&&PA.jsxDEV($,{color:"#FFD700",children:"EDIT MODE"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),PA.jsxDEV(j,{flexGrow:1,minHeight:0,flexDirection:"row",children:[PA.jsxDEV(j,{width:"25%",flexShrink:0,flexDirection:"column",paddingX:2,paddingY:1,children:[{id:"agents",label:"Agents",num:1},{id:"rules",label:"Rules",num:2},{id:"sessions",label:"Sessions",num:3},{id:"providers",label:"Providers",num:4},{id:"notifications",label:"Notifications",num:5},{id:"keybindings",label:"Keybindings",num:6}].map((P)=>{let x=A===P.id;return PA.jsxDEV(j,{marginBottom:1,children:[PA.jsxDEV($,{dimColor:!0,children:[P.num," "]},void 0,!0,void 0,this),PA.jsxDEV($,{bold:x,color:x?"#00FF88":"white",children:P.label},void 0,!1,void 0,this),x&&PA.jsxDEV(PA.Fragment,{children:[PA.jsxDEV($,{dimColor:!0,children:" "},void 0,!1,void 0,this),PA.jsxDEV($,{color:"#00FF88",children:"●"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},P.id,!0,void 0,this)})},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1,minHeight:0,flexDirection:"column",children:o()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),PA.jsxDEV(j,{flexShrink:0,paddingX:2,paddingY:1,children:[PA.jsxDEV($,{dimColor:!0,children:"TAB"},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:" Next "},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:"ENTER"},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:" Edit "},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:"ESC"},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,children:" Exit"},void 0,!1,void 0,this),PA.jsxDEV(j,{flexGrow:1},void 0,!1,void 0,this),PA.jsxDEV($,{dimColor:!0,italic:!0,children:"Press number keys 1-6 for quick navigation"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var ej=GA(KD(),1);function Ai(){ej.useEffect(()=>{(async()=>{try{let g=await(await t4()).getRecentSessions(20),a=sA.setState;a({sessions:g})}catch(_){console.error("Failed to load sessions from database:",_)}})();let D=sA.subscribe((_)=>_.sessions.length,(_,g)=>{if(_>g){let a=sA.setState,I=[...sA.getState().sessions].sort((C,y)=>y.updated-C.updated);a({sessions:I})}});return()=>{D()}},[])}var rg=GA(YD(),1);function FqA(){let A=sA((y)=>y.currentScreen),D=sA((y)=>y.isLoading),_=sA((y)=>y.error),g=sA((y)=>y.setError),[a,Q]=P8.useState(null),{loadConfig:I}=LI();Ai();let C=(y)=>{Q(y)};if(P8.useEffect(()=>{let y=process.cwd();Di(()=>sA),gi(()=>sA),_i(y).catch((w)=>{console.error("Failed to initialize agent manager:",w)}),ai(y).catch((w)=>{console.error("Failed to initialize rule manager:",w)}),I().catch((w)=>{console.error("Failed to load config:",w)})},[]),P8.useEffect(()=>{if(_){let y=setTimeout(()=>{g(null)},5000);return()=>clearTimeout(y)}},[_,g]),A==="dashboard")return rg.jsxDEV(AJ,{},void 0,!1,void 0,this);return rg.jsxDEV(j,{flexDirection:"column",width:"100%",height:"100%",paddingX:1,children:[rg.jsxDEV(j,{paddingY:1,children:[rg.jsxDEV($,{bold:!0,color:"#00D9FF",children:"SYLPHX FLOW"},void 0,!1,void 0,this),rg.jsxDEV($,{dimColor:!0,children:" │ "},void 0,!1,void 0,this),rg.jsxDEV($,{dimColor:!0,children:"AI Development Assistant"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_&&rg.jsxDEV(j,{paddingY:1,children:[rg.jsxDEV($,{color:"#FF3366",children:"▌"},void 0,!1,void 0,this),rg.jsxDEV($,{color:"#FF3366",bold:!0,children:" ERROR "},void 0,!1,void 0,this),rg.jsxDEV($,{color:"gray",children:_},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D&&rg.jsxDEV(j,{paddingY:1,children:[rg.jsxDEV($,{color:"#FFD700",children:"▌"},void 0,!1,void 0,this),rg.jsxDEV($,{color:"#FFD700",bold:!0,children:" LOADING"},void 0,!1,void 0,this),rg.jsxDEV($,{color:"gray",children:"..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),rg.jsxDEV(j,{flexDirection:"column",flexGrow:1,minHeight:0,children:[A==="chat"&&rg.jsxDEV(tH,{commandFromPalette:a},void 0,!1,void 0,this),A==="provider-management"&&rg.jsxDEV(e7,{},void 0,!1,void 0,this),A==="model-selection"&&rg.jsxDEV(DG,{},void 0,!1,void 0,this),A==="command-palette"&&rg.jsxDEV(_G,{onCommand:C},void 0,!1,void 0,this),A==="logs"&&rg.jsxDEV(eH,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function DJ(){return rg.jsxDEV(FqA,{},void 0,!1,void 0,this)}var Bi=GA(KD(),1);var QQ=GA(YD(),1);class _J extends Bi.default.Component{constructor(A){super(A);this.state={hasError:!1,error:null}}static getDerivedStateFromError(A){return{hasError:!0,error:A}}componentDidCatch(A,D){console.error("React Error Boundary caught error:",A),console.error("Error info:",D)}render(){if(this.state.hasError)return QQ.jsxDEV(j,{flexDirection:"column",padding:1,children:[QQ.jsxDEV(j,{marginBottom:1,children:QQ.jsxDEV($,{color:"red",bold:!0,children:"[ERROR] Application Error"},void 0,!1,void 0,this)},void 0,!1,void 0,this),QQ.jsxDEV(j,{marginBottom:1,children:QQ.jsxDEV($,{color:"yellow",children:"The application encountered an error and needs to restart."},void 0,!1,void 0,this)},void 0,!1,void 0,this),this.state.error&&QQ.jsxDEV(j,{flexDirection:"column",marginBottom:1,children:[QQ.jsxDEV($,{color:"gray",children:["Error: ",this.state.error.message]},void 0,!0,void 0,this),this.state.error.stack&&QQ.jsxDEV($,{color:"gray",dimColor:!0,children:this.state.error.stack.split(`
|
|
434
434
|
`).slice(0,5).join(`
|
|
435
435
|
`)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),QQ.jsxDEV(j,{children:QQ.jsxDEV($,{dimColor:!0,children:"Press Ctrl+C to exit and restart the application."},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return this.props.children}}async function uqA(){try{await BJ()}catch(A){console.error(CA.red("✗ Failed to initialize database:"),A),process.exit(1)}t1(aJ.default.createElement(_J,null,aJ.default.createElement(DJ)))}async function kqA(A,D){try{await BJ()}catch(u){console.error(CA.red("✗ Failed to initialize database:"),u),process.exit(1)}let _=await Qi(D.continue||!1);if(!_)process.exit(1);let g=Ew(_.provider),a=await d6();if(a._tag==="Failure")console.error(CA.red("✗ Failed to load config")),process.exit(1);let I=a.value.providers?.[_.provider];if(!I)console.error(CA.red(`✗ Provider ${_.provider} not configured`)),process.exit(1);if(!g.isConfigured(I))console.error(CA.red(`✗ ${g.name} is not properly configured`)),process.exit(1);let C=g.createClient(I,_.model),y=gJ(_,"user",A),w=await t4();if(await w.addMessage(_.id,"user",[{type:"text",content:A}]),!D.quiet)console.error(CA.dim(`
|
|
436
436
|
${_.provider} · ${_.model}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
CREATE TABLE `codebase_files` (
|
|
2
|
+
`path` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`mtime` integer NOT NULL,
|
|
4
|
+
`hash` text NOT NULL,
|
|
5
|
+
`content` text,
|
|
6
|
+
`language` text,
|
|
7
|
+
`size` integer,
|
|
8
|
+
`indexed_at` text NOT NULL
|
|
9
|
+
);
|
|
10
|
+
--> statement-breakpoint
|
|
11
|
+
CREATE INDEX `idx_codebase_files_mtime` ON `codebase_files` (`mtime`);--> statement-breakpoint
|
|
12
|
+
CREATE INDEX `idx_codebase_files_hash` ON `codebase_files` (`hash`);--> statement-breakpoint
|
|
13
|
+
CREATE TABLE `codebase_metadata` (
|
|
14
|
+
`key` text PRIMARY KEY NOT NULL,
|
|
15
|
+
`value` text NOT NULL
|
|
16
|
+
);
|
|
17
|
+
--> statement-breakpoint
|
|
18
|
+
CREATE TABLE `memory` (
|
|
19
|
+
`key` text NOT NULL,
|
|
20
|
+
`namespace` text DEFAULT 'default' NOT NULL,
|
|
21
|
+
`value` text NOT NULL,
|
|
22
|
+
`timestamp` integer NOT NULL,
|
|
23
|
+
`created_at` text NOT NULL,
|
|
24
|
+
`updated_at` text NOT NULL,
|
|
25
|
+
PRIMARY KEY(`key`, `namespace`)
|
|
26
|
+
);
|
|
27
|
+
--> statement-breakpoint
|
|
28
|
+
CREATE INDEX `idx_memory_namespace` ON `memory` (`namespace`);--> statement-breakpoint
|
|
29
|
+
CREATE INDEX `idx_memory_timestamp` ON `memory` (`timestamp`);--> statement-breakpoint
|
|
30
|
+
CREATE INDEX `idx_memory_key` ON `memory` (`key`);--> statement-breakpoint
|
|
31
|
+
CREATE TABLE `tfidf_documents` (
|
|
32
|
+
`file_path` text PRIMARY KEY NOT NULL,
|
|
33
|
+
`magnitude` real NOT NULL,
|
|
34
|
+
`term_count` integer NOT NULL,
|
|
35
|
+
`raw_terms` text NOT NULL,
|
|
36
|
+
FOREIGN KEY (`file_path`) REFERENCES `codebase_files`(`path`) ON UPDATE no action ON DELETE cascade
|
|
37
|
+
);
|
|
38
|
+
--> statement-breakpoint
|
|
39
|
+
CREATE TABLE `tfidf_idf` (
|
|
40
|
+
`term` text PRIMARY KEY NOT NULL,
|
|
41
|
+
`idf_value` real NOT NULL
|
|
42
|
+
);
|
|
43
|
+
--> statement-breakpoint
|
|
44
|
+
CREATE TABLE `tfidf_terms` (
|
|
45
|
+
`file_path` text NOT NULL,
|
|
46
|
+
`term` text NOT NULL,
|
|
47
|
+
`frequency` real NOT NULL,
|
|
48
|
+
FOREIGN KEY (`file_path`) REFERENCES `codebase_files`(`path`) ON UPDATE no action ON DELETE cascade
|
|
49
|
+
);
|
|
50
|
+
--> statement-breakpoint
|
|
51
|
+
CREATE INDEX `idx_tfidf_terms_term` ON `tfidf_terms` (`term`);--> statement-breakpoint
|
|
52
|
+
CREATE INDEX `idx_tfidf_terms_file` ON `tfidf_terms` (`file_path`);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
CREATE TABLE `message_attachments` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`message_id` text NOT NULL,
|
|
4
|
+
`path` text NOT NULL,
|
|
5
|
+
`relative_path` text NOT NULL,
|
|
6
|
+
`size` integer,
|
|
7
|
+
FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`) ON UPDATE no action ON DELETE cascade
|
|
8
|
+
);
|
|
9
|
+
--> statement-breakpoint
|
|
10
|
+
CREATE INDEX `idx_message_attachments_message` ON `message_attachments` (`message_id`);--> statement-breakpoint
|
|
11
|
+
CREATE INDEX `idx_message_attachments_path` ON `message_attachments` (`path`);--> statement-breakpoint
|
|
12
|
+
CREATE TABLE `message_parts` (
|
|
13
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
14
|
+
`message_id` text NOT NULL,
|
|
15
|
+
`ordering` integer NOT NULL,
|
|
16
|
+
`type` text NOT NULL,
|
|
17
|
+
`content` text NOT NULL,
|
|
18
|
+
FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`) ON UPDATE no action ON DELETE cascade
|
|
19
|
+
);
|
|
20
|
+
--> statement-breakpoint
|
|
21
|
+
CREATE INDEX `idx_message_parts_message` ON `message_parts` (`message_id`);--> statement-breakpoint
|
|
22
|
+
CREATE INDEX `idx_message_parts_ordering` ON `message_parts` (`message_id`,`ordering`);--> statement-breakpoint
|
|
23
|
+
CREATE INDEX `idx_message_parts_type` ON `message_parts` (`type`);--> statement-breakpoint
|
|
24
|
+
CREATE TABLE `message_todo_snapshots` (
|
|
25
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
26
|
+
`message_id` text NOT NULL,
|
|
27
|
+
`todo_id` integer NOT NULL,
|
|
28
|
+
`content` text NOT NULL,
|
|
29
|
+
`active_form` text NOT NULL,
|
|
30
|
+
`status` text NOT NULL,
|
|
31
|
+
`ordering` integer NOT NULL,
|
|
32
|
+
FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`) ON UPDATE no action ON DELETE cascade
|
|
33
|
+
);
|
|
34
|
+
--> statement-breakpoint
|
|
35
|
+
CREATE INDEX `idx_message_todo_snapshots_message` ON `message_todo_snapshots` (`message_id`);--> statement-breakpoint
|
|
36
|
+
CREATE TABLE `message_usage` (
|
|
37
|
+
`message_id` text PRIMARY KEY NOT NULL,
|
|
38
|
+
`prompt_tokens` integer NOT NULL,
|
|
39
|
+
`completion_tokens` integer NOT NULL,
|
|
40
|
+
`total_tokens` integer NOT NULL,
|
|
41
|
+
FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`) ON UPDATE no action ON DELETE cascade
|
|
42
|
+
);
|
|
43
|
+
--> statement-breakpoint
|
|
44
|
+
CREATE TABLE `messages` (
|
|
45
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
46
|
+
`session_id` text NOT NULL,
|
|
47
|
+
`role` text NOT NULL,
|
|
48
|
+
`timestamp` integer NOT NULL,
|
|
49
|
+
`ordering` integer NOT NULL,
|
|
50
|
+
`finish_reason` text,
|
|
51
|
+
`metadata` text,
|
|
52
|
+
FOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade
|
|
53
|
+
);
|
|
54
|
+
--> statement-breakpoint
|
|
55
|
+
CREATE INDEX `idx_messages_session` ON `messages` (`session_id`);--> statement-breakpoint
|
|
56
|
+
CREATE INDEX `idx_messages_ordering` ON `messages` (`session_id`,`ordering`);--> statement-breakpoint
|
|
57
|
+
CREATE INDEX `idx_messages_timestamp` ON `messages` (`timestamp`);--> statement-breakpoint
|
|
58
|
+
CREATE TABLE `sessions` (
|
|
59
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
60
|
+
`title` text,
|
|
61
|
+
`provider` text NOT NULL,
|
|
62
|
+
`model` text NOT NULL,
|
|
63
|
+
`next_todo_id` integer DEFAULT 1 NOT NULL,
|
|
64
|
+
`created` integer NOT NULL,
|
|
65
|
+
`updated` integer NOT NULL
|
|
66
|
+
);
|
|
67
|
+
--> statement-breakpoint
|
|
68
|
+
CREATE INDEX `idx_sessions_updated` ON `sessions` (`updated`);--> statement-breakpoint
|
|
69
|
+
CREATE INDEX `idx_sessions_created` ON `sessions` (`created`);--> statement-breakpoint
|
|
70
|
+
CREATE INDEX `idx_sessions_provider` ON `sessions` (`provider`);--> statement-breakpoint
|
|
71
|
+
CREATE INDEX `idx_sessions_title` ON `sessions` (`title`);--> statement-breakpoint
|
|
72
|
+
CREATE TABLE `todos` (
|
|
73
|
+
`id` integer NOT NULL,
|
|
74
|
+
`session_id` text NOT NULL,
|
|
75
|
+
`content` text NOT NULL,
|
|
76
|
+
`active_form` text NOT NULL,
|
|
77
|
+
`status` text NOT NULL,
|
|
78
|
+
`ordering` integer NOT NULL,
|
|
79
|
+
PRIMARY KEY(`session_id`, `id`),
|
|
80
|
+
FOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON UPDATE no action ON DELETE cascade
|
|
81
|
+
);
|
|
82
|
+
--> statement-breakpoint
|
|
83
|
+
CREATE INDEX `idx_todos_session` ON `todos` (`session_id`);--> statement-breakpoint
|
|
84
|
+
CREATE INDEX `idx_todos_status` ON `todos` (`status`);--> statement-breakpoint
|
|
85
|
+
CREATE INDEX `idx_todos_ordering` ON `todos` (`session_id`,`ordering`);
|