modular-studio 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -41
- package/dist/assets/Badge-DrUmDAXz.js +1 -0
- package/dist/assets/Input-ndEGQSgx.js +1 -0
- package/dist/assets/KnowledgeTab-CxlC76Rf.js +4 -0
- package/dist/assets/MemoryTab-CUScYWs9.js +16 -0
- package/dist/assets/QualificationTab-BqnWSQHm.js +1 -0
- package/dist/assets/ReviewTab-DKYl6cR9.js +103 -0
- package/dist/assets/Section-CgmwAj_2.js +1 -0
- package/dist/assets/TestTab-iJ2vCf9l.js +33 -0
- package/dist/assets/ToolsTab-C10Ulm8b.js +1 -0
- package/dist/assets/conversationStore-CkfEU2eV.js +1 -0
- package/dist/assets/icons-MKpPNvV8.js +1 -0
- package/dist/assets/index-B_ip7Amg.css +1 -0
- package/dist/assets/index-gBy3427k.js +143 -0
- package/dist/assets/{jszip.min-BK6ZQWkj.js → jszip.min-wf-D3Ix_.js} +1 -1
- package/dist/assets/markdown-DWF7F0i0.js +29 -0
- package/dist/assets/services-CTWXQK6j.js +356 -0
- package/dist/assets/stores-CeKWz7ou.js +1 -0
- package/dist/assets/vendor-D1h_O76p.js +9 -0
- package/dist/index.html +20 -16
- package/dist-server/bin/modular-mcp.js +0 -1
- package/dist-server/bin/modular-studio.js +0 -1
- package/dist-server/server/config.js +0 -1
- package/dist-server/server/data/mcp-tokens.json +3 -3
- package/dist-server/server/index.d.ts.map +1 -1
- package/dist-server/server/index.js +6 -1
- package/dist-server/server/mcp/manager.d.ts.map +1 -1
- package/dist-server/server/mcp/manager.js +16 -3
- package/dist-server/server/mcp/modular-server.js +0 -1
- package/dist-server/server/mcp/transport.js +0 -1
- package/dist-server/server/routes/agent-sdk.js +0 -1
- package/dist-server/server/routes/agents.d.ts +9 -5
- package/dist-server/server/routes/agents.d.ts.map +1 -1
- package/dist-server/server/routes/agents.js +108 -8
- package/dist-server/server/routes/auth-codex.js +0 -1
- package/dist-server/server/routes/cache.d.ts +3 -0
- package/dist-server/server/routes/cache.d.ts.map +1 -0
- package/dist-server/server/routes/cache.js +55 -0
- package/dist-server/server/routes/capabilities.js +0 -1
- package/dist-server/server/routes/claude-config.js +0 -1
- package/dist-server/server/routes/connectors.d.ts.map +1 -1
- package/dist-server/server/routes/connectors.js +224 -1
- package/dist-server/server/routes/conversations.js +0 -1
- package/dist-server/server/routes/embeddings.js +0 -1
- package/dist-server/server/routes/health.js +0 -1
- package/dist-server/server/routes/knowledge.js +0 -1
- package/dist-server/server/routes/lessons.d.ts +3 -0
- package/dist-server/server/routes/lessons.d.ts.map +1 -0
- package/dist-server/server/routes/lessons.js +46 -0
- package/dist-server/server/routes/llm.js +0 -1
- package/dist-server/server/routes/mcp-oauth.js +0 -1
- package/dist-server/server/routes/mcp.js +0 -1
- package/dist-server/server/routes/memory.d.ts +3 -0
- package/dist-server/server/routes/memory.d.ts.map +1 -0
- package/dist-server/server/routes/memory.js +314 -0
- package/dist-server/server/routes/pipeline.js +0 -1
- package/dist-server/server/routes/providers.js +0 -1
- package/dist-server/server/routes/qualification.d.ts.map +1 -1
- package/dist-server/server/routes/qualification.js +341 -75
- package/dist-server/server/routes/repo-index.d.ts.map +1 -1
- package/dist-server/server/routes/repo-index.js +7 -1
- package/dist-server/server/routes/runtime.js +0 -1
- package/dist-server/server/routes/skills-search.d.ts.map +1 -1
- package/dist-server/server/routes/skills-search.js +198 -8
- package/dist-server/server/routes/worktrees.js +0 -1
- package/dist-server/server/services/__tests__/embeddingService.test.js +0 -1
- package/dist-server/server/services/adapters/hindsightAdapter.d.ts +28 -0
- package/dist-server/server/services/adapters/hindsightAdapter.d.ts.map +1 -0
- package/dist-server/server/services/adapters/hindsightAdapter.js +63 -0
- package/dist-server/server/services/adapters/postgresAdapter.d.ts +29 -0
- package/dist-server/server/services/adapters/postgresAdapter.d.ts.map +1 -0
- package/dist-server/server/services/adapters/postgresAdapter.js +224 -0
- package/dist-server/server/services/adapters/sqliteAdapter.d.ts +28 -0
- package/dist-server/server/services/adapters/sqliteAdapter.d.ts.map +1 -0
- package/dist-server/server/services/adapters/sqliteAdapter.js +219 -0
- package/dist-server/server/services/adapters/storageAdapter.d.ts +22 -0
- package/dist-server/server/services/adapters/storageAdapter.d.ts.map +1 -0
- package/dist-server/server/services/adapters/storageAdapter.js +1 -0
- package/dist-server/server/services/agentRunner.js +0 -1
- package/dist-server/server/services/agentStore.d.ts +19 -3
- package/dist-server/server/services/agentStore.d.ts.map +1 -1
- package/dist-server/server/services/agentStore.js +117 -23
- package/dist-server/server/services/contentStore.js +0 -1
- package/dist-server/server/services/correctionDetector.d.ts +22 -0
- package/dist-server/server/services/correctionDetector.d.ts.map +1 -0
- package/dist-server/server/services/correctionDetector.js +91 -0
- package/dist-server/server/services/embeddingService.d.ts +2 -0
- package/dist-server/server/services/embeddingService.d.ts.map +1 -1
- package/dist-server/server/services/embeddingService.js +30 -19
- package/dist-server/server/services/factExtractor.js +0 -1
- package/dist-server/server/services/githubIndexer.js +0 -1
- package/dist-server/server/services/hindsightClient.d.ts +15 -0
- package/dist-server/server/services/hindsightClient.d.ts.map +1 -0
- package/dist-server/server/services/hindsightClient.js +47 -0
- package/dist-server/server/services/lessonExtractor.d.ts +19 -0
- package/dist-server/server/services/lessonExtractor.d.ts.map +1 -0
- package/dist-server/server/services/lessonExtractor.js +87 -0
- package/dist-server/server/services/mcpOAuth.js +0 -1
- package/dist-server/server/services/memoryScorer.js +0 -1
- package/dist-server/server/services/repoIndexer.js +0 -1
- package/dist-server/server/services/responseCache.d.ts +24 -0
- package/dist-server/server/services/responseCache.d.ts.map +1 -0
- package/dist-server/server/services/responseCache.js +163 -0
- package/dist-server/server/services/sqliteStore.d.ts +8 -0
- package/dist-server/server/services/sqliteStore.d.ts.map +1 -1
- package/dist-server/server/services/sqliteStore.js +53 -14
- package/dist-server/server/services/teamRunner.js +0 -1
- package/dist-server/server/services/worktreeManager.js +0 -1
- package/dist-server/server/types.d.ts +5 -0
- package/dist-server/server/types.d.ts.map +1 -1
- package/dist-server/server/types.js +0 -1
- package/dist-server/server/utils/pathSecurity.js +0 -1
- package/dist-server/src/services/budgetAllocator.js +0 -1
- package/dist-server/src/services/contradictionDetector.js +0 -1
- package/dist-server/src/services/treeIndexer.js +0 -1
- package/dist-server/src/store/knowledgeBase.d.ts +11 -0
- package/dist-server/src/store/knowledgeBase.d.ts.map +1 -1
- package/dist-server/src/store/knowledgeBase.js +13 -1
- package/dist-server/src/store/lessonStore.d.ts +26 -0
- package/dist-server/src/store/lessonStore.d.ts.map +1 -0
- package/dist-server/src/store/lessonStore.js +64 -0
- package/dist-server/src/store/memoryStore.d.ts +118 -0
- package/dist-server/src/store/memoryStore.d.ts.map +1 -0
- package/dist-server/src/store/memoryStore.js +272 -0
- package/dist-server/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +9 -1
- package/dist/assets/graphPopulator-B3rQxb5A.js +0 -1
- package/dist/assets/index-BA_J-aHx.js +0 -686
- package/dist/assets/index-C7vpqKVZ.css +0 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import{r as x,j as e}from"./vendor-D1h_O76p.js";import{a as A,e as J,j as pe,k as ue,O as Fe,u as j,l as Q,P as L}from"./services-CTWXQK6j.js";import{useConversationStore as Ee}from"./conversationStore-CkfEU2eV.js";import{u as S,M as Te,B as K,a as G,S as Z,g as Ae,d as B,e as ae,h as Pe,i as Me}from"./index-gBy3427k.js";import{I as D}from"./Input-ndEGQSgx.js";import{B as ze}from"./Badge-DrUmDAXz.js";import{X as U,i as re,aK as me,C as De,R as Oe,ab as xe,aL as Re,ai as te,B as Ie,Z as $e,g as Le,ae as q,T as fe,aM as Be,d as ge,aN as We,E as Ge,y as Ue,h as Ye,aO as Je,aP as Ke,aQ as Ve,aR as He,aS as _e,aT as Xe,aU as Qe,aV as Ze,aW as qe,a0 as ie,u as et,S as tt,aa as st,$ as le,a as nt,Q as ot,w as at,U as ee,aX as rt,ah as it}from"./icons-MKpPNvV8.js";import{S as R,T as W}from"./Section-CgmwAj_2.js";import"./stores-CeKWz7ou.js";const lt=x.forwardRef(function({icon:n,size:r="md",variant:o="ghost",tooltip:t,active:i,className:d="",style:l,...u},g){const a=S(),h=r==="sm"?24:32,k={ghost:{bg:i?"#FE500020":"transparent",color:i?"#FE5000":a.textDim,hoverBg:a.isDark?"#ffffff10":"#00000008"},secondary:{bg:a.surfaceElevated,color:a.textSecondary,hoverBg:a.isDark?"#2a2a30":"#eee"},danger:{bg:"transparent",color:a.statusError,hoverBg:a.statusErrorBg}}[o];return e.jsx("button",{ref:g,type:"button",title:t,"aria-label":t,className:`ds-icon-btn flex items-center justify-center rounded-md cursor-pointer border-none nodrag ${d}`,style:{width:h,height:h,background:k.bg,color:k.color,transition:"background 0.15s",...l},onMouseEnter:F=>F.currentTarget.style.background=k.hoverBg,onMouseLeave:F=>F.currentTarget.style.background=k.bg,...u,children:n})});function ct({children:s,variant:n="default",onRemove:r,className:o=""}){const t=S(),d={default:{bg:`${t.textSecondary}15`,color:t.textSecondary},success:{bg:`${t.statusSuccess}15`,color:t.statusSuccess},error:{bg:`${t.statusError}15`,color:t.statusError},warning:{bg:`${t.statusWarning}15`,color:t.statusWarning},info:{bg:`${t.statusInfo}15`,color:t.statusInfo}}[n];return e.jsxs("div",{className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-[14px] nodrag ${o}`,style:{background:d.bg,color:d.color,fontFamily:"'Geist Mono', monospace",fontSize:12,fontWeight:500},children:[e.jsx("span",{children:s}),r&&e.jsx("button",{type:"button",onClick:r,className:"p-0 border-none bg-transparent cursor-pointer hover:opacity-70 nodrag",style:{color:d.color},"aria-label":"Remove",children:e.jsx(U,{size:10})})]})}function dt({type:s}){const n={major:"#FE5000",minor:"#3498db",patch:"#888"};return e.jsx(Re,{size:6,fill:n[s],stroke:"none"})}function pt({v:s,isCurrent:n,onRestore:r,onDelete:o}){const t=S(),[i,d]=x.useState(!1);return e.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:`1px solid ${n?"#FE500040":t.borderSubtle}`,background:n?"#FE500008":"transparent"},children:[e.jsxs("button",{type:"button",onClick:()=>d(!i),className:"w-full min-h-[36px] flex items-center gap-2 px-3 py-2 cursor-pointer border-none bg-transparent text-left",children:[e.jsx(De,{size:10,style:{color:t.textDim,transform:i?"rotate(90deg)":"none",transition:"transform 0.15s"}}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[e.jsxs("span",{className:"text-[14px] font-bold shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:n?"#FE5000":t.textPrimary},children:["v",s.version]}),e.jsx("span",{className:"text-[12px] truncate",style:{color:t.textMuted},children:s.label||"Checkpoint"})]}),n&&e.jsx(ze,{variant:"success",size:"sm",dot:!0,children:"CURRENT"}),e.jsx("span",{className:"text-[13px] shrink-0",style:{color:t.textFaint},children:new Date(s.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),i&&e.jsxs("div",{className:"px-3 pb-2 flex flex-col gap-1.5",children:[s.changes.length===0&&e.jsx("div",{className:"text-[12px]",style:{color:t.textMuted},children:"No changelog entries recorded for this version."}),s.changes.map((l,u)=>e.jsxs("div",{className:"flex items-center gap-2 text-[12px]",style:{color:t.textSecondary},children:[e.jsx(dt,{type:l.type}),e.jsx("span",{className:"uppercase text-[12px] font-semibold w-14 shrink-0",style:{color:t.textDim},children:l.category}),e.jsx("span",{children:l.description})]},u)),e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[!n&&e.jsx(K,{variant:"secondary",size:"sm",icon:e.jsx(Oe,{size:10}),onClick:r,children:"Restore"}),e.jsx(lt,{icon:e.jsx(xe,{size:11}),variant:"danger",size:"sm",tooltip:"Delete version",onClick:o})]})]})]})}function ut(){const s=S(),n=A(l=>l.versions),r=A(l=>l.currentVersion),o=A(l=>l.dirty),t=A(l=>l.checkpoint),[i,d]=x.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>d(!0),className:"flex items-center gap-1.5 px-2 h-8 rounded-lg cursor-pointer border-none",style:{background:o?"#FE500015":"transparent",color:o?"#FE5000":s.textDim,fontFamily:"'Geist Mono', monospace",fontSize:12,fontWeight:600,transition:"background 0.15s"},title:"Version history",children:[e.jsx(re,{size:12}),"v",r,o&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#FE5000] animate-pulse"})]}),e.jsx(Te,{open:i,onClose:()=>d(!1),title:"Version History",width:480,footer:e.jsx(K,{variant:"primary",size:"sm",icon:e.jsx(me,{size:10}),onClick:()=>{t()},children:"Save Checkpoint"}),children:e.jsxs("div",{className:"flex flex-col gap-1.5 p-3 max-h-[60vh] overflow-y-auto overscroll-contain pr-1",children:[n.length===0&&e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(re,{size:20,style:{margin:"0 auto 8px",color:s.textFaint,opacity:.3}}),e.jsx("div",{className:"text-[12px]",style:{color:s.textFaint},children:"No versions yet"}),e.jsx("div",{className:"text-[12px] mt-1",style:{color:s.textMuted},children:"Make changes to your agent — versions are created automatically"})]}),[...n].reverse().map(l=>e.jsx(pt,{v:l,isCurrent:l.version===r,onRestore:()=>{A.getState().restoreVersion(l.version),d(!1)},onDelete:()=>A.getState().deleteVersion(l.id)},l.id))]})})]})}const he=[{id:"bot",icon:te},{id:"brain",icon:Ie},{id:"zap",icon:$e},{id:"flame",icon:Le},{id:"lightbulb",icon:q},{id:"target",icon:fe},{id:"rocket",icon:Be},{id:"shield",icon:ge},{id:"microscope",icon:We},{id:"chart",icon:Ge},{id:"palette",icon:Ue},{id:"file",icon:Ye},{id:"drama",icon:Je},{id:"star",icon:Ke},{id:"gem",icon:Ve},{id:"bird",icon:He},{id:"bug",icon:_e},{id:"cat",icon:Xe},{id:"dog",icon:Qe},{id:"heart",icon:Ze}];function ce({avatarId:s,size:n=20,color:r}){const o=S(),t=he.find(d=>d.id===s)?.icon??te,i=r||o.textPrimary;return e.jsx(t,{size:n,color:i})}function mt({agentMeta:s,setAgentMeta:n,collapsed:r,onToggle:o}){const t=S(),[i,d]=x.useState(!1),[l,u]=x.useState(""),g={display:"flex",alignItems:"center",justifyContent:"center",width:"80px",height:"80px",borderRadius:"8px",border:"2px dashed var(--border)",background:"var(--surface-elevated)",cursor:"pointer"},a={position:"absolute",top:"96px",left:0,background:t.surfaceElevated,border:`1px solid ${t.border}`,borderRadius:"8px",padding:"12px",display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"8px",zIndex:1e3,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"},h={display:"inline-flex",alignItems:"center",padding:"4px 8px",background:t.badgeBg,color:t.textSecondary,borderRadius:"12px",fontSize:"12px",fontFamily:"'Geist Sans', sans-serif"},c=m=>{m&&!s.tags.includes(m)&&n({tags:[...s.tags,m]})},k=m=>{n({tags:s.tags.filter(f=>f!==m)})},F=m=>{m.key==="Enter"&&l.trim()&&(c(l.trim()),u(""))};return e.jsxs(R,{icon:qe,label:"Identity",color:"#3498db",collapsed:r,onToggle:o,children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-4",children:[e.jsx(D,{label:"Agent Name",value:s.name,onChange:m=>n({name:m.target.value}),placeholder:"Enter agent name..."}),e.jsx(G,{label:"Description",value:s.description,onChange:m=>n({description:m.target.value}),placeholder:"Describe what this agent does...",rows:3}),e.jsx(D,{label:"Category",value:s.category,onChange:m=>n({category:m.target.value}),placeholder:"e.g., productivity, development, research..."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"block text-sm font-medium",style:{color:t.textPrimary},children:"Avatar"}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",onClick:()=>d(!i),"aria-label":`Select agent avatar (currently ${s.avatar||"default"})`,title:"Choose avatar","aria-expanded":i,"aria-haspopup":"menu",style:g,children:e.jsx(ce,{avatarId:s.avatar,size:48})}),i&&e.jsx("div",{style:a,children:he.map(m=>e.jsx("button",{type:"button",onClick:()=>{n({avatar:m.id}),d(!1)},"aria-label":`Select avatar ${m.id} as agent avatar`,title:`Select ${m.id} avatar`,className:"flex items-center justify-center w-12 h-12 rounded-lg cursor-pointer border-none",style:{background:s.avatar===m.id?"#FE500020":"transparent",border:`1px solid ${s.avatar===m.id?"#FE5000":"transparent"}`},children:e.jsx(ce,{avatarId:m.id,size:24})},m.id))})]})]})]}),e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsx("label",{className:"block text-sm font-medium",style:{color:t.textPrimary},children:"Tags"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.tags.map(m=>e.jsxs("span",{style:h,children:[m,e.jsx("button",{type:"button",onClick:()=>k(m),title:`Remove ${m} tag`,className:"border-none bg-transparent cursor-pointer p-0 ml-1",style:{color:"#FE5000"},children:"×"})]},m)),e.jsx(D,{value:l,onChange:m=>u(m.target.value),onKeyDown:F,placeholder:"Add tag...",className:"w-24",style:{minWidth:"100px"}})]})]})]})}const xt="#27ae60",ft="#FE5000";function V({onRefine:s}){const n=S(),[r,o]=x.useState(!1),[t,i]=x.useState(null),[d,l]=x.useState(!1),u=async()=>{i(null),l(!1),o(!0);try{await s(),l(!0),setTimeout(()=>l(!1),2e3)}catch(c){const k=c instanceof Error?c.message:"Refinement failed";i(k),setTimeout(()=>i(null),4e3)}finally{o(!1)}},g=t?n.statusError:d?xt:ft,a={background:"transparent",border:`1px solid ${g}`,color:g,borderRadius:6,padding:"2px 8px",fontSize:11,fontFamily:"'Geist Mono', monospace",fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",cursor:r?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:4,transition:"all 0.15s"},h=d?"Done":r?"Refining…":"Refine";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:u,disabled:r,title:"Refine with AI",style:a,children:[r?e.jsx("span",{className:"animate-spin",children:"⟳"}):e.jsx("span",{children:"✨"}),h]}),t&&e.jsx("span",{style:{color:n.statusError,fontSize:11,fontFamily:"'Geist Mono', monospace"},children:t})]})}const gt=`You are an expert prompt engineer. Your job is to take a user's rough brain dump about an AI agent they want to build, and transform it into structured, high-quality agent instructions following Anthropic's prompting best practices.
|
|
2
|
+
|
|
3
|
+
Given the user's rough input, produce a JSON response with this exact structure:
|
|
4
|
+
{
|
|
5
|
+
"persona": "<2-4 sentence persona description. Be specific about expertise, domain, and communication style. Use 'You are...' framing>",
|
|
6
|
+
"tone": "<one of: formal, neutral, casual>",
|
|
7
|
+
"expertise": <1-5 number, where 1=beginner-friendly and 5=expert-level>,
|
|
8
|
+
"constraints": [
|
|
9
|
+
"<clear, actionable constraint in imperative voice>"
|
|
10
|
+
],
|
|
11
|
+
"scopeDefinition": "<one sentence: what the agent handles and what it does NOT handle>",
|
|
12
|
+
"objectives": {
|
|
13
|
+
"primary": "<one clear sentence describing the agent's primary goal>",
|
|
14
|
+
"successCriteria": ["<measurable criterion>"],
|
|
15
|
+
"failureModes": ["<specific failure to avoid>"]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
Follow these rules:
|
|
20
|
+
1. Be specific — replace vague descriptions with concrete, actionable language
|
|
21
|
+
2. Use XML-tag-friendly language (the output will be assembled into a system prompt)
|
|
22
|
+
3. Infer reasonable constraints from the domain (e.g., a medical agent should cite sources)
|
|
23
|
+
4. Generate 2-4 success criteria and 2-3 failure modes based on the domain
|
|
24
|
+
5. Keep the persona concise but distinctive — give it a clear identity
|
|
25
|
+
6. If the input mentions tools, APIs, or specific capabilities, reference them in constraints
|
|
26
|
+
7. Think step by step about what makes an excellent agent for this use case before writing
|
|
27
|
+
|
|
28
|
+
Output ONLY the JSON object. No markdown fences, no explanation.`,ht={persona:'You are an expert prompt engineer. Transform this rough persona description into a clear, specific 2-4 sentence persona. Use "You are..." framing. Be concrete about expertise, domain knowledge, and communication style. Output ONLY the refined persona text.',constraints:"You are an expert prompt engineer. Transform these rough constraint notes into clear, actionable rules — one per line, imperative voice. Remove redundancy, sharpen vague rules, infer reasonable additions from the domain. Output ONLY the constraints, one per line.",scope:"You are an expert prompt engineer. Transform this rough scope description into a clear one-sentence definition of what the agent handles and what it does NOT handle. Output ONLY the scope sentence."};async function H(s,n){if(!n.trim())throw new Error("Nothing to refine");const r=J.getState(),o=r.providers.find(a=>a.id===r.selectedProviderId);if(!o)throw new Error("No provider configured — add one in Settings");const t=typeof o.models?.[0]=="object"?o.models[0].id:o.models?.[0]||"claude-sonnet-4-20250514",i=s==="full"?gt:ht[s];if(!i)throw new Error(`Unknown field: ${s}`);const l=o.authMethod==="claude-agent-sdk"?await pe({prompt:n,model:t,systemPrompt:i,maxTurns:1}):await ue({providerId:o.id,model:t,messages:[{role:"system",content:i},{role:"user",content:n}],temperature:.3,maxTokens:1024});if(s!=="full")return l;try{return JSON.parse(l)}catch{}const u=l.match(/```(?:json)?\s*([\s\S]*?)```/);if(u)try{return JSON.parse(u[1].trim())}catch{}const g=l.match(/\{[\s\S]*\}/);if(g)try{return JSON.parse(g[0])}catch{}throw new Error("Could not parse agent structure from LLM response")}function yt({persona:s,tone:n,expertise:r,updateInstruction:o,collapsed:t,onToggle:i}){const d=S(),l=async()=>{const u=await H("persona",s);typeof u=="string"&&o({persona:u})};return e.jsx(R,{icon:te,label:"Persona",color:"#9b59b6",collapsed:t,onToggle:i,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(G,{label:"Persona Description",labelAction:e.jsx(V,{onRefine:l}),value:s,onChange:u=>o({persona:u.target.value}),placeholder:"Describe the agent's personality, communication style, and approach...",rows:4}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Z,{label:"Tone",options:[{value:"formal",label:"Formal"},{value:"neutral",label:"Neutral"},{value:"casual",label:"Casual"}],value:n,onChange:u=>o({tone:u})}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2",style:{color:d.textPrimary},children:["Expertise Level: ",r,"/5"]}),e.jsx("input",{type:"range",min:"1",max:"5",step:"1",value:r,onChange:u=>o({expertise:Number(u.target.value)}),className:"w-full",style:{accentColor:"#FE5000"}}),e.jsxs("div",{className:"flex justify-between text-xs mt-1",style:{color:d.textDim},children:[e.jsx("span",{children:"Beginner"}),e.jsx("span",{children:"Expert"})]})]})]})]})})}function bt({constraints:s,onAdd:n,onRemove:r}){const[o,t]=x.useState(""),i=d=>{d.key==="Enter"&&o.trim()&&(n(o.trim()),t(""))};return e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:s.map(d=>e.jsx(ct,{onRemove:()=>r(d),children:d},d))}),e.jsx(D,{value:o,onChange:d=>t(d.target.value),onKeyDown:i,placeholder:"Type constraint and press Enter..."})]})}function vt({constraints:s,updateInstruction:n,customConstraints:r,addCustomConstraint:o,removeCustomConstraint:t,collapsed:i,onToggle:d}){const l=S(),u=async()=>{const a=await H("constraints",s.customConstraints);typeof a=="string"&&n({constraints:{...s,customConstraints:a}})},g=async()=>{const a=await H("scope",s.scopeDefinition);typeof a=="string"&&n({constraints:{...s,scopeDefinition:a}})};return e.jsx(R,{icon:ge,label:"Constraints & Safety",color:"#e74c3c",collapsed:i,onToggle:d,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(W,{checked:s.neverMakeUp,onChange:a=>n({constraints:{...s,neverMakeUp:a}}),label:"Never fabricate information"}),e.jsx(W,{checked:s.askBeforeActions,onChange:a=>n({constraints:{...s,askBeforeActions:a}}),label:"Ask before taking actions"}),e.jsx(W,{checked:s.stayInScope,onChange:a=>n({constraints:{...s,stayInScope:a}}),label:"Stay within defined scope"}),e.jsx(W,{checked:s.useOnlyTools,onChange:a=>n({constraints:{...s,useOnlyTools:a}}),label:"Use only provided tools"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(W,{checked:s.limitWords,onChange:a=>n({constraints:{...s,limitWords:a}}),label:"Limit response length"}),s.limitWords&&e.jsx(D,{type:"number",value:s.wordLimit.toString(),onChange:a=>n({constraints:{...s,wordLimit:Number(a.target.value)||0}}),placeholder:"Word limit",className:"w-24"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",style:{color:l.textPrimary},children:"Custom Constraints"}),e.jsx(bt,{constraints:r,onAdd:o,onRemove:t})]}),e.jsx(G,{label:"Scope Definition",labelAction:e.jsx(V,{onRefine:g}),value:s.scopeDefinition,onChange:a=>n({constraints:{...s,scopeDefinition:a.target.value}}),placeholder:"Define the specific scope and boundaries for this agent...",rows:2}),e.jsx(G,{label:"Additional Notes",labelAction:e.jsx(V,{onRefine:u}),value:s.customConstraints,onChange:a=>n({constraints:{...s,customConstraints:a.target.value}}),placeholder:"Add any additional constraints or rules (one per line)...",rows:3})]})})}function jt({objectives:s,updateInstruction:n,collapsed:r,onToggle:o}){const t=S(),[i,d]=x.useState(""),[l,u]=x.useState(""),g=()=>{if(i.trim()){const f=[...s.successCriteria,i.trim()];n({objectives:{...s,successCriteria:f}}),d("")}},a=f=>{const C=s.successCriteria.filter((I,P)=>P!==f);n({objectives:{...s,successCriteria:C}})},h=()=>{if(l.trim()){const f=[...s.failureModes,l.trim()];n({objectives:{...s,failureModes:f}}),u("")}},c=f=>{const C=s.failureModes.filter((I,P)=>P!==f);n({objectives:{...s,failureModes:C}})},k=f=>{f.key==="Enter"&&(f.preventDefault(),g())},F=f=>{f.key==="Enter"&&(f.preventDefault(),h())},m=async()=>{const f=await H("scope",s.primary);typeof f=="string"&&n({objectives:{...s,primary:f}})};return e.jsx(R,{icon:fe,label:"Objectives & Success Criteria",color:"#27ae60",collapsed:r,onToggle:o,children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(G,{label:"Primary Objective",labelAction:e.jsx(V,{onRefine:m}),value:s.primary,onChange:f=>n({objectives:{...s,primary:f.target.value}}),placeholder:"What is the main goal this agent should achieve?",rows:2}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",style:{color:t.textPrimary},children:"Success Criteria"}),e.jsxs("div",{className:"space-y-2",children:[s.successCriteria.map((f,C)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 px-3 py-2 rounded-md text-sm",style:{background:t.surfaceElevated,border:`1px solid ${t.border}`,color:t.textPrimary},children:f}),e.jsx("button",{type:"button",onClick:()=>a(C),className:"flex items-center justify-center w-8 h-8 rounded-md border-none cursor-pointer",style:{background:"transparent",color:t.textMuted},"aria-label":"Remove success criterion",title:"Remove criterion",children:e.jsx(U,{size:14})})]},C)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{value:i,onChange:f=>d(f.target.value),onKeyDown:k,placeholder:"Add a success criterion...",className:"flex-1"}),e.jsxs(K,{onClick:g,variant:"secondary",size:"sm",disabled:!i.trim(),title:"Add success criterion",className:"flex items-center gap-1",children:[e.jsx(ie,{size:14}),"Add"]})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",style:{color:t.textPrimary},children:"Failure Modes"}),e.jsxs("div",{className:"space-y-2",children:[s.failureModes.map((f,C)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 px-3 py-2 rounded-md text-sm",style:{background:t.surfaceElevated,border:`1px solid ${t.border}`,color:t.textPrimary},children:f}),e.jsx("button",{type:"button",onClick:()=>c(C),className:"flex items-center justify-center w-8 h-8 rounded-md border-none cursor-pointer",style:{background:"transparent",color:t.textMuted},"aria-label":"Remove failure mode",title:"Remove failure mode",children:e.jsx(U,{size:14})})]},C)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{value:l,onChange:f=>u(f.target.value),onKeyDown:F,placeholder:"Add a potential failure mode...",className:"flex-1"}),e.jsxs(K,{onClick:h,variant:"secondary",size:"sm",disabled:!l.trim(),title:"Add failure mode",className:"flex items-center gap-1",children:[e.jsx(ie,{size:14}),"Add"]})]})]})]})]})})}function kt({workflowSteps:s,collapsed:n,onToggle:r}){const o=S();return e.jsx(R,{icon:et,label:"Workflow Steps",color:"#e67e22",collapsed:n,onToggle:r,children:s.length===0?e.jsx("div",{className:"text-center py-8 text-sm",style:{color:o.textDim},children:"No workflow steps defined. The agent will operate without a structured workflow."}):e.jsx("div",{className:"space-y-2",children:s.map((t,i)=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded",style:{background:o.surfaceElevated},children:[e.jsx("span",{className:"flex items-center justify-center w-6 h-6 rounded-full text-xs font-bold",style:{background:"#e67e22",color:"white"},children:i+1}),e.jsx("span",{className:"flex-1 text-sm",style:{color:o.textPrimary},children:t.label}),e.jsx("span",{className:"text-xs px-2 py-1 rounded",style:{background:o.badgeBg,color:o.textDim},children:t.action})]},i))})})}function wt({outputFormat:s,setOutputFormat:n,selectedModel:r,tokenBudget:o,collapsed:t,onToggle:i}){const d=S(),l=J(a=>a.getAllModels),u=J(a=>a.providers),g=x.useMemo(()=>l().map(a=>({value:`${a.providerId}::${a.id}`,label:`${a.providerName} / ${a.label}`})),[l,u]);return e.jsx(R,{icon:tt,label:"Output Configuration",color:"#f1c40f",collapsed:t,onToggle:i,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Z,{label:"Output Format",options:Fe.map(a=>({value:a.id,label:a.label})),value:s,onChange:a=>n(a)}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx("div",{children:e.jsx(Z,{label:"Model",options:g,value:r,onChange:a=>j.getState().setModel(a)})}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-sm font-medium mb-2",style:{color:d.textPrimary},children:"Token Budget"}),e.jsx("div",{className:"p-2 rounded",style:{background:d.surfaceElevated,color:d.textSecondary},children:o?.toLocaleString()||"Default"})]})]})]})})}function St({onExport:s,onExportFormat:n,onPromptPreview:r,saveStatus:o}){const t=S(),[i,d]=x.useState(!1),l={display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",background:"#FE5000",color:"white",border:"none",borderRadius:"6px",fontSize:"14px",fontWeight:"500",fontFamily:"'Geist Sans', sans-serif",cursor:"pointer",transition:"all 0.15s ease"},u={display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",background:"transparent",color:t.textSecondary,border:`1px solid ${t.border}`,borderRadius:"6px",fontSize:"14px",fontWeight:"500",fontFamily:"'Geist Sans', sans-serif",cursor:"pointer",transition:"all 0.15s ease"},g={position:"absolute",top:"100%",left:0,right:0,background:t.surfaceElevated,border:`1px solid ${t.border}`,borderRadius:"6px",marginTop:"4px",zIndex:1e3,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)"},a=x.useCallback(h=>{n(h),d(!1)},[n]);return e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-2 px-4 py-2 text-sm rounded border",style:{background:"transparent",color:t.textSecondary,borderColor:t.border,fontFamily:"'Geist Sans', sans-serif"},children:[e.jsx(st,{size:14}),"Prompt Preview"]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>d(!i),"aria-expanded":i,"aria-haspopup":"menu","aria-label":"Export agent configuration in different formats",style:l,children:[e.jsx(le,{size:14}),"Export",e.jsx(nt,{size:12})]}),i&&e.jsx("div",{role:"menu",style:g,children:["JSON","YAML","Markdown","Claude format","OpenAI format"].map(h=>e.jsx("button",{type:"button",role:"menuitem",onClick:()=>a(h),"aria-label":`Export agent configuration as ${h}`,className:"w-full px-4 py-2 text-left text-sm hover:bg-gray-100",style:{background:"transparent",border:"none",color:t.textPrimary,cursor:"pointer"},children:h},h))})]}),e.jsxs("button",{type:"button",onClick:s,style:l,children:[e.jsx(le,{size:16}),"Export Agent"]}),e.jsxs("button",{type:"button",disabled:o==="saving",onClick:()=>{const h=A.getState();if(!h.agentId){const c=`agent-${Date.now()}`;h.setAgentId(c)}h.saveToServer("Manual save")},style:{...u,opacity:o==="saving"?.6:1,cursor:o==="saving"?"not-allowed":"pointer"},children:[e.jsx(me,{size:16}),o==="saving"?"Saving...":"Save Draft"]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{background:o==="saved"?"#22c55e":o==="saving"?"#f59e0b":o==="error"?"#ef4444":"#6b7280"}}),e.jsx("span",{style:{color:t.textSecondary,fontSize:"13px"},children:o==="saved"?"Saved":o==="saving"?"Saving...":o==="error"?"Save failed":"Unsaved changes"})]})]})}function Ct(s){const n=j.getState(),r=[n.agentMeta.name&&`Agent: ${n.agentMeta.name}`,n.agentMeta.description&&`Description: ${n.agentMeta.description}`,n.instructionState.persona&&`Persona: ${n.instructionState.persona.slice(0,200)}`,n.instructionState.objectives.primary&&`Objective: ${n.instructionState.objectives.primary}`,n.instructionState.constraints.customConstraints&&`Constraints: ${n.instructionState.constraints.customConstraints.slice(0,200)}`,n.workflowSteps.length>0&&`Workflow: ${n.workflowSteps.map(t=>t.label).join(" → ")}`,n.channels.filter(t=>t.enabled).length>0&&`Knowledge: ${n.channels.filter(t=>t.enabled).map(t=>t.name).join(", ")}`,n.mcpServers.filter(t=>t.enabled!==!1).length>0&&`MCP: ${n.mcpServers.filter(t=>t.enabled!==!1).map(t=>t.name).join(", ")}`,n.skills.filter(t=>t.enabled!==!1).length>0&&`Skills: ${n.skills.filter(t=>t.enabled!==!1).map(t=>t.name).join(", ")}`].filter(Boolean).join(`
|
|
29
|
+
`),o=s.map((t,i)=>`${i+1}. [${t.id}] "${t.content}" (type: ${t.type}, tags: ${t.tags.join(",")})`).join(`
|
|
30
|
+
`);return`You are an expert agent architect analyzing runtime memory facts to improve an agent's design.
|
|
31
|
+
|
|
32
|
+
<agent_context>
|
|
33
|
+
${r}
|
|
34
|
+
</agent_context>
|
|
35
|
+
|
|
36
|
+
<facts>
|
|
37
|
+
${o}
|
|
38
|
+
</facts>
|
|
39
|
+
|
|
40
|
+
Analyze each fact and determine if it should be PROMOTED from runtime memory into a structured agent component. Facts that encode persistent patterns, preferences, or capabilities should graduate into the agent's design.
|
|
41
|
+
|
|
42
|
+
Promotion targets:
|
|
43
|
+
- "instruction": Fact describes HOW the agent should behave → append to persona or instructions
|
|
44
|
+
- "constraint": Fact is a rule or limitation → add as a constraint
|
|
45
|
+
- "workflow": Fact describes a recurring process → add as a workflow step
|
|
46
|
+
- "knowledge": Fact points to a data source the agent needs → add as knowledge source
|
|
47
|
+
- "mcp": Fact mentions a tool/API the agent should use → suggest MCP server
|
|
48
|
+
- "skill": Fact describes a capability the agent needs → suggest a skill
|
|
49
|
+
- "keep": Fact is volatile/contextual → keep in runtime memory
|
|
50
|
+
|
|
51
|
+
Output ONLY valid JSON:
|
|
52
|
+
{
|
|
53
|
+
"promotions": [
|
|
54
|
+
{
|
|
55
|
+
"factId": "<id from facts list>",
|
|
56
|
+
"factContent": "<the fact text>",
|
|
57
|
+
"target": "<promotion target>",
|
|
58
|
+
"confidence": <0.0-1.0>,
|
|
59
|
+
"suggestion": "<human-readable suggestion>",
|
|
60
|
+
"reason": "<why this promotion improves the agent>",
|
|
61
|
+
"payload": {
|
|
62
|
+
"constraintText": "<if target=constraint>",
|
|
63
|
+
"workflowStep": { "label": "<step name>", "action": "<what to do>" },
|
|
64
|
+
"knowledgeSource": { "name": "<source name>", "type": "<ground-truth|signal|evidence|framework>" },
|
|
65
|
+
"mcpServerId": "<id from MCP registry if target=mcp>",
|
|
66
|
+
"skillId": "<skill id if target=skill>",
|
|
67
|
+
"instructionAppend": "<text to append to persona if target=instruction>"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"summary": "<one sentence summary of recommended changes>",
|
|
72
|
+
"versionImpact": "<major|minor|patch|none>"
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Rules:
|
|
76
|
+
- Only promote facts with confidence >= 0.6
|
|
77
|
+
- Facts that are temporary/contextual should stay as "keep"
|
|
78
|
+
- Prefer fewer high-confidence promotions over many low-confidence ones
|
|
79
|
+
- Include payload fields ONLY for the relevant target (omit others)
|
|
80
|
+
- versionImpact: major if persona/objective changes, minor if adding knowledge/tools/steps, patch if constraints only`}async function Nt(s){const n=J.getState(),r=n.providers.find(t=>t.id===n.selectedProviderId);if(!r)throw new Error("No provider configured — add one in Settings");const o=typeof r.models?.[0]=="object"?r.models[0].id:r.models?.[0]||"claude-sonnet-4-20250514";return r.authMethod==="claude-agent-sdk"?pe({prompt:s,model:o,maxTurns:1}):ue({providerId:r.id,model:o,messages:[{role:"user",content:s}],temperature:.3,maxTokens:4096})}function Ft(s){try{return JSON.parse(s)}catch{}const n=s.match(/```(?:json)?\s*([\s\S]*?)```/);if(n)try{return JSON.parse(n[1].trim())}catch{}const r=s.match(/\{[\s\S]*\}/);if(r)try{return JSON.parse(r[0])}catch{}throw new Error("Could not parse analysis response")}async function Et(s){if(s.length===0)return{promotions:[],summary:"No facts to analyze",versionImpact:"none"};const n=Ct(s),r=await Nt(n),o=Ft(r);return o.promotions=o.promotions.filter(t=>t.confidence>=.6&&t.target!=="keep").sort((t,i)=>i.confidence-t.confidence),o}function Tt(){const s=S(),n=Q(y=>y.facts),r=Q(y=>y.removeFact),o=j(y=>y.updateInstruction),t=j(y=>y.instructionState),i=j(y=>y.addWorkflowStep),d=j(y=>y.addChannel),l=A(y=>y.checkpoint),[u,g]=x.useState(n.length===0),[a,h]=x.useState(!1),[c,k]=x.useState(null),[F,m]=x.useState(new Set),[f,C]=x.useState(""),I=x.useCallback(async()=>{if(n.length!==0){h(!0),C(""),m(new Set);try{const y=await Et(n);k(y),u&&g(!1)}catch(y){C(y instanceof Error?y.message:"Analysis failed")}h(!1)}},[n,u]),P=x.useCallback(y=>{const N=y.payload;switch(y.target){case"instruction":if(N.instructionAppend){const z=t.persona;o({persona:z?`${z}
|
|
81
|
+
|
|
82
|
+
${N.instructionAppend}`:N.instructionAppend})}break;case"constraint":if(N.constraintText){const z=t.constraints.customConstraints;o({constraints:{...t.constraints,customConstraints:z?`${z}
|
|
83
|
+
${N.constraintText}`:N.constraintText}})}break;case"workflow":N.workflowStep&&i({label:N.workflowStep.label,action:N.workflowStep.action,tool:"",condition:"always"});break;case"knowledge":N.knowledgeSource&&d({sourceId:`promoted-${crypto.randomUUID().slice(0,8)}`,name:N.knowledgeSource.name,path:"",category:"knowledge",knowledgeType:N.knowledgeSource.type,depth:0,baseTokens:500});break}m(z=>new Set([...z,y.factId])),r(y.factId)},[t,o,i,d,r]),_=x.useCallback(()=>{if(c){for(const y of c.promotions)F.has(y.factId)||P(y);l("Facts promoted to agent design")}},[c,F,P,l]);if(n.length===0&&!c)return null;const M=c?c.promotions.filter(y=>!F.has(y.factId)).length:0;return e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{size:16,style:{color:"#FE5000"}}),e.jsx("h4",{className:"text-sm font-semibold",style:{color:s.textPrimary,fontFamily:"'Geist Sans', sans-serif"},children:"Fact Insights"}),c&&M>0&&e.jsxs("span",{className:"text-xs px-2 py-1 rounded",style:{background:"#FE500015",color:"#FE5000"},children:[M," suggestion",M!==1?"s":""]}),!c&&n.length>0&&e.jsxs("span",{className:"text-xs px-2 py-1 rounded",style:{background:s.isDark?"#1c1c20":"#f3f4f6",color:s.textDim},children:[n.length," facts to analyze"]})]}),e.jsx("button",{type:"button",onClick:()=>g(!u),title:u?"Show insights":"Hide insights",className:"text-xs border-none bg-transparent cursor-pointer",style:{color:s.textDim},children:u?"Show":"Hide"})]}),!u&&e.jsxs("div",{className:"space-y-3",children:[!c&&n.length>0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:s.textDim},children:"Analyze accumulated facts to discover which should become permanent parts of your agent — instructions, constraints, workflow steps, or knowledge sources."}),e.jsxs("button",{type:"button",onClick:I,disabled:a||n.length===0,title:a?"Analyzing facts":"Analyze for promotions",className:"flex items-center justify-center gap-1.5 w-full px-3 py-2.5 rounded text-[13px] tracking-wide uppercase cursor-pointer border-none",style:{background:a?"#CC4000":"#FE5000",color:"#fff",fontFamily:"'Geist Mono', monospace",opacity:a||n.length===0?.6:1},children:[a?e.jsx(ot,{size:11,className:"animate-spin"}):e.jsx(q,{size:11}),a?"Analyzing...":`Analyze ${n.length} fact${n.length!==1?"s":""}`]})]}),f&&e.jsx("div",{className:"text-xs text-red-500 p-2 rounded",style:{background:"#fee2e2"},children:f}),c&&M>0&&e.jsxs("button",{type:"button",onClick:_,title:"Apply all suggestions",className:"flex items-center justify-center gap-1.5 w-full px-3 py-2 rounded text-[12px] tracking-wide uppercase cursor-pointer border-none",style:{background:"#2ecc7120",color:"#2ecc71",fontFamily:"'Geist Mono', monospace"},children:["Apply all ",M," suggestions"]}),c&&M===0&&e.jsx("div",{className:"text-xs text-green-600 p-2 rounded",style:{background:"#f0fdf4"},children:"✅ All insights applied to your agent configuration."})]})]})}function de({lesson:s,onApprove:n,onReject:r,onRemove:o,onEdit:t}){const i=S(),[d,l]=x.useState(!1),[u,g]=x.useState(s.rule),a=()=>{u.trim()&&t?.(u.trim()),l(!1)},h={background:i.isDark?"#1c1c20":"#f9fafb",borderRadius:6,padding:"8px 10px"};return e.jsx("div",{className:"space-y-1",style:h,children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded shrink-0",style:{background:"#FE500015",color:"#FE5000"},children:s.category}),d?e.jsx("input",{className:"flex-1 text-[12px] bg-transparent border-b outline-none",style:{color:i.textPrimary,borderColor:i.border},value:u,onChange:c=>g(c.target.value),onKeyDown:c=>c.key==="Enter"&&a(),autoFocus:!0}):e.jsx("span",{className:"flex-1 text-[12px]",style:{color:i.textPrimary},children:s.rule}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[n&&e.jsx("button",{type:"button",onClick:n,title:"Approve",className:"border-none bg-transparent cursor-pointer p-1",style:{color:"#2ecc71"},children:e.jsx(ee,{size:13})}),r&&e.jsx("button",{type:"button",onClick:r,title:"Reject",className:"border-none bg-transparent cursor-pointer p-1",style:{color:i.textDim},children:e.jsx(U,{size:13})}),t&&!n&&(d?e.jsx("button",{type:"button",onClick:a,title:"Save",className:"border-none bg-transparent cursor-pointer p-1",style:{color:"#2ecc71"},children:e.jsx(ee,{size:13})}):e.jsx("button",{type:"button",onClick:()=>l(!0),title:"Edit",className:"border-none bg-transparent cursor-pointer p-1",style:{color:i.textDim},children:e.jsx(rt,{size:13})})),o&&e.jsx("button",{type:"button",onClick:o,title:"Remove",className:"border-none bg-transparent cursor-pointer p-1",style:{color:i.textDim},children:e.jsx(xe,{size:13})})]})]})})}function At(){const s=S(),n=A(c=>c.agentId)??"",r=L(c=>c.lessons),o=L(c=>c.approveLesson),t=L(c=>c.rejectLesson),i=L(c=>c.removeLesson),d=L(c=>c.updateLesson),[l,u]=x.useState(!1),g=r.filter(c=>c.agentId===n&&c.status==="pending"),a=r.filter(c=>c.agentId===n&&c.status==="approved"),h=a.reduce((c,k)=>c+k.appliedCount,0);return g.length===0&&a.length===0?null:e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(at,{size:16,style:{color:"#FE5000"}}),e.jsx("h4",{className:"text-sm font-semibold m-0",style:{color:s.textPrimary,fontFamily:"'Geist Sans', sans-serif"},children:"Auto-Lessons"}),g.length>0&&e.jsxs("span",{className:"text-xs px-2 py-1 rounded",style:{background:"#FE500015",color:"#FE5000"},children:[g.length," pending"]}),a.length>0&&e.jsxs("span",{className:"text-xs px-2 py-1 rounded",style:{background:s.isDark?"#1c1c20":"#f3f4f6",color:s.textDim},children:[a.length," active, applied ",h," time",h!==1?"s":""]})]}),e.jsx("button",{type:"button",onClick:()=>u(!l),className:"text-xs border-none bg-transparent cursor-pointer",style:{color:s.textDim},children:l?"Show":"Hide"})]}),!l&&e.jsxs("div",{className:"space-y-3",children:[g.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide m-0",style:{color:s.textDim,fontFamily:"'Geist Mono', monospace"},children:"Pending Review"}),g.map(c=>e.jsx(de,{lesson:c,onApprove:()=>o(c.id),onReject:()=>t(c.id)},c.id))]}),a.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide m-0",style:{color:s.textDim,fontFamily:"'Geist Mono', monospace"},children:"Active"}),a.map(c=>e.jsx(de,{lesson:c,onEdit:k=>d(c.id,k),onRemove:()=>i(c.id)},c.id))]})]})]})}function Pt({isOpen:s,onClose:n,prompt:r}){const o=S(),[t,i]=x.useState("Copy"),d=async()=>{try{await navigator.clipboard.writeText(r),i("Copied!"),setTimeout(()=>i("Copy"),2e3)}catch(l){console.error("Failed to copy:",l)}};return s?e.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50",style:{background:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(4px)"},onClick:n,children:e.jsxs("div",{className:"w-full h-[80vh] m-4 rounded-lg border shadow-lg flex flex-col",style:{background:o.surface,borderColor:o.border},onClick:l=>l.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",style:{borderColor:o.border},children:[e.jsx("h3",{className:"text-lg font-semibold m-0",style:{color:o.textPrimary,fontFamily:"'Geist Sans', sans-serif"},children:"System Prompt Preview"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:d,className:"flex items-center gap-2 px-3 py-2 text-sm rounded border",style:{background:"transparent",color:o.textSecondary,borderColor:o.border},children:[t==="Copy"?e.jsx(it,{size:14}):e.jsx(ee,{size:14}),t]}),e.jsx("button",{type:"button",onClick:n,className:"flex items-center justify-center w-8 h-8 rounded-md border-none cursor-pointer",style:{background:"transparent",color:o.textSecondary},"aria-label":"Close modal",children:e.jsx(U,{size:16})})]})]}),e.jsx("div",{className:"flex-1 p-4 overflow-y-auto",children:e.jsx("div",{className:"p-4 rounded-lg border h-full",style:{background:o.isDark?"#0a1929":"#f8fafc",borderColor:o.border},children:e.jsx("pre",{className:"h-full whitespace-pre-wrap",style:{fontSize:"14px",color:o.textSecondary,fontFamily:"'Geist Mono', monospace",lineHeight:1.5,margin:0},children:r||"No system prompt generated yet. Add persona, constraints, or workflow steps to see the preview."})})})]})}):null}function Wt(){const s=j(p=>p.agentMeta),n=j(p=>p.setAgentMeta),r=j(p=>p.instructionState),o=j(p=>p.updateInstruction),t=j(p=>p.workflowSteps),i=j(p=>p.channels),d=j(p=>p.selectedModel),l=j(p=>p.outputFormat),u=j(p=>p.setOutputFormat),g=j(p=>p.outputFormats),a=j(p=>p.prompt),h=j(p=>p.tokenBudget),c=j(p=>p.mcpServers),k=j(p=>p.skills),F=A(p=>p.saveStatus),[m,f]=x.useState(!1),[C,I]=x.useState(!1),[P,_]=x.useState(!1),[M,y]=x.useState(!1),[N,z]=x.useState(!1),[se,ye]=x.useState(!1),[be,ne]=x.useState(!1),Y=x.useCallback(()=>{const p=j.getState(),b=Ee.getState(),E=Q.getState(),v=i.filter(w=>w.enabled).map(w=>({sourceId:w.sourceId,name:w.name,path:w.path,knowledgeType:w.knowledgeType,depth:w.depth,tokens:w.baseTokens,content:w.content})),T=b.lastPipelineStats?.pipeline,X=T?{context:T.context,tokens:T.tokens,utilization:T.utilization,sources:T.sources.map(w=>({name:w.name,type:w.type,totalTokens:w.totalTokens})),compression:{originalTokens:T.compression.originalTokens,compressedTokens:T.compression.compressedTokens,ratio:T.compression.ratio},timing:{totalMs:T.timing.totalMs}}:void 0,oe=E.facts.map(w=>({id:w.id,text:w.content,domain:w.domain}));return{channels:i,selectedModel:d,outputFormat:l,outputFormats:g,prompt:a,tokenBudget:h,mcpServers:c,skills:k,agentMeta:s,agentConfig:p.agentConfig,connectors:p.connectors,instructionState:p.instructionState,workflowSteps:p.workflowSteps,knowledgeContent:v,pipelineSnapshot:X,facts:oe.length>0?oe:void 0}},[i,d,l,g,a,h,c,k,s,t]),ve=x.useCallback(()=>{const p=Y(),b=Ae(p),E=b.match(/^name:\s*(.+)$/m)?.[1]?.trim()??"modular-agent";B(b,E)},[Y]),je=x.useCallback(p=>{const b=Y(),E=b.agentMeta.name||"modular-agent";switch(p){case"JSON":{const v=Me(b);B(v,E,".json");break}case"YAML":{const v=Pe(b);B(v,E,".yaml");break}case"Markdown":case"Claude format":{const v=ae("claude",b);B(v,E,".md");break}case"OpenAI format":{const v=ae("codex",b);B(v,E,".json");break}}},[Y]),{constraints:$}=r,O=$.customConstraints?$.customConstraints.split(`
|
|
84
|
+
`).filter(p=>p.trim()):[],ke=p=>{if(p&&!O.includes(p)){const b=[...O,p];o({constraints:{...$,customConstraints:b.join(`
|
|
85
|
+
`)}})}},we=p=>{const b=O.filter(E=>E!==p);o({constraints:{...$,customConstraints:b.join(`
|
|
86
|
+
`)}})},Se=()=>{const{persona:p,constraints:b,objectives:E}=r;let v="";return p&&(v+=`You are ${s.name||"an AI assistant"}.
|
|
87
|
+
|
|
88
|
+
${p}
|
|
89
|
+
|
|
90
|
+
`),(O.length>0||b.neverMakeUp||b.askBeforeActions)&&(v+=`CONSTRAINTS:
|
|
91
|
+
`,b.neverMakeUp&&(v+=`- Never fabricate information. If you don't know something, say so.
|
|
92
|
+
`),b.askBeforeActions&&(v+=`- Always ask for permission before taking actions that could affect the user's system.
|
|
93
|
+
`),b.stayInScope&&(v+=`- Stay within the defined scope of your role and responsibilities.
|
|
94
|
+
`),b.useOnlyTools&&(v+=`- Only use the tools and information sources provided to you.
|
|
95
|
+
`),b.limitWords&&b.wordLimit>0&&(v+=`- Keep responses concise, under ${b.wordLimit} words when possible.
|
|
96
|
+
`),O.forEach(T=>{v+=`- ${T}
|
|
97
|
+
`}),v+=`
|
|
98
|
+
`),E.primary&&(v+=`PRIMARY OBJECTIVE: ${E.primary}
|
|
99
|
+
|
|
100
|
+
`),t.length>0&&(v+=`WORKFLOW:
|
|
101
|
+
`,t.forEach((T,X)=>{v+=`${X+1}. ${T.label}
|
|
102
|
+
`}),v+=`
|
|
103
|
+
`),v.trim()},Ce={color:"var(--text-primary)",fontFamily:"'Geist Sans', sans-serif"},Ne={color:"var(--text-secondary)",lineHeight:1.5};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-semibold mb-2 m-0",style:Ce,children:"Review & Configure"}),e.jsx("p",{className:"text-sm",style:Ne,children:"Review and finalize your agent's configuration. Customize the identity, persona, constraints, and output settings before testing."})]}),e.jsx(St,{onExport:ve,onExportFormat:je,onPromptPreview:()=>ne(!0),saveStatus:F}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(mt,{agentMeta:s,setAgentMeta:n,collapsed:m,onToggle:()=>f(!m)}),e.jsx(yt,{persona:r.persona,tone:r.tone,expertise:r.expertise,updateInstruction:o,collapsed:C,onToggle:()=>I(!C)}),e.jsx(vt,{constraints:$,updateInstruction:o,customConstraints:O,addCustomConstraint:ke,removeCustomConstraint:we,collapsed:P,onToggle:()=>_(!P)}),e.jsx(jt,{objectives:r.objectives,updateInstruction:o,collapsed:M,onToggle:()=>y(!M)}),e.jsx(kt,{workflowSteps:t,collapsed:N,onToggle:()=>z(!N)}),e.jsx(wt,{selectedModel:d,outputFormat:l,setOutputFormat:p=>u(p),tokenBudget:h,collapsed:se,onToggle:()=>ye(!se)})]}),e.jsx(Tt,{}),e.jsx(At,{}),e.jsx("div",{className:"mt-4",children:e.jsx(ut,{})}),e.jsx(Pt,{isOpen:be,onClose:()=>ne(!1),prompt:Se()})]})}export{Wt as ReviewTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./vendor-D1h_O76p.js";import{u as p}from"./index-gBy3427k.js";import{C as u,a as h}from"./icons-MKpPNvV8.js";function g({checked:n,onChange:r,label:i,size:o="md",disabled:s}){const a=p(),l=o==="sm"?28:36,d=o==="sm"?16:20,t=o==="sm"?12:16;return e.jsxs("button",{type:"button",role:"switch","aria-checked":n,onClick:()=>!s&&r(!n),className:"flex items-center gap-2 cursor-pointer border-none bg-transparent p-0 nodrag",style:{opacity:s?.5:1,cursor:s?"not-allowed":"pointer"},children:[e.jsx("div",{className:"relative rounded-full transition-colors",style:{width:l,height:d,background:n?"#FE5000":a.border},children:e.jsx("div",{className:"absolute top-[2px] rounded-full bg-white transition-transform",style:{width:t,height:t,transform:`translateX(${n?l-t-2:2}px)`,transition:"transform 0.15s ease"}})}),i&&e.jsx("span",{className:"text-[13px]",style:{color:a.textSecondary},children:i})]})}function j({icon:n,label:r,color:i,badge:o,collapsed:s,onToggle:a,children:l,id:d}){const t=p(),c=d||`section-${r.toLowerCase().replace(/\s+/g,"-")}`,m=`${c}-content`;return e.jsxs("section",{role:"region","aria-labelledby":`${c}-heading`,className:"mb-6",style:{border:`1px solid ${t.border}`,borderRadius:"8px",overflow:"hidden"},children:[e.jsx("h3",{id:`${c}-heading`,className:"m-0",children:e.jsxs("button",{type:"button",onClick:a,"aria-expanded":!s,"aria-controls":m,className:"flex items-center gap-2 w-full px-5 py-3.5 border-none cursor-pointer select-none transition-colors",style:{background:t.surfaceElevated},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),a())},children:[e.jsx(n,{size:16,style:{color:i,flexShrink:0}}),s?e.jsx(u,{size:12,style:{color:t.textDim},"aria-hidden":"true"}):e.jsx(h,{size:12,style:{color:t.textDim},"aria-hidden":"true"}),e.jsx("span",{className:"text-sm font-semibold flex-1 text-left",style:{fontFamily:"'Geist Sans', sans-serif",color:t.textPrimary},children:r}),o&&e.jsx("span",{className:"text-[13px] px-2 py-1 rounded-full",style:{fontFamily:"'Geist Mono', monospace",color:t.textDim,background:t.badgeBg},"aria-label":`${r} status: ${o}`,children:o}),e.jsxs("span",{className:"sr-only",children:[s?"Expand":"Collapse"," ",r," section"]})]})}),!s&&e.jsx("div",{id:m,className:"px-5 pb-4",role:"region","aria-labelledby":`${c}-heading`,children:l})]})}export{j as S,g as T};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-wf-D3Ix_.js","assets/vendor-D1h_O76p.js","assets/services-CTWXQK6j.js","assets/stores-CeKWz7ou.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as h,j as e}from"./vendor-D1h_O76p.js";import{u as w,e as de,d as Ye,S as Ne}from"./index-gBy3427k.js";import{useConversationStore as D}from"./conversationStore-CkfEU2eV.js";import{_ as le,m as O,n as B,u as I,r as fe,o as Ve,A as we,e as he,a as Ze,p as pe,q as Je,t as Xe,l as Qe,v as et,w as tt,x as st,y as ot,z as nt,B as Ce}from"./services-CTWXQK6j.js";import{a7 as ge,ao as $e,Q as ze,a6 as Le,a4 as Re,ap as Ae,ak as rt,a as W,C as U,Z as be,B as at,U as ye,ah as lt,aq as it,a0 as ct,ar as dt,X as pt,P as ut,c as mt,as as xt,at as ft,au as ht,h as Ie,av as yt,$ as gt,x as je,G as bt,aw as jt,i as vt,J as kt,ax as St,ay as Nt}from"./icons-MKpPNvV8.js";import{M as wt,r as Ct}from"./markdown-DWF7F0i0.js";import"./stores-CeKWz7ou.js";function ae(t){return t?t.includes(`
|
|
3
|
+
`)?`|
|
|
4
|
+
${t.split(`
|
|
5
|
+
`).map(s=>" "+s).join(`
|
|
6
|
+
`)}`:/[:#"'{}\[\],&*?|>!%@`]/.test(t)?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:t:'""'}function Me(t,s=0){const n=" ".repeat(s);return t.map(r=>`${n}- ${ae(r)}`).join(`
|
|
7
|
+
`)}function Mt(t){const s=t.agentMeta,n=t.agentConfig,r=[];return r.push(`name: ${ae(s.name||"Untitled Agent")}`),s.description&&r.push(`description: ${ae(s.description)}`),r.push('version: "1.0.0"'),s.tags?.length&&r.push(`tags:
|
|
8
|
+
${Me(s.tags)}`),s.avatar&&r.push(`avatar: ${s.avatar}`),s.icon&&r.push(`icon: ${s.icon}`),r.push(""),r.push("# Runtime"),r.push(`model: ${ae(t.selectedModel)}`),n?.temperature!==void 0&&r.push(`temperature: ${n.temperature}`),n?.planningMode&&r.push(`planning: ${n.planningMode}`),r.push(`token_budget: ${t.tokenBudget}`),r.push(""),r.push("# Output"),r.push(`output_format: ${t.outputFormat}`),t.outputFormats.length>1&&r.push(`output_formats:
|
|
9
|
+
${Me(t.outputFormats)}`),r.join(`
|
|
10
|
+
`)+`
|
|
11
|
+
`}function Tt(t){const s=t.instructionState,n=t.agentMeta,r=[];if(r.push(`# ${n.name||"Agent"}`),r.push(""),n.description&&(r.push(n.description),r.push("")),s?.persona&&(r.push("## Persona"),r.push(""),r.push(s.persona),r.push("")),s?.tone&&s.tone!=="neutral"&&(r.push(`**Tone:** ${s.tone}`),r.push("")),s?.expertise&&s.expertise!==3){const o=["Beginner","Novice","Intermediate","Advanced","Expert"];r.push(`**Expertise:** ${o[s.expertise-1]} (${s.expertise}/5)`),r.push("")}return r.join(`
|
|
12
|
+
`)}function Ft(t){const s=t.instructionState,n=["# Instructions",""];s?.objectives?.primary&&(n.push("## Objective"),n.push(""),n.push(s.objectives.primary),n.push(""),s.objectives.successCriteria.length>0&&(n.push("### Success Criteria"),n.push(""),s.objectives.successCriteria.forEach(o=>n.push(`- ${o}`)),n.push("")),s.objectives.failureModes.length>0&&(n.push("### Failure Modes to Avoid"),n.push(""),s.objectives.failureModes.forEach(o=>n.push(`- ${o}`)),n.push("")));const r=[];if(s?.constraints){const o=s.constraints;o.neverMakeUp&&r.push("Never fabricate information or make up facts"),o.askBeforeActions&&r.push("Ask for permission before taking significant actions"),o.stayInScope&&r.push(`Stay within scope${o.scopeDefinition?": "+o.scopeDefinition:""}`),o.useOnlyTools&&r.push("Only use tools and capabilities that are explicitly provided"),o.limitWords&&r.push(`Keep responses under ${o.wordLimit} words`),o.customConstraints&&o.customConstraints.split(`
|
|
13
|
+
`).filter(Boolean).forEach(i=>r.push(i.trim()))}return r.length>0&&(n.push("## Constraints"),n.push(""),r.forEach(o=>n.push(`- ${o}`)),n.push("")),t.workflowSteps&&t.workflowSteps.length>0&&(n.push("## Workflow"),n.push(""),t.workflowSteps.forEach((o,i)=>{n.push(`${i+1}. **${o.label}** — ${o.action}`)}),n.push("")),t.prompt&&!s?.persona&&!s?.objectives?.primary&&(n.push("## Additional Instructions"),n.push(""),n.push(t.prompt),n.push("")),n.join(`
|
|
14
|
+
`)}function Et(t){const s=["# Tools",""],n=t.mcpServers.filter(o=>o.enabled&&o.added),r=t.skills.filter(o=>o.enabled&&o.added);return n.length>0&&(s.push("## MCP Servers"),s.push(""),n.forEach(o=>{s.push(`### ${o.name}`),s.push(""),o.description&&s.push(o.description),s.push(""),s.push("```yaml"),s.push(`id: ${o.id}`),s.push("transport: stdio"),s.push("command: npx"),s.push(`args: ["@${o.id}/mcp"]`),s.push("```"),s.push("")})),r.length>0&&(s.push("## Skills"),s.push(""),r.forEach(o=>{s.push(`- **${o.name}**${o.description?" — "+o.description:""}`)}),s.push("")),n.length===0&&r.length===0&&(s.push("No tools configured."),s.push("")),s.join(`
|
|
15
|
+
`)}function Dt(t){const s=["# Knowledge",""],n=t.channels.filter(o=>o.enabled),r=(t.connectors??[]).filter(o=>o.enabled);return n.length>0&&(s.push("## Sources"),s.push(""),n.forEach(o=>{const i=o.knowledgeType||"signal";s.push(`### ${o.name||o.path}`),s.push(""),s.push(`- **Path:** \`${o.path}\``),s.push(`- **Type:** ${i}`),o.content&&s.push(`- **Content Preview:** ${o.content.slice(0,100)}${o.content.length>100?"...":""}`),o.hint&&s.push(`- **Hint:** ${o.hint}`),s.push("")})),r.length>0&&(s.push("## Connectors"),s.push(""),r.forEach(o=>{s.push(`- **${o.name}** (${o.service}) — ${o.direction}${o.hint?", scope: "+o.hint:""}`)}),s.push("")),s.push("## Budget"),s.push(""),s.push(`Token budget: ${t.tokenBudget}`),s.push(""),s.join(`
|
|
16
|
+
`)}function Pt(t){return["# Memory","","<!-- Initial memory for this agent. Add seed context, key facts, or preferences here. -->",""].join(`
|
|
17
|
+
`)}function _e(t){return{"agent.yaml":Mt(t),"SOUL.md":Tt(t),"INSTRUCTIONS.md":Ft(t),"TOOLS.md":Et(t),"KNOWLEDGE.md":Dt(t),"MEMORY.md":Pt()}}async function $t(t){const s=_e(t),n=(t.agentMeta.name||"modular-agent").toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");try{const r=(await le(async()=>{const{default:u}=await import("./jszip.min-wf-D3Ix_.js").then(m=>m.j);return{default:u}},__vite__mapDeps([0,1]))).default,o=new r,i=o.folder(n);for(const[u,m]of Object.entries(s))i.file(u,m);const l=await o.generateAsync({type:"blob"}),c=URL.createObjectURL(l),d=document.createElement("a");d.href=c,d.download=`${n}.zip`,d.click(),URL.revokeObjectURL(c)}catch{for(const[r,o]of Object.entries(s)){const i=new Blob([o],{type:"text/plain"}),l=URL.createObjectURL(i),c=document.createElement("a");c.href=l,c.download=r,c.click(),URL.revokeObjectURL(l)}}}function Be(t){const s={};return t["agent.yaml"]&&(s.agentYaml=Ge(t["agent.yaml"])),t["SOUL.md"]&&(s.soul=t["SOUL.md"]),t["INSTRUCTIONS.md"]&&(s.instructions=t["INSTRUCTIONS.md"]),t["TOOLS.md"]&&(s.tools=t["TOOLS.md"]),t["KNOWLEDGE.md"]&&(s.knowledge=t["KNOWLEDGE.md"]),t["MEMORY.md"]&&(s.memory=t["MEMORY.md"]),s}function Ge(t){const s={};let n=null,r="";for(const o of t.split(`
|
|
18
|
+
`)){const i=o.trim();if(!i||i.startsWith("#"))continue;if(i.startsWith("- ")&&n!==null){n.push(i.slice(2).replace(/^["']|["']$/g,"")),s[r]=n;continue}n=null;const l=i.indexOf(":");if(l===-1)continue;const c=i.slice(0,l).trim();if(c==="__proto__"||c==="constructor"||c==="prototype")continue;const d=i.slice(l+1).trim();if(!d){r=c,n=[];continue}const u=d.replace(/^["']|["']$/g,"");u==="true"?s[c]=!0:u==="false"?s[c]=!1:/^\d+(\.\d+)?$/.test(u)?s[c]=Number(u):s[c]=u}return s}function Oe(t){const s={};if(t.agentYaml){const n=t.agentYaml;s.agentMeta={name:n.name||"",description:n.description||"",avatar:n.avatar||"",icon:n.icon||"",category:n.category||"general",tags:Array.isArray(n.tags)?n.tags:[]},n.model&&(s.selectedModel=n.model),n.token_budget&&(s.tokenBudget=n.token_budget),n.output_format&&(s.outputFormat=n.output_format),s.agentConfig={temperature:n.temperature??.7,planningMode:n.planning??"single-shot",model:n.model??""}}if(t.soul||t.instructions){const n={persona:"",tone:"neutral",expertise:3,constraints:{neverMakeUp:!1,askBeforeActions:!1,stayInScope:!1,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:"",scopeDefinition:""},objectives:{primary:"",successCriteria:[],failureModes:[]},rawPrompt:"",autoSync:!1};if(t.soul){const r=t.soul.split(`
|
|
19
|
+
`);let o="",i="";for(const l of r){const c=l.trim();c.startsWith("## ")?(o==="persona"&&i.trim()&&(n.persona=i.trim()),o=c.toLowerCase().includes("persona")?"persona":"",i=""):!c.startsWith("#")&&c&&(o||!n.persona)&&(i+=l+`
|
|
20
|
+
`,!n.persona&&!o&&(n.persona=i.trim()))}o==="persona"&&i.trim()&&(n.persona=i.trim())}if(t.instructions){const r=t.instructions.split(`
|
|
21
|
+
`);let o="",i=!1,l=[];for(const c of r){const d=c.trim();if(d.startsWith("## ")){o==="successCriteria"&&l.length>0?n.objectives.successCriteria=l:o==="failureModes"&&l.length>0&&(n.objectives.failureModes=l);const u=d.toLowerCase();u.includes("objective")?o="objective":u.includes("constraint")&&(o="constraints"),i=!1,l=[]}else if(d.startsWith("### ")){const u=d.toLowerCase();u.includes("success")?(o="successCriteria",i=!0,l=[]):u.includes("failure")&&(o="failureModes",i=!0,l=[])}else if(d.startsWith("- ")){if(i)l.push(d.substring(2));else if(o==="constraints"){const u=d.substring(2);if((u.toLowerCase().includes("never fabricate")||u.toLowerCase().includes("never make up"))&&(n.constraints.neverMakeUp=!0),u.toLowerCase().includes("ask")&&u.toLowerCase().includes("permission")&&(n.constraints.askBeforeActions=!0),u.toLowerCase().includes("scope")&&(n.constraints.stayInScope=!0),u.toLowerCase().includes("only use tools")&&(n.constraints.useOnlyTools=!0),u.toLowerCase().includes("word")&&/\d+/.test(u)){n.constraints.limitWords=!0;const m=u.match(/(\d+)/);m&&(n.constraints.wordLimit=parseInt(m[1]))}}}else o==="objective"&&d&&!d.startsWith("#")&&(n.objectives.primary||(n.objectives.primary=d))}o==="successCriteria"&&l.length>0?n.objectives.successCriteria=l:o==="failureModes"&&l.length>0&&(n.objectives.failureModes=l)}s.instructionState=n}return s}async function We(t){try{const s=(await le(async()=>{const{default:y}=await import("./jszip.min-wf-D3Ix_.js").then(b=>b.j);return{default:y}},__vite__mapDeps([0,1]))).default,n=new s,r=10*1024*1024;if(t.size>r)throw new Error(`ZIP file too large (${(t.size/1024/1024).toFixed(1)}MB). Maximum is 10MB.`);const o=await n.loadAsync(t),i=2*1024*1024,l={},c=["agent.yaml","SOUL.md","INSTRUCTIONS.md","TOOLS.md","KNOWLEDGE.md","MEMORY.md"];for(const[y,b]of Object.entries(o.files)){if(b.dir)continue;const g=y.split("/").pop()||"";if(c.includes(g))try{const j=await b.async("text");if(j.length>i){console.warn(`Skipping ${g}: exceeds 2MB limit`);continue}l[g]=j}catch(j){console.warn(`Failed to read ${g}:`,j)}}if(!l["agent.yaml"])throw new Error("agent.yaml is required but not found in the ZIP file");const d=Be(l),u=Oe(d),{useConsoleStore:m}=await le(async()=>{const{useConsoleStore:y}=await import("./services-CTWXQK6j.js").then(b=>b.Q);return{useConsoleStore:y}},__vite__mapDeps([2,3,1]));m.getState().restoreFullState(u)}catch(s){throw console.error("Import failed:",s),s instanceof Error?s:new Error("Unknown import error")}}const zt=Object.freeze(Object.defineProperty({__proto__:null,agentDirectoryToState:Oe,downloadAgentDirectory:$t,exportAgentDirectory:_e,importAgentFromZip:We,parseAgentDirectory:Be,parseSimpleYaml:Ge},Symbol.toStringTag,{value:"Module"}));function Lt({stats:t,traceId:s}){const[n,r]=h.useState(!1),o=w(),i=O(j=>j.selectTrace),l=O(j=>j.selectedTraceId),c=s!=null&&l===s,d=t.totalContextTokens||0,u=t.retrieval?.selectedChunks||0,m=t.retrieval?.retrievalMs||0,p=t.retrieval?.embeddingMs||0,y=m+p,b=t.retrieval?.queryType||"none",g=t.toolTurns||0;return e.jsxs("div",{className:"mt-2 border rounded-md overflow-hidden transition-all duration-200",style:{border:`1px solid ${c?"#FE5000":o.borderSubtle}`,background:o.isDark?"#0d0d10":"#f8f8fa",fontFamily:"'Geist Mono', monospace"},children:[e.jsxs("div",{className:"flex items-center",children:[e.jsxs("button",{onClick:()=>r(!n),title:n?"Collapse trace":"Expand trace",className:"flex-1 px-3 py-2 text-left text-xs flex items-center justify-between hover:opacity-80 transition-opacity border-none bg-transparent cursor-pointer",style:{color:o.textDim,fontFamily:"'Geist Mono', monospace"},children:[e.jsxs("span",{children:["📊 ",d," tokens • ",u," sources • ",y,"ms",g>0&&` • ${g} tool calls`]}),e.jsx("span",{className:"text-[10px]",style:{color:"#FE5000"},children:n?"▼":"▶"})]}),s&&e.jsx("button",{onClick:j=>{j.stopPropagation(),i(c?null:s)},className:"px-2 py-1.5 text-[10px] border-none cursor-pointer rounded-r-md transition-colors",style:{background:c?"#FE500020":"transparent",color:c?"#FE5000":o.textFaint,fontFamily:"'Geist Mono', monospace"},title:c?"Deselect trace":"Select trace",children:c?"📍":"○"})]}),n&&e.jsxs("div",{className:"px-3 pb-3 pt-1 text-xs space-y-2 border-t",style:{borderTop:`1px solid ${o.borderSubtle}`,color:o.textSecondary},children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Context tokens:"}),e.jsx("span",{style:{color:o.textPrimary},children:d.toLocaleString()})]}),t.retrieval&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Retrieval mode:"}),e.jsx("span",{style:{color:o.textPrimary},children:b})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Sources selected:"}),e.jsxs("span",{style:{color:o.textPrimary},children:[u," / ",t.retrieval.totalChunks]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Retrieval time:"}),e.jsxs("span",{style:{color:o.textPrimary},children:[m,"ms"]})]}),p>0&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Embedding time:"}),e.jsxs("span",{style:{color:o.textPrimary},children:[p,"ms"]})]})]}),g>0&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Tool turns:"}),e.jsx("span",{style:{color:o.textPrimary},children:g})]}),t.systemTokens&&t.systemTokens!==d&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"System tokens:"}),e.jsx("span",{style:{color:o.textPrimary},children:t.systemTokens.toLocaleString()})]}),t.memory&&e.jsxs("div",{className:"pt-1 border-t",style:{borderTop:`1px solid ${o.borderSubtle}`},children:[e.jsx("div",{className:"text-[10px] mb-1",style:{color:o.textDim},children:"Memory"}),e.jsxs("div",{className:"flex justify-between text-[11px]",children:[e.jsx("span",{children:"Facts written:"}),e.jsx("span",{style:{color:o.textPrimary},children:t.memory.writtenFacts})]}),t.memory.recalledFacts>0&&e.jsxs("div",{className:"flex justify-between text-[11px]",children:[e.jsx("span",{children:"Facts recalled:"}),e.jsx("span",{style:{color:o.textPrimary},children:t.memory.recalledFacts})]})]})]})]})}const Rt={toolCalling:"Tool Calling",streaming:"Streaming",structuredOutput:"Structured Output",memoryHooks:"Memory Hooks",agentLoop:"Agent Loop",mcpBridge:"MCP Bridge"},T="supported",L="degraded",Q="unsupported",ne={anthropic:{toolCalling:{status:T},streaming:{status:T},structuredOutput:{status:T},memoryHooks:{status:T},agentLoop:{status:T},mcpBridge:{status:T}},"claude-agent-sdk":{toolCalling:{status:T},streaming:{status:T},structuredOutput:{status:T},memoryHooks:{status:T},agentLoop:{status:T},mcpBridge:{status:T}},openai:{toolCalling:{status:T},streaming:{status:T},structuredOutput:{status:T},memoryHooks:{status:L,note:"Requires external memory layer"},agentLoop:{status:T},mcpBridge:{status:L,note:"Via OpenAI-compatible proxy"}},google:{toolCalling:{status:T},streaming:{status:T},structuredOutput:{status:L,note:"JSON mode only, no strict schema"},memoryHooks:{status:Q,note:"Not natively supported"},agentLoop:{status:L,note:"Manual orchestration required"},mcpBridge:{status:Q,note:"No MCP support"}},openrouter:{toolCalling:{status:L,note:"Depends on underlying model"},streaming:{status:T},structuredOutput:{status:L,note:"Depends on underlying model"},memoryHooks:{status:L,note:"Depends on underlying model"},agentLoop:{status:L,note:"Depends on underlying model"},mcpBridge:{status:Q,note:"Not available through proxy"}},custom:{toolCalling:{status:L,note:"Depends on implementation"},streaming:{status:L,note:"Depends on implementation"},structuredOutput:{status:L,note:"Depends on implementation"},memoryHooks:{status:Q,note:"Unknown provider"},agentLoop:{status:L,note:"Depends on implementation"},mcpBridge:{status:Q,note:"Unknown provider"}}};function At(t){return ne[t]?ne[t]:(t.startsWith("custom"),ne.custom)}function It(t,s){const n=[];for(const r of s){const o=t[r],i=Rt[r];o.status==="unsupported"?n.push({level:"error",capability:r,message:`${i} is not supported by this provider${o.note?`: ${o.note}`:""}`}):o.status==="degraded"?n.push({level:"warning",capability:r,message:`${i} has limited support${o.note?`: ${o.note}`:""}`}):n.push({level:"ok",capability:r,message:`${i} is fully supported`})}return n}function _t({matrix:t,requiredCapabilities:s}){const n=w();if(s.length===0)return null;const r=It(t,s),o=r.filter(l=>l.level==="error"),i=r.filter(l=>l.level==="warning");return o.length===0&&i.length===0?null:e.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.map(l=>e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded-lg text-[12px]",style:{background:n.statusErrorBg,color:n.statusError,border:`1px solid ${n.statusError}30`},role:"alert",children:[e.jsx(ge,{size:12,className:"shrink-0 mt-0.5"}),e.jsx("span",{children:l.message})]},l.capability)),i.map(l=>e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded-lg text-[12px]",style:{background:n.statusWarningBg,color:n.statusWarning,border:`1px solid ${n.statusWarning}30`},role:"status",children:[e.jsx($e,{size:12,className:"shrink-0 mt-0.5"}),e.jsx("span",{children:l.message})]},l.capability))]})}const Bt={observation:"#3498db",inference:"#f1c40f",decision:"#2ecc71",hypothesis:"#9b59b6",contract:"#FE5000"};function Ue({fact:t}){const s=Bt[t.epistemicType]??"#888";return e.jsx("span",{style:{fontSize:12,padding:"2px 6px",borderRadius:4,background:s+"15",color:s,fontFamily:"'Geist Mono', monospace"},children:t.key})}function Gt({text:t}){const[s,n]=h.useState(!1);return e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(t),n(!0),setTimeout(()=>n(!1),1500)},style:{background:"none",border:"none",cursor:"pointer",padding:2,opacity:.6},title:"Copy output",children:s?e.jsx(ye,{size:12,style:{color:"#2ecc71"}}):e.jsx(lt,{size:12})})}function Ot({agent:t,expanded:s}){const n=w(),[r,o]=h.useState(s??!1),i={waiting:e.jsx(rt,{size:14,style:{color:n.textDim}}),running:e.jsx(ze,{size:14,className:"animate-spin",style:{color:"#FE5000"}}),completed:e.jsx(Le,{size:14,style:{color:"#2ecc71"}}),error:e.jsx(ge,{size:14,style:{color:"#dc2626"}})}[t.status],l=t.status==="completed"?t.output:t.currentMessage,c=(l?.length??0)>300;return e.jsxs("div",{style:{padding:12,borderRadius:8,border:`1px solid ${t.status==="running"?"#FE500040":n.border}`,background:t.status==="running"?"#FE500008":n.surface},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:l?8:0},children:[i,e.jsx("span",{style:{fontSize:14,fontWeight:600,color:n.textPrimary,fontFamily:"'Geist Mono', monospace"},children:t.name}),t.isAgentSdk&&e.jsx("span",{style:{fontSize:10,padding:"2px 6px",borderRadius:4,background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace",fontWeight:600,border:"1px solid #FE500030"},children:"Agent SDK"}),e.jsxs("span",{style:{fontSize:12,color:n.textDim,marginLeft:"auto",display:"flex",alignItems:"center",gap:6},children:[t.status==="running"?`Turn ${t.turns}`:t.status,t.tokens&&(t.tokens.input>0||t.tokens.output>0)&&e.jsxs("span",{style:{fontSize:11,color:n.textFaint},children:[((t.tokens.input+t.tokens.output)/1e3).toFixed(1),"k tok"]})]})]}),l&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx("div",{style:{fontSize:13,padding:10,borderRadius:6,background:n.inputBg,color:n.textPrimary,lineHeight:1.6,whiteSpace:"pre-wrap",overflowY:"auto",maxHeight:r?"none":200},children:l}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginTop:4},children:[c&&e.jsx("button",{type:"button",onClick:()=>o(!r),style:{background:"none",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:12,color:"#FE5000",display:"flex",alignItems:"center",gap:4,fontFamily:"'Geist Mono', monospace"},children:r?e.jsxs(e.Fragment,{children:[e.jsx(W,{size:12})," Collapse"]}):e.jsxs(e.Fragment,{children:[e.jsx(U,{size:12})," Expand (",Math.ceil((l?.length??0)/1e3),"k chars)"]})}),l&&e.jsx(Gt,{text:l})]})]}),t.toolCalls.length>0&&e.jsxs("div",{style:{marginTop:8},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[e.jsx(be,{size:12,style:{color:"#2ecc71"}}),e.jsxs("span",{style:{fontSize:12,fontWeight:600,color:n.textSecondary,fontFamily:"'Geist Mono', monospace"},children:["Tool Calls (",t.toolCalls.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:t.toolCalls.map((d,u)=>e.jsxs("div",{style:{fontSize:12,padding:6,borderRadius:4,background:"#2ecc7115",border:"1px solid #2ecc7130",color:n.textSecondary,fontFamily:"'Geist Mono', monospace"},children:[e.jsx("div",{style:{fontWeight:600,color:"#2ecc71",marginBottom:2},children:d.tool}),d.args&&e.jsx("div",{style:{color:n.textDim,fontSize:11,lineHeight:1.4},children:d.args.length>100?d.args.slice(0,100)+"…":d.args})]},u))})]}),t.facts.length>0&&e.jsx("div",{style:{marginTop:8,display:"flex",flexWrap:"wrap",gap:4},children:t.facts.map((d,u)=>e.jsx(Ue,{fact:d},u))})]})}function Wt({facts:t}){const s=w();return t.length===0?null:e.jsxs("div",{style:{padding:12,borderRadius:8,border:`1px solid ${s.border}`,background:s.surface},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[e.jsx(at,{size:14,style:{color:"#FE5000"}}),e.jsxs("span",{style:{fontSize:13,fontWeight:600,color:s.textPrimary,fontFamily:"'Geist Mono', monospace"},children:["Shared Memory (",t.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:t.map((n,r)=>e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[e.jsx(Ue,{fact:n}),e.jsx("span",{style:{fontSize:12,color:s.textDim,flex:1},children:n.value})]},r))})]})}function Ut(){const t=w(),s=B(p=>p.status),n=B(p=>p.agents),r=B(p=>p.sharedFacts),o=B(p=>p.startedAt),i=B(p=>p.completedAt),l=B(p=>p.error),[c,d]=h.useState(!1);if(s==="idle")return null;const u=i&&o?((i-o)/1e3).toFixed(1):o?((Date.now()-o)/1e3).toFixed(0):"0",m=e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,height:"100%"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[s==="running"&&e.jsx(ze,{size:14,className:"animate-spin",style:{color:"#FE5000"}}),s==="completed"&&e.jsx(Le,{size:14,style:{color:"#2ecc71"}}),s==="error"&&e.jsx(ge,{size:14,style:{color:"#dc2626"}}),e.jsx("span",{style:{fontSize:13,fontWeight:600,color:t.textPrimary},children:s==="running"?"Running...":s==="completed"?"Completed":"Error"}),e.jsxs("span",{style:{fontSize:12,color:t.textDim},children:[u,"s"]}),e.jsx("button",{type:"button",onClick:()=>d(!c),style:{marginLeft:"auto",background:"none",border:"none",cursor:"pointer",padding:4,color:t.textDim},title:c?"Minimize":"Maximize results",children:c?e.jsx(Re,{size:14}):e.jsx(Ae,{size:14})})]}),l&&e.jsx("div",{style:{fontSize:13,color:"#dc2626",padding:8,borderRadius:6,background:"#dc262610"},children:l}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,flex:1,overflowY:"auto"},children:n.map(p=>e.jsx(Ot,{agent:p,expanded:c},p.agentId))}),e.jsx(Wt,{facts:r})]});return c?e.jsx("div",{style:{position:"fixed",inset:0,zIndex:100,background:t.bg,padding:24,overflowY:"auto"},children:m}):m}function Ht({retrieval:t}){const s=w();if(!t)return null;const n=new Map;for(const p of t.chunks){const y=n.get(p.source)||[];y.push(p),n.set(p.source,y)}const r=p=>({"ground-truth":"#e74c3c",signal:"#f1c40f",evidence:"#3498db",framework:"#2ecc71",guideline:"#FE5000",hypothesis:"#9b59b6"})[p]||s.textDim,o=p=>({"ground-truth":"🔴 Ground Truth",signal:"🟡 Signal",evidence:"🔵 Evidence",framework:"🟢 Framework",guideline:"📏 Guideline",hypothesis:"🟣 Hypothesis"})[p]||p,i=p=>{const y={direct:{background:"#2ecc71",color:"#fff"},"parent-expansion":{background:"#f1c40f",color:"#333"},"sibling-coherence":{background:"#3498db",color:"#fff"},unknown:{background:s.border,color:s.textDim}};return y[p]||y.unknown},l=p=>({direct:"● Direct match","parent-expansion":"↑ Parent expanded","sibling-coherence":"↔ Sibling context",unknown:"? Unknown"})[p]||p,c=p=>({direct:"●","parent-expansion":"↑","sibling-coherence":"↔",unknown:"?"})[p]||"?",d=Array.from(n.keys()),u=t.chunks.length,m=t.chunks.reduce((p,y)=>p+y.tokens,0);return e.jsxs("div",{style:{maxHeight:400,overflowY:"auto",padding:12,fontFamily:"'Geist Mono', monospace",fontSize:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12,paddingBottom:8,borderBottom:`1px solid ${s.border}30`},children:[e.jsx("span",{style:{fontSize:10,color:s.textDim,textTransform:"uppercase",fontWeight:700},children:"Retrieved Context"}),e.jsxs("span",{style:{fontSize:10,color:s.textDim},children:[u," chunks selected → ",m.toLocaleString()," tokens sent to LLM"]}),e.jsxs("span",{style:{fontSize:10,color:s.textDim,marginLeft:"auto"},children:["Budget: ",t.budgetUsed.toLocaleString()," / ",t.budgetTotal.toLocaleString()," tokens"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:10},children:d.map((p,y)=>{const b=n.get(p)||[],g=b.reduce((S,C)=>S+C.tokens,0),j=b[0]?.knowledgeType||"signal",F=b.reduce((S,C)=>{const P=C.inclusionReason||"unknown";return S[P]=(S[P]||0)+1,S},{});return e.jsxs("div",{style:{width:280,border:`1px solid ${s.border}40`,borderRadius:8,padding:10,background:s.isDark?"#ffffff04":"#00000003"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:r(j),flexShrink:0}}),e.jsx("div",{style:{fontSize:12,fontWeight:600,color:s.textPrimary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:p.split("/").pop()||p}),e.jsxs("span",{style:{fontSize:10,color:"#FE5000",fontWeight:600,flexShrink:0},children:[g.toLocaleString()," tok"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[e.jsx("span",{style:{fontSize:9,color:s.textDim},children:o(j)}),e.jsxs("span",{style:{fontSize:9,color:s.textDim,marginLeft:"auto"},children:[b.length," chunk",b.length>1?"s":""]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginBottom:8},children:Object.entries(F).map(([S,C])=>e.jsxs("span",{title:l(S),style:{fontSize:9,padding:"2px 5px",borderRadius:3,...i(S)},children:[c(S)," ",C]},S))}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[b.sort((S,C)=>C.relevanceScore-S.relevanceScore).slice(0,5).map((S,C)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("div",{style:{width:20,height:3,borderRadius:1,background:"#333",overflow:"hidden",flexShrink:0},children:e.jsx("div",{style:{width:`${S.relevanceScore*100}%`,height:"100%",background:"#2ecc71"}})}),e.jsxs("span",{style:{fontSize:9,width:22,textAlign:"right",color:s.textDim,flexShrink:0},children:[(S.relevanceScore*100).toFixed(0),"%"]}),e.jsx("span",{style:{fontSize:10,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:s.textPrimary},children:S.section}),e.jsx("span",{style:{fontSize:8,color:s.textFaint,flexShrink:0},children:S.tokens})]},C)),b.length>5&&e.jsxs("span",{style:{fontSize:9,color:s.textDim,paddingTop:2},children:["+",b.length-5," more"]})]})]},y)})}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12,paddingTop:8,borderTop:`1px solid ${s.border}30`,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:9,color:s.textDim,fontWeight:600},children:"HOW CHUNKS ARE SELECTED:"}),[{icon:"●",label:"Direct match (semantic similarity)",color:"#2ecc71"},{icon:"↑",label:"Parent expanded (tree context)",color:"#f1c40f"},{icon:"↔",label:"Sibling coherence (related sections)",color:"#3498db"}].map(p=>e.jsxs("span",{style:{fontSize:9,color:p.color,display:"flex",alignItems:"center",gap:3},children:[e.jsx("span",{style:{fontWeight:700},children:p.icon})," ",p.label]},p.icon))]})]})}function qt(){const t=w(),s=D(m=>m.lastPipelineStats),[n,r]=h.useState(!1);if(!s)return null;const o=s.pipeline,i=m=>m>=1e3?`${(m/1e3).toFixed(1)}K`:`${m}`,l=["#2ecc71","#3498db","#f1c40f","#e67e22","#999"],c=["Full","Detail","Summary","Headlines","Mention"],d=m=>m>.5?"#2ecc71":m>.3?"#f1c40f":"#e74c3c",u=m=>{switch(m){case"factual":return"#3498db";case"analytical":return"#e67e22";case"exploratory":return"#9b59b6";default:return t.textDim}};return e.jsxs("div",{style:{borderTop:`1px solid ${t.border}`},children:[s.retrieval&&e.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5",style:{fontFamily:"'Geist Mono', monospace",fontSize:11,borderBottom:`1px solid ${t.border}30`},children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{color:t.textDim},children:"Diversity"}),e.jsx("div",{style:{width:40,height:4,borderRadius:2,background:"#333",overflow:"hidden"},children:e.jsx("div",{style:{width:`${s.retrieval.diversityScore*100}%`,height:"100%",background:d(s.retrieval.diversityScore),borderRadius:2}})}),e.jsxs("span",{style:{fontFamily:"'Geist Mono', monospace",color:d(s.retrieval.diversityScore),fontSize:11},children:[(s.retrieval.diversityScore*100).toFixed(0),"%"]})]}),e.jsxs("span",{style:{color:t.textDim},children:[s.retrieval.selectedChunks,"/",s.retrieval.totalChunks," chunks"]}),e.jsxs("span",{style:{color:t.textDim},children:["Budget ",Math.round(s.retrieval.budgetUsed/s.retrieval.budgetTotal*100),"%"]}),e.jsx("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,background:u(s.retrieval.queryType)+"15",color:u(s.retrieval.queryType)},children:s.retrieval.queryType}),e.jsxs("span",{style:{fontSize:11,color:t.textFaint,marginLeft:"auto"},children:[s.retrieval.embeddingMs+s.retrieval.retrievalMs,"ms"]}),s.retrieval.collapseWarning&&e.jsx("span",{style:{fontSize:11,color:"#e74c3c"},children:"⚠ Low diversity"})]}),e.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex items-center gap-3 px-4 py-1.5 text-[13px] w-full border-none cursor-pointer min-h-[44px]",style:{fontFamily:"'Geist Mono', monospace",color:t.textDim,background:"transparent",transition:"background-color 150ms"},onMouseEnter:m=>{m.currentTarget.style.background=t.isDark?"#ffffff08":"#00000005"},onMouseLeave:m=>{m.currentTarget.style.background="transparent"},"aria-label":"Toggle pipeline statistics","aria-expanded":n,children:[e.jsx(be,{size:9,style:{color:"#FE5000",flexShrink:0}}),e.jsxs("span",{title:"Total context tokens sent to LLM",children:["Context: ",i(s.totalContextTokens)]}),e.jsxs("span",{title:"System prompt tokens (persona + instructions)",children:["System: ",i(s.systemTokens)]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{title:"How much the knowledge was compressed before sending",style:{color:o.compression.ratio<.8?"#2ecc71":t.textDim},children:["Compressed: ",Math.round((1-o.compression.ratio)*100),"%"]}),e.jsxs("span",{title:"Number of knowledge sources indexed",children:[o.sources.length," source",o.sources.length!==1?"s":""]}),e.jsxs("span",{title:"Pipeline processing time",children:[o.timing.totalMs,"ms"]})]}),e.jsx(W,{size:8,style:{transform:n?"none":"rotate(-90deg)",transition:"transform 150ms"}})]}),n&&e.jsx("div",{style:{maxHeight:280,overflowY:"auto",borderBottom:`1px solid ${t.border}30`},children:s.retrieval?e.jsx(Ht,{retrieval:s.retrieval}):s.heatmap.length>0&&e.jsx("div",{className:"px-4 pb-2 flex flex-col gap-2",children:s.heatmap.map(m=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-[12px] font-medium",style:{color:t.textPrimary},children:m.name}),e.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded",style:{fontFamily:"'Geist Mono', monospace",background:l[m.depth]+"18",color:l[m.depth]},children:c[m.depth]}),e.jsxs("span",{className:"text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:t.textFaint},children:[i(m.filteredTokens),"/",i(m.totalTokens)]})]}),m.headings.length>0&&e.jsxs("div",{className:"flex flex-col gap-0.5 pl-2",children:[m.headings.slice(0,8).map(p=>{const y=Math.max(...m.headings.map(j=>j.tokens),1),b=Math.max(5,p.tokens/y*100),g=l[Math.min(p.depth,4)];return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] truncate w-20 text-right",style:{fontFamily:"'Geist Mono', monospace",color:t.textFaint},children:p.title}),e.jsx("div",{style:{flex:1,height:3,background:`${g}18`,borderRadius:1,overflow:"hidden"},children:e.jsx("div",{style:{width:`${b}%`,height:"100%",background:g,borderRadius:1}})}),e.jsx("span",{className:"text-[8px] w-6 text-right",style:{fontFamily:"'Geist Mono', monospace",color:t.textFaint},children:i(p.tokens)})]},p.nodeId)}),m.headings.length>8&&e.jsxs("span",{className:"text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:t.textFaint},children:["+",m.headings.length-8," more"]})]})]},m.path))})})]})}function Kt(){const t=w(),s=D(a=>a.messages),n=D(a=>a.inputText),r=D(a=>a.setInputText),o=D(a=>a.streaming),i=D(a=>a.addMessage),l=D(a=>a.setStreaming),c=D(a=>a.updateLastAssistant),d=D(a=>a.setLastPipelineStats),u=I(a=>a.channels),m=I(a=>a.connectors),p=I(a=>a.mcpServers),y=I(a=>a.agentMeta),b=I(a=>a.navigationMode),g=(()=>{const a=["streaming"];return m.length>0&&a.push("toolCalling"),p.length>0&&a.push("mcpBridge"),a})(),j=fe(),F=At(j.providerId||"custom"),S=h.useRef(null);h.useEffect(()=>{const a=window.matchMedia("(prefers-reduced-motion: reduce)").matches;S.current?.scrollIntoView({behavior:a?"auto":"smooth"})},[s]);const C=h.useCallback(async()=>{if(!n.trim()||o)return;const a=n.trim();r(""),i({role:"user",content:a}),i({role:"assistant",content:""}),l(!0);let f="";try{const{providerId:N,model:x,error:k}=fe();if(k){c(k),l(!1);return}await Ve({userMessage:a,channels:u,connectors:m,history:s.filter(v=>!(v.role==="assistant"&&v.content.trim()==="")).map(v=>({role:v.role,content:v.content})),agentMeta:{name:y.name,description:y.description,avatar:y.avatar,tags:y.tags},providerId:N,model:x,navigationMode:b,onChunk:v=>{f+=v,c(f)},onDone:v=>{d(v);const H=D.getState().messages,q=[...H].reverse().find($=>$.role==="assistant");q&&D.setState({messages:H.map($=>$.id===q.id?{...$,pipelineStats:v,traceId:v.traceId}:$)})},onError:v=>{c(f+`
|
|
22
|
+
|
|
23
|
+
_Error: ${v.message}_`)}})}catch(N){c(f+`
|
|
24
|
+
|
|
25
|
+
_Error: ${N instanceof Error?N.message:"Unknown error"}_`)}finally{l(!1)}},[n,o,s,u,m,y,b,r,i,l,c,d]),P=a=>{(a.metaKey||a.ctrlKey)&&a.key==="Enter"&&(a.preventDefault(),C())};return e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-3 flex flex-col gap-3","aria-live":"polite","aria-relevant":"additions",children:[s.length===0&&e.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:e.jsxs("div",{className:"max-w-md text-center space-y-4",children:[e.jsx("div",{className:"text-[16px] font-semibold",style:{color:t.textPrimary,fontFamily:"'Geist Mono', monospace"},children:"Ready to test your agent"}),e.jsx("div",{className:"text-[13px] leading-relaxed",style:{color:t.textDim},children:"Start a conversation to see how your agent responds with the current knowledge and configuration."}),e.jsxs("div",{className:"flex flex-wrap gap-2 justify-center mt-6",children:[e.jsx("button",{type:"button",onClick:()=>r("What is this codebase about?"),title:"Ask about codebase",className:"px-3 py-2 rounded-lg border cursor-pointer text-[12px] hover:border-[#FE5000] transition-colors",style:{background:t.surface,border:`1px solid ${t.border}`,color:t.textSecondary,fontFamily:"'Geist Mono', monospace"},children:"What is this codebase about?"}),e.jsx("button",{type:"button",onClick:()=>r("Explain the main architecture"),title:"Ask about architecture",className:"px-3 py-2 rounded-lg border cursor-pointer text-[12px] hover:border-[#FE5000] transition-colors",style:{background:t.surface,border:`1px solid ${t.border}`,color:t.textSecondary,fontFamily:"'Geist Mono', monospace"},children:"Explain the main architecture"}),e.jsx("button",{type:"button",onClick:()=>r("What are the key features?"),title:"Ask about features",className:"px-3 py-2 rounded-lg border cursor-pointer text-[12px] hover:border-[#FE5000] transition-colors",style:{background:t.surface,border:`1px solid ${t.border}`,color:t.textSecondary,fontFamily:"'Geist Mono', monospace"},children:"What are the key features?"})]})]})}),s.map(a=>e.jsxs("div",{className:"max-w-[85%] px-3.5 py-2.5 rounded-xl text-[14px] leading-relaxed",style:{alignSelf:a.role==="user"?"flex-end":"flex-start",background:a.role==="user"?"#FE500015":t.isDark?"#1c1c20":"#f0f0f5",border:`1px solid ${a.role==="user"?"#FE500020":t.border}`,color:a.role==="user"?t.textPrimary:t.textSecondary,borderBottomRightRadius:a.role==="user"?4:12,borderBottomLeftRadius:a.role==="assistant"?4:12},children:[a.role==="assistant"?e.jsx(wt,{remarkPlugins:[Ct],components:{pre:({children:f})=>e.jsx("pre",{style:{background:t.isDark?"#0d0d10":"#e8e8f0",borderRadius:6,padding:"8px 12px",overflowX:"auto",fontSize:13,margin:"8px 0"},children:f}),code:({children:f,className:N})=>!N?e.jsx("code",{style:{background:t.isDark?"#0d0d10":"#e8e8f0",borderRadius:3,padding:"1px 4px",fontSize:13},children:f}):e.jsx("code",{style:{fontFamily:"'Geist Mono', monospace"},children:f}),a:({href:f,children:N})=>e.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",style:{color:"#FE5000",textDecoration:"underline"},children:N}),h1:({children:f})=>e.jsx("h1",{style:{fontSize:16,fontWeight:600,margin:"8px 0 4px"},children:f}),h2:({children:f})=>e.jsx("h2",{style:{fontSize:15,fontWeight:600,margin:"8px 0 4px"},children:f}),h3:({children:f})=>e.jsx("h3",{style:{fontSize:14,fontWeight:600,margin:"6px 0 2px"},children:f}),ul:({children:f})=>e.jsx("ul",{style:{paddingLeft:20,margin:"4px 0"},children:f}),ol:({children:f})=>e.jsx("ol",{style:{paddingLeft:20,margin:"4px 0"},children:f}),li:({children:f})=>e.jsx("li",{style:{marginBottom:2},children:f}),blockquote:({children:f})=>e.jsx("blockquote",{style:{borderLeft:"3px solid #FE5000",paddingLeft:12,margin:"8px 0",color:t.textDim},children:f}),table:({children:f})=>e.jsx("table",{style:{borderCollapse:"collapse",width:"100%",margin:"8px 0",fontSize:13},children:f}),th:({children:f})=>e.jsx("th",{style:{border:`1px solid ${t.border}`,padding:"4px 8px",textAlign:"left",fontWeight:600},children:f}),td:({children:f})=>e.jsx("td",{style:{border:`1px solid ${t.border}`,padding:"4px 8px"},children:f})},children:a.content||(o?"...":"")}):a.content||"",a.role==="assistant"&&a.pipelineStats&&e.jsx(Lt,{stats:a.pipelineStats,traceId:a.traceId})]},a.id)),e.jsx("div",{ref:S})]}),g.length>0&&e.jsx("div",{className:"px-4 py-1.5",children:e.jsx(_t,{matrix:F,requiredCapabilities:g})}),e.jsx(qt,{}),e.jsxs("div",{className:"px-4 py-3 flex gap-2",style:{borderTop:`1px solid ${t.border}`},children:[e.jsx("input",{type:"text",value:n,onChange:a=>r(a.target.value),onKeyDown:P,placeholder:"Test your agent...","aria-label":"Test message",className:"flex-1 px-3.5 py-2.5 rounded-lg outline-none text-[14px]",style:{background:t.inputBg,border:`1px solid ${t.border}`,color:t.textPrimary,fontFamily:"'Geist Sans', sans-serif"}}),e.jsx("button",{type:"button","aria-label":"Send message",title:"Send message",onClick:C,disabled:o||!n.trim(),className:"px-4 rounded-lg cursor-pointer border-none text-[12px] font-semibold tracking-wider uppercase min-h-[44px] min-w-[44px]",style:{background:"#FE5000",color:"#fff",fontFamily:"'Geist Mono', monospace",opacity:o||!n.trim()?.5:1},children:e.jsx(it,{size:12})})]})]})}function Yt(){const t=w(),[s,n]=h.useState([{id:"agent-1",name:"Agent 1",rolePrompt:"",repoUrl:"",source:"blank"},{id:"agent-2",name:"Agent 2",rolePrompt:"",repoUrl:"",source:"blank"}]),[r,o]=h.useState(""),[i,l]=h.useState([]),[c,d]=h.useState(null),u=h.useRef(null),m=B(x=>x.status),p=B(x=>x.reset),y=m==="running";h.useEffect(()=>{fetch(`${we}/agents`).then(x=>x.ok?x.json():{data:[]}).then(x=>{const k=x.data??x??[];l(k.map(v=>({id:v.id,name:v.agentMeta?.name||v.id,description:v.agentMeta?.description||""})))}).catch(()=>{})},[]);const b=()=>{const x=s.length+1;n([...s,{id:`agent-${Date.now()}`,name:`Agent ${x}`,rolePrompt:"",repoUrl:"",source:"blank"}])},g=async(x,k)=>{try{const v=await fetch(`${we}/agents/${encodeURIComponent(k)}`);if(!v.ok)return;const H=await v.json(),q=H.data??H,$=q.agentMeta??{},E=[],R=q.instructionState??{};$.name&&E.push(`You are ${$.name}. ${$.description||""}`),R.persona&&E.push(`Persona: ${R.persona}`),R.objectives?.primary&&E.push(`Primary Objective: ${R.objectives.primary}`),R.constraints?.customConstraints&&E.push(`Constraints: ${R.constraints.customConstraints}`);const V=E.join(`
|
|
26
|
+
|
|
27
|
+
`);n(A=>A.map(Z=>Z.id===x?{...Z,name:$.name||k,savedSystemPrompt:V,source:k}:Z))}catch{}d(null)},j=x=>{s.length<=1||n(s.filter(k=>k.id!==x))},F=(x,k)=>{n(s.map(v=>v.id===x?{...v,...k}:v))},[S,C]=h.useState(null),[P,a]=h.useState(null),f=h.useCallback(async()=>{if(!r.trim()||y)return;C(null),a(null);const{providerId:x,model:k,error:v}=fe();if(v){C(v),console.error("[TeamRunner] Provider error:",v);return}const $=he.getState().providers.find(E=>E.id===x)?.authMethod==="claude-agent-sdk";try{const E=O.getState(),R=Ze.getState(),V=D.getState(),A=R.currentVersion||"0.0.0",Z=V.conversationId||`conv-${Date.now()}`,te=E.startTrace(Z,A),J=M=>{E.addEvent(te,M)},He=Date.now();let se=pe();J({kind:"retrieval",sourceName:"System Frame",query:"identity + constraints + workflow",resultCount:1,durationMs:Date.now()-He});const ve=I.getState(),oe=ve.channels,X=oe.filter(M=>M.enabled);let K="",ke="",ie=null;if(X.length>0){a("Preparing knowledge...");const M=Date.now(),z=await Je(X,te);ke=z.frameworkBlock,J({kind:"retrieval",sourceName:"Source Router",query:`${X.length} channels`,resultCount:z.regularChannels?.length??0,durationMs:Date.now()-M});const _=Date.now(),G=await Xe(oe,z.regularChannels,z.residualKnowledgeBlock,{userMessage:r,navigationMode:"manual",providerId:x,model:k},te);K=G.knowledgeBlock,ie=G.provenance,J({kind:"retrieval",sourceName:"Knowledge Pipeline",query:r.substring(0,80),resultCount:X.length,durationMs:Date.now()-_})}const Se=ve.connectors.filter(M=>M.enabled&&M.direction!=="write");if(Se.length>0){const z=`<connectors>
|
|
28
|
+
Available data connectors (use via MCP tools):
|
|
29
|
+
${Se.map(_=>{const G=_.hint?` (scope: ${_.hint})`:"";return`- ${_.name} [${_.service}] — ${_.direction}${G}`}).join(`
|
|
30
|
+
`)}
|
|
31
|
+
</connectors>`;K=K?`${K}
|
|
32
|
+
|
|
33
|
+
${z}`:z}const qe=Qe.getState();let ce="";if(qe.longTerm.enabled){a("Recalling memory...");const M=Date.now(),z=await et({userMessage:r,agentId:"team",traceId:te});z.contextBlock&&(ce=z.contextBlock),J({kind:"retrieval",sourceName:"Memory Recall",query:r.substring(0,80),durationMs:Date.now()-M})}if(ie&&(se=pe(ie)),X.length>0||K||ce){const M=tt(oe,st.getState().getIndex),z=oe.some(G=>G.enabled&&G.repoMeta);se=ot({frame:se,orientationBlock:M,hasRepos:z,knowledgeFormatGuide:nt(),frameworkBlock:ke,memoryBlock:ce,knowledgeBlock:K})}J({kind:"llm_call",model:k,sourceName:"LLM Request"}),a("Running team..."),C(null);const Ke={teamId:`team-${Date.now()}`,systemPrompt:se,task:r.trim(),providerId:x,model:k,isAgentSdk:$,agents:s.map(M=>({agentId:M.id,name:M.name,systemPrompt:M.savedSystemPrompt||void 0,rolePrompt:M.rolePrompt||void 0,repoUrl:M.repoUrl||void 0}))};u.current=Ce(Ke),a(null)}catch(E){console.error("[TeamRunner] Knowledge pipeline error:",E),a(null),C(`Knowledge pipeline error: ${E instanceof Error?E.message:"Unknown error"}`);const R=pe(),V={teamId:`team-${Date.now()}`,systemPrompt:R,task:r.trim(),providerId:x,model:k,isAgentSdk:$,agents:s.map(A=>({agentId:A.id,name:A.name,systemPrompt:A.savedSystemPrompt||void 0,rolePrompt:A.rolePrompt||void 0,repoUrl:A.repoUrl||void 0}))};u.current=Ce(V),a(null)}},[r,s,y]),N=()=>{u.current?.abort(),u.current=null};return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"px-4 py-3 flex flex-col gap-2 overflow-y-auto",style:{maxHeight:"45%"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("span",{className:"text-[12px] font-bold tracking-[0.08em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:t.textDim},children:["Team Agents (",s.length,")"]}),e.jsxs("button",{type:"button",onClick:b,disabled:s.length>=5,className:"flex items-center gap-1 text-[12px] px-2 py-1 rounded cursor-pointer border-none",style:{background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace",opacity:s.length>=5?.4:1},children:[e.jsx(ct,{size:10})," Add"]})]}),s.map(x=>e.jsxs("div",{style:{padding:10,borderRadius:8,border:`1px solid ${x.source!=="blank"?"#FE500030":t.border}`,background:t.surface},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(dt,{size:12,style:{color:x.source!=="blank"?"#FE5000":t.textDim}}),e.jsx("input",{type:"text",value:x.name,onChange:k=>F(x.id,{name:k.target.value}),className:"flex-1 text-[13px] font-semibold px-1.5 py-0.5 rounded outline-none border-none",style:{background:"transparent",color:t.textPrimary,fontFamily:"'Geist Mono', monospace"}}),e.jsx("button",{type:"button",onClick:()=>d(c===x.id?null:x.id),className:"text-[11px] px-2 py-0.5 rounded cursor-pointer border-none",style:{background:"#FE500010",color:"#FE5000",fontFamily:"'Geist Mono', monospace"},children:x.source!=="blank"?"↻ Swap":"↗ Load"}),s.length>1&&e.jsx("button",{type:"button",onClick:()=>j(x.id),className:"border-none cursor-pointer p-0.5 rounded",style:{background:"transparent",color:t.textDim},children:e.jsx(pt,{size:12})})]}),c===x.id&&i.length>0&&e.jsxs("div",{className:"mb-2 flex flex-col gap-1 p-2 rounded",style:{background:t.inputBg,border:`1px solid ${t.border}`},children:[e.jsx("span",{className:"text-[11px] uppercase font-bold tracking-[0.08em] mb-1",style:{color:t.textDim,fontFamily:"'Geist Mono', monospace"},children:"Load from library"}),i.map(k=>e.jsxs("button",{type:"button",onClick:()=>g(x.id,k.id),className:"text-left text-[12px] px-2 py-1.5 rounded cursor-pointer border-none w-full",style:{background:"transparent",color:t.textPrimary},onMouseEnter:v=>{v.currentTarget.style.background=t.surfaceHover},onMouseLeave:v=>{v.currentTarget.style.background="transparent"},children:[e.jsx("span",{style:{fontWeight:600},children:k.name}),k.description&&e.jsxs("span",{style:{color:t.textDim,marginLeft:6},children:["— ",k.description.slice(0,40)]})]},k.id)),i.length===0&&e.jsx("span",{className:"text-[12px]",style:{color:t.textFaint},children:"No saved agents. Save one from the Agent Builder first."})]}),x.source!=="blank"&&e.jsx("div",{className:"mb-1.5",children:e.jsxs("span",{className:"text-[11px] px-1.5 py-0.5 rounded",style:{background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace"},children:["↗ ",x.source]})}),e.jsx("input",{type:"text",value:x.rolePrompt,onChange:k=>F(x.id,{rolePrompt:k.target.value}),placeholder:"Role override (optional — appended to agent instructions)",className:"w-full text-[12px] px-2 py-1.5 rounded outline-none mb-1.5",style:{background:t.inputBg,border:`1px solid ${t.borderSubtle}`,color:t.textSecondary}}),e.jsx("input",{type:"text",value:x.repoUrl,onChange:k=>F(x.id,{repoUrl:k.target.value}),placeholder:"Repository URL (optional — e.g., https://github.com/user/repo)",className:"w-full text-[12px] px-2 py-1.5 rounded outline-none",style:{background:t.inputBg,border:`1px solid ${t.borderSubtle}`,color:t.textSecondary}})]},x.id))]}),e.jsxs("div",{className:"px-4 py-2",style:{borderTop:`1px solid ${t.border}`},children:[e.jsx("textarea",{value:r,onChange:x=>o(x.target.value),placeholder:"Describe the task for the team...",rows:3,className:"w-full text-[13px] px-3 py-2.5 rounded-lg outline-none resize-none",style:{background:t.inputBg,border:`1px solid ${t.border}`,color:t.textPrimary,lineHeight:1.5}}),P&&e.jsx("div",{className:"text-[12px] px-3 py-2 rounded mb-2",style:{background:"#10b98115",color:"#10b981",border:"1px solid #10b98130"},children:P}),S&&e.jsx("div",{className:"text-[12px] px-3 py-2 rounded mb-2",style:{background:"#dc262615",color:"#dc2626",border:"1px solid #dc262630"},children:S}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[y?e.jsxs("button",{type:"button",onClick:N,className:"flex items-center gap-1.5 px-4 py-2 rounded-lg cursor-pointer border-none text-[12px] font-bold tracking-[0.08em] uppercase min-h-[44px]",style:{background:"#dc2626",color:"#fff",fontFamily:"'Geist Mono', monospace"},children:[e.jsx(mt,{size:12})," Stop"]}):e.jsxs("button",{type:"button",onClick:f,disabled:!r.trim(),className:"flex items-center gap-1.5 px-4 py-2 rounded-lg cursor-pointer border-none text-[12px] font-bold tracking-[0.08em] uppercase min-h-[44px]",style:{background:"#FE5000",color:"#fff",fontFamily:"'Geist Mono', monospace",opacity:r.trim()?1:.5},children:[e.jsx(ut,{size:12})," Run Team"]}),m!=="idle"&&!y&&e.jsx("button",{type:"button",onClick:p,className:"text-[12px] px-3 py-2 rounded-lg cursor-pointer border-none",style:{background:t.border,color:t.textDim},children:"Clear"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3",style:{borderTop:`1px solid ${t.border}`},children:e.jsx(Ut,{})})]})}function Vt(){const t=w(),[s,n]=h.useState(null),[r,o]=h.useState(!1),[i,l]=h.useState(null),[c,d]=h.useState(!1),u=h.useRef(null),m=h.useCallback(()=>{const a=I.getState();return{channels:a.channels,selectedModel:a.selectedModel,outputFormat:a.outputFormat,outputFormats:a.outputFormats,prompt:a.prompt,tokenBudget:a.tokenBudget,mcpServers:a.mcpServers,skills:a.skills,agentMeta:a.agentMeta,agentConfig:a.agentConfig,connectors:a.connectors,instructionState:a.instructionState,workflowSteps:a.workflowSteps}},[]),p=h.useCallback(async()=>{try{const{downloadAgentDirectory:a}=await le(async()=>{const{downloadAgentDirectory:f}=await Promise.resolve().then(()=>zt);return{downloadAgentDirectory:f}},void 0);await a(m()),n("dir"),setTimeout(()=>n(null),2e3)}catch(a){console.error("Directory export failed:",a)}},[m]),y=h.useCallback(async a=>{try{const f=m();let N,x;a==="md"?(N=de("claude",f),x=".md"):a==="yaml"?(N=de("openclaw",f),x=".yaml"):(N=de("generic",f),x=".json");const k=(f.agentMeta.name||"modular-agent").toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");Ye(N,k,x),await navigator.clipboard.writeText(N),n(a),setTimeout(()=>n(null),2e3)}catch{}},[m]),b=h.useCallback(async a=>{if(!a.name.endsWith(".zip")){l("Please select a ZIP file containing an agent directory");return}o(!0),l(null);try{await We(a),n("import"),setTimeout(()=>n(null),2e3)}catch(f){const N=f instanceof Error?f.message:"Unknown import error";l(N),setTimeout(()=>l(null),5e3)}finally{o(!1)}},[]),g=h.useCallback(()=>{u.current?.click()},[]),j=h.useCallback(a=>{const f=a.target.files?.[0];f&&b(f),a.target&&(a.target.value="")},[b]),F=h.useCallback(a=>{a.preventDefault(),a.stopPropagation(),d(!0)},[]),S=h.useCallback(a=>{a.preventDefault(),a.stopPropagation(),d(!1)},[]),C=h.useCallback(a=>{a.preventDefault(),a.stopPropagation(),d(!1);const N=Array.from(a.dataTransfer.files).find(x=>x.name.endsWith(".zip"));if(!N){l("Please drop a ZIP file containing an agent directory"),setTimeout(()=>l(null),5e3);return}b(N)},[b]),P=[{id:"dir",icon:ht,label:"Agent Directory",fmt:".zip",primary:!0},{id:"md",icon:Ie,label:"Claude Code / .claude",fmt:".md",primary:!1},{id:"yaml",icon:yt,label:"OpenClaw Agent",fmt:".yaml",primary:!1},{id:"json",icon:gt,label:"Vibe Kanban / BloopAI",fmt:".json",primary:!1}];return e.jsxs("div",{className:"px-4 py-3",style:{borderTop:`1px solid ${t.border}`},onDragOver:F,onDragLeave:S,onDrop:C,children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"text-[12px] font-bold tracking-[0.08em] uppercase mb-2.5",style:{fontFamily:"'Geist Mono', monospace",color:t.textDim},children:"Import from"}),e.jsxs("button",{type:"button","aria-label":"Import agent from ZIP",onClick:g,disabled:r,className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg cursor-pointer w-full text-left min-h-[44px] motion-reduce:transition-none",style:{background:c?"#FE500020":"#FE500010",border:`1px solid ${c?"#FE500060":"#FE500030"}`,transition:"all 150ms",opacity:r?.6:1},onMouseEnter:a=>{r||(a.currentTarget.style.borderColor="#FE500040")},onMouseLeave:a=>{r||(a.currentTarget.style.borderColor="#FE500030")},onFocus:a=>{r||(a.currentTarget.style.borderColor="#FE500040")},onBlur:a=>{r||(a.currentTarget.style.borderColor="#FE500030")},children:[e.jsx("div",{className:"w-6 h-6 rounded flex items-center justify-center",style:{background:t.surfaceElevated},children:s==="import"?e.jsx(ye,{size:12,style:{color:"#00ff88"}}):r?e.jsx("div",{className:"w-3 h-3 border border-t-0 border-l-0",style:{borderColor:"#FE5000",borderRadius:"50%",animation:"spin 1s linear infinite"}}):e.jsx(xt,{size:12,style:{color:t.textDim}})}),e.jsx("span",{className:"flex-1 text-[13px]",style:{color:t.textPrimary},children:c?"Drop ZIP file here":r?"Importing...":"Import Agent"}),e.jsx("span",{className:"text-[13px]",style:{fontFamily:"'Geist Mono', monospace",color:t.textDim},children:".zip"})]}),i&&e.jsxs("div",{className:"mt-2 p-2 rounded-lg flex items-start gap-2",style:{background:"#dc262615",border:"1px solid #dc262630"},children:[e.jsx(ft,{size:14,style:{color:"#dc2626",flexShrink:0,marginTop:1}}),e.jsx("span",{className:"text-[12px] leading-relaxed",style:{color:"#dc2626"},children:i})]}),e.jsx("input",{ref:u,type:"file",accept:".zip",style:{display:"none"},onChange:j,"aria-label":"Import agent ZIP file"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-bold tracking-[0.08em] uppercase mb-2.5",style:{fontFamily:"'Geist Mono', monospace",color:t.textDim},children:"Export to"}),e.jsx("div",{className:"flex flex-col gap-1.5",children:P.map(a=>{const f=a.icon,N=a.id==="dir"?p:()=>y(a.id);return e.jsxs("button",{type:"button","aria-label":`Export as ${a.fmt}`,onClick:N,className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg cursor-pointer w-full text-left min-h-[44px] motion-reduce:transition-none",style:{background:a.primary?"#FE500010":t.isDark?"#1c1c20":"#f0f0f5",border:`1px solid ${a.primary?"#FE500030":t.border}`,transition:"border-color 150ms"},onMouseEnter:x=>{x.currentTarget.style.borderColor="#FE500040"},onMouseLeave:x=>{x.currentTarget.style.borderColor=t.border},onFocus:x=>{x.currentTarget.style.borderColor="#FE500040"},onBlur:x=>{x.currentTarget.style.borderColor=t.border},children:[e.jsx("div",{className:"w-6 h-6 rounded flex items-center justify-center",style:{background:t.surfaceElevated},children:s===a.id?e.jsx(ye,{size:12,style:{color:"#00ff88"}}):e.jsx(f,{size:12,style:{color:t.textDim}})}),e.jsx("span",{className:"flex-1 text-[13px]",style:{color:t.textPrimary},children:a.label}),e.jsx("span",{className:"text-[13px]",style:{fontFamily:"'Geist Mono', monospace",color:t.textDim},children:a.fmt})]},a.id)})})]})]})}function re({onCollapse:t,onExpand:s,onMinimize:n,isExpanded:r}){const o=w(),[i,l]=h.useState("chat");return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3",style:{borderBottom:`1px solid ${o.border}`},children:[e.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"#00ff88",boxShadow:"0 0 6px rgba(0,255,136,0.4)"}}),e.jsx("span",{className:"text-[12px] font-bold tracking-[0.08em] uppercase flex-1",style:{fontFamily:"'Geist Mono', monospace",color:o.textSecondary},children:i==="chat"?"Conversation Tester":i==="team"?"Team Runner":i==="traces"?"Execution Traces":"Export"}),e.jsxs("div",{className:"flex gap-0.5 rounded-md overflow-hidden",role:"tablist",style:{border:`1px solid ${o.border}`},children:[e.jsx("button",{type:"button",role:"tab",id:"tab-chat","aria-selected":i==="chat","aria-controls":"tabpanel-chat",onClick:()=>l("chat"),title:"Chat with agent",className:"text-[13px] px-2.5 py-2 cursor-pointer border-none min-h-[44px]",style:{background:i==="chat"?"#FE5000":"transparent",color:i==="chat"?"#fff":o.textDim,fontFamily:"'Geist Mono', monospace"},children:"Chat"}),e.jsx("button",{type:"button",role:"tab",id:"tab-team","aria-selected":i==="team","aria-controls":"tabpanel-team",onClick:()=>l("team"),title:"Run team mode",className:"text-[13px] px-2.5 py-2 cursor-pointer border-none min-h-[44px]",style:{background:i==="team"?"#FE5000":"transparent",color:i==="team"?"#fff":o.textDim,fontFamily:"'Geist Mono', monospace"},children:"Team"}),e.jsx("button",{type:"button",role:"tab",id:"tab-export","aria-selected":i==="export","aria-controls":"tabpanel-export",onClick:()=>l("export"),title:"Export agent",className:"text-[13px] px-2.5 py-2 cursor-pointer border-none min-h-[44px]",style:{background:i==="export"?"#FE5000":"transparent",color:i==="export"?"#fff":o.textDim,fontFamily:"'Geist Mono', monospace"},children:"Export"})]}),r&&n&&e.jsx("button",{type:"button",onClick:n,"aria-label":"Minimize test panel",title:"Minimize panel",className:"w-7 h-7 rounded-md border-none cursor-pointer flex items-center justify-center",style:{background:"transparent",color:o.textDim},children:e.jsx(Re,{size:14})}),!r&&s&&e.jsx("button",{type:"button",onClick:s,"aria-label":"Expand test panel",title:"Expand panel",className:"w-7 h-7 rounded-md border-none cursor-pointer flex items-center justify-center",style:{background:"transparent",color:o.textDim},children:e.jsx(Ae,{size:14})}),t&&e.jsx("button",{type:"button",onClick:t,"aria-label":"Collapse test panel",title:"Collapse panel",className:"w-7 h-7 rounded-md border-none cursor-pointer flex items-center justify-center",style:{background:"transparent",color:o.textDim},children:e.jsx(U,{size:14})})]}),i==="chat"&&e.jsx("div",{role:"tabpanel",id:"tabpanel-chat","aria-labelledby":"tab-chat",className:"flex flex-col flex-1 min-h-0",children:e.jsx(Kt,{})}),i==="team"&&e.jsx("div",{role:"tabpanel",id:"tabpanel-team","aria-labelledby":"tab-team",className:"flex flex-col flex-1 min-h-0",children:e.jsx(Yt,{})}),i==="export"&&e.jsx("div",{role:"tabpanel",id:"tabpanel-export","aria-labelledby":"tab-export",className:"flex-1 overflow-y-auto",children:e.jsx(Vt,{})})]})}function Te({}){const t=w(),s=D(c=>c.lastPipelineStats),[n,r]=h.useState(!1),[o,i]=h.useState(null);h.useEffect(()=>{s&&s!==o&&i(o)},[s]);const l=(c,d)=>{if(!d||!n)return c.toString();const u=c-d,m=u>0?`+${u}`:u.toString(),p=u>0?"#22c55e":u<0?"#ef4444":t.textSecondary;return e.jsxs("span",{className:"flex items-center gap-1",children:[c,e.jsxs("span",{style:{color:p,fontSize:"10px",fontWeight:500},children:["(",m,")"]})]})};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-3 py-2 border-b flex-shrink-0",style:{borderColor:t.border,background:t.surfaceElevated,color:t.textPrimary},children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{size:14,style:{color:"#FE5000"}}),e.jsx("h3",{className:"text-sm font-medium",style:{fontFamily:"'Geist Sans', sans-serif"},children:"Context Inspector"})]}),o&&e.jsxs("button",{onClick:()=>r(!n),className:"flex items-center gap-1 px-2 py-1 rounded text-[11px] font-medium transition-colors",style:{background:n?"#FE5000":t.surfaceElevated,color:n?"white":t.textSecondary,border:`1px solid ${n?"#FE5000":t.border}`},children:[e.jsx(bt,{size:12}),"Diff"]})]})}),e.jsx("div",{className:"flex-1 overflow-auto p-3",style:{background:t.surface},children:s?e.jsxs("div",{className:"space-y-3",children:[s.pipeline&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"text-xs font-medium",style:{color:t.textPrimary},children:["Pipeline Context ",n&&o&&"(Current vs Previous)"]}),e.jsxs("div",{className:"text-[11px] space-y-1",style:{color:t.textSecondary},children:[e.jsxs("div",{children:["Total Tokens: ",l(s.totalContextTokens||0,o?.totalContextTokens)]}),e.jsxs("div",{children:["System Tokens: ",l(s.systemTokens||0,o?.systemTokens)]}),e.jsxs("div",{children:["Tool Turns: ",l(s.toolTurns||0,o?.toolTurns)]})]})]}),s.memory&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-medium",style:{color:t.textPrimary},children:"Memory"}),e.jsx("div",{className:"text-[11px] space-y-1",style:{color:t.textSecondary},children:e.jsx("div",{children:"Memory available"})})]}),s.toolCalls&&s.toolCalls.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-medium",style:{color:t.textPrimary},children:"Tool Calls"}),e.jsx("div",{className:"text-[11px] space-y-1",style:{color:t.textSecondary},children:e.jsxs("div",{children:["Count: ",l(s.toolCalls.length,o?.toolCalls?.length)]})})]}),s.retrieval&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-medium",style:{color:t.textPrimary},children:"Retrieval"}),e.jsxs("div",{className:"text-[11px] space-y-1",style:{color:t.textSecondary},children:[e.jsxs("div",{children:["Query Type: ",s.retrieval.queryType]}),e.jsxs("div",{children:["Selected Chunks: ",l(s.retrieval.selectedChunks,o?.retrieval?.selectedChunks)]}),e.jsxs("div",{children:["Budget Used: ",l(s.retrieval.budgetUsed,o?.retrieval?.budgetUsed)]}),e.jsxs("div",{children:["Diversity Score: ",s.retrieval.diversityScore.toFixed(2)]})]})]}),(s.frameworkSummary||o?.frameworkSummary)&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-medium",style:{color:t.textPrimary},children:"Framework Summary"}),e.jsxs("div",{className:"text-[11px] space-y-1",style:{color:t.textSecondary},children:[e.jsxs("div",{children:["Constraints: ",l(s.frameworkSummary?.constraints||0,o?.frameworkSummary?.constraints)]}),e.jsxs("div",{children:["Workflow Steps: ",l(s.frameworkSummary?.workflowSteps||0,o?.frameworkSummary?.workflowSteps)]}),e.jsxs("div",{children:["Tool Hints: ",l(s.frameworkSummary?.toolHints||0,o?.frameworkSummary?.toolHints)]})]})]})]}):e.jsx("div",{className:"text-center text-sm",style:{color:t.textSecondary},children:"No context data available"})})]})}function Zt(t){return typeof t=="object"&&t!==null&&Array.isArray(t.sources)}function Jt(t){return typeof t=="object"&&t!==null&&Array.isArray(t.allocations)}function Xt(t){return typeof t=="object"&&t!==null&&Array.isArray(t.chunks)}function Qt(t){return typeof t=="object"&&t!==null&&"contradictionsFound"in t}function es(t){const s=t;return typeof t=="object"&&t!==null&&Array.isArray(s.sources)&&Array.isArray(s.derivationChain)}function Y({data:t}){const s=w(),[n,r]=h.useState(!1);return e.jsxs("div",{className:"px-4 pb-2",children:[e.jsxs("button",{type:"button",onClick:()=>r(o=>!o),className:"flex items-center gap-1 text-xs border-none bg-transparent cursor-pointer",style:{color:s.textFaint},children:[e.jsx(kt,{size:11}),n?"Hide":"Show"," raw JSON"]}),n&&e.jsx("pre",{className:"mt-2 text-xs overflow-auto max-h-40 rounded p-2",style:{background:s.surfaceElevated,color:s.textDim,fontFamily:"'Geist Mono', monospace"},children:JSON.stringify(t,null,2)})]})}function ee({name:t,data:s}){const n=w();return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"px-4 py-2 text-sm",style:{color:n.textDim},children:["No data available for ",t]}),e.jsx(Y,{data:s})]})}function ts({data:t,expanded:s,onToggle:n}){const r=w(),o=Zt(t)?t:null,i=o?o.sources.filter(l=>l.included).length:0;return e.jsxs("div",{className:"border-b",style:{borderColor:r.border},children:[e.jsxs("button",{type:"button",onClick:n,title:s?"Collapse source assembly":"Expand source assembly",className:"flex items-center gap-3 w-full px-4 py-3 text-left border-none cursor-pointer",style:{background:"transparent",color:r.textPrimary},children:[e.jsx(Ie,{size:16,style:{color:"#3b82f6"}}),e.jsx("span",{className:"flex-1 font-medium",children:"Source Assembly"}),o&&e.jsxs("span",{className:"text-sm",style:{color:r.textDim,fontFamily:"'Geist Mono', monospace"},children:[i,"/",o.sources.length," sources"]}),s?e.jsx(W,{size:16}):e.jsx(U,{size:16})]}),s&&e.jsxs(e.Fragment,{children:[o?e.jsx("div",{className:"px-4 pb-4 space-y-2",children:o.sources.map((l,c)=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg",style:{background:l.included?r.surface:r.surfaceElevated,border:`1px solid ${l.included?r.border:r.borderSubtle}`},children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${l.included?"bg-green-500":"bg-gray-400"}`}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",style:{color:r.textPrimary},children:l.name}),e.jsxs("div",{className:"text-xs",style:{color:r.textDim},children:[l.type," • ",l.rawTokens.toLocaleString()," tokens"]})]}),l.reason&&e.jsx("div",{className:"text-xs px-2 py-1 rounded",style:{background:l.included?"#10b98115":"#ef444415",color:l.included?"#10b981":"#ef4444"},children:l.reason})]},c))}):e.jsx(ee,{name:"Source Assembly",data:t}),e.jsx(Y,{data:t})]})]})}function ss({data:t,expanded:s,onToggle:n}){const r=w(),o=Jt(t)?t:null,i=o?o.allocations.reduce((d,u)=>d+u.allocatedTokens,0):0,l=o?o.allocations.reduce((d,u)=>d+u.usedTokens,0):0,c=i>0?l/i*100:0;return e.jsxs("div",{className:"border-b",style:{borderColor:r.border},children:[e.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-3 w-full px-4 py-3 text-left border-none cursor-pointer",style:{background:"transparent",color:r.textPrimary},children:[e.jsx(jt,{size:16,style:{color:"#8b5cf6"}}),e.jsx("span",{className:"flex-1 font-medium",children:"Budget Allocation"}),o&&e.jsxs("span",{className:"text-sm",style:{color:r.textDim,fontFamily:"'Geist Mono', monospace"},children:[c.toFixed(0),"% utilized"]}),s?e.jsx(W,{size:16}):e.jsx(U,{size:16})]}),s&&e.jsxs(e.Fragment,{children:[o?e.jsx("div",{className:"px-4 pb-4 space-y-3",children:e.jsx("div",{className:"space-y-2",children:o.allocations.map((d,u)=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{style:{color:r.textPrimary},children:d.source}),e.jsxs("span",{style:{color:r.textDim,fontFamily:"'Geist Mono', monospace"},children:[d.usedTokens.toLocaleString(),"/",d.allocatedTokens.toLocaleString()]})]}),e.jsxs("div",{className:"flex gap-1 h-2 rounded",style:{background:r.surfaceElevated},children:[e.jsx("div",{className:"h-full rounded",style:{width:`${d.percentage}%`,background:d.cappedBySize?"#f59e0b":"#10b981"}}),e.jsx("div",{className:"h-full rounded",style:{width:`${Math.max(0,d.percentage-d.usedTokens/o.totalBudget*100)}%`,background:d.cappedBySize?"#f59e0b30":"#10b98130"}})]}),d.cappedBySize&&e.jsx("div",{className:"text-xs",style:{color:"#f59e0b"},children:"Capped by content size"})]},u))})}):e.jsx(ee,{name:"Budget Allocation",data:t}),e.jsx(Y,{data:t})]})]})}function os({data:t,expanded:s,onToggle:n}){const r=w(),o=Xt(t)?t:null,i=o?o.diversityScore>.5?"#10b981":o.diversityScore>.3?"#f59e0b":"#ef4444":r.textDim;return e.jsxs("div",{className:"border-b",style:{borderColor:r.border},children:[e.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-3 w-full px-4 py-3 text-left border-none cursor-pointer",style:{background:"transparent",color:r.textPrimary},children:[e.jsx(je,{size:16,style:{color:"#06b6d4"}}),e.jsx("span",{className:"flex-1 font-medium",children:"Retrieval"}),o&&e.jsxs("span",{className:"text-sm",style:{color:r.textDim,fontFamily:"'Geist Mono', monospace"},children:[o.selectedChunks,"/",o.totalChunks," chunks • ",(o.diversityScore*100).toFixed(0),"% diversity"]}),s?e.jsx(W,{size:16}):e.jsx(U,{size:16})]}),s&&e.jsxs(e.Fragment,{children:[o?e.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded",style:{background:r.surface},children:[e.jsx("div",{className:"text-sm font-medium",style:{color:r.textPrimary},children:"Query Type:"}),e.jsx("span",{className:"px-2 py-1 text-xs rounded",style:{background:o.queryType==="factual"?"#3b82f615":o.queryType==="analytical"?"#f59e0b15":"#8b5cf615",color:o.queryType==="factual"?"#3b82f6":o.queryType==="analytical"?"#f59e0b":"#8b5cf6"},children:o.queryType}),e.jsxs("div",{className:"ml-auto text-sm",style:{color:i},children:["Diversity: ",(o.diversityScore*100).toFixed(1),"%"]})]}),e.jsx("div",{className:"space-y-2 max-h-60 overflow-y-auto",children:o.chunks.sort((l,c)=>c.relevanceScore-l.relevanceScore).map((l,c)=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded",style:{background:r.surface},children:[e.jsxs("div",{className:"w-8 text-xs text-center",style:{color:r.textDim,fontFamily:"'Geist Mono', monospace"},children:["#",c+1]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium",style:{color:r.textPrimary},children:l.source}),e.jsx("div",{className:"text-xs",style:{color:r.textDim},children:l.section})]}),e.jsx("div",{className:"text-xs px-2 py-1 rounded",style:{background:l.inclusionReason==="direct"?"#10b98115":l.inclusionReason==="parent-expansion"?"#3b82f615":"#8b5cf615",color:l.inclusionReason==="direct"?"#10b981":l.inclusionReason==="parent-expansion"?"#3b82f6":"#8b5cf6"},children:l.inclusionReason.replace("-"," ")}),e.jsx("div",{className:"text-xs",style:{fontFamily:"'Geist Mono', monospace",color:r.textDim},children:l.relevanceScore.toFixed(2)})]},c))})]}):e.jsx(ee,{name:"Retrieval",data:t}),e.jsx(Y,{data:t})]})]})}function ns({data:t,expanded:s,onToggle:n}){const r=w(),o=Qt(t)?t:null,i=o?o.contradictionsFound>0:!1;return e.jsxs("div",{className:"border-b",style:{borderColor:r.border},children:[e.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-3 w-full px-4 py-3 text-left border-none cursor-pointer",style:{background:"transparent",color:r.textPrimary},children:[e.jsx($e,{size:16,style:{color:i?"#ef4444":"#10b981"}}),e.jsx("span",{className:"flex-1 font-medium",children:"Contradiction Check"}),o&&e.jsxs("span",{className:"text-sm",style:{color:i?"#ef4444":"#10b981",fontFamily:"'Geist Mono', monospace"},children:[o.contradictionsFound," conflicts"]}),s?e.jsx(W,{size:16}):e.jsx(U,{size:16})]}),s&&e.jsxs(e.Fragment,{children:[o?e.jsx("div",{className:"px-4 pb-4 space-y-3",children:i?e.jsxs("div",{className:"space-y-3",children:[o.conflicts.map((l,c)=>e.jsxs("div",{className:"p-3 rounded-lg border",style:{background:"#ef444415",borderColor:"#ef444430"},children:[e.jsxs("div",{className:"font-medium text-sm mb-2",style:{color:"#ef4444"},children:["Conflict #",c+1]}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("div",{style:{color:r.textPrimary},children:[e.jsx("span",{style:{color:r.textDim},children:"Sources:"})," ",l.sources.join(", ")]}),e.jsxs("div",{style:{color:r.textPrimary},children:[e.jsx("span",{style:{color:r.textDim},children:"Resolved to:"})," ",l.resolvedTo]}),e.jsx("div",{style:{color:r.textDim},children:l.reason}),e.jsxs("div",{className:"text-xs",style:{color:"#f59e0b",fontFamily:"'Geist Mono', monospace"},children:["Confidence: ",(l.confidence*100).toFixed(0),"%"]})]})]},c)),o.annotations.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",style:{color:r.textDim},children:"Resolution Notes:"}),o.annotations.map((l,c)=>e.jsx("div",{className:"text-xs p-2 rounded",style:{background:r.surface,color:r.textDim},children:l},c))]})]}):e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"text-sm",style:{color:"#10b981"},children:"No contradictions detected"}),e.jsx("div",{className:"text-xs mt-1",style:{color:r.textDim},children:"All sources are consistent"})]})}):e.jsx(ee,{name:"Contradiction Check",data:t}),e.jsx(Y,{data:t})]})]})}function rs({data:t,expanded:s,onToggle:n}){const r=w(),o=es(t)?t:null,i=o?o.sources.reduce((l,c)=>l+c.transformations.length,0):0;return e.jsxs("div",{className:"border-b",style:{borderColor:r.border},children:[e.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-3 w-full px-4 py-3 text-left border-none cursor-pointer",style:{background:"transparent",color:r.textPrimary},children:[e.jsx(vt,{size:16,style:{color:"#f59e0b"}}),e.jsx("span",{className:"flex-1 font-medium",children:"Provenance"}),o&&e.jsxs("span",{className:"text-sm",style:{color:r.textDim,fontFamily:"'Geist Mono', monospace"},children:[o.sources.length," sources • ",i," transforms"]}),s?e.jsx(W,{size:16}):e.jsx(U,{size:16})]}),s&&e.jsxs(e.Fragment,{children:[o?e.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[e.jsx("div",{className:"space-y-2",children:o.derivationChain.map((l,c)=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded",style:{background:r.surface},children:[e.jsxs("div",{className:"w-8 text-xs text-center",style:{color:r.textDim,fontFamily:"'Geist Mono', monospace"},children:["#",c+1]}),e.jsxs("div",{className:"flex-1 text-sm",children:[e.jsx("span",{style:{color:r.textPrimary},children:l.from}),e.jsx("span",{style:{color:r.textDim,margin:"0 8px"},children:"→"}),e.jsx("span",{style:{color:r.textSecondary},children:l.to})]}),e.jsx("div",{className:"text-xs px-2 py-1 rounded",style:{background:"#f59e0b15",color:"#f59e0b"},children:l.method})]},c))}),o.sources.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"text-sm font-medium mb-2",style:{color:r.textDim},children:"Source Transformations:"}),e.jsx("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:o.sources.map((l,c)=>e.jsxs("div",{className:"p-2 rounded",style:{background:r.surface},children:[e.jsx("div",{className:"text-sm font-medium mb-1",style:{color:r.textPrimary},children:l.path}),e.jsx("div",{className:"text-xs",style:{color:r.textDim},children:l.type}),l.transformations.length>0&&e.jsx("div",{className:"mt-2 space-y-1",children:l.transformations.map((d,u)=>e.jsxs("div",{className:"text-xs flex items-center gap-2",style:{color:r.textDim},children:[e.jsx("span",{children:d.input}),e.jsx("span",{children:"→"}),e.jsx("span",{children:d.output}),e.jsx("span",{className:"ml-auto text-xs px-1 py-0.5 rounded",style:{background:r.surfaceElevated,color:r.textDim},children:d.method})]},u))})]},c))})]})]}):e.jsx(ee,{name:"Provenance",data:t}),e.jsx(Y,{data:t})]})]})}function as({event:t}){const s=w(),n=t.cacheMetrics;if(!n)return null;const r=n.stableTokens+n.volatileTokens>0?Math.round(n.stableTokens/(n.stableTokens+n.volatileTokens)*100):0,o={"anthropic-prefix":"Anthropic Prefix Cache","openai-auto":"OpenAI Auto Cache","google-context-cache":"Google Context Cache",none:"No Caching"};return e.jsxs("div",{className:"px-4 py-3 border-b",style:{borderColor:s.border},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(be,{size:14,style:{color:"#10b981"}}),e.jsx("span",{className:"text-sm font-medium",style:{color:s.textPrimary},children:"Cache Strategy"}),e.jsx("span",{className:"ml-auto text-xs px-2 py-0.5 rounded",style:{background:"#10b98115",color:"#10b981",fontFamily:"'Geist Mono', monospace"},children:o[n.strategy]??n.strategy})]}),e.jsxs("div",{className:"flex h-3 rounded overflow-hidden",style:{background:s.surfaceElevated},children:[e.jsx("div",{className:"h-full",style:{width:`${r}%`,background:"#10b981"},title:`Stable: ${n.stableTokens.toLocaleString()} tokens`}),e.jsx("div",{className:"h-full",style:{width:`${100-r}%`,background:"#f59e0b"},title:`Volatile: ${n.volatileTokens.toLocaleString()} tokens`})]}),e.jsxs("div",{className:"flex justify-between mt-1 text-xs",style:{color:s.textDim,fontFamily:"'Geist Mono', monospace"},children:[e.jsxs("span",{style:{color:"#10b981"},children:["● stable ",n.stableTokens.toLocaleString()," tok"]}),e.jsxs("span",{style:{color:"#f59e0b"},children:["● volatile ",n.volatileTokens.toLocaleString()," tok"]}),e.jsxs("span",{children:["~",n.estimatedSavings,"% cached"]})]})]})}const ls={retrieval:{color:"#3498db",label:"Retrieval"},llm_call:{color:"#9b59b6",label:"LLM"},tool_call:{color:"#2ecc71",label:"Tool"},error:{color:"#e74c3c",label:"Error"},fact_extracted:{color:"#FE5000",label:"Fact"},token_usage:{color:"#f1c40f",label:"Tokens"},cache:{color:"#10b981",label:"Cache"}};function is({events:t}){const s=w();return t.length===0?null:e.jsxs("div",{className:"px-4 py-3 space-y-2 border-t",style:{borderColor:s.border},children:[e.jsx("div",{className:"text-xs font-medium mb-2",style:{color:s.textDim},children:"Event Timeline"}),t.map((n,r)=>{const o=ls[n.kind]||{color:"#888",label:n.kind},i=n.sourceName||n.toolName||n.model||n.kind,l=(n.inputTokens||0)+(n.outputTokens||0);return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded",style:{background:s.isDark?"#ffffff06":"#00000006"},children:[e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:o.color}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] px-1.5 py-0.5 rounded font-medium",style:{background:`${o.color}20`,color:o.color,fontFamily:"'Geist Mono', monospace"},children:o.label}),e.jsx("span",{className:"text-[12px] font-medium truncate",style:{color:s.textPrimary},children:i})]}),n.query&&e.jsx("div",{className:"text-[11px] mt-0.5 truncate",style:{color:s.textDim},children:n.query})]}),e.jsxs("div",{className:"shrink-0 text-right",children:[n.durationMs!=null&&e.jsxs("div",{className:"text-[11px]",style:{color:s.textDim,fontFamily:"'Geist Mono', monospace"},children:[n.durationMs,"ms"]}),n.resultCount!=null&&e.jsxs("div",{className:"text-[10px]",style:{color:s.textFaint},children:[n.resultCount," results"]}),l>0&&e.jsxs("div",{className:"text-[10px]",style:{color:s.textFaint},children:[l," tok"]})]})]},r)})]})}const ue=["source_assembly","budget_allocation","retrieval","contradiction_check","provenance"],cs={source_assembly:"Source",budget_allocation:"Budget",retrieval:"Retrieval",contradiction_check:"Conflicts",provenance:"Provenance"};function ds({status:t}){const s="w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold shrink-0";return t==="error"?e.jsx("div",{className:s,style:{background:"#ef4444",color:"white"},children:"✕"}):t==="done"?e.jsx("div",{className:s,style:{background:"#10b981",color:"white"},children:"✓"}):t==="active"?e.jsx("div",{className:`${s} animate-pulse`,style:{background:"#FE5000"}}):e.jsx("div",{className:s,style:{background:"#6b7280"}})}function ps({stages:t,hasError:s}){const n=w(),r=ue.reduce((o,i,l)=>{const c=t.get(i);return c&&c.durationMs===void 0?l:o},-1);return e.jsx("div",{className:"flex items-start px-4 py-3 border-b",style:{borderColor:n.border},children:ue.map((o,i)=>{const l=t.get(o),c=l&&l.durationMs!==void 0,d=l&&l.durationMs===void 0,m=s&&i===r?"error":c?"done":d?"active":"pending",p=c||d;return e.jsxs("div",{className:"flex items-center flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[e.jsx(ds,{status:m}),e.jsx("span",{className:"text-[10px] text-center leading-tight",style:{color:n.textDim},children:cs[o]}),l?.durationMs!==void 0&&e.jsxs("span",{className:"text-[10px]",style:{color:n.textFaint,fontFamily:"'Geist Mono', monospace"},children:[l.durationMs,"ms"]})]}),i<ue.length-1&&e.jsx("div",{className:"flex-1 h-px mx-1",style:{background:p?"#10b981":"#6b7280",opacity:.5,marginTop:"-14px"}})]},o)})})}function Fe(){const t=w(),s=O(g=>g.getDisplayTrace),n=O(g=>g.selectedTraceId),r=O(g=>g.eventVersion),[o,i]=h.useState(new Set),l=h.useRef(null),c=s(),d=c?.events??[],u=d.filter(g=>g.kind==="pipeline_stage"),m=d.findLast(g=>g.kind==="cache"),p=new Map;for(const g of u)if(g.provenanceStages)for(const j of g.provenanceStages)p.set(j.stage,j);const y=g=>{const j=new Set(o);j.has(g)?j.delete(g):j.add(g),i(j)},b=d.some(g=>g.kind==="error");return h.useEffect(()=>{for(const g of u)if(g.provenanceStages)for(const j of g.provenanceStages)j.durationMs!==void 0&&!o.has(j.stage)&&i(F=>new Set([...F,j.stage]))},[r]),h.useEffect(()=>{l.current&&u.length>0&&(l.current.scrollTop=l.current.scrollHeight)},[r,u.length]),c?d.length===0?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(me,{selectedTraceId:n,stageCount:0,eventCount:0}),e.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:e.jsx("div",{className:"text-center",children:e.jsx("div",{className:"text-sm",style:{color:t.textDim},children:"Trace started, waiting for events…"})})})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(me,{selectedTraceId:n,stageCount:p.size,eventCount:d.length}),e.jsxs("div",{ref:l,className:"flex-1 overflow-y-auto",children:[p.size>0&&e.jsx(ps,{stages:p,hasError:b}),p.size===0&&e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"text-sm",style:{color:t.textDim},children:["Trace has ",d.length," event",d.length!==1?"s":""," but no pipeline stages."]}),e.jsx("div",{className:"text-xs mt-1",style:{color:t.textFaint},children:"Events are visible in the timeline below."})]}),p.has("source_assembly")&&e.jsx(ts,{data:p.get("source_assembly").data,expanded:o.has("source_assembly"),onToggle:()=>y("source_assembly")}),p.has("budget_allocation")&&e.jsx(ss,{data:p.get("budget_allocation").data,expanded:o.has("budget_allocation"),onToggle:()=>y("budget_allocation")}),p.has("retrieval")&&e.jsx(os,{data:p.get("retrieval").data,expanded:o.has("retrieval"),onToggle:()=>y("retrieval")}),p.has("contradiction_check")&&e.jsx(ns,{data:p.get("contradiction_check").data,expanded:o.has("contradiction_check"),onToggle:()=>y("contradiction_check")}),p.has("provenance")&&e.jsx(rs,{data:p.get("provenance").data,expanded:o.has("provenance"),onToggle:()=>y("provenance")}),m&&e.jsx(as,{event:m}),e.jsx(is,{events:d})]})]}):e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(me,{selectedTraceId:n,stageCount:0,eventCount:0}),e.jsx("div",{className:"flex-1 flex items-center justify-center p-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-sm",style:{color:t.textDim},children:"No trace yet"}),e.jsx("div",{className:"text-xs mt-2",style:{color:t.textFaint},children:"Run a chat in the Test tab to see how your agent processes knowledge through the pipeline."})]})})]})}function me({selectedTraceId:t,stageCount:s,eventCount:n}){const r=w();return e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b",style:{borderColor:r.border},children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${t?"bg-blue-500":"bg-green-500 animate-pulse"}`}),e.jsx("span",{className:"text-sm font-medium",style:{color:r.textPrimary},children:"Pipeline Observability"}),t&&e.jsx("button",{type:"button",onClick:()=>O.getState().selectTrace(null),title:"Stop viewing past trace",className:"text-[10px] px-1.5 py-0.5 rounded border-none cursor-pointer",style:{background:"#3b82f620",color:"#3b82f6",fontFamily:"'Geist Mono', monospace"},children:"viewing past · ✕"}),e.jsxs("span",{className:"ml-auto text-xs",style:{color:r.textDim,fontFamily:"'Geist Mono', monospace"},children:[s," stage",s!==1?"s":""," · ",n," event",n!==1?"s":""]})]})}function Ee({onResize:t,leftWidthPct:s,minWidthPx:n=200,onDoubleClick:r}){const o=w(),[i,l]=h.useState(!1),c=h.useRef(null),d=h.useCallback(y=>{y.preventDefault(),l(!0)},[]),u=h.useCallback(y=>{if(!i||!c.current)return;const b=c.current.parentElement;if(!b)return;const g=b.getBoundingClientRect(),F=(y.clientX-g.left)/g.width*100,S=n/g.width*100,C=100-S,P=Math.max(S,Math.min(C,F));t(P)},[i,n,t]),m=h.useCallback(()=>{l(!1)},[]),p=h.useCallback(()=>{r?.()},[r]);return h.useEffect(()=>{if(i)return document.addEventListener("mousemove",u),document.addEventListener("mouseup",m),()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",m)}},[i,u,m]),e.jsxs("div",{ref:c,className:"relative cursor-col-resize flex-shrink-0",style:{width:"4px",background:i?"#FE5000":"transparent",transition:i?"none":"background-color 0.2s ease"},onMouseDown:d,onDoubleClick:p,children:[e.jsx("div",{className:"absolute inset-y-0 left-1/2 transform -translate-x-1/2 w-1",style:{background:o.border}}),i&&e.jsx("div",{className:"fixed inset-0 cursor-col-resize",style:{zIndex:9999}})]})}const De="testTab-panelWidths",xe=25,Pe=25;function bs(){const t=w(),s=D(a=>a.conversationId),n=I(a=>a.selectedModel),r=I(a=>a.setModel),o=he(a=>a.getAllModels),i=he(a=>a.providers),l=h.useMemo(()=>o().map(a=>({value:`${a.providerId}::${a.id}`,label:`${a.providerName} / ${a.label}`})),[o,i]),c=h.useMemo(()=>o().find(f=>`${f.providerId}::${f.id}`===n)?.label||n,[o,i,n]),[d,u]=h.useState(()=>{const a=localStorage.getItem(De);if(a)try{return JSON.parse(a)}catch{return{left:xe,right:Pe}}return{left:xe,right:Pe}}),[m,p]=h.useState(0),[y,b]=h.useState(!1),[g,j]=h.useState(!1);h.useEffect(()=>{const a=()=>{j(window.innerWidth<1200)};return a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),h.useEffect(()=>{localStorage.setItem(De,JSON.stringify(d))},[d]);const F=h.useCallback(a=>{u(f=>({...f,left:a}))},[]),S=h.useCallback(a=>{u(f=>({...f,right:100-a}))},[]),C=h.useCallback(()=>{b(!y),u(y?a=>({...a,left:xe}):a=>({...a,left:0}))},[y]),P=100-d.left-d.right;if(g){const a=[{id:"conversation",label:"Conversation",icon:St,component:re},{id:"context",label:"Context",icon:je,component:Te},{id:"pipeline",label:"Pipeline",icon:Nt,component:Fe}],f=a[m]?.component||re;return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"px-4 py-3",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-2",style:{color:t.textPrimary,fontFamily:"'Geist Sans', sans-serif"},children:"Test Your Agent"}),e.jsx("p",{className:"text-sm mb-3",style:{color:t.textSecondary,lineHeight:1.5},children:"Test your agent with sample conversations, view execution traces, and analyze performance."}),e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"flex-1 max-w-xs",children:e.jsx(Ne,{options:l,value:n,onChange:N=>r(N),placeholder:"Select model..."})}),n&&e.jsxs("span",{className:"text-xs px-2 py-1 rounded-full",style:{background:"#FE500015",color:"#FE5000",border:"1px solid #FE500030"},children:["Current: ",c]})]})]}),e.jsx("div",{className:"flex border-b",style:{borderColor:t.border,background:t.surfaceElevated},children:a.map((N,x)=>{const k=N.icon,v=x===m;return e.jsxs("button",{type:"button",onClick:()=>p(x),title:`View ${N.label.toLowerCase()}`,className:"flex items-center gap-2 px-4 py-3 text-sm font-medium border-none bg-transparent",style:{color:v?"#FE5000":t.textSecondary,borderBottom:v?"2px solid #FE5000":"none",fontFamily:"'Geist Sans', sans-serif"},children:[e.jsx(k,{size:14}),N.label]},N.id)})}),e.jsx("div",{className:"flex-1 overflow-hidden",children:m===0?e.jsx(re,{}):e.jsx(f,{conversationId:s||void 0})})]})}return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"px-4 py-3 flex-shrink-0",children:[e.jsx("h2",{className:"text-2xl font-semibold mb-2",style:{color:t.textPrimary,fontFamily:"'Geist Sans', sans-serif"},children:"Test Your Agent"}),e.jsx("p",{className:"text-sm mb-3",style:{color:t.textSecondary,lineHeight:1.5},children:"Test your agent with sample conversations, view execution traces, and analyze performance."}),e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"flex-1 max-w-xs",children:e.jsx(Ne,{options:l,value:n,onChange:a=>r(a),placeholder:"Select model..."})}),n&&e.jsxs("span",{className:"text-xs px-2 py-1 rounded-full",style:{background:"#FE500015",color:"#FE5000",border:"1px solid #FE500030"},children:["Current: ",c]})]})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",style:{display:"grid",gridTemplateColumns:`${d.left}% 4px ${P}% 4px ${d.right}%`,gap:0},children:[e.jsx("div",{className:"overflow-hidden border-r overflow-y-auto",style:{borderColor:t.border,background:t.surface,display:d.left===0?"none":"block"},children:e.jsx(Te,{conversationId:s||void 0})}),e.jsx(Ee,{onResize:F,leftWidthPct:d.left,onDoubleClick:C}),e.jsx("div",{className:"overflow-hidden",style:{background:t.surface},children:e.jsx(re,{isExpanded:!y,onExpand:()=>b(!1),onMinimize:()=>b(!0)})}),e.jsx(Ee,{onResize:S,leftWidthPct:100-d.right}),e.jsx("div",{className:"overflow-hidden border-l",style:{borderColor:t.border,background:t.surface,display:d.right===0?"none":"block"},children:e.jsx(Fe,{})})]})]})}export{bs as TestTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as d,j as t}from"./vendor-D1h_O76p.js";import{u as te,c as m,f as re}from"./index-gBy3427k.js";import{u as l,c as f,J as se,L as oe,N as le}from"./services-CTWXQK6j.js";import{c as ae,p as ne}from"./stores-CeKWz7ou.js";import{f as j,a0 as x,Z as ce,aG as ie,O as de,ay as z,ao as me,aH as ue,aI as xe,Y as R,R as be}from"./icons-MKpPNvV8.js";const k=ae()(ne((r,u)=>({tools:[],addTool:n=>{const c=`cli-${Date.now()}-${Math.random().toString(36).slice(2,7)}`;r({tools:[...u().tools,{...n,id:c}]})},removeTool:n=>r({tools:u().tools.filter(c=>c.id!==n)})}),{name:"cli-tool-store"}));function je(){const r=te(),u=l(e=>e.removeMcp),n=f(e=>e.removeServer),c=f(e=>e.connectServer),i=f(e=>e.servers),b=se(e=>e.mcpHealth),N=m(e=>e.skills),C=m(e=>e.loaded),y=m(e=>e.loading),v=m(e=>e.loadSkills),D=m(e=>e.toggleSkill),S=l(e=>e.setShowSkillPicker),I=l(e=>e.setShowMarketplace),T=l(e=>e.skills),p=l(e=>e.connectors),M=l(e=>e.setShowConnectorPicker),g=k(e=>e.tools),B=k(e=>e.addTool),$=k(e=>e.removeTool),[w,H]=d.useState(null),[o,a]=d.useState({show:!1,name:"",command:"",description:""}),G=()=>{!o.name.trim()||!o.command.trim()||(B({name:o.name.trim(),command:o.command.trim(),description:o.description.trim()}),a({show:!1,name:"",command:"",description:""}))};d.useEffect(()=>{!C&&!y&&v()},[C,y,v]);const P=d.useMemo(()=>new Set(T.filter(e=>e.added).map(e=>e.id)),[T]),h=d.useMemo(()=>N.filter(e=>P.has(e.id)),[N,P]),O=e=>{const s=b[e.id];return s?.status==="error"?"#ef4444":e.status==="connected"&&s?.status==="healthy"?"#22c55e":e.status==="connecting"||s?.status==="checking"?"#f59e0b":e.status==="error"?"#ef4444":"#6b7280"},W=e=>{const s=b[e.id];return s?.status==="error"?"Error":e.status==="connected"&&s?.status==="healthy"?"Connected":e.status==="connecting"||s?.status==="checking"?"Connecting":e.status==="error"?"Error":"Disconnected"},Z=e=>{u(e),n(e)},J=async e=>{try{await c(e)}catch(s){console.error("Failed to reconnect MCP server:",s)}},Y=e=>e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",_=({skill:e})=>{const s=e.enabled;return t.jsx("div",{className:"p-4 rounded-lg border",style:{background:r.surface,borderColor:r.border},children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx("h3",{className:"text-sm font-medium truncate",style:{color:r.textPrimary},children:e.name}),t.jsx(re,{skillPath:e.path})]}),e.description&&t.jsx("p",{className:"text-xs mb-2",style:{color:r.textSecondary,lineHeight:1.4},children:e.description})]}),t.jsxs("label",{className:"flex items-center cursor-pointer",title:s?"Disable skill":"Enable skill",children:[t.jsx("input",{type:"checkbox",checked:s,onChange:()=>D(e.id),className:"sr-only"}),t.jsx("div",{className:`w-10 h-6 rounded-full relative transition-colors ${s?"bg-blue-500":""}`,style:{backgroundColor:s?"#3b82f6":r.borderSubtle},children:t.jsx("div",{className:`w-4 h-4 rounded-full bg-white absolute top-1 transition-transform ${s?"translate-x-5":"translate-x-1"}`,style:{boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})})]})]})})},q=({server:e})=>{const s=b[e.id],E=s?.toolCount??e.tools?.length??0,V=O(e),X=W(e),ee=e.status==="disconnected"||e.status==="error",L=s?.status==="checking",A=s?.checkedAt?Y(s.checkedAt):null,F=s?.errorMessage??void 0;return t.jsxs("div",{className:"p-4 rounded-lg border",style:{background:r.surface,borderColor:r.border},children:[t.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:V},title:F}),t.jsx("h3",{className:"text-sm font-medium",style:{color:r.textPrimary},children:e.name})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button","aria-label":`Check health of ${e.name}`,title:L?"Checking…":"Run health check",onClick:()=>le(e.id),disabled:L,className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800 disabled:opacity-40",style:{color:r.textFaint},children:t.jsx(z,{size:13})}),t.jsx("button",{type:"button","aria-label":`Remove ${e.name}`,title:`Remove ${e.name}`,onClick:()=>Z(e.id),className:"text-xs p-1 rounded hover:bg-red-100 dark:hover:bg-red-900/20",style:{color:r.textFaint},children:"×"})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3 text-xs",style:{color:r.textSecondary},children:[t.jsx("span",{title:F,children:X}),E>0&&t.jsxs("span",{className:"px-1.5 py-0.5 rounded",style:{background:r.badgeBg,color:r.textDim},children:[E," tools"]}),A&&t.jsxs("span",{style:{color:r.textFaint},children:["checked ",A]})]}),ee&&t.jsxs("button",{type:"button",onClick:()=>J(e.id),title:"Reconnect server",className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-gray-100 dark:hover:bg-gray-800",style:{color:r.textSecondary},children:[t.jsx(be,{size:10}),"Reconnect"]})]}),s?.errorMessage&&s.status!=="healthy"&&t.jsx("p",{className:"mt-2 text-xs truncate",title:s.errorMessage,style:{color:"#ef4444"},children:s.errorMessage})]})},K={connected:"#22c55e",configured:"#f59e0b",available:"#6b7280"},Q=({connector:e})=>{const s=K[e.status]??"#6b7280";return t.jsxs("div",{className:"p-4 rounded-lg border",style:{background:r.surface,borderColor:r.border},children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(j,{size:14,style:{color:r.textFaint}}),t.jsx("span",{className:"text-sm font-medium",style:{color:r.textPrimary},children:e.name})]}),t.jsx("span",{className:"px-1.5 py-0.5 rounded text-xs capitalize",style:{background:s+"20",color:s},children:e.status})]}),e.url&&t.jsx("p",{className:"text-xs mt-1 truncate",style:{color:r.textFaint},children:e.url})]})},U=({tool:e})=>t.jsx("div",{className:"p-4 rounded-lg border",style:{background:r.surface,borderColor:r.border},children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",style:{color:r.textPrimary},children:e.name}),t.jsx("code",{className:"text-xs font-mono block mt-1 truncate",style:{color:r.textSecondary},children:e.command}),e.description&&t.jsx("p",{className:"text-xs mt-1",style:{color:r.textFaint},children:e.description})]}),t.jsx("button",{type:"button","aria-label":`Remove ${e.name}`,title:`Remove ${e.name}`,onClick:()=>$(e.id),className:"text-xs p-1 rounded hover:bg-red-100 dark:hover:bg-red-900/20",style:{color:r.textFaint},children:"×"})]})});return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-semibold mb-2 m-0",style:{color:r.textPrimary,fontFamily:"'Geist Sans', sans-serif"},children:"Tools & Capabilities"}),t.jsx("p",{className:"text-sm",style:{color:r.textSecondary,lineHeight:1.5},children:"Configure the tools and capabilities your agent can use. Skills add specialized functionality while MCP servers provide external integrations."})]}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(j,{size:20,style:{color:"#3b82f6"}}),t.jsx("h3",{className:"text-lg font-medium",style:{color:r.textPrimary},children:"API Connectors"}),t.jsxs("span",{className:"px-2 py-1 rounded text-xs",style:{background:r.badgeBg,color:r.textDim},children:[p.length," total"]})]}),t.jsxs("button",{type:"button",onClick:()=>M(!0),title:"Connect an API service",className:"flex items-center gap-1.5 px-3 py-2 rounded text-sm border transition-colors",style:{borderColor:r.border,color:r.textSecondary},onMouseEnter:e=>{e.currentTarget.style.background="#3b82f610",e.currentTarget.style.borderColor="#3b82f6",e.currentTarget.style.color="#3b82f6"},onMouseLeave:e=>{e.currentTarget.style.background="transparent",e.currentTarget.style.borderColor=r.border,e.currentTarget.style.color=r.textSecondary},children:[t.jsx(x,{size:16}),"Connect"]})]}),p.length===0?t.jsxs("div",{className:"text-center py-8 rounded-lg border-2 border-dashed",style:{borderColor:r.border},children:[t.jsx(j,{size:32,className:"mx-auto mb-3",style:{color:r.textFaint}}),t.jsx("p",{className:"text-sm font-medium mb-1",style:{color:r.textPrimary},children:"No API Connectors"}),t.jsx("p",{className:"text-xs mb-4",style:{color:r.textSecondary},children:"Connect services like Notion, HubSpot, and Slack to give your agent API access."}),t.jsx("button",{type:"button",onClick:()=>M(!0),title:"Connect an API service",className:"px-4 py-2 rounded text-sm transition-colors",style:{background:"#3b82f6",color:"#fff",border:"none",cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.background="#2563eb"},onMouseLeave:e=>{e.currentTarget.style.background="#3b82f6"},children:"Connect Service"})]}):t.jsx("div",{className:"space-y-3",children:p.map(e=>t.jsx(Q,{connector:e},e.id))})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ce,{size:20,style:{color:"#f1c40f"}}),t.jsx("h3",{className:"text-lg font-medium",style:{color:r.textPrimary},children:"Skills"}),t.jsxs("span",{className:"px-2 py-1 rounded text-xs",style:{background:r.badgeBg,color:r.textDim},children:[h.length," total"]})]}),t.jsxs("button",{type:"button",onClick:()=>S(!0),title:"Add skills from library",className:"flex items-center gap-1.5 px-3 py-2 rounded text-sm border transition-colors",style:{borderColor:r.border,color:r.textSecondary},onMouseEnter:e=>{e.currentTarget.style.background="#FE500010",e.currentTarget.style.borderColor="#FE5000",e.currentTarget.style.color="#FE5000"},onMouseLeave:e=>{e.currentTarget.style.background="transparent",e.currentTarget.style.borderColor=r.border,e.currentTarget.style.color=r.textSecondary},children:[t.jsx(x,{size:16}),"Add from library"]}),t.jsx("button",{type:"button",onClick:()=>I(!0),title:"Browse marketplace",className:"flex items-center gap-1.5 px-3 py-2 rounded text-sm border transition-colors",style:{borderColor:r.border,color:r.textSecondary},onMouseEnter:e=>{e.currentTarget.style.background=r.surfaceElevated},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:"Marketplace"})]}),y?t.jsx("div",{className:"space-y-3",children:Array.from({length:3}).map((e,s)=>t.jsx("div",{className:"h-20 rounded-lg animate-pulse",style:{background:r.borderSubtle}},s))}):h.length===0?t.jsxs("div",{className:"text-center py-8 rounded-lg border-2 border-dashed",style:{borderColor:r.border},children:[t.jsx(ie,{size:32,className:"mx-auto mb-3",style:{color:r.textFaint}}),t.jsx("p",{className:"text-sm font-medium mb-1",style:{color:r.textPrimary},children:"No Skills Installed"}),t.jsx("p",{className:"text-xs mb-4",style:{color:r.textSecondary},children:"Browse the skill library to add specialized capabilities for your agent."}),t.jsx("button",{type:"button",onClick:()=>S(!0),title:"Browse skill library",className:"px-4 py-2 rounded text-sm transition-colors",style:{background:"#f1c40f",color:"#000",border:"none",cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.background="#e1b70f"},onMouseLeave:e=>{e.currentTarget.style.background="#f1c40f"},children:"Browse Skills"})]}):t.jsx("div",{className:"space-y-3",children:h.map(e=>t.jsx(_,{skill:e},e.id))})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(de,{size:20,style:{color:"#2ecc71"}}),t.jsx("h3",{className:"text-lg font-medium",style:{color:r.textPrimary},children:"MCP Servers"}),t.jsxs("span",{className:"px-2 py-1 rounded text-xs",style:{background:r.badgeBg,color:r.textDim},children:[i.length," servers"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[i.length>0&&t.jsxs("button",{type:"button",onClick:()=>oe(i.map(e=>e.id)),title:"Check health of all MCP servers",className:"flex items-center gap-1.5 px-3 py-2 rounded text-sm border transition-colors",style:{borderColor:r.border,color:r.textSecondary},onMouseEnter:e=>{e.currentTarget.style.background=r.surfaceElevated},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:[t.jsx(z,{size:14}),"Check All"]}),t.jsxs("button",{type:"button",onClick:()=>l.getState().setShowConnectionPicker(!0),title:"Connect MCP server",className:"flex items-center gap-1.5 px-3 py-2 rounded text-sm border transition-colors",style:{borderColor:r.border,color:r.textSecondary},onMouseEnter:e=>{e.currentTarget.style.background="#FE500010",e.currentTarget.style.borderColor="#FE5000",e.currentTarget.style.color="#FE5000"},onMouseLeave:e=>{e.currentTarget.style.background="transparent",e.currentTarget.style.borderColor=r.border,e.currentTarget.style.color=r.textSecondary},children:[t.jsx(x,{size:16}),"Connect"]})]})]}),w&&t.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg border-l-4",style:{backgroundColor:`${r.statusError}20`,borderLeftColor:r.statusError,color:r.statusError},children:[t.jsx(me,{size:16}),t.jsx("span",{className:"flex-1 text-sm",children:w}),t.jsx("button",{onClick:()=>H(null),className:"px-2 py-1 text-xs rounded transition-colors",style:{background:r.statusError,color:"#fff",border:"none",cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.opacity="0.9"},onMouseLeave:e=>{e.currentTarget.style.opacity="1"},children:"Dismiss"})]}),i.length===0?t.jsxs("div",{className:"text-center py-8 rounded-lg border-2 border-dashed",style:{borderColor:r.border},children:[t.jsx(ue,{size:32,className:"mx-auto mb-3",style:{color:r.textFaint}}),t.jsx("p",{className:"text-sm font-medium mb-1",style:{color:r.textPrimary},children:"No MCP Servers"}),t.jsx("p",{className:"text-xs mb-4",style:{color:r.textSecondary},children:"Connect to external integrations to expand your agent's capabilities."}),t.jsxs("button",{type:"button",onClick:()=>l.getState().setShowConnectionPicker(!0),className:"px-4 py-2 rounded text-sm transition-colors",style:{background:"#2ecc71",color:"#fff",border:"none",cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.background="#27ae60"},onMouseLeave:e=>{e.currentTarget.style.background="#2ecc71"},children:[t.jsx(xe,{size:16,style:{marginRight:"8px",display:"inline"}}),"Connect Server"]})]}):t.jsx("div",{className:"space-y-3",children:i.map(e=>t.jsx(q,{server:e},e.id))})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(R,{size:20,style:{color:"#a855f7"}}),t.jsx("h3",{className:"text-lg font-medium",style:{color:r.textPrimary},children:"CLI Tools"}),t.jsxs("span",{className:"px-2 py-1 rounded text-xs",style:{background:r.badgeBg,color:r.textDim},children:[g.length," total"]})]}),t.jsxs("button",{type:"button",onClick:()=>a(e=>({...e,show:!e.show})),title:"Add CLI tool",className:"flex items-center gap-1.5 px-3 py-2 rounded text-sm border transition-colors",style:{borderColor:r.border,color:r.textSecondary},onMouseEnter:e=>{e.currentTarget.style.background="#a855f710",e.currentTarget.style.borderColor="#a855f7",e.currentTarget.style.color="#a855f7"},onMouseLeave:e=>{e.currentTarget.style.background="transparent",e.currentTarget.style.borderColor=r.border,e.currentTarget.style.color=r.textSecondary},children:[t.jsx(x,{size:16}),"Add Tool"]})]}),o.show&&t.jsxs("div",{className:"p-4 rounded-lg border space-y-3",style:{background:r.surfaceElevated,borderColor:r.border},children:[t.jsx("input",{type:"text",placeholder:"Tool name",value:o.name,onChange:e=>a(s=>({...s,name:e.target.value})),className:"w-full px-3 py-2 rounded text-sm border",style:{background:r.surface,borderColor:r.border,color:r.textPrimary}}),t.jsx("input",{type:"text",placeholder:"Shell command (e.g. git status)",value:o.command,onChange:e=>a(s=>({...s,command:e.target.value})),className:"w-full px-3 py-2 rounded text-sm border font-mono",style:{background:r.surface,borderColor:r.border,color:r.textPrimary}}),t.jsx("input",{type:"text",placeholder:"Description (optional)",value:o.description,onChange:e=>a(s=>({...s,description:e.target.value})),className:"w-full px-3 py-2 rounded text-sm border",style:{background:r.surface,borderColor:r.border,color:r.textPrimary}}),t.jsxs("div",{className:"flex gap-2 justify-end",children:[t.jsx("button",{type:"button",onClick:()=>a({show:!1,name:"",command:"",description:""}),className:"px-3 py-1.5 rounded text-sm border",style:{borderColor:r.border,color:r.textSecondary,background:"transparent"},children:"Cancel"}),t.jsx("button",{type:"button",onClick:G,disabled:!o.name.trim()||!o.command.trim(),className:"px-3 py-1.5 rounded text-sm",style:{background:"#a855f7",color:"#fff",border:"none",cursor:"pointer",opacity:!o.name.trim()||!o.command.trim()?.5:1},children:"Save"})]})]}),g.length===0&&!o.show?t.jsxs("div",{className:"text-center py-8 rounded-lg border-2 border-dashed",style:{borderColor:r.border},children:[t.jsx(R,{size:32,className:"mx-auto mb-3",style:{color:r.textFaint}}),t.jsx("p",{className:"text-sm font-medium mb-1",style:{color:r.textPrimary},children:"No CLI Tools"}),t.jsx("p",{className:"text-xs mb-4",style:{color:r.textSecondary},children:"Define shell commands your agent can invoke directly."}),t.jsx("button",{type:"button",onClick:()=>a(e=>({...e,show:!0})),title:"Add a CLI tool",className:"px-4 py-2 rounded text-sm transition-colors",style:{background:"#a855f7",color:"#fff",border:"none",cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.background="#9333ea"},onMouseLeave:e=>{e.currentTarget.style.background="#a855f7"},children:"Add CLI Tool"})]}):t.jsx("div",{className:"space-y-3",children:g.map(e=>t.jsx(U,{tool:e},e.id))})]})]})]})}export{je as ToolsTab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c}from"./stores-CeKWz7ou.js";import"./vendor-D1h_O76p.js";const i="";let r=null;const p=c((a,n)=>({panelOpen:!1,panelHeight:40,activeTab:"chat",conversationId:null,conversations:[],messages:[],inputText:"",streaming:!1,lastPipelineStats:null,testCases:[],runningTests:!1,setPanelOpen:e=>a({panelOpen:e}),setPanelHeight:e=>a({panelHeight:Math.max(20,Math.min(80,e))}),setActiveTab:e=>a({activeTab:e}),setInputText:e=>a({inputText:e}),addMessage:e=>{const s=n(),t={...e,id:`msg-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,timestamp:Date.now()};let o=s.conversationId;!o&&s.messages.length===0&&(o=`conv-${Date.now()}-${Math.random().toString(36).slice(2,8)}`),a({messages:[...s.messages,t],conversationId:o}),r&&clearTimeout(r),r=setTimeout(()=>{n().saveToServer().catch(console.error)},1e3)},updateLastAssistant:e=>{const s=[...n().messages];for(let t=s.length-1;t>=0;t--)if(s[t].role==="assistant"){s[t]={...s[t],content:e};break}a({messages:s})},updateMessagePipelineStats:(e,s)=>{a({messages:n().messages.map(t=>t.id===e?{...t,pipelineStats:s}:t)})},clearMessages:()=>a({messages:[],lastPipelineStats:null}),setStreaming:e=>a({streaming:e}),setLastPipelineStats:e=>a({lastPipelineStats:e}),addTestCase:e=>a({testCases:[...n().testCases,{...e,id:`test-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}]}),updateTestCase:(e,s)=>a({testCases:n().testCases.map(t=>t.id===e?{...t,...s}:t)}),removeTestCase:e=>a({testCases:n().testCases.filter(s=>s.id!==e)}),setRunningTests:e=>a({runningTests:e}),saveCurrentAsTest:(e,s)=>{const o=[...n().messages].reverse().find(l=>l.role==="user");o&&n().addTestCase({name:e,input:o.content,expectedBehavior:s,passed:null})},saveToServer:async()=>{const e=n();if(!(!e.conversationId||e.messages.length===0))try{const s=e.messages[0]?.content?.slice(0,50)||"Untitled Conversation";await fetch(`${i}/api/conversations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e.conversationId,title:s,messages:e.messages,lastModified:Date.now()})})}catch(s){console.error("Failed to save conversation:",s)}},listFromServer:async()=>{try{const e=await fetch(`${i}/api/conversations`);if(e.ok){const s=await e.json();a({conversations:s})}}catch(e){console.error("Failed to list conversations:",e)}},loadFromServer:async e=>{try{const s=await fetch(`${i}/api/conversations/${e}`);if(s.ok){const t=await s.json();a({conversationId:t.id,messages:t.messages||[],lastPipelineStats:null})}}catch(s){console.error("Failed to load conversation:",s)}}}));export{p as useConversationStore};
|