@axlsdk/studio 0.13.0 → 0.13.2
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.
|
@@ -147,4 +147,4 @@ Please change the parent <Route path="${q}"> to <Route path="${q==="/"?"*":`${q}
|
|
|
147
147
|
*
|
|
148
148
|
* This source code is licensed under the ISC license.
|
|
149
149
|
* See the LICENSE file in the root directory of this source tree.
|
|
150
|
-
*/const Xb=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]],Ev=Et("Wrench",Xb);function _o(...u){return u.filter(Boolean).join(" ")}function jv(u){return u===0?"$0.00":u<.01?`$${u.toFixed(4)}`:`$${u.toFixed(2)}`}function Zb(u){return u<1e3?`${Math.round(u)}ms`:u<6e4?`${(u/1e3).toFixed(1)}s`:`${(u/6e4).toFixed(1)}m`}function Ds(u){return u.toLocaleString()}function Kb(u){switch(u){case"running":return"text-blue-500";case"completed":return"text-green-500";case"failed":return"text-red-500";case"waiting":return"text-amber-500";default:return"text-gray-500"}}const Vb=[{to:"/playground",label:"Playground",icon:zb},{to:"/workflows",label:"Workflows",icon:xv},{to:"/traces",label:"Traces",icon:yv},{to:"/costs",label:"Costs",icon:pv},{to:"/memory",label:"Memory",icon:vv},{to:"/sessions",label:"Sessions",icon:Sv},{to:"/tools",label:"Tools",icon:Ev},{to:"/evals",label:"Evals",icon:gv}];function kb(){return o.jsxs("aside",{className:"w-56 border-r border-[hsl(var(--border))] bg-[hsl(var(--card))] flex flex-col h-screen",children:[o.jsx("div",{className:"p-4 border-b border-[hsl(var(--border))]",children:o.jsx("h1",{className:"text-lg font-semibold tracking-tight",children:"Axl Studio"})}),o.jsx("nav",{className:"flex-1 p-2 space-y-0.5",children:Vb.map(({to:u,label:i,icon:r})=>o.jsxs(dv,{to:u,className:({isActive:c})=>_o("flex items-center gap-2.5 px-3 py-2 rounded-md text-sm transition-colors",c?"bg-[hsl(var(--accent))] text-[hsl(var(--accent-foreground))] font-medium":"text-[hsl(var(--muted-foreground))] hover:bg-[hsl(var(--accent))] hover:text-[hsl(var(--accent-foreground))]"),children:[o.jsx(r,{size:16}),i]},u))}),o.jsx("div",{className:"p-4 border-t border-[hsl(var(--border))] text-xs text-[hsl(var(--muted-foreground))]",children:"@axlsdk/studio"})]})}function ql({title:u,description:i,actions:r,children:c}){return o.jsxs("div",{className:"flex flex-col h-screen",children:[o.jsxs("header",{className:"flex items-center justify-between px-6 py-4 border-b border-[hsl(var(--border))]",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-xl font-semibold",children:u}),i&&o.jsx("p",{className:"text-sm text-[hsl(var(--muted-foreground))] mt-0.5",children:i})]}),r&&o.jsx("div",{className:"flex items-center gap-2",children:r})]}),o.jsx("main",{className:"flex-1 overflow-auto p-6",children:c})]})}function Vt({title:u,description:i,icon:r}){return o.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[r&&o.jsx("div",{className:"mb-3 text-[hsl(var(--muted-foreground))]",children:r}),o.jsx("h3",{className:"text-sm font-medium text-[hsl(var(--foreground))]",children:u}),i&&o.jsx("p",{className:"text-sm text-[hsl(var(--muted-foreground))] mt-1 max-w-sm",children:i})]})}function Jb({text:u,className:i}){return o.jsxs("div",{className:`whitespace-pre-wrap ${i??""}`,children:[u,o.jsx("span",{className:"animate-pulse",children:"|"})]})}function Jt({data:u,collapsed:i=!1,className:r}){const[c,d]=j.useState(i),m=JSON.stringify(u,null,2),y=m.length>200;return o.jsxs("div",{className:`relative ${r??""}`,children:[y&&o.jsx("button",{onClick:()=>d(!c),className:"text-xs text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))] mb-1",children:c?"Expand":"Collapse"}),o.jsx("pre",{className:"text-xs font-mono p-3 rounded-md bg-[hsl(var(--secondary))] overflow-auto max-h-96",children:c?JSON.stringify(u):m})]})}const Fb=(window.__AXL_STUDIO_BASE__??"")+"/api";async function Qe(u,i){const c=await(await fetch(`${Fb}${u}`,{headers:{"Content-Type":"application/json",...i==null?void 0:i.headers},...i})).json();if(!c.ok)throw new Error(c.error.message);return c.data}const $b=()=>Qe("/workflows"),Wb=u=>Qe(`/workflows/${encodeURIComponent(u)}`),Ib=(u,i,r=!1)=>Qe(`/workflows/${encodeURIComponent(u)}/execute`,{method:"POST",body:JSON.stringify({input:i,stream:r})}),Pb=()=>Qe("/executions"),e1=()=>Qe("/sessions"),t1=u=>Qe(`/sessions/${encodeURIComponent(u)}`),l1=u=>Qe(`/sessions/${encodeURIComponent(u)}`,{method:"DELETE"}),a1=()=>Qe("/agents"),n1=()=>Qe("/tools"),u1=u=>Qe(`/tools/${encodeURIComponent(u)}`),i1=(u,i)=>Qe(`/tools/${encodeURIComponent(u)}/test`,{method:"POST",body:JSON.stringify({input:i})}),s1=u=>Qe(`/memory/${encodeURIComponent(u)}`),r1=(u,i,r)=>Qe(`/memory/${encodeURIComponent(u)}/${encodeURIComponent(i)}`,{method:"PUT",body:JSON.stringify({value:r})}),c1=(u,i)=>Qe(`/memory/${encodeURIComponent(u)}/${encodeURIComponent(i)}`,{method:"DELETE"}),o1=(u,i,r)=>Qe("/memory/search",{method:"POST",body:JSON.stringify({query:u,scope:i,limit:r})}),f1=()=>Qe("/costs"),d1=()=>Qe("/costs/reset",{method:"POST"}),h1=()=>Qe("/evals"),m1=()=>Qe("/evals/history"),y1=u=>Qe(`/evals/${encodeURIComponent(u)}/run`,{method:"POST"}),v1=(u,i)=>Qe("/evals/compare",{method:"POST",body:JSON.stringify({baseline:u,candidate:i})}),p1=(u,i,r)=>Qe("/playground/chat",{method:"POST",body:JSON.stringify({message:u,sessionId:i,agent:r})});class g1{constructor(){ku(this,"ws",null);ku(this,"listeners",new Map);ku(this,"reconnectTimer",null);ku(this,"url");const i=window.location.protocol==="https:"?"wss:":"ws:",r=window.__AXL_STUDIO_BASE__??"";this.url=`${i}//${window.location.host}${r}/ws`}connect(){var i;((i=this.ws)==null?void 0:i.readyState)!==WebSocket.OPEN&&(this.ws=new WebSocket(this.url),this.ws.onopen=()=>{for(const r of this.listeners.keys())this.send({type:"subscribe",channel:r})},this.ws.onmessage=r=>{try{const c=JSON.parse(r.data);if(c.type==="event"&&c.channel){const d=this.listeners.get(c.channel);if(d)for(const y of d)y(c.data);const m=c.channel.indexOf(":");if(m>0){const y=c.channel.substring(0,m)+":*",p=this.listeners.get(y);if(p)for(const x of p)x(c.data)}}}catch{}},this.ws.onclose=()=>{this.scheduleReconnect()},this.ws.onerror=()=>{var r;(r=this.ws)==null||r.close()})}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},2e3))}send(i){var r;((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify(i))}subscribe(i,r){let c=this.listeners.get(i);return c||(c=new Set,this.listeners.set(i,c),this.send({type:"subscribe",channel:i})),c.add(r),this.connect(),()=>{c.delete(r),c.size===0&&(this.listeners.delete(i),this.send({type:"unsubscribe",channel:i}))}}disconnect(){var i;this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),(i=this.ws)==null||i.close(),this.ws=null}}const x1=new g1;function Jo(u,i){const r=j.useRef(i);r.current=i,j.useEffect(()=>{if(u)return x1.subscribe(u,c=>r.current(c))},[u])}function Nv(u){const[i,r]=j.useState({tokens:"",events:[],done:!1,error:null,result:null}),c=j.useCallback(d=>{const m=d;r(y=>{switch(m.type){case"token":return{...y,tokens:y.tokens+m.data,events:[...y.events,m]};case"done":return{...y,done:!0,result:m.result,events:[...y.events,m]};case"error":return{...y,done:!0,error:m.message,events:[...y.events,m]};default:return{...y,events:[...y.events,m]}}})},[]);return Jo(u?`execution:${u}`:null,c),i}function b1(){const[u,i]=j.useState([]),[r,c]=j.useState(""),[d,m]=j.useState(null),[y,p]=j.useState(null),[x,v]=j.useState(""),[T,g]=j.useState(!1),_=j.useRef(null),{data:w=[]}=kt({queryKey:["agents"],queryFn:a1}),Z=Nv(y);j.useEffect(()=>{Z.tokens&&T&&i(U=>{const Y=U[U.length-1];return(Y==null?void 0:Y.role)==="assistant"?[...U.slice(0,-1),{...Y,content:Z.tokens}]:[...U,{role:"assistant",content:Z.tokens}]}),Z.done&&(g(!1),p(null))},[Z.tokens,Z.done,T]),j.useEffect(()=>{const U=[],Y=[],q=[];for(const O of Z.events){if(O.type==="tool_call"&&U.push({name:O.name,args:O.args}),O.type==="tool_result"){const K=U.find(V=>V.name===O.name&&!V.result);K&&(K.result=O.result)}O.type==="handoff"&&Y.push({source:O.source,target:O.target,mode:O.mode??"oneway"}),O.type==="tool_approval"&&q.push({tool:O.name,approved:O.approved})}(U.length>0||Y.length>0||q.length>0)&&i(O=>{const K=O[O.length-1];return(K==null?void 0:K.role)==="assistant"?[...O.slice(0,-1),{...K,toolCalls:U.length>0?U:K.toolCalls,handoffs:Y.length>0?Y:K.handoffs,approvals:q.length>0?q:K.approvals}]:O})},[Z.events]),j.useEffect(()=>{var U;(U=_.current)==null||U.scrollIntoView({behavior:"smooth"})},[u]);const R=j.useCallback(async()=>{if(!r.trim()||T)return;const U=r.trim();c(""),i(Y=>[...Y,{role:"user",content:U}]),g(!0);try{const Y=await p1(U,d??void 0,x||void 0);m(Y.sessionId),p(Y.executionId)}catch(Y){g(!1),i(q=>[...q,{role:"assistant",content:`Error: ${Y instanceof Error?Y.message:String(Y)}`}])}},[r,T,d,x]),L=U=>{U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),R())};return o.jsx(ql,{title:"Agent Playground",description:"Chat with registered agents in real-time",actions:o.jsxs("div",{className:"flex items-center gap-2",children:[w.length>0&&o.jsxs("select",{value:x,onChange:U=>v(U.target.value),className:"px-2 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))]",children:[o.jsx("option",{value:"",children:"Default agent"}),w.map(U=>o.jsx("option",{value:U.name,children:U.name},U.name))]}),o.jsx("button",{onClick:()=>{i([]),m(null),p(null)},className:"px-3 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] hover:bg-[hsl(var(--accent))]",children:"New Chat"})]}),children:o.jsxs("div",{className:"flex flex-col h-full max-w-3xl mx-auto",children:[o.jsxs("div",{className:"flex-1 overflow-auto space-y-4 pb-4",children:[u.length===0&&o.jsx(Vt,{title:"Start a conversation",description:"Type a message below to chat with an agent. Tool calls, handoffs, and streaming responses will be displayed in real-time."}),u.map((U,Y)=>o.jsx("div",{className:`flex ${U.role==="user"?"justify-end":"justify-start"}`,children:o.jsxs("div",{className:`max-w-[80%] rounded-lg px-4 py-2.5 text-sm ${U.role==="user"?"bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))]":"bg-[hsl(var(--secondary))] text-[hsl(var(--secondary-foreground))]"}`,children:[U.role==="assistant"&&T&&Y===u.length-1?o.jsx(Jb,{text:U.content}):o.jsx("div",{className:"whitespace-pre-wrap",children:U.content}),U.handoffs&&U.handoffs.length>0&&o.jsx("div",{className:"mt-2 space-y-1 border-t border-[hsl(var(--border))] pt-2",children:U.handoffs.map((q,O)=>o.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[o.jsx(zo,{size:12,className:"text-amber-500"}),o.jsx("span",{className:"font-medium",children:q.source}),o.jsx(zo,{size:10}),o.jsx("span",{className:"font-medium",children:q.target}),o.jsxs("span",{className:"text-[hsl(var(--muted-foreground))]",children:["(",q.mode,")"]})]},O))}),U.approvals&&U.approvals.length>0&&o.jsx("div",{className:"mt-2 space-y-1 border-t border-[hsl(var(--border))] pt-2",children:U.approvals.map((q,O)=>o.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[o.jsx(Lb,{size:12,className:q.approved?"text-green-500":"text-red-500"}),o.jsxs("span",{children:["Tool ",o.jsx("span",{className:"font-mono",children:q.tool}),":"," ",q.approved?"approved":"denied"]})]},O))}),U.toolCalls&&U.toolCalls.length>0&&o.jsx("div",{className:"mt-2 space-y-2 border-t border-[hsl(var(--border))] pt-2",children:U.toolCalls.map((q,O)=>o.jsxs("details",{className:"text-xs",children:[o.jsxs("summary",{className:"cursor-pointer font-medium",children:["Tool: ",q.name]}),o.jsxs("div",{className:"mt-1 space-y-1",children:[o.jsx("div",{className:"text-[hsl(var(--muted-foreground))]",children:"Input:"}),o.jsx(Jt,{data:q.args,collapsed:!0}),q.result!==void 0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-[hsl(var(--muted-foreground))]",children:"Output:"}),o.jsx(Jt,{data:q.result,collapsed:!0})]})]})]},O))})]})},Y)),o.jsx("div",{ref:_})]}),o.jsx("div",{className:"border-t border-[hsl(var(--border))] pt-4",children:o.jsxs("div",{className:"flex items-end gap-2",children:[o.jsx("textarea",{value:r,onChange:U=>c(U.target.value),onKeyDown:L,placeholder:"Type a message...",rows:1,className:"flex-1 px-3 py-2.5 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))] resize-none focus:outline-none focus:ring-2 focus:ring-[hsl(var(--ring))]"}),o.jsx("button",{onClick:R,disabled:!r.trim()||T,className:"p-2.5 rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:opacity-90 disabled:opacity-50 transition-opacity",children:o.jsx(Bb,{size:16})})]})})]})})}function Tv({value:u,onChange:i,placeholder:r,className:c}){const[d,m]=j.useState(null),y=j.useCallback(p=>{const x=p.target.value;i(x);try{x.trim()&&JSON.parse(x),m(null)}catch(v){m(v instanceof Error?v.message:"Invalid JSON")}},[i]);return o.jsxs("div",{className:c,children:[o.jsx("textarea",{value:u,onChange:y,placeholder:r??"{}",className:"w-full h-32 p-3 text-xs font-mono rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))] text-[hsl(var(--foreground))] resize-y focus:outline-none focus:ring-2 focus:ring-[hsl(var(--ring))]",spellCheck:!1}),d&&o.jsx("p",{className:"text-xs text-red-500 mt-1",children:d})]})}function Cv({schema:u,onSubmit:i,submitLabel:r="Submit",className:c}){const[d,m]=j.useState({}),y=u.properties??{},p=new Set(u.required??[]),x=j.useCallback(v=>{v.preventDefault();const T={};for(const[g,_]of Object.entries(y)){const w=d[g]??"";if(!(!w&&!p.has(g)))if(_.type==="number")T[g]=Number(w);else if(_.type==="boolean")T[g]=w==="true";else if(_.type==="object"||_.type==="array")try{T[g]=JSON.parse(w)}catch{T[g]=w}else T[g]=w}i(T)},[d,y,p,i]);return o.jsxs("form",{onSubmit:x,className:`space-y-3 ${c??""}`,children:[Object.entries(y).map(([v,T])=>o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs font-medium text-[hsl(var(--foreground))] mb-1",children:[v,p.has(v)&&o.jsx("span",{className:"text-red-500 ml-0.5",children:"*"}),T.description&&o.jsxs("span",{className:"text-[hsl(var(--muted-foreground))] font-normal ml-1",children:["- ",T.description]})]}),T.enum?o.jsxs("select",{value:d[v]??"",onChange:g=>m({...d,[v]:g.target.value}),className:"w-full px-2 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))]",children:[o.jsx("option",{value:"",children:"Select..."}),T.enum.map(g=>o.jsx("option",{value:g,children:g},g))]}):T.type==="boolean"?o.jsxs("select",{value:d[v]??"",onChange:g=>m({...d,[v]:g.target.value}),className:"w-full px-2 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))]",children:[o.jsx("option",{value:"",children:"Select..."}),o.jsx("option",{value:"true",children:"true"}),o.jsx("option",{value:"false",children:"false"})]}):o.jsx("input",{type:T.type==="number"?"number":"text",value:d[v]??"",onChange:g=>m({...d,[v]:g.target.value}),placeholder:T.type??"string",className:"w-full px-2 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))]"})]},v)),o.jsx("button",{type:"submit",className:"px-4 py-2 text-sm font-medium rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:opacity-90 transition-opacity",children:r})]})}function Ov({status:u,className:i}){return o.jsxs("span",{className:_o("inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium",Kb(u),u==="running"&&"animate-pulse",i),children:[o.jsx("span",{className:_o("w-1.5 h-1.5 rounded-full",u==="running"&&"bg-blue-500",u==="completed"&&"bg-green-500",u==="failed"&&"bg-red-500",u==="waiting"&&"bg-amber-500")}),u]})}function xa({cost:u,className:i}){return o.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-mono bg-[hsl(var(--secondary))] text-[hsl(var(--secondary-foreground))] ${i??""}`,children:jv(u)})}function Do({ms:u,className:i}){return o.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-mono bg-[hsl(var(--secondary))] text-[hsl(var(--secondary-foreground))] ${i??""}`,children:Zb(u)})}function S1(){const[u,i]=j.useState(""),[r,c]=j.useState("{}"),[d,m]=j.useState(!0),[y,p]=j.useState(null),[x,v]=j.useState(null),[T,g]=j.useState(null),[_,w]=j.useState("idle"),{data:Z=[]}=kt({queryKey:["workflows"],queryFn:$b}),{data:R}=kt({queryKey:["workflow",u],queryFn:()=>Wb(u),enabled:!!u}),L=Nv(y),U=j.useCallback(async V=>{if(u){v(null),g(null),w("running");try{const k=await Ib(u,V,!0);k.streaming&&k.executionId?p(k.executionId):(v(k.result),w("completed"))}catch(k){g(k instanceof Error?k.message:String(k)),w("failed")}}},[u]),Y=j.useCallback(()=>{try{const V=JSON.parse(r);U(V)}catch(V){g(V instanceof Error?V.message:String(V)),w("failed")}},[r,U]),q=j.useCallback(V=>{U(V)},[U]);j.useEffect(()=>{L.done&&_==="running"&&(w(L.error?"failed":"completed"),L.error&&g(L.error),L.result&&v(L.result),p(null))},[L.done,L.error,L.result,_]);const O=L.events.filter(V=>V.type==="step").map(V=>V.data),K=!!(R!=null&&R.inputSchema);return o.jsx(ql,{title:"Workflow Runner",description:"Execute and debug registered workflows",children:o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium mb-1",children:"Workflow"}),o.jsxs("select",{value:u,onChange:V=>{i(V.target.value),c("{}"),v(null),g(null),w("idle")},className:"w-full px-3 py-2 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))]",children:[o.jsx("option",{value:"",children:"Select a workflow..."}),Z.map(V=>o.jsx("option",{value:V.name,children:V.name},V.name))]})]}),(R==null?void 0:R.outputSchema)!=null&&o.jsxs("details",{className:"text-xs",children:[o.jsx("summary",{className:"cursor-pointer text-[hsl(var(--muted-foreground))]",children:"Output Schema"}),o.jsx("div",{className:"mt-1",children:o.jsx(Jt,{data:R.outputSchema,collapsed:!0})})]}),K&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("label",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:"Input mode:"}),o.jsx("button",{onClick:()=>m(!0),className:`px-2 py-0.5 text-xs rounded ${d?"bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))]":"border border-[hsl(var(--input))]"}`,children:"Form"}),o.jsx("button",{onClick:()=>m(!1),className:`px-2 py-0.5 text-xs rounded ${d?"border border-[hsl(var(--input))]":"bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))]"}`,children:"JSON"})]}),K&&d?o.jsx(Cv,{schema:R.inputSchema,onSubmit:q,submitLabel:_==="running"?"Running...":"Execute"}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium mb-1",children:"Input (JSON)"}),o.jsx(Tv,{value:r,onChange:c})]}),o.jsxs("button",{onClick:Y,disabled:!u||_==="running",className:"flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:opacity-90 disabled:opacity-50",children:[o.jsx(xv,{size:14}),"Execute"]})]})]}),o.jsxs("div",{className:"space-y-4",children:[_!=="idle"&&o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Ov,{status:_}),L.events.length>0&&o.jsxs(o.Fragment,{children:[O.some(V=>V.cost)&&o.jsx(xa,{cost:O.reduce((V,k)=>V+(k.cost??0),0)}),O.some(V=>V.duration)&&o.jsx(Do,{ms:O.reduce((V,k)=>V+(k.duration??0),0)})]})]}),O.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium mb-2",children:"Timeline"}),o.jsx("div",{className:"space-y-1.5",children:O.map((V,k)=>o.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded bg-[hsl(var(--secondary))]",children:[o.jsxs("span",{className:"font-mono text-[hsl(var(--muted-foreground))]",children:["#",V.step]}),o.jsx("span",{className:"font-medium",children:V.type}),V.agent&&o.jsx("span",{className:"text-[hsl(var(--muted-foreground))]",children:V.agent}),V.tool&&o.jsx("span",{className:"text-[hsl(var(--muted-foreground))]",children:V.tool}),o.jsx("span",{className:"flex-1"}),V.duration&&o.jsx(Do,{ms:V.duration}),V.cost&&o.jsx(xa,{cost:V.cost})]},k))})]}),x!==null&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium mb-2",children:"Result"}),o.jsx(Jt,{data:x})]}),T&&o.jsx("div",{className:"p-3 rounded-md bg-red-50 dark:bg-red-950 border border-red-200 dark:border-red-800 text-red-700 dark:text-red-300 text-sm",children:T}),_==="idle"&&o.jsx(Vt,{title:"No execution",description:"Select a workflow and click Execute to see results."})]})]})})}const E1={agent_call:"bg-blue-500",tool_call:"bg-purple-500",tool_call_complete:"bg-purple-400",workflow_start:"bg-green-500",workflow_complete:"bg-green-400",handoff:"bg-amber-500",await_human:"bg-red-500",vote_start:"bg-cyan-500",spawn:"bg-indigo-500"};function Ty(u){return E1[u]??"bg-slate-500"}function j1(u){const i=u.type;return i==="workflow_start"||i==="workflow_complete"?0:i==="agent_call"||i==="spawn"||i==="vote_start"?1:i==="tool_call"||i==="tool_call_complete"||i==="handoff"?2:1}function N1(){const[u,i]=j.useState(null),[r,c]=j.useState([]),[d,m]=j.useState(""),[y,p]=j.useState(""),{data:x=[],refetch:v}=kt({queryKey:["executions"],queryFn:Pb,refetchInterval:3e3});Jo("trace:*",j.useCallback(R=>{c(L=>[...L.slice(-200),R])},[]));const T=u?u.steps:r;let g=T;d&&(g=g.filter(R=>R.type===d)),y&&(g=g.filter(R=>R.agent===y));const _=[...new Set(T.map(R=>R.type))],w=[...new Set(T.map(R=>R.agent).filter(Boolean))],Z=Math.max(...g.map(R=>R.duration??0),1);return o.jsx(ql,{title:"Trace Explorer",description:"Inspect execution traces with waterfall visualization",actions:o.jsx("button",{onClick:()=>{v(),c([])},className:"px-3 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] hover:bg-[hsl(var(--accent))]",children:"Refresh"}),children:o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6",children:[o.jsxs("div",{className:"lg:col-span-1 space-y-2",children:[o.jsx("h3",{className:"text-sm font-medium mb-2",children:"Executions"}),o.jsxs("button",{onClick:()=>i(null),className:`w-full text-left px-3 py-2 text-xs rounded-md border ${u?"border-[hsl(var(--border))]":"border-[hsl(var(--primary))] bg-[hsl(var(--accent))]"}`,children:["Live Events (",r.length,")"]}),x.map(R=>o.jsxs("button",{onClick:()=>i(R),className:`w-full text-left px-3 py-2 text-xs rounded-md border ${(u==null?void 0:u.executionId)===R.executionId?"border-[hsl(var(--primary))] bg-[hsl(var(--accent))]":"border-[hsl(var(--border))] hover:bg-[hsl(var(--accent))]"}`,children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-medium truncate",children:R.workflow}),o.jsx(Ov,{status:R.status})]}),o.jsxs("div",{className:"flex items-center justify-between mt-0.5",children:[o.jsxs("span",{className:"text-[hsl(var(--muted-foreground))] truncate",children:[R.executionId.slice(0,8),"... | ",R.steps.length," steps"]}),R.totalCost>0&&o.jsx(xa,{cost:R.totalCost})]})]},R.executionId)),x.length===0&&o.jsx("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:"No executions yet"})]}),o.jsxs("div",{className:"lg:col-span-3",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4 flex-wrap",children:[o.jsxs("select",{value:d,onChange:R=>m(R.target.value),className:"px-2 py-1 text-xs rounded border border-[hsl(var(--input))] bg-[hsl(var(--background))]",children:[o.jsx("option",{value:"",children:"All types"}),_.map(R=>o.jsx("option",{value:R,children:R},R))]}),w.length>0&&o.jsxs("select",{value:y,onChange:R=>p(R.target.value),className:"px-2 py-1 text-xs rounded border border-[hsl(var(--input))] bg-[hsl(var(--background))]",children:[o.jsx("option",{value:"",children:"All agents"}),w.map(R=>o.jsx("option",{value:R,children:R},R))]}),o.jsxs("span",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:[g.length," events"]})]}),g.length===0?o.jsx(Vt,{icon:o.jsx(yv,{size:32}),title:"No trace events",description:"Execute a workflow to see trace events here."}):o.jsx("div",{className:"space-y-1",children:g.map((R,L)=>{const U=j1(R);return o.jsxs("details",{className:"group",children:[o.jsxs("summary",{className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded bg-[hsl(var(--secondary))] cursor-pointer hover:bg-[hsl(var(--accent))]",style:{marginLeft:`${U*16}px`},children:[o.jsxs("span",{className:"font-mono text-[hsl(var(--muted-foreground))] w-8",children:["#",R.step]}),o.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Ty(R.type)}`}),o.jsx("span",{className:"font-medium w-28 truncate",children:R.type}),R.agent&&o.jsx("span",{className:"text-blue-600 dark:text-blue-400 w-28 truncate",children:R.agent}),R.tool&&o.jsx("span",{className:"text-purple-600 dark:text-purple-400 w-28 truncate",children:R.tool}),o.jsx("div",{className:"flex-1 h-3 bg-[hsl(var(--background))] rounded overflow-hidden",children:R.duration&&o.jsx("div",{className:`h-full rounded ${Ty(R.type)}`,style:{width:`${Math.max(R.duration/Z*100,2)}%`,opacity:.7}})}),R.duration&&o.jsx(Do,{ms:R.duration}),R.cost&&o.jsx(xa,{cost:R.cost})]}),o.jsxs("div",{className:"mt-1 mb-2 p-3 rounded bg-[hsl(var(--card))] border border-[hsl(var(--border))]",style:{marginLeft:`${U*16+32}px`},children:[R.model&&o.jsxs("p",{className:"text-xs mb-1",children:[o.jsx("strong",{children:"Model:"})," ",R.model]}),R.promptVersion&&o.jsxs("p",{className:"text-xs mb-1",children:[o.jsx("strong",{children:"Version:"})," ",R.promptVersion]}),R.tokens&&o.jsxs("p",{className:"text-xs mb-1",children:[o.jsx("strong",{children:"Tokens:"})," in=",R.tokens.input," out=",R.tokens.output,R.tokens.reasoning?` reasoning=${R.tokens.reasoning}`:""]}),R.data!=null&&o.jsx(Jt,{data:R.data,collapsed:!0})]})]},L)})})]})]})})}function T1({tokens:u,label:i,className:r}){return o.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-mono bg-[hsl(var(--secondary))] text-[hsl(var(--secondary-foreground))] ${r??""}`,children:[i&&o.jsx("span",{className:"text-[hsl(var(--muted-foreground))]",children:i}),Ds(u)]})}function C1(){const[u,i]=j.useState(null),{data:r,refetch:c}=kt({queryKey:["costs"],queryFn:f1});Jo("costs",j.useCallback(y=>{i(y)},[]));const d=u??r,m=async()=>{await d1(),i(null),c()};return d?o.jsxs(ql,{title:"Cost Dashboard",description:"Track spending across agents, models, and workflows",actions:o.jsx("button",{onClick:m,className:"px-3 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] hover:bg-[hsl(var(--accent))]",children:"Reset"}),children:[o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-8",children:[o.jsx(As,{label:"Total Cost",value:jv(d.totalCost)}),o.jsx(As,{label:"Input Tokens",value:Ds(d.totalTokens.input)}),o.jsx(As,{label:"Output Tokens",value:Ds(d.totalTokens.output)}),o.jsx(As,{label:"Reasoning Tokens",value:Ds(d.totalTokens.reasoning)})]}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium mb-3",children:"Cost by Agent"}),Object.keys(d.byAgent).length===0?o.jsx("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:"No agent data"}):o.jsxs("table",{className:"w-full text-xs",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("th",{className:"text-left py-2 font-medium",children:"Agent"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Calls"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Cost"})]})}),o.jsx("tbody",{children:Object.entries(d.byAgent).sort(([,y],[,p])=>p.cost-y.cost).map(([y,p])=>o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("td",{className:"py-2 font-mono",children:y}),o.jsx("td",{className:"py-2 text-right",children:p.calls}),o.jsx("td",{className:"py-2 text-right",children:o.jsx(xa,{cost:p.cost})})]},y))})]})]}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium mb-3",children:"Cost by Model"}),Object.keys(d.byModel).length===0?o.jsx("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:"No model data"}):o.jsxs("table",{className:"w-full text-xs",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("th",{className:"text-left py-2 font-medium",children:"Model"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Calls"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Tokens"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Cost"})]})}),o.jsx("tbody",{children:Object.entries(d.byModel).sort(([,y],[,p])=>p.cost-y.cost).map(([y,p])=>o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("td",{className:"py-2 font-mono",children:y}),o.jsx("td",{className:"py-2 text-right",children:p.calls}),o.jsx("td",{className:"py-2 text-right",children:o.jsx(T1,{tokens:p.tokens.input+p.tokens.output})}),o.jsx("td",{className:"py-2 text-right",children:o.jsx(xa,{cost:p.cost})})]},y))})]})]}),o.jsxs("div",{className:"lg:col-span-2",children:[o.jsx("h3",{className:"text-sm font-medium mb-3",children:"Cost by Workflow"}),Object.keys(d.byWorkflow).length===0?o.jsx("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:"No workflow data"}):o.jsxs("table",{className:"w-full text-xs",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("th",{className:"text-left py-2 font-medium",children:"Workflow"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Executions"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Total Cost"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Avg Cost"})]})}),o.jsx("tbody",{children:Object.entries(d.byWorkflow).sort(([,y],[,p])=>p.cost-y.cost).map(([y,p])=>o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("td",{className:"py-2 font-mono",children:y}),o.jsx("td",{className:"py-2 text-right",children:p.executions}),o.jsx("td",{className:"py-2 text-right",children:o.jsx(xa,{cost:p.cost})}),o.jsx("td",{className:"py-2 text-right",children:o.jsx(xa,{cost:p.executions>0?p.cost/p.executions:0})})]},y))})]})]})]})]}):o.jsx(ql,{title:"Cost Dashboard",description:"Track spending across agents, models, and workflows",children:o.jsx(Vt,{icon:o.jsx(pv,{size:32}),title:"No cost data",description:"Execute workflows to see cost data."})})}function As({label:u,value:i}){return o.jsxs("div",{className:"p-4 rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--card))]",children:[o.jsx("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:u}),o.jsx("p",{className:"text-2xl font-semibold mt-1",children:i})]})}function O1(){const[u,i]=j.useState("session"),[r,c]=j.useState(""),[d,m]=j.useState("{}"),[y,p]=j.useState(!1),[x,v]=j.useState(""),[T,g]=j.useState(null),_=ui(),{data:w=[]}=kt({queryKey:["memory",u],queryFn:()=>s1(u)}),Z=Ro({mutationFn:({key:Y,value:q})=>r1(u,Y,q),onSuccess:()=>{_.invalidateQueries({queryKey:["memory",u]}),p(!1),c(""),m("{}")}}),R=Ro({mutationFn:Y=>c1(u,Y),onSuccess:()=>{_.invalidateQueries({queryKey:["memory",u]})}}),L=j.useCallback(async()=>{if(!x.trim())return;const Y=await o1(x,u);g(Y.results)},[x,u]),U=j.useCallback(()=>{if(r.trim())try{const Y=JSON.parse(d);Z.mutate({key:r,value:Y})}catch{Z.mutate({key:r,value:d})}},[r,d,Z]);return o.jsxs(ql,{title:"Memory Browser",description:"View and manage agent memory entries",actions:o.jsxs("button",{onClick:()=>p(!y),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:opacity-90",children:[o.jsx(Ub,{size:14}),"Add Entry"]}),children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[["session","global"].map(Y=>o.jsx("button",{onClick:()=>{i(Y),g(null)},className:`px-3 py-1.5 text-sm rounded-md ${u===Y?"bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))]":"border border-[hsl(var(--input))] hover:bg-[hsl(var(--accent))]"}`,children:Y.charAt(0).toUpperCase()+Y.slice(1)},Y)),o.jsx("div",{className:"flex-1"}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("input",{value:x,onChange:Y=>v(Y.target.value),onKeyDown:Y=>Y.key==="Enter"&&L(),placeholder:"Semantic search...",className:"px-2 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))] w-48"}),o.jsx("button",{onClick:L,className:"p-1.5 rounded-md hover:bg-[hsl(var(--accent))]",children:o.jsx(Hb,{size:14})})]})]}),y&&o.jsxs("div",{className:"mb-4 p-4 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--card))] space-y-3",children:[o.jsx("input",{value:r,onChange:Y=>c(Y.target.value),placeholder:"Key",className:"w-full px-2 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))]"}),o.jsx(Tv,{value:d,onChange:m,placeholder:"Value (JSON)"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:U,disabled:!r.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:opacity-90 disabled:opacity-50",children:"Save"}),o.jsx("button",{onClick:()=>p(!1),className:"px-3 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] hover:bg-[hsl(var(--accent))]",children:"Cancel"})]})]}),T&&o.jsxs("div",{className:"mb-4 p-4 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--card))]",children:[o.jsx("h3",{className:"text-sm font-medium mb-2",children:"Search Results"}),T.length===0?o.jsx("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:"No results found"}):o.jsx(Jt,{data:T})]}),w.length===0?o.jsx(Vt,{icon:o.jsx(vv,{size:32}),title:"No memory entries",description:`No entries in the ${u} scope. Use ctx.remember() in workflows or add entries manually.`}):o.jsx("div",{className:"space-y-2",children:w.map(Y=>o.jsxs("div",{className:"p-3 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--card))]",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("span",{className:"text-sm font-mono font-medium",children:Y.key}),o.jsx("button",{onClick:()=>R.mutate(Y.key),className:"p-1 rounded hover:bg-[hsl(var(--destructive))] hover:text-[hsl(var(--destructive-foreground))] text-[hsl(var(--muted-foreground))]",children:o.jsx(bv,{size:14})})]}),o.jsx(Jt,{data:Y.value,collapsed:!0})]},Y.key))})]})}function R1(){const[u,i]=j.useState(null),[r,c]=j.useState(null),d=ui(),{data:m=[]}=kt({queryKey:["sessions"],queryFn:e1,refetchInterval:5e3}),{data:y}=kt({queryKey:["session",u],queryFn:()=>t1(u),enabled:!!u}),p=Ro({mutationFn:l1,onSuccess:()=>{d.invalidateQueries({queryKey:["sessions"]}),i(null)}}),x=y!=null&&y.history?r!==null?y.history.slice(0,r+1):y.history:[];return o.jsx(ql,{title:"Session Manager",description:"Browse active sessions, replay conversations, and view handoff chains",children:o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs("h3",{className:"text-sm font-medium mb-2",children:["Sessions (",m.length,")"]}),m.length===0?o.jsx(Vt,{icon:o.jsx(Sv,{size:24}),title:"No sessions",description:"Sessions are created when using runtime.session()"}):m.map(v=>o.jsxs("button",{onClick:()=>{i(v.id),c(null)},className:`w-full text-left px-3 py-2 text-xs rounded-md border ${u===v.id?"border-[hsl(var(--primary))] bg-[hsl(var(--accent))]":"border-[hsl(var(--border))] hover:bg-[hsl(var(--accent))]"}`,children:[o.jsx("div",{className:"font-mono truncate",children:v.id}),o.jsxs("div",{className:"text-[hsl(var(--muted-foreground))] mt-0.5",children:[v.messageCount," messages"]})]},v.id))]}),o.jsx("div",{className:"lg:col-span-2",children:y?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium font-mono",children:y.id}),o.jsxs("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:[y.history.length," messages"]})]}),o.jsxs("button",{onClick:()=>p.mutate(y.id),className:"flex items-center gap-1 px-2 py-1 text-xs rounded-md border border-red-300 text-red-600 hover:bg-red-50 dark:border-red-800 dark:text-red-400 dark:hover:bg-red-950",children:[o.jsx(bv,{size:12}),"Delete"]})]}),y.handoffHistory&&y.handoffHistory.length>0&&o.jsxs("div",{children:[o.jsx("h4",{className:"text-xs font-medium mb-2",children:"Handoff Chain"}),o.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:y.handoffHistory.map((v,T)=>o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"px-2 py-0.5 text-xs rounded bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300",children:v.source}),o.jsx(zo,{size:12,className:"text-[hsl(var(--muted-foreground))]"}),o.jsx("span",{className:"px-2 py-0.5 text-xs rounded bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300",children:v.target}),o.jsxs("span",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:["(",v.mode,")"]}),T<y.handoffHistory.length-1&&o.jsx("span",{className:"mx-1 text-[hsl(var(--muted-foreground))]",children:"|"})]},T))})]}),y.history.length>1&&o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs font-medium mb-1",children:["Replay:"," ",r!==null?`${r+1} / ${y.history.length}`:"All"]}),o.jsx("input",{type:"range",min:0,max:y.history.length-1,value:r??y.history.length-1,onChange:v=>c(Number(v.target.value)),className:"w-full"})]}),o.jsx("div",{className:"space-y-3",children:x.map((v,T)=>o.jsxs("div",{className:`p-3 rounded-md text-sm ${v.role==="user"?"bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] ml-8":v.role==="assistant"?"bg-[hsl(var(--secondary))] mr-8":"bg-[hsl(var(--muted))] text-xs font-mono"}`,children:[o.jsx("div",{className:"text-xs font-medium mb-1 opacity-70",children:v.role}),o.jsx("div",{className:"whitespace-pre-wrap",children:v.content}),v.tool_calls&&v.tool_calls.length>0&&o.jsx("div",{className:"mt-2 space-y-1",children:v.tool_calls.map(g=>o.jsxs("details",{className:"text-xs",children:[o.jsx("summary",{className:"cursor-pointer font-mono",children:g.function.name}),o.jsx(Jt,{data:JSON.parse(g.function.arguments),collapsed:!0})]},g.id))})]},T))})]}):o.jsx(Vt,{title:"Select a session",description:"Click a session to view its history"})})]})})}function A1(){const[u,i]=j.useState(null),[r,c]=j.useState(null),[d,m]=j.useState(null),[y,p]=j.useState(!1),{data:x=[]}=kt({queryKey:["tools"],queryFn:n1}),{data:v}=kt({queryKey:["tool",u],queryFn:()=>u1(u),enabled:!!u}),T=j.useCallback(async g=>{if(u){c(null),m(null),p(!0);try{const _=await i1(u,g);c(_.result)}catch(_){m(_ instanceof Error?_.message:String(_))}finally{p(!1)}}},[u]);return o.jsx(ql,{title:"Tool Inspector",description:"View tool schemas and test tools directly",children:o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs("h3",{className:"text-sm font-medium mb-2",children:["Tools (",x.length,")"]}),x.length===0?o.jsx(Vt,{icon:o.jsx(Ev,{size:24}),title:"No tools",description:"Register tools with runtime.registerTool()"}):x.map(g=>o.jsxs("button",{onClick:()=>{i(g.name),c(null),m(null)},className:`w-full text-left px-3 py-2 text-xs rounded-md border ${u===g.name?"border-[hsl(var(--primary))] bg-[hsl(var(--accent))]":"border-[hsl(var(--border))] hover:bg-[hsl(var(--accent))]"}`,children:[o.jsx("div",{className:"font-medium",children:g.name}),o.jsx("div",{className:"text-[hsl(var(--muted-foreground))] mt-0.5 truncate",children:g.description}),o.jsxs("div",{className:"flex items-center gap-1.5 mt-1",children:[g.sensitive&&o.jsx("span",{className:"px-1 py-0.5 rounded bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300 text-[10px]",children:"sensitive"}),g.requireApproval&&o.jsx("span",{className:"px-1 py-0.5 rounded bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 text-[10px]",children:"approval"})]})]},g.name))]}),o.jsx("div",{className:"lg:col-span-2",children:u?v?o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-medium",children:v.name}),o.jsx("p",{className:"text-sm text-[hsl(var(--muted-foreground))]",children:v.description})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[v.sensitive&&o.jsx("span",{className:"px-2 py-1 text-xs rounded-md bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300",children:"Sensitive"}),v.requireApproval&&o.jsx("span",{className:"px-2 py-1 text-xs rounded-md bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300",children:"Requires Approval"}),v.retry.attempts&&v.retry.attempts>1&&o.jsxs("span",{className:"px-2 py-1 text-xs rounded-md bg-green-100 dark:bg-green-900 text-green-700 dark:text-green-300",children:["Retry: ",v.retry.attempts,"x ",v.retry.backoff]}),v.hasHooks&&v.hooks&&o.jsxs("span",{className:"px-2 py-1 text-xs rounded-md bg-purple-100 dark:bg-purple-900 text-purple-700 dark:text-purple-300",children:["Hooks:"," ",[v.hooks.hasBefore&&"before",v.hooks.hasAfter&&"after"].filter(Boolean).join(" + ")]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"text-sm font-medium mb-2",children:"Input Schema"}),o.jsx(Jt,{data:v.inputSchema})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"text-sm font-medium mb-2",children:"Test Tool"}),o.jsx(Cv,{schema:v.inputSchema,onSubmit:T,submitLabel:y?"Running...":"Run Tool"})]}),r!==null&&o.jsxs("div",{children:[o.jsx("h4",{className:"text-sm font-medium mb-2",children:"Result"}),o.jsx(Jt,{data:r})]}),d&&o.jsx("div",{className:"p-3 rounded-md bg-red-50 dark:bg-red-950 border border-red-200 dark:border-red-800 text-red-700 dark:text-red-300 text-sm",children:d})]}):o.jsx("div",{className:"text-sm text-[hsl(var(--muted-foreground))]",children:"Loading..."}):o.jsx(Vt,{title:"Select a tool",description:"Click a tool to view its schema and test it"})})]})})}function M1(){var q;const u=ui(),[i,r]=j.useState("run"),[c,d]=j.useState(""),[m,y]=j.useState(!1),[p,x]=j.useState(null),[v,T]=j.useState(null),[g,_]=j.useState(null),{data:w=[]}=kt({queryKey:["evals"],queryFn:h1}),{data:Z=[]}=kt({queryKey:["evalHistory"],queryFn:m1}),R=w.find(O=>O.name===c),L=j.useCallback(async()=>{if(c){y(!0),T(null),x(null);try{const O=await y1(c);x(O),u.invalidateQueries({queryKey:["evalHistory"]})}catch(O){T(O instanceof Error?O.message:String(O))}finally{y(!1)}}},[c,u]),U=j.useCallback(async()=>{if(!(Z.length<2))try{const O=Z[1].data,K=Z[0].data,V=await v1(O,K);_(V)}catch(O){T(O instanceof Error?O.message:String(O))}},[Z]),Y=(q=p==null?void 0:p.summary)!=null&&q.scorers?Object.entries(p.summary.scorers):[];return o.jsxs(ql,{title:"Eval Runner",description:"Run evaluations, view results, and compare runs",children:[o.jsx("div",{className:"flex items-center gap-1 mb-6",children:["run","history","compare"].map(O=>o.jsx("button",{onClick:()=>r(O),className:`px-3 py-1.5 text-sm rounded-md ${i===O?"bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))]":"border border-[hsl(var(--input))] hover:bg-[hsl(var(--accent))]"}`,children:O.charAt(0).toUpperCase()+O.slice(1)},O))}),i==="run"&&o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium mb-1",children:"Eval"}),w.length===0?o.jsxs("p",{className:"text-sm text-[hsl(var(--muted-foreground))]",children:["No evals registered. Define evals with"," ",o.jsx("code",{className:"text-xs bg-[hsl(var(--muted))] px-1 py-0.5 rounded",children:"defineEval()"})," ","and load them via the"," ",o.jsx("code",{className:"text-xs bg-[hsl(var(--muted))] px-1 py-0.5 rounded",children:"evals"})," ","middleware option or"," ",o.jsx("code",{className:"text-xs bg-[hsl(var(--muted))] px-1 py-0.5 rounded",children:"runtime.registerEval()"}),"."]}):o.jsxs("select",{value:c,onChange:O=>d(O.target.value),className:"w-full px-3 py-2 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))]",children:[o.jsx("option",{value:"",children:"Select an eval..."}),w.map(O=>o.jsx("option",{value:O.name,children:O.name},O.name))]})]}),R&&o.jsxs("div",{className:"space-y-2 text-xs",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"font-medium text-[hsl(var(--muted-foreground))]",children:"Workflow:"}),o.jsx("span",{className:"font-mono",children:R.workflow})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"font-medium text-[hsl(var(--muted-foreground))]",children:"Dataset:"}),o.jsx("span",{className:"font-mono",children:R.dataset})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"font-medium text-[hsl(var(--muted-foreground))]",children:"Scorers:"}),o.jsx("div",{className:"flex flex-wrap gap-1",children:R.scorers.map(O=>o.jsx("span",{className:"px-1.5 py-0.5 rounded bg-[hsl(var(--muted))] font-mono",children:O},O))})]})]}),o.jsx("button",{onClick:L,disabled:!c||m,className:"px-4 py-2 text-sm font-medium rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:opacity-90 disabled:opacity-50",children:m?"Running...":"Run Eval"})]}),o.jsxs("div",{children:[v&&o.jsx("div",{className:"p-3 rounded-md bg-red-50 dark:bg-red-950 border border-red-200 dark:border-red-800 text-red-700 dark:text-red-300 text-sm mb-4",children:v}),p?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-4 text-xs text-[hsl(var(--muted-foreground))]",children:[o.jsxs("span",{children:[p.summary.count," items, ",p.summary.failures," failures"]}),p.duration>0&&o.jsxs("span",{children:[(p.duration/1e3).toFixed(1),"s"]}),p.totalCost>0&&o.jsxs("span",{children:["$",p.totalCost.toFixed(4)]})]}),Y.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium mb-2",children:"Summary"}),o.jsxs("table",{className:"w-full text-xs",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("th",{className:"text-left py-2 font-medium",children:"Scorer"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Mean"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"P50"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"P95"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Min"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Max"})]})}),o.jsx("tbody",{children:Y.map(([O,K])=>{const V=p.items.some(k=>!k.error&&k.scores[O]!=null);return o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("td",{className:"py-2 font-mono",children:O}),V?o.jsxs(o.Fragment,{children:[o.jsx("td",{className:"py-2 text-right font-mono",children:K.mean.toFixed(3)}),o.jsx("td",{className:"py-2 text-right font-mono",children:K.p50.toFixed(3)}),o.jsx("td",{className:"py-2 text-right font-mono",children:K.p95.toFixed(3)}),o.jsx("td",{className:"py-2 text-right font-mono",children:K.min.toFixed(3)}),o.jsx("td",{className:"py-2 text-right font-mono",children:K.max.toFixed(3)})]}):o.jsx("td",{colSpan:5,className:"py-2 text-center text-[hsl(var(--muted-foreground))]",children:"No valid scores"})]},O)})})]})]}),p.items&&p.items.length>0&&o.jsxs("div",{children:[o.jsxs("h3",{className:"text-sm font-medium mb-2",children:["Items (",p.items.length,")"]}),o.jsx("div",{className:"space-y-2",children:p.items.map((O,K)=>o.jsxs("details",{className:"border border-[hsl(var(--border))] rounded-md",children:[o.jsxs("summary",{className:"flex items-center justify-between px-3 py-2 text-xs cursor-pointer hover:bg-[hsl(var(--accent))]",children:[o.jsxs("span",{className:"font-mono",children:["Item #",K+1,O.error&&o.jsx("span",{className:"ml-2 text-red-600 dark:text-red-400",children:"(error)"}),O.errors&&O.errors.length>0&&!O.error&&o.jsx("span",{className:"ml-2 text-amber-600 dark:text-amber-400",children:"(scorer errors)"})]}),o.jsx("div",{className:"flex items-center gap-2",children:Object.entries(O.scores).filter(([,V])=>V!=null).map(([V,k])=>o.jsxs("span",{className:`px-1.5 py-0.5 rounded font-mono ${k>=.8?"bg-green-100 dark:bg-green-900 text-green-700 dark:text-green-300":k>=.5?"bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300":"bg-red-100 dark:bg-red-900 text-red-700 dark:text-red-300"}`,children:[V,": ",k.toFixed(2)]},V))})]}),o.jsxs("div",{className:"px-3 py-2 border-t border-[hsl(var(--border))] space-y-2 text-xs",children:[o.jsxs("div",{children:[o.jsx("span",{className:"font-medium",children:"Input:"}),o.jsx(Jt,{data:O.input,collapsed:!0})]}),o.jsxs("div",{children:[o.jsx("span",{className:"font-medium",children:"Output:"}),o.jsx(Jt,{data:O.output,collapsed:!0})]}),O.error&&o.jsxs("div",{children:[o.jsx("span",{className:"font-medium text-red-600 dark:text-red-400",children:"Error:"}),o.jsx("span",{className:"ml-1",children:O.error})]}),O.errors&&O.errors.length>0&&o.jsxs("div",{children:[o.jsx("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Scorer errors:"}),o.jsx("ul",{className:"ml-4 mt-1 list-disc",children:O.errors.map((V,k)=>o.jsx("li",{className:"text-amber-700 dark:text-amber-300",children:V},k))})]})]})]},K))})]})]}):o.jsx(Vt,{icon:o.jsx(gv,{size:32}),title:"No results",description:"Select an eval and run it to see results."})]})]}),i==="history"&&o.jsx("div",{children:Z.length===0?o.jsx(Vt,{title:"No eval history",description:"Run evaluations to build history."}):o.jsxs("table",{className:"w-full text-xs",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("th",{className:"text-left py-2 font-medium",children:"Eval"}),o.jsx("th",{className:"text-left py-2 font-medium",children:"Timestamp"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Items"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Failures"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Cost"})]})}),o.jsx("tbody",{children:Z.map(O=>{const K=O.data;return o.jsxs("tr",{className:"border-b border-[hsl(var(--border))] cursor-pointer hover:bg-[hsl(var(--accent))]",onClick:()=>{x(K),r("run")},children:[o.jsx("td",{className:"py-2 font-mono",children:O.eval}),o.jsx("td",{className:"py-2",children:new Date(O.timestamp).toLocaleString()}),o.jsx("td",{className:"py-2 text-right",children:K.summary.count}),o.jsx("td",{className:"py-2 text-right",children:K.summary.failures>0?o.jsx("span",{className:"text-red-600 dark:text-red-400",children:K.summary.failures}):0}),o.jsx("td",{className:"py-2 text-right font-mono",children:K.totalCost>0?`$${K.totalCost.toFixed(4)}`:"-"})]},O.id)})})]})}),i==="compare"&&o.jsx("div",{className:"space-y-4",children:Z.length<2?o.jsx(Vt,{title:"Need at least 2 eval runs",description:"Run evaluations to compare results."}):o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-[hsl(var(--muted-foreground))]",children:"Comparing most recent run against previous run."}),o.jsx("button",{onClick:U,className:"px-4 py-2 text-sm font-medium rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:opacity-90",children:"Compare"}),g&&o.jsxs("div",{className:"space-y-4",children:[g.summary&&o.jsx("p",{className:"text-sm",children:g.summary}),g.scorers&&Object.keys(g.scorers).length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium mb-2",children:"Scorer Comparison"}),o.jsxs("table",{className:"w-full text-xs",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("th",{className:"text-left py-2 font-medium",children:"Scorer"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Baseline"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Candidate"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Delta"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"%"})]})}),o.jsx("tbody",{children:Object.entries(g.scorers).map(([O,K])=>o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("td",{className:"py-2 font-mono",children:O}),o.jsx("td",{className:"py-2 text-right font-mono",children:K.baselineMean.toFixed(3)}),o.jsx("td",{className:"py-2 text-right font-mono",children:K.candidateMean.toFixed(3)}),o.jsxs("td",{className:`py-2 text-right font-mono ${K.delta>0?"text-green-600 dark:text-green-400":K.delta<0?"text-red-600 dark:text-red-400":""}`,children:[K.delta>0?"+":"",K.delta.toFixed(3)]}),o.jsxs("td",{className:`py-2 text-right font-mono ${K.deltaPercent>0?"text-green-600 dark:text-green-400":K.deltaPercent<0?"text-red-600 dark:text-red-400":""}`,children:[K.deltaPercent>0?"+":"",K.deltaPercent.toFixed(1),"%"]})]},O))})]})]}),g.regressions&&g.regressions.length>0&&o.jsxs("div",{children:[o.jsxs("h3",{className:"text-sm font-medium mb-2 text-red-600 dark:text-red-400",children:["Regressions (",g.regressions.length,")"]}),o.jsx("div",{className:"space-y-1",children:g.regressions.map((O,K)=>o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 text-xs border border-[hsl(var(--border))] rounded",children:[o.jsx("span",{className:"font-mono",children:O.scorer}),o.jsxs("span",{className:"font-mono text-red-600 dark:text-red-400",children:[O.baseline.toFixed(2)," → ",O.candidate.toFixed(2)," (",O.delta.toFixed(2),")"]})]},K))})]}),g.improvements&&g.improvements.length>0&&o.jsxs("div",{children:[o.jsxs("h3",{className:"text-sm font-medium mb-2 text-green-600 dark:text-green-400",children:["Improvements (",g.improvements.length,")"]}),o.jsx("div",{className:"space-y-1",children:g.improvements.map((O,K)=>o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 text-xs border border-[hsl(var(--border))] rounded",children:[o.jsx("span",{className:"font-mono",children:O.scorer}),o.jsxs("span",{className:"font-mono text-green-600 dark:text-green-400",children:[O.baseline.toFixed(2)," → ",O.candidate.toFixed(2)," (+",O.delta.toFixed(2),")"]})]},K))})]})]})]})})]})}function z1(){return o.jsx(hb,{basename:window.__AXL_STUDIO_BASE__||"/",children:o.jsxs("div",{className:"flex h-screen overflow-hidden",children:[o.jsx(kb,{}),o.jsx("div",{className:"flex-1 overflow-hidden",children:o.jsxs(Xx,{children:[o.jsx(il,{path:"/playground",element:o.jsx(b1,{})}),o.jsx(il,{path:"/workflows",element:o.jsx(S1,{})}),o.jsx(il,{path:"/traces",element:o.jsx(N1,{})}),o.jsx(il,{path:"/costs",element:o.jsx(C1,{})}),o.jsx(il,{path:"/memory",element:o.jsx(O1,{})}),o.jsx(il,{path:"/sessions",element:o.jsx(R1,{})}),o.jsx(il,{path:"/tools",element:o.jsx(A1,{})}),o.jsx(il,{path:"/evals",element:o.jsx(M1,{})}),o.jsx(il,{path:"*",element:o.jsx(Yx,{to:"/playground",replace:!0})})]})})]})})}rg.createRoot(document.getElementById("root")).render(o.jsx(j.StrictMode,{children:o.jsx(Dg,{client:Kg,children:o.jsx(z1,{})})}));
|
|
150
|
+
*/const Xb=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]],Ev=Et("Wrench",Xb);function _o(...u){return u.filter(Boolean).join(" ")}function jv(u){return u===0?"$0.00":u<.01?`$${u.toFixed(4)}`:`$${u.toFixed(2)}`}function Zb(u){return u<1e3?`${Math.round(u)}ms`:u<6e4?`${(u/1e3).toFixed(1)}s`:`${(u/6e4).toFixed(1)}m`}function Ds(u){return u.toLocaleString()}function Kb(u){switch(u){case"running":return"text-blue-500";case"completed":return"text-green-500";case"failed":return"text-red-500";case"waiting":return"text-amber-500";default:return"text-gray-500"}}const Vb=[{to:"/playground",label:"Playground",icon:zb},{to:"/workflows",label:"Workflows",icon:xv},{to:"/traces",label:"Traces",icon:yv},{to:"/costs",label:"Costs",icon:pv},{to:"/memory",label:"Memory",icon:vv},{to:"/sessions",label:"Sessions",icon:Sv},{to:"/tools",label:"Tools",icon:Ev},{to:"/evals",label:"Evals",icon:gv}];function kb(){return o.jsxs("aside",{className:"w-56 border-r border-[hsl(var(--border))] bg-[hsl(var(--card))] flex flex-col h-screen",children:[o.jsx("div",{className:"p-4 border-b border-[hsl(var(--border))]",children:o.jsx("h1",{className:"text-lg font-semibold tracking-tight",children:"Axl Studio"})}),o.jsx("nav",{className:"flex-1 p-2 space-y-0.5",children:Vb.map(({to:u,label:i,icon:r})=>o.jsxs(dv,{to:u,className:({isActive:c})=>_o("flex items-center gap-2.5 px-3 py-2 rounded-md text-sm transition-colors",c?"bg-[hsl(var(--accent))] text-[hsl(var(--accent-foreground))] font-medium":"text-[hsl(var(--muted-foreground))] hover:bg-[hsl(var(--accent))] hover:text-[hsl(var(--accent-foreground))]"),children:[o.jsx(r,{size:16}),i]},u))}),o.jsx("div",{className:"p-4 border-t border-[hsl(var(--border))] text-xs text-[hsl(var(--muted-foreground))]",children:"@axlsdk/studio"})]})}function ql({title:u,description:i,actions:r,children:c}){return o.jsxs("div",{className:"flex flex-col h-screen",children:[o.jsxs("header",{className:"flex items-center justify-between px-6 py-4 border-b border-[hsl(var(--border))]",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-xl font-semibold",children:u}),i&&o.jsx("p",{className:"text-sm text-[hsl(var(--muted-foreground))] mt-0.5",children:i})]}),r&&o.jsx("div",{className:"flex items-center gap-2",children:r})]}),o.jsx("main",{className:"flex-1 overflow-auto p-6",children:c})]})}function Vt({title:u,description:i,icon:r}){return o.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[r&&o.jsx("div",{className:"mb-3 text-[hsl(var(--muted-foreground))]",children:r}),o.jsx("h3",{className:"text-sm font-medium text-[hsl(var(--foreground))]",children:u}),i&&o.jsx("p",{className:"text-sm text-[hsl(var(--muted-foreground))] mt-1 max-w-sm",children:i})]})}function Jb({text:u,className:i}){return o.jsxs("div",{className:`whitespace-pre-wrap ${i??""}`,children:[u,o.jsx("span",{className:"animate-pulse",children:"|"})]})}function Jt({data:u,collapsed:i=!1,className:r}){const[c,d]=j.useState(i),m=JSON.stringify(u,null,2),y=m.length>200;return o.jsxs("div",{className:`relative ${r??""}`,children:[y&&o.jsx("button",{onClick:()=>d(!c),className:"text-xs text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))] mb-1",children:c?"Expand":"Collapse"}),o.jsx("pre",{className:"text-xs font-mono p-3 rounded-md bg-[hsl(var(--secondary))] overflow-auto max-h-96",children:c?JSON.stringify(u):m})]})}const Fb=(window.__AXL_STUDIO_BASE__??"")+"/api";async function Qe(u,i){const c=await(await fetch(`${Fb}${u}`,{headers:{"Content-Type":"application/json",...i==null?void 0:i.headers},...i})).json();if(!c.ok)throw new Error(c.error.message);return c.data}const $b=()=>Qe("/workflows"),Wb=u=>Qe(`/workflows/${encodeURIComponent(u)}`),Ib=(u,i,r=!1)=>Qe(`/workflows/${encodeURIComponent(u)}/execute`,{method:"POST",body:JSON.stringify({input:i,stream:r})}),Pb=()=>Qe("/executions"),e1=()=>Qe("/sessions"),t1=u=>Qe(`/sessions/${encodeURIComponent(u)}`),l1=u=>Qe(`/sessions/${encodeURIComponent(u)}`,{method:"DELETE"}),a1=()=>Qe("/agents"),n1=()=>Qe("/tools"),u1=u=>Qe(`/tools/${encodeURIComponent(u)}`),i1=(u,i)=>Qe(`/tools/${encodeURIComponent(u)}/test`,{method:"POST",body:JSON.stringify({input:i})}),s1=u=>Qe(`/memory/${encodeURIComponent(u)}`),r1=(u,i,r)=>Qe(`/memory/${encodeURIComponent(u)}/${encodeURIComponent(i)}`,{method:"PUT",body:JSON.stringify({value:r})}),c1=(u,i)=>Qe(`/memory/${encodeURIComponent(u)}/${encodeURIComponent(i)}`,{method:"DELETE"}),o1=(u,i,r)=>Qe("/memory/search",{method:"POST",body:JSON.stringify({query:u,scope:i,limit:r})}),f1=()=>Qe("/costs"),d1=()=>Qe("/costs/reset",{method:"POST"}),h1=()=>Qe("/evals"),m1=()=>Qe("/evals/history"),y1=u=>Qe(`/evals/${encodeURIComponent(u)}/run`,{method:"POST"}),v1=(u,i)=>Qe("/evals/compare",{method:"POST",body:JSON.stringify({baseline:u,candidate:i})}),p1=(u,i,r)=>Qe("/playground/chat",{method:"POST",body:JSON.stringify({message:u,sessionId:i,agent:r})});class g1{constructor(){ku(this,"ws",null);ku(this,"listeners",new Map);ku(this,"reconnectTimer",null);ku(this,"url");const i=window.location.protocol==="https:"?"wss:":"ws:",r=window.__AXL_STUDIO_BASE__??"";this.url=`${i}//${window.location.host}${r}/ws`}connect(){var i;((i=this.ws)==null?void 0:i.readyState)!==WebSocket.OPEN&&(this.ws=new WebSocket(this.url),this.ws.onopen=()=>{for(const r of this.listeners.keys())this.send({type:"subscribe",channel:r})},this.ws.onmessage=r=>{try{const c=JSON.parse(r.data);if(c.type==="event"&&c.channel){const d=this.listeners.get(c.channel);if(d)for(const y of d)y(c.data);const m=c.channel.indexOf(":");if(m>0){const y=c.channel.substring(0,m)+":*",p=this.listeners.get(y);if(p)for(const x of p)x(c.data)}}}catch{}},this.ws.onclose=()=>{this.scheduleReconnect()},this.ws.onerror=()=>{var r;(r=this.ws)==null||r.close()})}scheduleReconnect(){this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},2e3))}send(i){var r;((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify(i))}subscribe(i,r){let c=this.listeners.get(i);return c||(c=new Set,this.listeners.set(i,c),this.send({type:"subscribe",channel:i})),c.add(r),this.connect(),()=>{c.delete(r),c.size===0&&(this.listeners.delete(i),this.send({type:"unsubscribe",channel:i}))}}disconnect(){var i;this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),(i=this.ws)==null||i.close(),this.ws=null}}const x1=new g1;function Jo(u,i){const r=j.useRef(i);r.current=i,j.useEffect(()=>{if(u)return x1.subscribe(u,c=>r.current(c))},[u])}function Nv(u){const[i,r]=j.useState({tokens:"",events:[],done:!1,error:null,result:null}),c=j.useCallback(d=>{const m=d;r(y=>{switch(m.type){case"token":return{...y,tokens:y.tokens+m.data,events:[...y.events,m]};case"done":return{...y,done:!0,result:m.result,events:[...y.events,m]};case"error":return{...y,done:!0,error:m.message,events:[...y.events,m]};default:return{...y,events:[...y.events,m]}}})},[]);return Jo(u?`execution:${u}`:null,c),i}function b1(){const[u,i]=j.useState([]),[r,c]=j.useState(""),[d,m]=j.useState(null),[y,p]=j.useState(null),[x,v]=j.useState(""),[T,g]=j.useState(!1),_=j.useRef(null),{data:w=[]}=kt({queryKey:["agents"],queryFn:a1}),Z=Nv(y);j.useEffect(()=>{Z.tokens&&T&&i(U=>{const Y=U[U.length-1];return(Y==null?void 0:Y.role)==="assistant"?[...U.slice(0,-1),{...Y,content:Z.tokens}]:[...U,{role:"assistant",content:Z.tokens}]}),Z.done&&(g(!1),p(null))},[Z.tokens,Z.done,T]),j.useEffect(()=>{const U=[],Y=[],q=[];for(const O of Z.events){if(O.type==="tool_call"&&U.push({name:O.name,args:O.args}),O.type==="tool_result"){const K=U.find(V=>V.name===O.name&&!V.result);K&&(K.result=O.result)}O.type==="handoff"&&Y.push({source:O.source,target:O.target,mode:O.mode??"oneway"}),O.type==="tool_approval"&&q.push({tool:O.name,approved:O.approved})}(U.length>0||Y.length>0||q.length>0)&&i(O=>{const K=O[O.length-1];return(K==null?void 0:K.role)==="assistant"?[...O.slice(0,-1),{...K,toolCalls:U.length>0?U:K.toolCalls,handoffs:Y.length>0?Y:K.handoffs,approvals:q.length>0?q:K.approvals}]:O})},[Z.events]),j.useEffect(()=>{var U;(U=_.current)==null||U.scrollIntoView({behavior:"smooth"})},[u]);const R=j.useCallback(async()=>{if(!r.trim()||T)return;const U=r.trim();c(""),i(Y=>[...Y,{role:"user",content:U}]),g(!0);try{const Y=await p1(U,d??void 0,x||void 0);m(Y.sessionId),p(Y.executionId)}catch(Y){g(!1),i(q=>[...q,{role:"assistant",content:`Error: ${Y instanceof Error?Y.message:String(Y)}`}])}},[r,T,d,x]),L=U=>{U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),R())};return o.jsx(ql,{title:"Agent Playground",description:"Chat with registered agents in real-time",actions:o.jsxs("div",{className:"flex items-center gap-2",children:[w.length>0&&o.jsxs("select",{value:x,onChange:U=>v(U.target.value),className:"px-2 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))]",children:[o.jsx("option",{value:"",children:"Default agent"}),w.map(U=>o.jsx("option",{value:U.name,children:U.name},U.name))]}),o.jsx("button",{onClick:()=>{i([]),m(null),p(null)},className:"px-3 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] hover:bg-[hsl(var(--accent))]",children:"New Chat"})]}),children:o.jsxs("div",{className:"flex flex-col h-full max-w-3xl mx-auto",children:[o.jsxs("div",{className:"flex-1 overflow-auto space-y-4 pb-4",children:[u.length===0&&o.jsx(Vt,{title:"Start a conversation",description:"Type a message below to chat with an agent. Tool calls, handoffs, and streaming responses will be displayed in real-time."}),u.map((U,Y)=>o.jsx("div",{className:`flex ${U.role==="user"?"justify-end":"justify-start"}`,children:o.jsxs("div",{className:`max-w-[80%] rounded-lg px-4 py-2.5 text-sm ${U.role==="user"?"bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))]":"bg-[hsl(var(--secondary))] text-[hsl(var(--secondary-foreground))]"}`,children:[U.role==="assistant"&&T&&Y===u.length-1?o.jsx(Jb,{text:U.content}):o.jsx("div",{className:"whitespace-pre-wrap",children:U.content}),U.handoffs&&U.handoffs.length>0&&o.jsx("div",{className:"mt-2 space-y-1 border-t border-[hsl(var(--border))] pt-2",children:U.handoffs.map((q,O)=>o.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[o.jsx(zo,{size:12,className:"text-amber-500"}),o.jsx("span",{className:"font-medium",children:q.source}),o.jsx(zo,{size:10}),o.jsx("span",{className:"font-medium",children:q.target}),o.jsxs("span",{className:"text-[hsl(var(--muted-foreground))]",children:["(",q.mode,")"]})]},O))}),U.approvals&&U.approvals.length>0&&o.jsx("div",{className:"mt-2 space-y-1 border-t border-[hsl(var(--border))] pt-2",children:U.approvals.map((q,O)=>o.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[o.jsx(Lb,{size:12,className:q.approved?"text-green-500":"text-red-500"}),o.jsxs("span",{children:["Tool ",o.jsx("span",{className:"font-mono",children:q.tool}),":"," ",q.approved?"approved":"denied"]})]},O))}),U.toolCalls&&U.toolCalls.length>0&&o.jsx("div",{className:"mt-2 space-y-2 border-t border-[hsl(var(--border))] pt-2",children:U.toolCalls.map((q,O)=>o.jsxs("details",{className:"text-xs",children:[o.jsxs("summary",{className:"cursor-pointer font-medium",children:["Tool: ",q.name]}),o.jsxs("div",{className:"mt-1 space-y-1",children:[o.jsx("div",{className:"text-[hsl(var(--muted-foreground))]",children:"Input:"}),o.jsx(Jt,{data:q.args,collapsed:!0}),q.result!==void 0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"text-[hsl(var(--muted-foreground))]",children:"Output:"}),o.jsx(Jt,{data:q.result,collapsed:!0})]})]})]},O))})]})},Y)),o.jsx("div",{ref:_})]}),o.jsx("div",{className:"border-t border-[hsl(var(--border))] pt-4",children:o.jsxs("div",{className:"flex items-end gap-2",children:[o.jsx("textarea",{value:r,onChange:U=>c(U.target.value),onKeyDown:L,placeholder:"Type a message...",rows:1,className:"flex-1 px-3 py-2.5 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))] resize-none focus:outline-none focus:ring-2 focus:ring-[hsl(var(--ring))]"}),o.jsx("button",{onClick:R,disabled:!r.trim()||T,className:"p-2.5 rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:opacity-90 disabled:opacity-50 transition-opacity",children:o.jsx(Bb,{size:16})})]})})]})})}function Tv({value:u,onChange:i,placeholder:r,className:c}){const[d,m]=j.useState(null),y=j.useCallback(p=>{const x=p.target.value;i(x);try{x.trim()&&JSON.parse(x),m(null)}catch(v){m(v instanceof Error?v.message:"Invalid JSON")}},[i]);return o.jsxs("div",{className:c,children:[o.jsx("textarea",{value:u,onChange:y,placeholder:r??"{}",className:"w-full h-32 p-3 text-xs font-mono rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))] text-[hsl(var(--foreground))] resize-y focus:outline-none focus:ring-2 focus:ring-[hsl(var(--ring))]",spellCheck:!1}),d&&o.jsx("p",{className:"text-xs text-red-500 mt-1",children:d})]})}function Cv({schema:u,onSubmit:i,submitLabel:r="Submit",className:c}){const[d,m]=j.useState({}),y=u.properties??{},p=new Set(u.required??[]),x=j.useCallback(v=>{v.preventDefault();const T={};for(const[g,_]of Object.entries(y)){const w=d[g]??"";if(!(!w&&!p.has(g)))if(_.type==="number")T[g]=Number(w);else if(_.type==="boolean")T[g]=w==="true";else if(_.type==="object"||_.type==="array")try{T[g]=JSON.parse(w)}catch{T[g]=w}else T[g]=w}i(T)},[d,y,p,i]);return o.jsxs("form",{onSubmit:x,className:`space-y-3 ${c??""}`,children:[Object.entries(y).map(([v,T])=>o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs font-medium text-[hsl(var(--foreground))] mb-1",children:[v,p.has(v)&&o.jsx("span",{className:"text-red-500 ml-0.5",children:"*"}),T.description&&o.jsxs("span",{className:"text-[hsl(var(--muted-foreground))] font-normal ml-1",children:["- ",T.description]})]}),T.enum?o.jsxs("select",{value:d[v]??"",onChange:g=>m({...d,[v]:g.target.value}),className:"w-full px-2 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))]",children:[o.jsx("option",{value:"",children:"Select..."}),T.enum.map(g=>o.jsx("option",{value:g,children:g},g))]}):T.type==="boolean"?o.jsxs("select",{value:d[v]??"",onChange:g=>m({...d,[v]:g.target.value}),className:"w-full px-2 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))]",children:[o.jsx("option",{value:"",children:"Select..."}),o.jsx("option",{value:"true",children:"true"}),o.jsx("option",{value:"false",children:"false"})]}):o.jsx("input",{type:T.type==="number"?"number":"text",value:d[v]??"",onChange:g=>m({...d,[v]:g.target.value}),placeholder:T.type??"string",className:"w-full px-2 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))]"})]},v)),o.jsx("button",{type:"submit",className:"px-4 py-2 text-sm font-medium rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:opacity-90 transition-opacity",children:r})]})}function Ov({status:u,className:i}){return o.jsxs("span",{className:_o("inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium",Kb(u),u==="running"&&"animate-pulse",i),children:[o.jsx("span",{className:_o("w-1.5 h-1.5 rounded-full",u==="running"&&"bg-blue-500",u==="completed"&&"bg-green-500",u==="failed"&&"bg-red-500",u==="waiting"&&"bg-amber-500")}),u]})}function xa({cost:u,className:i}){return o.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-mono bg-[hsl(var(--secondary))] text-[hsl(var(--secondary-foreground))] ${i??""}`,children:jv(u)})}function Do({ms:u,className:i}){return o.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-mono bg-[hsl(var(--secondary))] text-[hsl(var(--secondary-foreground))] ${i??""}`,children:Zb(u)})}function S1(){const[u,i]=j.useState(""),[r,c]=j.useState("{}"),[d,m]=j.useState(!0),[y,p]=j.useState(null),[x,v]=j.useState(null),[T,g]=j.useState(null),[_,w]=j.useState("idle"),{data:Z=[]}=kt({queryKey:["workflows"],queryFn:$b}),{data:R}=kt({queryKey:["workflow",u],queryFn:()=>Wb(u),enabled:!!u}),L=Nv(y),U=j.useCallback(async V=>{if(u){v(null),g(null),w("running");try{const k=await Ib(u,V,!0);k.streaming&&k.executionId?p(k.executionId):(v(k.result),w("completed"))}catch(k){g(k instanceof Error?k.message:String(k)),w("failed")}}},[u]),Y=j.useCallback(()=>{try{const V=JSON.parse(r);U(V)}catch(V){g(V instanceof Error?V.message:String(V)),w("failed")}},[r,U]),q=j.useCallback(V=>{U(V)},[U]);j.useEffect(()=>{L.done&&_==="running"&&(w(L.error?"failed":"completed"),L.error&&g(L.error),L.result&&v(L.result),p(null))},[L.done,L.error,L.result,_]);const O=L.events.filter(V=>V.type==="step").map(V=>V.data),K=!!(R!=null&&R.inputSchema);return o.jsx(ql,{title:"Workflow Runner",description:"Execute and debug registered workflows",children:o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium mb-1",children:"Workflow"}),o.jsxs("select",{value:u,onChange:V=>{i(V.target.value),c("{}"),v(null),g(null),w("idle")},className:"w-full px-3 py-2 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))]",children:[o.jsx("option",{value:"",children:"Select a workflow..."}),Z.map(V=>o.jsx("option",{value:V.name,children:V.name},V.name))]})]}),(R==null?void 0:R.outputSchema)!=null&&o.jsxs("details",{className:"text-xs",children:[o.jsx("summary",{className:"cursor-pointer text-[hsl(var(--muted-foreground))]",children:"Output Schema"}),o.jsx("div",{className:"mt-1",children:o.jsx(Jt,{data:R.outputSchema,collapsed:!0})})]}),K&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("label",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:"Input mode:"}),o.jsx("button",{onClick:()=>m(!0),className:`px-2 py-0.5 text-xs rounded ${d?"bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))]":"border border-[hsl(var(--input))]"}`,children:"Form"}),o.jsx("button",{onClick:()=>m(!1),className:`px-2 py-0.5 text-xs rounded ${d?"border border-[hsl(var(--input))]":"bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))]"}`,children:"JSON"})]}),K&&d?o.jsx(Cv,{schema:R.inputSchema,onSubmit:q,submitLabel:_==="running"?"Running...":"Execute"}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium mb-1",children:"Input (JSON)"}),o.jsx(Tv,{value:r,onChange:c})]}),o.jsxs("button",{onClick:Y,disabled:!u||_==="running",className:"flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:opacity-90 disabled:opacity-50",children:[o.jsx(xv,{size:14}),"Execute"]})]})]}),o.jsxs("div",{className:"space-y-4",children:[_!=="idle"&&o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(Ov,{status:_}),L.events.length>0&&o.jsxs(o.Fragment,{children:[O.some(V=>V.cost)&&o.jsx(xa,{cost:O.reduce((V,k)=>V+(k.cost??0),0)}),O.some(V=>V.duration)&&o.jsx(Do,{ms:O.reduce((V,k)=>V+(k.duration??0),0)})]})]}),O.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium mb-2",children:"Timeline"}),o.jsx("div",{className:"space-y-1.5",children:O.map((V,k)=>o.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded bg-[hsl(var(--secondary))]",children:[o.jsxs("span",{className:"font-mono text-[hsl(var(--muted-foreground))]",children:["#",V.step]}),o.jsx("span",{className:"font-medium",children:V.type}),V.agent&&o.jsx("span",{className:"text-[hsl(var(--muted-foreground))]",children:V.agent}),V.tool&&o.jsx("span",{className:"text-[hsl(var(--muted-foreground))]",children:V.tool}),o.jsx("span",{className:"flex-1"}),V.duration&&o.jsx(Do,{ms:V.duration}),V.cost&&o.jsx(xa,{cost:V.cost})]},k))})]}),x!==null&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium mb-2",children:"Result"}),o.jsx(Jt,{data:x})]}),T&&o.jsx("div",{className:"p-3 rounded-md bg-red-50 dark:bg-red-950 border border-red-200 dark:border-red-800 text-red-700 dark:text-red-300 text-sm",children:T}),_==="idle"&&o.jsx(Vt,{title:"No execution",description:"Select a workflow and click Execute to see results."})]})]})})}const E1={agent_call:"bg-blue-500",tool_call:"bg-purple-500",tool_call_complete:"bg-purple-400",workflow_start:"bg-green-500",workflow_complete:"bg-green-400",handoff:"bg-amber-500",await_human:"bg-red-500",vote_start:"bg-cyan-500",spawn:"bg-indigo-500"};function Ty(u){return E1[u]??"bg-slate-500"}function j1(u){const i=u.type;return i==="workflow_start"||i==="workflow_complete"?0:i==="agent_call"||i==="spawn"||i==="vote_start"?1:i==="tool_call"||i==="tool_call_complete"||i==="handoff"?2:1}function N1(){const[u,i]=j.useState(null),[r,c]=j.useState([]),[d,m]=j.useState(""),[y,p]=j.useState(""),{data:x=[],refetch:v}=kt({queryKey:["executions"],queryFn:Pb,refetchInterval:3e3});Jo("trace:*",j.useCallback(R=>{c(L=>[...L.slice(-200),R])},[]));const T=u?u.steps:r;let g=T;d&&(g=g.filter(R=>R.type===d)),y&&(g=g.filter(R=>R.agent===y));const _=[...new Set(T.map(R=>R.type))],w=[...new Set(T.map(R=>R.agent).filter(Boolean))],Z=Math.max(...g.map(R=>R.duration??0),1);return o.jsx(ql,{title:"Trace Explorer",description:"Inspect execution traces with waterfall visualization",actions:o.jsx("button",{onClick:()=>{v(),c([])},className:"px-3 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] hover:bg-[hsl(var(--accent))]",children:"Refresh"}),children:o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6",children:[o.jsxs("div",{className:"lg:col-span-1 space-y-2",children:[o.jsx("h3",{className:"text-sm font-medium mb-2",children:"Executions"}),o.jsxs("button",{onClick:()=>i(null),className:`w-full text-left px-3 py-2 text-xs rounded-md border ${u?"border-[hsl(var(--border))]":"border-[hsl(var(--primary))] bg-[hsl(var(--accent))]"}`,children:["Live Events (",r.length,")"]}),x.map(R=>o.jsxs("button",{onClick:()=>i(R),className:`w-full text-left px-3 py-2 text-xs rounded-md border ${(u==null?void 0:u.executionId)===R.executionId?"border-[hsl(var(--primary))] bg-[hsl(var(--accent))]":"border-[hsl(var(--border))] hover:bg-[hsl(var(--accent))]"}`,children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-medium truncate",children:R.workflow}),o.jsx(Ov,{status:R.status})]}),o.jsxs("div",{className:"flex items-center justify-between mt-0.5",children:[o.jsxs("span",{className:"text-[hsl(var(--muted-foreground))] truncate",children:[R.executionId.slice(0,8),"... | ",R.steps.length," steps"]}),R.totalCost>0&&o.jsx(xa,{cost:R.totalCost})]})]},R.executionId)),x.length===0&&o.jsx("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:"No executions yet"})]}),o.jsxs("div",{className:"lg:col-span-3",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4 flex-wrap",children:[o.jsxs("select",{value:d,onChange:R=>m(R.target.value),className:"px-2 py-1 text-xs rounded border border-[hsl(var(--input))] bg-[hsl(var(--background))]",children:[o.jsx("option",{value:"",children:"All types"}),_.map(R=>o.jsx("option",{value:R,children:R},R))]}),w.length>0&&o.jsxs("select",{value:y,onChange:R=>p(R.target.value),className:"px-2 py-1 text-xs rounded border border-[hsl(var(--input))] bg-[hsl(var(--background))]",children:[o.jsx("option",{value:"",children:"All agents"}),w.map(R=>o.jsx("option",{value:R,children:R},R))]}),o.jsxs("span",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:[g.length," events"]})]}),g.length===0?o.jsx(Vt,{icon:o.jsx(yv,{size:32}),title:"No trace events",description:"Execute a workflow to see trace events here."}):o.jsx("div",{className:"space-y-1",children:g.map((R,L)=>{const U=j1(R);return o.jsxs("details",{className:"group",children:[o.jsxs("summary",{className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded bg-[hsl(var(--secondary))] cursor-pointer hover:bg-[hsl(var(--accent))]",style:{marginLeft:`${U*16}px`},children:[o.jsxs("span",{className:"font-mono text-[hsl(var(--muted-foreground))] w-8",children:["#",R.step]}),o.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Ty(R.type)}`}),o.jsx("span",{className:"font-medium w-28 truncate",children:R.type}),R.agent&&o.jsx("span",{className:"text-blue-600 dark:text-blue-400 w-28 truncate",children:R.agent}),R.tool&&o.jsx("span",{className:"text-purple-600 dark:text-purple-400 w-28 truncate",children:R.tool}),o.jsx("div",{className:"flex-1 h-3 bg-[hsl(var(--background))] rounded overflow-hidden",children:R.duration&&o.jsx("div",{className:`h-full rounded ${Ty(R.type)}`,style:{width:`${Math.max(R.duration/Z*100,2)}%`,opacity:.7}})}),R.duration&&o.jsx(Do,{ms:R.duration}),R.cost&&o.jsx(xa,{cost:R.cost})]}),o.jsxs("div",{className:"mt-1 mb-2 p-3 rounded bg-[hsl(var(--card))] border border-[hsl(var(--border))]",style:{marginLeft:`${U*16+32}px`},children:[R.model&&o.jsxs("p",{className:"text-xs mb-1",children:[o.jsx("strong",{children:"Model:"})," ",R.model]}),R.promptVersion&&o.jsxs("p",{className:"text-xs mb-1",children:[o.jsx("strong",{children:"Version:"})," ",R.promptVersion]}),R.tokens&&o.jsxs("p",{className:"text-xs mb-1",children:[o.jsx("strong",{children:"Tokens:"})," in=",R.tokens.input," out=",R.tokens.output,R.tokens.reasoning?` reasoning=${R.tokens.reasoning}`:""]}),R.data!=null&&o.jsx(Jt,{data:R.data,collapsed:!0})]})]},L)})})]})]})})}function T1({tokens:u,label:i,className:r}){return o.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-mono bg-[hsl(var(--secondary))] text-[hsl(var(--secondary-foreground))] ${r??""}`,children:[i&&o.jsx("span",{className:"text-[hsl(var(--muted-foreground))]",children:i}),Ds(u)]})}function C1(){const[u,i]=j.useState(null),{data:r,refetch:c}=kt({queryKey:["costs"],queryFn:f1});Jo("costs",j.useCallback(y=>{i(y)},[]));const d=u??r,m=async()=>{await d1(),i(null),c()};return d?o.jsxs(ql,{title:"Cost Dashboard",description:"Track spending across agents, models, and workflows",actions:o.jsx("button",{onClick:m,className:"px-3 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] hover:bg-[hsl(var(--accent))]",children:"Reset"}),children:[o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-8",children:[o.jsx(As,{label:"Total Cost",value:jv(d.totalCost)}),o.jsx(As,{label:"Input Tokens",value:Ds(d.totalTokens.input)}),o.jsx(As,{label:"Output Tokens",value:Ds(d.totalTokens.output)}),o.jsx(As,{label:"Reasoning Tokens",value:Ds(d.totalTokens.reasoning)})]}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium mb-3",children:"Cost by Agent"}),Object.keys(d.byAgent).length===0?o.jsx("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:"No agent data"}):o.jsxs("table",{className:"w-full text-xs",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("th",{className:"text-left py-2 font-medium",children:"Agent"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Calls"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Cost"})]})}),o.jsx("tbody",{children:Object.entries(d.byAgent).sort(([,y],[,p])=>p.cost-y.cost).map(([y,p])=>o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("td",{className:"py-2 font-mono",children:y}),o.jsx("td",{className:"py-2 text-right",children:p.calls}),o.jsx("td",{className:"py-2 text-right",children:o.jsx(xa,{cost:p.cost})})]},y))})]})]}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium mb-3",children:"Cost by Model"}),Object.keys(d.byModel).length===0?o.jsx("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:"No model data"}):o.jsxs("table",{className:"w-full text-xs",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("th",{className:"text-left py-2 font-medium",children:"Model"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Calls"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Tokens"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Cost"})]})}),o.jsx("tbody",{children:Object.entries(d.byModel).sort(([,y],[,p])=>p.cost-y.cost).map(([y,p])=>o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("td",{className:"py-2 font-mono",children:y}),o.jsx("td",{className:"py-2 text-right",children:p.calls}),o.jsx("td",{className:"py-2 text-right",children:o.jsx(T1,{tokens:p.tokens.input+p.tokens.output})}),o.jsx("td",{className:"py-2 text-right",children:o.jsx(xa,{cost:p.cost})})]},y))})]})]}),o.jsxs("div",{className:"lg:col-span-2",children:[o.jsx("h3",{className:"text-sm font-medium mb-3",children:"Cost by Workflow"}),Object.keys(d.byWorkflow).length===0?o.jsx("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:"No workflow data"}):o.jsxs("table",{className:"w-full text-xs",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("th",{className:"text-left py-2 font-medium",children:"Workflow"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Executions"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Total Cost"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Avg Cost"})]})}),o.jsx("tbody",{children:Object.entries(d.byWorkflow).sort(([,y],[,p])=>p.cost-y.cost).map(([y,p])=>o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("td",{className:"py-2 font-mono",children:y}),o.jsx("td",{className:"py-2 text-right",children:p.executions}),o.jsx("td",{className:"py-2 text-right",children:o.jsx(xa,{cost:p.cost})}),o.jsx("td",{className:"py-2 text-right",children:o.jsx(xa,{cost:p.executions>0?p.cost/p.executions:0})})]},y))})]})]})]})]}):o.jsx(ql,{title:"Cost Dashboard",description:"Track spending across agents, models, and workflows",children:o.jsx(Vt,{icon:o.jsx(pv,{size:32}),title:"No cost data",description:"Execute workflows to see cost data."})})}function As({label:u,value:i}){return o.jsxs("div",{className:"p-4 rounded-lg border border-[hsl(var(--border))] bg-[hsl(var(--card))]",children:[o.jsx("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:u}),o.jsx("p",{className:"text-2xl font-semibold mt-1",children:i})]})}function O1(){const[u,i]=j.useState("session"),[r,c]=j.useState(""),[d,m]=j.useState("{}"),[y,p]=j.useState(!1),[x,v]=j.useState(""),[T,g]=j.useState(null),_=ui(),{data:w=[]}=kt({queryKey:["memory",u],queryFn:()=>s1(u)}),Z=Ro({mutationFn:({key:Y,value:q})=>r1(u,Y,q),onSuccess:()=>{_.invalidateQueries({queryKey:["memory",u]}),p(!1),c(""),m("{}")}}),R=Ro({mutationFn:Y=>c1(u,Y),onSuccess:()=>{_.invalidateQueries({queryKey:["memory",u]})}}),L=j.useCallback(async()=>{if(!x.trim())return;const Y=await o1(x,u);g(Y.results)},[x,u]),U=j.useCallback(()=>{if(r.trim())try{const Y=JSON.parse(d);Z.mutate({key:r,value:Y})}catch{Z.mutate({key:r,value:d})}},[r,d,Z]);return o.jsxs(ql,{title:"Memory Browser",description:"View and manage agent memory entries",actions:o.jsxs("button",{onClick:()=>p(!y),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:opacity-90",children:[o.jsx(Ub,{size:14}),"Add Entry"]}),children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[["session","global"].map(Y=>o.jsx("button",{onClick:()=>{i(Y),g(null)},className:`px-3 py-1.5 text-sm rounded-md ${u===Y?"bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))]":"border border-[hsl(var(--input))] hover:bg-[hsl(var(--accent))]"}`,children:Y.charAt(0).toUpperCase()+Y.slice(1)},Y)),o.jsx("div",{className:"flex-1"}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("input",{value:x,onChange:Y=>v(Y.target.value),onKeyDown:Y=>Y.key==="Enter"&&L(),placeholder:"Semantic search...",className:"px-2 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))] w-48"}),o.jsx("button",{onClick:L,className:"p-1.5 rounded-md hover:bg-[hsl(var(--accent))]",children:o.jsx(Hb,{size:14})})]})]}),y&&o.jsxs("div",{className:"mb-4 p-4 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--card))] space-y-3",children:[o.jsx("input",{value:r,onChange:Y=>c(Y.target.value),placeholder:"Key",className:"w-full px-2 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))]"}),o.jsx(Tv,{value:d,onChange:m,placeholder:"Value (JSON)"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:U,disabled:!r.trim(),className:"px-3 py-1.5 text-sm rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:opacity-90 disabled:opacity-50",children:"Save"}),o.jsx("button",{onClick:()=>p(!1),className:"px-3 py-1.5 text-sm rounded-md border border-[hsl(var(--input))] hover:bg-[hsl(var(--accent))]",children:"Cancel"})]})]}),T&&o.jsxs("div",{className:"mb-4 p-4 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--card))]",children:[o.jsx("h3",{className:"text-sm font-medium mb-2",children:"Search Results"}),T.length===0?o.jsx("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:"No results found"}):o.jsx(Jt,{data:T})]}),w.length===0?o.jsx(Vt,{icon:o.jsx(vv,{size:32}),title:"No memory entries",description:`No entries in the ${u} scope. Use ctx.remember() in workflows or add entries manually.`}):o.jsx("div",{className:"space-y-2",children:w.map(Y=>o.jsxs("div",{className:"p-3 rounded-md border border-[hsl(var(--border))] bg-[hsl(var(--card))]",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("span",{className:"text-sm font-mono font-medium",children:Y.key}),o.jsx("button",{onClick:()=>R.mutate(Y.key),className:"p-1 rounded hover:bg-[hsl(var(--destructive))] hover:text-[hsl(var(--destructive-foreground))] text-[hsl(var(--muted-foreground))]",children:o.jsx(bv,{size:14})})]}),o.jsx(Jt,{data:Y.value,collapsed:!0})]},Y.key))})]})}function R1(){const[u,i]=j.useState(null),[r,c]=j.useState(null),d=ui(),{data:m=[]}=kt({queryKey:["sessions"],queryFn:e1,refetchInterval:5e3}),{data:y}=kt({queryKey:["session",u],queryFn:()=>t1(u),enabled:!!u}),p=Ro({mutationFn:l1,onSuccess:()=>{d.invalidateQueries({queryKey:["sessions"]}),i(null)}}),x=y!=null&&y.history?r!==null?y.history.slice(0,r+1):y.history:[];return o.jsx(ql,{title:"Session Manager",description:"Browse active sessions, replay conversations, and view handoff chains",children:o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs("h3",{className:"text-sm font-medium mb-2",children:["Sessions (",m.length,")"]}),m.length===0?o.jsx(Vt,{icon:o.jsx(Sv,{size:24}),title:"No sessions",description:"Sessions are created when using runtime.session()"}):m.map(v=>o.jsxs("button",{onClick:()=>{i(v.id),c(null)},className:`w-full text-left px-3 py-2 text-xs rounded-md border ${u===v.id?"border-[hsl(var(--primary))] bg-[hsl(var(--accent))]":"border-[hsl(var(--border))] hover:bg-[hsl(var(--accent))]"}`,children:[o.jsx("div",{className:"font-mono truncate",children:v.id}),o.jsxs("div",{className:"text-[hsl(var(--muted-foreground))] mt-0.5",children:[v.messageCount," messages"]})]},v.id))]}),o.jsx("div",{className:"lg:col-span-2",children:y?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium font-mono",children:y.id}),o.jsxs("p",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:[y.history.length," messages"]})]}),o.jsxs("button",{onClick:()=>p.mutate(y.id),className:"flex items-center gap-1 px-2 py-1 text-xs rounded-md border border-red-300 text-red-600 hover:bg-red-50 dark:border-red-800 dark:text-red-400 dark:hover:bg-red-950",children:[o.jsx(bv,{size:12}),"Delete"]})]}),y.handoffHistory&&y.handoffHistory.length>0&&o.jsxs("div",{children:[o.jsx("h4",{className:"text-xs font-medium mb-2",children:"Handoff Chain"}),o.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:y.handoffHistory.map((v,T)=>o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"px-2 py-0.5 text-xs rounded bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300",children:v.source}),o.jsx(zo,{size:12,className:"text-[hsl(var(--muted-foreground))]"}),o.jsx("span",{className:"px-2 py-0.5 text-xs rounded bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300",children:v.target}),o.jsxs("span",{className:"text-xs text-[hsl(var(--muted-foreground))]",children:["(",v.mode,")"]}),T<y.handoffHistory.length-1&&o.jsx("span",{className:"mx-1 text-[hsl(var(--muted-foreground))]",children:"|"})]},T))})]}),y.history.length>1&&o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs font-medium mb-1",children:["Replay:"," ",r!==null?`${r+1} / ${y.history.length}`:"All"]}),o.jsx("input",{type:"range",min:0,max:y.history.length-1,value:r??y.history.length-1,onChange:v=>c(Number(v.target.value)),className:"w-full"})]}),o.jsx("div",{className:"space-y-3",children:x.map((v,T)=>o.jsxs("div",{className:`p-3 rounded-md text-sm ${v.role==="user"?"bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] ml-8":v.role==="assistant"?"bg-[hsl(var(--secondary))] mr-8":"bg-[hsl(var(--muted))] text-xs font-mono"}`,children:[o.jsx("div",{className:"text-xs font-medium mb-1 opacity-70",children:v.role}),o.jsx("div",{className:"whitespace-pre-wrap",children:v.content}),v.tool_calls&&v.tool_calls.length>0&&o.jsx("div",{className:"mt-2 space-y-1",children:v.tool_calls.map(g=>o.jsxs("details",{className:"text-xs",children:[o.jsx("summary",{className:"cursor-pointer font-mono",children:g.function.name}),o.jsx(Jt,{data:JSON.parse(g.function.arguments),collapsed:!0})]},g.id))})]},T))})]}):o.jsx(Vt,{title:"Select a session",description:"Click a session to view its history"})})]})})}function A1(){const[u,i]=j.useState(null),[r,c]=j.useState(null),[d,m]=j.useState(null),[y,p]=j.useState(!1),{data:x=[]}=kt({queryKey:["tools"],queryFn:n1}),{data:v}=kt({queryKey:["tool",u],queryFn:()=>u1(u),enabled:!!u}),T=j.useCallback(async g=>{if(u){c(null),m(null),p(!0);try{const _=await i1(u,g);c(_.result)}catch(_){m(_ instanceof Error?_.message:String(_))}finally{p(!1)}}},[u]);return o.jsx(ql,{title:"Tool Inspector",description:"View tool schemas and test tools directly",children:o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs("h3",{className:"text-sm font-medium mb-2",children:["Tools (",x.length,")"]}),x.length===0?o.jsx(Vt,{icon:o.jsx(Ev,{size:24}),title:"No tools",description:"Register tools with runtime.registerTool()"}):x.map(g=>o.jsxs("button",{onClick:()=>{i(g.name),c(null),m(null)},className:`w-full text-left px-3 py-2 text-xs rounded-md border ${u===g.name?"border-[hsl(var(--primary))] bg-[hsl(var(--accent))]":"border-[hsl(var(--border))] hover:bg-[hsl(var(--accent))]"}`,children:[o.jsx("div",{className:"font-medium",children:g.name}),o.jsx("div",{className:"text-[hsl(var(--muted-foreground))] mt-0.5 truncate",children:g.description}),o.jsxs("div",{className:"flex items-center gap-1.5 mt-1",children:[g.sensitive&&o.jsx("span",{className:"px-1 py-0.5 rounded bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300 text-[10px]",children:"sensitive"}),g.requireApproval&&o.jsx("span",{className:"px-1 py-0.5 rounded bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 text-[10px]",children:"approval"})]})]},g.name))]}),o.jsx("div",{className:"lg:col-span-2",children:u?v?o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-medium",children:v.name}),o.jsx("p",{className:"text-sm text-[hsl(var(--muted-foreground))]",children:v.description})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[v.sensitive&&o.jsx("span",{className:"px-2 py-1 text-xs rounded-md bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300",children:"Sensitive"}),v.requireApproval&&o.jsx("span",{className:"px-2 py-1 text-xs rounded-md bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300",children:"Requires Approval"}),v.retry.attempts&&v.retry.attempts>1&&o.jsxs("span",{className:"px-2 py-1 text-xs rounded-md bg-green-100 dark:bg-green-900 text-green-700 dark:text-green-300",children:["Retry: ",v.retry.attempts,"x ",v.retry.backoff]}),v.hasHooks&&v.hooks&&o.jsxs("span",{className:"px-2 py-1 text-xs rounded-md bg-purple-100 dark:bg-purple-900 text-purple-700 dark:text-purple-300",children:["Hooks:"," ",[v.hooks.hasBefore&&"before",v.hooks.hasAfter&&"after"].filter(Boolean).join(" + ")]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"text-sm font-medium mb-2",children:"Input Schema"}),o.jsx(Jt,{data:v.inputSchema})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"text-sm font-medium mb-2",children:"Test Tool"}),o.jsx(Cv,{schema:v.inputSchema,onSubmit:T,submitLabel:y?"Running...":"Run Tool"})]}),r!==null&&o.jsxs("div",{children:[o.jsx("h4",{className:"text-sm font-medium mb-2",children:"Result"}),o.jsx(Jt,{data:r})]}),d&&o.jsx("div",{className:"p-3 rounded-md bg-red-50 dark:bg-red-950 border border-red-200 dark:border-red-800 text-red-700 dark:text-red-300 text-sm",children:d})]}):o.jsx("div",{className:"text-sm text-[hsl(var(--muted-foreground))]",children:"Loading..."}):o.jsx(Vt,{title:"Select a tool",description:"Click a tool to view its schema and test it"})})]})})}function M1(){var q;const u=ui(),[i,r]=j.useState("run"),[c,d]=j.useState(""),[m,y]=j.useState(!1),[p,x]=j.useState(null),[v,T]=j.useState(null),[g,_]=j.useState(null),{data:w=[]}=kt({queryKey:["evals"],queryFn:h1}),{data:Z=[]}=kt({queryKey:["evalHistory"],queryFn:m1}),R=w.find(O=>O.name===c),L=j.useCallback(async()=>{if(c){y(!0),T(null),x(null);try{const O=await y1(c);x(O),u.invalidateQueries({queryKey:["evalHistory"]})}catch(O){T(O instanceof Error?O.message:String(O))}finally{y(!1)}}},[c,u]),U=j.useCallback(async()=>{if(!(Z.length<2))try{const O=Z[1].data,K=Z[0].data,V=await v1(O,K);_(V)}catch(O){T(O instanceof Error?O.message:String(O))}},[Z]),Y=(q=p==null?void 0:p.summary)!=null&&q.scorers?Object.entries(p.summary.scorers):[];return o.jsxs(ql,{title:"Eval Runner",description:"Run evaluations, view results, and compare runs",children:[o.jsx("div",{className:"flex items-center gap-1 mb-6",children:["run","history","compare"].map(O=>o.jsx("button",{onClick:()=>r(O),className:`px-3 py-1.5 text-sm rounded-md ${i===O?"bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))]":"border border-[hsl(var(--input))] hover:bg-[hsl(var(--accent))]"}`,children:O.charAt(0).toUpperCase()+O.slice(1)},O))}),i==="run"&&o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium mb-1",children:"Eval"}),w.length===0?o.jsxs("p",{className:"text-sm text-[hsl(var(--muted-foreground))]",children:["No evals registered. Define evals with"," ",o.jsx("code",{className:"text-xs bg-[hsl(var(--muted))] px-1 py-0.5 rounded",children:"defineEval()"})," ","and load them via the"," ",o.jsx("code",{className:"text-xs bg-[hsl(var(--muted))] px-1 py-0.5 rounded",children:"evals"})," ","middleware option or"," ",o.jsx("code",{className:"text-xs bg-[hsl(var(--muted))] px-1 py-0.5 rounded",children:"runtime.registerEval()"}),"."]}):o.jsxs("select",{value:c,onChange:O=>d(O.target.value),className:"w-full px-3 py-2 text-sm rounded-md border border-[hsl(var(--input))] bg-[hsl(var(--background))]",children:[o.jsx("option",{value:"",children:"Select an eval..."}),w.map(O=>o.jsx("option",{value:O.name,children:O.name},O.name))]})]}),R&&o.jsxs("div",{className:"space-y-2 text-xs",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"font-medium text-[hsl(var(--muted-foreground))]",children:"Workflow:"}),o.jsx("span",{className:"font-mono",children:R.workflow})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"font-medium text-[hsl(var(--muted-foreground))]",children:"Dataset:"}),o.jsx("span",{className:"font-mono",children:R.dataset})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"font-medium text-[hsl(var(--muted-foreground))]",children:"Scorers:"}),o.jsx("div",{className:"flex flex-wrap gap-1",children:R.scorers.map(O=>o.jsx("span",{className:"px-1.5 py-0.5 rounded bg-[hsl(var(--muted))] font-mono",children:O},O))})]})]}),o.jsx("button",{onClick:L,disabled:!c||m,className:"px-4 py-2 text-sm font-medium rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:opacity-90 disabled:opacity-50",children:m?"Running...":"Run Eval"})]}),o.jsxs("div",{children:[v&&o.jsx("div",{className:"p-3 rounded-md bg-red-50 dark:bg-red-950 border border-red-200 dark:border-red-800 text-red-700 dark:text-red-300 text-sm mb-4",children:v}),p?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-4 text-xs text-[hsl(var(--muted-foreground))]",children:[o.jsxs("span",{children:[p.summary.count," items, ",p.summary.failures," failures"]}),p.duration>0&&o.jsxs("span",{children:[(p.duration/1e3).toFixed(1),"s"]}),p.totalCost>0&&o.jsxs("span",{children:["$",p.totalCost.toFixed(4)]})]}),Y.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium mb-2",children:"Summary"}),o.jsxs("table",{className:"w-full text-xs",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("th",{className:"text-left py-2 font-medium",children:"Scorer"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Mean"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"P50"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"P95"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Min"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Max"})]})}),o.jsx("tbody",{children:Y.map(([O,K])=>{const V=p.items.some(k=>!k.error&&k.scores[O]!=null);return o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("td",{className:"py-2 font-mono",children:O}),V?o.jsxs(o.Fragment,{children:[o.jsx("td",{className:"py-2 text-right font-mono",children:K.mean.toFixed(3)}),o.jsx("td",{className:"py-2 text-right font-mono",children:K.p50.toFixed(3)}),o.jsx("td",{className:"py-2 text-right font-mono",children:K.p95.toFixed(3)}),o.jsx("td",{className:"py-2 text-right font-mono",children:K.min.toFixed(3)}),o.jsx("td",{className:"py-2 text-right font-mono",children:K.max.toFixed(3)})]}):o.jsx("td",{colSpan:5,className:"py-2 text-center text-[hsl(var(--muted-foreground))]",children:"No valid scores"})]},O)})})]})]}),p.items&&p.items.length>0&&o.jsxs("div",{children:[o.jsxs("h3",{className:"text-sm font-medium mb-2",children:["Items (",p.items.length,")"]}),o.jsx("div",{className:"space-y-2",children:p.items.map((O,K)=>o.jsxs("details",{className:"border border-[hsl(var(--border))] rounded-md",children:[o.jsxs("summary",{className:"flex items-center justify-between px-3 py-2 text-xs cursor-pointer hover:bg-[hsl(var(--accent))]",children:[o.jsxs("span",{className:"font-mono",children:["Item #",K+1,O.error&&o.jsx("span",{className:"ml-2 text-red-600 dark:text-red-400",children:"(error)"}),O.scorerErrors&&O.scorerErrors.length>0&&!O.error&&o.jsx("span",{className:"ml-2 text-amber-600 dark:text-amber-400",children:"(scorer errors)"})]}),o.jsx("div",{className:"flex items-center gap-2",children:Object.entries(O.scores).filter(([,V])=>V!=null).map(([V,k])=>o.jsxs("span",{className:`px-1.5 py-0.5 rounded font-mono ${k>=.8?"bg-green-100 dark:bg-green-900 text-green-700 dark:text-green-300":k>=.5?"bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300":"bg-red-100 dark:bg-red-900 text-red-700 dark:text-red-300"}`,children:[V,": ",k.toFixed(2)]},V))})]}),o.jsxs("div",{className:"px-3 py-2 border-t border-[hsl(var(--border))] space-y-2 text-xs",children:[o.jsxs("div",{children:[o.jsx("span",{className:"font-medium",children:"Input:"}),o.jsx(Jt,{data:O.input,collapsed:!0})]}),o.jsxs("div",{children:[o.jsx("span",{className:"font-medium",children:"Output:"}),o.jsx(Jt,{data:O.output,collapsed:!0})]}),O.error&&o.jsxs("div",{children:[o.jsx("span",{className:"font-medium text-red-600 dark:text-red-400",children:"Error:"}),o.jsx("span",{className:"ml-1",children:O.error})]}),O.scorerErrors&&O.scorerErrors.length>0&&o.jsxs("div",{children:[o.jsx("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:"Scorer errors:"}),o.jsx("ul",{className:"ml-4 mt-1 list-disc",children:O.scorerErrors.map((V,k)=>o.jsx("li",{className:"text-amber-700 dark:text-amber-300",children:V},k))})]})]})]},K))})]})]}):o.jsx(Vt,{icon:o.jsx(gv,{size:32}),title:"No results",description:"Select an eval and run it to see results."})]})]}),i==="history"&&o.jsx("div",{children:Z.length===0?o.jsx(Vt,{title:"No eval history",description:"Run evaluations to build history."}):o.jsxs("table",{className:"w-full text-xs",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("th",{className:"text-left py-2 font-medium",children:"Eval"}),o.jsx("th",{className:"text-left py-2 font-medium",children:"Timestamp"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Items"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Failures"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Cost"})]})}),o.jsx("tbody",{children:Z.map(O=>{const K=O.data;return o.jsxs("tr",{className:"border-b border-[hsl(var(--border))] cursor-pointer hover:bg-[hsl(var(--accent))]",onClick:()=>{x(K),r("run")},children:[o.jsx("td",{className:"py-2 font-mono",children:O.eval}),o.jsx("td",{className:"py-2",children:new Date(O.timestamp).toLocaleString()}),o.jsx("td",{className:"py-2 text-right",children:K.summary.count}),o.jsx("td",{className:"py-2 text-right",children:K.summary.failures>0?o.jsx("span",{className:"text-red-600 dark:text-red-400",children:K.summary.failures}):0}),o.jsx("td",{className:"py-2 text-right font-mono",children:K.totalCost>0?`$${K.totalCost.toFixed(4)}`:"-"})]},O.id)})})]})}),i==="compare"&&o.jsx("div",{className:"space-y-4",children:Z.length<2?o.jsx(Vt,{title:"Need at least 2 eval runs",description:"Run evaluations to compare results."}):o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-[hsl(var(--muted-foreground))]",children:"Comparing most recent run against previous run."}),o.jsx("button",{onClick:U,className:"px-4 py-2 text-sm font-medium rounded-md bg-[hsl(var(--primary))] text-[hsl(var(--primary-foreground))] hover:opacity-90",children:"Compare"}),g&&o.jsxs("div",{className:"space-y-4",children:[g.summary&&o.jsx("p",{className:"text-sm",children:g.summary}),g.scorers&&Object.keys(g.scorers).length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium mb-2",children:"Scorer Comparison"}),o.jsxs("table",{className:"w-full text-xs",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("th",{className:"text-left py-2 font-medium",children:"Scorer"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Baseline"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Candidate"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"Delta"}),o.jsx("th",{className:"text-right py-2 font-medium",children:"%"})]})}),o.jsx("tbody",{children:Object.entries(g.scorers).map(([O,K])=>o.jsxs("tr",{className:"border-b border-[hsl(var(--border))]",children:[o.jsx("td",{className:"py-2 font-mono",children:O}),o.jsx("td",{className:"py-2 text-right font-mono",children:K.baselineMean.toFixed(3)}),o.jsx("td",{className:"py-2 text-right font-mono",children:K.candidateMean.toFixed(3)}),o.jsxs("td",{className:`py-2 text-right font-mono ${K.delta>0?"text-green-600 dark:text-green-400":K.delta<0?"text-red-600 dark:text-red-400":""}`,children:[K.delta>0?"+":"",K.delta.toFixed(3)]}),o.jsxs("td",{className:`py-2 text-right font-mono ${K.deltaPercent>0?"text-green-600 dark:text-green-400":K.deltaPercent<0?"text-red-600 dark:text-red-400":""}`,children:[K.deltaPercent>0?"+":"",K.deltaPercent.toFixed(1),"%"]})]},O))})]})]}),g.regressions&&g.regressions.length>0&&o.jsxs("div",{children:[o.jsxs("h3",{className:"text-sm font-medium mb-2 text-red-600 dark:text-red-400",children:["Regressions (",g.regressions.length,")"]}),o.jsx("div",{className:"space-y-1",children:g.regressions.map((O,K)=>o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 text-xs border border-[hsl(var(--border))] rounded",children:[o.jsx("span",{className:"font-mono",children:O.scorer}),o.jsxs("span",{className:"font-mono text-red-600 dark:text-red-400",children:[O.baseline.toFixed(2)," → ",O.candidate.toFixed(2)," (",O.delta.toFixed(2),")"]})]},K))})]}),g.improvements&&g.improvements.length>0&&o.jsxs("div",{children:[o.jsxs("h3",{className:"text-sm font-medium mb-2 text-green-600 dark:text-green-400",children:["Improvements (",g.improvements.length,")"]}),o.jsx("div",{className:"space-y-1",children:g.improvements.map((O,K)=>o.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 text-xs border border-[hsl(var(--border))] rounded",children:[o.jsx("span",{className:"font-mono",children:O.scorer}),o.jsxs("span",{className:"font-mono text-green-600 dark:text-green-400",children:[O.baseline.toFixed(2)," → ",O.candidate.toFixed(2)," (+",O.delta.toFixed(2),")"]})]},K))})]})]})]})})]})}function z1(){return o.jsx(hb,{basename:window.__AXL_STUDIO_BASE__||"/",children:o.jsxs("div",{className:"flex h-screen overflow-hidden",children:[o.jsx(kb,{}),o.jsx("div",{className:"flex-1 overflow-hidden",children:o.jsxs(Xx,{children:[o.jsx(il,{path:"/playground",element:o.jsx(b1,{})}),o.jsx(il,{path:"/workflows",element:o.jsx(S1,{})}),o.jsx(il,{path:"/traces",element:o.jsx(N1,{})}),o.jsx(il,{path:"/costs",element:o.jsx(C1,{})}),o.jsx(il,{path:"/memory",element:o.jsx(O1,{})}),o.jsx(il,{path:"/sessions",element:o.jsx(R1,{})}),o.jsx(il,{path:"/tools",element:o.jsx(A1,{})}),o.jsx(il,{path:"/evals",element:o.jsx(M1,{})}),o.jsx(il,{path:"*",element:o.jsx(Yx,{to:"/playground",replace:!0})})]})})]})})}rg.createRoot(document.getElementById("root")).render(o.jsx(j.StrictMode,{children:o.jsx(Dg,{client:Kg,children:o.jsx(z1,{})})}));
|
package/dist/client/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Axl Studio</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/index-
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-CwdbiyOq.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="./assets/index-6StQoHS_.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axlsdk/studio",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2",
|
|
4
4
|
"description": "Local development UI for debugging, testing, and iterating on Axl agents and workflows",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/server/index.cjs",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@hono/node-ws": "^1.1.0",
|
|
41
41
|
"tsx": "^4.19.0",
|
|
42
42
|
"ws": "^8.0.0",
|
|
43
|
-
"@axlsdk/axl": "0.13.
|
|
43
|
+
"@axlsdk/axl": "0.13.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@tailwindcss/vite": "^4.1.0",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"vite": "^6.0.0",
|
|
62
62
|
"vitest": "^3.0.0",
|
|
63
63
|
"zod": "^4.0.0",
|
|
64
|
-
"@axlsdk/testing": "0.13.
|
|
64
|
+
"@axlsdk/testing": "0.13.2"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@axlsdk/eval": "0.13.
|
|
67
|
+
"@axlsdk/eval": "0.13.2"
|
|
68
68
|
},
|
|
69
69
|
"peerDependenciesMeta": {
|
|
70
70
|
"@axlsdk/eval": {
|