@townco/gui-template 0.1.48 → 0.1.49

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.
@@ -1 +1 @@
1
- import{n as h,a as p,s as e,o,r as a,u as t,b as l,l as n,c as s,d as m}from"./vendor-BrF4o6BL.js";const Qe=1,x=h(),C=p(),w=e(),q=o({_meta:a(t()).optional(),content:e(),path:e(),sessionId:e()}),f=o({_meta:a(t()).optional(),limit:p().optional().nullable(),line:p().optional().nullable(),path:e(),sessionId:e()}),M=o({_meta:a(t()).optional(),sessionId:e(),terminalId:e()}),k=o({_meta:a(t()).optional(),sessionId:e(),terminalId:e()}),v=o({_meta:a(t()).optional(),sessionId:e(),terminalId:e()}),O=o({_meta:a(t()).optional(),sessionId:e(),terminalId:e()}),F=a(t()),U=l([n("assistant"),n("user")]),z=o({_meta:a(t()).optional(),mimeType:e().optional().nullable(),text:e(),uri:e()}),N=o({_meta:a(t()).optional(),blob:e(),mimeType:e().optional().nullable(),uri:e()}),b=l([n("read"),n("edit"),n("delete"),n("move"),n("search"),n("execute"),n("think"),n("fetch"),n("switch_mode"),n("other")]),_=l([n("pending"),n("in_progress"),n("completed"),n("failed")]),S=o({code:p(),data:a(t()).optional(),message:e()}),E=o({_meta:a(t()).optional()}),P=o({_meta:t().optional()}),V=o({_meta:a(t()).optional(),stopReason:l([n("end_turn"),n("max_tokens"),n("max_turn_requests"),n("refusal"),n("cancelled")])}),j=o({_meta:a(t()).optional()}),L=a(t()),B=e(),H=a(t()),K=o({hint:e()}),A=h(),D=p(),G=e(),J=o({_meta:a(t()).optional(),methodId:e()}),Q=o({_meta:a(t()).optional(),modeId:e(),sessionId:e()}),W=o({_meta:a(t()).optional(),modelId:e(),sessionId:e()}),X=a(t()),d=o({_meta:a(t()).optional(),name:e(),value:e()}),i=o({_meta:a(t()).optional(),audience:s(U).optional().nullable(),lastModified:e().optional().nullable(),priority:p().optional().nullable()}),c=l([z,N]),Y=o({_meta:a(t()).optional()}),Z=o({_meta:a(t()).optional(),content:e()}),$=o({_meta:a(t()).optional(),outcome:l([o({outcome:n("cancelled")}),o({optionId:e(),outcome:n("selected")})])}),ee=o({_meta:a(t()).optional(),terminalId:e()}),oe=o({_meta:a(t()).optional()}),te=o({_meta:a(t()).optional(),exitCode:p().optional().nullable(),signal:e().optional().nullable()}),ae=o({_meta:a(t()).optional()}),ne=a(t()),le=o({_meta:a(t()).optional(),sessionId:e()}),ie=a(t()),se=o({_meta:a(t()).optional(),kind:l([n("allow_once"),n("allow_always"),n("reject_once"),n("reject_always")]),name:e(),optionId:e()}),u=l([o({content:l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),type:n("content")}),o({_meta:a(t()).optional(),newText:e(),oldText:e().optional().nullable(),path:e(),type:n("diff")}),o({terminalId:e(),type:n("terminal")})]),r=o({_meta:a(t()).optional(),line:p().optional().nullable(),path:e()}),y=o({_meta:a(t()).optional(),name:e(),value:e()}),R=o({name:e(),title:e().optional().nullable(),version:e()}),pe=o({_meta:a(t()).optional(),description:e().optional().nullable(),id:e(),name:e()}),me=o({_meta:a(t()).optional(),http:m().optional(),sse:m().optional()}),ce=o({_meta:a(t()).optional(),audio:m().optional(),embeddedContext:m().optional(),image:m().optional()}),ue=o({_meta:a(t()).optional(),description:e().optional().nullable(),modelId:e(),name:e()}),re=o({_meta:a(t()).optional(),description:e().optional().nullable(),id:B,name:e()}),T=o({_meta:a(t()).optional(),availableModels:s(ue),currentModelId:e()}),I=o({_meta:a(t()).optional(),availableModes:s(re),currentModeId:e()}),de=o({_meta:a(t()).optional(),content:e(),priority:l([n("high"),n("medium"),n("low")]),status:l([n("pending"),n("in_progress"),n("completed")])}),he=K,be=o({_meta:a(t()).optional(),readTextFile:m().optional(),writeTextFile:m().optional()}),_e=o({args:s(e()),command:e(),env:s(y),name:e()}),g=l([o({headers:s(d),name:e(),type:n("http"),url:e()}),o({headers:s(d),name:e(),type:n("sse"),url:e()}),_e]),Se=l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),ye=o({_meta:a(t()).optional(),exitCode:p().optional().nullable(),signal:e().optional().nullable()}),Re=l([le,ie]),Te=o({_meta:a(t()).optional(),options:s(se),sessionId:e(),toolCall:o({_meta:a(t()).optional(),content:s(u).optional().nullable(),kind:b.optional().nullable(),locations:s(r).optional().nullable(),rawInput:a(t()).optional(),rawOutput:a(t()).optional(),status:_.optional().nullable(),title:e().optional().nullable(),toolCallId:e()})}),Ie=o({_meta:a(t()).optional(),args:s(e()).optional(),command:e(),cwd:e().optional().nullable(),env:s(y).optional(),outputByteLimit:p().optional().nullable(),sessionId:e()}),ge=o({_meta:a(t()).optional(),models:T.optional().nullable(),modes:I.optional().nullable(),sessionId:e()}),xe=o({_meta:a(t()).optional(),models:T.optional().nullable(),modes:I.optional().nullable()}),Ce=o({method:e(),params:Re.optional().nullable()}),we=o({_meta:a(t()).optional(),cwd:e(),mcpServers:s(g)}),qe=o({_meta:a(t()).optional(),cwd:e(),mcpServers:s(g),sessionId:e()}),fe=o({_meta:a(t()).optional(),prompt:s(Se),sessionId:e()}),Me=o({_meta:a(t()).optional(),exitStatus:ye.optional().nullable(),output:e(),truncated:m()}),ke=l([q,f,Te,Ie,M,k,v,O,F]),ve=o({_meta:a(t()).optional(),loadSession:m().optional(),mcpCapabilities:me.optional(),promptCapabilities:ce.optional()}),Oe=o({_meta:a(t()).optional(),description:e(),input:he.optional().nullable(),name:e()}),Fe=o({_meta:a(t()).optional(),fs:be.optional(),terminal:m().optional()}),Ue=o({id:l([x,C,w]),method:e(),params:ke.optional().nullable()}),ze=o({_meta:a(t()).optional(),agentCapabilities:ve.optional(),agentInfo:R.optional().nullable(),authMethods:s(pe).optional(),protocolVersion:p()}),Ne=o({_meta:a(t()).optional(),sessionId:e(),update:l([o({_meta:a(t()).optional(),content:l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),sessionUpdate:n("user_message_chunk")}),o({_meta:a(t()).optional(),content:l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),sessionUpdate:n("agent_message_chunk")}),o({_meta:a(t()).optional(),content:l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),sessionUpdate:n("agent_thought_chunk")}),o({_meta:a(t()).optional(),content:s(u).optional(),kind:l([n("read"),n("edit"),n("delete"),n("move"),n("search"),n("execute"),n("think"),n("fetch"),n("switch_mode"),n("other")]).optional(),locations:s(r).optional(),rawInput:a(t()).optional(),rawOutput:a(t()).optional(),sessionUpdate:n("tool_call"),status:l([n("pending"),n("in_progress"),n("completed"),n("failed")]).optional(),title:e(),toolCallId:e()}),o({_meta:a(t()).optional(),content:s(u).optional().nullable(),kind:b.optional().nullable(),locations:s(r).optional().nullable(),rawInput:a(t()).optional(),rawOutput:a(t()).optional(),sessionUpdate:n("tool_call_update"),status:_.optional().nullable(),title:e().optional().nullable(),toolCallId:e()}),o({_meta:a(t()).optional(),entries:s(de),sessionUpdate:n("plan")}),o({_meta:a(t()).optional(),availableCommands:s(Oe),sessionUpdate:n("available_commands_update")}),o({_meta:a(t()).optional(),currentModeId:e(),sessionUpdate:n("current_mode_update")})])}),Ee=o({_meta:a(t()).optional(),clientCapabilities:Fe.optional(),clientInfo:R.optional().nullable(),protocolVersion:p()}),Pe=l([Y,Z,$,ee,Me,oe,te,ae,ne]),Ve=l([Ne,H]),je=l([Ee,J,we,qe,Q,fe,W,X]),Le=o({method:e(),params:Ve.optional().nullable()}),Be=l([ze,E,ge,xe,P,V,j,L]),He=o({id:l([A,D,G]),method:e(),params:je.optional().nullable()}),Ke=l([o({result:Pe}),o({error:S})]),Ae=l([He,Ke,Ce]),De=l([o({result:Be}),o({error:S})]),Ge=l([Ue,De,Le]);l([Ge,Ae]);export{Qe as P,Ge as a};
1
+ import{n as h,a as p,s as e,o,r as a,u as t,b as l,l as n,c as s,d as m}from"./vendor-MRgUePH2.js";const Qe=1,x=h(),C=p(),w=e(),q=o({_meta:a(t()).optional(),content:e(),path:e(),sessionId:e()}),f=o({_meta:a(t()).optional(),limit:p().optional().nullable(),line:p().optional().nullable(),path:e(),sessionId:e()}),M=o({_meta:a(t()).optional(),sessionId:e(),terminalId:e()}),k=o({_meta:a(t()).optional(),sessionId:e(),terminalId:e()}),v=o({_meta:a(t()).optional(),sessionId:e(),terminalId:e()}),O=o({_meta:a(t()).optional(),sessionId:e(),terminalId:e()}),F=a(t()),U=l([n("assistant"),n("user")]),z=o({_meta:a(t()).optional(),mimeType:e().optional().nullable(),text:e(),uri:e()}),N=o({_meta:a(t()).optional(),blob:e(),mimeType:e().optional().nullable(),uri:e()}),b=l([n("read"),n("edit"),n("delete"),n("move"),n("search"),n("execute"),n("think"),n("fetch"),n("switch_mode"),n("other")]),_=l([n("pending"),n("in_progress"),n("completed"),n("failed")]),S=o({code:p(),data:a(t()).optional(),message:e()}),E=o({_meta:a(t()).optional()}),P=o({_meta:t().optional()}),V=o({_meta:a(t()).optional(),stopReason:l([n("end_turn"),n("max_tokens"),n("max_turn_requests"),n("refusal"),n("cancelled")])}),j=o({_meta:a(t()).optional()}),L=a(t()),B=e(),H=a(t()),K=o({hint:e()}),A=h(),D=p(),G=e(),J=o({_meta:a(t()).optional(),methodId:e()}),Q=o({_meta:a(t()).optional(),modeId:e(),sessionId:e()}),W=o({_meta:a(t()).optional(),modelId:e(),sessionId:e()}),X=a(t()),d=o({_meta:a(t()).optional(),name:e(),value:e()}),i=o({_meta:a(t()).optional(),audience:s(U).optional().nullable(),lastModified:e().optional().nullable(),priority:p().optional().nullable()}),c=l([z,N]),Y=o({_meta:a(t()).optional()}),Z=o({_meta:a(t()).optional(),content:e()}),$=o({_meta:a(t()).optional(),outcome:l([o({outcome:n("cancelled")}),o({optionId:e(),outcome:n("selected")})])}),ee=o({_meta:a(t()).optional(),terminalId:e()}),oe=o({_meta:a(t()).optional()}),te=o({_meta:a(t()).optional(),exitCode:p().optional().nullable(),signal:e().optional().nullable()}),ae=o({_meta:a(t()).optional()}),ne=a(t()),le=o({_meta:a(t()).optional(),sessionId:e()}),ie=a(t()),se=o({_meta:a(t()).optional(),kind:l([n("allow_once"),n("allow_always"),n("reject_once"),n("reject_always")]),name:e(),optionId:e()}),u=l([o({content:l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),type:n("content")}),o({_meta:a(t()).optional(),newText:e(),oldText:e().optional().nullable(),path:e(),type:n("diff")}),o({terminalId:e(),type:n("terminal")})]),r=o({_meta:a(t()).optional(),line:p().optional().nullable(),path:e()}),y=o({_meta:a(t()).optional(),name:e(),value:e()}),R=o({name:e(),title:e().optional().nullable(),version:e()}),pe=o({_meta:a(t()).optional(),description:e().optional().nullable(),id:e(),name:e()}),me=o({_meta:a(t()).optional(),http:m().optional(),sse:m().optional()}),ce=o({_meta:a(t()).optional(),audio:m().optional(),embeddedContext:m().optional(),image:m().optional()}),ue=o({_meta:a(t()).optional(),description:e().optional().nullable(),modelId:e(),name:e()}),re=o({_meta:a(t()).optional(),description:e().optional().nullable(),id:B,name:e()}),T=o({_meta:a(t()).optional(),availableModels:s(ue),currentModelId:e()}),I=o({_meta:a(t()).optional(),availableModes:s(re),currentModeId:e()}),de=o({_meta:a(t()).optional(),content:e(),priority:l([n("high"),n("medium"),n("low")]),status:l([n("pending"),n("in_progress"),n("completed")])}),he=K,be=o({_meta:a(t()).optional(),readTextFile:m().optional(),writeTextFile:m().optional()}),_e=o({args:s(e()),command:e(),env:s(y),name:e()}),g=l([o({headers:s(d),name:e(),type:n("http"),url:e()}),o({headers:s(d),name:e(),type:n("sse"),url:e()}),_e]),Se=l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),ye=o({_meta:a(t()).optional(),exitCode:p().optional().nullable(),signal:e().optional().nullable()}),Re=l([le,ie]),Te=o({_meta:a(t()).optional(),options:s(se),sessionId:e(),toolCall:o({_meta:a(t()).optional(),content:s(u).optional().nullable(),kind:b.optional().nullable(),locations:s(r).optional().nullable(),rawInput:a(t()).optional(),rawOutput:a(t()).optional(),status:_.optional().nullable(),title:e().optional().nullable(),toolCallId:e()})}),Ie=o({_meta:a(t()).optional(),args:s(e()).optional(),command:e(),cwd:e().optional().nullable(),env:s(y).optional(),outputByteLimit:p().optional().nullable(),sessionId:e()}),ge=o({_meta:a(t()).optional(),models:T.optional().nullable(),modes:I.optional().nullable(),sessionId:e()}),xe=o({_meta:a(t()).optional(),models:T.optional().nullable(),modes:I.optional().nullable()}),Ce=o({method:e(),params:Re.optional().nullable()}),we=o({_meta:a(t()).optional(),cwd:e(),mcpServers:s(g)}),qe=o({_meta:a(t()).optional(),cwd:e(),mcpServers:s(g),sessionId:e()}),fe=o({_meta:a(t()).optional(),prompt:s(Se),sessionId:e()}),Me=o({_meta:a(t()).optional(),exitStatus:ye.optional().nullable(),output:e(),truncated:m()}),ke=l([q,f,Te,Ie,M,k,v,O,F]),ve=o({_meta:a(t()).optional(),loadSession:m().optional(),mcpCapabilities:me.optional(),promptCapabilities:ce.optional()}),Oe=o({_meta:a(t()).optional(),description:e(),input:he.optional().nullable(),name:e()}),Fe=o({_meta:a(t()).optional(),fs:be.optional(),terminal:m().optional()}),Ue=o({id:l([x,C,w]),method:e(),params:ke.optional().nullable()}),ze=o({_meta:a(t()).optional(),agentCapabilities:ve.optional(),agentInfo:R.optional().nullable(),authMethods:s(pe).optional(),protocolVersion:p()}),Ne=o({_meta:a(t()).optional(),sessionId:e(),update:l([o({_meta:a(t()).optional(),content:l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),sessionUpdate:n("user_message_chunk")}),o({_meta:a(t()).optional(),content:l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),sessionUpdate:n("agent_message_chunk")}),o({_meta:a(t()).optional(),content:l([o({_meta:a(t()).optional(),annotations:i.optional().nullable(),text:e(),type:n("text")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("image"),uri:e().optional().nullable()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),data:e(),mimeType:e(),type:n("audio")}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),description:e().optional().nullable(),mimeType:e().optional().nullable(),name:e(),size:p().optional().nullable(),title:e().optional().nullable(),type:n("resource_link"),uri:e()}),o({_meta:a(t()).optional(),annotations:i.optional().nullable(),resource:c,type:n("resource")})]),sessionUpdate:n("agent_thought_chunk")}),o({_meta:a(t()).optional(),content:s(u).optional(),kind:l([n("read"),n("edit"),n("delete"),n("move"),n("search"),n("execute"),n("think"),n("fetch"),n("switch_mode"),n("other")]).optional(),locations:s(r).optional(),rawInput:a(t()).optional(),rawOutput:a(t()).optional(),sessionUpdate:n("tool_call"),status:l([n("pending"),n("in_progress"),n("completed"),n("failed")]).optional(),title:e(),toolCallId:e()}),o({_meta:a(t()).optional(),content:s(u).optional().nullable(),kind:b.optional().nullable(),locations:s(r).optional().nullable(),rawInput:a(t()).optional(),rawOutput:a(t()).optional(),sessionUpdate:n("tool_call_update"),status:_.optional().nullable(),title:e().optional().nullable(),toolCallId:e()}),o({_meta:a(t()).optional(),entries:s(de),sessionUpdate:n("plan")}),o({_meta:a(t()).optional(),availableCommands:s(Oe),sessionUpdate:n("available_commands_update")}),o({_meta:a(t()).optional(),currentModeId:e(),sessionUpdate:n("current_mode_update")})])}),Ee=o({_meta:a(t()).optional(),clientCapabilities:Fe.optional(),clientInfo:R.optional().nullable(),protocolVersion:p()}),Pe=l([Y,Z,$,ee,Me,oe,te,ae,ne]),Ve=l([Ne,H]),je=l([Ee,J,we,qe,Q,fe,W,X]),Le=o({method:e(),params:Ve.optional().nullable()}),Be=l([ze,E,ge,xe,P,V,j,L]),He=o({id:l([A,D,G]),method:e(),params:je.optional().nullable()}),Ke=l([o({result:Pe}),o({error:S})]),Ae=l([He,Ke,Ce]),De=l([o({result:Be}),o({error:S})]),Ge=l([Ue,De,Le]);l([Ge,Ae]);export{Qe as P,Ge as a};
@@ -0,0 +1 @@
1
+ import{r as s}from"./react-BVqFSXsV.js";const _=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),m=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(a,c,o)=>o?o.toUpperCase():c.toLowerCase()),h=t=>{const a=m(t);return a.charAt(0).toUpperCase()+a.slice(1)},i=(...t)=>t.filter((a,c,o)=>!!a&&a.trim()!==""&&o.indexOf(a)===c).join(" ").trim(),M=t=>{for(const a in t)if(a.startsWith("aria-")||a==="role"||a==="title")return!0};var u={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const x=s.forwardRef(({color:t="currentColor",size:a=24,strokeWidth:c=2,absoluteStrokeWidth:o,className:r="",children:n,iconNode:y,...d},l)=>s.createElement("svg",{ref:l,...u,width:a,height:a,stroke:t,strokeWidth:o?Number(c)*24/Number(a):c,className:i("lucide",r),...!n&&!M(d)&&{"aria-hidden":"true"},...d},[...y.map(([k,p])=>s.createElement(k,p)),...Array.isArray(n)?n:[n]]));const e=(t,a)=>{const c=s.forwardRef(({className:o,...r},n)=>s.createElement(x,{ref:n,iconNode:a,className:i(`lucide-${_(h(t))}`,`lucide-${t}`,o),...r}));return c.displayName=h(t),c};const g=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],n1=e("arrow-down",g);const v=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],s1=e("arrow-up",v);const f=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],r1=e("bug",f);const $=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],d1=e("check",$);const w=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],h1=e("chevron-down",w);const N=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],i1=e("chevron-right",N);const C=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],y1=e("chevron-up",C);const b=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],l1=e("chevrons-up-down",b);const z=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],k1=e("circle-alert",z);const A=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],p1=e("circle-check",A);const j=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],_1=e("circle-dot",j);const q=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],m1=e("circle",q);const H=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],M1=e("cloud",H);const L=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],u1=e("database",L);const V=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],x1=e("ellipsis-vertical",V);const S=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],g1=e("file-code",S);const P=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],v1=e("file-text",P);const B=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],f1=e("folder-open",B);const D=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],$1=e("folder",D);const E=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],w1=e("globe",E);const F=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],N1=e("image",F);const U=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],C1=e("link-2",U);const I=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],b1=e("link",I);const R=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 19H3",key:"108z41"}],["path",{d:"M15 12.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997a1 1 0 0 1-1.517-.86z",key:"ms4nik"}]],z1=e("list-video",R);const W=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],A1=e("loader-circle",W);const Z=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],j1=e("mic",Z);const G=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],q1=e("moon",G);const O=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],H1=e("panel-right",O);const K=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],L1=e("paperclip",K);const T=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],V1=e("plus",T);const X=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],S1=e("search",X);const J=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],P1=e("settings",J);const Q=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],B1=e("square-check-big",Q);const Y=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],D1=e("square-pen",Y);const e1=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],E1=e("square-slash",e1);const a1=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],F1=e("sun",a1);const t1=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],U1=e("wrench",t1);const c1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],I1=e("x",c1);export{n1 as A,r1 as B,i1 as C,u1 as D,x1 as E,f1 as F,w1 as G,N1 as I,C1 as L,j1 as M,L1 as P,E1 as S,U1 as W,I1 as X,d1 as a,m1 as b,$1 as c,g1 as d,h1 as e,p1 as f,B1 as g,v1 as h,H1 as i,V1 as j,s1 as k,P1 as l,y1 as m,z1 as n,A1 as o,_1 as p,D1 as q,S1 as r,M1 as s,b1 as t,k1 as u,l1 as v,F1 as w,q1 as x};
@@ -0,0 +1,9 @@
1
+ import{r as l,j as e,P as Hs,h as Ws,i as Vs,M as qs,b as Le,k as Gs}from"./react-BVqFSXsV.js";import{S as ue,L as Ks,M as et,N as ee,O as D,P as z,Q as N,R as ze,T as V,U as B,W as le,X as Y,Y as X,Z as Qs,$ as ke,a0 as Js,a1 as Ys,a2 as Xs,a3 as Zs,a4 as ce,a5 as en,a6 as tt}from"./vendor-MRgUePH2.js";import{P as st,a as tn}from"./acp-sdk-D6pxVlZx.js";import{S as ve,a as mt,b as ft,P as sn,C as gt,I as ht,c as xt,d as bt,R as yt,L as vt,e as wt,f as nn,T as on,g as jt,h as Nt,i as St,j as an,k as Ct,l as rn,m as ln,n as cn,O as Tt,o as dn,p as kt,q as un,r as It,D as Et,s as Rt,t as At,u as pn,v as _t,w as Mt,x as mn,y as Pt,V as fn,z as Dt,A as Ut,B as gn,E as hn,F as Lt}from"./radix-ChM6MBck.js";import{C as he,S as xn,P as bn,M as yn,A as vn,a as zt,b as Fe,F as wn,c as jn,d as Nn,E as Sn,e as ie,f as Ft,g as Ee,h as Oe,D as Ot,L as $t,B as nt,i as Cn,j as Tn,X as Bt,k as kn,l as Ht,m as Wt,n as Vt,o as qt,p as Gt,W as In,q as En,r as Rn,s as An,t as _n,I as Mn,G as Pn,u as Dn,v as Un,w as Ln,x as zn}from"./icons-C6hTt5Kh.js";import{r as Fn}from"./markdown-BQwuNzn9.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const r of a.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&n(r)}).observe(document,{childList:!0,subtree:!0});function o(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function n(i){if(i.ep)return;i.ep=!0;const a=o(i);fetch(i.href,a)}})();var On={};const Ne=typeof process<"u"&&process.versions?.node;let $n,Bn=0;const Hn=new Set;function Wn(t){for(const s of Hn)s(t)}const ot={trace:0,debug:1,info:2,warn:3,error:4,fatal:5},Vn={trace:ue.TRACE,debug:ue.DEBUG,info:ue.INFO,warn:ue.WARN,error:ue.ERROR,fatal:ue.FATAL};class qn{service;minLevel;logFilePath;logsDir;writeQueue=[];isWriting=!1;enableConsoleOutput;constructor(s,o="debug"){this.service=s,this.minLevel=o,typeof process<"u"&&(this.minLevel="info"),this.enableConsoleOutput=typeof process<"u"&&On?.TOWN_LOG_CONSOLE==="true"||!1}setupFileLogging(){}async writeToFile(s){if(!(!this.logFilePath||!Ne)&&(this.writeQueue.push(s),!this.isWriting)){for(this.isWriting=!0;this.writeQueue.length>0;){const n=`${this.writeQueue.splice(0,this.writeQueue.length).join(`
2
+ `)}
3
+ `;try{await require("node:fs").promises.appendFile(this.logFilePath,n,"utf-8")}catch{}}this.isWriting=!1}}shouldLog(s){return ot[s]>=ot[this.minLevel]}log(s,o,n){if(!this.shouldLog(s))return;const i={id:`log_${++Bn}`,timestamp:new Date().toISOString(),level:s,service:this.service,message:o,...n&&{metadata:n}};if(Wn(i),Ne&&this.logFilePath,Ne&&this.logFilePath){const m={timestamp:i.timestamp,level:i.level,service:i.service,message:i.message,...i.metadata&&{metadata:i.metadata}};this.writeToFile(JSON.stringify(m)).catch(()=>{})}if(Ne&&this.enableConsoleOutput){const m=i.timestamp,u=i.level.toUpperCase().padEnd(5),c=`[${this.service}]`,d=i.metadata?` ${JSON.stringify(i.metadata)}`:"";console.log(`${m} ${u} ${c} ${i.message}${d}`)}const a=Ks.getLogger(this.service),r=et.trace.getSpan(et.context.active());a.emit({severityNumber:Vn[s],severityText:s.toUpperCase(),body:o,attributes:{service:this.service,...n&&Object.fromEntries(Object.entries(n).map(([m,u])=>[`log.${m}`,typeof u=="object"?JSON.stringify(u):u])),...r&&{trace_id:r.spanContext().traceId,span_id:r.spanContext().spanId}}})}trace(s,o){this.log("trace",s,o)}debug(s,o){this.log("debug",s,o)}info(s,o){this.log("info",s,o)}warn(s,o){this.log("warn",s,o)}error(s,o){this.log("error",s,o)}fatal(s,o){this.log("fatal",s,o)}}function oe(t,s="debug"){return new qn(t,s)}const P=oe("http-transport");class Gn{connected=!1;sessionUpdateCallbacks=new Set;errorCallbacks=new Set;messageQueue=[];currentSessionId=null;chunkResolvers=[];streamComplete=!1;sseAbortController=null;reconnectAttempts=0;maxReconnectAttempts=5;reconnectDelay=1e3;reconnecting=!1;abortController=null;options;isReceivingMessages=!1;isInReplayMode=!1;agentInfo;constructor(s){this.options={...s,baseUrl:s.baseUrl.replace(/\/$/,"")}}async connect(){if(!this.connected)try{this.abortController=new AbortController;const s={protocolVersion:st,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},o=await this.sendRpcRequest("initialize",s);if(o.agentInfo){const a=o._meta,r=a&&typeof a=="object",m=r&&"agentDescription"in a?String(a.agentDescription):void 0,u=r&&"suggestedPrompts"in a&&Array.isArray(a.suggestedPrompts)?a.suggestedPrompts:void 0,c=r&&"tools"in a&&Array.isArray(a.tools)?a.tools:void 0,d=r&&"mcps"in a&&Array.isArray(a.mcps)?a.mcps:void 0,f=r&&"subagents"in a&&Array.isArray(a.subagents)?a.subagents:void 0,p=r&&"initialMessage"in a&&a.initialMessage&&typeof a.initialMessage=="object"?a.initialMessage:void 0,h=r&&"uiConfig"in a&&a.uiConfig&&typeof a.uiConfig=="object"?a.uiConfig:void 0;this.agentInfo={name:o.agentInfo.name,...o.agentInfo.title?{displayName:o.agentInfo.title}:{},version:o.agentInfo.version,...m?{description:m}:{},...u?{suggestedPrompts:u}:{},...p?{initialMessage:p}:{},...h?{uiConfig:h}:{},...c?{tools:c}:{},...d?{mcps:d}:{},...f?{subagents:f}:{}}}P.info("ACP connection initialized",{initResponse:o});const n={cwd:"/",mcpServers:[]},i=await this.sendRpcRequest("session/new",n);this.currentSessionId=i.sessionId,P.info("Session created",{sessionId:this.currentSessionId}),await this.connectSSE(),this.connected=!0,this.reconnectAttempts=0}catch(s){this.connected=!1;const o=s instanceof Error?s:new Error(String(s));throw this.notifyError(o),o}}async loadSession(s){this.connected&&(P.warn("Transport already connected, disconnecting first",{sessionId:s}),await this.disconnect());try{this.abortController=new AbortController;const o={protocolVersion:st,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}};P.info("Loading session - initializing connection",{sessionId:s});const n=await this.sendRpcRequest("initialize",o);if(n.agentInfo){const r=n._meta,m=r&&typeof r=="object",u=m&&"agentDescription"in r?String(r.agentDescription):void 0,c=m&&"suggestedPrompts"in r&&Array.isArray(r.suggestedPrompts)?r.suggestedPrompts:void 0,d=m&&"tools"in r&&Array.isArray(r.tools)?r.tools:void 0,f=m&&"mcps"in r&&Array.isArray(r.mcps)?r.mcps:void 0,p=m&&"subagents"in r&&Array.isArray(r.subagents)?r.subagents:void 0,h=m&&"initialMessage"in r&&r.initialMessage&&typeof r.initialMessage=="object"?r.initialMessage:void 0,x=m&&"uiConfig"in r&&r.uiConfig&&typeof r.uiConfig=="object"?r.uiConfig:void 0;this.agentInfo={name:n.agentInfo.name,...n.agentInfo.title?{displayName:n.agentInfo.title}:{},version:n.agentInfo.version,...u?{description:u}:{},...c?{suggestedPrompts:c}:{},...h?{initialMessage:h}:{},...x?{uiConfig:x}:{},...d?{tools:d}:{},...f?{mcps:f}:{},...p?{subagents:p}:{}}}if(!n.agentCapabilities?.loadSession)throw P.error("Agent does not support loading sessions",{capabilities:n.agentCapabilities}),new Error("Agent does not support loading sessions");P.info("ACP connection initialized, loading session",{sessionId:s,capabilities:n.agentCapabilities}),this.isInReplayMode=!0,this.currentSessionId=s,await this.connectSSE();const i={sessionId:s,cwd:"/",mcpServers:[]};P.info("Sending session/load request",{loadRequest:i});const a=await this.sendRpcRequest("session/load",i);P.info("Session loaded successfully",{sessionId:this.currentSessionId,loadResponse:a}),this.connected=!0,this.reconnectAttempts=0}catch(o){this.connected=!1;const n=o instanceof Error?o:new Error(String(o));throw P.error("Failed to load session",{sessionId:s,error:n.message,stack:n.stack}),this.notifyError(n),n}}async listSessions(){try{const s={method:"GET"};this.options.headers&&(s.headers=this.options.headers);const o=await fetch(`${this.options.baseUrl}/sessions`,s);if(!o.ok)throw new Error(`HTTP ${o.status}: ${await o.text()}`);return(await o.json()).sessions||[]}catch(s){return P.error("Failed to list sessions",{error:s}),[]}}async disconnect(){if(this.connected)try{this.abortController&&(this.abortController.abort(),this.abortController=null),this.sseAbortController&&(this.sseAbortController.abort(),this.sseAbortController=null),this.connected=!1,this.currentSessionId=null,this.messageQueue=[],this.chunkResolvers=[],this.streamComplete=!1,this.reconnecting=!1,this.reconnectAttempts=0}catch(s){const o=s instanceof Error?s:new Error(String(s));throw this.notifyError(o),o}}async send(s){if(!this.connected||!this.currentSessionId)throw new Error("Transport not connected");this.isInReplayMode&&(P.info("Exiting replay mode - user sent a message"),this.isInReplayMode=!1);try{this.streamComplete=!1,this.messageQueue=[];const o=s.content.map(r=>r.type==="text"?{type:"text",text:r.text}:r.type==="image"?"source"in r&&r.source?{type:"image",data:r.source.data,mimeType:r.source.media_type}:"data"in r&&"mimeType"in r?{type:"image",data:r.data,mimeType:r.mimeType}:r:r),n={sessionId:this.currentSessionId,prompt:o},i=await this.sendRpcRequest("session/prompt",n);P.debug("Prompt sent",{promptResponse:i}),this.streamComplete=!0;const a=this.chunkResolvers.shift();a?a({id:this.currentSessionId||"unknown",role:"assistant",contentDelta:{type:"text",text:""},isComplete:!0}):this.messageQueue.push({id:this.currentSessionId||"unknown",role:"assistant",contentDelta:{type:"text",text:""},isComplete:!0})}catch(o){this.streamComplete=!0;const n=o instanceof Error?o:new Error(String(o));throw this.notifyError(n),n}}async*receive(){this.isReceivingMessages=!0;try{for(;!this.streamComplete;)if(this.messageQueue.length>0){const s=this.messageQueue.shift();if(s&&(yield s,s.isComplete))return}else{const s=await new Promise(o=>{this.chunkResolvers.push(o)});if(s.isComplete){yield s;return}else yield s}for(;this.messageQueue.length>0;){const s=this.messageQueue.shift();s&&(yield s)}yield{id:this.currentSessionId||"unknown",role:"assistant",contentDelta:{type:"text",text:""},isComplete:!0}}finally{this.isReceivingMessages=!1}}isConnected(){return this.connected}onSessionUpdate(s){return this.sessionUpdateCallbacks.add(s),()=>{this.sessionUpdateCallbacks.delete(s)}}onError(s){return this.errorCallbacks.add(s),()=>{this.errorCallbacks.delete(s)}}getAgentInfo(){return this.agentInfo||{}}async sendRpcRequest(s,o){const i={jsonrpc:"2.0",id:this.generateRequestId(),method:s,params:o};P.debug("Sending RPC request",{method:s,params:o,request:i});const a={"Content-Type":"application/json",...this.options.headers},r=this.options.timeout??600*1e3,m=new AbortController,u=setTimeout(()=>m.abort(),r);try{const c=await fetch(`${this.options.baseUrl}/rpc`,{method:"POST",headers:a,body:JSON.stringify(i),signal:m.signal});if(clearTimeout(u),!c.ok){const f=await c.text();throw new Error(`HTTP ${c.status}: ${f}`)}const d=await c.json();if(d.error)throw new Error(`ACP error: ${d.error.message||JSON.stringify(d.error)}`);return d.result||d}catch(c){throw clearTimeout(u),c instanceof Error&&c.name==="AbortError"?new Error(`Request timeout after ${r}ms`):c}}async connectSSE(){if(!this.currentSessionId)throw new Error("Cannot connect SSE without a session ID");const s=`${this.options.baseUrl}/events`,o={"X-Session-ID":this.currentSessionId,...this.options.headers};this.sseAbortController=new AbortController;try{const n=await fetch(s,{method:"GET",headers:o,signal:this.sseAbortController.signal});if(!n.ok)throw new Error(`SSE connection failed: HTTP ${n.status}`);if(!n.body)throw new Error("Response body is null");P.debug("SSE connection opened"),this.reconnectAttempts=0,this.reconnectDelay=1e3;const i=n.body.getReader(),a=new TextDecoder;let r="";(async()=>{try{for(;;){const{done:m,value:u}=await i.read();if(m){P.debug("SSE stream closed by server"),this.connected&&await this.handleSSEDisconnect();break}r+=a.decode(u,{stream:!0});const c=r.split(`
4
+ `);r=c.pop()||"";let d={event:"message",data:""};for(const f of c)f.startsWith("event:")?d.event=f.substring(6).trim():f.startsWith("data:")?d.data=f.substring(5).trim():f===""&&(d.event==="message"&&d.data&&this.handleSSEMessage(d.data),d={event:"message",data:""})}}catch(m){if(m instanceof Error&&m.name==="AbortError"){P.debug("SSE stream aborted");return}P.error("Error reading SSE stream",{error:m}),this.connected&&!this.reconnecting&&await this.handleSSEDisconnect()}})()}catch(n){throw P.error("SSE connection error",{error:n}),n}}async handleSSEDisconnect(){if(this.reconnecting||!this.connected)return;if(this.reconnecting=!0,this.sseAbortController&&(this.sseAbortController.abort(),this.sseAbortController=null),this.reconnectAttempts>=this.maxReconnectAttempts){const o=new Error(`SSE reconnection failed after ${this.maxReconnectAttempts} attempts`);this.notifyError(o),this.connected=!1,this.reconnecting=!1;return}this.reconnectAttempts++;const s=Math.min(this.reconnectDelay*2**(this.reconnectAttempts-1),32e3);P.debug("SSE reconnecting",{delay:s,attempt:this.reconnectAttempts,maxAttempts:this.maxReconnectAttempts}),await new Promise(o=>setTimeout(o,s));try{await this.connectSSE(),P.info("SSE reconnected successfully"),this.reconnecting=!1}catch(o){P.error("SSE reconnection failed",{error:o}),this.reconnecting=!1}}handleSSEMessage(s){try{const o=JSON.parse(s);P.debug("Received SSE message",{message:o});const n=tn.safeParse(o);if(!n.success){P.error("Invalid ACP message from SSE",{issues:n.error.issues});return}const i=n.data;P.debug("Parsed ACP message",{method:"method"in i?i.method:"(no method)"}),"method"in i&&i.method==="session/update"&&(P.debug("Received session/update notification"),"params"in i&&i.params&&(P.debug("Calling handleSessionNotification",{params:i.params}),this.handleSessionNotification(i.params)))}catch(o){P.error("Error parsing SSE message",{error:o}),this.notifyError(o instanceof Error?o:new Error(String(o)))}}handleSessionNotification(s){P.debug("handleSessionNotification called",{params:s});const n=s.update,i=this.currentSessionId||s.sessionId;if(P.debug("Update session type",{sessionUpdate:n?.sessionUpdate}),n?.sessionUpdate==="tool_call"){P.debug("Tool call notification",{tokenUsage:n.tokenUsage});const a=n._meta&&typeof n._meta=="object"&&"messageId"in n._meta?String(n._meta.messageId):void 0,r=n._meta&&typeof n._meta=="object"&&"prettyName"in n._meta&&typeof n._meta.prettyName=="string"?n._meta.prettyName:void 0,m=n._meta&&typeof n._meta=="object"&&"icon"in n._meta&&typeof n._meta.icon=="string"?n._meta.icon:void 0,u=n._meta&&typeof n._meta=="object"&&"subline"in n._meta&&typeof n._meta.subline=="string"?n._meta.subline:void 0,c=n._meta&&typeof n._meta=="object"&&"batchId"in n._meta&&typeof n._meta.batchId=="string"?n._meta.batchId:void 0,d={id:n.toolCallId??"",batchId:c,title:n.title??"",prettyName:r,icon:m,subline:u,kind:n.kind||"other",status:n.status||"pending",locations:n.locations,rawInput:n.rawInput,tokenUsage:n.tokenUsage,content:n.content?.map(p=>{if(typeof p!="object"||p===null)return{type:"text",text:""};const h=p;if(h.type==="content"&&typeof h.content=="object"&&h.content!==null){const x=h.content;if(x.type==="text")return{type:"content",content:{type:"text",text:typeof x.text=="string"?x.text:""}}}return h.type==="text"?{type:"text",text:typeof h.text=="string"?h.text:""}:h.type==="diff"?{type:"diff",path:typeof h.path=="string"?h.path:"",oldText:typeof h.oldText=="string"?h.oldText:"",newText:typeof h.newText=="string"?h.newText:"",line:typeof h.line=="number"?h.line:null}:h.type==="terminal"?{type:"terminal",terminalId:typeof h.terminalId=="string"?h.terminalId:""}:{type:"text",text:""}}),startedAt:Date.now()},f={type:"tool_call",sessionId:i,status:"active",toolCall:d,messageId:a};this.notifySessionUpdate(f)}else if(n?.sessionUpdate==="tool_call_update"){const a=n._meta&&typeof n._meta=="object"&&"messageId"in n._meta?String(n._meta.messageId):void 0,r=n._meta&&typeof n._meta=="object"&&"prettyName"in n._meta&&typeof n._meta.prettyName=="string"?n._meta.prettyName:void 0,m=n._meta&&typeof n._meta=="object"&&"icon"in n._meta&&typeof n._meta.icon=="string"?n._meta.icon:void 0,u=n._meta&&typeof n._meta=="object"&&"batchId"in n._meta&&typeof n._meta.batchId=="string"?n._meta.batchId:void 0,c=n._meta&&typeof n._meta=="object"&&"subagentPort"in n._meta&&typeof n._meta.subagentPort=="number"?n._meta.subagentPort:void 0,d=n._meta&&typeof n._meta=="object"&&"subagentSessionId"in n._meta&&typeof n._meta.subagentSessionId=="string"?n._meta.subagentSessionId:void 0;(c||d)&&P.info("Extracted subagent connection info from tool_call_update",{toolCallId:n.toolCallId,subagentPort:c,subagentSessionId:d,_meta:n._meta});const f={id:n.toolCallId??"",status:n.status,title:n.title,prettyName:r,icon:m,batchId:u,rawInput:n.rawInput,locations:n.locations,rawOutput:n.rawOutput,tokenUsage:n.tokenUsage,content:n.content?.map(h=>{if(typeof h!="object"||h===null)return{type:"text",text:""};const x=h;if(x.type==="content"&&typeof x.content=="object"&&x.content!==null){const g=x.content;if(g.type==="text")return{type:"content",content:{type:"text",text:typeof g.text=="string"?g.text:""}}}return x.type==="text"?{type:"text",text:typeof x.text=="string"?x.text:""}:x.type==="diff"?{type:"diff",path:typeof x.path=="string"?x.path:"",oldText:typeof x.oldText=="string"?x.oldText:"",newText:typeof x.newText=="string"?x.newText:"",line:typeof x.line=="number"?x.line:null}:x.type==="terminal"?{type:"terminal",terminalId:typeof x.terminalId=="string"?x.terminalId:""}:{type:"text",text:""}}),error:n.error,completedAt:n.status==="completed"||n.status==="failed"?Date.now():void 0,subagentPort:c,subagentSessionId:d},p={type:"tool_call_update",sessionId:i,status:"active",toolCallUpdate:f,messageId:a};P.debug("Notifying tool_call_update session update",{sessionUpdate:p}),this.notifySessionUpdate(p)}else if(n&&"sessionUpdate"in n&&n.sessionUpdate==="tool_output"){const a=n,r=a._meta&&typeof a._meta=="object"&&"messageId"in a._meta?String(a._meta.messageId):void 0,m={id:a.toolCallId??"",rawOutput:a.rawOutput,content:a.content?.map(c=>{if(typeof c!="object"||c===null)return{type:"text",text:""};const d=c;if(d.type==="content"&&typeof d.content=="object"&&d.content!==null){const f=d.content;if(f.type==="text")return{type:"content",content:{type:"text",text:typeof f.text=="string"?f.text:""}}}return d.type==="text"?{type:"text",text:typeof d.text=="string"?d.text:""}:d.type==="diff"?{type:"diff",path:typeof d.path=="string"?d.path:"",oldText:typeof d.oldText=="string"?d.oldText:"",newText:typeof d.newText=="string"?d.newText:"",line:typeof d.line=="number"?d.line:null}:d.type==="terminal"?{type:"terminal",terminalId:typeof d.terminalId=="string"?d.terminalId:""}:d.type==="image"?{type:"image",data:typeof d.data=="string"?d.data:"",mimeType:typeof d.mimeType=="string"?d.mimeType:"image/png",alt:typeof d.alt=="string"?d.alt:void 0}:{type:"text",text:""}})},u={type:"tool_call_update",sessionId:i,status:"active",toolCallUpdate:m,messageId:r};P.debug("Notifying tool_output as tool_call_update",{sessionUpdate:u}),this.notifySessionUpdate(u)}else if(n?.sessionUpdate==="agent_message_chunk"){const a=n._meta&&typeof n._meta=="object"&&"isReplay"in n._meta&&n._meta.isReplay===!0;if(this.isInReplayMode&&!a)return;const r=n._meta&&typeof n._meta=="object"&&"tokenUsage"in n._meta?n._meta.tokenUsage:void 0,m=n._meta&&typeof n._meta=="object"&&"contextInputTokens"in n._meta&&typeof n._meta.contextInputTokens=="number"?n._meta.contextInputTokens:void 0,u=n._meta&&typeof n._meta=="object"&&"context_size"in n._meta?n._meta.context_size:void 0,c={type:"generic",sessionId:i,status:"active",_meta:n._meta},d=n.content;if(d&&typeof d=="object"){const p=d;let h=null;if(p.type==="text"&&typeof p.text=="string"&&(h={id:s.sessionId,role:"assistant",contentDelta:{type:"text",text:p.text},tokenUsage:r,contextInputTokens:m,_meta:u?{context_size:u}:void 0,isComplete:!1}),h&&!a){const x=this.chunkResolvers.shift();x?x(h):this.messageQueue.push(h)}if(h&&typeof p.text=="string"&&(a||!this.isReceivingMessages)){const x={type:"generic",sessionId:i,status:"active",message:{id:`msg_${Date.now()}_assistant`,role:"assistant",content:[{type:"text",text:p.text}],timestamp:new Date().toISOString()}};this.notifySessionUpdate(x)}}const f=c._meta&&"context_size"in c._meta;(!a||f)&&this.notifySessionUpdate(c)}else if(n?.sessionUpdate==="user_message_chunk"){P.debug("Received user_message_chunk",{update:n});const a=n.content;if(a&&typeof a=="object"){const r=a;if(r.type==="text"&&typeof r.text=="string"){const m={type:"generic",sessionId:i,status:"active",message:{id:`msg_${Date.now()}_user`,role:"user",content:[{type:"text",text:r.text}],timestamp:new Date().toISOString()}};P.debug("Notifying session update for user message"),this.notifySessionUpdate(m)}}}else{const a={type:"generic",sessionId:i,status:"active"};this.notifySessionUpdate(a)}}generateRequestId(){return`req-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}notifySessionUpdate(s){for(const o of this.sessionUpdateCallbacks)try{o(s)}catch(n){P.error("Error in session update callback",{error:n})}}notifyError(s){for(const o of this.errorCallbacks)try{o(s)}catch(n){P.error("Error in error callback",{error:n})}}}class Kn{constructor(){throw new Error("StdioTransport is not available in the browser. Use HttpTransport or WebSocketTransport instead.")}async connect(){throw new Error("StdioTransport not available in browser")}async disconnect(){}async send(){throw new Error("StdioTransport not available in browser")}async*receive(){throw new Error("StdioTransport not available in browser")}isConnected(){return!1}onSessionUpdate(){return()=>{}}onError(){return()=>{}}}class Qn{ws=null;connected=!1;sessionUpdateCallbacks=new Set;errorCallbacks=new Set;constructor(s){}async connect(){throw new Error("WebSocketTransport not yet implemented. Waiting for HTTP ACP server.")}async disconnect(){this.ws&&(this.ws.close(),this.ws=null),this.connected=!1}async send(s){throw!this.connected||!this.ws?new Error("Transport not connected"):new Error("WebSocketTransport not yet implemented. Waiting for HTTP ACP server.")}async*receive(){throw new Error("WebSocketTransport not yet implemented. Waiting for HTTP ACP server.")}isConnected(){return this.connected}onSessionUpdate(s){return this.sessionUpdateCallbacks.add(s),()=>{this.sessionUpdateCallbacks.delete(s)}}onError(s){return this.errorCallbacks.add(s),()=>{this.errorCallbacks.delete(s)}}}const Ue=oe("acp-client","debug");class Jn{constructor(s){this.config=s,this.transport=this.createTransport(),this.setupTransportListeners(),s.autoConnect&&this.connect().catch(o=>{Ue.error("Failed to auto-connect",{error:o instanceof Error?o.message:String(o)})})}transport;sessions=new Map;currentSessionId=null;sessionUpdateHandlers=new Set;errorHandlers=new Set;async connect(){await this.transport.connect()}async disconnect(){await this.transport.disconnect(),this.currentSessionId=null}isConnected(){return this.transport.isConnected()}async startSession(s){const o="currentSessionId"in this.transport?this.transport.currentSessionId:void 0;if(o){const m=new Date().toISOString(),u=this.transport.getAgentInfo?.()?.name,c={id:o,status:"connected",config:s?{...s,agentPath:s.agentPath||""}:{agentPath:""},messages:[],metadata:{startedAt:m,agentName:u}};return this.sessions.set(o,c),this.currentSessionId=o,o}const n=this.generateSessionId(),i=new Date().toISOString(),a=this.transport.getAgentInfo?.()?.name,r={id:n,status:"connecting",config:s?{...s,agentPath:s.agentPath||""}:{agentPath:""},messages:[],metadata:{startedAt:i,agentName:a}};return this.sessions.set(n,r),this.currentSessionId=n,this.updateSessionStatus(n,"connected"),n}async loadSession(s,o){if(!this.transport.loadSession)throw new Error("Transport does not support loading sessions");const n=new Date().toISOString(),i={id:s,status:"connecting",config:o?{...o,agentPath:o.agentPath||""}:{agentPath:""},messages:[],metadata:{startedAt:n}};if(this.sessions.set(s,i),this.currentSessionId=s,await this.transport.loadSession(s),this.transport.getAgentInfo){const a=this.transport.getAgentInfo();a.name&&i.metadata&&(i.metadata.agentName=a.name)}return this.updateSessionStatus(s,"connected"),s}async listSessions(){return this.transport.listSessions?this.transport.listSessions():[]}async sendMessage(s,o,n){const i=o||this.currentSessionId;if(!i)throw new Error("No active session. Start a session first.");if(!this.transport.isConnected())throw new Error("Transport not connected");const a=this.sessions.get(i);if(!a)throw new Error(`Session ${i} not found`);const r=[];if(n&&n.length>0)for(const u of n)u.mimeType.startsWith("image/")&&r.push({type:"image",source:{type:"base64",media_type:u.mimeType,data:u.data}});r.push({type:"text",text:s});const m={id:this.generateMessageId(),role:"user",content:r,timestamp:new Date().toISOString()};a.messages.push(m),this.updateSessionStatus(i,"active"),await this.transport.send(m)}async*receiveMessages(){if(!this.transport.isConnected())throw new Error("Transport not connected");yield*this.transport.receive()}getSession(s){return this.sessions.get(s)}getCurrentSession(){return this.currentSessionId?this.sessions.get(this.currentSessionId):void 0}getAllSessions(){return Array.from(this.sessions.values())}onSessionUpdate(s){return this.sessionUpdateHandlers.add(s),()=>{this.sessionUpdateHandlers.delete(s)}}onError(s){return this.errorHandlers.add(s),()=>{this.errorHandlers.delete(s)}}getAgentInfo(){return this.transport.getAgentInfo?.()||{}}createTransport(){switch(this.config.type){case"stdio":return new Kn(this.config.options);case"http":return new Gn(this.config.options);case"websocket":return new Qn(this.config.options);default:throw new Error(`Unknown transport type: ${this.config.type}`)}}setupTransportListeners(){this.transport.onSessionUpdate(s=>{this.handleSessionUpdate(s)}),this.transport.onError(s=>{this.handleError(s)})}handleSessionUpdate(s){if(s.sessionId){const o=this.sessions.get(s.sessionId);o&&(s.status&&(o.status=s.status),s.message&&o.messages.push(s.message),s.error&&(o.error=s.error))}for(const o of this.sessionUpdateHandlers)try{o(s)}catch(n){Ue.error("Error in session update handler",{error:n instanceof Error?n.message:String(n)})}}handleError(s){for(const o of this.errorHandlers)try{o(s)}catch(n){Ue.error("Error in error handler",{error:n instanceof Error?n.message:String(n)})}}updateSessionStatus(s,o){const n=this.sessions.get(s);n&&(n.status=o,this.handleSessionUpdate({sessionId:s,status:o}))}generateSessionId(){return`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}generateMessageId(){return`msg_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}}const pe=oe("acp-client-hook");function Yn(t){const[s,o]=l.useState(null),[n,i]=l.useState(null),[a,r]=l.useState(null);return l.useEffect(()=>{const u=new URLSearchParams(window.location.search).get("session");u&&(pe.info("Session ID found in URL",{sessionId:u}),r(u));try{pe.info("Initializing ACP client",{serverUrl:t.serverUrl});const c=new Jn({type:"http",options:{baseUrl:t.serverUrl}});return o(c),pe.info("ACP client initialized successfully"),()=>{pe.debug("Disconnecting ACP client"),c.disconnect().catch(d=>{pe.error("Failed to disconnect ACP client",{error:d instanceof Error?d.message:String(d)})})}}catch(c){const d=c instanceof Error?c.message:"Failed to initialize ACP client";i(d),pe.error("Failed to initialize ACP client",{error:c instanceof Error?c.message:String(c),stack:c instanceof Error?c.stack:void 0});return}},[t.serverUrl]),{client:s,error:n,sessionId:a}}const $e=ee(["pending","in_progress","completed","failed"]),Xn=ee(["read","edit","delete","move","search","execute","think","fetch","switch_mode","other"]),Kt=D({path:N(),line:z().nullable().optional()}),Be=D({inputTokens:z().optional(),outputTokens:z().optional(),totalTokens:z().optional()}),He=ze("type",[D({type:V("content"),content:D({type:V("text"),text:N()})}),D({type:V("text"),text:N()}),D({type:V("image"),data:N(),mimeType:N().optional(),alt:N().optional()}),D({type:V("image"),url:N(),alt:N().optional()}),D({type:V("diff"),path:N(),oldText:N(),newText:N(),line:z().nullable().optional()}),D({type:V("terminal"),terminalId:N()})]),Qt=D({id:N(),title:N(),prettyName:N().optional(),icon:N().optional(),status:$e,content:B(He).optional()}),Zn=ze("type",[D({type:V("text"),text:N()}),D({type:V("tool_call"),toolCall:Qt})]),eo=D({id:N(),content:N(),toolCalls:B(Qt).optional(),contentBlocks:B(Zn).optional(),isStreaming:le().optional()}),Jt=D({id:N(),batchId:N().optional(),title:N(),prettyName:N().optional(),icon:N().optional(),subline:N().optional(),kind:Xn,status:$e,contentPosition:z().optional(),locations:B(Kt).optional(),rawInput:Y(N(),X()).optional(),rawOutput:Y(N(),X()).optional(),content:B(He).optional(),error:N().optional(),startedAt:z().optional(),completedAt:z().optional(),tokenUsage:Be.optional(),_meta:D({truncationWarning:N().optional(),compactionAction:ee(["compacted","truncated"]).optional(),originalTokens:z().optional(),finalTokens:z().optional()}).optional(),subagentPort:z().optional(),subagentSessionId:N().optional(),subagentMessages:B(eo).optional(),subagentStreaming:le().optional()}),to=D({id:N(),status:$e.optional(),title:N().optional(),prettyName:N().optional(),icon:N().optional(),batchId:N().optional(),rawInput:Y(N(),X()).optional(),locations:B(Kt).optional(),rawOutput:Y(N(),X()).optional(),content:B(He).optional(),error:N().optional(),completedAt:z().optional(),tokenUsage:Be.optional(),subagentPort:z().optional(),subagentSessionId:N().optional()});function at(t,s){return{...t,status:s.status??t.status,title:s.title??t.title,prettyName:s.prettyName??t.prettyName,icon:s.icon??t.icon,batchId:s.batchId??t.batchId,rawInput:s.rawInput??t.rawInput,locations:s.locations??t.locations,rawOutput:s.rawOutput??t.rawOutput,content:s.content?[...t.content??[],...s.content]:t.content,error:s.error??t.error,completedAt:s.completedAt??t.completedAt,tokenUsage:s.tokenUsage??t.tokenUsage,subagentPort:s.subagentPort??t.subagentPort,subagentSessionId:s.subagentSessionId??t.subagentSessionId}}const me=oe("chat-store","debug"),Ce=[];let Se={sessionId:null,toolCallId:null,todos:Ce};const so=t=>{const s=t.sessionId;if(!s)return Ce;const n=(t.toolCalls[s]||[]).filter(r=>r.title==="todo_write").sort((r,m)=>(m.startedAt||0)-(r.startedAt||0));if(n.length===0)return Ce;const i=n[0];if(!i?.rawInput?.todos||!Array.isArray(i.rawInput.todos))return Ce;if(Se.sessionId===s&&Se.toolCallId===i.id)return Se.todos;const a=i.rawInput.todos.map((r,m)=>({id:`${i.id}-${m}`,text:r.status==="in_progress"?r.activeForm:r.content,status:r.status}));return Se={sessionId:s,toolCallId:i.id,todos:a},a},M=Qs(t=>({connectionStatus:"disconnected",sessionId:null,error:null,messages:[],isStreaming:!1,streamingStartTime:null,toolCalls:{},totalBilled:{inputTokens:0,outputTokens:0,totalTokens:0},currentContext:{inputTokens:0,outputTokens:0,totalTokens:0},latestContextSize:null,currentModel:"claude-sonnet-4-5-20250929",tokenDisplayMode:"context",logs:[],activeTab:"chat",input:{value:"",isSubmitting:!1,attachedFiles:[]},setConnectionStatus:s=>t({connectionStatus:s}),setSessionId:s=>t({sessionId:s}),setError:s=>t({error:s}),addMessage:s=>t(o=>({messages:[...o.messages,s]})),updateMessage:(s,o)=>t(n=>{const i=n.messages.find(c=>c.id===s);let a=n.totalBilled,r=n.currentContext,m=o;if(o.tokenUsage){const c=i?.tokenUsage;me.debug("updateMessage: incoming tokenUsage",{incoming:o.tokenUsage,existing:c});const d={inputTokens:Math.max(o.tokenUsage.inputTokens??0,c?.inputTokens??0),outputTokens:Math.max(o.tokenUsage.outputTokens??0,c?.outputTokens??0),totalTokens:Math.max(o.tokenUsage.inputTokens??0,c?.inputTokens??0)+Math.max(o.tokenUsage.outputTokens??0,c?.outputTokens??0)};me.debug("updateMessage: merged tokenUsage",{merged:d}),m={...o,tokenUsage:d};const f=d.inputTokens-(c?.inputTokens??0),p=d.outputTokens-(c?.outputTokens??0),h=d.totalTokens-(c?.totalTokens??0);a={inputTokens:n.totalBilled.inputTokens+f,outputTokens:n.totalBilled.outputTokens+p,totalTokens:n.totalBilled.totalTokens+h},r={inputTokens:d.inputTokens,outputTokens:n.currentContext.outputTokens+p,totalTokens:d.totalTokens}}const u=n.messages.map(c=>c.id===s?{...c,...m}:c);if(o.tokenUsage&&m.tokenUsage){const c=i?.tokenUsage,d=m.tokenUsage,f=(d.inputTokens??0)-(c?.inputTokens??0),p=(d.outputTokens??0)-(c?.outputTokens??0),h=(d.totalTokens??0)-(c?.totalTokens??0),x=u.filter(v=>v.tokenUsage).map(v=>({id:v.id,role:v.role,tokens:v.tokenUsage})),g=u.reduce((v,S)=>({inputTokens:v.inputTokens+(S.tokenUsage?.inputTokens??0),outputTokens:v.outputTokens+(S.tokenUsage?.outputTokens??0),totalTokens:v.totalTokens+(S.tokenUsage?.totalTokens??0)}),{inputTokens:0,outputTokens:0,totalTokens:0}),j=g.inputTokens===a.inputTokens&&g.outputTokens===a.outputTokens&&g.totalTokens===a.totalTokens;me.debug("updateMessage: tokenUsage update",{messageId:s,updates:o.tokenUsage,existing:c,messageMax:d,delta:{inputDelta:f,outputDelta:p,totalDelta:h},totalBilled:a,currentContext:r,actualSum:g,billedCorrect:j?"✅":"❌",messageCount:u.length,messagesWithTokens:x.length,breakdown:x})}return{messages:u,totalBilled:a,currentContext:r}}),clearMessages:()=>t({messages:[]}),setIsStreaming:s=>t({isStreaming:s}),setStreamingStartTime:s=>t({streamingStartTime:s}),addToolCall:(s,o)=>t(n=>({toolCalls:{...n.toolCalls,[s]:[...n.toolCalls[s]||[],o]}})),addToolCallToCurrentMessage:s=>t(o=>{const n=o.messages.findLastIndex(u=>u.role==="assistant");if(n===-1){me.debug("No assistant message found, creating one for tool call at position 0");const u={id:`msg_${Date.now()}_assistant`,role:"assistant",content:"",timestamp:new Date().toISOString(),isStreaming:!1,toolCalls:[{...s,contentPosition:0}]};return{messages:[...o.messages,u]}}const i=[...o.messages],a=i[n];if(!a)return o;const r=a.content.length,m={...s,contentPosition:r};return i[n]={...a,toolCalls:[...a.toolCalls||[],m]},{messages:i}}),updateToolCallInCurrentMessage:s=>t(o=>{const n=o.messages.findLastIndex(d=>d.role==="assistant");if(n===-1)return me.warn("No assistant message found to update tool call in"),o;const i=[...o.messages],a=i[n];if(!a)return o;const r=a.toolCalls||[],m=r.findIndex(d=>d.id===s.id);if(m===-1)return me.warn(`Tool call ${s.id} not found in message`),o;const u=r[m];if(!u)return o;const c=[...r];return c[m]=at(u,s),i[n]={...a,toolCalls:c},{messages:i}}),updateToolCall:(s,o)=>t(n=>{const i=n.toolCalls[s]||[],a=i.findIndex(u=>u.id===o.id);if(a===-1)return n;const r=i[a];if(!r)return n;const m=[...i];return m[a]=at(r,o),{toolCalls:{...n.toolCalls,[s]:m}}}),setInputValue:s=>t(o=>({input:{...o.input,value:s}})),setInputSubmitting:s=>t(o=>({input:{...o.input,isSubmitting:s}})),addFileAttachment:s=>t(o=>({input:{...o.input,attachedFiles:[...o.input.attachedFiles,s]}})),removeFileAttachment:s=>t(o=>({input:{...o.input,attachedFiles:o.input.attachedFiles.filter((n,i)=>i!==s)}})),clearInput:()=>t(s=>({input:{value:"",isSubmitting:!1,attachedFiles:[]}})),addTokenUsage:s=>t(o=>({totalBilled:{inputTokens:o.totalBilled.inputTokens+(s.inputTokens??0),outputTokens:o.totalBilled.outputTokens+(s.outputTokens??0),totalTokens:o.totalBilled.totalTokens+(s.totalTokens??0)},currentContext:{inputTokens:s.inputTokens??o.currentContext.inputTokens,outputTokens:o.currentContext.outputTokens+(s.outputTokens??0),totalTokens:(s.inputTokens??o.currentContext.inputTokens)+(o.currentContext.outputTokens+(s.outputTokens??0))}})),setLatestContextSize:s=>t({latestContextSize:s}),setCurrentModel:s=>t({currentModel:s}),resetTokens:()=>t({totalBilled:{inputTokens:0,outputTokens:0,totalTokens:0},currentContext:{inputTokens:0,outputTokens:0,totalTokens:0},latestContextSize:null}),cycleTokenDisplayMode:()=>t(s=>{const o=["context","input","output"],i=(o.indexOf(s.tokenDisplayMode)+1)%o.length,a=o[i];return a?{tokenDisplayMode:a}:s}),addLog:s=>t(o=>({logs:[...o.logs,s]})),clearLogs:()=>t({logs:[]}),setActiveTab:s=>t({activeTab:s})})),se=oe("use-chat-messages","debug");function Yt(t,s){const o=M(p=>p.messages),n=M(p=>p.isStreaming),i=M(p=>p.sessionId),a=M(p=>p.setIsStreaming),r=M(p=>p.setStreamingStartTime),m=M(p=>p.addMessage),u=M(p=>p.updateMessage),c=M(p=>p.setError),d=M(p=>p.setLatestContextSize),f=l.useCallback(async(p,h)=>{if(se.debug("[sendMessage] Called with",{contentLength:p.length,attachmentsCount:h?.length||0,hasAttachments:!!h&&h.length>0}),!t){se.error("No client available"),c("No client available");return}let x=i;if(!x){se.info("Creating new session before sending first message");const j=await s();if(!j){se.error("Failed to create session"),c("Failed to create session");return}x=j,se.info("Session created successfully",{sessionId:j})}const g=`msg_${Date.now()}_assistant`;try{const j=Date.now();a(!0),r(j);const v={id:`msg_${Date.now()}_user`,role:"user",content:p,timestamp:new Date().toISOString(),isStreaming:!1,...h&&h.length>0?{images:h.filter(T=>T.mimeType.startsWith("image/")).map(T=>({mimeType:T.mimeType,data:T.data}))}:{}};m(v);const S={id:g,role:"assistant",content:"",timestamp:new Date().toISOString(),isStreaming:!0,streamingStartTime:j};m(S);const b=t.receiveMessages();t.sendMessage(p,x,h).catch(T=>{const I=T instanceof Error?T.message:String(T);c(I),a(!1),r(null)});let w="",C=!1;for await(const T of b){const I=T._meta,A=I?.context_size||T.context_size;if(A!=null){const U=A;se.info("✅ Received context_size from backend",{context_size:U,totalEstimated:U.totalEstimated,source:I?.context_size?"_meta":"direct"}),d(U)}else se.debug("Chunk does not have context_size",{hasContextSize:"context_size"in T,hasMeta:"_meta"in T,metaKeys:I?Object.keys(I):null});if(T.tokenUsage&&se.debug("Received tokenUsage from backend",{tokenUsage:T.tokenUsage}),T.isComplete){u(g,{content:w,isStreaming:!1,streamingStartTime:void 0,...T.tokenUsage?{tokenUsage:T.tokenUsage}:{}}),a(!1),r(null),C=!0;break}else T.contentDelta.type==="text"&&(w+=T.contentDelta.text,u(g,{content:w,...T.tokenUsage?{tokenUsage:T.tokenUsage}:{}}),await new Promise(U=>setTimeout(U,16)))}C||(se.warn("Stream ended without isComplete flag"),u(g,{isStreaming:!1,streamingStartTime:void 0}),a(!1),r(null))}catch(j){const v=j instanceof Error?j.message:String(j);c(v),a(!1),r(null),u(g,{isStreaming:!1,streamingStartTime:void 0})}},[t,i,s,m,u,a,r,c,d]);return{messages:o,isStreaming:n,sendMessage:f}}const rt=oe("use-chat-input","debug");function no(t,s){const o=M(p=>p.input),n=M(p=>p.setInputValue),i=M(p=>p.setInputSubmitting),a=M(p=>p.addFileAttachment),r=M(p=>p.removeFileAttachment),{sendMessage:m}=Yt(t,s),u=l.useCallback(p=>{n(p)},[n]),c=l.useCallback(async()=>{if(!o.value.trim()||o.isSubmitting)return;const p=o.value,h=o.attachedFiles;rt.debug("Submitting message with attachments",{messageLength:p.length,attachmentCount:h.length,hasAttachments:h.length>0}),n(""),i(!0);try{await m(p,h.length>0?h:void 0),M.setState(x=>({input:{...x.input,attachedFiles:[]}}))}catch(x){rt.error("Failed to send message",{error:x instanceof Error?x.message:String(x)})}finally{i(!1)}},[o,n,i,m]),d=l.useCallback(p=>{a(p)},[a]),f=l.useCallback(p=>{r(p)},[r]);return{value:o.value,isSubmitting:o.isSubmitting,attachedFiles:o.attachedFiles,onChange:u,onSubmit:c,onAttachFile:d,onRemoveFile:f}}const ae=oe("use-chat-session","debug");function oo(t,s){const o=M(g=>g.connectionStatus),n=M(g=>g.sessionId),i=M(g=>g.setConnectionStatus),a=M(g=>g.setSessionId),r=M(g=>g.setError),m=M(g=>g.clearMessages),u=M(g=>g.resetTokens),c=M(g=>g.addMessage),d=M(g=>g.setLatestContextSize);l.useEffect(()=>t?t.onSessionUpdate(j=>{const v=j._meta,S=v?.context_size||j.context_size;if(S!=null){const b=S;ae.info("✅ Received context_size from session update",{context_size:b,totalEstimated:b.totalEstimated,isReplay:v?.isReplay}),d(b)}if(j.message&&(ae.debug("Session update with message",{message:j.message}),j.message.role!=="tool")){const b=j.message.content.map(I=>I.type==="text"?I.text:"").join(""),w=[];for(const I of j.message.content)if(I.type==="image"){const A=I;A.source?.data?w.push({mimeType:A.source.media_type||"image/png",data:A.source.data}):A.data&&w.push({mimeType:A.mimeType||"image/png",data:A.data})}const C=M.getState().messages,T=C[C.length-1];if(j.message.role==="assistant"&&T?.role==="assistant"&&T.content===""&&b)ae.debug("Appending text to existing assistant message"),M.getState().updateMessage(T.id,{content:T.content+b});else{const I={id:j.message.id,role:j.message.role,content:b,timestamp:j.message.timestamp,isStreaming:!1,...w.length>0?{images:w}:{}};c(I)}}}):void 0,[t,c,d]);const f=l.useCallback(async()=>{if(!t){r("No client available");return}try{i("connecting"),r(null),await t.connect();const g=t.getCurrentSession();if(g?.id&&(a(g.id),typeof window<"u")){const j=new URL(window.location.href);j.searchParams.set("session",g.id),window.history.replaceState({},"",j.toString())}i("connected")}catch(g){ae.error("Failed to connect",{error:g instanceof Error?g.message:String(g)});const j=g instanceof Error?g.message:String(g);r(j),i("error")}},[t,i,a,r]),p=l.useCallback(async g=>{if(!t){r("No client available");return}try{i("connecting"),r(null),m(),u();const j=await t.loadSession(g);a(j),i("connected"),ae.info("Session loaded successfully",{sessionId:j})}catch(j){ae.warn("Failed to load session, creating new one instead",{sessionId:g,error:j instanceof Error?j.message:String(j)});try{await f();const v=await t.startSession();if(a(v),m(),u(),typeof window<"u"){const S=new URL(window.location.href);S.searchParams.set("session",v),window.history.replaceState({},"",S.toString())}ae.info("Created new session after failed load",{sessionId:v})}catch(v){const S=v instanceof Error?v.message:String(v);r(`Failed to load or create session: ${S}`),i("error")}}},[t,i,a,r,m,u,f]),h=l.useCallback(async()=>{if(!t)return r("No client available"),null;try{const g=await t.startSession();if(a(g),M.getState().messages.length===0&&(m(),u()),typeof window<"u"){const v=new URL(window.location.href);v.searchParams.set("session",g),window.history.pushState({},"",v.toString())}return g}catch(g){const j=g instanceof Error?g.message:String(g);return r(j),null}},[t,a,r,m,u]),x=l.useCallback(async()=>{if(t)try{await t.disconnect(),i("disconnected"),a(null)}catch(g){const j=g instanceof Error?g.message:String(g);r(j)}},[t,i,a,r]);return l.useEffect(()=>{!t||o!=="disconnected"||(s?(ae.info("Loading initial session from URL",{sessionId:s}),p(s)):f())},[t,o,s,f,p]),{connectionStatus:o,sessionId:n,connect:f,loadSession:p,startSession:h,disconnect:x}}const it="town-message-history",ao=100;function ro(){const[t,s]=l.useState(-1),[o,n]=l.useState(""),i=l.useCallback(()=>{try{const d=localStorage.getItem(it);return d?JSON.parse(d):[]}catch{return[]}},[]),a=l.useCallback(d=>{const f=d.trim();if(f){try{const p=i();if(p[0]===f)return;const h=[f,...p].slice(0,ao);localStorage.setItem(it,JSON.stringify(h))}catch{}s(-1),n("")}},[i]),r=l.useCallback(d=>{const f=i();if(f.length===0)return null;t===-1&&n(d);const p=Math.min(t+1,f.length-1);if(p===t)return null;const h=f[p];return h===void 0?null:(s(p),h)},[t,i]),m=l.useCallback(()=>{if(t===-1)return null;const d=i();if(t===0){s(-1);const h=o;return n(""),h}const f=t-1,p=d[f];return p===void 0?null:(s(f),p)},[t,o,i]),u=l.useCallback(()=>{t!==-1&&(s(-1),n(""))},[t]);return{addToHistory:a,navigatePrevious:r,navigateNext:m,resetNavigation:u,isBrowsingHistory:t!==-1,historyIndex:t}}const Z=oe("subagent-stream");function io(t){const[s,o]=l.useState([]),[n,i]=l.useState(!!t),[a,r]=l.useState(!1),[m,u]=l.useState(null),c=l.useRef(null),d=l.useRef(null),f=l.useRef(null),p=l.useCallback(()=>{f.current||(f.current=setTimeout(()=>{f.current=null,d.current&&o([{...d.current}])},250))},[]),h=l.useCallback(j=>{try{const v=JSON.parse(j);if(Z.debug("Processing SSE message",{method:v.method,hasParams:!!v.params}),v.method==="session/update"&&v.params?.update){const S=v.params.update;if(Z.debug("Got session update",{sessionUpdate:S.sessionUpdate}),S.sessionUpdate==="agent_message_chunk"){const b=S.content;if(b?.type==="text"&&typeof b.text=="string"&&d.current){d.current.content+=b.text;const w=d.current.contentBlocks??[],C=w[w.length-1];C&&C.type==="text"?C.text+=b.text:w.push({type:"text",text:b.text}),d.current.contentBlocks=w,p()}}else if(S.sessionUpdate==="tool_call"){const b={id:S.toolCallId??`tc-${Date.now()}`,title:S.title??"Tool call",prettyName:S._meta?.prettyName,icon:S._meta?.icon,status:S.status??"pending",content:[]};if(d.current){d.current.toolCalls=[...d.current.toolCalls??[],b];const w=d.current.contentBlocks??[];w.push({type:"tool_call",toolCall:b}),d.current.contentBlocks=w,p()}}else if(S.sessionUpdate==="tool_call_update"&&d.current?.toolCalls){const b=S.toolCallId,w=C=>C.id===b?{...C,status:S.status??C.status,content:S.content??C.content}:C;d.current.toolCalls=d.current.toolCalls.map(w),d.current.contentBlocks&&(d.current.contentBlocks=d.current.contentBlocks.map(C=>C.type==="tool_call"?{...C,toolCall:w(C.toolCall)}:C)),p()}}}catch(v){Z.error("Failed to parse sub-agent SSE message",{error:v instanceof Error?v.message:String(v)})}},[p]),x=l.useCallback(async(j,v,S)=>{const b=`http://${S}:${j}`;Z.info("Connecting to sub-agent SSE",{baseUrl:b,sessionId:v}),i(!0),u(null);const w=new AbortController;c.current=w;try{Z.info("Fetching SSE endpoint",{url:`${b}/events`,sessionId:v});const C=await fetch(`${b}/events`,{method:"GET",headers:{"X-Session-ID":v},signal:w.signal});if(Z.info("SSE response received",{status:C.status,ok:C.ok}),!C.ok)throw new Error(`SSE connection failed: HTTP ${C.status}`);if(!C.body)throw new Error("Response body is null");Z.info("Sub-agent SSE connection opened, starting to read stream");const T=C.body.getReader(),I=new TextDecoder;let A="";for(d.current={id:`subagent-${Date.now()}`,content:"",toolCalls:[],contentBlocks:[],isStreaming:!0},o([d.current]);;){const{done:U,value:H}=await T.read();if(U){Z.debug("Sub-agent SSE stream closed");break}A+=I.decode(H,{stream:!0});const G=A.split(`
5
+ `);A=G.pop()||"";let k={event:"message",data:""};for(const L of G)L.startsWith("event:")?k.event=L.substring(6).trim():L.startsWith("data:")?k.data=L.substring(5).trim():L===""&&(k.event==="message"&&k.data&&h(k.data),k={event:"message",data:""})}}catch(C){if(C instanceof Error&&C.name==="AbortError")Z.debug("Sub-agent SSE stream aborted");else{const T=C instanceof Error?C.message:"Failed to connect to sub-agent";Z.error("Sub-agent SSE error",{error:T}),u(T)}}finally{d.current&&(d.current.isStreaming=!1,o(C=>C.map(T=>T.id===d.current?.id?{...T,isStreaming:!1}:T))),r(!0),i(!1),c.current=null,Z.debug("Sub-agent stream completed")}},[h]);return l.useEffect(()=>{if(!t)return;const{port:j,sessionId:v,host:S="localhost"}=t;if(!(!j||!v))return o([]),u(null),r(!1),i(!0),x(j,v,S),()=>{c.current&&(c.current.abort(),c.current=null),f.current&&(clearTimeout(f.current),f.current=null)}},[t?.port,t?.sessionId,t?.host,x]),{messages:s,isStreaming:!a,error:m}}function lo(t){const s=M(r=>r.toolCalls),o=M(r=>r.addToolCall),n=M(r=>r.updateToolCall),i=M(r=>r.addToolCallToCurrentMessage),a=M(r=>r.updateToolCallInCurrentMessage);return l.useEffect(()=>{if(!t)return;const r=t.onSessionUpdate(m=>{m.type==="tool_call"?(o(m.sessionId,m.toolCall),i(m.toolCall)):m.type==="tool_call_update"&&(n(m.sessionId,m.toolCallUpdate),a(m.toolCallUpdate))});return()=>{r()}},[t,o,n,i,a]),{toolCalls:s,getToolCallsForSession:r=>{const m=s[r];return m&&m.length>0?m:Object.values(s).flat()}}}const co=D({mimeType:N(),data:N()}),uo=D({id:N(),role:ee(["user","assistant","system"]),content:N(),timestamp:ke(),isStreaming:le().default(!1),streamingStartTime:z().optional(),metadata:Y(N(),X()).optional(),toolCalls:B(Jt).optional(),tokenUsage:Be.optional(),images:B(co).optional()}),po=D({value:N(),isSubmitting:le(),attachedFiles:B(D({name:N(),path:N(),size:z(),mimeType:N(),data:N()}))});D({sessionId:N().nullable(),isConnected:le(),isStreaming:le(),messages:B(uo),input:po,error:N().nullable()});ee(["disconnected","connecting","connected","error"]);const mo=D({name:N(),description:N().optional(),parameters:Y(N(),X()).optional()}),fo=D({name:N(),description:N(),parameters:Y(N(),X()),required:B(N()).optional()}),go=D({name:N(),version:N().optional(),description:N().optional(),author:N().optional(),capabilities:B(mo).optional(),tools:B(fo).optional(),supportedFormats:B(N()).optional()}),ho=ee(["initializing","ready","busy","error","terminated"]);D({status:ho,info:go.optional(),pid:z().optional(),error:N().optional(),uptime:z().optional()});const Xt=ee(["user","assistant","system","tool"]),xo=ee(["text","image","file","tool_call","tool_result"]),we=D({type:xo}),bo=we.extend({type:V("text"),text:N()}),yo=we.extend({type:V("image"),url:N().url().optional(),source:D({type:V("base64"),media_type:ee(["image/jpeg","image/png","image/gif","image/webp"]),data:N()}).optional()}),vo=we.extend({type:V("file"),name:N(),path:N().optional(),url:N().url().optional(),mimeType:N(),size:z().optional()}),wo=we.extend({type:V("tool_call"),id:N(),name:N(),arguments:Y(N(),X())}),jo=we.extend({type:V("tool_result"),callId:N(),result:X(),error:N().optional()}),Zt=ze("type",[bo,yo,vo,wo,jo]),es=D({id:N(),role:Xt,content:B(Zt),timestamp:ke(),metadata:Y(N(),X()).optional()});D({id:N(),role:Xt,contentDelta:Zt,isComplete:le(),tokenUsage:D({inputTokens:z().optional(),outputTokens:z().optional(),totalTokens:z().optional()}).optional(),contextInputTokens:z().optional(),_meta:D({context_size:D({systemPromptTokens:z(),userMessagesTokens:z(),assistantMessagesTokens:z(),toolInputTokens:z(),toolResultsTokens:z(),totalEstimated:z(),llmReportedInputTokens:z().optional()}).optional()}).optional()});const ts=ee(["idle","connecting","connected","active","streaming","error","disconnected"]),No=D({agentPath:N(),agentArgs:B(N()).optional(),environment:Y(N(),N()).optional(),workingDirectory:N().optional(),timeout:z().optional()}),So=D({agentName:N().optional(),agentVersion:N().optional(),capabilities:B(N()).optional(),startedAt:ke(),lastActivityAt:ke().optional()});D({id:N(),status:ts,config:No,metadata:So.optional(),messages:B(es),error:N().optional()});const Re=D({sessionId:N(),status:ts.optional(),message:es.optional(),error:N().optional(),_meta:Y(N(),X()).optional()}),Co=Re.extend({type:V("tool_call"),toolCall:Jt,messageId:N().optional()}),To=Re.extend({type:V("tool_call_update"),toolCallUpdate:to,messageId:N().optional()}),ko=Re.extend({type:V("tool_output"),toolOutput:D({id:N(),content:B(Js()).optional(),rawOutput:Y(N(),X()).optional()}),messageId:N().optional()}),Io=Re.extend({type:V("generic").optional()});Ys([Co,To,ko,Io]);const Eo=[{id:"folder-1",name:"Item 1",type:"folder",children:[{id:"file-1-1",name:"Item 2",type:"file",extension:"tsx"},{id:"file-1-2",name:"Item 3",type:"file",extension:"ts"},{id:"file-1-3",name:"Item 4",type:"file",extension:"json"},{id:"file-1-4",name:"Item 5",type:"file",extension:"md"}]},{id:"folder-2",name:"Description 1",type:"folder",children:[{id:"file-2-1",name:"Description 2",type:"file",extension:"tsx"},{id:"file-2-2",name:"Description 3",type:"file",extension:"ts"},{id:"file-2-3",name:"Description 4",type:"file",extension:"json"},{id:"file-2-4",name:"Description 5",type:"file",extension:"md"}]},{id:"folder-3",name:"financial-docs",type:"folder",children:[]}];class Ro{data;constructor(s=Eo){this.data=s}async getRootItems(){return Promise.resolve(this.data)}async getItemChildren(s){const o=i=>{for(const a of i){if(a.id===s)return a;if(a.children){const r=o(a.children);if(r)return r}}},n=o(this.data);return Promise.resolve(n?.children||[])}async getItemDetails(s){const o=i=>{for(const a of i){if(a.id===s)return a;if(a.children){const r=o(a.children);if(r)return r}}},n=o(this.data);if(!n)throw new Error(`Item with id ${s} not found`);return Promise.resolve(n)}}const Ao=[{id:"1",title:"Boeing Scores Early Wins at Dubai Airshow",url:"https://www.reuters.com/business/aerospace-defense/boeing-scores-early-wins-dubai-airshow-2024-11-17",snippet:"DUBAI, Nov 17 (Reuters) - Boeing (BA.N), opens new tab took centre stage at day one of the Dubai Airshow on Monday, booking a $38 billion order from host carrier Emirates and clinching more deals with African carriers, while China displayed its C919 in the Middle East for the first time.",sourceName:"Reuters",favicon:"https://www.reuters.com/favicon.ico"},{id:"2",title:"Boeing's Sustainable Aviation Goals Take Flight",url:"https://www.forbes.com/boeing-sustainability",snippet:"SEATTLE, Nov 18 (Reuters) - Boeing is making headway towards its sustainability targets, unveiling plans for a new eco-friendly aircraft design aimed at reducing emissions by 50% by 2030.",sourceName:"Forbes"},{id:"3",title:"Boeing Faces Increased Competition in Global Aviation Market",url:"https://www.reuters.com/business/aerospace-defense/boeing-competition-2024-11-19",snippet:"CHICAGO, Nov 19 (Reuters) - As the global aviation industry rebounds post-pandemic, Boeing is grappling with intensified competition from rival manufacturers, particularly in the Asian market.",sourceName:"Reuters",favicon:"https://www.reuters.com/favicon.ico"},{id:"4",title:"Boeing's Starliner Successfully Completes Orbital Test Flight",url:"https://www.theverge.com/boeing-starliner",snippet:"NASA, Nov 20 (Reuters) - Boeing's CST-100 Starliner spacecraft achieves a significant milestone, successfully completing its orbital test flight, paving the way for future crewed missions to the International Space Station.",sourceName:"The Verge"}];function y(...t){return Xs(Zs(t))}const _o=ce("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-paragraph-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 cursor-pointer",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary-hover",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive-hover",outline:"border border-input bg-background hover:bg-accent-hover hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary-hover",ghost:"hover:bg-accent-hover hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),de=l.forwardRef(({className:t,variant:s,size:o,asChild:n=!1,...i},a)=>{const r=n?ve:"button";return e.jsx(r,{className:y(_o({variant:s,size:o,className:t})),ref:a,...i})});de.displayName="Button";const Mo=l.forwardRef(({className:t,...s},o)=>e.jsx("div",{ref:o,className:y("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Mo.displayName="Card";const Po=l.forwardRef(({className:t,...s},o)=>e.jsx("div",{ref:o,className:y("flex flex-col space-y-1.5 p-6",t),...s}));Po.displayName="CardHeader";const Do=l.forwardRef(({className:t,...s},o)=>e.jsx("div",{ref:o,className:y("text-2xl font-semibold leading-none tracking-tight",t),...s}));Do.displayName="CardTitle";const Uo=l.forwardRef(({className:t,...s},o)=>e.jsx("div",{ref:o,className:y("text-sm text-muted-foreground",t),...s}));Uo.displayName="CardDescription";const Lo=l.forwardRef(({className:t,...s},o)=>e.jsx("div",{ref:o,className:y("p-6 pt-0",t),...s}));Lo.displayName="CardContent";const zo=l.forwardRef(({className:t,...s},o)=>e.jsx("div",{ref:o,className:y("flex items-center p-6 pt-0",t),...s}));zo.displayName="CardFooter";const ss=l.forwardRef(({title:t,titleElement:s,description:o,guideUrl:n,guideText:i="Guide",suggestedPrompts:a=[],onPromptClick:r,onGuideClick:m,onOpenFiles:u,onOpenSettings:c,toolsAndMcpsCount:d,onPromptHover:f,onPromptLeave:p,className:h,...x},g)=>{const j=b=>{r?.(b)},v=()=>{n&&window.open(n,"_blank","noopener,noreferrer"),m?.()},S=[];for(let b=0;b<a.length;b+=2)S.push(a.slice(b,b+2));return e.jsxs("div",{ref:g,className:y("flex flex-col items-start",h),...x,children:[s?e.jsx("div",{className:"text-heading-4 text-text-primary mb-6",children:s}):e.jsx("h3",{className:"text-heading-4 text-text-primary mb-6",children:t}),e.jsx("p",{className:"text-subheading text-text-secondary max-w-prose mb-6",children:o}),(u||c)&&e.jsxs("div",{className:"flex items-center gap-1 -ml-3 mb-6",children:[u&&e.jsxs("button",{type:"button",onClick:u,className:"inline-flex items-center gap-1 py-1.5 pr-3 pl-3 rounded-lg hover:bg-accent transition-colors",children:[e.jsx("span",{className:"text-paragraph-sm-medium text-foreground tracking-wide leading-none",children:"View Files"}),e.jsx(he,{className:"size-4 text-foreground shrink-0"})]}),c&&e.jsxs("button",{type:"button",onClick:c,className:"inline-flex items-center gap-1 py-1.5 pr-3 pl-3 rounded-lg hover:bg-accent transition-colors",children:[e.jsxs("span",{className:"text-paragraph-sm-medium text-foreground tracking-wide leading-none",children:["View Tools & MCPs",d!==void 0&&d>0&&e.jsxs("span",{className:"ml-1",children:["(",d,")"]})]}),e.jsx(he,{className:"size-4 text-foreground shrink-0"})]})]}),(n||m)&&e.jsxs("button",{type:"button",onClick:v,className:"inline-flex items-center gap-1 py-1.5 pr-3 -ml-3 pl-3 rounded-lg hover:bg-accent transition-colors",children:[e.jsx("span",{className:"text-paragraph-sm-medium text-foreground tracking-wide leading-none",children:i}),e.jsx(he,{className:"size-4 text-foreground shrink-0"})]}),a.length>0&&e.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-prompt-container",children:[e.jsx("p",{className:"text-label text-text-tertiary",children:"Suggested Prompts"}),e.jsx("div",{className:"flex flex-col gap-2.5",children:S.map(b=>e.jsx("div",{className:"flex gap-2.5 items-center",children:b.map(w=>e.jsx("button",{type:"button",onClick:()=>j(w),onMouseEnter:()=>f?.(w),onMouseLeave:()=>p?.(),className:"flex-1 flex items-start gap-2 p-3 bg-secondary hover:bg-secondary/80 rounded-2xl transition-colors min-w-0",children:e.jsx("span",{className:"text-paragraph font-normal leading-normal text-text-tertiary truncate",children:w})},w))},b.join("-")))})]})]})});ss.displayName="ChatEmptyState";const ns=l.createContext(void 0),We=()=>{const t=l.useContext(ns);if(!t)throw new Error("ChatHeader components must be used within ChatHeader.Root");return t},os=l.forwardRef(({defaultExpanded:t=!1,expanded:s,onExpandedChange:o,className:n,children:i,...a},r)=>{const[m,u]=l.useState(t),c=s??m,d=l.useCallback(x=>{u(x),o?.(x)},[o]),f=l.Children.toArray(i),p=f.find(x=>l.isValidElement(x)&&typeof x.type=="function"&&x.type.displayName==="ChatHeader.ExpandablePanel"),h=f.filter(x=>x!==p);return e.jsxs(ns.Provider,{value:{isExpanded:c,setIsExpanded:d},children:[e.jsx("div",{ref:r,className:y("flex items-center justify-between px-6 py-4",n),...a,children:h}),p]})});os.displayName="ChatHeader.Root";const Fo=l.forwardRef(({className:t,children:s,...o},n)=>e.jsx("h1",{ref:n,className:y("m-0 text-subheading font-semibold",t),...o,children:s}));Fo.displayName="ChatHeader.Title";const Oo=l.forwardRef(({className:t,children:s,...o},n)=>e.jsx("div",{ref:n,className:y("flex items-center gap-3",t),...o,children:s}));Oo.displayName="ChatHeader.Actions";const $o=t=>{switch(t){case"connected":return"bg-green-500";case"connecting":return"bg-yellow-500";case"error":return"bg-red-500";default:return"bg-gray-500"}},Bo=t=>{switch(t){case"connected":return"Connected";case"connecting":return"Connecting...";case"error":return"Connection Error";default:return"No Server"}},Ho=l.forwardRef(({status:t,statusText:s,className:o,...n},i)=>{const a=s??Bo(t),r=$o(t);return e.jsxs("div",{ref:i,className:y("flex items-center gap-2",o),...n,children:[e.jsx("div",{className:y("h-2 w-2 rounded-full",r)}),e.jsx("span",{className:"text-paragraph-sm text-muted-foreground",children:a})]})});Ho.displayName="ChatHeader.StatusIndicator";const Wo=l.forwardRef(({icon:t,className:s,children:o,onClick:n,...i},a)=>{const{isExpanded:r,setIsExpanded:m}=We(),u=c=>{m(!r),n?.(c)};return e.jsxs("button",{ref:a,type:"button",onClick:u,className:y("rounded p-1 transition-colors hover:bg-background lg:hidden",s),"aria-label":r?"Collapse header":"Expand header",...i,children:[t&&e.jsx("div",{className:y("transition-transform duration-200",r&&"rotate-180"),children:t}),o]})});Wo.displayName="ChatHeader.Toggle";const as=l.forwardRef(({className:t,children:s,...o},n)=>{const{isExpanded:i}=We();return i?e.jsx("div",{ref:n,className:y("absolute top-full left-0 right-0 z-50 border-b border-border bg-card px-6 py-4 shadow-lg lg:hidden",t),...o,children:s}):null});as.displayName="ChatHeader.ExpandablePanel";const rs=l.forwardRef(({commands:t=[],showCommandMenu:s,commandMenuQuery:o,selectedMenuIndex:n,setSelectedMenuIndex:i,setMenuItemCount:a,triggerCounter:r,onChange:m,className:u,...c},d)=>{const f=l.useCallback((h,x)=>{const g=h.toLowerCase(),j=x.toLowerCase();if(!x)return 1;if(g.includes(j))return 1-j.length/g.length;let v=0;for(let S=0;S<g.length&&v<j.length;S++)g[S]===j[v]&&v++;return v===j.length?.5-v/g.length:0},[]),p=l.useMemo(()=>t.map(h=>({...h,score:Math.max(f(h.label,o),h.description?f(h.description,o):0)})).filter(h=>h.score>0).sort((h,x)=>x.score-h.score),[t,o,f]);return l.useEffect(()=>{a(p.length)},[p.length,a]),l.useEffect(()=>{i(0)},[i]),l.useEffect(()=>{r>0&&p[n]&&(p[n].onSelect(),m(""))},[r,p,n,m]),!s||p.length===0?null:e.jsxs("div",{ref:d,className:y("absolute bottom-full left-0 z-50 mb-2 w-full max-w-md","rounded-md border border-border bg-card p-2 shadow-lg",u),...c,children:[e.jsx("div",{className:"text-caption font-semibold text-muted-foreground px-2 py-1",children:"Commands"}),e.jsx("div",{className:"max-h-64 overflow-y-auto",children:p.map((h,x)=>e.jsxs("button",{type:"button",onClick:()=>h.onSelect(),className:y("w-full rounded-sm px-2 py-2 text-left text-paragraph-sm transition-colors","flex items-start gap-2","hover:bg-muted",x===n&&"bg-muted"),children:[h.icon&&e.jsx("span",{className:"shrink-0 mt-0.5",children:h.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium",children:h.label}),h.description&&e.jsx("div",{className:"text-caption text-muted-foreground truncate",children:h.description})]})]},h.id))})]})});rs.displayName="ChatInputCommandMenu";const is=l.createContext(void 0),Ae=()=>{const t=l.useContext(is);if(!t)throw new Error("ChatInput components must be used within ChatInput.Root");return t},ls=l.forwardRef(({client:t,startSession:s,value:o,onChange:n,onSubmit:i,disabled:a=!1,isSubmitting:r,submitOnEnter:m=!0,className:u,children:c,...d},f)=>{const p=l.useRef(null),h=l.useCallback(async()=>Promise.resolve(null),[]),x=no(t??null,s??h),g=M(O=>O.isStreaming),{addToHistory:j,navigatePrevious:v,navigateNext:S,resetNavigation:b}=ro(),w=t&&s,C=w?x.value:o||"",T=w?x.onChange:n||(()=>{}),I=w?x.onSubmit:i||(async()=>{}),A=w?x.isSubmitting||g:r||!1,U=l.useCallback(async()=>{const O=C.trim();O&&j(O),await I()},[C,j,I]),[H,G]=l.useState(!1),[k,L]=l.useState(""),[K,q]=l.useState(0),[Q,E]=l.useState(0),[F,$]=l.useState(0),_=l.useCallback(()=>{$(O=>O+1)},[]),R=async O=>{O.preventDefault(),C.trim()&&!A&&!a&&(await U(),setTimeout(()=>{p.current?.focus()},0))},W=O=>{const te=O.target;!(te.tagName==="BUTTON"||te.tagName==="INPUT"||te.tagName==="TEXTAREA"||te.closest("button"))&&p.current&&p.current.focus()},je=O=>{const te=O.target;!(te.tagName==="BUTTON"||te.tagName==="INPUT"||te.tagName==="TEXTAREA"||te.closest("button"))&&O.key===" "&&(O.preventDefault(),p.current&&p.current.focus())};return l.useEffect(()=>{const O=document.querySelector('textarea[name="chat-input"]');O&&p.current!==O&&(p.current=O)},[]),l.useEffect(()=>{!C&&p.current&&(p.current.style.height="auto",p.current.style.overflowY="hidden")},[C]),e.jsx(is.Provider,{value:{value:C,onChange:T,onSubmit:U,disabled:a,isSubmitting:A,submitOnEnter:m,showCommandMenu:H,setShowCommandMenu:G,commandMenuQuery:k,setCommandMenuQuery:L,selectedMenuIndex:K,setSelectedMenuIndex:q,menuItemCount:Q,setMenuItemCount:E,triggerMenuSelect:_,triggerCounter:F,navigateHistoryPrevious:v,navigateHistoryNext:S,resetHistoryNavigation:b},children:e.jsx("form",{ref:f,onSubmit:R,onClick:W,onKeyDown:je,className:y("relative w-full divide-y rounded-xl border bg-background shadow-md",u),...d,children:c})})});ls.displayName="ChatInput.Root";const cs=l.forwardRef(({asChild:t=!1,className:s,onKeyDown:o,onFilesDropped:n,children:i,...a},r)=>{const{value:m,onChange:u,onSubmit:c,disabled:d,isSubmitting:f,submitOnEnter:p,showCommandMenu:h,setShowCommandMenu:x,setCommandMenuQuery:g,setSelectedMenuIndex:j,menuItemCount:v,triggerMenuSelect:S,navigateHistoryPrevious:b,navigateHistoryNext:w,resetHistoryNavigation:C}=Ae(),T=l.useRef(null),[I,A]=l.useState(!1),U=l.useCallback(E=>{T.current=E,typeof r=="function"?r(E):r&&(r.current=E)},[r]),H=E=>new Promise((F,$)=>{const _=new FileReader;_.readAsDataURL(E),_.onload=()=>{const R=_.result.split(",")[1];F(R||"")},_.onerror=R=>$(R)}),Q={ref:U,name:"chat-input",value:m,onChange:E=>{const F=E.target.value;if(u(F),C(),F.startsWith("/")&&!F.includes(`
6
+ `)){x(!0);const R=F.slice(1);g(R)}else x(!1),g("");const $=T.current;if(!$)return;$.style.height="auto";const _=Math.min($.scrollHeight,164);$.style.height=`${_}px`,$.scrollHeight>164?$.style.overflowY="auto":$.style.overflowY="hidden"},onKeyDown:E=>{if(h&&v>0){if(E.key==="ArrowDown"){E.preventDefault(),j(F=>(F+1)%v);return}else if(E.key==="ArrowUp"){E.preventDefault(),j(F=>(F-1+v)%v);return}else if(E.key==="Enter"&&!E.shiftKey){E.preventDefault(),S();return}else if(E.key==="Escape"){E.preventDefault(),x(!1),g("");return}}if(!h){const F=T.current,$=F?.selectionStart===0&&F?.selectionEnd===0,_=F?.selectionStart===m.length&&F?.selectionEnd===m.length,R=m.includes(`
7
+ `);if(E.key==="ArrowUp"&&($||!m||!R)){const W=b(m);if(W!==null){E.preventDefault(),u(W),setTimeout(()=>{T.current&&(T.current.selectionStart=W.length,T.current.selectionEnd=W.length)},0);return}}else if(E.key==="ArrowDown"&&(_||!m||!R)){const W=w();if(W!==null){E.preventDefault(),u(W),setTimeout(()=>{T.current&&(T.current.selectionStart=W.length,T.current.selectionEnd=W.length)},0);return}}}p&&E.key==="Enter"&&!E.shiftKey&&(m.trim()&&!f&&!d?(E.preventDefault(),c()):(f||d)&&E.preventDefault()),o?.(E)},onDrop:async E=>{E.preventDefault(),A(!1);const F=E.dataTransfer.files;if(!F||F.length===0||!n)return;const $=[];for(const _ of Array.from(F))if(_.type.startsWith("image/"))try{const R=await H(_);$.push({name:_.name,path:_.name,size:_.size,mimeType:_.type,data:R})}catch(R){console.error("Failed to process dropped file:",_.name,R)}$.length>0&&n($)},onDragOver:E=>{E.preventDefault(),A(!0)},onDragLeave:E=>{E.preventDefault(),A(!1)},disabled:d,...a};return t&&l.isValidElement(i)?l.cloneElement(i,Q):e.jsx("textarea",{...Q,rows:1,className:y("w-full resize-none rounded-none border-none p-4 shadow-none","outline-none ring-0 max-h-[6lh] min-h-[44px]","bg-transparent dark:bg-transparent focus-visible:ring-0","text-paragraph-sm placeholder:text-muted-foreground","disabled:cursor-not-allowed disabled:opacity-50",I&&"ring-2 ring-primary ring-offset-2",s)})});cs.displayName="ChatInput.Field";const ds=l.forwardRef(({asChild:t=!1,className:s,disabled:o,children:n,...i},a)=>{const{value:r,disabled:m,isSubmitting:u}=Ae(),c=o||m||u||!r.trim(),d=t?ve:de;return e.jsx(d,{ref:a,type:"submit",disabled:c,variant:t?void 0:"default",size:"icon",className:y(!t&&"gap-1.5 rounded-full",s),...i,children:n})});ds.displayName="ChatInput.Submit";const us=l.forwardRef(({className:t,children:s,...o},n)=>e.jsx("div",{ref:n,className:y("flex items-center justify-between p-2",t),...o,children:s}));us.displayName="ChatInput.Toolbar";const ps=l.forwardRef(({asChild:t=!1,className:s,children:o,onClick:n,...i},a)=>{const{value:r,onChange:m,setShowCommandMenu:u,setCommandMenuQuery:c}=Ae(),d=p=>{r.startsWith("/")||(m("/"),u(!0),c("")),n?.(p)},f=t?ve:de;return e.jsx(f,{ref:a,type:"button",variant:"ghost",size:"icon",className:y("rounded-full",s),onClick:d,...i,children:o||e.jsx(xn,{className:"size-4"})})});ps.displayName="ChatInput.Actions";const ms=l.forwardRef(({asChild:t=!1,className:s,children:o,onFilesSelected:n,...i},a)=>{const r=l.useRef(null),m=f=>new Promise((p,h)=>{const x=new FileReader;x.readAsDataURL(f),x.onload=()=>{const g=x.result.split(",")[1];p(g||"")},x.onerror=g=>h(g)}),u=async f=>{const p=f.target.files;if(!p||p.length===0)return;const h=[];for(const x of Array.from(p))if(x.type.startsWith("image/"))try{const g=await m(x);h.push({name:x.name,path:x.name,size:x.size,mimeType:x.type,data:g})}catch(g){console.error("Failed to process file:",x.name,g)}h.length>0&&n&&n(h),r.current&&(r.current.value="")},c=f=>{f.preventDefault(),r.current?.click()},d=t?ve:de;return e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:r,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:u}),e.jsx(d,{ref:a,type:"button",variant:"ghost",size:"icon",className:y("rounded-full",s),onClick:c,...i,children:o||e.jsx(bn,{className:"size-4"})})]})});ms.displayName="ChatInput.Attachment";const fs=l.forwardRef(({asChild:t=!1,className:s,children:o,...n},i)=>{const a=t?ve:de;return e.jsx(a,{ref:i,type:"button",variant:"ghost",size:"icon",className:y("rounded-full",s),...n,children:o||e.jsx(yn,{className:"size-4"})})});fs.displayName="ChatInput.VoiceInput";const gs=l.forwardRef(({commands:t=[],className:s,onChange:o,...n},i)=>{const{showCommandMenu:a,commandMenuQuery:r,selectedMenuIndex:m,setSelectedMenuIndex:u,setMenuItemCount:c,triggerCounter:d,onChange:f}=Ae();return e.jsx(rs,{ref:i,commands:t,showCommandMenu:a,commandMenuQuery:r,selectedMenuIndex:m,setSelectedMenuIndex:u,setMenuItemCount:c,triggerCounter:d,onChange:f,className:s,...n})});gs.displayName="ChatInput.CommandMenu";const Vo=({className:t,...s})=>e.jsx(Hs,{className:y("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",t),...s}),hs=({className:t,...s})=>e.jsx(Ws,{className:y(t),...s}),qo=({withHandle:t,className:s,...o})=>e.jsx(Vs,{className:y("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",s),...o,children:t&&e.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-2.5 w-2.5",children:[e.jsx("title",{children:"Resize Handle"}),e.jsx("circle",{cx:"9",cy:"12",r:"1"}),e.jsx("circle",{cx:"9",cy:"5",r:"1"}),e.jsx("circle",{cx:"9",cy:"19",r:"1"}),e.jsx("circle",{cx:"15",cy:"12",r:"1"}),e.jsx("circle",{cx:"15",cy:"5",r:"1"}),e.jsx("circle",{cx:"15",cy:"19",r:"1"})]})})}),Go=({...t})=>e.jsx(en,{position:"top-center",className:"toaster group",style:{"--top-offset":"16px","--width:":"calc(100% - 2 * var(--top-offset))",position:"absolute",zIndex:5,top:"var(--top-offset)",left:"50%",transform:"translateX(-50%)",width:"calc(100% - 2 * var(--top-offset))",maxWidth:"480px"},offset:0,toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t}),Ve=l.createContext(void 0),fe=()=>{const t=l.useContext(Ve);if(!t)throw new Error("ChatLayout components must be used within ChatLayout.Root");return t},xs=l.forwardRef(({defaultSidebarOpen:t=!1,defaultPanelSize:s="hidden",defaultActiveTab:o="todo",className:n,children:i,...a},r)=>{const[m,u]=l.useState(t),[c,d]=l.useState(s),[f,p]=l.useState(o);return e.jsx(Ve.Provider,{value:{sidebarOpen:m,setSidebarOpen:u,panelSize:c,setPanelSize:d,activeTab:f,setActiveTab:p},children:e.jsx("div",{ref:r,className:y("flex h-screen flex-row bg-background text-foreground",n),...a,children:e.jsx(Vo,{direction:"horizontal",className:"flex-1",children:i})})})});xs.displayName="ChatLayout.Root";const Ko=l.forwardRef(({className:t,children:s,...o},n)=>e.jsx("div",{ref:n,className:y("relative z-10 border-b border-border bg-card shrink-0",t),...o,children:s}));Ko.displayName="ChatLayout.Header";const bs=l.forwardRef(({className:t,children:s,...o},n)=>e.jsx(hs,{defaultSize:70,minSize:50,children:e.jsx("div",{ref:n,className:y("flex flex-1 flex-col overflow-hidden h-full",t),...o,children:s})}));bs.displayName="ChatLayout.Main";const ys=l.forwardRef(({showToaster:t=!0,className:s,children:o,...n},i)=>e.jsxs("div",{ref:i,className:y("relative flex flex-1 flex-col overflow-hidden",s),...n,children:[o,t&&e.jsx(Go,{})]}));ys.displayName="ChatLayout.Body";const vs=l.forwardRef(({className:t,children:s,onScrollChange:o,showScrollToBottom:n=!0,initialScrollToBottom:i=!0,...a},r)=>{const[m,u]=l.useState(!1),c=l.useRef(null),d=l.useRef(!0),f=l.useRef(!1),p=l.useRef(!1);l.useImperativeHandle(r,()=>c.current);const h=l.useCallback(()=>{const w=c.current;if(!w)return!1;const{scrollTop:C,scrollHeight:T,clientHeight:I}=w,U=T-C-I<100;return u(!U&&n),o?.(U),U},[o,n]),x=l.useCallback(()=>{if(f.current)return;const w=h();d.current=w},[h]),g=l.useCallback((w=!0)=>{const C=c.current;C&&(f.current=!0,d.current=!0,C.scrollTo({top:C.scrollHeight,behavior:w?"smooth":"auto"}),setTimeout(()=>{f.current=!1},w?300:0))},[]);l.useEffect(()=>{c.current&&(d.current&&!f.current&&requestAnimationFrame(()=>{g(!1)}),f.current||h())},[s,g,h]);const j=l.useRef(0),v=l.useRef(0);l.useEffect(()=>{if(!i)return;const w=c.current;if(!w)return;const C=()=>{w.scrollTop=w.scrollHeight,d.current=!0},T=w.scrollHeight;T===j.current?v.current++:(v.current=0,j.current=T),v.current<3?(f.current=!0,C(),p.current=!0):f.current=!1},[i,s]),l.useEffect(()=>{if(!i)return;const w=c.current;if(!w)return;let C=!1;const T=setInterval(()=>{C||w.scrollHeight>w.clientHeight&&(f.current=!0,w.scrollTop=w.scrollHeight,d.current=!0,p.current=!0)},100),I=setTimeout(()=>{clearInterval(T),f.current=!1},2e3);return()=>{C=!0,clearInterval(T),clearTimeout(I)}},[i]),l.useEffect(()=>{if(!f.current){const w=h();d.current=w}},[h]);const S=l.useCallback(()=>{f.current=!1;const w=c.current;if(!w)return;const{scrollTop:C,scrollHeight:T,clientHeight:I}=w;T-C-I>=100&&(d.current=!1)},[]),b=l.useCallback(w=>{["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"].includes(w.key)&&(f.current=!1,requestAnimationFrame(()=>{const T=c.current;if(!T)return;const{scrollTop:I,scrollHeight:A,clientHeight:U}=T,H=A-I-U;d.current=H<100}))},[]);return e.jsxs("div",{className:"relative flex-1 overflow-hidden",children:[e.jsx("div",{ref:c,className:y("h-full overflow-y-auto flex flex-col",t),onScroll:x,onWheel:S,onTouchStart:S,onKeyDown:b,tabIndex:0,...a,children:e.jsx("div",{className:"mx-auto max-w-chat flex-1 w-full flex flex-col",children:s})}),m&&e.jsx("button",{type:"button",onClick:()=>g(!0),className:y("absolute bottom-4 left-1/2 -translate-x-1/2 z-10","flex items-center justify-center p-2 rounded-full","bg-card border border-border shadow-lg","text-foreground","hover:bg-accent hover:text-accent-foreground","transition-all duration-200 ease-in-out","animate-in fade-in slide-in-from-bottom-2"),"aria-label":"Scroll to bottom",children:e.jsx(vn,{className:"size-4"})})]})});vs.displayName="ChatLayout.Messages";const ws=l.forwardRef(({className:t,children:s,...o},n)=>e.jsx("div",{ref:n,className:y("bg-linear-to-t from-background to-transparent px-4 pb-4",t),...o,children:e.jsx("div",{className:"mx-auto max-w-chat",children:s})}));ws.displayName="ChatLayout.Footer";const Qo=l.forwardRef(({className:t,children:s,...o},n)=>{const{sidebarOpen:i}=fe();return i?e.jsx("div",{ref:n,className:y("border-r border-border bg-card w-64 overflow-y-auto",t),...o,children:s}):null});Qo.displayName="ChatLayout.Sidebar";const js=l.forwardRef(({breakpoint:t="lg",className:s,children:o,...n},i)=>{const{panelSize:a}=fe(),[r,m]=l.useState(28);return l.useEffect(()=>{const u=()=>{const d=450/window.innerWidth*100;m(Math.max(d,28))};return u(),window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}},[]),a==="hidden"?null:e.jsxs(e.Fragment,{children:[e.jsx(qo,{withHandle:!0,className:"group-hover:opacity-100 opacity-0 transition-opacity"}),e.jsx(hs,{defaultSize:30,minSize:r,maxSize:40,className:"group",children:e.jsx("div",{ref:i,className:y("hidden h-full border-l border-border bg-card overflow-y-auto transition-all duration-300",t==="md"&&"md:block",t==="lg"&&"lg:block",t==="xl"&&"xl:block",t==="2xl"&&"2xl:block",s),...n,children:o})})]})});js.displayName="ChatLayout.Aside";const qe=nn,Ge=on,Jo=l.forwardRef(({className:t,inset:s,children:o,...n},i)=>e.jsxs(mt,{ref:i,className:y("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-paragraph-sm outline-none","focus:bg-muted data-[state=open]:bg-muted",s&&"pl-8",t),...n,children:[o,e.jsx(he,{className:"ml-auto h-4 w-4"})]}));Jo.displayName=mt.displayName;const Yo=l.forwardRef(({className:t,...s},o)=>e.jsx(ft,{ref:o,className:y("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-card p-1 shadow-lg","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2","data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2","data-[side=top]:slide-in-from-bottom-2",t),...s}));Yo.displayName=ft.displayName;const _e=l.forwardRef(({className:t,sideOffset:s=4,...o},n)=>e.jsx(sn,{children:e.jsx(gt,{ref:n,sideOffset:s,className:y("z-50 min-w-[8rem] overflow-hidden rounded-lg border border-border bg-popover p-0.5 shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2","data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2","data-[side=top]:slide-in-from-bottom-2",t),...o})}));_e.displayName=gt.displayName;const ne=l.forwardRef(({className:t,inset:s,...o},n)=>e.jsx(ht,{ref:n,className:y("relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-paragraph-sm outline-none transition-colors","focus:bg-muted focus:text-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s&&"pl-8",t),...o}));ne.displayName=ht.displayName;const Xo=l.forwardRef(({className:t,children:s,...o},n)=>e.jsxs(xt,{ref:n,className:y("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-paragraph-sm outline-none transition-colors","focus:bg-muted focus:text-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...o,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(bt,{children:e.jsx(zt,{className:"h-4 w-4"})})}),s]}));Xo.displayName=xt.displayName;const Zo=l.forwardRef(({className:t,children:s,...o},n)=>e.jsxs(yt,{ref:n,className:y("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-paragraph-sm outline-none transition-colors","focus:bg-muted focus:text-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...o,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(bt,{children:e.jsx(Fe,{className:"h-2 w-2 fill-current"})})}),s]}));Zo.displayName=yt.displayName;const Ns=l.forwardRef(({className:t,inset:s,...o},n)=>e.jsx(vt,{ref:n,className:y("px-2 py-1.5 text-paragraph-sm font-semibold",s&&"pl-8",t),...o}));Ns.displayName=vt.displayName;const Ie=l.forwardRef(({className:t,...s},o)=>e.jsx(wt,{ref:o,className:y("-mx-1 my-1 h-px bg-border",t),...s}));Ie.displayName=wt.displayName;function Ss({item:t,level:s=0,onSelect:o,selectedId:n,isDropTarget:i=!1,onDownload:a,onRename:r,onDelete:m}){const[u,c]=l.useState(!0),d=n===t.id,f=()=>{t.type==="folder"&&c(!u)},p=()=>{o?.(t),t.type==="folder"&&f()},h=g=>{g.key==="Enter"||g.key===" "?(g.preventDefault(),p()):g.key==="ArrowRight"&&t.type==="folder"&&!u?(g.preventDefault(),c(!0)):g.key==="ArrowLeft"&&t.type==="folder"&&u&&(g.preventDefault(),c(!1))},x=()=>s===0?"p-2":s===1?"pl-8 pr-2 py-2":"pl-16 pr-2 py-2";return e.jsxs("div",{className:"flex flex-col w-full",children:[e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":t.type==="folder"?u:void 0,className:y("group/item flex items-center gap-2 rounded-md cursor-pointer transition-colors text-paragraph-sm",x(),"hover:bg-accent-hover","focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-border-dark",d&&"bg-accent",i&&["bg-accent","border border-dashed border-border-dark"]),onClick:p,onKeyDown:h,children:[e.jsx("div",{className:"shrink-0 size-4 flex items-center justify-center text-foreground",children:t.type==="folder"?u?e.jsx(wn,{className:"size-4"}):e.jsx(jn,{className:"size-4"}):e.jsx(Nn,{className:"size-4"})}),e.jsx("p",{className:"flex-1 text-foreground whitespace-nowrap overflow-hidden text-ellipsis",children:t.name}),e.jsxs(qe,{children:[e.jsx(Ge,{asChild:!0,children:e.jsx("button",{className:y("shrink-0 size-4 transition-opacity text-muted-foreground hover:text-foreground","opacity-0 group-hover/item:opacity-100","data-[state=open]:opacity-100"),onClick:g=>{g.stopPropagation()},"aria-label":"More options",type:"button",tabIndex:-1,children:e.jsx(Sn,{className:"size-4"})})}),e.jsxs(_e,{align:"end",side:"bottom",sideOffset:5,alignOffset:0,collisionPadding:8,className:"w-40 z-[100]",onClick:g=>g.stopPropagation(),children:[a&&e.jsx(ne,{onClick:g=>{g.stopPropagation(),a(t)},children:"Download"}),r&&e.jsx(ne,{onClick:g=>{g.stopPropagation(),r(t)},children:"Rename"}),(a||r)&&m&&e.jsx(Ie,{}),m&&e.jsx(ne,{className:"text-destructive focus:text-destructive focus:bg-muted",onClick:g=>{g.stopPropagation(),m(t)},children:e.jsx("span",{className:"text-paragraph-sm",children:"Delete"})})]})]}),t.type==="folder"&&e.jsx("div",{className:"shrink-0 size-4 flex items-center justify-center text-muted-foreground",children:e.jsx(ie,{className:y("size-4 transition-transform",!u&&"-rotate-90")})})]}),t.type==="folder"&&u&&t.children&&e.jsx("div",{className:"flex flex-col",children:t.children.map(g=>e.jsx(Ss,{item:g,level:s+1,...o&&{onSelect:o},...n&&{selectedId:n},...a&&{onDownload:a},...r&&{onRename:r},...m&&{onDelete:m}},g.id))})]})}const ea=new Ro;function ta({className:t,provider:s=ea,onItemSelect:o,onDownload:n,onRename:i,onDelete:a}){const[r,m]=l.useState([]),[u,c]=l.useState(),[d,f]=l.useState(!0),[p,h]=l.useState();l.useEffect(()=>{(async()=>{try{f(!0);const j=await s.getRootItems();m(j),h(void 0)}catch(j){h(j instanceof Error?j.message:"Failed to load items")}finally{f(!1)}})()},[s]);const x=g=>{c(g.id),o?.(g)};return d?e.jsx("div",{className:y("",t),children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."})}):p?e.jsx("div",{className:y("",t),children:e.jsxs("p",{className:"text-sm text-destructive",children:["Error: ",p]})}):e.jsx("div",{className:y("flex flex-col",t),children:r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No items found"}):r.map(g=>e.jsx(Ss,{item:g,onSelect:x,...u&&{selectedId:u},...n&&{onDownload:n},...i&&{onRename:i},...a&&{onDelete:a}},g.id))})}const Cs=l.forwardRef(({source:t,isSelected:s,className:o,...n},i)=>e.jsxs("button",{ref:i,type:"button",className:y("group flex w-full text-left gap-2 items-start p-2 rounded-md cursor-pointer transition-colors text-paragraph-sm","hover:bg-accent-hover","focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-border-dark",s&&"bg-accent",o),onClick:()=>window.open(t.url,"_blank"),...n,children:[e.jsx("div",{className:"shrink-0 flex items-center h-5",children:e.jsx("div",{className:"relative rounded-[3px] size-4 overflow-hidden bg-muted",children:t.favicon?e.jsx("img",{alt:t.sourceName,className:"size-full object-cover",src:t.favicon}):e.jsx("div",{className:"size-full bg-muted"})})}),e.jsxs("div",{className:"flex flex-1 flex-col gap-1 min-w-0",children:[e.jsxs("div",{className:"text-paragraph-sm text-foreground",children:[e.jsx("span",{className:"font-medium",children:t.sourceName}),e.jsxs("span",{className:"text-muted-foreground",children:[" · ",t.title]})]}),e.jsx("p",{className:"text-paragraph-sm text-muted-foreground line-clamp-3",children:t.snippet})]})]}));Cs.displayName="SourceListItem";const Ts=l.forwardRef(({todo:t,className:s,...o},n)=>{const i=t.status==="completed";return e.jsxs("div",{ref:n,className:y("group flex items-center gap-2 p-2 rounded-md cursor-pointer transition-colors text-paragraph-sm","hover:bg-accent-hover","focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-border-dark",!1,s),role:"button",tabIndex:0,...o,children:[e.jsx("div",{className:"shrink-0 size-4 flex items-center justify-center text-foreground",children:t.status==="completed"?e.jsx(Ft,{className:"size-4 text-muted-foreground"}):t.status==="in_progress"?e.jsx("div",{className:"size-2.5 rounded-full bg-foreground animate-pulse-scale"}):e.jsx(Fe,{className:"size-4 text-foreground"})}),e.jsx("p",{className:y("flex-1 text-foreground",i&&"line-through text-muted-foreground",t.status==="in_progress"&&"font-medium"),children:t.text})]})});Ts.displayName="TodoListItem";function sa(){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[e.jsx(Ee,{className:"size-8 text-neutral-300"}),e.jsxs("p",{className:"text-base leading-6 text-neutral-400 text-center",children:["There's nothing on the",e.jsx("br",{}),"to-do list yet."]})]})}const Ke=l.forwardRef(({client:t,todos:s,className:o,...n},i)=>{const a=s||[];return a.length===0?e.jsx("div",{ref:i,className:y("h-full",o),...n,children:e.jsx(sa,{})}):e.jsx("div",{ref:i,className:y("space-y-2 max-h-64 overflow-y-auto",o),...n,children:a.map(r=>e.jsx(Ts,{todo:r},r.id))})});Ke.displayName="TodoList";const Me=l.forwardRef(({todos:t=[],className:s,...o},n)=>e.jsx("div",{ref:n,className:y("h-full",s),...o,children:e.jsx(Ke,{todos:t,className:"h-full"})}));Me.displayName="TodoTabContent";const Pe=l.forwardRef(({files:t=[],provider:s,onFileSelect:o,className:n,...i},a)=>{const r=l.useCallback(c=>{console.log("Download:",c.name)},[]),m=l.useCallback(c=>{console.log("Rename:",c.name)},[]),u=l.useCallback(c=>{console.log("Delete:",c.name)},[]);return e.jsx("div",{ref:a,className:y("h-full",n),...i,children:e.jsx(ta,{...s&&{provider:s},onItemSelect:c=>{c.type==="file"&&o&&o(c.path||c.name)},onDownload:r,onRename:m,onDelete:u,className:"h-full"})})});Pe.displayName="FilesTabContent";const De=l.forwardRef(({sources:t,className:s,...o},n)=>{const i=t&&t.length>0?t:Ao;return e.jsx("div",{ref:n,className:y("space-y-2",s),...o,children:i.map(a=>e.jsx(Cs,{source:a},a.id))})});De.displayName="SourcesTabContent";const na=l.forwardRef(({data:t,className:s,...o},n)=>e.jsxs("div",{ref:n,className:y("space-y-4",s),...o,children:[e.jsx("h3",{className:"font-semibold text-subheading",children:"Database"}),e.jsxs("div",{className:"text-paragraph-sm text-muted-foreground",children:[e.jsx("p",{children:"Database viewer - panel automatically expanded to large size"}),e.jsxs("div",{className:"mt-4 p-4 border border-border rounded",children:[e.jsx("p",{children:"Your large data table would go here"}),t&&typeof t=="object"?e.jsx("pre",{className:"mt-2 text-caption overflow-auto",children:JSON.stringify(t,null,2)}):null]})]})]}));na.displayName="DatabaseTabContent";const Qe=l.forwardRef(({tools:t=[],mcps:s=[],subagents:o=[],className:n,...i},a)=>e.jsxs("div",{ref:a,className:y("space-y-6",n),...i,children:[e.jsxs("div",{className:"space-y-3 p-2",children:[e.jsx("h3",{className:"font-semibold text-subheading",children:"Tools"}),t.length>0?e.jsx("div",{className:"space-y-2",children:t.map(r=>e.jsxs("div",{className:"p-3 border border-border rounded-lg bg-muted/30",children:[e.jsx("div",{className:"font-medium text-paragraph-sm",children:r.prettyName||r.name}),r.description&&e.jsx("div",{className:"text-caption text-muted-foreground mt-1 line-clamp-1",children:r.description})]},r.name))}):e.jsx("p",{className:"text-paragraph-sm text-muted-foreground",children:"No tools available"})]}),e.jsxs("div",{className:"space-y-3 p-2",children:[e.jsx("h3",{className:"font-semibold text-subheading",children:"MCP Servers"}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(r=>e.jsxs("div",{className:"p-3 border border-border rounded-lg bg-muted/30",children:[e.jsx("div",{className:"font-medium text-paragraph-sm",children:r.name}),e.jsxs("div",{className:"text-caption text-muted-foreground mt-1",children:["Transport: ",r.transport]})]},r.name))}):e.jsx("p",{className:"text-paragraph-sm text-muted-foreground",children:"No MCP servers connected"})]}),e.jsxs("div",{className:"space-y-3 p-2",children:[e.jsx("h3",{className:"font-semibold text-subheading",children:"Subagents"}),o.length>0?e.jsx("div",{className:"space-y-2",children:o.map(r=>e.jsxs("div",{className:"p-3 border border-border rounded-lg bg-muted/30",children:[e.jsx("div",{className:"font-medium text-paragraph-sm",children:r.name}),e.jsx("div",{className:"text-caption text-muted-foreground mt-1 line-clamp-2",children:r.description})]},r.name))}):e.jsx("p",{className:"text-paragraph-sm text-muted-foreground",children:"No subagents available"})]})]}));Qe.displayName="SettingsTabContent";const Je=an,xe=l.forwardRef(({className:t,...s},o)=>e.jsx(jt,{ref:o,className:y("inline-flex h-10 items-center rounded-md bg-muted p-1 text-muted-foreground gap-1",t),...s}));xe.displayName=jt.displayName;const be=l.forwardRef(({className:t,...s},o)=>e.jsx(Nt,{ref:o,className:y("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-paragraph-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...s}));be.displayName=Nt.displayName;const J=l.forwardRef(({className:t,...s},o)=>e.jsx(St,{ref:o,className:y("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s}));J.displayName=St.displayName;const oa=l.forwardRef(({client:t,todos:s,variant:o="animated",showIcons:n=!1,visibleTabs:i=["todo","files","database"],className:a,...r},m)=>{const u=s||[],[c,d]=l.useState(i[0]||"todo"),f=l.useRef(null),p=l.useRef(null);l.useEffect(()=>{const j=setTimeout(()=>{const v=f.current;if(c&&v){const S=p.current;if(S){const b=v.getBoundingClientRect(),w=S.getBoundingClientRect(),C=w.left-b.left,T=w.width,I=C/b.width*100,A=100-(C+T)/b.width*100;v.style.clipPath=`inset(0 ${A.toFixed(2)}% 0 ${I.toFixed(2)}% round 999px)`}}},0);return()=>clearTimeout(j)},[c]);const x=[{id:"todo",label:o==="pills"?"To-do":"To-Do List",icon:Ee},{id:"files",label:"Files",icon:Oe},{id:"database",label:"Database",icon:Ot},{id:"sources",label:"Sources",icon:$t}].filter(g=>i.includes(g.id));return e.jsx("div",{ref:m,className:y("select-none",a),...r,children:e.jsxs(Je,{value:c,onValueChange:d,className:"w-full",children:[o==="pills"?e.jsx(xe,{className:y("w-full justify-start bg-transparent p-0 h-auto","gap-1"),children:x.map(g=>{const j=g.icon;return e.jsxs(be,{value:g.id,className:y("gap-2 px-3 py-1.5 rounded-lg text-paragraph-sm font-medium","data-[state=active]:bg-accent data-[state=active]:text-foreground","data-[state=inactive]:text-muted-foreground"),children:[n&&j&&e.jsx(j,{className:"size-4"}),g.label]},g.id)})}):e.jsxs("div",{className:"relative mb-4 border-border",children:[e.jsx(xe,{className:"bg-transparent p-0 h-auto rounded-none w-full border-none",children:x.map(g=>e.jsx(be,{value:g.id,className:"px-3 py-1 text-paragraph-sm font-medium rounded-none text-foreground opacity-60 data-[state=active]:opacity-100 data-[state=active]:bg-transparent data-[state=active]:shadow-none",children:g.label},g.id))}),e.jsx("div",{ref:f,className:"absolute top-0 left-0 w-full overflow-hidden z-10 pointer-events-none",style:{clipPath:"inset(0 100% 0 0% round 999px)",transition:"clip-path 0.25s ease-out"},children:e.jsx(xe,{className:"bg-secondary p-0 h-auto rounded-none w-full border-none",children:x.map(g=>e.jsx(be,{value:g.id,ref:c===g.id?p:null,className:"px-3 py-1 text-paragraph-sm font-medium rounded-none text-primary bg-transparent data-[state=active]:shadow-none shadow-none",tabIndex:-1,children:g.label},g.id))})})]}),e.jsx(J,{value:"todo",className:o==="pills"?"mt-0":"",children:o==="pills"?e.jsx(Me,{todos:u}):e.jsx(Ke,{todos:u})}),e.jsx(J,{value:"files",className:o==="pills"?"mt-0":"",children:e.jsx(Pe,{})}),e.jsx(J,{value:"database",className:o==="pills"?"mt-0":"",children:e.jsx("div",{className:"text-paragraph-sm text-foreground opacity-60 italic",children:"Database tab coming soon..."})}),e.jsx(J,{value:"sources",className:o==="pills"?"mt-0":"",children:e.jsx(De,{})})]})})});oa.displayName="ChatSecondaryPanel";const aa=l.forwardRef(({className:t,children:s,...o},n)=>e.jsx("div",{ref:n,className:y("flex h-full flex-col",t),...o,children:s}));aa.displayName="ChatSidebar.Root";const ra=l.forwardRef(({className:t,children:s,...o},n)=>e.jsx("div",{ref:n,className:y("border-b border-border px-4 py-3",t),...o,children:s}));ra.displayName="ChatSidebar.Header";const ia=l.forwardRef(({className:t,children:s,...o},n)=>e.jsx("div",{ref:n,className:y("flex-1 overflow-y-auto p-4",t),...o,children:s}));ia.displayName="ChatSidebar.Content";const la=l.forwardRef(({className:t,children:s,...o},n)=>e.jsx("div",{ref:n,className:y("border-t border-border px-4 py-3",t),...o,children:s}));la.displayName="ChatSidebar.Footer";const ca=l.forwardRef(({children:t,className:s,...o},n)=>{const[i,a]=l.useState(t),[r,m]=l.useState(!1),u=l.useRef(t),c=l.useRef(!0);return l.useEffect(()=>{if(c.current){c.current=!1,u.current=t;return}if(u.current===t)return;m(!0);const d=setTimeout(()=>{a(t),u.current=t,requestAnimationFrame(()=>{m(!1)})},150);return()=>{clearTimeout(d)}},[t]),e.jsx("span",{ref:n,className:y("text-sm text-foreground opacity-60 transition-opacity duration-300",r?"opacity-0":"opacity-60",s),...o,children:i})});ca.displayName="ChatStatus";const re=oe("gui");function da({children:t}){const{setPanelSize:s,setActiveTab:o,panelSize:n,activeTab:i}=fe(),a=()=>{n!=="hidden"&&i==="files"?s("hidden"):(s("small"),o("files"))},r=()=>{n!=="hidden"&&i==="settings"?s("hidden"):(s("small"),o("settings"))};return e.jsx(e.Fragment,{children:t({openFiles:a,openSettings:r})})}function ua(){const{panelSize:t,setPanelSize:s}=fe();return l.useEffect(()=>{const o=n=>{(n.metaKey||n.ctrlKey)&&n.key==="b"&&(n.preventDefault(),s(t==="hidden"?"small":"hidden"))};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t,s]),null}function pa(t){const s=new Date(t),n=new Date().getTime()-s.getTime(),i=Math.floor(n/6e4),a=Math.floor(n/36e5),r=Math.floor(n/864e5);return i<1?"Just now":i<60?`${i}m ago`:a<24?`${a}h ago`:r<7?`${r}d ago`:s.toLocaleDateString()}function Ye({agentName:t,client:s,currentSessionId:o}){const[n,i]=l.useState([]),[a,r]=l.useState(!1),[m,u]=l.useState(!1),c=l.useCallback(async()=>{if(s){r(!0);try{const p=await s.listSessions();i(p)}catch(p){re.error("Failed to fetch sessions",{error:p})}finally{r(!1)}}},[s]);l.useEffect(()=>{m&&c()},[m,c]);const d=()=>{const p=new URL(window.location.href);p.searchParams.delete("session"),window.location.href=p.toString()},f=p=>{if(p===o){u(!1);return}const h=new URL(window.location.href);h.searchParams.set("session",p),window.location.href=h.toString()};return e.jsxs(qe,{open:m,onOpenChange:u,children:[e.jsx(Ge,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex items-center gap-1 text-heading-4 text-foreground hover:text-foreground/80 transition-colors cursor-pointer",children:[t,e.jsx(ie,{className:y("size-4 text-muted-foreground transition-transform duration-200",m&&"rotate-180")})]})}),e.jsxs(_e,{align:"start",className:"w-72",children:[e.jsxs(Ns,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Sessions"}),a&&e.jsx("span",{className:"text-caption text-muted-foreground",children:"Loading..."})]}),e.jsx(Ie,{}),e.jsxs(ne,{onClick:d,className:"gap-2",children:[e.jsx(Tn,{className:"size-4"}),e.jsx("span",{children:"New Session"})]}),n.length>0&&e.jsx(Ie,{}),e.jsx("div",{className:"max-h-64 overflow-y-auto",children:n.map(p=>e.jsxs(ne,{onClick:()=>f(p.sessionId),className:y("flex flex-col items-start gap-0.5 py-2",p.sessionId===o&&"bg-muted/50 font-medium"),children:[e.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate text-paragraph-sm",children:p.firstUserMessage||"Empty session"}),p.sessionId===o&&e.jsx("span",{className:"shrink-0 text-caption text-primary",children:"Current"})]}),e.jsxs("span",{className:"text-caption text-muted-foreground",children:[pa(p.updatedAt)," • ",p.messageCount," ","messages"]})]},p.sessionId))}),n.length===0&&!a&&e.jsx("div",{className:"px-2 py-4 text-center text-paragraph-sm text-muted-foreground",children:"No previous sessions"})]})]})}function ma({client:t,startSession:s,placeholder:o,latestContextSize:n,currentModel:i,commandMenuItems:a}){const r=M(d=>d.input.attachedFiles),m=M(d=>d.addFileAttachment),u=M(d=>d.removeFileAttachment),c=d=>{for(const f of d)m(f)};return e.jsxs(ls,{client:t,startSession:s,children:[e.jsx(gs,{commands:a}),r.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 p-3 border-b border-border",children:r.map((d,f)=>e.jsxs("div",{className:"relative group rounded-md overflow-hidden border border-border",children:[e.jsx("img",{src:`data:${d.mimeType};base64,${d.data}`,alt:d.name,className:"h-20 w-20 object-cover"}),e.jsx("button",{type:"button",onClick:()=>u(f),className:"absolute top-1 right-1 p-1 rounded-full bg-background/80 hover:bg-background opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Bt,{className:"size-3"})})]},f))}),e.jsx(cs,{placeholder:o,autoFocus:!0,onFilesDropped:c}),e.jsxs(us,{children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx(ps,{}),e.jsx(ms,{onFilesSelected:c}),n!=null&&e.jsx(Rs,{contextSize:n,modelContextWindow:i?.includes("claude")?2e5:128e3})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(fs,{}),e.jsx(ds,{children:e.jsx(kn,{className:"size-4"})})]})]})]})}function fa({todos:t,tools:s,mcps:o,subagents:n}){const{activeTab:i,setActiveTab:a}=fe();return e.jsxs(Je,{value:i,onValueChange:r=>a(r),className:"flex flex-col h-full",children:[e.jsx("div",{className:y("border-b border-border bg-card","px-4 py-2 h-16","flex items-center","[border-bottom-width:0.5px]"),children:e.jsx(Ze,{showIcons:!0,visibleTabs:["todo","files","sources","settings"],variant:"compact"})}),e.jsx(J,{value:"todo",className:"flex-1 p-4 mt-0",children:e.jsx(Me,{todos:t})}),e.jsx(J,{value:"files",className:"flex-1 p-4 mt-0",children:e.jsx(Pe,{})}),e.jsx(J,{value:"sources",className:"flex-1 p-4 mt-0",children:e.jsx(De,{})}),e.jsx(J,{value:"settings",className:"flex-1 p-4 mt-0 overflow-y-auto",children:e.jsx(Qe,{tools:s??[],mcps:o??[],subagents:n??[]})})]})}function ga({agentName:t,showHeader:s,client:o,currentSessionId:n}){const{isExpanded:i,setIsExpanded:a}=We();return e.jsxs("div",{className:"flex lg:hidden items-center flex-1",children:[s&&e.jsx("div",{className:"flex items-center gap-2 flex-1",children:e.jsx(Ye,{agentName:t,client:o,currentSessionId:n})}),!s&&e.jsx("div",{className:"flex-1"}),e.jsx(Os,{}),e.jsx(ye,{"aria-label":"Toggle menu",onClick:()=>a(!i),children:e.jsx(Wt,{className:y("size-4 text-muted-foreground transition-transform duration-200",i?"":"rotate-180")})})]})}function ha({agentName:t,todos:s,sources:o,showHeader:n,sessionId:i,debuggerUrl:a,tools:r,mcps:m,subagents:u,client:c}){const{panelSize:d,setPanelSize:f}=fe(),p=a?i?`${a}/sessions/${i}`:a:null;return e.jsxs(os,{className:y("border-b border-border bg-card relative lg:p-0","[border-bottom-width:0.5px]"),children:[e.jsxs("div",{className:"hidden lg:flex items-center w-full h-16 py-5 pl-6 pr-4",children:[n&&e.jsx("div",{className:"flex items-center gap-2 flex-1",children:e.jsx(Ye,{agentName:t,client:c,currentSessionId:i})}),!n&&e.jsx("div",{className:"flex-1"}),a&&e.jsx(ks,{children:e.jsxs(Is,{children:[e.jsx(Es,{asChild:!0,children:e.jsx(ye,{"aria-label":"View session in debugger",disabled:!p,asChild:!!p,children:p?e.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",children:e.jsx(nt,{className:"size-4 text-muted-foreground"})}):e.jsx(nt,{className:"size-4 text-muted-foreground"})})}),e.jsx(Xe,{children:e.jsx("p",{children:i?"View session in debugger":"Open debugger"})})]})}),e.jsx(Os,{}),e.jsx(ye,{"aria-label":"Toggle sidebar",onClick:()=>{f(d==="hidden"?"small":"hidden")},children:e.jsx(Cn,{className:"size-4 text-muted-foreground"})})]}),e.jsx(ga,{agentName:t,showHeader:n,client:c,currentSessionId:i}),e.jsx(as,{className:y("pt-6 pb-8 px-6","border-b border-border bg-card","shadow-[0_4px_16px_0_rgba(0,0,0,0.04)]","[border-bottom-width:0.5px]"),children:e.jsxs(Je,{defaultValue:"todo",className:"w-full",children:[e.jsx(Ze,{showIcons:!0,visibleTabs:["todo","files","sources","settings"],variant:"default"}),e.jsx(J,{value:"todo",className:"mt-4",children:e.jsx(Me,{todos:s})}),e.jsx(J,{value:"files",className:"mt-4",children:e.jsx(Pe,{})}),e.jsx(J,{value:"sources",className:"mt-4",children:e.jsx(De,{sources:o})}),e.jsx(J,{value:"settings",className:"mt-4",children:e.jsx(Qe,{tools:r??[],mcps:m??[],subagents:u??[]})})]})})]})}function xa({client:t,initialSessionId:s,error:o,debuggerUrl:n}){const{connectionStatus:i,connect:a,sessionId:r,startSession:m}=oo(t,s),{messages:u,sendMessage:c}=Yt(t,m);lo(t);const d=M(_=>_.error),f=M(_=>_.currentModel),[p,h]=l.useState("Agent"),[x,g]=l.useState("This research agent can help you find and summarize information, analyze sources, track tasks, and answer questions about your research. Start by typing a message below to begin your investigation."),[j,v]=l.useState(["Search the web for the latest news on top tech company earnings, produce a summary for each company, and then a macro trend analysis of the tech industry. Use your todo list","What can you help me with?"]),[S,b]=l.useState([]),[w,C]=l.useState([]),[T,I]=l.useState([]),[A,U]=l.useState(typeof window<"u"?window.innerWidth>=1024:!0),[H,G]=l.useState("Type a message or / for commands..."),[k,L]=l.useState(!1);l.useEffect(()=>{re.debug("Connection status changed",{status:i}),i==="error"&&d&&re.error("Connection error occurred",{error:d})},[i,d]),l.useEffect(()=>{if(t){const _=t.getCurrentSession();_?.metadata?.agentName&&h(_.metadata.agentName);const R=t.getAgentInfo();R.displayName?h(R.displayName):R.name&&h(R.name),R.description&&g(R.description),R.suggestedPrompts&&R.suggestedPrompts.length>0&&v(R.suggestedPrompts),R.tools&&R.tools.length>0&&(b(R.tools),re.info("Agent tools loaded",{tools:R.tools})),R.mcps&&R.mcps.length>0&&(C(R.mcps),re.info("Agent MCPs loaded",{mcps:R.mcps})),R.subagents&&R.subagents.length>0&&(I(R.subagents),re.info("Agent subagents loaded",{subagents:R.subagents})),R.uiConfig?.hideTopBar&&L(!0)}},[t,r,i]),l.useEffect(()=>{const _=window.matchMedia("(min-width: 1024px)"),R=W=>{U(W.matches)};return U(_.matches),_.addEventListener("change",R),()=>{_.removeEventListener("change",R)}},[]);const K=_=>{G(_)},q=()=>{G("Type a message or / for commands...")};if(o)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-background",children:e.jsxs("div",{className:"text-center p-8 max-w-md",children:[e.jsx("h1",{className:"text-2xl font-bold text-destructive mb-4",children:"Initialization Error"}),e.jsx("p",{className:"text-foreground mb-4",children:o}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to initialize the ACP client. Check the console for details."})]})});const Q=M(so),E=[{id:"1",title:"Boeing Scores Early Wins at Dubai Airshow",sourceName:"Reuters",url:"https://www.reuters.com/markets/companies/BA.N",snippet:"DUBAI, Nov 17 (Reuters) - Boeing (BA.N), opens new tab took centre stage at day one of the Dubai Airshow on Monday, booking a $38 billion order from host carrier Emirates and clinching more deals with African carriers, while China displayed its C919 in the Middle East for the first time.",favicon:"https://www.google.com/s2/favicons?domain=reuters.com&sz=32"},{id:"2",title:"Boeing's Sustainable Aviation Goals Take Flight",sourceName:"Forbes",url:"https://www.forbes.com",snippet:"SEATTLE, Nov 18 (Reuters) - Boeing is making headway towards its sustainability targets, unveiling plans for a new eco-friendly aircraft design aimed at reducing emissions by 50% by 2030.",favicon:"https://www.google.com/s2/favicons?domain=forbes.com&sz=32"},{id:"3",title:"Boeing Faces Increased Competition in Global Aviation Market",sourceName:"Reuters",url:"https://www.reuters.com",snippet:"CHICAGO, Nov 19 (Reuters) - As the global aviation industry rebounds post-pandemic, Boeing is grappling with intensified competition from rival manufacturers, particularly in the Asian market.",favicon:"https://www.google.com/s2/favicons?domain=reuters.com&sz=32"},{id:"4",title:"Boeing's Starliner Successfully Completes Orbital Test Flight",sourceName:"The Verge",url:"https://www.theverge.com",snippet:"NASA, Nov 20 (Reuters) - Boeing's CST-100 Starliner spacecraft achieves a significant milestone, successfully completing its orbital test flight, paving the way for future crewed missions to the International Space Station.",favicon:"https://www.google.com/s2/favicons?domain=theverge.com&sz=32"}],F=M(_=>_.latestContextSize),$=[{id:"settings",label:"Open Settings",description:"Configure chat preferences",icon:e.jsx(Ht,{className:"h-4 w-4"}),category:"action",onSelect:()=>{re.info("User opened settings")}}];return e.jsxs(xs,{defaultPanelSize:"hidden",defaultActiveTab:"todo",children:[e.jsx(ua,{}),e.jsxs(bs,{children:[!k&&e.jsx(ha,{agentName:p,todos:Q,sources:E,showHeader:u.length>0,sessionId:r,tools:S,mcps:w,subagents:T,client:t,...n&&{debuggerUrl:n}}),i==="error"&&d&&e.jsx("div",{className:"border-b border-destructive/20 bg-destructive/10 px-6 py-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"mb-1 text-paragraph-sm font-semibold text-destructive",children:"Connection Error"}),e.jsx("p",{className:"whitespace-pre-line text-paragraph-sm text-foreground",children:d})]}),e.jsx("button",{type:"button",onClick:a,className:"rounded-lg bg-destructive px-4 py-2 text-paragraph-sm font-medium text-destructive-foreground transition-colors hover:bg-destructive-hover",children:"Retry"})]})}),e.jsxs(ys,{children:[e.jsx(vs,{children:u.length===0?e.jsx(da,{children:({openFiles:_,openSettings:R})=>e.jsx("div",{className:"flex flex-1 items-center px-4",children:e.jsx(ss,{title:p,titleElement:e.jsx(Ye,{agentName:p,client:t,currentSessionId:r}),description:x,suggestedPrompts:j,onPromptClick:W=>{c(W),G("Type a message or / for commands..."),re.info("Prompt clicked",{prompt:W})},onPromptHover:K,onPromptLeave:q,onOpenFiles:_,onOpenSettings:R,toolsAndMcpsCount:S.length+w.length+T.length})})}):e.jsx("div",{className:"flex flex-col px-4",children:u.map((_,R)=>{const W=R===0,je=W?null:u[R-1];let O="mt-2";return W?O=_.role==="assistant"?"mt-8":"mt-2":_.role==="user"?O=(je?.role==="user","mt-4"):_.role==="assistant"&&(O=je?.role==="assistant"?"mt-2":"mt-6"),e.jsx(_s,{message:_,className:O,isLastMessage:R===u.length-1,children:e.jsx(Us,{message:_,thinkingDisplayStyle:"collapsible"})},_.id)})})}),e.jsx(ws,{children:e.jsx(ma,{client:t,startSession:m,placeholder:H,latestContextSize:F,currentModel:f,commandMenuItems:$})})]})]}),A&&e.jsx(js,{breakpoint:"lg",children:e.jsx(fa,{todos:Q,tools:S,mcps:w,subagents:T})})]})}const ks=rn,Is=ln,Es=cn,Xe=l.forwardRef(({className:t,sideOffset:s=4,...o},n)=>e.jsx(Ct,{ref:n,sideOffset:s,className:y("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...o}));Xe.displayName=Ct.displayName;const Rs=l.forwardRef(({contextSize:t,modelContextWindow:s,className:o,...n},i)=>{const a=Math.max(t.totalEstimated,t.llmReportedInputTokens??0),r=a/s*100,m=`${r.toFixed(1)}%`,u=Math.min(100,Math.max(0,r)),d=(S=>S<50?"text-foreground":S<75?"text-yellow-500":"text-red-500")(r),f=S=>a===0?"0.0%":`${(S/a*100).toFixed(1)}%`,p=16,h=2,x=(p-h)/2,g=p/2,j=2*Math.PI*x,v=j-u/100*j;return e.jsx(ks,{children:e.jsxs(Is,{children:[e.jsx(Es,{asChild:!0,children:e.jsx(de,{ref:i,type:"button",variant:"ghost",size:"icon",className:y("rounded-full cursor-default",d,o),...n,children:e.jsxs("svg",{width:p,height:p,viewBox:`0 0 ${p} ${p}`,className:"transform -rotate-90",children:[e.jsx("circle",{cx:g,cy:g,r:x,stroke:"currentColor",strokeWidth:h,fill:"transparent",className:"opacity-20"}),e.jsx("circle",{cx:g,cy:g,r:x,stroke:"currentColor",strokeWidth:h,fill:"transparent",strokeDasharray:j,strokeDashoffset:v,strokeLinecap:"round",className:"transition-all duration-300 ease-in-out"})]})})}),e.jsx(Xe,{side:"top",align:"center",className:"p-3",children:e.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between gap-6",children:[e.jsx("span",{className:"text-muted-foreground",children:"System Prompt:"}),e.jsxs("div",{className:"flex gap-1 items-baseline",children:[e.jsx("span",{children:t.systemPromptTokens.toLocaleString()}),e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["(",f(t.systemPromptTokens),")"]})]})]}),t.toolOverheadTokens!==void 0&&t.toolOverheadTokens>0&&e.jsxs("div",{className:"flex justify-between gap-6",children:[e.jsx("span",{className:"text-muted-foreground",children:"Tools Definition:"}),e.jsxs("div",{className:"flex gap-1 items-baseline",children:[e.jsx("span",{children:t.toolOverheadTokens.toLocaleString()}),e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["(",f(t.toolOverheadTokens),")"]})]})]}),t.mcpOverheadTokens!==void 0&&t.mcpOverheadTokens>0&&e.jsxs("div",{className:"flex justify-between gap-6",children:[e.jsx("span",{className:"text-muted-foreground",children:"MCPs Definition:"}),e.jsxs("div",{className:"flex gap-1 items-baseline",children:[e.jsx("span",{children:t.mcpOverheadTokens.toLocaleString()}),e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["(",f(t.mcpOverheadTokens),")"]})]})]}),e.jsxs("div",{className:"flex justify-between gap-6",children:[e.jsx("span",{className:"text-muted-foreground",children:"User Messages:"}),e.jsxs("div",{className:"flex gap-1 items-baseline",children:[e.jsx("span",{children:t.userMessagesTokens.toLocaleString()}),e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["(",f(t.userMessagesTokens),")"]})]})]}),e.jsxs("div",{className:"flex justify-between gap-6",children:[e.jsx("span",{className:"text-muted-foreground",children:"Assistant Messages:"}),e.jsxs("div",{className:"flex gap-1 items-baseline",children:[e.jsx("span",{children:t.assistantMessagesTokens.toLocaleString()}),e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["(",f(t.assistantMessagesTokens),")"]})]})]}),e.jsxs("div",{className:"flex justify-between gap-6",children:[e.jsx("span",{className:"text-muted-foreground",children:"Tool Inputs:"}),e.jsxs("div",{className:"flex gap-1 items-baseline",children:[e.jsx("span",{children:t.toolInputTokens.toLocaleString()}),e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["(",f(t.toolInputTokens),")"]})]})]}),e.jsxs("div",{className:"flex justify-between gap-6",children:[e.jsx("span",{className:"text-muted-foreground",children:"Tool Results:"}),e.jsxs("div",{className:"flex gap-1 items-baseline",children:[e.jsx("span",{children:t.toolResultsTokens.toLocaleString()}),e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["(",f(t.toolResultsTokens),")"]})]})]})]}),e.jsx("div",{className:"border-t border-border pt-2",children:e.jsxs("div",{className:y("flex justify-end gap-2 font-semibold",d),children:[e.jsx("span",{children:a.toLocaleString()}),e.jsxs("span",{children:["(",m,")"]})]})})]})})]})})});Rs.displayName="ContextUsageButton";const ba=l.forwardRef(({autoScroll:t=!0,isStreaming:s=!1,scrollBehavior:o="smooth",scrollThreshold:n=100,showScrollButton:i=!0,scrollButton:a,className:r,children:m,...u},c)=>{const d=l.useRef(null),[f,p]=l.useState(!0),[h,x]=l.useState(!1),g=l.useRef(0);l.useImperativeHandle(c,()=>{if(!d.current)throw new Error("Container ref not initialized");return d.current});const j=l.useCallback(()=>{const S=d.current;if(!S)return;const{scrollTop:b,scrollHeight:w,clientHeight:C}=S,I=w-b-C<n;p(I),x(!I&&i),g.current=b},[n,i]),v=l.useCallback((S=o)=>{const b=d.current;b&&b.scrollTo({top:b.scrollHeight,behavior:S})},[o]);return l.useEffect(()=>{!t||!d.current||(s&&f?v("auto"):!s&&f&&v())},[t,s,f,v]),l.useEffect(()=>{const S=d.current;if(!S)return;const b=()=>{j()};return S.addEventListener("scroll",b,{passive:!0}),j(),()=>{S.removeEventListener("scroll",b)}},[j]),l.useEffect(()=>{const S=d.current;if(!S)return;const b=new ResizeObserver(()=>{f&&t&&v("auto")});return b.observe(S),()=>{b.disconnect()}},[f,t,v]),e.jsxs("div",{className:"relative flex-1",children:[e.jsx("div",{ref:d,className:y("h-full overflow-y-auto overflow-x-hidden","scrollbar-thin scrollbar-thumb-[border] scrollbar-track-transparent",r),...u,children:e.jsx("div",{className:"flex flex-col gap-4 px-4 py-4",children:m})}),h&&e.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-10",children:a||e.jsxs("button",{type:"button",onClick:()=>v(),className:"px-4 py-2 rounded-full bg-card border border-border shadow-lg hover:shadow-xl hover:bg-card/90 transition-all text-sm font-medium text-foreground flex items-center gap-2","aria-label":"Scroll to bottom",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Down arrow",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})}),"Scroll to bottom"]})})]})});ba.displayName="Conversation";const ya=dn,As=l.forwardRef(({className:t,...s},o)=>e.jsx(Tt,{ref:o,className:y("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));As.displayName=Tt.displayName;const va=l.forwardRef(({className:t,children:s,...o},n)=>e.jsxs(ya,{children:[e.jsx(As,{}),e.jsxs(kt,{ref:n,className:y("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...o,children:[s,e.jsxs(un,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(Bt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));va.displayName=kt.displayName;const wa=l.forwardRef(({className:t,...s},o)=>e.jsx(It,{ref:o,className:y("text-subheading font-semibold leading-none tracking-tight",t),...s}));wa.displayName=It.displayName;const ja=l.forwardRef(({className:t,...s},o)=>e.jsx(Et,{ref:o,className:y("text-paragraph-sm text-muted-foreground",t),...s}));ja.displayName=Et.displayName;const ye=l.forwardRef(({className:t,...s},o)=>e.jsx(de,{ref:o,variant:"ghost",size:"icon",className:y("rounded-full",t),...s}));ye.displayName="IconButton";const Na=ce("flex h-10 w-full rounded-md border bg-input-background px-3 py-2 text-paragraph-sm ring-offset-background file:border-0 file:bg-transparent file:text-paragraph-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",{variants:{variant:{default:"border-input focus-visible:ring-ring",error:"border-destructive focus-visible:ring-destructive",success:"border-green-500 focus-visible:ring-green-500"}},defaultVariants:{variant:"default"}}),Sa=l.forwardRef(({className:t,type:s,variant:o,...n},i)=>e.jsx("input",{type:s,className:y(Na({variant:o,className:t})),ref:i,...n}));Sa.displayName="Input";const Ca=l.forwardRef(({className:t,...s},o)=>e.jsx(Rt,{ref:o,className:y("text-label font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...s}));Ca.displayName=Rt.displayName;const Ta=ce("flex animate-fadeIn",{variants:{role:{user:"max-w-[80%] self-end ml-auto mr-2",assistant:"self-start mr-auto",system:"self-start mr-auto max-w-full"},layout:{default:"",full:"max-w-full",compact:"max-w-[90%]"}},defaultVariants:{role:"assistant",layout:"default"}}),_s=l.forwardRef(({message:t,role:s,layout:o,className:n,children:i,messageId:a,autoScroll:r,isLastMessage:m=!1,...u},c)=>{const d=t?t.role:s||"assistant",f=t?t.id:a,p=l.useRef(null),[h,x]=l.useState(void 0);return l.useImperativeHandle(c,()=>p.current),l.useEffect(()=>{if(!m||d!=="assistant"){x(void 0);return}const g=()=>{const v=p.current;if(!v)return;let S=v.parentElement;for(;S&&!S.classList.contains("overflow-y-auto");)S=S.parentElement;if(!S)return;const b=v.previousElementSibling;if(!b||b.getAttribute("aria-label")!=="user message"){x(void 0);return}const w=S.clientHeight,C=b.offsetHeight,I=Math.max(0,w-C-32);x(I)};g();const j=new ResizeObserver(g);if(p.current){j.observe(p.current);let v=p.current.parentElement;for(;v&&!v.classList.contains("overflow-y-auto");)v=v.parentElement;v&&j.observe(v)}return()=>j.disconnect()},[m,d]),l.useEffect(()=>{if((r!==void 0?r:d==="user")&&p.current){const j=setTimeout(()=>{p.current?.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},50);return()=>clearTimeout(j)}},[d,r]),e.jsx("article",{ref:p,"aria-label":`${d} message`,"data-message-id":f,className:y(Ta({role:d,layout:o}),n),style:{minHeight:h!==void 0?`${h}px`:void 0},...u,children:i})});_s.displayName="Message";function lt({toolCalls:t}){const s=t.map(i=>i.prettyName||i.title),o=[...new Set(s)],n=o.length<=2?o.join(", "):`${o.slice(0,2).join(", ")} +${o.length-2} more`;return e.jsxs("div",{className:"flex flex-col my-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-paragraph-sm text-muted-foreground/50",children:[e.jsx(Vt,{className:"h-3 w-3"}),e.jsx("span",{children:"Invoking parallel operation"}),e.jsx("span",{className:"text-[10px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground/50",children:t.length})]}),e.jsx("span",{className:"text-paragraph-sm text-muted-foreground/50 pl-4.5",children:n})]})}const ct=ce("mb-3 rounded-lg bg-card border border-border transition-all",{variants:{variant:{default:"opacity-70",subtle:"opacity-50",prominent:"opacity-90 shadow-sm"}},defaultVariants:{variant:"default"}}),ka=ce("w-4 h-4 text-foreground opacity-60 transition-transform duration-200",{variants:{expanded:{true:"rotate-180",false:""}},defaultVariants:{expanded:!1}}),Ms=l.forwardRef(({content:t,isStreaming:s=!1,mode:o="collapsible",defaultExpanded:n=!1,autoExpand:i=!1,autoCollapse:a=!0,autoCollapseDelay:r=2e3,label:m="Thinking",variant:u,className:c},d)=>{const[f,p]=l.useState(o==="inline"?!0:n),[h,x]=l.useState(!1);return l.useEffect(()=>{if(a&&!s&&t&&o==="collapsible"){const g=setTimeout(()=>{x(!0),p(!1)},r);return()=>clearTimeout(g)}},[s,t,a,r,o]),l.useEffect(()=>{i&&s&&o==="collapsible"&&!h&&p(!0)},[i,s,o,h]),!t&&!s?null:o==="inline"?e.jsxs("div",{ref:d,className:y(ct({variant:u}),"p-3",c),children:[e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx("span",{className:"text-caption font-medium text-foreground opacity-60 uppercase tracking-wide",children:m}),s&&e.jsx("span",{className:"inline-block w-2 h-2 bg-primary rounded-full animate-pulse"})]}),e.jsxs("div",{className:"text-paragraph-sm italic text-foreground opacity-80 leading-relaxed whitespace-pre-wrap",children:[t,s&&t&&e.jsx("span",{className:"inline-block animate-typing text-primary",children:"..."})]})]}):e.jsxs("div",{ref:d,className:y("mb-3",c),children:[e.jsxs("button",{type:"button",onClick:()=>{p(!f),x(!1)},className:"w-full flex items-center justify-between p-2.5 rounded-lg bg-card border border-border hover:bg-card/80 hover:shadow-sm transition-all text-left","aria-expanded":f,"aria-label":`${f?"Collapse":"Expand"} reasoning`,children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("span",{className:"text-caption font-medium text-foreground opacity-60 uppercase tracking-wide shrink-0",children:m}),s&&e.jsx("span",{className:"inline-block w-2 h-2 bg-primary rounded-full animate-pulse shrink-0"}),!f&&t&&e.jsxs("span",{className:"text-caption text-foreground opacity-50 truncate",children:[t.substring(0,60),t.length>60&&"..."]})]}),e.jsx(ie,{className:ka({expanded:f}),"aria-hidden":"true"})]}),f&&e.jsx("div",{className:y(ct({variant:u}),"mt-2 p-3 animate-fadeIn"),children:e.jsxs("div",{className:"text-paragraph-sm italic text-foreground opacity-80 leading-relaxed whitespace-pre-wrap",children:[t,s&&t&&e.jsx("span",{className:"inline-block animate-typing text-primary",children:"..."})]})})]})});Ms.displayName="Reasoning";const Te=l.forwardRef(({content:t,isStreaming:s=!1,showEmpty:o=!0,emptyMessage:n="",className:i,...a},r)=>{if(!t&&s&&o)return e.jsx("div",{ref:r,className:y("opacity-70 italic text-paragraph-sm",i),...a,children:n});if(!t)return null;const m={table:({node:u,...c})=>e.jsx("div",{className:"overflow-x-auto my-4",children:e.jsx("table",{className:"min-w-full border-collapse border border-border rounded-md",...c})}),thead:({node:u,...c})=>e.jsx("thead",{className:"bg-card border-b border-border",...c}),tbody:({node:u,...c})=>e.jsx("tbody",{...c}),tr:({node:u,...c})=>e.jsx("tr",{className:"border-b border-border hover:bg-card transition-colors",...c}),th:({node:u,...c})=>e.jsx("th",{className:"px-4 py-2 text-left font-semibold text-foreground border-r border-border last:border-r-0",...c}),td:({node:u,...c})=>e.jsx("td",{className:"px-4 py-2 text-foreground border-r border-border last:border-r-0",...c}),input:({node:u,checked:c,...d})=>d.type==="checkbox"?e.jsx("input",{type:"checkbox",checked:c||!1,disabled:!0,readOnly:!0,className:"mr-2 w-4 h-4 accent-[primary] cursor-not-allowed",...d}):e.jsx("input",{...d}),code:({node:u,...c})=>c.className?.includes("language-")?e.jsx("code",{className:"block p-4 bg-card border border-border rounded-md overflow-x-auto text-code text-foreground shadow-sm",...c}):e.jsx("code",{className:"px-1.5 py-0.5 bg-card border border-border rounded text-code text-foreground",...c}),pre:({node:u,...c})=>e.jsx("pre",{className:"my-4 rounded-lg",...c}),h1:({node:u,...c})=>e.jsx("h1",{className:"text-heading-3 mt-6 mb-4 text-foreground border-b border-border pb-2",...c}),h2:({node:u,...c})=>e.jsx("h2",{className:"text-subheading mt-5 mb-3 text-foreground border-b border-border/50 pb-1.5",...c}),h3:({node:u,...c})=>e.jsx("h3",{className:"text-subheading mt-4 mb-2 text-foreground",...c}),h4:({node:u,...c})=>e.jsx("h4",{className:"text-paragraph-sm font-semibold mt-3 mb-2 text-foreground",...c}),ul:({node:u,...c})=>{const d=u?.children?.some(f=>typeof f=="object"&&f!==null&&"type"in f&&f.type==="element"&&"tagName"in f&&f.tagName==="li"&&"children"in f&&Array.isArray(f.children)&&f.children.some(p=>typeof p=="object"&&p!==null&&"type"in p&&p.type==="element"&&"tagName"in p&&p.tagName==="input"&&"properties"in p&&typeof p.properties=="object"&&p.properties!==null&&"type"in p.properties&&p.properties.type==="checkbox"));return e.jsx("ul",{className:y("my-2 space-y-1 text-foreground",d?"list-none space-y-2":"list-disc list-outside pl-4"),...c})},ol:({node:u,...c})=>e.jsx("ol",{className:"list-decimal list-outside pl-4 my-2 space-y-1 text-foreground",...c}),li:({node:u,...c})=>{const d=u?.children?.some(f=>typeof f=="object"&&f!==null&&"type"in f&&f.type==="element"&&"tagName"in f&&f.tagName==="input"&&"properties"in f&&typeof f.properties=="object"&&f.properties!==null&&"type"in f.properties&&f.properties.type==="checkbox");return e.jsx("li",{className:y(d?"flex items-start gap-2":""),...c})},a:({node:u,...c})=>e.jsx("a",{className:"text-primary hover:underline decoration-2 underline-offset-2 transition-all",target:"_blank",rel:"noopener noreferrer",...c}),p:({node:u,...c})=>e.jsx("p",{className:"mb-2 text-foreground leading-relaxed",...c}),blockquote:({node:u,...c})=>e.jsx("blockquote",{className:"border-l-4 border-[primary] pl-4 italic my-4 text-foreground bg-card py-2 rounded-r-md shadow-sm",...c}),hr:({node:u,...c})=>e.jsx("hr",{className:"my-6 border-t border-border opacity-50",...c}),img:({node:u,...c})=>e.jsx("img",{className:"max-w-full h-auto rounded-md border border-border my-4",loading:"lazy",...c})};return e.jsx("div",{ref:r,className:y("markdown-content prose prose-sm max-w-none dark:prose-invert",i),...a,children:e.jsx(qs,{remarkPlugins:[Fn],components:m,children:t})})});Te.displayName="Response";const Ia=50;function Ea({port:t,sessionId:s,host:o,parentStatus:n,agentName:i,query:a,isExpanded:r,onExpandChange:m}){const[u,c]=l.useState(!1),d=r??u,[f,p]=l.useState(!1),[h,x]=l.useState(!0),g=l.useRef(null),{messages:j,isStreaming:v,error:S}=io({port:t,sessionId:s,...o!==void 0?{host:o}:{}}),b=n==="in_progress"||n==="pending"||v,w=j[j.length-1],C=w&&(w.content||w.toolCalls&&w.toolCalls.length>0||w.contentBlocks&&w.contentBlocks.length>0),T=l.useRef(b);l.useEffect(()=>{T.current&&!b&&p(!1),T.current=b},[b]);const I=l.useCallback(()=>{const k=g.current;if(!k)return;const{scrollTop:L,scrollHeight:K,clientHeight:q}=k,Q=K-L-q;x(Q<Ia)},[]),A=l.useCallback(()=>{const k=g.current;k&&(k.scrollTop=k.scrollHeight)},[]);l.useEffect(()=>{h&&(b||C)&&A()},[w?.content,w?.toolCalls,h,b,C,A]),l.useEffect(()=>{const k=g.current;if(!k)return;const L=()=>I();return k.addEventListener("scroll",L,{passive:!0}),I(),()=>k.removeEventListener("scroll",L)},[I,f,d]);const U=w?.content&&w.content.split(`
8
+ `).filter(Boolean).pop()||"",H=U.length>100?`${U.slice(0,100)}...`:U,G=a?(a.split(`
9
+ `)[0]??"").slice(0,100)+(a.length>100?"...":""):"";return e.jsxs("div",{children:[!d&&e.jsx("div",{className:"w-full max-w-md",children:H?e.jsx("p",{className:"text-paragraph-sm text-muted-foreground/70 truncate",children:H}):G?e.jsx("p",{className:"text-paragraph-sm text-muted-foreground/50 truncate",children:G}):null}),d&&e.jsxs("div",{className:"space-y-3",children:[(i||a)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-1.5 font-sans",children:"Input"}),e.jsxs("div",{className:"text-[11px] font-mono space-y-1",children:[i&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"agentName: "}),e.jsx("span",{className:"text-foreground",children:i})]}),a&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"query: "}),e.jsx("span",{className:"text-foreground",children:a})]})]})]}),e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>p(!f),className:"flex items-center gap-2 cursor-pointer bg-transparent border-none p-0 text-left group",children:[e.jsx("div",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider font-sans",children:"Thinking"}),e.jsx(ie,{className:`h-3 w-3 text-muted-foreground/70 transition-transform duration-200 ${f?"rotate-180":""}`})]}),f&&e.jsxs("div",{ref:g,className:"mt-2 rounded-md overflow-hidden bg-muted/30 border border-border/50 max-h-[200px] overflow-y-auto",children:[S&&e.jsxs("div",{className:"px-2 py-2 text-[11px] text-destructive",children:["Error: ",S]}),!S&&!C&&b&&e.jsx("div",{className:"px-2 py-2 text-[11px] text-muted-foreground",children:"Waiting for sub-agent response..."}),w&&e.jsxs("div",{className:"px-2 py-2 space-y-2",children:[w.contentBlocks&&w.contentBlocks.length>0?w.contentBlocks.map((k,L)=>k.type==="text"?e.jsx("div",{className:"text-[11px] text-foreground whitespace-pre-wrap font-mono",children:k.text},`text-${L}`):e.jsx(Ra,{toolCall:k.toolCall},k.toolCall.id)):w.content&&e.jsx("div",{className:"text-[11px] text-foreground whitespace-pre-wrap font-mono",children:w.content}),w.isStreaming&&e.jsx("span",{className:"inline-block w-1.5 h-3 bg-primary/70 ml-0.5 animate-pulse"})]})]})]}),!b&&w?.content&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-1.5 font-sans",children:"Output"}),e.jsx("div",{className:"text-[11px] text-foreground whitespace-pre-wrap font-mono max-h-[200px] overflow-y-auto rounded-md bg-muted/30 border border-border/50 px-2 py-2",children:w.content})]})]})]})}function Ra({toolCall:t}){const s={pending:"...",in_progress:"",completed:"",failed:""}[t.status],o={pending:"text-muted-foreground",in_progress:"text-blue-500",completed:"text-green-500",failed:"text-destructive"}[t.status];return e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground",children:[e.jsx("span",{className:o,children:s}),e.jsx("span",{className:"font-medium",children:t.prettyName||t.title}),t.status==="in_progress"&&e.jsx(qt,{className:"h-2.5 w-2.5 animate-spin"})]})}const Aa={theme:"system",setTheme:()=>null,resolvedTheme:"light"},Ps=l.createContext(Aa);function _a({children:t,defaultTheme:s="system",storageKey:o="vite-ui-theme"}){const[n,i]=l.useState(()=>localStorage.getItem(o)||s),[a,r]=l.useState("light");l.useEffect(()=>{const u=window.document.documentElement;if(u.classList.remove("light","dark"),n==="system"){const c=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";u.classList.add(c),r(c);return}u.classList.add(n),r(n)},[n]);const m={theme:n,setTheme:u=>{localStorage.setItem(o,u),i(u)},resolvedTheme:a};return e.jsx(Ps.Provider,{value:m,children:t})}const Ds=()=>{const t=l.useContext(Ps);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t},dt={Globe:Pn,Image:Mn,Link:_n,Cloud:An,CheckSquare:Ee,Search:Rn,FileText:Oe,Edit:En,Wrench:In,CircleDot:Gt};function ge({toolCall:t}){const[s,o]=l.useState(!1),[n,i]=l.useState(!1),{resolvedTheme:a}=Ds(),r=t.title==="todo_write",m=!!(t.subagentPort&&t.subagentSessionId),u=Le.useContext(Ve),c=Le.useCallback(()=>{r&&u?u.panelSize!=="hidden"&&u.activeTab==="todo"?u.setPanelSize("hidden"):(u.setPanelSize("small"),u.setActiveTab("todo")):m?i(!n):o(!s)},[r,u,s,m,n]),d=t.icon&&dt[t.icon]?dt[t.icon]:Gt,f=t.prettyName||t.title,p=m&&(t.status==="in_progress"||t.status==="pending"),h=m&&t.status==="failed",x=m?h?"text-destructive":p?"text-foreground animate-pulse":"text-green-500":"text-muted-foreground",g=m?h?"Sub-agent failed":p?"Sub-agent running":"Sub-agent completed":void 0,j=t.status==="failed"||!!t.error,v=t.status==="pending"&&(!t.rawInput||Object.keys(t.rawInput).length===0),S={fontSize:"11px",backgroundColor:"transparent",fontFamily:"inherit","--w-rjv-color":a==="dark"?"#fafafa":"#09090b","--w-rjv-key-string":a==="dark"?"#fafafa":"#09090b","--w-rjv-background-color":"transparent","--w-rjv-line-color":a==="dark"?"#27272a":"#e4e4e7","--w-rjv-arrow-color":a==="dark"?"#a1a1aa":"#71717a","--w-rjv-edit-color":a==="dark"?"#fafafa":"#09090b","--w-rjv-info-color":a==="dark"?"#a1a1aa":"#71717a","--w-rjv-update-color":a==="dark"?"#fafafa":"#09090b","--w-rjv-copied-color":a==="dark"?"#fafafa":"#09090b","--w-rjv-copied-success-color":a==="dark"?"#22c55e":"#16a34a","--w-rjv-curlybraces-color":a==="dark"?"#a1a1aa":"#71717a","--w-rjv-colon-color":a==="dark"?"#a1a1aa":"#71717a","--w-rjv-brackets-color":a==="dark"?"#a1a1aa":"#71717a","--w-rjv-quotes-color":a==="dark"?"#a1a1aa":"#71717a","--w-rjv-quotes-string-color":a==="dark"?"#a1a1aa":"#71717a","--w-rjv-type-string-color":a==="dark"?"#22c55e":"#16a34a","--w-rjv-type-int-color":a==="dark"?"#f59e0b":"#d97706","--w-rjv-type-float-color":a==="dark"?"#f59e0b":"#d97706","--w-rjv-type-bigint-color":a==="dark"?"#f59e0b":"#d97706","--w-rjv-type-boolean-color":a==="dark"?"#3b82f6":"#2563eb","--w-rjv-type-date-color":a==="dark"?"#ec4899":"#db2777","--w-rjv-type-url-color":a==="dark"?"#3b82f6":"#2563eb","--w-rjv-type-null-color":a==="dark"?"#ef4444":"#dc2626","--w-rjv-type-nan-color":a==="dark"?"#ef4444":"#dc2626","--w-rjv-type-undefined-color":a==="dark"?"#ef4444":"#dc2626"};return v?e.jsx("div",{className:"flex flex-col my-4",children:e.jsxs("span",{className:"text-paragraph-sm text-muted-foreground/50",children:["Invoking ",f]})}):e.jsxs("div",{className:"flex flex-col my-4",children:[e.jsxs("button",{type:"button",className:"flex flex-col items-start gap-0.5 cursor-pointer bg-transparent border-none p-0 text-left group w-fit",onClick:c,"aria-expanded":r?void 0:s,children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground",children:[e.jsx("div",{className:x,title:g,children:e.jsx(d,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-paragraph-sm text-muted-foreground",children:f}),j&&e.jsx(Dn,{className:"h-3 w-3 text-destructive"}),r?e.jsx(he,{className:"h-3 w-3 text-muted-foreground/70"}):e.jsx(ie,{className:`h-3 w-3 text-muted-foreground/70 transition-transform duration-200 ${s?"rotate-180":""}`})]}),t.subline&&e.jsx("span",{className:"text-paragraph-sm text-muted-foreground/70 pl-4.5",children:t.subline})]}),!r&&m&&e.jsx("div",{className:"pl-4.5",children:e.jsx(Ea,{port:t.subagentPort,sessionId:t.subagentSessionId,parentStatus:t.status,agentName:t.rawInput?.agentName,query:t.rawInput?.query,isExpanded:n,onExpandChange:i})}),!r&&!m&&s&&e.jsxs("div",{className:"mt-2 text-sm border border-border rounded-lg bg-card overflow-hidden w-full",children:[t.rawInput&&Object.keys(t.rawInput).length>0&&!t.subagentPort&&e.jsxs("div",{className:"p-3 border-b border-border",children:[e.jsx("div",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-1.5 font-sans",children:"Input"}),e.jsx("div",{className:"text-[11px] font-mono text-foreground",children:e.jsx(tt,{value:t.rawInput,collapsed:!1,displayDataTypes:!1,displayObjectSize:!1,enableClipboard:!0,style:S})})]}),t.locations&&t.locations.length>0&&e.jsxs("div",{className:"p-3 border-b border-border",children:[e.jsx("div",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-1.5 font-sans",children:"Files"}),e.jsx("ul",{className:"space-y-1",children:t.locations.map(b=>e.jsxs("li",{className:"font-mono text-[11px] text-foreground bg-muted px-1.5 py-0.5 rounded w-fit",children:[b.path,b.line!==null&&b.line!==void 0&&`:${b.line}`]},`${b.path}:${b.line??""}`))})]}),t.content&&t.content.length>0||t.error?e.jsxs("div",{className:"p-3 border-b border-border last:border-0",children:[e.jsx("div",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider mb-1.5 font-sans",children:"Output"}),e.jsxs("div",{className:"space-y-2 text-[11px] text-foreground",children:[t.content?.map((b,w)=>{const C=()=>b.type==="diff"&&"path"in b?`diff-${b.path}-${w}`:b.type==="terminal"&&"terminalId"in b?`terminal-${b.terminalId}`:b.type==="text"&&"text"in b?`text-${b.text.substring(0,20)}-${w}`:b.type==="content"&&"content"in b?`content-${b.content.text?.substring(0,20)}-${w}`:`block-${w}`,T=(I,A)=>{try{const U=JSON.parse(I);if(typeof U=="object"&&U!==null)return e.jsx("div",{className:"text-[11px]",children:e.jsx(tt,{value:U,collapsed:!1,displayDataTypes:!1,displayObjectSize:!1,enableClipboard:!0,style:S})},A)}catch{}return e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[11px] text-foreground overflow-x-auto",children:I},A)};if(b.type==="content"&&"content"in b){const I=b.content;if(I.type==="text"&&I.text)return T(I.text,C())}if(b.type==="text"&&"text"in b)return T(b.text,C());if(b.type==="image"){const I=b.alt||"Generated image";let A;if("data"in b)A=`data:${b.mimeType||"image/png"};base64,${b.data}`;else if("url"in b)A=b.url;else return null;return e.jsx("div",{className:"my-2",children:e.jsx("img",{src:A,alt:I,className:"max-w-full h-auto rounded-md border border-border"})},C())}return b.type==="diff"&&"path"in b&&"oldText"in b&&"newText"in b?e.jsxs("div",{className:"border border-border rounded bg-card",children:[e.jsxs("div",{className:"bg-muted px-2 py-1 text-[10px] font-mono text-muted-foreground border-b border-border",children:[b.path,"line"in b&&b.line!==null&&b.line!==void 0&&`:${b.line}`]}),e.jsxs("div",{className:"p-2 font-mono text-[11px]",children:[e.jsxs("div",{className:"text-red-500 dark:text-red-400",children:["- ",b.oldText]}),e.jsxs("div",{className:"text-green-500 dark:text-green-400",children:["+ ",b.newText]})]})]},C()):b.type==="terminal"&&"terminalId"in b?e.jsxs("div",{className:"bg-neutral-900 text-neutral-100 p-2 rounded text-[11px] font-mono",children:["Terminal: ",b.terminalId]},C()):null}),t.error&&e.jsxs("div",{className:"text-destructive font-mono text-[11px] mt-2",children:["Error: ",t.error]})]})]}):null,t._meta?.truncationWarning&&e.jsxs("div",{className:"mx-3 mt-3 mb-0 flex items-center gap-2 rounded-md bg-yellow-50 dark:bg-yellow-950/20 px-3 py-2 text-[11px] text-yellow-800 dark:text-yellow-200 border border-yellow-200 dark:border-yellow-900",children:[e.jsx("span",{className:"text-yellow-600 dark:text-yellow-500",children:"⚠️"}),e.jsx("span",{children:t._meta.truncationWarning})]}),(t.tokenUsage||t.startedAt)&&e.jsxs("div",{className:"p-2 bg-muted/50 border-t border-border flex flex-wrap gap-4 text-[10px] text-muted-foreground font-sans",children:[t.tokenUsage&&e.jsxs("div",{className:"flex gap-3",children:[t.tokenUsage.inputTokens!==void 0&&e.jsxs("div",{children:[e.jsx("span",{className:"uppercase tracking-wide font-semibold mr-1",children:"Input:"}),t.tokenUsage.inputTokens.toLocaleString()]}),t.tokenUsage.outputTokens!==void 0&&e.jsxs("div",{children:[e.jsx("span",{className:"uppercase tracking-wide font-semibold mr-1",children:"Output:"}),t.tokenUsage.outputTokens.toLocaleString()]}),t.tokenUsage.totalTokens!==void 0&&e.jsxs("div",{children:[e.jsx("span",{className:"uppercase tracking-wide font-semibold mr-1",children:"Total:"}),t.tokenUsage.totalTokens.toLocaleString()]})]}),t.startedAt&&e.jsxs("div",{className:"flex gap-3 ml-auto",children:[e.jsxs("span",{children:["Started: ",new Date(t.startedAt).toLocaleTimeString()]}),t.completedAt&&e.jsxs("span",{children:["Completed:"," ",new Date(t.completedAt).toLocaleTimeString()," (",Math.round((t.completedAt-t.startedAt)/1e3),"s)"]})]})]})]})]})}function ut({toolCalls:t}){const[s,o]=l.useState(!1);(()=>{const m=t.map(u=>u.status);return m.some(u=>u==="failed")?"failed":m.some(u=>u==="in_progress")?"in_progress":m.every(u=>u==="completed")?"completed":"pending"})();const i=t.map(m=>m.prettyName||m.title),a=[...new Set(i)],r=a.length<=2?a.join(", "):`${a.slice(0,2).join(", ")} +${a.length-2} more`;return e.jsxs("div",{className:"flex flex-col my-4",children:[e.jsxs("button",{type:"button",className:"flex flex-col items-start gap-0.5 cursor-pointer bg-transparent border-none p-0 text-left group w-fit",onClick:()=>o(!s),"aria-expanded":s,children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground",children:[e.jsx("div",{className:"text-muted-foreground",children:e.jsx(Vt,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-paragraph-sm text-muted-foreground",children:"Parallel operation"}),e.jsx("span",{className:"text-[10px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground/70",children:t.length}),e.jsx(ie,{className:`h-3 w-3 text-muted-foreground/70 transition-transform duration-200 ${s?"rotate-180":""}`})]}),!s&&e.jsx("span",{className:"text-paragraph-sm text-muted-foreground/70 pl-4.5",children:r})]}),s&&e.jsx("div",{className:"mt-1",children:t.map(m=>e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"w-2.5 h-4 border-l-2 border-b-2 border-border rounded-bl-[6px] mt-1 mr-0.5 shrink-0"}),e.jsx("div",{className:"flex-1 -mt-2",children:e.jsx(ge,{toolCall:m})})]},m.id))})]})}const Ma=ce("w-full rounded-2xl text-[var(--font-size)] font-[var(--font-family)] leading-relaxed break-words transition-colors",{variants:{role:{user:"bg-secondary text-foreground px-4 py-4 text-paragraph",assistant:"text-foreground text-paragraph-sm",system:"bg-card border border-border text-foreground opacity-80 text-caption px-4 py-3"},variant:{default:"",outline:"border border-border",ghost:"bg-transparent"}},defaultVariants:{role:"assistant",variant:"default"}}),Us=l.forwardRef(({role:t,variant:s,isStreaming:o,message:n,thinkingDisplayStyle:i="collapsible",className:a,children:r,...m},u)=>{const c=M(x=>x.streamingStartTime);M(x=>x.currentModel);const d=n&&!r,f=d?n.role:t||"assistant",p=d?n.isStreaming:o;let h=r;if(d){const x=n.metadata?.thinking,g=!!x,j=n.isStreaming&&!n.content&&n.role==="assistant";h=e.jsxs(e.Fragment,{children:[n.role==="assistant"&&g&&e.jsx(Ms,{content:x,isStreaming:n.isStreaming,mode:i,autoCollapse:!0}),j&&c&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("div",{className:"size-2.5 rounded-full bg-foreground animate-pulse-scale"})}),n.role==="assistant"?(()=>{const v=(n.toolCalls||[]).slice().sort((k,L)=>(k.contentPosition??1/0)-(L.contentPosition??1/0)),S=k=>k.status==="pending"&&(!k.rawInput||Object.keys(k.rawInput).length===0),b=k=>{const L=[],K=new Map;let q=[];const Q=()=>{q.length>1?L.push({type:"invoking",toolCalls:q}):q.length===1&&L.push(q[0]),q=[]};for(const E of k)if(E.batchId){Q();const F=K.get(E.batchId);if(F)F.push(E);else{const $=[E];K.set(E.batchId,$),L.push({type:"batch",toolCalls:$})}}else S(E)?q.push(E):(Q(),L.push(E));return Q(),L},w=(k,L)=>typeof k=="object"&&"type"in k&&k.type==="batch"?e.jsx(ut,{toolCalls:k.toolCalls},`batch-${k.toolCalls[0]?.batchId||L}`):typeof k=="object"&&"type"in k&&k.type==="invoking"?e.jsx(lt,{toolCalls:k.toolCalls},`invoking-${k.toolCalls[0]?.id||L}`):e.jsx(ge,{toolCall:k},k.id);if(v.length===0||!v.some(k=>k.contentPosition!==void 0)){const k=b(v);return e.jsxs(e.Fragment,{children:[k.length>0&&e.jsx("div",{className:"flex flex-col gap-2 mb-1",children:k.map((L,K)=>w(L,K))}),e.jsx(Te,{content:n.content,isStreaming:n.isStreaming,showEmpty:!1})]})}const C=[];let T=0,I=[],A;const U=()=>{I.length>1&&A?C.push(e.jsx(ut,{toolCalls:I},`group-${A}`)):I.length===1&&C.push(e.jsx("div",{children:e.jsx(ge,{toolCall:I[0]})},`tool-${I[0].id}`)),I=[],A=void 0},H=v.filter(S),G=v.filter(k=>!S(k));if(G.forEach((k,L)=>{const K=k.contentPosition??n.content.length;if(K>T){U();const q=n.content.slice(T,K);q&&C.push(e.jsx(Te,{content:q,isStreaming:!1,showEmpty:!1},`text-before-${k.id}`))}k.batchId?A===k.batchId?I.push(k):(U(),A=k.batchId,I=[k]):(U(),C.push(e.jsx("div",{children:e.jsx(ge,{toolCall:k})},`tool-${k.id}`))),T=K,L===G.length-1&&U()}),T<n.content.length){const k=n.content.slice(T);k&&C.push(e.jsx(Te,{content:k,isStreaming:n.isStreaming,showEmpty:!1},"text-end"))}return H.length>0&&(H.length>1?C.push(e.jsx(lt,{toolCalls:H},`invoking-group-${H[0].id}`)):C.push(e.jsx("div",{children:e.jsx(ge,{toolCall:H[0]})},`tool-${H[0].id}`))),e.jsx(e.Fragment,{children:C})})():e.jsxs("div",{className:"flex flex-col gap-2",children:[n.images&&n.images.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:n.images.map((v,S)=>e.jsx("img",{src:`data:${v.mimeType};base64,${v.data}`,alt:`Attachment ${S+1}`,className:"max-w-[200px] max-h-[200px] rounded-lg object-cover"},S))}),n.content&&e.jsx("div",{className:"whitespace-pre-wrap",children:n.content})]})]})}return e.jsx("div",{ref:u,className:y(Ma({role:f,variant:s}),p&&"animate-pulse-subtle",a),...m,children:h})});Us.displayName="MessageContent";const Ze=l.forwardRef(({showIcons:t=!0,visibleTabs:s=["todo","files"],variant:o="default",className:n,...i},a)=>{const m=[{id:"todo",label:"To-do",icon:Ee},{id:"files",label:"Files",icon:Oe},{id:"database",label:"Database",icon:Ot},{id:"sources",label:"Sources",icon:$t},{id:"settings",label:"Settings",icon:Ht}].filter(c=>s.includes(c.id)),u=o==="compact"?"gap-[4px]":"gap-3";return e.jsx(xe,{ref:a,className:y("w-full justify-start bg-transparent p-0 h-auto",u,n),...i,children:m.map(c=>{const d=c.icon;return e.jsxs(be,{value:c.id,className:y("gap-2 px-3 py-1.5 rounded-lg text-paragraph-sm font-medium","data-[state=active]:bg-accent data-[state=active]:text-foreground","data-[state=inactive]:text-muted-foreground hover:text-foreground transition-colors"),children:[t&&d&&e.jsx(d,{className:"size-4"}),c.label]},c.id)})})});Ze.displayName="PanelTabsHeader";const Pa=l.forwardRef(({className:t,children:s,...o},n)=>e.jsxs(At,{ref:n,className:y("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-paragraph-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...o,children:[s,e.jsx(pn,{asChild:!0,children:e.jsx(Un,{className:"h-4 w-4 opacity-50"})})]}));Pa.displayName=At.displayName;const Ls=l.forwardRef(({className:t,...s},o)=>e.jsx(_t,{ref:o,className:y("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Wt,{className:"h-4 w-4"})}));Ls.displayName=_t.displayName;const zs=l.forwardRef(({className:t,...s},o)=>e.jsx(Mt,{ref:o,className:y("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(ie,{className:"h-4 w-4"})}));zs.displayName=Mt.displayName;const Da=l.forwardRef(({className:t,children:s,position:o="popper",...n},i)=>e.jsx(mn,{children:e.jsxs(Pt,{ref:i,className:y("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",o==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:o,...n,children:[e.jsx(Ls,{}),e.jsx(fn,{className:y("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(zs,{})]})}));Da.displayName=Pt.displayName;const Ua=l.forwardRef(({className:t,...s},o)=>e.jsx(Dt,{ref:o,className:y("py-1.5 pl-8 pr-2 text-paragraph-sm font-semibold",t),...s}));Ua.displayName=Dt.displayName;const La=l.forwardRef(({className:t,children:s,...o},n)=>e.jsxs(Ut,{ref:n,className:y("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-paragraph-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...o,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(gn,{children:e.jsx(zt,{className:"h-4 w-4"})})}),e.jsx(hn,{children:s})]}));La.displayName=Ut.displayName;const za=l.forwardRef(({className:t,...s},o)=>e.jsx(Lt,{ref:o,className:y("-mx-1 my-1 h-px bg-muted",t),...s}));za.displayName=Lt.displayName;const Fs=l.forwardRef(({task:t,collapsible:s=!0,defaultExpanded:o=!1,onTaskClick:n,className:i,...a},r)=>{const[m,u]=l.useState(o),c=!!(t.details||t.files&&t.files.length>0),d={pending:Fe,in_progress:qt,completed:Ft}[t.status],f=()=>{switch(t.status){case"completed":return"text-green-500";case"in_progress":return"text-primary";default:return"text-foreground opacity-40"}},p=()=>{c&&s&&u(!m),n?.(t)};return e.jsxs("div",{ref:r,className:y("rounded-lg border border-border bg-card transition-all","hover:shadow-sm hover:border-border/80",i),...a,children:[e.jsxs("button",{type:"button",onClick:p,className:y("w-full flex items-center gap-3 px-3 py-2.5 text-left",c&&s&&"cursor-pointer"),disabled:!c&&!s,children:[e.jsx(d,{className:y("w-4 h-4 shrink-0",f(),t.status==="in_progress"&&"animate-spin")}),e.jsx("span",{className:y("flex-1 text-paragraph-sm font-[var(--font-family)]",t.status==="completed"&&"line-through opacity-60",t.status==="in_progress"&&"font-medium"),children:t.text}),c&&s&&e.jsx(ie,{className:y("w-4 h-4 text-foreground opacity-50 transition-transform duration-200 shrink-0",m&&"rotate-180"),"aria-hidden":"true"})]}),c&&m&&e.jsxs("div",{className:"px-3 pb-3 pt-1 border-t border-border/50 animate-fadeIn",children:[t.details&&e.jsx("p",{className:"text-paragraph-sm text-foreground opacity-80 leading-relaxed mb-2",children:t.details}),t.files&&t.files.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-caption font-medium text-foreground opacity-60 uppercase tracking-wide",children:"Files:"}),e.jsx("div",{className:"space-y-1",children:t.files.map(h=>e.jsx("div",{className:"text-caption font-mono text-foreground opacity-70 bg-background px-2 py-1 rounded border border-border/50",children:h},h))})]})]})]})});Fs.displayName="Subagent";const Fa=l.forwardRef(({tasks:t,collapsible:s=!0,onTaskClick:o,emptyMessage:n="No subagents yet.",className:i,...a},r)=>e.jsx("div",{ref:r,className:y("space-y-2 max-h-96 overflow-y-auto",i),...a,children:t.length===0?e.jsx("p",{className:"text-paragraph-sm text-foreground opacity-60 italic py-4 text-center",children:n}):t.map(m=>e.jsx(Fs,{task:m,collapsible:s,...o?{onTaskClick:o}:{}},m.id))}));Fa.displayName="SubagentList";const Oa=ce("flex min-h-[80px] w-full rounded-md border bg-background px-3 py-2 text-paragraph-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-none",{variants:{variant:{default:"border-input focus-visible:ring-ring",error:"border-destructive focus-visible:ring-destructive",success:"border-green-500 focus-visible:ring-green-500"}},defaultVariants:{variant:"default"}}),$a=l.forwardRef(({className:t,autoResize:s=!1,maxHeight:o=200,variant:n,...i},a)=>{const r=l.useRef(null),m=l.useCallback(c=>{r.current=c,typeof a=="function"?a(c):a&&(a.current=c)},[a]),u=l.useCallback(()=>{const c=r.current;if(!c||!s)return;c.style.height="auto";const d=Math.min(c.scrollHeight,o);c.style.height=`${d}px`,c.scrollHeight>o?c.style.overflowY="auto":c.style.overflowY="hidden"},[s,o]);return l.useEffect(()=>{u()},[u]),e.jsx("textarea",{className:y(Oa({variant:n}),s&&"overflow-y-hidden",t),ref:m,...i})});$a.displayName="Textarea";function Os(){const{setTheme:t}=Ds();return e.jsxs(qe,{children:[e.jsx(Ge,{asChild:!0,children:e.jsxs(ye,{children:[e.jsx(Ln,{className:"size-4 text-muted-foreground rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),e.jsx(zn,{className:"absolute size-4 text-muted-foreground rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),e.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),e.jsxs(_e,{align:"end",children:[e.jsx(ne,{onClick:()=>t("light"),children:"Light"}),e.jsx(ne,{onClick:()=>t("dark"),children:"Dark"}),e.jsx(ne,{onClick:()=>t("system"),children:"System"})]})]})}function Ba(){return"http://localhost:3100"}const pt={agentServerUrl:Ba(),debuggerUrl:void 0};function Ha(){const{client:t,error:s,sessionId:o}=Yn({serverUrl:pt.agentServerUrl});return e.jsx(_a,{defaultTheme:"dark",storageKey:"vite-ui-theme",children:e.jsx(xa,{client:t,initialSessionId:o,error:s,...pt.debuggerUrl})})}const $s=document.getElementById("root");if(!$s)throw new Error("Root element not found");Gs.createRoot($s).render(e.jsx(Le.StrictMode,{children:e.jsx(Ha,{})}));