apteva 0.4.26 → 0.4.29

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.
Files changed (54) hide show
  1. package/dist/ActivityPage.41nbye4r.js +3 -0
  2. package/dist/{ApiDocsPage.3q5x9hhg.js → ApiDocsPage.4smnt8m3.js} +1 -1
  3. package/dist/{App.9bzz8dqh.js → App.0sbax9et.js} +1 -1
  4. package/dist/{App.a7h91mxr.js → App.0ws427h8.js} +1 -1
  5. package/dist/App.4ehxpt48.js +4 -0
  6. package/dist/App.6q6bar8b.js +4 -0
  7. package/dist/{App.wnap3h7r.js → App.ca1rz1ph.js} +1 -1
  8. package/dist/{App.e54ynjf2.js → App.ensa6z0r.js} +1 -1
  9. package/dist/{App.sb2fg71h.js → App.f8g7tych.js} +1 -1
  10. package/dist/App.kh7d2xj3.js +267 -0
  11. package/dist/App.mvtqv6qc.js +20 -0
  12. package/dist/{App.2prdcxgq.js → App.ncgc9cxy.js} +1 -1
  13. package/dist/{App.r2c5nw36.js → App.p0fb1pds.js} +1 -1
  14. package/dist/{App.6ftxk387.js → App.pmaq48sj.js} +1 -1
  15. package/dist/{App.40azyqz6.js → App.yv87t9m5.js} +1 -1
  16. package/dist/App.zjmfm8p6.js +4 -0
  17. package/dist/ConnectionsPage.anb3rv9a.js +3 -0
  18. package/dist/McpPage.y396h6fy.js +3 -0
  19. package/dist/SettingsPage.5k6vp396.js +3 -0
  20. package/dist/SkillsPage.yj3xdsay.js +3 -0
  21. package/dist/{TasksPage.65dcf4vw.js → TasksPage.sjv0khtv.js} +1 -1
  22. package/dist/TelemetryPage.2qm4w16r.js +3 -0
  23. package/dist/TestsPage.zzs4qfj8.js +3 -0
  24. package/dist/index.html +1 -1
  25. package/dist/styles.css +1 -1
  26. package/package.json +1 -1
  27. package/src/channels/telegram.ts +5 -0
  28. package/src/crypto.ts +13 -4
  29. package/src/db.ts +25 -2
  30. package/src/providers.ts +44 -0
  31. package/src/routes/api/agent-utils.ts +64 -9
  32. package/src/routes/api/agents.ts +41 -13
  33. package/src/routes/api/integrations.ts +16 -6
  34. package/src/routes/api/mcp.ts +7 -0
  35. package/src/web/components/activity/ActivityPage.tsx +3 -3
  36. package/src/web/components/agents/AgentCard.tsx +5 -5
  37. package/src/web/components/agents/AgentPanel.tsx +81 -20
  38. package/src/web/components/mcp/McpPage.tsx +16 -5
  39. package/src/web/components/settings/SettingsPage.tsx +279 -30
  40. package/src/web/context/ProjectContext.tsx +5 -0
  41. package/src/web/context/TelemetryContext.tsx +14 -0
  42. package/src/web/types.ts +20 -2
  43. package/dist/ActivityPage.cycn14ck.js +0 -3
  44. package/dist/App.0wwyytz2.js +0 -4
  45. package/dist/App.fq11mvc7.js +0 -4
  46. package/dist/App.h6k4j1w9.js +0 -4
  47. package/dist/App.jq5tmjws.js +0 -267
  48. package/dist/App.k377qek6.js +0 -20
  49. package/dist/ConnectionsPage.6fyhqfhz.js +0 -3
  50. package/dist/McpPage.hk2qt1qt.js +0 -3
  51. package/dist/SettingsPage.gwpx9v7v.js +0 -3
  52. package/dist/SkillsPage.j5zech2z.js +0 -3
  53. package/dist/TelemetryPage.07xrbd7k.js +0 -3
  54. package/dist/TestsPage.q6zfephf.js +0 -3
