apteva 0.4.44 → 0.4.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ActivityPage.c48n83h2.js → ActivityPage.sw9p594m.js} +1 -1
- package/dist/{ApiDocsPage.yzcxx5ax.js → ApiDocsPage.90e03bz7.js} +1 -1
- package/dist/App.0ws87fpx.js +53 -0
- package/dist/App.3vnrera5.js +4 -0
- package/dist/App.94x6mh7f.js +20 -0
- package/dist/{App.qzbx5wtj.js → App.9sryp183.js} +1 -1
- package/dist/App.d9tny4t0.js +221 -0
- package/dist/{App.r5serxkt.js → App.jhb45d7r.js} +1 -1
- package/dist/App.p7jjw1zf.js +4 -0
- package/dist/App.pfbdzrhh.js +4 -0
- package/dist/App.stgng5bx.js +13 -0
- package/dist/{App.152mbs1r.js → App.tm3k7h4b.js} +1 -1
- package/dist/App.vkg121c6.js +4 -0
- package/dist/App.wghtdzsk.js +1 -0
- package/dist/App.xf7wsckg.js +4 -0
- package/dist/App.xva0tfzh.js +4 -0
- package/dist/App.ysxy7akk.js +61 -0
- package/dist/App.yzkh4gq2.js +4 -0
- package/dist/ConnectionsPage.q5f9fd37.js +3 -0
- package/dist/McpPage.f3ccrezb.js +3 -0
- package/dist/SettingsPage.3sqx6wm4.js +3 -0
- package/dist/SkillsPage.whxnez67.js +3 -0
- package/dist/TasksPage.zp4jfevw.js +3 -0
- package/dist/TelemetryPage.a9fmxq87.js +3 -0
- package/dist/TestsPage.18krj0d1.js +3 -0
- package/dist/ThreadsPage.nnphgy98.js +3 -0
- package/dist/apteva-kit.css +1 -1
- package/dist/index.html +1 -1
- package/dist/styles.css +1 -1
- package/package.json +5 -4
- package/src/db.ts +42 -4
- package/src/providers.ts +14 -9
- package/src/routes/api/agent-utils.ts +25 -3
- package/src/routes/api/telemetry.ts +20 -2
- package/src/server.ts +52 -1
- package/src/web/App.tsx +1 -1
- package/src/web/components/agents/AgentCard.tsx +9 -7
- package/src/web/components/agents/AgentPanel.tsx +205 -44
- package/src/web/components/agents/CreateAgentModal.tsx +5 -5
- package/src/web/components/auth/LoginPage.tsx +2 -2
- package/src/web/components/common/LoadingSpinner.tsx +1 -1
- package/src/web/components/common/Modal.tsx +6 -6
- package/src/web/components/common/Select.tsx +2 -2
- package/src/web/components/connections/ConnectionsPage.tsx +1 -1
- package/src/web/components/connections/IntegrationsTab.tsx +3 -3
- package/src/web/components/connections/OverviewTab.tsx +3 -3
- package/src/web/components/connections/TriggersTab.tsx +8 -8
- package/src/web/components/dashboard/Dashboard.tsx +2 -2
- package/src/web/components/layout/Header.tsx +3 -3
- package/src/web/components/layout/Sidebar.tsx +3 -2
- package/src/web/components/mcp/McpPage.tsx +13 -13
- package/src/web/components/onboarding/OnboardingWizard.tsx +2 -2
- package/src/web/components/settings/SettingsPage.tsx +55 -22
- package/src/web/components/skills/SkillsPage.tsx +7 -7
- package/src/web/components/tasks/TasksPage.tsx +212 -36
- package/src/web/components/telemetry/TelemetryPage.tsx +278 -9
- package/src/web/components/tests/TestsPage.tsx +2 -2
- package/src/web/components/threads/ThreadsPage.tsx +2 -2
- package/src/web/context/ThemeContext.tsx +31 -10
- package/src/web/index.html +1 -6
- package/src/web/styles.css +47 -0
- package/src/web/themes.ts +68 -5
- package/dist/App.09yb8t0b.js +0 -1
- package/dist/App.3a67nx9w.js +0 -4
- package/dist/App.9epx6785.js +0 -4
- package/dist/App.d8955awp.js +0 -4
- package/dist/App.drwb57jq.js +0 -4
- package/dist/App.gssbmajb.js +0 -4
- package/dist/App.qw70pc29.js +0 -53
- package/dist/App.tpmp9020.js +0 -20
- package/dist/App.v2wb4d7d.js +0 -61
- package/dist/App.vxmaaj0m.js +0 -13
- package/dist/App.w4p2tda9.js +0 -4
- package/dist/App.wv2ng55q.js +0 -221
- package/dist/App.yncnrn0f.js +0 -4
- package/dist/ConnectionsPage.k6cspyqq.js +0 -3
- package/dist/McpPage.cdxm48xj.js +0 -3
- package/dist/SettingsPage.evpv7c2y.js +0 -3
- package/dist/SkillsPage.pvzp6c1a.js +0 -3
- package/dist/TasksPage.6jnvbpsy.js +0 -3
- package/dist/TelemetryPage.t7vk24zc.js +0 -3
- package/dist/TestsPage.5x6658aa.js +0 -3
- package/dist/ThreadsPage.3fvhtevh.js +0 -3
package/dist/App.d8955awp.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{O as V}from"./App.9epx6785.js";import{U as D}from"./App.drwb57jq.js";import{$ as Kk,X as P,aa as v,da as i,ja as o,ma as d}from"./App.tpmp9020.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-[var(--color-surface-raised)] text-[var(--color-text-muted)]"}`,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-[var(--color-text-muted)] 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-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] text-[var(--color-text)] 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-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] 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-[var(--color-text-muted)] 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-[var(--color-border-light)] 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-[var(--color-text-muted)] mb-2",children:"No tests yet"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] 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-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] 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-[var(--color-surface)] border border-[var(--color-border)] 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-[var(--color-text-secondary)] 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-[var(--color-text-secondary)] mb-1.5 line-clamp-2",children:k.behavior},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)] space-y-0.5",children:[q.jsxDEV("div",{children:["Agent:"," ",q.jsxDEV("span",{className:"text-[var(--color-text-secondary)]",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-[var(--color-text-secondary)]",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-[var(--color-text-secondary)]",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-[var(--color-text-secondary)]",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-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-raised)] 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-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] text-[var(--color-text)] 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-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-raised)] 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-[var(--color-text-muted)] hover:text-red-400 hover:bg-[var(--color-surface-raised)] 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-[var(--color-text-secondary)]",children:"Run History"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>{I(null),f(null)},className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]",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-[var(--color-text-muted)]",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-[var(--color-bg-secondary)] border border-[var(--color-border)] 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-[var(--color-text-muted)]",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-[var(--color-text-secondary)] font-mono",children:[k.score,"/10"]},void 0,!0,void 0,this),k.selected_agent_name&&q.jsxDEV("span",{className:"text-xs text-[var(--color-text-faint)]",children:["Agent: ",k.selected_agent_name]},void 0,!0,void 0,this),q.jsxDEV("span",{className:"text-xs text-[var(--color-text-faint)]",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-[var(--color-text-faint)]",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-[var(--color-text-muted)] mb-1",children:"Planner:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-[var(--color-text-secondary)] bg-[var(--color-bg)] p-2 rounded",children:[k.selected_agent_name&&q.jsxDEV("span",{className:"text-[var(--color-accent)]",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-[var(--color-text-muted)] mb-1",children:"Generated Message:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-[var(--color-text-secondary)] bg-[var(--color-bg)] 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-[var(--color-text-muted)] mb-1",children:"Judge:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-[var(--color-text-secondary)] bg-[var(--color-bg)] 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-[var(--color-bg)] 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-[var(--color-text-muted)] mb-1",children:"Agent Response (Thread):"},void 0,!1,void 0,this),q.jsxDEV("pre",{className:"text-xs text-[var(--color-text-secondary)] bg-[var(--color-bg)] 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-[var(--color-surface)] border border-[var(--color-border)] 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-[var(--color-text-muted)] 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-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 text-sm focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[var(--color-text-muted)] 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-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 text-sm focus:outline-none focus:border-[var(--color-accent)] resize-none"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] 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-[var(--color-text-muted)] 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-[var(--color-text-faint)] 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-[var(--color-text-secondary)] hover:text-[var(--color-text)] transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:e,disabled:!M||!b,className:"px-4 py-2 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] 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
|
-
export{Yk as M};
|
|
3
|
-
|
|
4
|
-
//# debugId=3B7C511E895831F964756E2164756E21
|
package/dist/App.drwb57jq.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{$ as b,X as s,aa as u}from"./App.tpmp9020.js";var o=s(b(),1),e=s(u(),1);function h({value:r,options:i,onChange:v,placeholder:m="Select...",compact:d}){let[a,l]=o.useState(!1),c=o.useRef(null),n=i.find((t)=>t.value===r);return o.useEffect(()=>{function t(f){if(c.current&&!c.current.contains(f.target))l(!1)}return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]),e.jsxDEV("div",{ref:c,className:"relative",children:[e.jsxDEV("button",{type:"button",onClick:()=>l(!a),className:`w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded ${d?"px-2.5 py-1.5 text-sm":"px-3 py-2"} text-left flex items-center justify-between focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)] hover:border-[var(--color-border-light)] transition`,children:[e.jsxDEV("span",{className:n?"text-[var(--color-text)]":"text-[var(--color-text-muted)]",children:n?e.jsxDEV(e.Fragment,{children:[n.label,n.recommended&&e.jsxDEV("span",{className:"text-[var(--color-accent)] text-xs ml-2",children:"(Recommended)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):m},void 0,!1,void 0,this),e.jsxDEV(p,{isOpen:a},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a&&e.jsxDEV("div",{className:"absolute z-50 w-full min-w-max mt-1 bg-[var(--color-surface)] border border-[var(--color-border-light)] rounded shadow-lg max-h-60 overflow-y-auto scrollbar-hide",children:i.map((t)=>e.jsxDEV("button",{type:"button",onClick:()=>{v(t.value),l(!1)},className:`w-full ${d?"px-2.5 py-1.5 text-sm":"px-3 py-2"} text-left flex items-center justify-between hover:bg-[var(--color-surface-raised)] transition ${t.value===r?"bg-[var(--color-surface-raised)] text-[var(--color-accent)]":"text-[var(--color-text)]"}`,children:[e.jsxDEV("span",{children:[t.label,t.recommended&&e.jsxDEV("span",{className:"text-[var(--color-accent)] text-xs ml-2",children:"(Recommended)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t.value===r&&e.jsxDEV("svg",{className:"w-4 h-4 text-[var(--color-accent)]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},t.value,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function p({isOpen:r}){return e.jsxDEV("svg",{className:`w-4 h-4 text-[var(--color-text-muted)] transition-transform ${r?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}
|
|
2
|
-
export{h as U};
|
|
3
|
-
|
|
4
|
-
//# debugId=4CDD03E09C93D11064756E2164756E21
|
package/dist/App.gssbmajb.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{G as D,H as r,I as k,l as p,q as j}from"./App.qzbx5wtj.js";import{O as d}from"./App.9epx6785.js";import{U as V}from"./App.drwb57jq.js";import{$ as t,X as g,aa as l,da as u,ja as c,ma as i}from"./App.tpmp9020.js";var X=g(t(),1);var z=g(l(),1);function Zz({onSelectAgent:G}){let{authFetch:q}=c(),{currentProjectId:Y}=i(),[_,O]=X.useState([]),[L,K]=X.useState(!0),[Z,J]=X.useState("all"),[U,$]=X.useState("all"),[W,N]=X.useState(null),[w,R]=X.useState(!1),[v,P]=X.useState(!1),f=X.useRef(null),{events:I}=u({category:"TASK"}),A=X.useCallback(async()=>{try{let B=`/api/tasks?status=${Z}`;if(Y!==null)B+=`&project_id=${encodeURIComponent(Y)}`;let Q=await(await q(B)).json();O(Q.tasks||[])}catch(B){console.error("Failed to fetch tasks:",B)}finally{K(!1)}},[q,Z,Y]);X.useEffect(()=>{A()},[A]),X.useEffect(()=>{if(!I.length)return;let B=I[0];if(!B||B.id===f.current)return;let H=B.type;if(H==="task_created"||H==="task_updated"||H==="task_deleted")f.current=B.id,console.log("[TasksPage] Telemetry event:",H),A()},[I,A]);let b=X.useCallback(async(B)=>{N(B),R(!0);try{let H=await q(`/api/tasks/${B.agentId}/${B.id}`);if(console.log("[TasksPage] Fetch task response status:",H.status),H.ok){let Q=await H.json();if(console.log("[TasksPage] Task data:",Q),console.log("[TasksPage] Has trajectory:",!!Q.task?.trajectory,"Length:",Q.task?.trajectory?.length),Q.task)N({...Q.task,agentId:B.agentId,agentName:B.agentName})}else console.error("[TasksPage] Failed to fetch task:",H.status,await H.text())}catch(H){console.error("Failed to fetch task details:",H)}finally{R(!1)}},[q]),F=X.useMemo(()=>{let B=new Map;for(let H of _){let Q=H.agentId||H.agent_id,M=H.agentName||H.agent_name;if(Q&&M&&!B.has(Q))B.set(Q,M)}return Array.from(B.entries()).sort((H,Q)=>H[1].localeCompare(Q[1]))},[_]),T=X.useMemo(()=>{return[...U==="all"?_:_.filter((H)=>(H.agentId||H.agent_id)===U)].sort((H,Q)=>{if(H.status==="running"&&Q.status!=="running")return-1;if(Q.status==="running"&&H.status!=="running")return 1;let M=H.status==="pending",S=Q.status==="pending";if(M&&!S)return-1;if(S&&!M)return 1;if(M&&S||H.status==="running"&&Q.status==="running"){let m=H.next_run||H.execute_at||null,h=Q.next_run||Q.execute_at||null,e=m?new Date(m).getTime():1/0,s=h?new Date(h).getTime():1/0;return e-s}let x=H.completed_at||H.executed_at||H.created_at,a=Q.completed_at||Q.executed_at||Q.created_at;return new Date(a).getTime()-new Date(x).getTime()})},[_,U]),C={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"};return z.jsxDEV("div",{className:"flex-1 flex overflow-hidden",children:[z.jsxDEV("div",{className:`flex-1 p-4 md:p-6 overflow-auto ${W?"hidden md:block md:w-1/2 lg:w-2/3":""}`,children:z.jsxDEV("div",{className:"max-w-4xl",children:[z.jsxDEV("div",{className:"mb-6",children:[z.jsxDEV("div",{className:"mb-4 flex items-start justify-between",children:[z.jsxDEV("div",{children:[z.jsxDEV("h1",{className:"text-xl md:text-2xl font-semibold mb-1",children:"Tasks"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:"View tasks from all running agents"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:()=>P(!0),className:"px-3 py-1.5 rounded text-sm bg-[var(--color-accent)] text-black hover:opacity-90 transition flex items-center gap-1.5 flex-shrink-0",children:[z.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:z.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"},void 0,!1,void 0,this)},void 0,!1,void 0,this),"Create Task"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-3 flex-wrap pb-1",children:[z.jsxDEV("div",{className:"flex gap-2 overflow-x-auto scrollbar-hide",children:[{value:"all",label:"All"},{value:"pending",label:"Pending"},{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}].map((B)=>z.jsxDEV("button",{onClick:()=>J(B.value),className:`px-3 py-1.5 rounded text-sm transition whitespace-nowrap ${Z===B.value?"bg-[var(--color-accent)] text-black":"bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)]"}`,children:B.label},B.value,!1,void 0,this))},void 0,!1,void 0,this),F.length>0&&z.jsxDEV("div",{className:"w-48",children:z.jsxDEV(V,{value:U,onChange:$,placeholder:"All agents",compact:!0,options:[{value:"all",label:"All agents"},...F.map(([B,H])=>({value:B,label:H}))]},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),L?z.jsxDEV("div",{className:"text-center py-12 text-[var(--color-text-muted)]",children:"Loading tasks..."},void 0,!1,void 0,this):T.length===0?z.jsxDEV("div",{className:"text-center py-12",children:[z.jsxDEV(j,{className:"w-12 h-12 mx-auto mb-4 text-[var(--color-border-light)]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:"No tasks found"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[var(--color-text-faint)] mt-1",children:"Tasks will appear here when agents create them"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV("div",{className:"space-y-3",children:T.map((B)=>z.jsxDEV("div",{onClick:()=>b(B),className:`bg-[var(--color-surface)] border rounded-lg p-4 cursor-pointer transition ${W?.id===B.id&&W?.agentId===B.agentId?"border-[var(--color-accent)]":"border-[var(--color-border)] hover:border-[var(--color-border-light)]"}`,children:[z.jsxDEV("div",{className:"flex items-start justify-between mb-2",children:[z.jsxDEV("div",{className:"flex-1",children:[z.jsxDEV("h3",{className:"font-medium",children:B.title},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:B.agentName},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("span",{className:`px-2 py-1 rounded text-xs font-medium ${C[B.status]||C.pending}`,children:B.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),B.description&&z.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)] mb-2 line-clamp-2",children:B.description},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-[var(--color-text-faint)]",children:[z.jsxDEV("span",{className:"flex items-center gap-1",children:[B.type==="recurring"?z.jsxDEV(D,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this):B.execute_at?z.jsxDEV(r,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this):z.jsxDEV(k,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this),B.type==="recurring"&&B.recurrence?n(B.recurrence):B.type]},void 0,!0,void 0,this),z.jsxDEV("span",{children:["Priority: ",B.priority]},void 0,!0,void 0,this),B.next_run&&z.jsxDEV("span",{className:"text-[var(--color-accent)]",children:y(B.next_run)},void 0,!1,void 0,this),!B.next_run&&B.execute_at&&z.jsxDEV("span",{className:"text-[var(--color-accent)]",children:y(B.execute_at)},void 0,!1,void 0,this),z.jsxDEV("span",{children:["Created: ",new Date(B.created_at).toLocaleDateString()]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},`${B.agentId}-${B.id}`,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),W&&z.jsxDEV(zz,{task:W,statusColors:C,onClose:()=>N(null),onSelectAgent:G,loading:w,authFetch:q,onRefresh:()=>{A(),N(null)}},void 0,!1,void 0,this),v&&z.jsxDEV(Gz,{authFetch:q,currentProjectId:Y,onClose:()=>P(!1),onCreated:()=>{A(),P(!1)}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function zz({task:G,statusColors:q,onClose:Y,onSelectAgent:_,loading:O,authFetch:L,onRefresh:K}){let[Z,J]=X.useState(!1),[U,$]=X.useState(!1),{confirm:W,ConfirmDialog:N}=d(),w=async()=>{if(!L||Z)return;J(!0);try{await L(`/api/tasks/${G.agentId}/${G.id}/execute`,{method:"POST"}),K?.()}catch(v){console.error("Failed to execute task:",v)}finally{J(!1)}},R=async()=>{if(!L||U)return;if(!await W(`Are you sure you want to delete "${G.title}"?`,{title:"Delete Task",confirmText:"Delete",confirmVariant:"danger"}))return;$(!0);try{await L(`/api/tasks/${G.agentId}/${G.id}`,{method:"DELETE"}),K?.()}catch(P){console.error("Failed to delete task:",P)}finally{$(!1)}};return z.jsxDEV("div",{className:"w-full md:w-1/2 lg:w-1/3 border-l border-[var(--color-border)] bg-[var(--color-bg)] flex flex-col overflow-hidden",children:[N,z.jsxDEV("div",{className:"flex items-center justify-between p-4 border-b border-[var(--color-border)]",children:[z.jsxDEV("h2",{className:"font-medium truncate pr-2",children:"Task Details"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2",children:[L&&(G.status==="pending"||G.status==="completed")&&z.jsxDEV("button",{onClick:w,disabled:Z,title:"Execute now",className:"text-[var(--color-accent)] hover:opacity-80 transition disabled:opacity-50",children:z.jsxDEV("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[z.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"},void 0,!1,void 0,this),z.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),L&&z.jsxDEV("button",{onClick:R,disabled:U,title:"Delete task",className:"text-red-400 hover:text-red-300 transition disabled:opacity-50",children:z.jsxDEV("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:z.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:Y,className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] transition",children:z.jsxDEV(p,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-start justify-between gap-2 mb-2",children:[z.jsxDEV("h3",{className:"text-lg font-medium",children:G.title},void 0,!1,void 0,this),z.jsxDEV("span",{className:`px-2 py-1 rounded text-xs font-medium flex-shrink-0 ${q[G.status]}`,children:G.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:()=>_?.(G.agentId),className:"text-sm text-[var(--color-accent)] hover:underline",children:G.agentName},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.description&&z.jsxDEV("div",{children:[z.jsxDEV("h4",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-1",children:"Description"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)] whitespace-pre-wrap",children:G.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[z.jsxDEV("div",{children:[z.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Type"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"capitalize",children:G.type},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Priority"},void 0,!1,void 0,this),z.jsxDEV("p",{children:G.priority},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Source"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"capitalize",children:G.source},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.recurrence&&z.jsxDEV("div",{children:[z.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Recurrence"},void 0,!1,void 0,this),z.jsxDEV("p",{children:n(G.recurrence)},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-0.5 font-mono",children:G.recurrence},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"space-y-2 text-sm",children:[z.jsxDEV("div",{className:"flex justify-between",children:[z.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Created"},void 0,!1,void 0,this),z.jsxDEV("span",{children:new Date(G.created_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.execute_at&&z.jsxDEV("div",{className:"flex justify-between",children:[z.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Scheduled"},void 0,!1,void 0,this),z.jsxDEV("span",{className:"text-[var(--color-accent)]",children:y(G.execute_at)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.executed_at&&z.jsxDEV("div",{className:"flex justify-between",children:[z.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Started"},void 0,!1,void 0,this),z.jsxDEV("span",{children:new Date(G.executed_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.completed_at&&z.jsxDEV("div",{className:"flex justify-between",children:[z.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Completed"},void 0,!1,void 0,this),z.jsxDEV("span",{children:new Date(G.completed_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.next_run&&z.jsxDEV("div",{className:"flex justify-between",children:[z.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Next Run"},void 0,!1,void 0,this),z.jsxDEV("span",{className:"text-[var(--color-accent)]",children:y(G.next_run)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G.status==="failed"&&G.error&&z.jsxDEV("div",{className:"min-w-0",children:[z.jsxDEV("h4",{className:"text-xs text-red-400 uppercase tracking-wider mb-1",children:"Error"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"bg-red-500/10 border border-red-500/20 rounded p-3 overflow-x-auto",children:z.jsxDEV("pre",{className:"text-sm text-red-400 whitespace-pre-wrap break-words",children:G.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.status==="completed"&&G.result&&z.jsxDEV("div",{className:"min-w-0",children:[z.jsxDEV("h4",{className:"text-xs text-green-400 uppercase tracking-wider mb-1",children:"Result"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/20 rounded p-3 overflow-x-auto",children:z.jsxDEV("pre",{className:"text-sm text-green-400 whitespace-pre-wrap break-words",children:typeof G.result==="string"?G.result:JSON.stringify(G.result,null,2)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),O&&!G.trajectory&&z.jsxDEV("div",{children:[z.jsxDEV("h4",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-2",children:"Trajectory"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"text-sm text-[var(--color-text-faint)]",children:"Loading trajectory..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.trajectory&&G.trajectory.length>0&&z.jsxDEV("div",{children:[z.jsxDEV("h4",{className:"text-xs text-[var(--color-text-muted)] uppercase tracking-wider mb-2",children:["Trajectory (",G.trajectory.length," steps)"]},void 0,!0,void 0,this),z.jsxDEV(Bz,{trajectory:G.trajectory},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 Bz({trajectory:G}){let[q,Y]=X.useState(new Set),_=(K)=>{Y((Z)=>{let J=new Set(Z);if(J.has(K))J.delete(K);else J.add(K);return J})},O={user:{bg:"bg-blue-500/10",text:"text-blue-400",icon:"\uD83D\uDC64",label:"User"},assistant:{bg:"bg-purple-500/10",text:"text-purple-400",icon:"\uD83E\uDD16",label:"Assistant"}},L=(K)=>{let Z=K.content;if(typeof Z==="string"){let J=Z.length>200,U=q.has(K.id);return z.jsxDEV("div",{children:[z.jsxDEV("p",{className:`text-sm text-[var(--color-text)] whitespace-pre-wrap break-words ${!U&&J?"line-clamp-4":""}`,children:Z},void 0,!1,void 0,this),J&&z.jsxDEV("button",{onClick:()=>_(K.id),className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] mt-1",children:U?"Show less":"Show more..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}return z.jsxDEV("div",{className:"space-y-2",children:Z.map((J,U)=>{if(J.type==="tool_use"){let $=JSON.stringify(J.input,null,2),W=$.length>150,N=`${K.id}-${U}`,w=q.has(N);return z.jsxDEV("div",{className:"bg-orange-500/10 border border-orange-500/20 rounded p-2",children:[z.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[z.jsxDEV("span",{className:"text-orange-400",children:"\uD83D\uDD27"},void 0,!1,void 0,this),z.jsxDEV("span",{className:"text-xs font-medium text-orange-400",children:"Tool Call"},void 0,!1,void 0,this),z.jsxDEV("span",{className:"text-xs text-[var(--color-text-secondary)]",children:J.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("pre",{className:`text-xs text-[var(--color-text-secondary)] overflow-x-auto ${!w&&W?"line-clamp-3":""}`,children:$},void 0,!1,void 0,this),W&&z.jsxDEV("button",{onClick:()=>_(N),className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] mt-1",children:w?"Show less":"Show more..."},void 0,!1,void 0,this)]},U,!0,void 0,this)}if(J.type==="tool_result"){let $=J.is_error,W=`${K.id}-${U}`,N=q.has(W),w=J.content.length>150;return z.jsxDEV("div",{className:`${$?"bg-red-500/10 border-red-500/20":"bg-teal-500/10 border-teal-500/20"} border rounded p-2`,children:[z.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[z.jsxDEV("span",{children:$?"❌":"\uD83D\uDCCB"},void 0,!1,void 0,this),z.jsxDEV("span",{className:`text-xs font-medium ${$?"text-red-400":"text-teal-400"}`,children:"Tool Result"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("pre",{className:`text-xs text-[var(--color-text-secondary)] overflow-x-auto whitespace-pre-wrap break-words ${!N&&w?"line-clamp-3":""}`,children:J.content},void 0,!1,void 0,this),w&&z.jsxDEV("button",{onClick:()=>_(W),className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] mt-1",children:N?"Show less":"Show more..."},void 0,!1,void 0,this)]},U,!0,void 0,this)}return null})},void 0,!1,void 0,this)};return z.jsxDEV("div",{className:"space-y-2",children:G.map((K)=>{let Z=O[K.role]||O.assistant;return z.jsxDEV("div",{className:`${Z.bg} border border-[var(--color-border)] rounded overflow-hidden p-3`,children:[z.jsxDEV("div",{className:"flex items-center gap-2 mb-2",children:[z.jsxDEV("span",{children:Z.icon},void 0,!1,void 0,this),z.jsxDEV("span",{className:`text-xs font-medium ${Z.text}`,children:Z.label},void 0,!1,void 0,this),K.model&&z.jsxDEV("span",{className:"text-xs text-[var(--color-text-faint)]",children:["· ",K.model]},void 0,!0,void 0,this),z.jsxDEV("span",{className:"text-xs text-[var(--color-text-faint)]",children:["· ",new Date(K.created_at).toLocaleTimeString()]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),L(K)]},K.id,!0,void 0,this)})},void 0,!1,void 0,this)}function Gz({authFetch:G,currentProjectId:q,onClose:Y,onCreated:_}){let[O,L]=X.useState([]),[K,Z]=X.useState(""),[J,U]=X.useState(""),[$,W]=X.useState(""),[N,w]=X.useState("once"),[R,v]=X.useState(5),[P,f]=X.useState(""),[I,A]=X.useState(""),[b,F]=X.useState(!1),[T,C]=X.useState("");return X.useEffect(()=>{G("/api/agents").then((B)=>B.json()).then((B)=>{let H=(B.agents||[]).filter((Q)=>Q.status==="running"&&Q.features?.tasks);if(L(H.map((Q)=>({id:Q.id,name:Q.name}))),H.length===1)Z(H[0].id)}).catch(()=>{})},[G]),z.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:Y,children:z.jsxDEV("div",{className:"bg-[var(--color-surface)] border border-[var(--color-border)] rounded-lg w-full max-w-md",onClick:(B)=>B.stopPropagation(),children:[z.jsxDEV("div",{className:"flex items-center justify-between p-4 border-b border-[var(--color-border)]",children:[z.jsxDEV("h2",{className:"font-medium",children:"Create Task"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:Y,className:"text-[var(--color-text-muted)] hover:text-[var(--color-text)] transition",children:z.jsxDEV(p,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("form",{onSubmit:async(B)=>{if(B.preventDefault(),!K||!J.trim())return;F(!0),C("");let H={title:J.trim(),description:$.trim()||void 0,type:N,priority:R};if(N==="once"&&P)H.execute_at=new Date(P).toISOString();if(N==="recurring"&&I.trim())H.recurrence=I.trim();try{let Q=await G(`/api/tasks/${K}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H)});if(!Q.ok){let M=await Q.json().catch(()=>({}));C(M.error||`HTTP ${Q.status}`);return}_()}catch(Q){C(String(Q))}finally{F(!1)}},className:"p-4 space-y-4",children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Agent"},void 0,!1,void 0,this),O.length===0?z.jsxDEV("p",{className:"text-sm text-[var(--color-text-faint)]",children:"No running agents with tasks enabled"},void 0,!1,void 0,this):z.jsxDEV("select",{value:K,onChange:(B)=>Z(B.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-3 py-2 text-sm",required:!0,children:[z.jsxDEV("option",{value:"",children:"Select agent..."},void 0,!1,void 0,this),O.map((B)=>z.jsxDEV("option",{value:B.id,children:B.name},B.id,!1,void 0,this))]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Title"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:J,onChange:(B)=>U(B.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-3 py-2 text-sm",placeholder:"e.g. Check email for new orders",required:!0},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Description"},void 0,!1,void 0,this),z.jsxDEV("textarea",{value:$,onChange:(B)=>W(B.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-3 py-2 text-sm resize-none",rows:2,placeholder:"Optional instructions for the agent..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"grid grid-cols-2 gap-3",children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Type"},void 0,!1,void 0,this),z.jsxDEV("select",{value:N,onChange:(B)=>w(B.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-3 py-2 text-sm",children:[z.jsxDEV("option",{value:"once",children:"One-time"},void 0,!1,void 0,this),z.jsxDEV("option",{value:"recurring",children:"Recurring"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Priority"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"number",min:1,max:10,value:R,onChange:(B)=>v(Number(B.target.value)),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-3 py-2 text-sm"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),N==="once"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Schedule (optional)"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"datetime-local",value:P,onChange:(B)=>f(B.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-3 py-2 text-sm"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-1",children:"Leave empty to execute immediately"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),N==="recurring"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Cron Schedule"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:I,onChange:(B)=>A(B.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border)] rounded px-3 py-2 text-sm font-mono",placeholder:"*/30 * * * *",required:!0},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-1",children:"e.g. */30 * * * * = every 30 min, 0 9 * * 1-5 = weekdays at 9am"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T&&z.jsxDEV("p",{className:"text-sm text-red-400",children:T},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex justify-end gap-2 pt-2",children:[z.jsxDEV("button",{type:"button",onClick:Y,className:"px-4 py-2 rounded text-sm bg-[var(--color-surface-raised)] hover:bg-[var(--color-border)] transition",children:"Cancel"},void 0,!1,void 0,this),z.jsxDEV("button",{type:"submit",disabled:b||!K||!J.trim()||O.length===0,className:"px-4 py-2 rounded text-sm bg-[var(--color-accent)] text-black hover:opacity-90 transition disabled:opacity-50",children:b?"Creating...":"Create Task"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function n(G){try{let q=G.trim().split(/\s+/);if(q.length!==5)return G;let[Y,_,O,L,K]=q;if(Y.startsWith("*/")&&_==="*"&&O==="*"&&L==="*"&&K==="*"){let J=parseInt(Y.slice(2));if(J===1)return"Every minute";return`Every ${J} minutes`}if(Y!=="*"&&!Y.includes("/")&&_==="*"&&O==="*"&&L==="*"&&K==="*")return"Every hour";if(_.startsWith("*/")&&O==="*"&&L==="*"&&K==="*"){let J=parseInt(_.slice(2));if(J===1)return"Every hour";return`Every ${J} hours`}let Z=(J,U)=>{let $=parseInt(J),W=parseInt(U);if(isNaN($))return"";let N=$>=12?"PM":"AM";return`${$===0?12:$>12?$-12:$}:${W.toString().padStart(2,"0")} ${N}`};if(_!=="*"&&!_.includes("/")&&O==="*"&&L==="*"){let J=Z(_,Y);if(K==="*")return`Daily at ${J}`;let U=K.split(",").map(($)=>{let W=parseInt($.trim());return o[W]||$});if(U.length===7)return`Daily at ${J}`;if(U.length===5&&!U.includes("Sat")&&!U.includes("Sun"))return`Weekdays at ${J}`;if(U.length===1)return`Weekly on ${U[0]} at ${J}`;return`${U.join(" & ")} at ${J}`}return G}catch{return G}}function y(G){let q=new Date(G),Y=new Date,_=q.getTime()-Y.getTime(),O=Math.abs(_),L=_>0,K=Math.floor(O/60000),Z=Math.floor(O/3600000),J=Math.floor(O/86400000),U=q.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),$=q.toDateString()===Y.toDateString(),W=new Date(Y);W.setDate(W.getDate()+1);let N=q.toDateString()===W.toDateString(),w=new Date(Y);w.setDate(w.getDate()-1);let R=q.toDateString()===w.toDateString();if($){if(K<1)return L?"now":"just now";if(K<60)return L?`in ${K} min (${U})`:`${K} min ago`;return L?`in ${Z}h (${U})`:`${Z}h ago`}if(N)return`Tomorrow at ${U}`;if(R)return`Yesterday at ${U}`;if(J<7)return`${o[q.getDay()]} at ${U}`;return q.toLocaleDateString([],{month:"short",day:"numeric"})+` at ${U}`}
|
|
2
|
-
export{Zz as d,zz as e,Bz as f,n as g,y as h};
|
|
3
|
-
|
|
4
|
-
//# debugId=6613E014B5F09F8264756E2164756E21
|