@@ -0,0 +1,3 @@
1
+ import{d as a}from"./App.6q6bar8b.js";import"./App.ncgc9cxy.js";import"./App.mvtqv6qc.js";export{a as ActivityPage};
2
+
3
+ //# debugId=A836402CCF3683F564756E2164756E21
@@ -1,4 +1,4 @@
1
- import{S as y,V as E,W as D,ca as l}from"./App.k377qek6.js";var M=y(E(),1);var z=y(D(),1),V={get:"#61affe",post:"#49cc90",put:"#fca130",delete:"#f93e3e",patch:"#50e3c2"};function c({method:I,path:A,parameters:F,requestBody:L,authFetch:T}){let[U,R]=M.useState({}),[G,O]=M.useState(""),[_,k]=M.useState(null),[w,q]=M.useState(!1),[B,f]=M.useState(null);M.useEffect(()=>{if(L?.content?.["application/json"]?.schema){let W=L.content["application/json"].schema;if(W.example)O(JSON.stringify(W.example,null,2));else if(W.properties){let $={};for(let[N,Q]of Object.entries(W.properties))if(Q.example!==void 0)$[N]=Q.example;else if(Q.type==="string")$[N]="";else if(Q.type==="number"||Q.type==="integer")$[N]=0;else if(Q.type==="boolean")$[N]=!1;else if(Q.type==="array")$[N]=[];else if(Q.type==="object")$[N]={};O(JSON.stringify($,null,2))}}},[L]);let C=async()=>{q(!0),f(null),k(null);try{let W=A,$=[];for(let Z of F||[]){let H=U[Z.name]||"";if(Z.in==="path")W=W.replace(`{${Z.name}}`,encodeURIComponent(H));else if(Z.in==="query"&&H)$.push(`${Z.name}=${encodeURIComponent(H)}`)}if($.length>0)W+=`?${$.join("&")}`;let N={method:I.toUpperCase()};if(G&&["post","put","patch"].includes(I))N.headers={"Content-Type":"application/json"},N.body=G;let Q=await T(`/api${W}`,N),X;if(Q.headers.get("content-type")?.includes("application/json"))X=await Q.json();else X=await Q.text();k({status:Q.status,data:X})}catch(W){f(W.message||"Request failed")}finally{q(!1)}},b=F?.filter((W)=>W.in==="path")||[],K=F?.filter((W)=>W.in==="query")||[],S=["post","put","patch"].includes(I)&&L;return z.jsxDEV("div",{style:{marginTop:16,padding:16,background:"#0a0a14",borderRadius:6,border:"1px solid #222"},children:[z.jsxDEV("h4",{style:{fontSize:13,color:"#f97316",marginBottom:12,fontWeight:600},children:"Try it out"},void 0,!1,void 0,this),b.length>0&&z.jsxDEV("div",{style:{marginBottom:12},children:[z.jsxDEV("div",{style:{fontSize:11,color:"#666",marginBottom:6},children:"Path Parameters"},void 0,!1,void 0,this),b.map((W)=>z.jsxDEV("div",{style:{marginBottom:8},children:[z.jsxDEV("label",{style:{fontSize:12,color:"#888",display:"block",marginBottom:4},children:[W.name," ",W.required&&z.jsxDEV("span",{style:{color:"#f66"},children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("input",{type:"text",value:U[W.name]||"",onChange:($)=>R({...U,[W.name]:$.target.value}),placeholder:W.schema?.type||"string",style:{width:"100%",padding:"8px 12px",background:"#111",border:"1px solid #333",borderRadius:4,color:"#fff",fontSize:13,fontFamily:"monospace"}},void 0,!1,void 0,this)]},W.name,!0,void 0,this))]},void 0,!0,void 0,this),K.length>0&&z.jsxDEV("div",{style:{marginBottom:12},children:[z.jsxDEV("div",{style:{fontSize:11,color:"#666",marginBottom:6},children:"Query Parameters"},void 0,!1,void 0,this),K.map((W)=>z.jsxDEV("div",{style:{marginBottom:8},children:[z.jsxDEV("label",{style:{fontSize:12,color:"#888",display:"block",marginBottom:4},children:[W.name," ",W.required&&z.jsxDEV("span",{style:{color:"#f66"},children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("input",{type:"text",value:U[W.name]||"",onChange:($)=>R({...U,[W.name]:$.target.value}),placeholder:W.schema?.type||"string",style:{width:"100%",padding:"8px 12px",background:"#111",border:"1px solid #333",borderRadius:4,color:"#fff",fontSize:13,fontFamily:"monospace"}},void 0,!1,void 0,this)]},W.name,!0,void 0,this))]},void 0,!0,void 0,this),S&&z.jsxDEV("div",{style:{marginBottom:12},children:[z.jsxDEV("div",{style:{fontSize:11,color:"#666",marginBottom:6},children:"Request Body (JSON)"},void 0,!1,void 0,this),z.jsxDEV("textarea",{value:G,onChange:(W)=>O(W.target.value),rows:6,style:{width:"100%",padding:"8px 12px",background:"#111",border:"1px solid #333",borderRadius:4,color:"#fff",fontSize:12,fontFamily:"monospace",resize:"vertical"}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:C,disabled:w,style:{padding:"10px 20px",background:w?"#333":"#f97316",color:w?"#666":"#000",border:"none",borderRadius:4,cursor:w?"not-allowed":"pointer",fontSize:13,fontWeight:600},children:w?"Executing...":"Execute"},void 0,!1,void 0,this),B&&z.jsxDEV("div",{style:{marginTop:12,padding:12,background:"#2a1515",borderRadius:4,color:"#f66",fontSize:12},children:B},void 0,!1,void 0,this),_&&z.jsxDEV("div",{style:{marginTop:12},children:[z.jsxDEV("div",{style:{fontSize:11,color:"#666",marginBottom:6},children:["Response"," ",z.jsxDEV("span",{style:{color:_.status>=200&&_.status<300?"#49cc90":"#f66"},children:_.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("pre",{style:{padding:12,background:"#111",borderRadius:4,color:"#888",fontSize:11,fontFamily:"monospace",overflow:"auto",maxHeight:300,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:typeof _.data==="string"?_.data:JSON.stringify(_.data,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function h(){let{authFetch:I}=l(),[A,F]=M.useState(null),[L,T]=M.useState(!0),[U,R]=M.useState(new Set),[G,O]=M.useState(null),[_,k]=M.useState(!1);M.useEffect(()=>{B()},[]);async function w(){if(!A)return;try{await navigator.clipboard.writeText(JSON.stringify(A,null,2)),k(!0),setTimeout(()=>k(!1),2000)}catch(N){console.error("Failed to copy:",N)}}function q(){if(!A)return;let N=new Blob([JSON.stringify(A,null,2)],{type:"application/json"}),Q=URL.createObjectURL(N),X=document.createElement("a");X.href=Q,X.download="apteva-openapi.json",X.click(),URL.revokeObjectURL(Q)}async function B(){try{let N=await I("/api/openapi");if(N.ok){let Q=await N.json();F(Q)}}catch(N){console.error("Failed to load OpenAPI spec:",N)}finally{T(!1)}}function f(N){R((Q)=>{let X=new Set(Q);if(X.has(N))X.delete(N);else X.add(N);return X})}function C(N,Q=0){if(!N)return"{}";if(Q>2)return"...";if(N.$ref)return N.$ref.split("/").pop()||"Object";if(N.type==="array")return`${C(N.items,Q+1)}[]`;if(N.type==="object"&&N.properties){let X=Object.entries(N.properties).slice(0,3).map(([Z,H])=>`${Z}: ${H.type||"any"}`).join(", "),Y=Object.keys(N.properties).length>3?", ...":"";return`{ ${X}${Y} }`}return N.type||"any"}if(L)return z.jsxDEV("div",{style:{padding:24},children:z.jsxDEV("p",{style:{color:"#888"},children:"Loading API documentation..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(!A)return z.jsxDEV("div",{style:{padding:24},children:z.jsxDEV("p",{style:{color:"#f66"},children:"Failed to load API documentation"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let b=A.tags||[],K=Object.entries(A.paths);function S(N){let Q=new Set;function X(Y){if(!Y)return;if(typeof Y==="object"){if(Y.$ref){let Z=Y.$ref.split("/").pop();if(Z)Q.add(Z)}for(let Z of Object.values(Y))X(Z)}}return X(N.requestBody),X(N.responses),Q}function W(){if(!G||!A.components?.schemas)return Object.keys(A.components?.schemas||{});let N=new Set;for(let[Q,X]of $)for(let[Y,Z]of Object.entries(X)){if(!["get","post","put","delete","patch"].includes(Y))continue;if(Z.tags?.includes(G))S(Z).forEach((g)=>N.add(g))}return Array.from(N)}let $=G?K.filter(([N,Q])=>Object.values(Q).some((X)=>X.tags?.includes(G))):K;return z.jsxDEV("div",{style:{padding:24,maxWidth:1000,height:"100%",overflowY:"auto"},children:[z.jsxDEV("div",{style:{marginBottom:24},children:[z.jsxDEV("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[z.jsxDEV("h1",{style:{fontSize:24,fontWeight:600},children:A.info.title},void 0,!1,void 0,this),z.jsxDEV("div",{style:{display:"flex",gap:8},children:[z.jsxDEV("button",{onClick:w,style:{padding:"8px 16px",borderRadius:4,border:"1px solid #333",background:_?"#49cc90":"#1a1a2e",color:_?"#000":"#fff",cursor:"pointer",fontSize:12,fontFamily:"inherit"},children:_?"Copied!":"Copy JSON"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:q,style:{padding:"8px 16px",borderRadius:4,border:"1px solid #333",background:"#1a1a2e",color:"#fff",cursor:"pointer",fontSize:12,fontFamily:"inherit"},children:"Download"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{style:{color:"#888",marginBottom:8},children:A.info.description.split(`
1
+ import{S as y,V as E,W as D,ca as l}from"./App.mvtqv6qc.js";var M=y(E(),1);var z=y(D(),1),V={get:"#61affe",post:"#49cc90",put:"#fca130",delete:"#f93e3e",patch:"#50e3c2"};function c({method:I,path:A,parameters:F,requestBody:L,authFetch:T}){let[U,R]=M.useState({}),[G,O]=M.useState(""),[_,k]=M.useState(null),[w,q]=M.useState(!1),[B,f]=M.useState(null);M.useEffect(()=>{if(L?.content?.["application/json"]?.schema){let W=L.content["application/json"].schema;if(W.example)O(JSON.stringify(W.example,null,2));else if(W.properties){let $={};for(let[N,Q]of Object.entries(W.properties))if(Q.example!==void 0)$[N]=Q.example;else if(Q.type==="string")$[N]="";else if(Q.type==="number"||Q.type==="integer")$[N]=0;else if(Q.type==="boolean")$[N]=!1;else if(Q.type==="array")$[N]=[];else if(Q.type==="object")$[N]={};O(JSON.stringify($,null,2))}}},[L]);let C=async()=>{q(!0),f(null),k(null);try{let W=A,$=[];for(let Z of F||[]){let H=U[Z.name]||"";if(Z.in==="path")W=W.replace(`{${Z.name}}`,encodeURIComponent(H));else if(Z.in==="query"&&H)$.push(`${Z.name}=${encodeURIComponent(H)}`)}if($.length>0)W+=`?${$.join("&")}`;let N={method:I.toUpperCase()};if(G&&["post","put","patch"].includes(I))N.headers={"Content-Type":"application/json"},N.body=G;let Q=await T(`/api${W}`,N),X;if(Q.headers.get("content-type")?.includes("application/json"))X=await Q.json();else X=await Q.text();k({status:Q.status,data:X})}catch(W){f(W.message||"Request failed")}finally{q(!1)}},b=F?.filter((W)=>W.in==="path")||[],K=F?.filter((W)=>W.in==="query")||[],S=["post","put","patch"].includes(I)&&L;return z.jsxDEV("div",{style:{marginTop:16,padding:16,background:"#0a0a14",borderRadius:6,border:"1px solid #222"},children:[z.jsxDEV("h4",{style:{fontSize:13,color:"#f97316",marginBottom:12,fontWeight:600},children:"Try it out"},void 0,!1,void 0,this),b.length>0&&z.jsxDEV("div",{style:{marginBottom:12},children:[z.jsxDEV("div",{style:{fontSize:11,color:"#666",marginBottom:6},children:"Path Parameters"},void 0,!1,void 0,this),b.map((W)=>z.jsxDEV("div",{style:{marginBottom:8},children:[z.jsxDEV("label",{style:{fontSize:12,color:"#888",display:"block",marginBottom:4},children:[W.name," ",W.required&&z.jsxDEV("span",{style:{color:"#f66"},children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("input",{type:"text",value:U[W.name]||"",onChange:($)=>R({...U,[W.name]:$.target.value}),placeholder:W.schema?.type||"string",style:{width:"100%",padding:"8px 12px",background:"#111",border:"1px solid #333",borderRadius:4,color:"#fff",fontSize:13,fontFamily:"monospace"}},void 0,!1,void 0,this)]},W.name,!0,void 0,this))]},void 0,!0,void 0,this),K.length>0&&z.jsxDEV("div",{style:{marginBottom:12},children:[z.jsxDEV("div",{style:{fontSize:11,color:"#666",marginBottom:6},children:"Query Parameters"},void 0,!1,void 0,this),K.map((W)=>z.jsxDEV("div",{style:{marginBottom:8},children:[z.jsxDEV("label",{style:{fontSize:12,color:"#888",display:"block",marginBottom:4},children:[W.name," ",W.required&&z.jsxDEV("span",{style:{color:"#f66"},children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("input",{type:"text",value:U[W.name]||"",onChange:($)=>R({...U,[W.name]:$.target.value}),placeholder:W.schema?.type||"string",style:{width:"100%",padding:"8px 12px",background:"#111",border:"1px solid #333",borderRadius:4,color:"#fff",fontSize:13,fontFamily:"monospace"}},void 0,!1,void 0,this)]},W.name,!0,void 0,this))]},void 0,!0,void 0,this),S&&z.jsxDEV("div",{style:{marginBottom:12},children:[z.jsxDEV("div",{style:{fontSize:11,color:"#666",marginBottom:6},children:"Request Body (JSON)"},void 0,!1,void 0,this),z.jsxDEV("textarea",{value:G,onChange:(W)=>O(W.target.value),rows:6,style:{width:"100%",padding:"8px 12px",background:"#111",border:"1px solid #333",borderRadius:4,color:"#fff",fontSize:12,fontFamily:"monospace",resize:"vertical"}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:C,disabled:w,style:{padding:"10px 20px",background:w?"#333":"#f97316",color:w?"#666":"#000",border:"none",borderRadius:4,cursor:w?"not-allowed":"pointer",fontSize:13,fontWeight:600},children:w?"Executing...":"Execute"},void 0,!1,void 0,this),B&&z.jsxDEV("div",{style:{marginTop:12,padding:12,background:"#2a1515",borderRadius:4,color:"#f66",fontSize:12},children:B},void 0,!1,void 0,this),_&&z.jsxDEV("div",{style:{marginTop:12},children:[z.jsxDEV("div",{style:{fontSize:11,color:"#666",marginBottom:6},children:["Response"," ",z.jsxDEV("span",{style:{color:_.status>=200&&_.status<300?"#49cc90":"#f66"},children:_.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("pre",{style:{padding:12,background:"#111",borderRadius:4,color:"#888",fontSize:11,fontFamily:"monospace",overflow:"auto",maxHeight:300,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:typeof _.data==="string"?_.data:JSON.stringify(_.data,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function h(){let{authFetch:I}=l(),[A,F]=M.useState(null),[L,T]=M.useState(!0),[U,R]=M.useState(new Set),[G,O]=M.useState(null),[_,k]=M.useState(!1);M.useEffect(()=>{B()},[]);async function w(){if(!A)return;try{await navigator.clipboard.writeText(JSON.stringify(A,null,2)),k(!0),setTimeout(()=>k(!1),2000)}catch(N){console.error("Failed to copy:",N)}}function q(){if(!A)return;let N=new Blob([JSON.stringify(A,null,2)],{type:"application/json"}),Q=URL.createObjectURL(N),X=document.createElement("a");X.href=Q,X.download="apteva-openapi.json",X.click(),URL.revokeObjectURL(Q)}async function B(){try{let N=await I("/api/openapi");if(N.ok){let Q=await N.json();F(Q)}}catch(N){console.error("Failed to load OpenAPI spec:",N)}finally{T(!1)}}function f(N){R((Q)=>{let X=new Set(Q);if(X.has(N))X.delete(N);else X.add(N);return X})}function C(N,Q=0){if(!N)return"{}";if(Q>2)return"...";if(N.$ref)return N.$ref.split("/").pop()||"Object";if(N.type==="array")return`${C(N.items,Q+1)}[]`;if(N.type==="object"&&N.properties){let X=Object.entries(N.properties).slice(0,3).map(([Z,H])=>`${Z}: ${H.type||"any"}`).join(", "),Y=Object.keys(N.properties).length>3?", ...":"";return`{ ${X}${Y} }`}return N.type||"any"}if(L)return z.jsxDEV("div",{style:{padding:24},children:z.jsxDEV("p",{style:{color:"#888"},children:"Loading API documentation..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(!A)return z.jsxDEV("div",{style:{padding:24},children:z.jsxDEV("p",{style:{color:"#f66"},children:"Failed to load API documentation"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let b=A.tags||[],K=Object.entries(A.paths);function S(N){let Q=new Set;function X(Y){if(!Y)return;if(typeof Y==="object"){if(Y.$ref){let Z=Y.$ref.split("/").pop();if(Z)Q.add(Z)}for(let Z of Object.values(Y))X(Z)}}return X(N.requestBody),X(N.responses),Q}function W(){if(!G||!A.components?.schemas)return Object.keys(A.components?.schemas||{});let N=new Set;for(let[Q,X]of $)for(let[Y,Z]of Object.entries(X)){if(!["get","post","put","delete","patch"].includes(Y))continue;if(Z.tags?.includes(G))S(Z).forEach((g)=>N.add(g))}return Array.from(N)}let $=G?K.filter(([N,Q])=>Object.values(Q).some((X)=>X.tags?.includes(G))):K;return z.jsxDEV("div",{style:{padding:24,maxWidth:1000,height:"100%",overflowY:"auto"},children:[z.jsxDEV("div",{style:{marginBottom:24},children:[z.jsxDEV("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[z.jsxDEV("h1",{style:{fontSize:24,fontWeight:600},children:A.info.title},void 0,!1,void 0,this),z.jsxDEV("div",{style:{display:"flex",gap:8},children:[z.jsxDEV("button",{onClick:w,style:{padding:"8px 16px",borderRadius:4,border:"1px solid #333",background:_?"#49cc90":"#1a1a2e",color:_?"#000":"#fff",cursor:"pointer",fontSize:12,fontFamily:"inherit"},children:_?"Copied!":"Copy JSON"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:q,style:{padding:"8px 16px",borderRadius:4,border:"1px solid #333",background:"#1a1a2e",color:"#fff",cursor:"pointer",fontSize:12,fontFamily:"inherit"},children:"Download"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{style:{color:"#888",marginBottom:8},children:A.info.description.split(`
2
2
  `)[0]},void 0,!1,void 0,this),z.jsxDEV("p",{style:{color:"#666",fontSize:12},children:["Version: ",A.info.version]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{style:{background:"#1a1a2e",padding:12,borderRadius:6,marginBottom:24,fontFamily:"monospace"},children:[z.jsxDEV("span",{style:{color:"#888"},children:"Base URL: "},void 0,!1,void 0,this),z.jsxDEV("span",{style:{color:"#61affe"},children:[window.location.origin,"/api"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{style:{marginBottom:24,display:"flex",flexWrap:"wrap",gap:8},children:[z.jsxDEV("button",{onClick:()=>O(null),style:{padding:"6px 12px",borderRadius:4,border:"1px solid #333",background:G===null?"#333":"transparent",color:G===null?"#fff":"#888",cursor:"pointer",fontSize:12},children:"All"},void 0,!1,void 0,this),b.map((N)=>z.jsxDEV("button",{onClick:()=>O(N.name),style:{padding:"6px 12px",borderRadius:4,border:"1px solid #333",background:G===N.name?"#333":"transparent",color:G===N.name?"#fff":"#888",cursor:"pointer",fontSize:12},title:N.description,children:N.name},N.name,!1,void 0,this))]},void 0,!0,void 0,this),z.jsxDEV("div",{style:{display:"flex",flexDirection:"column",gap:8},children:$.map(([N,Q])=>Object.entries(Q).filter(([X])=>["get","post","put","delete","patch"].includes(X)).map(([X,Y])=>{let Z=`${X}:${N}`,H=U.has(Z),g=X.toUpperCase(),j=V[X]||"#888";return z.jsxDEV("div",{style:{border:"1px solid #333",borderRadius:6,overflow:"hidden"},children:[z.jsxDEV("div",{onClick:()=>f(Z),style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:H?"#1a1a2e":"transparent",cursor:"pointer"},children:[z.jsxDEV("span",{style:{background:j,color:"#000",padding:"4px 8px",borderRadius:4,fontSize:11,fontWeight:600,minWidth:60,textAlign:"center"},children:g},void 0,!1,void 0,this),z.jsxDEV("span",{style:{fontFamily:"monospace",color:"#fff"},children:N},void 0,!1,void 0,this),z.jsxDEV("span",{style:{color:"#888",flex:1,fontSize:13},children:Y.summary},void 0,!1,void 0,this),z.jsxDEV("span",{style:{color:"#666",fontSize:12},children:H?"[-]":"[+]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H&&z.jsxDEV("div",{style:{padding:16,background:"#0d0d1a",borderTop:"1px solid #333"},children:[Y.description&&z.jsxDEV("p",{style:{color:"#888",marginBottom:16,fontSize:13},children:Y.description},void 0,!1,void 0,this),Y.parameters&&Y.parameters.length>0&&z.jsxDEV("div",{style:{marginBottom:16},children:[z.jsxDEV("h4",{style:{fontSize:13,color:"#888",marginBottom:8},children:"Parameters"},void 0,!1,void 0,this),z.jsxDEV("div",{style:{background:"#1a1a2e",borderRadius:4,padding:12},children:Y.parameters.map((J)=>z.jsxDEV("div",{style:{display:"flex",gap:12,marginBottom:8,fontSize:12},children:[z.jsxDEV("span",{style:{color:"#61affe",minWidth:100},children:[J.name,J.required&&z.jsxDEV("span",{style:{color:"#f66"},children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("span",{style:{color:"#666"},children:["(",J.in,")"]},void 0,!0,void 0,this),z.jsxDEV("span",{style:{color:"#888"},children:J.schema?.type||"string"},void 0,!1,void 0,this),J.description&&z.jsxDEV("span",{style:{color:"#666"},children:["- ",J.description]},void 0,!0,void 0,this)]},J.name,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y.requestBody&&z.jsxDEV("div",{style:{marginBottom:16},children:[z.jsxDEV("h4",{style:{fontSize:13,color:"#888",marginBottom:8},children:["Request Body",Y.requestBody.required&&z.jsxDEV("span",{style:{color:"#f66"},children:" (required)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{style:{background:"#1a1a2e",borderRadius:4,padding:12,fontFamily:"monospace",fontSize:12,color:"#49cc90"},children:Object.entries(Y.requestBody.content||{}).map(([J,P])=>z.jsxDEV("div",{children:[z.jsxDEV("span",{style:{color:"#666"},children:[J,": "]},void 0,!0,void 0,this),C(P.schema)]},J,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y.responses&&z.jsxDEV("div",{children:[z.jsxDEV("h4",{style:{fontSize:13,color:"#888",marginBottom:8},children:"Responses"},void 0,!1,void 0,this),z.jsxDEV("div",{style:{background:"#1a1a2e",borderRadius:4,padding:12},children:Object.entries(Y.responses).map(([J,P])=>{let v=P.content?.["application/json"]?.schema,u=v?.$ref?.split("/").pop(),n=v?.type,i=v?.items?.$ref?.split("/").pop();return z.jsxDEV("div",{style:{marginBottom:12,fontSize:12},children:[z.jsxDEV("div",{style:{display:"flex",gap:12,marginBottom:4},children:[z.jsxDEV("span",{style:{color:J.startsWith("2")?"#49cc90":"#f66",minWidth:40},children:J},void 0,!1,void 0,this),z.jsxDEV("span",{style:{color:"#888"},children:P.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),v&&z.jsxDEV("div",{style:{marginLeft:52,padding:"8px 12px",background:"#0d0d1a",borderRadius:4,fontFamily:"monospace"},children:u?z.jsxDEV("span",{style:{color:"#61affe"},children:u},void 0,!1,void 0,this):n==="array"&&i?z.jsxDEV("span",{style:{color:"#61affe"},children:[i,"[]"]},void 0,!0,void 0,this):n==="array"?z.jsxDEV("span",{style:{color:"#888"},children:"array"},void 0,!1,void 0,this):z.jsxDEV("span",{style:{color:"#888"},children:C(v)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},J,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV(c,{method:X,path:N,parameters:Y.parameters,requestBody:Y.requestBody,authFetch:I},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},Z,!0,void 0,this)}))},void 0,!1,void 0,this),A.components?.schemas&&W().length>0&&z.jsxDEV("div",{style:{marginTop:32},children:[z.jsxDEV("h2",{style:{fontSize:18,fontWeight:600,marginBottom:16},children:["Schemas ",G&&z.jsxDEV("span",{style:{color:"#666",fontSize:14},children:["(",G,")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{style:{display:"flex",flexDirection:"column",gap:8},children:W().map((N)=>{let Q=A.components.schemas[N];if(!Q)return null;return z.jsxDEV("div",{style:{border:"1px solid #333",borderRadius:6,padding:12},children:[z.jsxDEV("h3",{style:{fontSize:14,color:"#61affe",marginBottom:8},children:N},void 0,!1,void 0,this),Q.properties&&z.jsxDEV("div",{style:{fontSize:12},children:Object.entries(Q.properties).map(([X,Y])=>z.jsxDEV("div",{style:{display:"flex",gap:8,marginBottom:4,fontFamily:"monospace"},children:[z.jsxDEV("span",{style:{color:"#fff",minWidth:120},children:X},void 0,!1,void 0,this),z.jsxDEV("span",{style:{color:"#888"},children:[Y.type||(Y.$ref?Y.$ref.split("/").pop():"any"),Y.nullable&&" | null"]},void 0,!0,void 0,this),Y.enum&&z.jsxDEV("span",{style:{color:"#666"},children:["[",Y.enum.join(" | "),"]"]},void 0,!0,void 0,this)]},X,!0,void 0,this))},void 0,!1,void 0,this)]},N,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}export{h as ApiDocsPage};
3
3
 
4
4
  //# debugId=F1BCC3A63EFF032E64756E2164756E21
@@ -1,4 +1,4 @@
1
- import{O as V}from"./App.40azyqz6.js";import{R as D}from"./App.r2c5nw36.js";import{S as P,V as Kk,W as v,Z as i,ca as o,fa as d}from"./App.k377qek6.js";var J=P(Kk(),1);var q=P(v(),1);function Yk(){let{authFetch:K}=o(),{currentProjectId:X}=d(),{confirm:j,ConfirmDialog:E}=V(),[$,x]=J.useState([]),[A,c]=J.useState([]),[a,u]=J.useState(!0),[r,Y]=J.useState(!1),[H,C]=J.useState(null),[T,Q]=J.useState(new Set),[F,R]=J.useState(!1),[y,I]=J.useState(null),[w,f]=J.useState(null),[S,U]=J.useState({}),[M,N]=J.useState(""),[b,L]=J.useState(""),[g,B]=J.useState(""),Z=X&&X!=="all"&&X!=="unassigned"?X:null,n=Z?A.filter((k)=>k.projectId===Z):A,{events:p}=i({category:"test",limit:50}),_=J.useRef(new Set);J.useEffect(()=>{for(let k of p){if(_.current.has(k.id))continue;_.current.add(k.id);let z=k.data?.test_case_id;if(!z)continue;if(k.type==="test_started")U((G)=>({...G,[z]:{phase:"starting"}})),Q((G)=>new Set(G).add(z));else if(k.type==="test_planning")U((G)=>({...G,[z]:{phase:"planning"}}));else if(k.type==="test_executing"){let G=k.data?.agent_name;U((O)=>({...O,[z]:{phase:"executing",detail:G}}))}else if(k.type==="test_judging")U((G)=>({...G,[z]:{phase:"judging"}}));else if(k.type==="test_completed")U((G)=>{let O={...G};return delete O[z],O}),Q((G)=>{let O=new Set(G);return O.delete(z),O}),W()}if(_.current.size>500)_.current=new Set([..._.current].slice(-200))},[p]);let W=async()=>{try{let k=Z?`?project_id=${Z}`:"",z=await K(`/api/tests${k}`);if(z.ok)x(await z.json())}catch{}u(!1)},s=async()=>{try{let k=await K("/api/agents");if(k.ok){let z=await k.json();c((z.agents||z).map((G)=>({id:G.id,name:G.name,status:G.status,provider:G.provider,model:G.model,projectId:G.projectId||null})))}}catch{}};J.useEffect(()=>{Promise.all([W(),s()])},[X]);let l=()=>{C(null),N(""),L(""),B(""),Y(!0)},t=(k)=>{C(k),N(k.name),L(k.behavior||""),B(k.agent_id||""),Y(!0)},e=async()=>{if(!M||!b)return;let k={name:M,behavior:b,agent_id:g||null,project_id:Z||void 0};if(H)await K(`/api/tests/${H.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)});else await K("/api/tests",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)});Y(!1),W()},kk=async(k)=>{if(!await j("Delete this test case? Run history will also be deleted."))return;await K(`/api/tests/${k}`,{method:"DELETE"}),W()},qk=async(k)=>{Q((z)=>new Set(z).add(k));try{await K(`/api/tests/${k}/run`,{method:"POST"}),await W()}catch{}Q((z)=>{let G=new Set(z);return G.delete(k),G}),U((z)=>{let G={...z};return delete G[k],G})},zk=async()=>{R(!0);try{let k=$.map((z)=>z.id);Q(new Set(k)),await K("/api/tests/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({test_case_ids:k})}),await W()}catch{}Q(new Set),R(!1)},Gk=async(k)=>{try{let z=await K(`/api/tests/${k}/runs`);if(z.ok)I({testId:k,runs:await z.json()})}catch{}},h={starting:{label:"Starting",color:"bg-blue-900/50 text-blue-400 border-blue-500/30"},planning:{label:"Planning",color:"bg-purple-900/50 text-purple-400 border-purple-500/30"},executing:{label:"Executing",color:"bg-cyan-900/50 text-cyan-400 border-cyan-500/30"},judging:{label:"Judging",color:"bg-amber-900/50 text-amber-400 border-amber-500/30"}},m=(k)=>{return q.jsxDEV("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${{passed:"bg-green-900/50 text-green-400",failed:"bg-red-900/50 text-red-400",error:"bg-yellow-900/50 text-yellow-400",running:"bg-blue-900/50 text-blue-400"}[k]||"bg-[#222] text-[#666]"}`,children:k.toUpperCase()},void 0,!1,void 0,this)},Jk=(k)=>{let z=S[k];if(!z)return null;let G=h[z.phase]||h.starting;return q.jsxDEV("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded text-xs font-medium border ${G.color} animate-pulse`,children:[q.jsxDEV("span",{className:"w-1.5 h-1.5 rounded-full bg-current"},void 0,!1,void 0,this),G.label,z.detail?` · ${z.detail}`:""]},void 0,!0,void 0,this)};return q.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:[E,q.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[q.jsxDEV("div",{children:[q.jsxDEV("h1",{className:"text-xl font-bold",children:"Tests"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666] mt-1",children:"Describe behavior, AI handles the rest"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[$.length>0&&q.jsxDEV("button",{onClick:zk,disabled:F,className:"px-4 py-2 bg-[#1a1a1a] hover:bg-[#222] text-[#e0e0e0] rounded text-sm font-medium transition disabled:opacity-50",children:F?"Running...":"Run All"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:l,className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] text-white rounded text-sm font-medium transition",children:"+ New Test"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),a?q.jsxDEV("div",{className:"text-[#666] text-sm",children:"Loading..."},void 0,!1,void 0,this):$.length===0?q.jsxDEV("div",{className:"text-center py-16",children:[q.jsxDEV("div",{className:"text-[#333] text-4xl mb-4",children:q.jsxDEV("svg",{className:"w-12 h-12 mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:q.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666] mb-2",children:"No tests yet"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#555] mb-4",children:"Describe what your agents should do and let AI verify it"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:l,className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] text-white rounded text-sm font-medium transition",children:"Create your first test"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:$.map((k)=>q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:q.jsxDEV("div",{className:"flex items-start justify-between",children:[q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("span",{className:"font-medium text-sm",children:k.name},void 0,!1,void 0,this),S[k.id]?Jk(k.id):k.last_run&&q.jsxDEV(q.Fragment,{children:[m(k.last_run.status),k.last_run.score!=null&&q.jsxDEV("span",{className:"text-xs text-[#888] font-mono",children:[k.last_run.score,"/10"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k.behavior&&q.jsxDEV("p",{className:"text-xs text-[#888] mb-1.5 line-clamp-2",children:k.behavior},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-xs text-[#666] space-y-0.5",children:[q.jsxDEV("div",{children:["Agent:"," ",q.jsxDEV("span",{className:"text-[#888]",children:k.agent_name||(k.last_run?.selected_agent_name?`${k.last_run.selected_agent_name} (auto-selected)`:"Auto (AI picks)")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),k.last_run?.generated_message&&q.jsxDEV("div",{className:"truncate",children:["Message: ",q.jsxDEV("span",{className:"text-[#888]",children:['"',k.last_run.generated_message,'"']},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k.input_message&&!k.last_run?.generated_message&&q.jsxDEV("div",{className:"truncate",children:["Message: ",q.jsxDEV("span",{className:"text-[#888]",children:['"',k.input_message,'"']},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k.last_run&&q.jsxDEV("div",{children:["Last run:"," ",q.jsxDEV("span",{className:"text-[#888]",children:[k.last_run.duration_ms?`${(k.last_run.duration_ms/1000).toFixed(1)}s`:"---",k.last_run.judge_reasoning&&` --- "${k.last_run.judge_reasoning.slice(0,80)}${k.last_run.judge_reasoning.length>80?"...":""}"`]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-1 ml-3 shrink-0",children:[q.jsxDEV("button",{onClick:()=>Gk(k.id),className:"px-2 py-1 text-xs text-[#666] hover:text-[#888] hover:bg-[#1a1a1a] rounded transition",title:"View run history",children:"History"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>qk(k.id),disabled:T.has(k.id),className:"px-3 py-1 text-xs bg-[#1a1a1a] hover:bg-[#222] text-[#e0e0e0] rounded transition disabled:opacity-50",children:T.has(k.id)?"Running...":"Run"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>t(k),className:"px-2 py-1 text-xs text-[#666] hover:text-[#888] hover:bg-[#1a1a1a] rounded transition",children:"Edit"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>kk(k.id),className:"px-2 py-1 text-xs text-[#666] hover:text-red-400 hover:bg-[#1a1a1a] rounded transition",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},k.id,!1,void 0,this))},void 0,!1,void 0,this),y&&q.jsxDEV("div",{className:"mt-6",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[q.jsxDEV("h2",{className:"text-sm font-bold text-[#888]",children:"Run History"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>{I(null),f(null)},className:"text-xs text-[#666] hover:text-[#888]",children:"Close"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y.runs.length===0?q.jsxDEV("p",{className:"text-sm text-[#666]",children:"No runs yet"},void 0,!1,void 0,this):q.jsxDEV("div",{className:"space-y-2",children:y.runs.map((k)=>q.jsxDEV("div",{className:"bg-[#0d0d0d] border border-[#1a1a1a] rounded p-3",children:[q.jsxDEV("div",{className:"flex items-center justify-between cursor-pointer",onClick:()=>f(w===k.id?null:k.id),children:[q.jsxDEV("div",{className:"flex items-center gap-3",children:[m(k.status),q.jsxDEV("span",{className:"text-xs text-[#666]",children:k.duration_ms?`${(k.duration_ms/1000).toFixed(1)}s`:"---"},void 0,!1,void 0,this),k.score!=null&&q.jsxDEV("span",{className:"text-xs text-[#888] font-mono",children:[k.score,"/10"]},void 0,!0,void 0,this),k.selected_agent_name&&q.jsxDEV("span",{className:"text-xs text-[#555]",children:["Agent: ",k.selected_agent_name]},void 0,!0,void 0,this),q.jsxDEV("span",{className:"text-xs text-[#555]",children:new Date(k.created_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("span",{className:"text-xs text-[#555]",children:w===k.id?"---":"+"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w===k.id&&q.jsxDEV("div",{className:"mt-3 space-y-2",children:[k.planner_reasoning&&q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"text-xs text-[#666] mb-1",children:"Planner:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-[#aaa] bg-[#0a0a0a] p-2 rounded",children:[k.selected_agent_name&&q.jsxDEV("span",{className:"text-[#f97316]",children:k.selected_agent_name},void 0,!1,void 0,this),k.selected_agent_name&&" --- ",k.planner_reasoning]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k.generated_message&&q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"text-xs text-[#666] mb-1",children:"Generated Message:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-[#aaa] bg-[#0a0a0a] p-2 rounded",children:['"',k.generated_message,'"']},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k.judge_reasoning&&q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"text-xs text-[#666] mb-1",children:"Judge:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-[#aaa] bg-[#0a0a0a] p-2 rounded",children:k.judge_reasoning},void 0,!1,void 0,this)]},void 0,!0,void 0,this),k.error&&q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"text-xs text-red-400 mb-1",children:"Error:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-red-300 bg-[#0a0a0a] p-2 rounded",children:k.error},void 0,!1,void 0,this)]},void 0,!0,void 0,this),k.agent_response&&q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"text-xs text-[#666] mb-1",children:"Agent Response (Thread):"},void 0,!1,void 0,this),q.jsxDEV("pre",{className:"text-xs text-[#888] bg-[#0a0a0a] p-2 rounded overflow-auto max-h-64",children:k.agent_response},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},k.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),r&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/60 z-50 flex items-center justify-center",onClick:()=>Y(!1),children:q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg w-full max-w-lg mx-4 p-6",onClick:(k)=>k.stopPropagation(),children:[q.jsxDEV("h2",{className:"text-lg font-bold mb-4",children:H?"Edit Test":"New Test"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[#666] mb-1",children:"Name"},void 0,!1,void 0,this),q.jsxDEV("input",{value:M,onChange:(k)=>N(k.target.value),placeholder:"e.g. Social Media Posting",className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[#666] mb-1",children:"Behavior"},void 0,!1,void 0,this),q.jsxDEV("textarea",{value:b,onChange:(k)=>L(k.target.value),placeholder:"Describe what should happen, e.g. 'When asked to post on social media, the agent creates a proper post with relevant hashtags and confirms it was published'",rows:3,className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316] resize-none"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"AI will generate the test message and evaluate results based on this"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[#666] mb-1",children:"Agent"},void 0,!1,void 0,this),q.jsxDEV(D,{value:g,onChange:B,placeholder:"Auto (AI picks the best agent)",options:n.map((k)=>({value:k.id,label:`${k.name} (${k.status})`}))},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Leave empty to let AI choose the right agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex justify-end gap-2 mt-6",children:[q.jsxDEV("button",{onClick:()=>Y(!1),className:"px-4 py-2 text-sm text-[#888] hover:text-[#e0e0e0] transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:e,disabled:!M||!b,className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-white rounded text-sm font-medium transition",children:H?"Save":"Create"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}
1
+ import{O as V}from"./App.yv87t9m5.js";import{R as D}from"./App.p0fb1pds.js";import{S as P,V as Kk,W as v,Z as i,ca as o,fa as d}from"./App.mvtqv6qc.js";var J=P(Kk(),1);var q=P(v(),1);function Yk(){let{authFetch:K}=o(),{currentProjectId:X}=d(),{confirm:j,ConfirmDialog:E}=V(),[$,x]=J.useState([]),[A,c]=J.useState([]),[a,u]=J.useState(!0),[r,Y]=J.useState(!1),[H,C]=J.useState(null),[T,Q]=J.useState(new Set),[F,R]=J.useState(!1),[y,I]=J.useState(null),[w,f]=J.useState(null),[S,U]=J.useState({}),[M,N]=J.useState(""),[b,L]=J.useState(""),[g,B]=J.useState(""),Z=X&&X!=="all"&&X!=="unassigned"?X:null,n=Z?A.filter((k)=>k.projectId===Z):A,{events:p}=i({category:"test",limit:50}),_=J.useRef(new Set);J.useEffect(()=>{for(let k of p){if(_.current.has(k.id))continue;_.current.add(k.id);let z=k.data?.test_case_id;if(!z)continue;if(k.type==="test_started")U((G)=>({...G,[z]:{phase:"starting"}})),Q((G)=>new Set(G).add(z));else if(k.type==="test_planning")U((G)=>({...G,[z]:{phase:"planning"}}));else if(k.type==="test_executing"){let G=k.data?.agent_name;U((O)=>({...O,[z]:{phase:"executing",detail:G}}))}else if(k.type==="test_judging")U((G)=>({...G,[z]:{phase:"judging"}}));else if(k.type==="test_completed")U((G)=>{let O={...G};return delete O[z],O}),Q((G)=>{let O=new Set(G);return O.delete(z),O}),W()}if(_.current.size>500)_.current=new Set([..._.current].slice(-200))},[p]);let W=async()=>{try{let k=Z?`?project_id=${Z}`:"",z=await K(`/api/tests${k}`);if(z.ok)x(await z.json())}catch{}u(!1)},s=async()=>{try{let k=await K("/api/agents");if(k.ok){let z=await k.json();c((z.agents||z).map((G)=>({id:G.id,name:G.name,status:G.status,provider:G.provider,model:G.model,projectId:G.projectId||null})))}}catch{}};J.useEffect(()=>{Promise.all([W(),s()])},[X]);let l=()=>{C(null),N(""),L(""),B(""),Y(!0)},t=(k)=>{C(k),N(k.name),L(k.behavior||""),B(k.agent_id||""),Y(!0)},e=async()=>{if(!M||!b)return;let k={name:M,behavior:b,agent_id:g||null,project_id:Z||void 0};if(H)await K(`/api/tests/${H.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)});else await K("/api/tests",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)});Y(!1),W()},kk=async(k)=>{if(!await j("Delete this test case? Run history will also be deleted."))return;await K(`/api/tests/${k}`,{method:"DELETE"}),W()},qk=async(k)=>{Q((z)=>new Set(z).add(k));try{await K(`/api/tests/${k}/run`,{method:"POST"}),await W()}catch{}Q((z)=>{let G=new Set(z);return G.delete(k),G}),U((z)=>{let G={...z};return delete G[k],G})},zk=async()=>{R(!0);try{let k=$.map((z)=>z.id);Q(new Set(k)),await K("/api/tests/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({test_case_ids:k})}),await W()}catch{}Q(new Set),R(!1)},Gk=async(k)=>{try{let z=await K(`/api/tests/${k}/runs`);if(z.ok)I({testId:k,runs:await z.json()})}catch{}},h={starting:{label:"Starting",color:"bg-blue-900/50 text-blue-400 border-blue-500/30"},planning:{label:"Planning",color:"bg-purple-900/50 text-purple-400 border-purple-500/30"},executing:{label:"Executing",color:"bg-cyan-900/50 text-cyan-400 border-cyan-500/30"},judging:{label:"Judging",color:"bg-amber-900/50 text-amber-400 border-amber-500/30"}},m=(k)=>{return q.jsxDEV("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${{passed:"bg-green-900/50 text-green-400",failed:"bg-red-900/50 text-red-400",error:"bg-yellow-900/50 text-yellow-400",running:"bg-blue-900/50 text-blue-400"}[k]||"bg-[#222] text-[#666]"}`,children:k.toUpperCase()},void 0,!1,void 0,this)},Jk=(k)=>{let z=S[k];if(!z)return null;let G=h[z.phase]||h.starting;return q.jsxDEV("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded text-xs font-medium border ${G.color} animate-pulse`,children:[q.jsxDEV("span",{className:"w-1.5 h-1.5 rounded-full bg-current"},void 0,!1,void 0,this),G.label,z.detail?` · ${z.detail}`:""]},void 0,!0,void 0,this)};return q.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:[E,q.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[q.jsxDEV("div",{children:[q.jsxDEV("h1",{className:"text-xl font-bold",children:"Tests"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666] mt-1",children:"Describe behavior, AI handles the rest"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[$.length>0&&q.jsxDEV("button",{onClick:zk,disabled:F,className:"px-4 py-2 bg-[#1a1a1a] hover:bg-[#222] text-[#e0e0e0] rounded text-sm font-medium transition disabled:opacity-50",children:F?"Running...":"Run All"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:l,className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] text-white rounded text-sm font-medium transition",children:"+ New Test"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),a?q.jsxDEV("div",{className:"text-[#666] text-sm",children:"Loading..."},void 0,!1,void 0,this):$.length===0?q.jsxDEV("div",{className:"text-center py-16",children:[q.jsxDEV("div",{className:"text-[#333] text-4xl mb-4",children:q.jsxDEV("svg",{className:"w-12 h-12 mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:q.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666] mb-2",children:"No tests yet"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#555] mb-4",children:"Describe what your agents should do and let AI verify it"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:l,className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] text-white rounded text-sm font-medium transition",children:"Create your first test"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:$.map((k)=>q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:q.jsxDEV("div",{className:"flex items-start justify-between",children:[q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("span",{className:"font-medium text-sm",children:k.name},void 0,!1,void 0,this),S[k.id]?Jk(k.id):k.last_run&&q.jsxDEV(q.Fragment,{children:[m(k.last_run.status),k.last_run.score!=null&&q.jsxDEV("span",{className:"text-xs text-[#888] font-mono",children:[k.last_run.score,"/10"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k.behavior&&q.jsxDEV("p",{className:"text-xs text-[#888] mb-1.5 line-clamp-2",children:k.behavior},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-xs text-[#666] space-y-0.5",children:[q.jsxDEV("div",{children:["Agent:"," ",q.jsxDEV("span",{className:"text-[#888]",children:k.agent_name||(k.last_run?.selected_agent_name?`${k.last_run.selected_agent_name} (auto-selected)`:"Auto (AI picks)")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),k.last_run?.generated_message&&q.jsxDEV("div",{className:"truncate",children:["Message: ",q.jsxDEV("span",{className:"text-[#888]",children:['"',k.last_run.generated_message,'"']},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k.input_message&&!k.last_run?.generated_message&&q.jsxDEV("div",{className:"truncate",children:["Message: ",q.jsxDEV("span",{className:"text-[#888]",children:['"',k.input_message,'"']},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k.last_run&&q.jsxDEV("div",{children:["Last run:"," ",q.jsxDEV("span",{className:"text-[#888]",children:[k.last_run.duration_ms?`${(k.last_run.duration_ms/1000).toFixed(1)}s`:"---",k.last_run.judge_reasoning&&` --- "${k.last_run.judge_reasoning.slice(0,80)}${k.last_run.judge_reasoning.length>80?"...":""}"`]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-1 ml-3 shrink-0",children:[q.jsxDEV("button",{onClick:()=>Gk(k.id),className:"px-2 py-1 text-xs text-[#666] hover:text-[#888] hover:bg-[#1a1a1a] rounded transition",title:"View run history",children:"History"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>qk(k.id),disabled:T.has(k.id),className:"px-3 py-1 text-xs bg-[#1a1a1a] hover:bg-[#222] text-[#e0e0e0] rounded transition disabled:opacity-50",children:T.has(k.id)?"Running...":"Run"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>t(k),className:"px-2 py-1 text-xs text-[#666] hover:text-[#888] hover:bg-[#1a1a1a] rounded transition",children:"Edit"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>kk(k.id),className:"px-2 py-1 text-xs text-[#666] hover:text-red-400 hover:bg-[#1a1a1a] rounded transition",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},k.id,!1,void 0,this))},void 0,!1,void 0,this),y&&q.jsxDEV("div",{className:"mt-6",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[q.jsxDEV("h2",{className:"text-sm font-bold text-[#888]",children:"Run History"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>{I(null),f(null)},className:"text-xs text-[#666] hover:text-[#888]",children:"Close"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y.runs.length===0?q.jsxDEV("p",{className:"text-sm text-[#666]",children:"No runs yet"},void 0,!1,void 0,this):q.jsxDEV("div",{className:"space-y-2",children:y.runs.map((k)=>q.jsxDEV("div",{className:"bg-[#0d0d0d] border border-[#1a1a1a] rounded p-3",children:[q.jsxDEV("div",{className:"flex items-center justify-between cursor-pointer",onClick:()=>f(w===k.id?null:k.id),children:[q.jsxDEV("div",{className:"flex items-center gap-3",children:[m(k.status),q.jsxDEV("span",{className:"text-xs text-[#666]",children:k.duration_ms?`${(k.duration_ms/1000).toFixed(1)}s`:"---"},void 0,!1,void 0,this),k.score!=null&&q.jsxDEV("span",{className:"text-xs text-[#888] font-mono",children:[k.score,"/10"]},void 0,!0,void 0,this),k.selected_agent_name&&q.jsxDEV("span",{className:"text-xs text-[#555]",children:["Agent: ",k.selected_agent_name]},void 0,!0,void 0,this),q.jsxDEV("span",{className:"text-xs text-[#555]",children:new Date(k.created_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("span",{className:"text-xs text-[#555]",children:w===k.id?"---":"+"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w===k.id&&q.jsxDEV("div",{className:"mt-3 space-y-2",children:[k.planner_reasoning&&q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"text-xs text-[#666] mb-1",children:"Planner:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-[#aaa] bg-[#0a0a0a] p-2 rounded",children:[k.selected_agent_name&&q.jsxDEV("span",{className:"text-[#f97316]",children:k.selected_agent_name},void 0,!1,void 0,this),k.selected_agent_name&&" --- ",k.planner_reasoning]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k.generated_message&&q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"text-xs text-[#666] mb-1",children:"Generated Message:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-[#aaa] bg-[#0a0a0a] p-2 rounded",children:['"',k.generated_message,'"']},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k.judge_reasoning&&q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"text-xs text-[#666] mb-1",children:"Judge:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-[#aaa] bg-[#0a0a0a] p-2 rounded",children:k.judge_reasoning},void 0,!1,void 0,this)]},void 0,!0,void 0,this),k.error&&q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"text-xs text-red-400 mb-1",children:"Error:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-red-300 bg-[#0a0a0a] p-2 rounded",children:k.error},void 0,!1,void 0,this)]},void 0,!0,void 0,this),k.agent_response&&q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"text-xs text-[#666] mb-1",children:"Agent Response (Thread):"},void 0,!1,void 0,this),q.jsxDEV("pre",{className:"text-xs text-[#888] bg-[#0a0a0a] p-2 rounded overflow-auto max-h-64",children:k.agent_response},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},k.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),r&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/60 z-50 flex items-center justify-center",onClick:()=>Y(!1),children:q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg w-full max-w-lg mx-4 p-6",onClick:(k)=>k.stopPropagation(),children:[q.jsxDEV("h2",{className:"text-lg font-bold mb-4",children:H?"Edit Test":"New Test"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[#666] mb-1",children:"Name"},void 0,!1,void 0,this),q.jsxDEV("input",{value:M,onChange:(k)=>N(k.target.value),placeholder:"e.g. Social Media Posting",className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[#666] mb-1",children:"Behavior"},void 0,!1,void 0,this),q.jsxDEV("textarea",{value:b,onChange:(k)=>L(k.target.value),placeholder:"Describe what should happen, e.g. 'When asked to post on social media, the agent creates a proper post with relevant hashtags and confirms it was published'",rows:3,className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316] resize-none"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"AI will generate the test message and evaluate results based on this"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[#666] mb-1",children:"Agent"},void 0,!1,void 0,this),q.jsxDEV(D,{value:g,onChange:B,placeholder:"Auto (AI picks the best agent)",options:n.map((k)=>({value:k.id,label:`${k.name} (${k.status})`}))},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Leave empty to let AI choose the right agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex justify-end gap-2 mt-6",children:[q.jsxDEV("button",{onClick:()=>Y(!1),className:"px-4 py-2 text-sm text-[#888] hover:text-[#e0e0e0] transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:e,disabled:!M||!b,className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-white rounded text-sm font-medium transition",children:H?"Save":"Create"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}
2
2
  export{Yk as M};
3
3
 
4
4
  //# debugId=395511E423F4574664756E2164756E21
@@ -1,4 +1,4 @@
1
- import{R as P}from"./App.r2c5nw36.js";import{S as N,V as Qq,W as c,Y as o,ca as E,fa as u}from"./App.k377qek6.js";var K=N(Qq(),1);var z=N(c(),1);function i(W){let H=W.category==="LLM",X=W.category==="TOOL",M=W.level==="error",$=W.data?.input_tokens||0,Z=W.data?.output_tokens||0;return{llm_calls:H?1:0,tool_calls:X?1:0,errors:M?1:0,input_tokens:$,output_tokens:Z}}function _q(){let{events:W,statusChangeCounter:H}=o(),{currentProjectId:X,currentProject:M}=u(),{authFetch:$}=E(),[Z,l]=K.useState(null),[C,v]=K.useState([]),[I,d]=K.useState([]),[r,h]=K.useState(!0),[Y,p]=K.useState({level:"",agent_id:""}),[k,n]=K.useState(new Set(["DATABASE"])),[R,a]=K.useState([]),[S,s]=K.useState(null),T=K.useRef(new Set),[t,m]=K.useState(new Set),f=K.useRef(new Set);K.useEffect(()=>{(async()=>{try{let G=await(await $("/api/agents")).json();a(G.agents||[])}catch(B){console.error("Failed to fetch agents:",B)}})()},[$]);let w=K.useMemo(()=>{if(X===null)return R;if(X==="unassigned")return R.filter((q)=>!q.projectId);return R.filter((q)=>q.projectId===X)},[R,X]),V=K.useMemo(()=>new Set(w.map((q)=>q.id)),[w]),g=async()=>{h(!0);try{let q=X==="unassigned"?"null":X||"",B=new URLSearchParams;if(q)B.set("project_id",q);let Q=await(await $(`/api/telemetry/stats${B.toString()?`?${B}`:""}`)).json();l(Q.stats);let J=new URLSearchParams;if(Y.level)J.set("level",Y.level);if(Y.agent_id)J.set("agent_id",Y.agent_id);if(q)J.set("project_id",q);J.set("limit","100");let O=(await(await $(`/api/telemetry/events?${J}`)).json()).events||[];v(O),T.current=new Set(O.map((Kq)=>Kq.id));let b=new URLSearchParams;if(b.set("group_by","agent"),q)b.set("project_id",q);let Jq=await(await $(`/api/telemetry/usage?${b}`)).json();d(Jq.usage||[])}catch(q){console.error("Failed to fetch telemetry:",q)}h(!1)};K.useEffect(()=>{g()},[Y,X,$,H]);let U=K.useMemo(()=>{if(!Z)return null;let q=0,B=0,G=0,Q=0,J=0,A=0;for(let y of W)if(!T.current.has(y.id)){q++;let O=i(y);B+=O.llm_calls,G+=O.tool_calls,Q+=O.errors,J+=O.input_tokens,A+=O.output_tokens}return{total_events:Z.total_events+q,total_llm_calls:Z.total_llm_calls+B,total_tool_calls:Z.total_tool_calls+G,total_errors:Z.total_errors+Q,total_input_tokens:Z.total_input_tokens+J,total_output_tokens:Z.total_output_tokens+A}},[Z,W]),D=K.useMemo(()=>{let q=new Map;for(let B of I)q.set(B.agent_id,{...B});for(let B of W)if(!T.current.has(B.id)){let G=i(B),Q=q.get(B.agent_id);if(Q)Q.llm_calls+=G.llm_calls,Q.tool_calls+=G.tool_calls,Q.errors+=G.errors,Q.input_tokens+=G.input_tokens,Q.output_tokens+=G.output_tokens;else q.set(B.agent_id,{agent_id:B.agent_id,llm_calls:G.llm_calls,tool_calls:G.tool_calls,errors:G.errors,input_tokens:G.input_tokens,output_tokens:G.output_tokens})}return Array.from(q.values())},[I,W]),F=K.default.useMemo(()=>{let q=W;if(X!==null)q=q.filter((J)=>V.has(J.agent_id));if(Y.agent_id)q=q.filter((J)=>J.agent_id===Y.agent_id);if(k.size>0)q=q.filter((J)=>!k.has(J.category));if(Y.level)q=q.filter((J)=>J.level===Y.level);let B=C;if(k.size>0)B=B.filter((J)=>!k.has(J.category));let G=new Set(q.map((J)=>J.id)),Q=[...q];for(let J of B)if(!G.has(J.id))Q.push(J),G.add(J.id);return Q.sort((J,A)=>new Date(A.timestamp).getTime()-new Date(J.timestamp).getTime()),Q.slice(0,100)},[W,C,Y,k,X,V]);K.useEffect(()=>{let q=[];for(let B of W)if(!f.current.has(B.id))f.current.add(B.id),q.push(B.id);if(q.length>0)m((B)=>{let G=new Set(B);return q.forEach((Q)=>G.add(Q)),G}),setTimeout(()=>{m((B)=>{let G=new Set(B);return q.forEach((Q)=>G.delete(Q)),G})},5000)},[W]);let x=(q)=>{return R.find((G)=>G.id===q)?.name||q},_=(q)=>{if(q>=1e6)return(q/1e6).toFixed(1)+"M";if(q>=1000)return(q/1000).toFixed(1)+"K";return q.toString()},e={debug:"text-[#555]",info:"text-blue-400",warn:"text-yellow-400",error:"text-red-400"},j={LLM:"bg-purple-500/20 text-purple-400 border-purple-500/30",TOOL:"bg-blue-500/20 text-blue-400 border-blue-500/30",CHAT:"bg-green-500/20 text-green-400 border-green-500/30",ERROR:"bg-red-500/20 text-red-400 border-red-500/30",SYSTEM:"bg-gray-500/20 text-gray-400 border-gray-500/30",TASK:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",MEMORY:"bg-cyan-500/20 text-cyan-400 border-cyan-500/30",MCP:"bg-orange-500/20 text-orange-400 border-orange-500/30",DATABASE:"bg-pink-500/20 text-pink-400 border-pink-500/30"},qq=["LLM","TOOL","CHAT","TASK","MEMORY","MCP","SYSTEM","DATABASE","ERROR"],zq=(q)=>{n((B)=>{let G=new Set(B);if(G.has(q))G.delete(q);else G.add(q);return G})},Bq=[{value:"",label:"All Agents"},...w.map((q)=>({value:q.id,label:q.name}))],Gq=[{value:"",label:"All Levels"},{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}];return z.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"mb-6",children:[z.jsxDEV("div",{className:"flex items-center gap-3 mb-1",children:[M&&z.jsxDEV("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:M.color}},void 0,!1,void 0,this),z.jsxDEV("h1",{className:"text-2xl font-semibold",children:X===null?"Telemetry":X==="unassigned"?"Telemetry - Unassigned":`Telemetry - ${M?.name||""}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-[#666]",children:"Monitor agent activity, token usage, and errors."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U&&z.jsxDEV("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-6",children:[z.jsxDEV(L,{label:"Events",value:_(U.total_events)},void 0,!1,void 0,this),z.jsxDEV(L,{label:"LLM Calls",value:_(U.total_llm_calls)},void 0,!1,void 0,this),z.jsxDEV(L,{label:"Tool Calls",value:_(U.total_tool_calls)},void 0,!1,void 0,this),z.jsxDEV(L,{label:"Errors",value:_(U.total_errors),color:"red"},void 0,!1,void 0,this),z.jsxDEV(L,{label:"Input Tokens",value:_(U.total_input_tokens)},void 0,!1,void 0,this),z.jsxDEV(L,{label:"Output Tokens",value:_(U.total_output_tokens)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D.length>0&&z.jsxDEV("div",{className:"mb-6",children:[z.jsxDEV("h2",{className:"text-lg font-medium mb-3",children:"Usage by Agent"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg overflow-hidden",children:z.jsxDEV("table",{className:"w-full text-sm",children:[z.jsxDEV("thead",{children:z.jsxDEV("tr",{className:"border-b border-[#1a1a1a] text-[#666]",children:[z.jsxDEV("th",{className:"text-left p-3",children:"Agent"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"LLM Calls"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"Tool Calls"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"Input Tokens"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"Output Tokens"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"Errors"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("tbody",{children:D.map((q)=>z.jsxDEV("tr",{className:"border-b border-[#1a1a1a] last:border-0",children:[z.jsxDEV("td",{className:"p-3 font-medium",children:x(q.agent_id)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right text-[#888]",children:_(q.llm_calls)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right text-[#888]",children:_(q.tool_calls)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right text-[#888]",children:_(q.input_tokens)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right text-[#888]",children:_(q.output_tokens)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right",children:q.errors>0?z.jsxDEV("span",{className:"text-red-400",children:q.errors},void 0,!1,void 0,this):z.jsxDEV("span",{className:"text-[#444]",children:"0"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},q.agent_id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[z.jsxDEV("div",{className:"w-44",children:z.jsxDEV(P,{value:Y.agent_id,options:Bq,onChange:(q)=>p({...Y,agent_id:q}),placeholder:"All Agents"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap items-center gap-1.5 flex-1",children:qq.map((q)=>{let B=k.has(q),G=j[q]||"bg-[#222] text-[#888] border-[#333]";return z.jsxDEV("button",{onClick:()=>zq(q),className:`px-2 py-0.5 rounded text-xs border transition-all ${B?"bg-[#1a1a1a] text-[#555] border-[#333] opacity-50":G}`,children:q},q,!1,void 0,this)})},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("div",{className:"w-36",children:z.jsxDEV(P,{value:Y.level,options:Gq,onChange:(q)=>p({...Y,level:q}),placeholder:"All Levels"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:g,className:"px-3 py-2 bg-[#1a1a1a] hover:bg-[#222] border border-[#333] rounded text-sm transition",children:"Refresh"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg",children:[z.jsxDEV("div",{className:"p-3 border-b border-[#1a1a1a] flex items-center justify-between",children:[z.jsxDEV("h2",{className:"font-medium",children:"Recent Events"},void 0,!1,void 0,this),W.length>0&&z.jsxDEV("span",{className:"text-xs text-[#666]",children:[W.length," new"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),r&&F.length===0?z.jsxDEV("div",{className:"p-8 text-center text-[#666]",children:"Loading..."},void 0,!1,void 0,this):F.length===0?z.jsxDEV("div",{className:"p-8 text-center text-[#666]",children:"No telemetry events yet. Events will appear here in real-time once agents start sending data."},void 0,!1,void 0,this):z.jsxDEV("div",{className:"divide-y divide-[#1a1a1a]",children:F.map((q)=>{let B=t.has(q.id);return z.jsxDEV("div",{className:`p-3 hover:bg-[#0a0a0a] cursor-pointer transition-all duration-500 ${B?"bg-green-500/5":""}`,style:{animation:B?"slideIn 0.3s ease-out":void 0},onClick:()=>s(S===q.id?null:q.id),children:z.jsxDEV("div",{className:"flex items-start gap-3",children:[z.jsxDEV("span",{className:`px-2 py-0.5 rounded text-xs border transition-colors duration-300 ${j[q.category]||"bg-[#222] text-[#888] border-[#333]"}`,children:q.category},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("span",{className:"font-medium text-sm",children:q.type},void 0,!1,void 0,this),z.jsxDEV("span",{className:`text-xs ${e[q.level]||"text-[#666]"}`,children:q.level},void 0,!1,void 0,this),q.duration_ms&&z.jsxDEV("span",{className:"text-xs text-[#555]",children:[q.duration_ms,"ms"]},void 0,!0,void 0,this),z.jsxDEV("span",{className:`w-1.5 h-1.5 rounded-full bg-green-400 transition-opacity duration-1000 ${B?"opacity-100":"opacity-0"}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"text-xs text-[#555] mt-1",children:[x(q.agent_id)," · ",new Date(q.timestamp).toLocaleString()]},void 0,!0,void 0,this),q.error&&z.jsxDEV("div",{className:"text-xs text-red-400 mt-1 font-mono",children:q.error},void 0,!1,void 0,this),S===q.id&&q.data&&Object.keys(q.data).length>0&&z.jsxDEV("pre",{className:"text-xs text-[#666] mt-2 p-2 bg-[#0a0a0a] rounded overflow-x-auto",children:JSON.stringify(q.data,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},q.id,!1,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function L({label:W,value:H,color:X}){return z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[z.jsxDEV("div",{className:"text-[#666] text-xs mb-1",children:W},void 0,!1,void 0,this),z.jsxDEV("div",{className:`text-2xl font-semibold ${X==="red"?"text-red-400":""}`,children:H},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}
1
+ import{R as P}from"./App.p0fb1pds.js";import{S as N,V as Qq,W as c,Y as o,ca as E,fa as u}from"./App.mvtqv6qc.js";var K=N(Qq(),1);var z=N(c(),1);function i(W){let H=W.category==="LLM",X=W.category==="TOOL",M=W.level==="error",$=W.data?.input_tokens||0,Z=W.data?.output_tokens||0;return{llm_calls:H?1:0,tool_calls:X?1:0,errors:M?1:0,input_tokens:$,output_tokens:Z}}function _q(){let{events:W,statusChangeCounter:H}=o(),{currentProjectId:X,currentProject:M}=u(),{authFetch:$}=E(),[Z,l]=K.useState(null),[C,v]=K.useState([]),[I,d]=K.useState([]),[r,h]=K.useState(!0),[Y,p]=K.useState({level:"",agent_id:""}),[k,n]=K.useState(new Set(["DATABASE"])),[R,a]=K.useState([]),[S,s]=K.useState(null),T=K.useRef(new Set),[t,m]=K.useState(new Set),f=K.useRef(new Set);K.useEffect(()=>{(async()=>{try{let G=await(await $("/api/agents")).json();a(G.agents||[])}catch(B){console.error("Failed to fetch agents:",B)}})()},[$]);let w=K.useMemo(()=>{if(X===null)return R;if(X==="unassigned")return R.filter((q)=>!q.projectId);return R.filter((q)=>q.projectId===X)},[R,X]),V=K.useMemo(()=>new Set(w.map((q)=>q.id)),[w]),g=async()=>{h(!0);try{let q=X==="unassigned"?"null":X||"",B=new URLSearchParams;if(q)B.set("project_id",q);let Q=await(await $(`/api/telemetry/stats${B.toString()?`?${B}`:""}`)).json();l(Q.stats);let J=new URLSearchParams;if(Y.level)J.set("level",Y.level);if(Y.agent_id)J.set("agent_id",Y.agent_id);if(q)J.set("project_id",q);J.set("limit","100");let O=(await(await $(`/api/telemetry/events?${J}`)).json()).events||[];v(O),T.current=new Set(O.map((Kq)=>Kq.id));let b=new URLSearchParams;if(b.set("group_by","agent"),q)b.set("project_id",q);let Jq=await(await $(`/api/telemetry/usage?${b}`)).json();d(Jq.usage||[])}catch(q){console.error("Failed to fetch telemetry:",q)}h(!1)};K.useEffect(()=>{g()},[Y,X,$,H]);let U=K.useMemo(()=>{if(!Z)return null;let q=0,B=0,G=0,Q=0,J=0,A=0;for(let y of W)if(!T.current.has(y.id)){q++;let O=i(y);B+=O.llm_calls,G+=O.tool_calls,Q+=O.errors,J+=O.input_tokens,A+=O.output_tokens}return{total_events:Z.total_events+q,total_llm_calls:Z.total_llm_calls+B,total_tool_calls:Z.total_tool_calls+G,total_errors:Z.total_errors+Q,total_input_tokens:Z.total_input_tokens+J,total_output_tokens:Z.total_output_tokens+A}},[Z,W]),D=K.useMemo(()=>{let q=new Map;for(let B of I)q.set(B.agent_id,{...B});for(let B of W)if(!T.current.has(B.id)){let G=i(B),Q=q.get(B.agent_id);if(Q)Q.llm_calls+=G.llm_calls,Q.tool_calls+=G.tool_calls,Q.errors+=G.errors,Q.input_tokens+=G.input_tokens,Q.output_tokens+=G.output_tokens;else q.set(B.agent_id,{agent_id:B.agent_id,llm_calls:G.llm_calls,tool_calls:G.tool_calls,errors:G.errors,input_tokens:G.input_tokens,output_tokens:G.output_tokens})}return Array.from(q.values())},[I,W]),F=K.default.useMemo(()=>{let q=W;if(X!==null)q=q.filter((J)=>V.has(J.agent_id));if(Y.agent_id)q=q.filter((J)=>J.agent_id===Y.agent_id);if(k.size>0)q=q.filter((J)=>!k.has(J.category));if(Y.level)q=q.filter((J)=>J.level===Y.level);let B=C;if(k.size>0)B=B.filter((J)=>!k.has(J.category));let G=new Set(q.map((J)=>J.id)),Q=[...q];for(let J of B)if(!G.has(J.id))Q.push(J),G.add(J.id);return Q.sort((J,A)=>new Date(A.timestamp).getTime()-new Date(J.timestamp).getTime()),Q.slice(0,100)},[W,C,Y,k,X,V]);K.useEffect(()=>{let q=[];for(let B of W)if(!f.current.has(B.id))f.current.add(B.id),q.push(B.id);if(q.length>0)m((B)=>{let G=new Set(B);return q.forEach((Q)=>G.add(Q)),G}),setTimeout(()=>{m((B)=>{let G=new Set(B);return q.forEach((Q)=>G.delete(Q)),G})},5000)},[W]);let x=(q)=>{return R.find((G)=>G.id===q)?.name||q},_=(q)=>{if(q>=1e6)return(q/1e6).toFixed(1)+"M";if(q>=1000)return(q/1000).toFixed(1)+"K";return q.toString()},e={debug:"text-[#555]",info:"text-blue-400",warn:"text-yellow-400",error:"text-red-400"},j={LLM:"bg-purple-500/20 text-purple-400 border-purple-500/30",TOOL:"bg-blue-500/20 text-blue-400 border-blue-500/30",CHAT:"bg-green-500/20 text-green-400 border-green-500/30",ERROR:"bg-red-500/20 text-red-400 border-red-500/30",SYSTEM:"bg-gray-500/20 text-gray-400 border-gray-500/30",TASK:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",MEMORY:"bg-cyan-500/20 text-cyan-400 border-cyan-500/30",MCP:"bg-orange-500/20 text-orange-400 border-orange-500/30",DATABASE:"bg-pink-500/20 text-pink-400 border-pink-500/30"},qq=["LLM","TOOL","CHAT","TASK","MEMORY","MCP","SYSTEM","DATABASE","ERROR"],zq=(q)=>{n((B)=>{let G=new Set(B);if(G.has(q))G.delete(q);else G.add(q);return G})},Bq=[{value:"",label:"All Agents"},...w.map((q)=>({value:q.id,label:q.name}))],Gq=[{value:"",label:"All Levels"},{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}];return z.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"mb-6",children:[z.jsxDEV("div",{className:"flex items-center gap-3 mb-1",children:[M&&z.jsxDEV("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:M.color}},void 0,!1,void 0,this),z.jsxDEV("h1",{className:"text-2xl font-semibold",children:X===null?"Telemetry":X==="unassigned"?"Telemetry - Unassigned":`Telemetry - ${M?.name||""}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-[#666]",children:"Monitor agent activity, token usage, and errors."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U&&z.jsxDEV("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-6",children:[z.jsxDEV(L,{label:"Events",value:_(U.total_events)},void 0,!1,void 0,this),z.jsxDEV(L,{label:"LLM Calls",value:_(U.total_llm_calls)},void 0,!1,void 0,this),z.jsxDEV(L,{label:"Tool Calls",value:_(U.total_tool_calls)},void 0,!1,void 0,this),z.jsxDEV(L,{label:"Errors",value:_(U.total_errors),color:"red"},void 0,!1,void 0,this),z.jsxDEV(L,{label:"Input Tokens",value:_(U.total_input_tokens)},void 0,!1,void 0,this),z.jsxDEV(L,{label:"Output Tokens",value:_(U.total_output_tokens)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D.length>0&&z.jsxDEV("div",{className:"mb-6",children:[z.jsxDEV("h2",{className:"text-lg font-medium mb-3",children:"Usage by Agent"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg overflow-hidden",children:z.jsxDEV("table",{className:"w-full text-sm",children:[z.jsxDEV("thead",{children:z.jsxDEV("tr",{className:"border-b border-[#1a1a1a] text-[#666]",children:[z.jsxDEV("th",{className:"text-left p-3",children:"Agent"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"LLM Calls"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"Tool Calls"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"Input Tokens"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"Output Tokens"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"Errors"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("tbody",{children:D.map((q)=>z.jsxDEV("tr",{className:"border-b border-[#1a1a1a] last:border-0",children:[z.jsxDEV("td",{className:"p-3 font-medium",children:x(q.agent_id)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right text-[#888]",children:_(q.llm_calls)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right text-[#888]",children:_(q.tool_calls)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right text-[#888]",children:_(q.input_tokens)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right text-[#888]",children:_(q.output_tokens)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right",children:q.errors>0?z.jsxDEV("span",{className:"text-red-400",children:q.errors},void 0,!1,void 0,this):z.jsxDEV("span",{className:"text-[#444]",children:"0"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},q.agent_id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[z.jsxDEV("div",{className:"w-44",children:z.jsxDEV(P,{value:Y.agent_id,options:Bq,onChange:(q)=>p({...Y,agent_id:q}),placeholder:"All Agents"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap items-center gap-1.5 flex-1",children:qq.map((q)=>{let B=k.has(q),G=j[q]||"bg-[#222] text-[#888] border-[#333]";return z.jsxDEV("button",{onClick:()=>zq(q),className:`px-2 py-0.5 rounded text-xs border transition-all ${B?"bg-[#1a1a1a] text-[#555] border-[#333] opacity-50":G}`,children:q},q,!1,void 0,this)})},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("div",{className:"w-36",children:z.jsxDEV(P,{value:Y.level,options:Gq,onChange:(q)=>p({...Y,level:q}),placeholder:"All Levels"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:g,className:"px-3 py-2 bg-[#1a1a1a] hover:bg-[#222] border border-[#333] rounded text-sm transition",children:"Refresh"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg",children:[z.jsxDEV("div",{className:"p-3 border-b border-[#1a1a1a] flex items-center justify-between",children:[z.jsxDEV("h2",{className:"font-medium",children:"Recent Events"},void 0,!1,void 0,this),W.length>0&&z.jsxDEV("span",{className:"text-xs text-[#666]",children:[W.length," new"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),r&&F.length===0?z.jsxDEV("div",{className:"p-8 text-center text-[#666]",children:"Loading..."},void 0,!1,void 0,this):F.length===0?z.jsxDEV("div",{className:"p-8 text-center text-[#666]",children:"No telemetry events yet. Events will appear here in real-time once agents start sending data."},void 0,!1,void 0,this):z.jsxDEV("div",{className:"divide-y divide-[#1a1a1a]",children:F.map((q)=>{let B=t.has(q.id);return z.jsxDEV("div",{className:`p-3 hover:bg-[#0a0a0a] cursor-pointer transition-all duration-500 ${B?"bg-green-500/5":""}`,style:{animation:B?"slideIn 0.3s ease-out":void 0},onClick:()=>s(S===q.id?null:q.id),children:z.jsxDEV("div",{className:"flex items-start gap-3",children:[z.jsxDEV("span",{className:`px-2 py-0.5 rounded text-xs border transition-colors duration-300 ${j[q.category]||"bg-[#222] text-[#888] border-[#333]"}`,children:q.category},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("span",{className:"font-medium text-sm",children:q.type},void 0,!1,void 0,this),z.jsxDEV("span",{className:`text-xs ${e[q.level]||"text-[#666]"}`,children:q.level},void 0,!1,void 0,this),q.duration_ms&&z.jsxDEV("span",{className:"text-xs text-[#555]",children:[q.duration_ms,"ms"]},void 0,!0,void 0,this),z.jsxDEV("span",{className:`w-1.5 h-1.5 rounded-full bg-green-400 transition-opacity duration-1000 ${B?"opacity-100":"opacity-0"}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"text-xs text-[#555] mt-1",children:[x(q.agent_id)," · ",new Date(q.timestamp).toLocaleString()]},void 0,!0,void 0,this),q.error&&z.jsxDEV("div",{className:"text-xs text-red-400 mt-1 font-mono",children:q.error},void 0,!1,void 0,this),S===q.id&&q.data&&Object.keys(q.data).length>0&&z.jsxDEV("pre",{className:"text-xs text-[#666] mt-2 p-2 bg-[#0a0a0a] rounded overflow-x-auto",children:JSON.stringify(q.data,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},q.id,!1,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function L({label:W,value:H,color:X}){return z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[z.jsxDEV("div",{className:"text-[#666] text-xs mb-1",children:W},void 0,!1,void 0,this),z.jsxDEV("div",{className:`text-2xl font-semibold ${X==="red"?"text-red-400":""}`,children:H},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}
2
2
  export{_q as Q};
3
3
 
4
4
  //# debugId=95CAF9676B21055C64756E2164756E21
@@ -0,0 +1,4 @@
1
+ import{G as D,l as u,m as i}from"./App.ncgc9cxy.js";import{N as r,O as V}from"./App.yv87t9m5.js";import{R as x}from"./App.p0fb1pds.js";import{S as j,V as s,W as o,ca as p,fa as d}from"./App.mvtqv6qc.js";var H=j(s(),1);var q=j(o(),1);function Tq(){let{projectsEnabled:z,metaAgentEnabled:Z}=d(),[W,R]=H.useState("general"),U=[{key:"general",label:"General"},{key:"providers",label:"Providers"},...z?[{key:"projects",label:"Projects"}]:[],...Z?[{key:"assistant",label:"Assistant"}]:[],{key:"channels",label:"Channels"},{key:"api-keys",label:"API Keys"},{key:"account",label:"Account"},{key:"updates",label:"Updates"},{key:"data",label:"Data"}];return q.jsxDEV("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden",children:[q.jsxDEV("div",{className:"md:hidden border-b border-[#1a1a1a] bg-[#0a0a0a]",children:q.jsxDEV("div",{className:"flex overflow-x-auto",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:U.map((Q)=>q.jsxDEV("button",{onClick:()=>R(Q.key),className:`flex-shrink-0 px-4 py-3 text-sm font-medium border-b-2 transition ${W===Q.key?"border-[#f97316] text-[#f97316]":"border-transparent text-[#666] hover:text-[#888]"}`,children:Q.label},Q.key,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("div",{className:"hidden md:block w-48 border-r border-[#1a1a1a] p-4 flex-shrink-0",children:[q.jsxDEV("h2",{className:"text-sm font-medium text-[#666] uppercase tracking-wider mb-3",children:"Settings"},void 0,!1,void 0,this),q.jsxDEV("nav",{className:"space-y-1",children:U.map((Q)=>q.jsxDEV(e,{label:Q.label,active:W===Q.key,onClick:()=>R(Q.key)},Q.key,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex-1 overflow-auto p-4 md:p-6",children:[W==="general"&&q.jsxDEV(qq,{},void 0,!1,void 0,this),W==="providers"&&q.jsxDEV(zq,{},void 0,!1,void 0,this),W==="projects"&&z&&q.jsxDEV(Hq,{},void 0,!1,void 0,this),W==="channels"&&q.jsxDEV(Wq,{},void 0,!1,void 0,this),W==="api-keys"&&q.jsxDEV(Zq,{},void 0,!1,void 0,this),W==="account"&&q.jsxDEV($q,{},void 0,!1,void 0,this),W==="updates"&&q.jsxDEV(Xq,{},void 0,!1,void 0,this),W==="data"&&q.jsxDEV(Gq,{},void 0,!1,void 0,this),W==="assistant"&&Z&&q.jsxDEV(Jq,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function e({label:z,active:Z,onClick:W}){return q.jsxDEV("button",{onClick:W,className:`w-full text-left px-3 py-2 rounded text-sm transition ${Z?"bg-[#1a1a1a] text-[#e0e0e0]":"text-[#666] hover:bg-[#111] hover:text-[#888]"}`,children:z},void 0,!1,void 0,this)}function qq(){let{authFetch:z}=p(),[Z,W]=H.useState(""),[R,U]=H.useState(!0),[Q,N]=H.useState(!1),[L,T]=H.useState(null);H.useEffect(()=>{(async()=>{try{let _=await(await z("/api/settings/instance-url")).json();W(_.instance_url||"")}catch{}U(!1)})()},[]);let J=async()=>{N(!0),T(null);try{let O=await z("/api/settings/instance-url",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({instance_url:Z})}),M=await O.json();if(O.ok)W(M.instance_url||""),T({type:"success",text:"Instance URL saved"});else T({type:"error",text:M.error||"Failed to save"})}catch{T({type:"error",text:"Failed to save"})}N(!1)};return q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"General"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"Instance configuration."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[q.jsxDEV("h3",{className:"font-medium mb-2",children:"Instance URL"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:"The public HTTPS URL for this instance. Used for webhook callbacks from external services like Composio."},void 0,!1,void 0,this),R?q.jsxDEV("div",{className:"text-[#666] text-sm",children:"Loading..."},void 0,!1,void 0,this):q.jsxDEV("div",{className:"space-y-3 max-w-lg",children:[q.jsxDEV("input",{type:"text",value:Z,onChange:(O)=>W(O.target.value),placeholder:"https://your-domain.com",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316] font-mono text-sm"},void 0,!1,void 0,this),L&&q.jsxDEV("div",{className:`p-3 rounded text-sm ${L.type==="success"?"bg-green-500/10 text-green-400 border border-green-500/30":"bg-red-500/10 text-red-400 border border-red-500/30"}`,children:L.text},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:J,disabled:Q,className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black rounded text-sm font-medium transition",children:Q?"Saving...":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function zq(){let{authFetch:z}=p(),{projects:Z,projectsEnabled:W}=d(),[R,U]=H.useState([]),[Q,N]=H.useState(null),[L,T]=H.useState(""),[J,O]=H.useState(!1),[M,_]=H.useState(!1),[B,X]=H.useState(null),[b,I]=H.useState(null),{confirm:F,ConfirmDialog:f}=V(),K=async()=>{let S=await(await z("/api/providers")).json();U(S.providers||[])};H.useEffect(()=>{K()},[]);let y=async()=>{if(!Q||!L)return;O(!0),X(null),I(null);try{_(!0);let S=await(await z(`/api/keys/${Q}/test`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:L})})).json();if(_(!1),!S.valid){X(S.error||"API key is invalid"),O(!1);return}let h=await z(`/api/keys/${Q}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:L})}),g=await h.json();if(!h.ok)X(g.error||"Failed to save key");else{let P="API key saved!";if(g.restartedAgents&&g.restartedAgents.length>0){let c=g.restartedAgents.filter((A)=>A.success).length;if(g.restartedAgents.length-c===0)P+=` Restarted ${c} agent${c>1?"s":""} with new key.`;else P+=` Restarted ${c}/${g.restartedAgents.length} agents.`}I(P),T(""),N(null),K()}}catch($){X("Failed to save key")}O(!1)},l=async($)=>{if(!await F("Are you sure you want to remove this API key?",{confirmText:"Remove",title:"Remove API Key"}))return;await z(`/api/keys/${$}`,{method:"DELETE"}),K()},m=R.filter(($)=>$.type==="llm"),C=R.filter(($)=>$.type==="integration"),G=R.filter(($)=>$.type==="browser"),Y=m.filter(($)=>$.hasKey).length,k=C.filter(($)=>$.hasKey).length,w=G.filter(($)=>$.hasKey).length;return H.useEffect(()=>{if(b&&!Q){let $=setTimeout(()=>I(null),5000);return()=>clearTimeout($)}},[b,Q]),q.jsxDEV(q.Fragment,{children:[f,q.jsxDEV("div",{className:"space-y-10",children:[b&&!Q&&q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4 flex items-center justify-between",children:[q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400",children:[q.jsxDEV(u,{className:"w-5 h-5"},void 0,!1,void 0,this),q.jsxDEV("span",{children:b},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>I(null),className:"text-green-400 hover:text-green-300",children:q.jsxDEV(i,{className:"w-4 h-4"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"AI Providers"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:["Manage your API keys for AI providers. ",Y," of ",m.length," configured."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:m.map(($)=>q.jsxDEV(a,{provider:$,isEditing:Q===$.id,apiKey:L,saving:J,testing:M,error:Q===$.id?B:null,success:Q===$.id?b:null,onStartEdit:()=>{N($.id),X(null),I(null)},onCancelEdit:()=>{N(null),T(""),X(null)},onApiKeyChange:T,onSave:y,onDelete:()=>l($.id)},$.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h2",{className:"text-xl font-semibold mb-1",children:"MCP Integrations"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:["Connect to MCP gateways for tool integrations. ",k," of ",C.length," configured."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:C.map(($)=>q.jsxDEV(Yq,{provider:$,isEditing:Q===$.id,apiKey:L,saving:J,testing:M,error:Q===$.id?B:null,success:Q===$.id?b:null,onStartEdit:()=>{N($.id),X(null),I(null)},onCancelEdit:()=>{N(null),T(""),X(null)},onApiKeyChange:T,onSave:y,onDelete:()=>l($.id),projectsEnabled:W,projects:Z,onRefresh:K},$.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h2",{className:"text-xl font-semibold mb-1",children:"Browser Providers"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:["Configure browser environments for operator mode (computer use). ",w," of ",G.length," configured."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:G.map(($)=>q.jsxDEV(a,{provider:$,isEditing:Q===$.id,apiKey:L,saving:J,testing:M,error:Q===$.id?B:null,success:Q===$.id?b:null,onStartEdit:()=>{N($.id),X(null),I(null)},onCancelEdit:()=>{N(null),T(""),X(null)},onApiKeyChange:T,onSave:y,onDelete:()=>l($.id)},$.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var n=["#f97316","#6366f1","#22c55e","#ef4444","#3b82f6","#a855f7","#14b8a6","#f59e0b"];function Hq(){let{projects:z,createProject:Z,updateProject:W,deleteProject:R}=d(),[U,Q]=H.useState(!1),[N,L]=H.useState(null),{confirm:T,ConfirmDialog:J}=V(),O=async(X)=>{if(!await T("Are you sure you want to delete this project? Agents in this project will become unassigned.",{confirmText:"Delete",title:"Delete Project"}))return;await R(X)},M=()=>{L(null),Q(!0)},_=(X)=>{L(X),Q(!0)},B=()=>{Q(!1),L(null)};return q.jsxDEV(q.Fragment,{children:[J,q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6 flex items-center justify-between gap-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Projects"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"Organize agents into projects for better management."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:M,className:"flex items-center gap-2 bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition flex-shrink-0",children:[q.jsxDEV(D,{className:"w-4 h-4"},void 0,!1,void 0,this),"New Project"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.length===0?q.jsxDEV("div",{className:"text-center py-12 text-[#666]",children:[q.jsxDEV("p",{className:"text-lg mb-2",children:"No projects yet"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm",children:"Create a project to organize your agents."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:z.map((X)=>q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 flex items-center gap-4",children:[q.jsxDEV("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:X.color}},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("h3",{className:"font-medium",children:X.name},void 0,!1,void 0,this),X.description&&q.jsxDEV("p",{className:"text-sm text-[#666] truncate",children:X.description},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#666] mt-1",children:[X.agentCount," agent",X.agentCount!==1?"s":""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("button",{onClick:()=>_(X),className:"text-sm text-[#888] hover:text-[#e0e0e0] px-2 py-1",children:"Edit"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>O(X.id),className:"text-sm text-red-400 hover:text-red-300 px-2 py-1",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},X.id,!0,void 0,this))},void 0,!1,void 0,this),U&&q.jsxDEV(Qq,{project:N,onSave:async(X)=>{if(N){let b=await W(N.id,X);if(b)B();return!!b}else{let b=await Z(X);if(b)B();return!!b}},onClose:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Qq({project:z,onSave:Z,onClose:W}){let[R,U]=H.useState(z?.name||""),[Q,N]=H.useState(z?.description||""),[L,T]=H.useState(z?.color||n[Math.floor(Math.random()*n.length)]),[J,O]=H.useState(!1),[M,_]=H.useState(null),B=async()=>{if(!R.trim()){_("Name is required");return}O(!0),_(null);let X=await Z({name:R,description:Q||void 0,color:L});if(O(!1),!X)_(z?"Failed to update project":"Failed to create project")};return q.jsxDEV(r,{onClose:W,children:[q.jsxDEV("h2",{className:"text-xl font-semibold mb-6",children:z?"Edit Project":"Create New Project"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:R,onChange:(X)=>U(X.target.value),className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]",placeholder:"My Project",autoFocus:!0},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Description (optional)"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:Q,onChange:(X)=>N(X.target.value),className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]",placeholder:"A short description"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Color"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-3 flex-wrap",children:n.map((X)=>q.jsxDEV("button",{type:"button",onClick:()=>T(X),className:`w-10 h-10 rounded-full transition ${L===X?"ring-2 ring-white ring-offset-2 ring-offset-[#111]":"hover:scale-110"}`,style:{backgroundColor:X}},X,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),M&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:M},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex gap-3 mt-6",children:[q.jsxDEV("button",{onClick:W,className:"flex-1 border border-[#333] hover:border-[#f97316] hover:text-[#f97316] px-4 py-2 rounded font-medium transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:B,disabled:J||!R.trim(),className:"flex-1 bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-4 py-2 rounded font-medium transition",children:J?"Saving...":z?"Update":"Create"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Xq(){let{authFetch:z}=p(),[Z,W]=H.useState(null),[R,U]=H.useState(!1),[Q,N]=H.useState(!1),[L,T]=H.useState(null),[J,O]=H.useState(null),[M,_]=H.useState(null),B=async()=>{U(!0),T(null);try{let F=await z("/api/version");if(!F.ok)throw Error("Failed to check for updates");let f=await F.json();W(f)}catch(F){T("Failed to check for updates")}U(!1)},X=async()=>{N(!0),T(null),O(null);try{let f=await(await z("/api/version/update",{method:"POST"})).json();if(!f.success)T(f.error||"Update failed");else{let K=f.restarted?.length||0,y=K>0?` ${K} running agent${K>1?"s":""} restarted.`:"";O(`Agent binary updated to v${f.version}.${y}`),await B()}}catch(F){T("Failed to update agent")}N(!1)};H.useEffect(()=>{B()},[]);let b=(F,f)=>{navigator.clipboard.writeText(F),_(f),setTimeout(()=>_(null),2000)},I=Z?.apteva.updateAvailable||Z?.agent.updateAvailable;return q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Updates"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"Check for new versions of apteva and the agent binary."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),R&&!Z?q.jsxDEV("div",{className:"text-[#666]",children:"Checking version info..."},void 0,!1,void 0,this):L&&!Z?q.jsxDEV("div",{className:"text-red-400",children:L},void 0,!1,void 0,this):Z?.isDocker?q.jsxDEV("div",{className:"space-y-6",children:[q.jsxDEV("div",{className:"bg-blue-500/10 border border-blue-500/30 rounded-lg p-4",children:[q.jsxDEV("div",{className:"flex items-center gap-2 text-blue-400 mb-2",children:[q.jsxDEV("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:q.jsxDEV("path",{d:"M13.983 11.078h2.119a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.119a.185.185 0 00-.185.185v1.888c0 .102.083.185.185.185m-2.954-5.43h2.118a.186.186 0 00.186-.186V3.574a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m0 2.716h2.118a.187.187 0 00.186-.186V6.29a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.887c0 .102.082.186.185.186m-2.93 0h2.12a.186.186 0 00.184-.186V6.29a.185.185 0 00-.185-.185H8.1a.185.185 0 00-.185.185v1.887c0 .102.083.186.185.186m-2.964 0h2.119a.186.186 0 00.185-.186V6.29a.186.186 0 00-.185-.185H5.136a.186.186 0 00-.186.185v1.887c0 .102.084.186.186.186m5.893 2.715h2.118a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m-2.93 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.083.185.185.185m-2.964 0h2.119a.185.185 0 00.185-.185V9.006a.185.185 0 00-.185-.186H5.136a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185m-2.92 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185M23.763 9.89c-.065-.051-.672-.51-1.954-.51-.338.001-.676.03-1.01.087-.248-1.7-1.653-2.53-1.716-2.566l-.344-.199-.226.327c-.284.438-.49.922-.612 1.43-.23.97-.09 1.882.403 2.661-.595.332-1.55.413-1.744.42H.751a.751.751 0 00-.75.748 11.376 11.376 0 00.692 4.062c.545 1.428 1.355 2.48 2.41 3.124 1.18.723 3.1 1.137 5.275 1.137.983.003 1.963-.086 2.93-.266a12.248 12.248 0 003.823-1.389c.98-.567 1.86-1.288 2.61-2.136 1.252-1.418 1.998-2.997 2.553-4.4h.221c1.372 0 2.215-.549 2.68-1.009.309-.293.55-.65.707-1.046l.098-.288Z"},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("span",{className:"font-medium",children:"Docker Environment"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#888]",children:"Updates are automatic when you pull a new image version."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-5",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium text-lg",children:"Current Version"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:"apteva + agent binary"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"text-right",children:q.jsxDEV("div",{className:"text-xl font-mono",children:["v",Z.apteva.installed||"?"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I?q.jsxDEV("div",{className:"bg-[#f97316]/10 border border-[#f97316]/30 rounded-lg p-4",children:[q.jsxDEV("p",{className:"text-sm text-[#888] mb-3",children:["A newer version (v",Z.apteva.latest,") is available. To update:"]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"space-y-2",children:[q.jsxDEV("code",{className:"block bg-[#0a0a0a] px-3 py-2 rounded font-mono text-sm text-[#888]",children:"docker pull apteva/apteva:latest"},void 0,!1,void 0,this),q.jsxDEV("code",{className:"block bg-[#0a0a0a] px-3 py-2 rounded font-mono text-sm text-[#888]",children:"docker compose up -d"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{navigator.clipboard.writeText("docker pull apteva/apteva:latest && docker compose up -d"),_("docker"),setTimeout(()=>_(null),2000)},className:"mt-3 px-3 py-1.5 bg-[#1a1a1a] hover:bg-[#222] rounded text-sm",children:M==="docker"?"Copied!":"Copy commands"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400 text-sm",children:[q.jsxDEV(u,{className:"w-4 h-4"},void 0,!1,void 0,this),"Up to date"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#555]",children:"Your data is stored in a Docker volume and persists across updates."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):Z?q.jsxDEV("div",{className:"space-y-6",children:[J&&q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4 text-green-400",children:J},void 0,!1,void 0,this),L&&q.jsxDEV("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-4 text-red-400",children:L},void 0,!1,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-5",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium text-lg",children:"apteva"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:"The app you're running"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"text-right",children:[q.jsxDEV("div",{className:"text-xl font-mono",children:["v",Z.apteva.installed||"?"]},void 0,!0,void 0,this),Z.apteva.updateAvailable&&q.jsxDEV("div",{className:"text-sm text-[#f97316]",children:["→ v",Z.apteva.latest]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Z.apteva.updateAvailable?q.jsxDEV("div",{className:"bg-[#f97316]/10 border border-[#f97316]/30 rounded-lg p-4",children:[q.jsxDEV("p",{className:"text-sm text-[#888] mb-3",children:"Update by running:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("code",{className:"flex-1 bg-[#0a0a0a] px-3 py-2 rounded font-mono text-sm text-[#888]",children:"npx apteva@latest"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>b("npx apteva@latest","apteva"),className:"px-3 py-2 bg-[#1a1a1a] hover:bg-[#222] rounded text-sm",children:M==="apteva"?"Copied!":"Copy"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400 text-sm",children:[q.jsxDEV(u,{className:"w-4 h-4"},void 0,!1,void 0,this),"Up to date"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-5",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium text-lg",children:"Agent Binary"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:"The Go binary that runs agents"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"text-right",children:[q.jsxDEV("div",{className:"text-xl font-mono",children:["v",Z.agent.installed||"?"]},void 0,!0,void 0,this),Z.agent.updateAvailable&&q.jsxDEV("div",{className:"text-sm text-[#f97316]",children:["→ v",Z.agent.latest]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Z.agent.updateAvailable?q.jsxDEV("div",{className:"bg-[#f97316]/10 border border-[#f97316]/30 rounded-lg p-4",children:[q.jsxDEV("p",{className:"text-sm text-[#888] mb-3",children:"A new version is available. Stop all agents before updating."},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2",children:q.jsxDEV("button",{onClick:X,disabled:Q,className:"px-4 py-2 bg-[#f97316] text-black rounded font-medium text-sm disabled:opacity-50",children:Q?"Updating...":"Update Agent"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400 text-sm",children:[q.jsxDEV(u,{className:"w-4 h-4"},void 0,!1,void 0,this),"Up to date"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!I&&!J&&q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4 flex items-center gap-2 text-green-400",children:[q.jsxDEV(u,{className:"w-5 h-5"},void 0,!1,void 0,this),"Everything is up to date!"]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:B,disabled:R,className:"text-sm text-[#666] hover:text-[#888] disabled:opacity-50",children:R?"Checking...":"Check for updates"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this)}function a({provider:z,isEditing:Z,apiKey:W,saving:R,testing:U,error:Q,success:N,onStartEdit:L,onCancelEdit:T,onApiKeyChange:J,onSave:O,onDelete:M}){let _=z.id==="ollama",B=_||z.id==="browserengine"||z.id==="chrome",X=z.type==="browser",[b,I]=H.default.useState(null);return H.default.useEffect(()=>{if(_&&z.hasKey)fetch("/api/providers/ollama/status").then((F)=>F.json()).then((F)=>I({connected:F.connected,modelCount:F.modelCount})).catch(()=>I({connected:!1}))},[_,z.hasKey]),q.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 ${z.hasKey?"border-green-500/20":"border-[#1a1a1a]"}`,children:[q.jsxDEV("div",{className:"flex items-start justify-between gap-2 mb-2",children:[q.jsxDEV("div",{className:"min-w-0",children:[q.jsxDEV("h3",{className:"font-medium",children:z.name},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666] truncate",children:X?z.description||"Browser automation":z.type==="integration"?z.description||"MCP integration":_?"Run models locally":`${z.models.length} models`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.hasKey?q.jsxDEV("span",{className:`text-xs flex items-center gap-1 px-2 py-1 rounded whitespace-nowrap flex-shrink-0 ${_&&b?b.connected?"text-green-400 bg-green-500/10":"text-yellow-400 bg-yellow-500/10":"text-green-400 bg-green-500/10"}`,children:_&&b?b.connected?q.jsxDEV(q.Fragment,{children:[q.jsxDEV(u,{className:"w-3 h-3"},void 0,!1,void 0,this),b.modelCount," models"]},void 0,!0,void 0,this):q.jsxDEV(q.Fragment,{children:"Not running"},void 0,!1,void 0,this):B?q.jsxDEV(q.Fragment,{children:[q.jsxDEV(u,{className:"w-3 h-3"},void 0,!1,void 0,this),"Configured"]},void 0,!0,void 0,this):q.jsxDEV(q.Fragment,{children:[q.jsxDEV(u,{className:"w-3 h-3"},void 0,!1,void 0,this),z.keyHint]},void 0,!0,void 0,this)},void 0,!1,void 0,this):q.jsxDEV("span",{className:"text-[#666] text-xs bg-[#1a1a1a] px-2 py-1 rounded whitespace-nowrap flex-shrink-0",children:"Not configured"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 pt-3 border-t border-[#1a1a1a]",children:Z?q.jsxDEV("div",{className:"space-y-3",children:[q.jsxDEV("input",{type:B?"text":"password",value:W,onChange:(F)=>J(F.target.value),placeholder:_?"http://localhost:11434":z.id==="browserengine"?"http://localhost:8098":z.id==="chrome"?"http://localhost:9222":z.hasKey?"Enter new API key...":"Enter API key...",autoFocus:!0,className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),B&&q.jsxDEV("p",{className:"text-xs text-[#666]",children:_?"Enter your Ollama server URL. Default is http://localhost:11434":z.id==="browserengine"?"Enter your BrowserEngine service URL (e.g., http://localhost:8098)":"Enter your Chrome DevTools URL (e.g., http://localhost:9222)"},void 0,!1,void 0,this),Q&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:Q},void 0,!1,void 0,this),N&&q.jsxDEV("p",{className:"text-green-400 text-sm",children:N},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:T,className:"flex-1 px-3 py-1.5 border border-[#333] rounded text-sm hover:border-[#666]",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:O,disabled:!W||R,className:"flex-1 px-3 py-1.5 bg-[#f97316] text-black rounded text-sm font-medium disabled:opacity-50",children:U?"Validating...":R?"Saving...":B?"Connect":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):z.hasKey?q.jsxDEV("div",{className:"flex items-center justify-between",children:[z.docsUrl?q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:_?"Download Ollama":"View docs"},void 0,!1,void 0,this):q.jsxDEV("span",{},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-3",children:[q.jsxDEV("button",{onClick:L,className:"text-sm text-[#888] hover:text-[#e0e0e0]",children:B?"Change URL":"Update key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:M,className:"text-red-400 hover:text-red-300 text-sm",children:"Remove"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center justify-between",children:[z.docsUrl?q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:_?"Download Ollama":X?"View docs":"Get API key"},void 0,!1,void 0,this):q.jsxDEV("span",{},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:L,className:"text-sm text-[#f97316] hover:text-[#fb923c]",children:B?"Configure":"+ Add key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Yq({provider:z,isEditing:Z,apiKey:W,saving:R,testing:U,error:Q,success:N,onStartEdit:L,onCancelEdit:T,onApiKeyChange:J,onSave:O,onDelete:M,projectsEnabled:_,projects:B,onRefresh:X}){let{authFetch:b}=p(),[I,F]=H.useState([]),[f,K]=H.useState(""),[y,l]=H.useState(!1),[m,C]=H.useState(null),[G,Y]=H.useState(!1),{confirm:k,ConfirmDialog:w}=V(),$=async()=>{try{let v=await(await b(`/api/keys/${z.id}`)).json();F(v.keys||[])}catch(A){console.error("Failed to fetch keys:",A)}};H.useEffect(()=>{if(_)$()},[z.id,_]),H.useEffect(()=>{if(Z)C(null)},[Z]);let S=async()=>{if(!W)return;Y(!0),C(null);try{let A=await b(`/api/keys/${z.id}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:W,project_id:f||null})}),v=await A.json();if(A.ok)J(""),K(""),T(),$(),X();else C(v.error||"Failed to save key")}catch(A){console.error("Failed to save key:",A),C("Failed to save key")}Y(!1)},h=async(A,v)=>{if(!await k(`Are you sure you want to remove this API key${v?` (${v})`:""}?`,{confirmText:"Remove",title:"Remove API Key"}))return;try{await b(`/api/keys/by-id/${A}`,{method:"DELETE"}),$(),X()}catch(t){console.error("Failed to delete key:",t)}},g=I.find((A)=>!A.project_id),P=I.filter((A)=>A.project_id),c=(A)=>B.find((v)=>v.id===A)?.name||"Unknown",E=(A)=>B.find((v)=>v.id===A)?.color||"#666";if(!_)return q.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 ${z.hasKey?"border-[#f97316]/20":"border-[#1a1a1a]"}`,children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:z.name},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:z.description||"MCP integration"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.hasKey?q.jsxDEV("span",{className:"text-[#f97316] text-xs flex items-center gap-1 bg-[#f97316]/10 px-2 py-1 rounded",children:[q.jsxDEV(u,{className:"w-3 h-3"},void 0,!1,void 0,this),z.keyHint]},void 0,!0,void 0,this):q.jsxDEV("span",{className:"text-[#666] text-xs bg-[#1a1a1a] px-2 py-1 rounded",children:"Not configured"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 pt-3 border-t border-[#1a1a1a]",children:Z?q.jsxDEV("div",{className:"space-y-3",children:[q.jsxDEV("input",{type:"password",value:W,onChange:(A)=>J(A.target.value),placeholder:z.hasKey?"Enter new API key...":"Enter API key...",autoFocus:!0,className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),Q&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:Q},void 0,!1,void 0,this),N&&q.jsxDEV("p",{className:"text-green-400 text-sm",children:N},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:T,className:"flex-1 px-3 py-1.5 border border-[#333] rounded text-sm hover:border-[#666]",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:O,disabled:!W||R,className:"flex-1 px-3 py-1.5 bg-[#f97316] text-black rounded text-sm font-medium disabled:opacity-50",children:U?"Validating...":R?"Saving...":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):z.hasKey?q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:"View docs"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-3",children:[q.jsxDEV("button",{onClick:L,className:"text-sm text-[#888] hover:text-[#e0e0e0]",children:"Update key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:M,className:"text-red-400 hover:text-red-300 text-sm",children:"Remove"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:"Get API key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:L,className:"text-sm text-[#f97316] hover:text-[#fb923c]",children:"+ Add key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return q.jsxDEV(q.Fragment,{children:[w,q.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 ${I.length>0?"border-[#f97316]/20":"border-[#1a1a1a]"}`,children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:z.name},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:z.description||"MCP integration"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I.length>0?q.jsxDEV("span",{className:"text-[#f97316] text-xs flex items-center gap-1 bg-[#f97316]/10 px-2 py-1 rounded",children:[q.jsxDEV(u,{className:"w-3 h-3"},void 0,!1,void 0,this),I.length," key",I.length!==1?"s":""]},void 0,!0,void 0,this):q.jsxDEV("span",{className:"text-[#666] text-xs bg-[#1a1a1a] px-2 py-1 rounded",children:"Not configured"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I.length>0&&q.jsxDEV("div",{className:"mt-3 space-y-2",children:[g&&q.jsxDEV("div",{className:"flex items-center justify-between text-sm bg-[#0a0a0a] rounded px-3 py-2",children:[q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("span",{className:"text-[#888]",children:"Global"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#555]",children:"·"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#666] font-mono text-xs",children:g.key_hint},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>h(g.id,"Global"),className:"text-red-400 hover:text-red-300 text-xs",children:"Remove"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P.slice(0,y?void 0:2).map((A)=>q.jsxDEV("div",{className:"flex items-center justify-between text-sm bg-[#0a0a0a] rounded px-3 py-2",children:[q.jsxDEV("div",{className:"flex items-center gap-2 min-w-0",children:[q.jsxDEV("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:E(A.project_id)}},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#888] truncate",children:A.name||c(A.project_id)},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#555]",children:"·"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#666] font-mono text-xs",children:A.key_hint},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>h(A.id,A.name||c(A.project_id)),className:"text-red-400 hover:text-red-300 text-xs flex-shrink-0 ml-2",children:"Remove"},void 0,!1,void 0,this)]},A.id,!0,void 0,this)),P.length>2&&!y&&q.jsxDEV("button",{onClick:()=>l(!0),className:"text-xs text-[#666] hover:text-[#888] w-full text-center py-1",children:["Show ",P.length-2," more..."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 pt-3 border-t border-[#1a1a1a]",children:Z?q.jsxDEV("div",{className:"space-y-3",children:[q.jsxDEV("input",{type:"password",value:W,onChange:(A)=>J(A.target.value),placeholder:"Enter API key...",autoFocus:!0,className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),q.jsxDEV(x,{value:f,onChange:K,placeholder:"Global (all projects)",options:[{value:"",label:"Global (all projects)"},...B.map((A)=>({value:A.id,label:A.name}))]},void 0,!1,void 0,this),m&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:m},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:()=>{T(),K(""),C(null)},className:"flex-1 px-3 py-1.5 border border-[#333] rounded text-sm hover:border-[#666]",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:S,disabled:!W||G,className:"flex-1 px-3 py-1.5 bg-[#f97316] text-black rounded text-sm font-medium disabled:opacity-50",children:G?"Saving...":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:I.length>0?"View docs":"Get API key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:L,className:"text-sm text-[#f97316] hover:text-[#fb923c]",children:"+ Add key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Zq(){let{authFetch:z}=p(),[Z,W]=H.useState([]),[R,U]=H.useState(!1),[Q,N]=H.useState(""),[L,T]=H.useState("90"),[J,O]=H.useState(!1),[M,_]=H.useState(null),[B,X]=H.useState(null),[b,I]=H.useState(!1),{confirm:F,ConfirmDialog:f}=V(),K=async()=>{try{let k=await(await z("/api/keys/personal")).json();W(k.keys||[])}catch{}};H.useEffect(()=>{K()},[]);let y=async()=>{if(!Q.trim()){_("Name is required");return}O(!0),_(null);try{let Y=await z("/api/keys/personal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Q.trim(),expires_in_days:L?parseInt(L):null})}),k=await Y.json();if(!Y.ok)_(k.error||"Failed to create key");else X(k.key),N(""),T("90"),K()}catch{_("Failed to create key")}O(!1)},l=async(Y,k)=>{if(!await F(`Delete API key "${k}"? This cannot be undone.`,{confirmText:"Delete",title:"Delete API Key"}))return;try{await z(`/api/keys/personal/${Y}`,{method:"DELETE"}),K()}catch{}},m=()=>{if(B)navigator.clipboard.writeText(B),I(!0),setTimeout(()=>I(!1),2000)},C=(Y)=>{if(!Y)return"Never";return new Date(Y).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})},G=(Y)=>{if(!Y)return!1;return new Date(Y)<new Date};return q.jsxDEV(q.Fragment,{children:[f,q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6 flex items-center justify-between gap-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"API Keys"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:["Create personal API keys for programmatic access. Use them with the ",q.jsxDEV("code",{className:"text-[#888] bg-[#1a1a1a] px-1 rounded text-xs",children:"X-API-Key"},void 0,!1,void 0,this)," header."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!R&&!B&&q.jsxDEV("button",{onClick:()=>{U(!0),_(null)},className:"flex items-center gap-2 bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition flex-shrink-0",children:[q.jsxDEV(D,{className:"w-4 h-4"},void 0,!1,void 0,this),"New Key"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),B&&q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4 mb-6",children:[q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400 mb-2",children:[q.jsxDEV(u,{className:"w-5 h-5"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"font-medium",children:"API key created"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#888] mb-3",children:"Copy this key now. You won't be able to see it again."},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("code",{className:"flex-1 bg-[#0a0a0a] px-3 py-2 rounded font-mono text-sm text-[#e0e0e0] break-all select-all",children:B},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:m,className:"px-3 py-2 bg-[#1a1a1a] hover:bg-[#222] rounded text-sm flex-shrink-0",children:b?"Copied!":"Copy"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{X(null),U(!1)},className:"mt-3 text-sm text-[#666] hover:text-[#888]",children:"Done"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),R&&!B&&q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 mb-6",children:[q.jsxDEV("h3",{className:"font-medium mb-4",children:"Create new API key"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-4 max-w-md",children:[q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:Q,onChange:(Y)=>N(Y.target.value),placeholder:"e.g. CI Pipeline, My Script",autoFocus:!0,className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Expiration"},void 0,!1,void 0,this),q.jsxDEV("select",{value:L,onChange:(Y)=>T(Y.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]",children:[q.jsxDEV("option",{value:"30",children:"30 days"},void 0,!1,void 0,this),q.jsxDEV("option",{value:"90",children:"90 days"},void 0,!1,void 0,this),q.jsxDEV("option",{value:"180",children:"180 days"},void 0,!1,void 0,this),q.jsxDEV("option",{value:"365",children:"1 year"},void 0,!1,void 0,this),q.jsxDEV("option",{value:"",children:"No expiration"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:M},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:()=>{U(!1),_(null),N("")},className:"flex-1 px-3 py-2 border border-[#333] rounded text-sm hover:border-[#666]",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:y,disabled:J||!Q.trim(),className:"flex-1 px-3 py-2 bg-[#f97316] text-black rounded text-sm font-medium disabled:opacity-50",children:J?"Creating...":"Create Key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Z.length===0?q.jsxDEV("div",{className:"text-center py-12 text-[#666]",children:[q.jsxDEV("p",{className:"text-lg mb-2",children:"No API keys yet"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm",children:"Create an API key to access apteva programmatically."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:Z.map((Y)=>q.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 flex items-center gap-4 ${!Y.is_active||G(Y.expires_at)?"border-[#1a1a1a] opacity-60":"border-[#1a1a1a]"}`,children:[q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("h3",{className:"font-medium",children:Y.name},void 0,!1,void 0,this),!Y.is_active&&q.jsxDEV("span",{className:"text-xs text-red-400 bg-red-500/10 px-2 py-0.5 rounded",children:"Revoked"},void 0,!1,void 0,this),Y.is_active&&G(Y.expires_at)&&q.jsxDEV("span",{className:"text-xs text-yellow-400 bg-yellow-500/10 px-2 py-0.5 rounded",children:"Expired"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-3 text-sm text-[#666]",children:[q.jsxDEV("code",{className:"font-mono text-xs bg-[#0a0a0a] px-2 py-0.5 rounded",children:[Y.prefix,"..."]},void 0,!0,void 0,this),q.jsxDEV("span",{children:["Created ",C(Y.created_at)]},void 0,!0,void 0,this),Y.expires_at&&q.jsxDEV("span",{children:["Expires ",C(Y.expires_at)]},void 0,!0,void 0,this),Y.last_used_at&&q.jsxDEV("span",{children:["Last used ",C(Y.last_used_at)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Y.is_active&&q.jsxDEV("button",{onClick:()=>l(Y.id,Y.name),className:"text-sm text-red-400 hover:text-red-300 px-2 py-1 flex-shrink-0",children:"Delete"},void 0,!1,void 0,this)]},Y.id,!0,void 0,this))},void 0,!1,void 0,this),Z.length>0&&q.jsxDEV("div",{className:"mt-6 bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[q.jsxDEV("h3",{className:"font-medium mb-2 text-sm",children:"Usage"},void 0,!1,void 0,this),q.jsxDEV("code",{className:"block bg-[#0a0a0a] px-3 py-2 rounded font-mono text-xs text-[#888]",children:'curl -H "X-API-Key: apt_..." http://localhost:4280/api/agents'},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function $q(){let{authFetch:z,user:Z}=p(),[W,R]=H.useState(""),[U,Q]=H.useState(""),[N,L]=H.useState(""),[T,J]=H.useState(!1),[O,M]=H.useState(null),_=async()=>{if(!W||!U||!N){M({type:"error",text:"All fields are required"});return}if(U!==N){M({type:"error",text:"New passwords do not match"});return}if(U.length<8){M({type:"error",text:"Password must be at least 8 characters"});return}J(!0),M(null);try{let B=await z("/api/auth/password",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:W,newPassword:U})}),X=await B.json();if(B.ok)M({type:"success",text:"Password updated successfully"}),R(""),Q(""),L("");else M({type:"error",text:X.error||"Failed to update password"})}catch{M({type:"error",text:"Failed to update password"})}J(!1)};return q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Account Settings"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"Manage your account and security."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z&&q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 mb-6",children:[q.jsxDEV("h3",{className:"font-medium mb-3",children:"Profile"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-2 text-sm",children:[q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Username"},void 0,!1,void 0,this),q.jsxDEV("span",{children:Z.username},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z.email&&q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Email"},void 0,!1,void 0,this),q.jsxDEV("span",{children:Z.email},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Role"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"capitalize",children:Z.role},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[q.jsxDEV("h3",{className:"font-medium mb-4",children:"Change Password"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-4 max-w-md",children:[q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Current Password"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:W,onChange:(B)=>R(B.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"New Password"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:U,onChange:(B)=>Q(B.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Confirm New Password"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:N,onChange:(B)=>L(B.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),O&&q.jsxDEV("div",{className:`p-3 rounded text-sm ${O.type==="success"?"bg-green-500/10 text-green-400 border border-green-500/30":"bg-red-500/10 text-red-400 border border-red-500/30"}`,children:O.text},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:_,disabled:T||!W||!U||!N,className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 disabled:cursor-not-allowed text-black rounded text-sm font-medium transition",children:T?"Updating...":"Update Password"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Gq(){let{authFetch:z}=p(),[Z,W]=H.useState(!1),[R,U]=H.useState(null),[Q,N]=H.useState(null),{confirm:L,ConfirmDialog:T}=V(),J=async()=>{try{let _=await(await z("/api/telemetry/stats")).json();N(_.stats?.total_events||0)}catch{N(null)}};H.useEffect(()=>{J()},[]);let O=async()=>{if(!await L("Are you sure you want to delete all telemetry data? This cannot be undone.",{confirmText:"Clear All",title:"Clear Telemetry Data"}))return;W(!0),U(null);try{let _=await z("/api/telemetry/clear",{method:"POST"}),B=await _.json();if(_.ok)U({type:"success",text:`Cleared ${B.deleted||0} telemetry events.`}),N(0);else U({type:"error",text:B.error||"Failed to clear telemetry"})}catch{U({type:"error",text:"Failed to clear telemetry"})}W(!1)};return q.jsxDEV(q.Fragment,{children:[T,q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Data Management"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"Manage stored data and telemetry."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[q.jsxDEV("h3",{className:"font-medium mb-2",children:"Telemetry Data"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:Q!==null?`${Q.toLocaleString()} events stored`:"Loading..."},void 0,!1,void 0,this),R&&q.jsxDEV("div",{className:`mb-4 p-3 rounded text-sm ${R.type==="success"?"bg-green-500/10 text-green-400 border border-green-500/30":"bg-red-500/10 text-red-400 border border-red-500/30"}`,children:R.text},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:O,disabled:Z||Q===0,className:"px-4 py-2 bg-red-500/20 text-red-400 hover:bg-red-500/30 disabled:opacity-50 disabled:cursor-not-allowed rounded text-sm font-medium transition",children:Z?"Clearing...":"Clear All Telemetry"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Wq(){let{authFetch:z}=p(),[Z,W]=H.useState([]),[R,U]=H.useState([]),[Q,N]=H.useState(!0),[L,T]=H.useState(!1),[J,O]=H.useState({name:"",agent_id:"",botToken:""}),[M,_]=H.useState(!1),[B,X]=H.useState(null),{confirm:b,ConfirmDialog:I}=V(),F=async()=>{try{let Y=await(await z("/api/channels")).json();W(Y.channels||[])}catch{}finally{N(!1)}},f=async()=>{try{let Y=await(await z("/api/agents")).json();U((Y.agents||[]).map((k)=>({id:k.id,name:k.name,status:k.status})))}catch{}};H.useEffect(()=>{F(),f()},[]);let K=async()=>{if(!J.name||!J.agent_id||!J.botToken)return;_(!0),X(null);try{let G=await z("/api/channels",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"telegram",name:J.name,agent_id:J.agent_id,config:{botToken:J.botToken}})});if(!G.ok){let Y=await G.json();X(Y.error||"Failed to create channel")}else O({name:"",agent_id:"",botToken:""}),T(!1),await F()}catch(G){X(G.message)}finally{_(!1)}},y=async(G)=>{let Y=G.status==="running"?"stop":"start";try{let k=await z(`/api/channels/${G.id}/${Y}`,{method:"POST"});if(!k.ok){let w=await k.json();X(w.error||`Failed to ${Y} channel`)}await F()}catch{X(`Failed to ${Y} channel`)}},l=async(G)=>{if(!await b(`Delete channel "${G.name}"?`,{confirmText:"Delete",title:"Delete Channel"}))return;try{await z(`/api/channels/${G.id}`,{method:"DELETE"}),await F()}catch{}},m={running:"bg-green-500/20 text-green-400",stopped:"bg-[#333] text-[#666]",error:"bg-red-500/20 text-red-400"},C=(G)=>{return R.find((Y)=>Y.id===G)?.name||G};return q.jsxDEV(q.Fragment,{children:[I,q.jsxDEV("div",{className:"max-w-2xl",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[q.jsxDEV("div",{children:[q.jsxDEV("h2",{className:"text-xl font-semibold mb-1",children:"Channels"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:"Connect agents to external messaging platforms"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>T(!L),className:"flex items-center gap-2 bg-[#f97316] hover:bg-[#fb923c] text-black px-3 py-1.5 rounded text-sm font-medium transition",children:[q.jsxDEV(D,{},void 0,!1,void 0,this)," Add Channel"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),B&&q.jsxDEV("div",{className:"mb-4 bg-red-500/10 text-red-400 border border-red-500/30 px-3 py-2 rounded text-sm flex items-center justify-between",children:[q.jsxDEV("span",{children:B},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>X(null),className:"text-red-400 hover:text-red-300 ml-2",children:q.jsxDEV(i,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),L&&q.jsxDEV("div",{className:"mb-6 bg-[#111] border border-[#1a1a1a] rounded-lg p-4 space-y-3",children:[q.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-2",children:"New Telegram Channel"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[#666] mb-1",children:"Channel Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:J.name,onChange:(G)=>O((Y)=>({...Y,name:G.target.value})),placeholder:"e.g. My Telegram Bot",className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[#666] mb-1",children:"Agent"},void 0,!1,void 0,this),q.jsxDEV(x,{value:J.agent_id,options:R.map((G)=>({value:G.id,label:G.name})),onChange:(G)=>O((Y)=>({...Y,agent_id:G})),placeholder:"Select an agent..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[#666] mb-1",children:"Bot Token"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:J.botToken,onChange:(G)=>O((Y)=>({...Y,botToken:G.target.value})),placeholder:"From @BotFather on Telegram",className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:["Create a bot via ",q.jsxDEV("a",{href:"https://t.me/BotFather",target:"_blank",className:"text-[#f97316] hover:underline",children:"@BotFather"},void 0,!1,void 0,this)," on Telegram to get a token."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex gap-2 pt-1",children:[q.jsxDEV("button",{onClick:K,disabled:M||!J.name||!J.agent_id||!J.botToken,className:"bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-4 py-1.5 rounded text-sm font-medium transition",children:M?"Creating...":"Create"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>{T(!1),O({name:"",agent_id:"",botToken:""})},className:"border border-[#333] hover:border-[#444] px-4 py-1.5 rounded text-sm transition",children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Q?q.jsxDEV("p",{className:"text-[#666] text-sm",children:"Loading channels..."},void 0,!1,void 0,this):Z.length===0?q.jsxDEV("div",{className:"text-center py-12 text-[#666]",children:[q.jsxDEV("p",{className:"text-lg mb-2",children:"No channels configured"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm",children:"Add a Telegram channel to let users message your agents directly."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:Z.map((G)=>q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:q.jsxDEV("div",{className:"flex items-start justify-between",children:[q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("h3",{className:"font-medium",children:G.name},void 0,!1,void 0,this),q.jsxDEV("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${m[G.status]||m.stopped}`,children:G.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:[G.type==="telegram"?"Telegram":G.type," → ",C(G.agent_id)]},void 0,!0,void 0,this),G.status==="error"&&G.error&&q.jsxDEV("p",{className:"text-xs text-red-400 mt-1",children:G.error},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2 ml-4",children:[q.jsxDEV("button",{onClick:()=>y(G),className:`px-3 py-1 rounded text-xs font-medium transition ${G.status==="running"?"bg-[#f97316]/20 text-[#f97316] hover:bg-[#f97316]/30":"bg-[#3b82f6]/20 text-[#3b82f6] hover:bg-[#3b82f6]/30"}`,children:G.status==="running"?"Stop":"Start"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>l(G),className:"text-[#666] hover:text-red-400 transition text-sm",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},G.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Jq(){let{authFetch:z}=p(),[Z,W]=H.useState([]),[R,U]=H.useState(""),[Q,N]=H.useState(""),[L,T]=H.useState(""),[J,O]=H.useState("unknown"),[M,_]=H.useState(!0),[B,X]=H.useState(!1),[b,I]=H.useState(null),[F,f]=H.useState(!1),[K,y]=H.useState({provider:"",model:"",systemPrompt:""});H.useEffect(()=>{(async()=>{try{let[$,S]=await Promise.all([z("/api/meta-agent/status"),z("/api/providers")]),h=await $.json(),g=await S.json();if(W((g.providers||[]).filter((P)=>P.type==="llm"&&P.hasKey)),h.agent){let P=h.agent;U(P.provider||""),N(P.model||""),T(P.systemPrompt||""),O(P.status||"stopped"),y({provider:P.provider||"",model:P.model||"",systemPrompt:P.systemPrompt||""})}}catch{I({type:"error",text:"Failed to load assistant config"})}finally{_(!1)}})()},[z]);let m=Z.find((w)=>w.id===R)?.models||[],C=(w)=>{U(w);let $=Z.find((h)=>h.id===w),S=$?.models.find((h)=>h.recommended)?.value||$?.models[0]?.value||"";N(S)},G=R!==K.provider||Q!==K.model||L!==K.systemPrompt,Y=async()=>{X(!0),I(null);try{let w=await z("/api/agents/apteva-assistant",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:R,model:Q,systemPrompt:L})});if(w.ok)y({provider:R,model:Q,systemPrompt:L}),I({type:"success",text:"Assistant settings saved"}),setTimeout(()=>I(null),3000);else{let $=await w.json().catch(()=>({}));I({type:"error",text:$.error||"Failed to save"})}}catch{I({type:"error",text:"Failed to save settings"})}finally{X(!1)}},k=async()=>{f(!0),I(null);try{let $=await z(J==="running"?"/api/meta-agent/stop":"/api/meta-agent/start",{method:"POST"});if($.ok)O(J==="running"?"stopped":"running");else{let S=await $.json().catch(()=>({}));I({type:"error",text:S.error||"Failed to toggle assistant"})}}catch{I({type:"error",text:"Failed to toggle assistant"})}finally{f(!1)}};if(M)return q.jsxDEV("div",{className:"text-[#666]",children:"Loading assistant settings..."},void 0,!1,void 0,this);return q.jsxDEV("div",{className:"max-w-2xl",children:[q.jsxDEV("h2",{className:"text-lg font-medium mb-1",children:"Apteva Assistant"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666] mb-6",children:"Configure the built-in AI assistant that manages your agents and platform."},void 0,!1,void 0,this),b&&q.jsxDEV("div",{className:`mb-4 px-3 py-2 rounded text-sm ${b.type==="success"?"bg-green-500/10 text-green-400":"bg-red-500/10 text-red-400"}`,children:b.text},void 0,!1,void 0,this),q.jsxDEV("div",{className:"mb-6 flex items-center gap-3",children:[q.jsxDEV("span",{className:"text-sm text-[#666]",children:"Status:"},void 0,!1,void 0,this),q.jsxDEV("span",{className:`px-2 py-1 rounded text-xs font-medium ${J==="running"?"bg-[#3b82f6]/20 text-[#3b82f6]":"bg-[#333] text-[#666]"}`,children:J},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:k,disabled:F,className:`px-3 py-1.5 rounded text-sm font-medium transition ${J==="running"?"bg-[#f97316]/20 text-[#f97316] hover:bg-[#f97316]/30":"bg-[#3b82f6]/20 text-[#3b82f6] hover:bg-[#3b82f6]/30"} disabled:opacity-50`,children:F?"...":J==="running"?"Stop":"Start"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mb-4",children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Provider"},void 0,!1,void 0,this),q.jsxDEV(x,{value:R,onChange:C,options:Z.map((w)=>({value:w.id,label:w.name})),placeholder:"Select provider..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mb-4",children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Model"},void 0,!1,void 0,this),q.jsxDEV(x,{value:Q,onChange:N,options:m.map((w)=>({value:w.value,label:w.label,recommended:w.recommended})),placeholder:"Select model..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"System Prompt"},void 0,!1,void 0,this),q.jsxDEV("textarea",{value:L,onChange:(w)=>T(w.target.value),rows:12,className:"w-full bg-[#111] border border-[#1a1a1a] rounded px-3 py-2 text-sm font-mono focus:outline-none focus:border-[#f97316] resize-y"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:Y,disabled:!G||B,className:"bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 disabled:cursor-not-allowed text-black px-4 py-2 rounded font-medium transition",children:B?"Saving...":"Save Changes"},void 0,!1,void 0,this),J==="running"&&G&&q.jsxDEV("p",{className:"text-xs text-[#666] mt-2",children:"Changes will be applied to the running assistant"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}
2
+ export{Tq as c};
3
+
4
+ //# debugId=BE8BEC7BB468E33C64756E2164756E21
@@ -0,0 +1,4 @@
1
+ import{H as u,I as c,J as E}from"./App.ncgc9cxy.js";import{S as A,V as a,W as h,Y as V,Z as x,_ as D,ca as T,fa as j}from"./App.mvtqv6qc.js";var X=A(a(),1);var q=A(h(),1);function Qq({agents:B,loading:Z,onNavigate:L}){let{authFetch:G}=T(),{currentProjectId:J}=j(),{events:$,statusChangeCounter:K}=V(),[H,Q]=X.useState(null),[W,U]=X.useState([]),[O,P]=X.useState([]),I=X.useRef(null),{events:R}=x({category:"TASK"}),N=X.useMemo(()=>{if(J===null)return B;if(J==="unassigned")return B.filter((z)=>!z.projectId);return B.filter((z)=>z.projectId===J)},[B,J]),b=X.useMemo(()=>{return[...N].sort((z,Y)=>{if(z.status==="running"&&Y.status!=="running")return-1;if(Y.status==="running"&&z.status!=="running")return 1;return z.name.localeCompare(Y.name)})},[N]),g=X.useMemo(()=>N.filter((z)=>z.status==="running").length,[N]),f=X.useMemo(()=>new Set(N.map((z)=>z.id)),[N]),d=X.useMemo(()=>{let z=new Map;return N.forEach((Y)=>z.set(Y.id,Y.name)),z},[N]),M=X.useCallback(async()=>{let z=J?`&project_id=${encodeURIComponent(J)}`:"",[Y,p]=await Promise.all([G(`/api/tasks?status=all${z}`).catch(()=>null),G(`/api/telemetry/events?type=thread_activity&limit=50${z}`).catch(()=>null)]);if(Y?.ok){let _=(await Y.json()).tasks||[];_.sort((F,w)=>{let S=F.status==="running"?0:F.status==="pending"?1:F.status==="completed"?2:3,v=w.status==="running"?0:w.status==="pending"?1:w.status==="completed"?2:3;if(S!==v)return S-v;if(S<=1){let r=F.next_run||F.execute_at?new Date(F.next_run||F.execute_at).getTime():1/0,n=w.next_run||w.execute_at?new Date(w.next_run||w.execute_at).getTime():1/0;return r-n}let o=F.completed_at||F.executed_at||F.created_at,i=w.completed_at||w.executed_at||w.created_at;return new Date(i).getTime()-new Date(o).getTime()}),U(_)}if(p?.ok){let C=await p.json();P(C.events||[])}},[G,J]);X.useEffect(()=>{M()},[M,K]),X.useEffect(()=>{if(!R.length)return;let z=R[0];if(!z||z.id===I.current)return;let Y=z.type;if(Y==="task_created"||Y==="task_updated"||Y==="task_deleted")I.current=z.id,M()},[R,M]);let y=X.useMemo(()=>{let z=$.filter((_)=>_.type==="thread_activity"),Y=new Set(z.map((_)=>_.id)),p=[...z];for(let _ of O)if(!Y.has(_.id))p.push(_),Y.add(_.id);let C=p.filter((_)=>f.has(_.agent_id));return C.sort((_,F)=>new Date(F.timestamp).getTime()-new Date(_.timestamp).getTime()),C.slice(0,50)},[$,O,f]);if(Z)return q.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[#666]",children:"Loading..."},void 0,!1,void 0,this);return q.jsxDEV("div",{className:"flex-1 flex flex-col overflow-hidden",children:[q.jsxDEV("div",{className:"px-6 pt-6 pb-4 shrink-0",children:q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("h1",{className:"text-xl font-semibold",children:"Activity"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-sm text-[#666]",children:[g," of ",N.length," agents running"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[q.jsxDEV("div",{className:"flex-[2] flex flex-col overflow-hidden border-r border-[#1a1a1a]",children:[q.jsxDEV("div",{className:"px-4 py-2.5 border-b border-[#1a1a1a] shrink-0",children:q.jsxDEV("h3",{className:"text-xs font-semibold text-[#666] uppercase tracking-wider",children:"Agents"},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex-1 overflow-auto px-3 py-2",children:[b.length===0?q.jsxDEV("p",{className:"text-sm text-[#555] px-2 py-4 text-center",children:"No agents found"},void 0,!1,void 0,this):q.jsxDEV("div",{className:"space-y-1",children:b.map((z)=>q.jsxDEV(s,{agent:z,selected:H===z.id,onSelect:()=>Q(H===z.id?null:z.id)},z.id,!1,void 0,this))},void 0,!1,void 0,this),H&&q.jsxDEV(t,{agent:N.find((z)=>z.id===H)||null},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex-[3] flex flex-col min-h-0 overflow-hidden border-r border-[#1a1a1a]",children:[q.jsxDEV("div",{className:"px-4 py-2.5 border-b border-[#1a1a1a] flex items-center justify-between shrink-0",children:[q.jsxDEV("h3",{className:"text-xs font-semibold text-[#666] uppercase tracking-wider",children:"Activity Feed"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-xs text-[#555]",children:y.length},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex-1 overflow-auto",children:y.length===0?q.jsxDEV("div",{className:"p-6 text-center text-[#555] text-sm",children:"No activity yet. Agent activity will appear here in real-time."},void 0,!1,void 0,this):q.jsxDEV("div",{className:"divide-y divide-[#1a1a1a]",children:y.map((z)=>q.jsxDEV("div",{className:"px-4 py-2.5 hover:bg-[#111]/50 transition",children:[q.jsxDEV("p",{className:"text-sm truncate",children:z.data?.activity||"Working..."},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2 text-[10px] text-[#555] mt-0.5",children:[q.jsxDEV("span",{className:"text-[#666]",children:d.get(z.agent_id)||z.agent_id},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#444]",children:"·"},void 0,!1,void 0,this),q.jsxDEV("span",{children:zq(z.timestamp)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},z.id,!0,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex-[3] flex flex-col overflow-hidden",children:[q.jsxDEV("div",{className:"px-4 py-2.5 border-b border-[#1a1a1a] flex items-center justify-between shrink-0",children:[q.jsxDEV("h3",{className:"text-xs font-semibold text-[#666] uppercase tracking-wider",children:"Tasks"},void 0,!1,void 0,this),L&&q.jsxDEV("button",{onClick:()=>L("tasks"),className:"text-xs text-[#3b82f6] hover:text-[#60a5fa]",children:"View All"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex-1 overflow-auto px-3 py-3",children:W.length===0?q.jsxDEV("p",{className:"text-sm text-[#555] px-2 py-4 text-center",children:"No tasks yet"},void 0,!1,void 0,this):q.jsxDEV("div",{className:"space-y-2.5",children:W.map((z)=>q.jsxDEV(e,{task:z},`${z.agentId}-${z.id}`,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function s({agent:B,selected:Z,onSelect:L}){let{isActive:G,label:J}=D(B.id),$=B.status==="running";return q.jsxDEV("button",{onClick:L,className:`w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-left transition ${Z?"bg-[#f97316]/10 border border-[#f97316]/30":"hover:bg-[#1a1a1a] border border-transparent"}`,children:[q.jsxDEV("span",{className:`w-2.5 h-2.5 rounded-full shrink-0 ${$&&G?"bg-green-400 animate-pulse":$?"bg-[#3b82f6]":"bg-[#444]"}`},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("span",{className:`text-sm font-medium truncate ${$?"":"text-[#666]"}`,children:B.name},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[10px] text-[#555] shrink-0",children:B.provider},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G&&J?q.jsxDEV("p",{className:"text-[11px] text-green-400 truncate",children:J},void 0,!1,void 0,this):q.jsxDEV("p",{className:`text-[11px] ${$?"text-[#555]":"text-[#444]"}`,children:$?"idle":"stopped"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function t({agent:B}){let{authFetch:Z}=T(),[L,G]=X.useState(""),[J,$]=X.useState(!1),[K,H]=X.useState(null);if(X.useEffect(()=>{G(""),H(null)},[B?.id]),!B)return null;let Q=B.status==="running",W=async()=>{if(!L.trim()||J)return;if(!Q){H("Agent is not running"),setTimeout(()=>H(null),3000);return}$(!0);try{let U=await Z(`/api/agents/${B.id}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:L,agent_id:B.id})});if(U.ok)H("Sent"),G("");else{let O=await U.json().catch(()=>({}));H(O.error||"Failed")}}catch{H("Failed to send")}finally{$(!1),setTimeout(()=>H(null),3000)}};return q.jsxDEV("div",{className:"mt-2 bg-[#0a0a0a] border border-[#1a1a1a] rounded-lg p-2.5",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-1.5",children:[q.jsxDEV("span",{className:"text-[10px] text-[#666]",children:["Send to ",q.jsxDEV("span",{className:"text-[#888]",children:B.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),K&&q.jsxDEV("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${K==="Sent"?"bg-green-500/10 text-green-400":"bg-red-500/10 text-red-400"}`,children:K},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex gap-1.5",children:[q.jsxDEV("input",{type:"text",value:L,onChange:(U)=>G(U.target.value),onKeyDown:(U)=>U.key==="Enter"&&W(),placeholder:Q?"Command...":"Not running",disabled:J||!Q,autoFocus:!0,className:"flex-1 bg-[#111] border border-[#1a1a1a] rounded px-2 py-1.5 text-xs focus:outline-none focus:border-[#f97316] placeholder-[#444] disabled:opacity-50"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:W,disabled:J||!L.trim()||!Q,className:"px-2.5 py-1.5 bg-[#f97316]/20 text-[#f97316] rounded text-xs font-medium hover:bg-[#f97316]/30 transition disabled:opacity-30",children:J?"...":"Send"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var k={pending:"bg-yellow-500/20 text-yellow-400",running:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",cancelled:"bg-gray-500/20 text-gray-400"},m=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function e({task:B}){return q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-3 hover:border-[#333] transition",children:[q.jsxDEV("div",{className:"flex items-start justify-between mb-1.5",children:[q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("h4",{className:"text-sm font-medium truncate",children:B.title},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#666]",children:B.agentName},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium shrink-0 ml-2 ${k[B.status]||k.pending}`,children:B.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-[#555]",children:[q.jsxDEV("span",{className:"flex items-center gap-1",children:[B.type==="recurring"?q.jsxDEV(u,{className:"w-3 h-3"},void 0,!1,void 0,this):B.execute_at?q.jsxDEV(c,{className:"w-3 h-3"},void 0,!1,void 0,this):q.jsxDEV(E,{className:"w-3 h-3"},void 0,!1,void 0,this),B.type==="recurring"&&B.recurrence?qq(B.recurrence):B.type]},void 0,!0,void 0,this),B.next_run&&q.jsxDEV("span",{className:"text-[#f97316]",children:l(B.next_run)},void 0,!1,void 0,this),!B.next_run&&B.execute_at&&q.jsxDEV("span",{className:"text-[#f97316]",children:l(B.execute_at)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function qq(B){try{let Z=B.trim().split(/\s+/);if(Z.length!==5)return B;let[L,G,J,$,K]=Z;if(L.startsWith("*/")&&G==="*"&&J==="*"&&$==="*"&&K==="*"){let Q=parseInt(L.slice(2));return Q===1?"Every min":`Every ${Q}min`}if(L!=="*"&&!L.includes("/")&&G==="*"&&J==="*"&&$==="*"&&K==="*")return"Hourly";if(G.startsWith("*/")&&J==="*"&&$==="*"&&K==="*"){let Q=parseInt(G.slice(2));return Q===1?"Hourly":`Every ${Q}h`}let H=(Q,W)=>{let U=parseInt(Q),O=parseInt(W);if(isNaN(U))return"";let P=U>=12?"PM":"AM";return`${U===0?12:U>12?U-12:U}:${O.toString().padStart(2,"0")} ${P}`};if(G!=="*"&&!G.includes("/")&&J==="*"&&$==="*"){let Q=H(G,L);if(K==="*")return`Daily ${Q}`;let W=K.split(",").map((U)=>m[parseInt(U.trim())]||U);if(W.length===1)return`${W[0]} ${Q}`;return`${W.join(", ")} ${Q}`}return B}catch{return B}}function l(B){let Z=new Date(B),L=new Date,G=Z.getTime()-L.getTime(),J=G>0,$=Math.abs(G),K=Math.floor($/60000),H=Math.floor($/3600000),Q=Z.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),W=Z.toDateString()===L.toDateString(),U=new Date(L);U.setDate(U.getDate()+1);let O=Z.toDateString()===U.toDateString();if(W){if(K<1)return"now";if(K<60)return J?`in ${K}m`:`${K}m ago`;return J?`in ${H}h (${Q})`:`${H}h ago`}if(O)return`Tomorrow ${Q}`;return`${m[Z.getDay()]} ${Q}`}function zq(B){let Z=Math.floor((Date.now()-new Date(B).getTime())/1000);if(Z<5)return"just now";if(Z<60)return`${Z}s ago`;let L=Math.floor(Z/60);if(L<60)return`${L}m ago`;let G=Math.floor(L/60);if(G<24)return`${G}h ago`;return`${Math.floor(G/24)}d ago`}
2
+ export{Qq as d};
3
+
4
+ //# debugId=A710C5DDE644C40564756E2164756E21