@openork/cli 0.1.1 → 0.2.1
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/commands/doctor.d.ts +12 -0
- package/commands/doctor.d.ts.map +1 -0
- package/commands/doctor.js +110 -0
- package/commands/doctor.js.map +1 -0
- package/{dist/commands → commands}/gateway/start.d.ts.map +1 -1
- package/{dist/commands → commands}/gateway/start.js +14 -0
- package/commands/gateway/start.js.map +1 -0
- package/{dist/commands → commands}/setup.d.ts.map +1 -1
- package/{dist/commands → commands}/setup.js +19 -0
- package/commands/setup.js.map +1 -0
- package/externals.json +13 -0
- package/lib/doctor.d.ts +28 -0
- package/lib/doctor.d.ts.map +1 -0
- package/lib/doctor.js +227 -0
- package/lib/doctor.js.map +1 -0
- package/{dist/openapi.yml → openapi.yml} +770 -0
- package/package.json +14 -32
- package/prisma/migrations/20260401135027_add_auth_rbac_multitenancy/migration.sql +211 -0
- package/{dist/prisma → prisma}/schema.prisma +101 -0
- package/server.js +81901 -0
- package/server.js.map +1 -0
- package/{dist/web/assets/activity-feed-D_eonDKG.js → web/assets/activity-feed-CNgi7Qb_.js} +1 -1
- package/web/assets/agent-edit-CgbnHiT5.js +98 -0
- package/web/assets/agent-sessions-Bpay1_ZH.js +1 -0
- package/web/assets/agent-use-BaBxQ2fx.js +1 -0
- package/web/assets/agents-Dwbd6TQx.js +1 -0
- package/web/assets/api-DNWoqIPN.js +1 -0
- package/web/assets/arrow-down-upU5tcpi.js +1 -0
- package/web/assets/arrow-left-BiNeYcK0.js +1 -0
- package/web/assets/auth-client-ys1jC854.js +1 -0
- package/web/assets/chat-BP5H9CWl.js +4 -0
- package/{dist/web/assets/chat-input-BepRPV_L.js → web/assets/chat-input-CKAtAtgG.js} +2 -2
- package/{dist/web/assets/chat-message-CbcDeDcb.js → web/assets/chat-message-CW-HnO3f.js} +3 -3
- package/web/assets/chat-new-BQp9Bn7Q.js +1 -0
- package/web/assets/chat-sessions-D3bS5vba.js +1 -0
- package/web/assets/chats-DJolHH4e.js +1 -0
- package/{dist/web/assets/circle-alert-W8QX9LOG.js → web/assets/circle-alert-D040vPU_.js} +1 -1
- package/web/assets/circle-check-CW3adL8A.js +1 -0
- package/{dist/web/assets/circle-x-D_8Tcgt1.js → web/assets/circle-x-34c-1fVL.js} +1 -1
- package/web/assets/code-BFUT4gGT.js +1 -0
- package/{dist/web/assets/code-editor-x9L6nkh4.js → web/assets/code-editor-I6vK5q_W.js} +1 -1
- package/web/assets/commands-DBI4Bb2N.js +8 -0
- package/{dist/web/assets/copy-C87mjn_Y.js → web/assets/copy-DI5qjA1p.js} +1 -1
- package/web/assets/credentials-D8VN8A5M.js +1 -0
- package/{dist/web/assets/crown-BJEsQkh4.js → web/assets/crown-DWB5bSnq.js} +1 -1
- package/web/assets/dashboard-Cc6KWs62.js +1 -0
- package/{dist/web/assets/database-BohjTljV.js → web/assets/database-5jczNGML.js} +1 -1
- package/web/assets/debug-DewdHeoW.js +1 -0
- package/{dist/web/assets/download-B2UOiYAS.js → web/assets/download-CwO6xusv.js} +1 -1
- package/{dist/web/assets/eye-DN-Km5vf.js → web/assets/eye-BQGasWwb.js} +1 -1
- package/{dist/web/assets/file-plus-B8qWemgt.js → web/assets/file-plus-kHgvf9P8.js} +1 -1
- package/web/assets/file-tree-CTe61XCg.js +1 -0
- package/{dist/web/assets/folder-plus-DsmP6Mur.js → web/assets/folder-plus-mZAz-QpJ.js} +1 -1
- package/{dist/web/assets/globe-fwFSeXZn.js → web/assets/globe-C0WHVFW_.js} +1 -1
- package/{dist/web/assets/grip-vertical-Djo-yR-o.js → web/assets/grip-vertical-CdhrWSnV.js} +1 -1
- package/{dist/web/assets/history-CyBBboEp.js → web/assets/history-w7qYglj5.js} +1 -1
- package/web/assets/index-9X_UIor3.css +2 -0
- package/web/assets/index-DWNLSHpo.js +4 -0
- package/web/assets/key-DJEQ_jUi.js +1 -0
- package/{dist/web/assets/layers-ephyCrDm.js → web/assets/layers-KZu6CpGE.js} +1 -1
- package/{dist/web/assets/layout-grid-DCVGg8ZA.js → web/assets/layout-grid-U17jhSjz.js} +1 -1
- package/web/assets/login-DoSA7KtI.js +1 -0
- package/web/assets/mcp-setup-Cyj1YAiY.js +17 -0
- package/web/assets/memory-DWZU2Tfl.js +1 -0
- package/web/assets/new-chat-BRS3DM8Z.js +1 -0
- package/web/assets/play-BzkxV_O-.js +1 -0
- package/{dist/web/assets/refresh-cw-RFYUf5GB.js → web/assets/refresh-cw-D3_GZ86i.js} +1 -1
- package/web/assets/register-BS5OkCgS.js +1 -0
- package/web/assets/rotate-ccw-CkJIdGxi.js +1 -0
- package/{dist/web/assets/save-Dewm93H6.js → web/assets/save-BXEZF80P.js} +1 -1
- package/web/assets/search-BmZSwFnA.js +1 -0
- package/{dist/web/assets/send-FWvygYFQ.js → web/assets/send-CNiXC6KO.js} +1 -1
- package/web/assets/server-C5bKQLDi.js +1 -0
- package/web/assets/settings-CBAhSOZM.js +1 -0
- package/web/assets/shield-CMMTdOiM.js +1 -0
- package/{dist/web/assets/shield-check-Dt7sXtBF.js → web/assets/shield-check-BmphmMlD.js} +1 -1
- package/{dist/web/assets/shuffle-DjvBJ7XV.js → web/assets/shuffle-Dv_-PFl5.js} +1 -1
- package/web/assets/src-CaF63bXY.js +24 -0
- package/web/assets/sse-url-qohTy4Sw.js +1 -0
- package/web/assets/team-edit-BW1bePKn.js +1 -0
- package/web/assets/team-sessions-GspGc7zN.js +1 -0
- package/web/assets/team-use-BVC7nt9K.js +3 -0
- package/web/assets/terminal-CjSFIwMK.js +1 -0
- package/{dist/web/assets/timer-C9X20mTO.js → web/assets/timer-3siC9tpd.js} +1 -1
- package/{dist/web/assets/useMutation-BlOHt3MR.js → web/assets/useMutation-DA8-TvTt.js} +1 -1
- package/{dist/web/assets/utils-DHTPP40O.js → web/assets/utils-D1nRmcA6.js} +1 -1
- package/web/assets/workflow-edit-DkmsARCv.js +4 -0
- package/web/assets/workflow-runs-DcJPL7Bo.js +1 -0
- package/web/assets/workflows-Dnx0dwJn.js +1 -0
- package/{dist/web/assets/wrench-DZBtSPP8.js → web/assets/wrench-u8B_fDwT.js} +1 -1
- package/{dist/web/assets/zap-CbT5plGA.js → web/assets/zap-hOn7wkXe.js} +1 -1
- package/{dist/web → web}/index.html +9 -7
- package/README.md +0 -33
- package/dist/commands/gateway/start.js.map +0 -1
- package/dist/commands/setup.js.map +0 -1
- package/dist/server.js +0 -38234
- package/dist/server.js.map +0 -1
- package/dist/web/assets/agent-edit-CblZItU5.js +0 -98
- package/dist/web/assets/agent-sessions-COpCcffa.js +0 -1
- package/dist/web/assets/agent-use-F4pOt3KJ.js +0 -1
- package/dist/web/assets/agents-Av7w2wHE.js +0 -1
- package/dist/web/assets/arrow-down-XHN5PD1k.js +0 -1
- package/dist/web/assets/arrow-left-wtNmm6Le.js +0 -1
- package/dist/web/assets/chat-CQvfLy7Y.js +0 -4
- package/dist/web/assets/chat-new-BOtDuYij.js +0 -1
- package/dist/web/assets/chat-sessions-CaCaK_PC.js +0 -1
- package/dist/web/assets/chats-64IReeGV.js +0 -1
- package/dist/web/assets/circle-check-DLl9fl65.js +0 -1
- package/dist/web/assets/code-Brz4KHlI.js +0 -1
- package/dist/web/assets/commands-DT9K8bae.js +0 -8
- package/dist/web/assets/credentials-DC-HOVxW.js +0 -1
- package/dist/web/assets/dashboard-OfnNUjFX.js +0 -1
- package/dist/web/assets/debug-Et9rgBM8.js +0 -1
- package/dist/web/assets/file-tree-DkLQ1z0I.js +0 -1
- package/dist/web/assets/index-YgjFlLLv.css +0 -2
- package/dist/web/assets/index-dc8HGqTp.js +0 -2
- package/dist/web/assets/mcp-setup-BfMdYdsI.js +0 -17
- package/dist/web/assets/memory-DAQ474-p.js +0 -1
- package/dist/web/assets/new-chat-DtMw6FMg.js +0 -1
- package/dist/web/assets/play-DXJMtO-K.js +0 -1
- package/dist/web/assets/search-Ww0msJQz.js +0 -1
- package/dist/web/assets/settings-Auyn4Z5T.js +0 -1
- package/dist/web/assets/src-DUhGoAQb.js +0 -24
- package/dist/web/assets/team-edit-DO-RX3lC.js +0 -1
- package/dist/web/assets/team-sessions-DSw8MTtZ.js +0 -1
- package/dist/web/assets/team-use-BfNvsFcO.js +0 -3
- package/dist/web/assets/terminal-CIapYonS.js +0 -1
- package/dist/web/assets/workflow-edit-D0FNyl64.js +0 -4
- package/dist/web/assets/workflow-runs-CPVvaVzN.js +0 -1
- package/dist/web/assets/workflows-C9jurJiE.js +0 -1
- /package/{dist/commands → commands}/gateway/start.d.ts +0 -0
- /package/{dist/commands → commands}/gateway/stop.d.ts +0 -0
- /package/{dist/commands → commands}/gateway/stop.d.ts.map +0 -0
- /package/{dist/commands → commands}/gateway/stop.js +0 -0
- /package/{dist/commands → commands}/gateway/stop.js.map +0 -0
- /package/{dist/commands → commands}/setup.d.ts +0 -0
- /package/{dist/commands → commands}/setup.spec.d.ts +0 -0
- /package/{dist/commands → commands}/setup.spec.d.ts.map +0 -0
- /package/{dist/commands → commands}/setup.spec.js +0 -0
- /package/{dist/commands → commands}/setup.spec.js.map +0 -0
- /package/{dist/commands → commands}/uninstall.d.ts +0 -0
- /package/{dist/commands → commands}/uninstall.d.ts.map +0 -0
- /package/{dist/commands → commands}/uninstall.js +0 -0
- /package/{dist/commands → commands}/uninstall.js.map +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.d.ts.map → index.d.ts.map} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/index.js.map → index.js.map} +0 -0
- /package/{dist/lib → lib}/gateway.d.ts +0 -0
- /package/{dist/lib → lib}/gateway.d.ts.map +0 -0
- /package/{dist/lib → lib}/gateway.js +0 -0
- /package/{dist/lib → lib}/gateway.js.map +0 -0
- /package/{dist/lib → lib}/shell-profile.d.ts +0 -0
- /package/{dist/lib → lib}/shell-profile.d.ts.map +0 -0
- /package/{dist/lib → lib}/shell-profile.js +0 -0
- /package/{dist/lib → lib}/shell-profile.js.map +0 -0
- /package/{dist/migrations → migrations}/0001-add-memory-enabled.js +0 -0
- /package/{dist/migrations → migrations}/lib/helpers.js +0 -0
- /package/{dist/migrations → migrations}/lib/template.js +0 -0
- /package/{dist/prisma → prisma}/migrations/20260318152538_add_trigger_type_and_source_workflow/migration.sql +0 -0
- /package/{dist/prisma → prisma}/migrations/20260318154232_drop_skill_and_emit_from_action/migration.sql +0 -0
- /package/{dist/prisma → prisma}/migrations/20260318160029_action_types_cli_bash_node_http/migration.sql +0 -0
- /package/{dist/prisma → prisma}/migrations/20260401085053_schema_sync/migration.sql +0 -0
- /package/{dist/prisma → prisma}/migrations/migration_lock.toml +0 -0
- /package/{dist/web/assets/api-docs-BQzn4-6U.js → web/assets/api-docs-DgRFxVfh.js} +0 -0
- /package/{dist/web/assets/bi-gM8sIAZV.js → web/assets/bi-Da3wz7XD.js} +0 -0
- /package/{dist/web/assets/cron-COUPKvGu.js → web/assets/cron-3VyztcE9.js} +0 -0
- /package/{dist/web → web}/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
- /package/{dist/web → web}/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
- /package/{dist/web → web}/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
- /package/{dist/web → web}/assets/rolldown-runtime-Dw2cE7zH.js +0 -0
- /package/{dist/web → web}/assets/useQuery-DvovkaPT.js +0 -0
- /package/{dist/web/assets/vendor-editor-BORFA-rZ.js → web/assets/vendor-editor-Cx3Ogh9u.js} +0 -0
- /package/{dist/web → web}/assets/vendor-react-BJ8SIkmN.js +0 -0
- /package/{dist/web → web}/assets/vendor-ui-CHpVij2M.css +0 -0
- /package/{dist/web/assets/vendor-ui-Dpw9mBc-.js → web/assets/vendor-ui-DnL9d3od.js} +0 -0
- /package/{dist/web → web}/docs.html +0 -0
- /package/{dist/web → web}/favicon.svg +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,l as n,t as r,u as i}from"./vendor-react-BJ8SIkmN.js";import{r as a,t as o}from"./useQuery-DvovkaPT.js";import{t as s}from"./useMutation-BlOHt3MR.js";import{K as c,U as l,V as u,_ as d,f,g as p,h as m,j as h,m as g,q as _,v,w as y,y as b}from"./src-DUhGoAQb.js";import{C as ee,S as x,_ as S,b as te,g as C,h as ne,m as w,p as re,v as ie,w as ae,x as T,y as oe}from"./vendor-ui-Dpw9mBc-.js";import{t as se}from"./arrow-left-wtNmm6Le.js";import{n as E,r as D,t as O}from"./shuffle-DjvBJ7XV.js";import{t as k}from"./crown-BJEsQkh4.js";import{t as A}from"./grip-vertical-Djo-yR-o.js";import{t as ce}from"./layout-grid-DCVGg8ZA.js";import{t as le}from"./save-Dewm93H6.js";import"./utils-DHTPP40O.js";import{D as ue,I as de,k as fe,m as pe,n as j,r as M,t as N,w as P}from"./index-dc8HGqTp.js";var F=e(t(),1),I=r(),me={sequential:{icon:D,label:`Sequential`,description:`Agents run one after another`},parallel:{icon:E,label:`Parallel`,description:`All agents run simultaneously`},router:{icon:O,label:`Router`,description:`A router agent decides who handles the task`},debate:{icon:de,label:`Debate`,description:`Agents discuss and reach consensus`}},L=(0,F.memo)(function({data:e,selected:t}){let n=e.agent;return(0,I.jsxs)(`div`,{className:c(`rounded-lg border-2 min-w-[220px] max-w-[280px] transition-all duration-150`,e.isRouter?`border-amber-500/50 bg-amber-500/5`:`border-violet-500/50 bg-violet-500/5`,t&&`ring-2 ring-primary ring-offset-1 ring-offset-background`),children:[(0,I.jsx)(S,{type:`target`,position:x.Top,id:`top-in`,className:`!bg-transparent !border-orange-400`,style:{left:`35%`,width:12,height:6,borderRadius:`6px 6px 0 0`,borderWidth:2,borderBottomWidth:0,transform:`translate(-50%, 0)`,top:-6}}),(0,I.jsx)(S,{type:`source`,position:x.Top,id:`top-out`,className:`!bg-sky-400 !border-0`,style:{left:`65%`,width:12,height:6,borderRadius:`6px 6px 0 0`,transform:`translate(-50%, 0)`,top:-6}}),(0,I.jsx)(S,{type:`target`,position:x.Left,id:`left-in`,className:`!bg-transparent !border-orange-400`,style:{top:`35%`,width:6,height:12,borderRadius:`6px 0 0 6px`,borderWidth:2,borderRightWidth:0,transform:`translate(0, -50%)`,left:-6}}),(0,I.jsx)(S,{type:`source`,position:x.Left,id:`left-out`,className:`!bg-sky-400 !border-0`,style:{top:`65%`,width:6,height:12,borderRadius:`6px 0 0 6px`,transform:`translate(0, -50%)`,left:-6}}),(0,I.jsx)(S,{type:`source`,position:x.Right,id:`right-out`,className:`!bg-sky-400 !border-0`,style:{top:`35%`,width:6,height:12,borderRadius:`0 6px 6px 0`,transform:`translate(0, -50%)`,right:-6,left:`auto`}}),(0,I.jsx)(S,{type:`target`,position:x.Right,id:`right-in`,className:`!bg-transparent !border-orange-400`,style:{top:`65%`,width:6,height:12,borderRadius:`0 6px 6px 0`,borderWidth:2,borderLeftWidth:0,transform:`translate(0, -50%)`,right:-6,left:`auto`}}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-3 border-b border-border/50`,children:[(0,I.jsx)(A,{className:`h-3.5 w-3.5 text-muted-foreground/50 shrink-0 cursor-grab`}),(0,I.jsx)(`span`,{className:`text-2xl`,children:n?.avatar??`?`}),(0,I.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,I.jsx)(`div`,{className:`text-sm font-medium truncate`,children:n?.name??`Unknown Agent`}),(0,I.jsxs)(`div`,{className:`text-[10px] text-muted-foreground flex items-center gap-1`,children:[n?.runtime===`cli`&&n.cli&&(0,F.createElement)(j(n.cli),{className:`h-2.5 w-2.5`}),n?.runtime===`cli`?M(n.cli??void 0):`API`]})]}),e.isRouter&&(0,I.jsx)(k,{className:`h-4 w-4 text-amber-500 shrink-0`})]}),(0,I.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,I.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Role: `}),(0,I.jsx)(`span`,{className:c(`text-[11px] font-medium`,e.role?`text-primary/80`:`text-muted-foreground/50 italic`),children:e.role||`N/A`})]}),(0,I.jsx)(S,{type:`source`,position:x.Bottom,id:`bottom-out`,className:`!bg-sky-400 !border-0`,style:{left:`35%`,width:12,height:6,borderRadius:`0 0 6px 6px`,transform:`translate(-50%, 0)`,bottom:-6,top:`auto`}}),(0,I.jsx)(S,{type:`target`,position:x.Bottom,id:`bottom-in`,className:`!bg-transparent !border-orange-400`,style:{left:`65%`,width:12,height:6,borderRadius:`0 0 6px 6px`,borderWidth:2,borderTopWidth:0,transform:`translate(-50%, 0)`,bottom:-6,top:`auto`}})]})});function R({id:e,sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:o,style:s,markerEnd:c,data:l}){let u=l?.hovered??!1,[d,f,p]=ae({sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:o});return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(w,{path:d,markerEnd:c,style:{...s,stroke:u?`#f87171`:s?.stroke,strokeWidth:u?2.5:s?.strokeWidth??2}}),u&&(0,I.jsx)(C,{children:(0,I.jsx)(`button`,{className:`nodrag nopan absolute flex items-center justify-center w-5 h-5 rounded-full bg-muted border border-border text-muted-foreground shadow-sm hover:bg-red-400/20 hover:text-red-400 hover:border-red-400/50 transition-colors cursor-pointer`,style:{transform:`translate(-50%, -50%) translate(${f}px, ${p}px)`,pointerEvents:`all`},onClick:()=>l?.onDelete?.(e),children:(0,I.jsx)(h,{className:`h-3 w-3`})})})]})}function he({agents:e}){let{t}=P(),n=(e,t)=>{e.dataTransfer.setData(`application/team-agent-id`,t),e.dataTransfer.effectAllowed=`move`};return(0,I.jsxs)(`div`,{className:`w-56 border-r border-border bg-card flex flex-col h-full`,children:[(0,I.jsxs)(`div`,{className:`p-3 border-b border-border`,children:[(0,I.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Agents`}),(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:`Drag agents onto the canvas`})]}),(0,I.jsxs)(`div`,{className:`flex-1 overflow-auto p-2 space-y-1`,children:[e.length===0&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground italic text-center py-8`,children:t(`teamEdit.noAgentsYet`)}),e.map(e=>(0,I.jsxs)(`div`,{draggable:!0,onDragStart:t=>n(t,e.id),className:`flex items-center gap-2 p-2 rounded-md border border-border bg-background hover:bg-accent/50 cursor-grab active:cursor-grabbing transition-colors`,children:[(0,I.jsx)(`span`,{className:`text-lg`,children:e.avatar}),(0,I.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium truncate`,children:e.name}),(0,I.jsxs)(`div`,{className:`text-[10px] text-muted-foreground flex items-center gap-1`,children:[e?.runtime===`cli`&&e.cli&&(0,F.createElement)(j(e.cli),{className:`h-2.5 w-2.5`}),e.runtime===`cli`?M(e.cli??void 0):`API`]})]})]},e.id))]})]})}function ge({node:e,agents:t,onUpdate:n,onDelete:r,onClose:i}){let{t:a}=P(),o=e.data,s=t.find(e=>e.id===o.agentId);return(0,I.jsxs)(`div`,{className:`w-72 border-l border-border bg-card flex flex-col h-full`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between p-3 border-b border-border`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-lg`,children:s?.avatar??`?`}),(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:s?.name??`Unknown`})]}),(0,I.jsx)(u,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:i,children:(0,I.jsx)(h,{className:`h-4 w-4`})})]}),(0,I.jsxs)(`div`,{className:`flex-1 overflow-auto p-3 space-y-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`text-xs text-muted-foreground mb-1 block`,children:`Agent`}),(0,I.jsxs)(m,{value:o.agentId,onValueChange:r=>{if(r){let i=t.find(e=>e.id===r);n(e.id,{agentId:r,agent:i})}},children:[(0,I.jsx)(v,{children:(0,I.jsx)(b,{})}),(0,I.jsx)(p,{children:t.map(e=>(0,I.jsxs)(d,{value:e.id,children:[e.avatar,` `,e.name]},e.id))})]})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`text-xs text-muted-foreground mb-1 block`,children:a(`teamEdit.role`)}),(0,I.jsx)(y,{value:o.role,onChange:t=>n(e.id,{role:t.target.value}),placeholder:a(`teamEdit.rolePlaceholder`)})]}),s&&(0,I.jsxs)(`div`,{className:`space-y-2 pt-2`,children:[(0,I.jsx)(g,{}),(0,I.jsx)(`label`,{className:`text-xs text-muted-foreground block`,children:a(`teamEdit.agentDetails`)}),s.description&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s.description}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[s.soul&&(0,I.jsx)(l,{variant:`secondary`,className:`text-[10px]`,children:`SOUL`}),s.identity&&(0,I.jsx)(l,{variant:`secondary`,className:`text-[10px]`,children:`Identity`}),s.rules&&(0,I.jsx)(l,{variant:`secondary`,className:`text-[10px]`,children:`Rules`}),s.heartbeat&&(0,I.jsx)(l,{variant:`secondary`,className:`text-[10px]`,children:`Heartbeat`}),s.knowledge&&(0,I.jsx)(l,{variant:`secondary`,className:`text-[10px]`,children:`Knowledge`})]})]})]}),(0,I.jsx)(`div`,{className:`p-3 border-t border-border`,children:(0,I.jsxs)(u,{variant:`destructive`,size:`sm`,className:`w-full`,onClick:()=>r(e.id),children:[(0,I.jsx)(fe,{className:`h-3.5 w-3.5 mr-1.5`}),`Remove from Team`]})})]})}var z=280,B=300;function _e(e){return Math.round(e/z)*z}function V(e){if(e.length===0)return e;let t=[...new Set(e.map(e=>Math.round(e.position.y/z)))].sort((e,t)=>e-t);if(t.every((e,n)=>e===t[0]+n))return e;let n=new Map;return t.forEach((e,t)=>n.set(e,t)),e.map(e=>{let t=Math.round(e.position.y/z),r=(n.get(t)??t)*z;return r===e.position.y?e:{...e,position:{...e.position,y:r}}})}function ve(e){if(e.length===0)return e;let t=new Map;for(let n of e){let e=Math.round(n.position.y/z);t.has(e)||t.set(e,[]),t.get(e).push(n)}let n=new Map;for(let[e,r]of t){r.sort((e,t)=>e.position.x-t.position.x);let t=-((r.length-1)*B)/2;for(let i=0;i<r.length;i++)n.set(r[i].id,{x:t+i*B,y:e*z})}return e.map(e=>({...e,position:n.get(e.id)??e.position}))}var H=0;function ye(){return`team_node_${++H}_${Date.now()}`}function U(e,t,n,r,i){return{id:e,source:t,sourceHandle:n,target:r,targetHandle:i,type:`team-edge`,markerEnd:{type:T.ArrowClosed,width:16,height:16},style:{strokeWidth:2,stroke:`#6b7280`},animated:!0}}function W(e,t){let n=[];if(t===`sequential`)for(let t=0;t<e.length-1;t++)n.push(U(`e-${e[t].id}-${e[t+1].id}`,e[t].id,`bottom-out`,e[t+1].id,`top-in`));else if(t===`router`){let t=e.find(e=>e.data.isRouter);if(t)for(let r of e)r.id!==t.id&&n.push(U(`e-${t.id}-${r.id}`,t.id,`bottom-out`,r.id,`top-in`))}return n}function be(e,t){if(!e||e.agents.length===0)return{nodes:[],edges:[]};let n=new Map(t.map(e=>[e.id,e]));if(e.canvas&&e.canvas.nodes.length>0)return{nodes:e.canvas.nodes.map(e=>({id:e.id,type:`team-agent`,position:{x:e.x,y:e.y},data:{agentId:e.agentId,role:e.role,agent:n.get(e.agentId),isRouter:e.isRouter??!1}})),edges:e.canvas.edges.map(e=>U(e.id,e.source,e.sourceHandle,e.target,e.targetHandle))};let r=e.agents.map(t=>({id:ye(),type:`team-agent`,position:{x:0,y:0},data:{agentId:t.agentId,role:t.role,agent:n.get(t.agentId),isRouter:e.strategy===`router`&&e.routerConfig?.routerAgentId===t.agentId}})),i=W(r,e.strategy);return{nodes:ve(r),edges:i}}function G(e,t){let n=new Map;for(let t of e)n.set(t.id,[]);for(let e of t){let t=n.get(e.target);t&&t.push(e.source)}return n}function K(e,t,n,r){let i=[];for(let a of t)if(a.source===e&&!r.has(a.target)){let e=n.find(e=>e.id===a.target);e&&i.push(e)}return i}function q(e,t){let n=G(e,t),r=e.filter(e=>(n.get(e.id)??[]).length===0),i=new Set,a=[],o=[...r];for(;o.length>0;){let n=o.shift();i.has(n.id)||(i.add(n.id),a.push(n),o.push(...K(n.id,t,e,i)))}for(let t of e)i.has(t.id)||a.push(t);return a}function xe(e,t){let n=q(e,t).map(e=>({agentId:e.data.agentId,role:e.data.role})),r={nodes:e.map(e=>({id:e.id,agentId:e.data.agentId,role:e.data.role,isRouter:e.data.isRouter||void 0,x:e.position.x,y:e.position.y})),edges:t.map(e=>({id:e.id,source:e.source,sourceHandle:e.sourceHandle??`bottom-out`,target:e.target,targetHandle:e.targetHandle??`top-in`}))};return{agents:n,routerAgentId:e.find(e=>e.data.isRouter)?.data.agentId??null,canvas:r}}function Se({viewport:e,tierRange:t}){let{y:n,zoom:r}=e,i=z*r,{minTier:a,maxTier:o,isDragging:s,dragTier:c}=t,l=s?a-1:a,u=s?o+1:o,d=l>u?0:l,f=l>u?0:u,p=[`0, 90%, 60%`,`25, 95%, 55%`,`50, 95%, 50%`,`139, 72%, 50%`,`217, 80%, 55%`,`280, 70%, 55%`];return(0,I.jsx)(`div`,{style:{position:`absolute`,inset:0,pointerEvents:`none`,overflow:`hidden`,zIndex:5},children:Array.from({length:f-d+1},(e,t)=>{let l=d+t,u=l-d,f=(l*z-z/2)*r+n,m=l<a||l>o,h=s&&c===l,g=p[u%p.length],_=f+i,v;v=h?.6:m?.12:.3;let y;return y=h?.5:m?.15:.35,(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{style:{position:`absolute`,left:0,right:0,top:_,height:0,borderTop:`1px dashed hsl(${g})`,opacity:v,transition:`background 150ms ease, height 150ms ease`}}),(0,I.jsxs)(`div`,{style:{position:`absolute`,left:10,top:f+6,fontSize:11,fontWeight:600,color:`hsl(${g})`,opacity:y,fontFamily:`var(--font-sans, system-ui)`,fontStyle:m?`italic`:void 0,userSelect:`none`,transition:`color 150ms ease`},children:[`Tier `,u]})]},l)})})}var Ce={"team-agent":L},we={"team-edge":R};function J(){let{t:e}=P(),{id:t}=i(),r=n(),d=a(),p=!t,m=(0,F.useRef)(null),[h,v]=(0,F.useState)(null),[b,x,S]=te([]),[C,w,ae]=oe([]),[E,D]=(0,F.useState)(null),[O,k]=(0,F.useState)(null),A=(0,F.useRef)(null),[de,fe]=(0,F.useState)(!1),[j,M]=(0,F.useState)({x:0,y:0,zoom:.6}),[L,R]=(0,F.useState)(!1),[B,H]=(0,F.useState)(null),[U,W]=(0,F.useState)(``),[G,K]=(0,F.useState)(``),[q,J]=(0,F.useState)(`sequential`),[Y,Te]=(0,F.useState)(``),[X,Ee]=(0,F.useState)(!0),Z=o({queryKey:[`agents`],queryFn:()=>_.agents.list({page:1,pageSize:100})}),De=o({queryKey:[`teams`,t],queryFn:()=>_.teams.get(t),enabled:!!t}),Q=(0,F.useMemo)(()=>Z.data?.data??[],[Z.data?.data]),$=De.data;if(!de&&(p||$)&&(fe(!0),$)){W($.name),K($.description),J($.strategy),Te($.tags.join(`, `)),Ee($.memoryEnabled??!0);let{nodes:e,edges:t}=be($,Q);x(e),w(t)}let Oe=(0,F.useMemo)(()=>E?b.find(e=>e.id===E):null,[b,E]),ke=s({mutationFn:e=>_.teams.create(e),onSuccess:t=>{d.invalidateQueries({queryKey:[`teams`]}),N.success(e(`teamEdit.teamCreated`)),r(`/agents/teams/${t.id}`,{replace:!0})},onError:e=>N.error(e.message)}),Ae=s({mutationFn:e=>_.teams.update(t,e),onSuccess:()=>{d.invalidateQueries({queryKey:[`teams`]}),N.success(e(`teamEdit.teamSaved`))},onError:e=>N.error(e.message)}),je=(0,F.useCallback)(()=>{let e=Y.split(`,`).map(e=>e.trim()).filter(Boolean),{agents:t,routerAgentId:n,canvas:r}=xe(b,C),i={name:U,description:G,strategy:q,agents:t,routerConfig:q===`router`&&n?{routerAgentId:n,routingPrompt:``}:null,canvas:r,memoryEnabled:X,tags:e};p?ke.mutate(i):Ae.mutate(i)},[U,G,q,Y,X,b,C,p,ke,Ae]),Me=(0,F.useCallback)(e=>w(t=>t.filter(t=>t.id!==e)),[w]),Ne=(0,F.useMemo)(()=>C.map(e=>({...e,type:`team-edge`,data:{...e.data,onDelete:Me,hovered:e.id===O}})),[C,Me,O]),Pe=(0,F.useCallback)(e=>{w(t=>ee({...e,type:`team-edge`,markerEnd:{type:T.ArrowClosed,width:16,height:16},style:{strokeWidth:2,stroke:`#6b7280`},animated:!0},t))},[w]),Fe=(0,F.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),Ie=(0,F.useCallback)(e=>{e.preventDefault();let t=e.dataTransfer.getData(`application/team-agent-id`);if(!t||!h||!m.current)return;let n=Q.find(e=>e.id===t);if(!n)return;let r=h.screenToFlowPosition({x:e.clientX,y:e.clientY}),i={x:r.x,y:_e(r.y)},a={id:ye(),type:`team-agent`,position:i,data:{agentId:t,role:``,agent:n,isRouter:!1}};x(e=>V([...e,a])),D(a.id)},[h,Q,x]),Le=(0,F.useMemo)(()=>{if(b.length===0)return{minTier:0,maxTier:0,isDragging:L,dragTier:B};let e=1/0,t=-1/0;for(let n of b){let r=Math.round(n.position.y/z);r<e&&(e=r),r>t&&(t=r)}return{minTier:e,maxTier:t,isDragging:L,dragTier:B}},[b,L,B]),Re=(0,F.useCallback)((e,t)=>{R(!0),H(Math.round(t.position.y/z))},[]),ze=(0,F.useCallback)((e,t)=>{R(!1),H(null),x(e=>V(e.map(e=>e.id===t.id?{...e,position:{...e.position,y:_e(t.position.y)}}:e)))},[x]),Be=(0,F.useCallback)((e,t)=>{D(t.id)},[]),Ve=(0,F.useCallback)(()=>{D(null)},[]),He=(0,F.useCallback)((e,t)=>{x(n=>n.map(n=>n.id===e?{...n,data:{...n.data,...t}}:n))},[x]),Ue=(0,F.useCallback)(e=>{x(t=>V(t.filter(t=>t.id!==e))),w(t=>t.filter(t=>t.source!==e&&t.target!==e)),D(null)},[x,w]),We=(0,F.useCallback)(()=>{x(e=>ve(e)),setTimeout(()=>h?.fitView({padding:.5,maxZoom:.7}),50)},[x,h]),Ge=ke.isPending||Ae.isPending;return(0,F.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`s`&&(e.preventDefault(),U.trim()&&je())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[je,U]),!p&&(De.isLoading||Z.isLoading)?(0,I.jsx)(pe,{}):(0,I.jsxs)(`div`,{className:`h-[calc(100vh-3.5rem)] flex flex-col`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 border-b border-border bg-card shrink-0`,children:[(0,I.jsx)(u,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>r(`/agents?tab=teams`),children:(0,I.jsx)(se,{className:`h-4 w-4`})}),(0,I.jsx)(`div`,{className:`h-8 w-8 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,I.jsx)(ue,{className:`h-4 w-4 text-primary`})}),(0,I.jsx)(y,{value:U,onChange:e=>W(e.target.value),placeholder:e(`teamEdit.namePlaceholder`),className:`h-8 text-sm font-medium max-w-xs border-none bg-transparent focus-visible:ring-1`}),(0,I.jsx)(y,{value:G,onChange:e=>K(e.target.value),placeholder:e(`teamEdit.descriptionPlaceholder`),className:`h-8 text-xs text-muted-foreground max-w-xs border-none bg-transparent focus-visible:ring-1`}),(0,I.jsx)(g,{orientation:`vertical`,className:`h-6`}),(0,I.jsx)(`div`,{className:`flex items-center gap-1`,children:Object.entries(me).map(([e,t])=>{let n=t.icon;return(0,I.jsxs)(u,{variant:q===e?`secondary`:`ghost`,size:`sm`,className:c(`h-7 text-xs gap-1`,q===e&&`font-medium`),onClick:()=>J(e),title:t.description,children:[(0,I.jsx)(n,{className:`h-3 w-3`}),t.label]},e)})}),(0,I.jsx)(g,{orientation:`vertical`,className:`h-6`}),(0,I.jsx)(y,{value:Y,onChange:e=>Te(e.target.value),placeholder:e(`teamEdit.tagsPlaceholder`),className:`h-8 text-xs max-w-32 border-none bg-transparent focus-visible:ring-1`}),(0,I.jsx)(g,{orientation:`vertical`,className:`h-6`}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:e(`teamEdit.memoryEnabled`)}),(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`teamEdit.memoryEnabledHelp`)})]}),(0,I.jsx)(f,{checked:X,onCheckedChange:Ee})]}),(0,I.jsx)(`div`,{className:`flex-1`}),(0,I.jsxs)(l,{variant:`outline`,className:`text-xs`,children:[b.length,` agent`,b.length===1?``:`s`]}),(0,I.jsxs)(u,{size:`sm`,onClick:je,disabled:!U.trim()||Ge,children:[(0,I.jsx)(le,{className:`h-3.5 w-3.5 mr-1.5`}),Ge?`Saving...`:`Save`]})]}),(0,I.jsxs)(`div`,{className:`flex-1 flex min-h-0`,children:[(0,I.jsx)(he,{agents:Q}),(0,I.jsxs)(`div`,{className:`flex-1 relative`,ref:m,children:[b.length>1&&(0,I.jsx)(`div`,{className:`absolute top-3 right-3 z-10`,children:(0,I.jsxs)(u,{variant:`secondary`,size:`sm`,className:`h-8 shadow-md`,onClick:We,children:[(0,I.jsx)(ce,{className:`h-3.5 w-3.5 mr-1.5`}),`Tidy up`]})}),(0,I.jsxs)(ie,{nodes:b,edges:Ne,onNodesChange:e=>S(e),onEdgesChange:ae,onConnect:Pe,onInit:e=>{v(e),M(e.getViewport())},onMove:(e,t)=>M(t),onDrop:Ie,onDragOver:Fe,onEdgeMouseEnter:(e,t)=>{A.current&&=(clearTimeout(A.current),null),k(t.id)},onEdgeMouseLeave:()=>{A.current=setTimeout(()=>k(null),150)},onNodeDrag:Re,onNodeDragStop:ze,onNodeClick:Be,onPaneClick:Ve,nodeTypes:Ce,edgeTypes:we,fitView:!0,fitViewOptions:{padding:.5,maxZoom:.7},defaultViewport:{x:0,y:0,zoom:.6},proOptions:{hideAttribution:!0},deleteKeyCode:[`Backspace`,`Delete`],snapToGrid:!0,snapGrid:[16,16],minZoom:.2,maxZoom:2,edgesFocusable:!0,edgesReconnectable:!0,defaultEdgeOptions:{markerEnd:{type:T.ArrowClosed,width:16,height:16},style:{strokeWidth:2,stroke:`#6b7280`},animated:!0,interactionWidth:20},children:[(0,I.jsx)(re,{gap:16,size:1,color:`hsl(var(--muted-foreground) / 0.08)`}),(0,I.jsx)(ne,{showInteractive:!1})]}),(0,I.jsx)(Se,{viewport:j,tierRange:Le}),b.length===0&&(0,I.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center pointer-events-none`,children:(0,I.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,I.jsx)(ue,{className:`h-12 w-12 mx-auto mb-3 opacity-30`}),(0,I.jsx)(`p`,{className:`text-lg font-medium`,children:`Drag agents from the palette`}),(0,I.jsx)(`p`,{className:`text-sm mt-1`,children:`to compose your team hierarchy`}),(0,I.jsx)(`p`,{className:`text-xs mt-3 opacity-60`,children:`Connect agents with edges to define execution order`})]})})]}),Oe&&(0,I.jsx)(ge,{node:Oe,agents:Q,onUpdate:He,onDelete:Ue,onClose:()=>D(null)})]})]})}export{J as TeamEdit};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,l as n,r,t as i,u as a}from"./vendor-react-BJ8SIkmN.js";import{U as o,V as s,q as c}from"./src-DUhGoAQb.js";import{t as l}from"./arrow-left-wtNmm6Le.js";import{n as u,t as d}from"./zap-CbT5plGA.js";import{t as f}from"./layers-ephyCrDm.js";import{t as p}from"./play-DXJMtO-K.js";import{A as m,D as h,H as g,K as _,U as v,W as y,t as b,w as x}from"./index-dc8HGqTp.js";var S=e(t(),1),C=i();function w(e){switch(e){case`completed`:return`default`;case`failed`:return`destructive`;case`cancelled`:return`outline`;default:return`secondary`}}function T(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function E(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function D(e,t){let n=new Date(t).getTime()-new Date(e).getTime();if(n<1e3)return`${n}ms`;let r=Math.round(n/1e3);return r<60?`${r}s`:`${Math.floor(r/60)}m ${r%60}s`}function O({stats:e}){return(0,C.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,C.jsxs)(`div`,{className:`rounded-lg border bg-card p-4`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,C.jsx)(f,{className:`h-3.5 w-3.5`}),`Sessions`]}),(0,C.jsx)(`p`,{className:`mt-1 text-2xl font-semibold`,children:e.totalSessions})]}),(0,C.jsxs)(`div`,{className:`rounded-lg border bg-card p-4`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,C.jsx)(d,{className:`h-3.5 w-3.5`}),`Total Tokens`]}),(0,C.jsx)(`p`,{className:`mt-1 text-2xl font-semibold`,children:T(e.totalTokens)})]}),(0,C.jsxs)(`div`,{className:`rounded-lg border bg-card p-4`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,C.jsx)(u,{className:`h-3.5 w-3.5`}),`Input`]}),(0,C.jsx)(`p`,{className:`mt-1 text-2xl font-semibold`,children:T(e.totalInputTokens)})]}),(0,C.jsxs)(`div`,{className:`rounded-lg border bg-card p-4`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,C.jsx)(u,{className:`h-3.5 w-3.5`}),`Output`]}),(0,C.jsx)(`p`,{className:`mt-1 text-2xl font-semibold`,children:T(e.totalOutputTokens)})]})]})}function k({session:e}){let t=n(),r=e.inputTokens+e.outputTokens;return(0,C.jsxs)(`div`,{className:`space-y-6`,children:[(0,C.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-lg font-semibold`,children:e.teamName}),(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.prompt})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsxs)(s,{size:`sm`,variant:`outline`,onClick:()=>t(`/agents/teams/${e.teamId}/use/${e.id}`),children:[(0,C.jsx)(g,{className:`mr-1.5 h-3.5 w-3.5`}),`Review in team`]}),(0,C.jsx)(o,{variant:w(e.status),children:e.status})]})]}),(0,C.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,C.jsxs)(`div`,{className:`text-sm`,children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Strategy`}),(0,C.jsx)(`p`,{className:`font-medium capitalize`,children:e.strategy})]}),(0,C.jsxs)(`div`,{className:`text-sm`,children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Rounds`}),(0,C.jsxs)(`p`,{className:`font-medium`,children:[e.totalRounds,`/`,e.maxRounds]})]}),(0,C.jsxs)(`div`,{className:`text-sm`,children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Duration`}),(0,C.jsx)(`p`,{className:`font-medium`,children:D(e.startedAt,e.completedAt)})]}),(0,C.jsxs)(`div`,{className:`text-sm`,children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Tokens`}),(0,C.jsx)(`p`,{className:`font-medium`,children:T(r)})]})]}),e.error&&(0,C.jsx)(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive`,children:e.error}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h3`,{className:`mb-3 text-sm font-medium text-muted-foreground`,children:`Agents`}),(0,C.jsx)(`div`,{className:`space-y-2`,children:e.agents.map(e=>{let t=e.inputTokens+e.outputTokens;return(0,C.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(_,{className:`h-4 w-4 text-muted-foreground`}),(0,C.jsx)(`span`,{className:`font-medium text-sm`,children:e.agentName}),(0,C.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,e.role,`)`]})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.model&&(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.model}),(0,C.jsx)(o,{variant:w(e.status),className:`text-xs`,children:e.status}),(0,C.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[T(t),` tok`]})]})]}),e.output&&(0,C.jsxs)(`pre`,{className:`mt-2 max-h-48 overflow-auto rounded bg-muted/50 p-2 text-xs whitespace-pre-wrap`,children:[e.output.slice(0,2e3),e.output.length>2e3&&`…`]})]},e.id)})})]})]})}function A(){let{t:e}=x(),t=n(),{id:i}=a(),[u,f]=(0,S.useState)([]),[A,j]=(0,S.useState)([]),[M,N]=(0,S.useState)(0),[P,F]=(0,S.useState)(null),[I,L]=(0,S.useState)(null),[R,z]=(0,S.useState)(!0),[B,V]=(0,S.useState)(1);(0,S.useEffect)(()=>{let e=!1;return Promise.resolve().then(()=>{e||z(!0)}),Promise.all([c.teamSessions.list({limit:20,offset:(B-1)*20}),c.teamSessions.stats(14),c.teams.listActiveRuns()]).then(([t,n,r])=>{e||(f(t.data),N(t.total),F(n),j(r.data.filter(e=>e.status===`running`)))}).finally(()=>{e||z(!1)}),()=>{e=!0}},[B]),(0,S.useEffect)(()=>{i?c.teamSessions.get(i).then(L).catch(()=>L(null)):Promise.resolve().then(()=>L(null))},[i]);let H=async e=>{await c.teams.cancelRun(e),j(t=>t.filter(t=>t.id!==e)),b.success(`Run cancelled`)},U=Math.ceil(M/20);return I?(0,C.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4 p-6`,children:[(0,C.jsxs)(r,{to:`/team-sessions`,className:`inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground`,children:[(0,C.jsx)(l,{className:`h-3.5 w-3.5`}),` Back to sessions`]}),(0,C.jsx)(k,{session:I})]}):(0,C.jsxs)(`div`,{className:`mx-auto max-w-6xl space-y-6 p-6`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h1`,{className:`text-xl font-semibold`,children:e(`teamSessions.title`)}),(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`History of all team runs with token consumption analytics`})]}),P&&(0,C.jsx)(O,{stats:P}),P&&(P.byTeam.length>0||P.byAgent.length>0)&&(0,C.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[P.byTeam.length>0&&(0,C.jsxs)(`div`,{className:`rounded-lg border bg-card p-4`,children:[(0,C.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-sm font-medium`,children:[(0,C.jsx)(h,{className:`h-4 w-4`}),` Top Teams (14d)`]}),(0,C.jsx)(`div`,{className:`space-y-2`,children:P.byTeam.slice(0,5).map(e=>(0,C.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,C.jsx)(`span`,{className:`truncate`,children:e.teamName}),(0,C.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,C.jsxs)(`span`,{children:[e.sessions,` runs`]}),(0,C.jsxs)(`span`,{children:[T(e.totalTokens),` tok`]}),(0,C.jsxs)(`span`,{className:`text-green-500`,children:[e.completed,`ok`]}),e.failed>0&&(0,C.jsxs)(`span`,{className:`text-red-500`,children:[e.failed,`err`]})]})]},e.teamId))})]}),P.byAgent.length>0&&(0,C.jsxs)(`div`,{className:`rounded-lg border bg-card p-4`,children:[(0,C.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-sm font-medium`,children:[(0,C.jsx)(_,{className:`h-4 w-4`}),` Top Agents (14d)`]}),(0,C.jsx)(`div`,{className:`space-y-2`,children:P.byAgent.slice(0,5).map(e=>(0,C.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,C.jsx)(`span`,{className:`truncate`,children:e.agentName}),(0,C.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,C.jsxs)(`span`,{children:[e.sessions,` runs`]}),(0,C.jsxs)(`span`,{children:[T(e.totalTokens),` tok`]})]})]},e.agentId))})]})]}),A.length>0&&(0,C.jsxs)(`div`,{className:`rounded-lg border border-yellow-500/30`,children:[(0,C.jsx)(`div`,{className:`border-b border-yellow-500/30 px-4 py-3`,children:(0,C.jsxs)(`h3`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,C.jsxs)(`span`,{className:`relative flex h-2 w-2`,children:[(0,C.jsx)(`span`,{className:`animate-ping absolute inline-flex h-full w-full rounded-full bg-yellow-400 opacity-75`}),(0,C.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2 bg-yellow-500`})]}),`Running (`,A.length,`)`]})}),(0,C.jsx)(`div`,{className:`divide-y`,children:A.map(e=>(0,C.jsxs)(`div`,{className:`flex items-center gap-4 px-4 py-3 hover:bg-muted/50 transition-colors`,children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`font-medium text-sm truncate`,children:e.teamId}),(0,C.jsx)(o,{variant:`secondary`,className:`text-xs`,children:`running`}),(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground capitalize`,children:e.strategy})]}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground line-clamp-1`,children:e.prompt})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,C.jsxs)(s,{size:`sm`,variant:`outline`,onClick:()=>t(`/agents/teams/${e.teamId}/use`),children:[(0,C.jsx)(p,{className:`mr-1.5 h-3.5 w-3.5`}),`Open`]}),(0,C.jsxs)(s,{size:`sm`,variant:`outline`,onClick:()=>H(e.id),children:[(0,C.jsx)(m,{className:`mr-1.5 h-3.5 w-3.5`}),`Stop`]})]})]},e.id))})]}),(0,C.jsxs)(`div`,{className:`rounded-lg border`,children:[(0,C.jsx)(`div`,{className:`border-b px-4 py-3`,children:(0,C.jsxs)(`h3`,{className:`text-sm font-medium`,children:[`All Sessions (`,M,`)`]})}),R&&(0,C.jsx)(`div`,{className:`p-8 text-center text-sm text-muted-foreground`,children:`Loading...`}),!R&&u.length===0&&(0,C.jsx)(`div`,{className:`p-8 text-center text-sm text-muted-foreground`,children:`No sessions yet. Run a team to see history here.`}),!R&&u.length>0&&(0,C.jsx)(`div`,{className:`divide-y`,children:u.map(e=>{let n=e.inputTokens+e.outputTokens;return(0,C.jsxs)(`div`,{className:`flex items-center gap-4 px-4 py-3 hover:bg-muted/50 transition-colors cursor-pointer`,onClick:()=>t(`/team-sessions/${e.id}`),children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`font-medium text-sm truncate`,children:e.teamName}),(0,C.jsx)(o,{variant:w(e.status),className:`text-xs`,children:e.status}),(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground capitalize`,children:e.strategy})]}),(0,C.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground line-clamp-1`,children:e.prompt})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-muted-foreground shrink-0`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,C.jsx)(v,{className:`h-3 w-3`}),E(e.startedAt)]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,C.jsx)(d,{className:`h-3 w-3`}),T(n)]}),(0,C.jsxs)(`span`,{children:[e.agents.length,` agents`]}),(0,C.jsx)(`span`,{children:D(e.startedAt,e.completedAt)}),(0,C.jsxs)(s,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:n=>{n.stopPropagation(),t(`/agents/teams/${e.teamId}/use/${e.id}`)},children:[(0,C.jsx)(g,{className:`mr-1 h-3.5 w-3.5`}),`Review`]}),(0,C.jsx)(y,{className:`h-4 w-4`})]})]},e.id)})}),U>1&&(0,C.jsxs)(`div`,{className:`flex items-center justify-between border-t px-4 py-3`,children:[(0,C.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Page `,B,` of `,U]}),(0,C.jsxs)(`div`,{className:`flex gap-2`,children:[(0,C.jsx)(s,{size:`sm`,variant:`outline`,disabled:B<=1,onClick:()=>V(e=>e-1),children:`Previous`}),(0,C.jsx)(s,{size:`sm`,variant:`outline`,disabled:B>=U,onClick:()=>V(e=>e+1),children:`Next`})]})]})]})]})}export{A as TeamSessions};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,l as n,t as r,u as i}from"./vendor-react-BJ8SIkmN.js";import{t as a}from"./useQuery-DvovkaPT.js";import{F as o,K as s,N as c,U as l,V as u,j as d,q as f,t as p}from"./src-DUhGoAQb.js";import{S as m,_ as h,h as g,p as _,v,x as y}from"./vendor-ui-Dpw9mBc-.js";import{t as b}from"./arrow-left-wtNmm6Le.js";import{t as x}from"./crown-BJEsQkh4.js";import{t as S}from"./chat-message-CbcDeDcb.js";import{t as ee}from"./history-CyBBboEp.js";import{n as C,r as te,t as ne}from"./send-FWvygYFQ.js";import{t as w}from"./play-DXJMtO-K.js";import"./utils-DHTPP40O.js";import{A as T,D as E,R as re,_ as ie,g as D,n as O,r as k,t as A,w as j}from"./index-dc8HGqTp.js";var ae=o(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),M=e(t(),1);function N(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>{let r=n;return[r.agentId,r.output??t[r.agentId]??``]}))}function oe(e){let[t,n]=(0,M.useState)({agentStates:{},agentOutputs:{},agentStreaming:{},agentIsStreaming:{},agentStreamIds:{},messageEdges:[],runStatus:`idle`,currentRound:0,maxRounds:0,debateRound:null}),r=(0,M.useRef)(null),i=(0,M.useCallback)(()=>{n({agentStates:{},agentOutputs:{},agentStreaming:{},agentIsStreaming:{},agentStreamIds:{},messageEdges:[],runStatus:`idle`,currentRound:0,maxRounds:0,debateRound:null})},[]);return(0,M.useEffect)(()=>{if(!e){r.current&&=(r.current.close(),null);return}let i=new EventSource(`/api/team-runs/${e}/stream`);r.current=i,i.onopen=()=>{n(e=>({...e,runStatus:`running`}))},i.addEventListener(`state`,e=>{try{let t=JSON.parse(e.data);t.type===`state-snapshot`&&n(e=>({...e,agentStates:t.agentStates??e.agentStates,runStatus:t.status===`running`?`running`:t.status,currentRound:t.currentRound??e.currentRound,maxRounds:t.maxRounds??e.maxRounds,agentOutputs:N(t.agentStates??{},e.agentOutputs)}))}catch{}}),i.addEventListener(`team-event`,e=>{try{a(JSON.parse(e.data))}catch{}}),i.onerror=()=>{t.runStatus!==`running`&&i.close()};function a(e){n(t=>{let n={...t};switch(e.type){case`run-started`:n.runStatus=`running`;break;case`agent-status`:{let t=n.agentStates[e.nodeId];n.agentStates={...n.agentStates,[e.nodeId]:{...t??{agentId:e.agentId,nodeId:e.nodeId,role:``,round:0},status:e.status}},e.status===`running`&&(n.agentIsStreaming={...n.agentIsStreaming,[e.agentId]:!0},n.agentStreaming={...n.agentStreaming,[e.agentId]:``}),(e.status===`done`||e.status===`error`)&&(n.agentIsStreaming={...n.agentIsStreaming,[e.agentId]:!1});break}case`agent-stream-start`:n.agentStreamIds={...n.agentStreamIds,[e.agentId]:e.streamId},n.agentIsStreaming={...n.agentIsStreaming,[e.agentId]:!0},n.agentStreaming={...n.agentStreaming,[e.agentId]:``};break;case`agent-output`:n.agentStreaming={...n.agentStreaming,[e.agentId]:(t.agentStreaming[e.agentId]??``)+e.delta};break;case`agent-done`:n.agentOutputs={...n.agentOutputs,[e.agentId]:e.output},n.agentStreaming={...n.agentStreaming,[e.agentId]:``},n.agentIsStreaming={...n.agentIsStreaming,[e.agentId]:!1};break;case`agent-error`:n.agentIsStreaming={...n.agentIsStreaming,[e.agentId]:!1};break;case`message-pass`:n.messageEdges=[...t.messageEdges,{fromNodeId:e.fromNodeId,toNodeId:e.toNodeId,preview:e.preview,edgeId:e.edgeId,timestamp:Date.now()}].slice(-50);break;case`round-info`:n.currentRound=e.currentRound,n.maxRounds=e.maxRounds;break;case`debate-round`:n.debateRound={current:e.round,total:e.totalRounds};break;case`run-completed`:n.runStatus=`completed`;break;case`run-failed`:n.runStatus=`failed`;break;case`run-cancelled`:n.runStatus=`cancelled`;break;case`run-final`:n.runStatus=e.status;break}return n})}return()=>{i.close(),r.current=null}},[e]),{...t,reset:i}}var P=r();function F(e){return e===`running`?`running`:e===`done`?`done`:e===`error`?`error`:`idle`}var I=(0,M.memo)(function({data:e,selected:t}){let n=e.agent;return(0,P.jsxs)(`div`,{className:s(`rounded-lg border-2 min-w-[220px] max-w-[280px] transition-all duration-300`,e.isRouter?`border-amber-500/50 bg-amber-500/5`:`border-violet-500/50 bg-violet-500/5`,e.isSelected&&`ring-2 ring-primary ring-offset-1 ring-offset-background`,!e.isSelected&&{idle:``,running:`ring-2 ring-emerald-500/50`,done:`ring-2 ring-emerald-500/20`,error:`ring-2 ring-red-500/30`}[e.status],e.status===`running`&&`agent-node-active`),style:e.status===`running`?{boxShadow:`0 0 20px 4px rgba(16, 185, 129, 0.25), 0 0 40px 8px rgba(16, 185, 129, 0.10)`}:void 0,children:[(0,P.jsx)(h,{type:`target`,position:m.Top,id:`top-in`,className:`!bg-transparent !border-orange-400`,style:{left:`35%`,width:12,height:6,borderRadius:`6px 6px 0 0`,borderWidth:2,borderBottomWidth:0,transform:`translate(-50%, 0)`,top:-6}}),(0,P.jsx)(h,{type:`source`,position:m.Top,id:`top-out`,className:`!bg-sky-400 !border-0`,style:{left:`65%`,width:12,height:6,borderRadius:`6px 6px 0 0`,transform:`translate(-50%, 0)`,top:-6}}),(0,P.jsx)(h,{type:`target`,position:m.Left,id:`left-in`,className:`!bg-transparent !border-orange-400`,style:{top:`35%`,width:6,height:12,borderRadius:`6px 0 0 6px`,borderWidth:2,borderRightWidth:0,transform:`translate(0, -50%)`,left:-6}}),(0,P.jsx)(h,{type:`source`,position:m.Left,id:`left-out`,className:`!bg-sky-400 !border-0`,style:{top:`65%`,width:6,height:12,borderRadius:`6px 0 0 6px`,transform:`translate(0, -50%)`,left:-6}}),(0,P.jsx)(h,{type:`source`,position:m.Right,id:`right-out`,className:`!bg-sky-400 !border-0`,style:{top:`35%`,width:6,height:12,borderRadius:`0 6px 6px 0`,transform:`translate(0, -50%)`,right:-6,left:`auto`}}),(0,P.jsx)(h,{type:`target`,position:m.Right,id:`right-in`,className:`!bg-transparent !border-orange-400`,style:{top:`65%`,width:6,height:12,borderRadius:`0 6px 6px 0`,borderWidth:2,borderLeftWidth:0,transform:`translate(0, -50%)`,right:-6,left:`auto`}}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-3 border-b border-border/50`,children:[(0,P.jsx)(`span`,{className:`text-2xl`,children:n?.avatar??`?`}),(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium truncate`,children:n?.name??`Unknown Agent`}),(0,P.jsxs)(`div`,{className:`text-[10px] text-muted-foreground flex items-center gap-1`,children:[n?.runtime===`cli`&&n.cli&&(0,M.createElement)(O(n.cli),{className:`h-2.5 w-2.5`}),n?.runtime===`cli`?k(n.cli??void 0):`API`]})]}),e.isRouter&&(0,P.jsx)(x,{className:`h-4 w-4 text-amber-500 shrink-0`}),e.status===`running`&&(0,P.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full bg-emerald-500 animate-pulse shrink-0`}),e.status===`done`&&(0,P.jsx)(l,{variant:`secondary`,className:`text-[9px] bg-emerald-500/15 text-emerald-500 px-1.5 py-0`,children:`Done`}),e.status===`error`&&(0,P.jsx)(l,{variant:`secondary`,className:`text-[9px] bg-red-500/15 text-red-500 px-1.5 py-0`,children:`Error`})]}),(0,P.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,P.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Role: `}),(0,P.jsx)(`span`,{className:s(`text-[11px] font-medium`,e.role?`text-primary/80`:`text-muted-foreground/50 italic`),children:e.role||`N/A`})]}),(0,P.jsx)(h,{type:`source`,position:m.Bottom,id:`bottom-out`,className:`!bg-sky-400 !border-0`,style:{left:`35%`,width:12,height:6,borderRadius:`0 0 6px 6px`,transform:`translate(-50%, 0)`,bottom:-6,top:`auto`}}),(0,P.jsx)(h,{type:`target`,position:m.Bottom,id:`bottom-in`,className:`!bg-transparent !border-orange-400`,style:{left:`65%`,width:12,height:6,borderRadius:`0 0 6px 6px`,borderWidth:2,borderTopWidth:0,transform:`translate(-50%, 0)`,bottom:-6,top:`auto`}})]})}),se={"team-agent":I};function L({agent:e,session:t,onSend:n,onStop:r,isStreaming:i,streamingContent:a,streamingThinking:o,streamingToolCalls:c,compact:f,onClose:m,label:h,hideHeader:g}){let[_,v]=(0,M.useState)(``),y=(0,M.useRef)(null),b=(0,M.useRef)(null),[x,ee]=(0,M.useState)(!0),C=(0,M.useCallback)(()=>{y.current?.scrollIntoView({behavior:`smooth`})},[]),te=(0,M.useCallback)(()=>{let e=b.current;e&&ee(e.scrollHeight-e.scrollTop-e.clientHeight<100)},[]);(0,M.useEffect)(()=>{x&&C()},[t.messages,a,c,x,C]),(0,M.useEffect)(()=>{let e=t.messages;e.length>0&&e[e.length-1].role===`user`&&setTimeout(C,0)},[t.messages.length,C,t.messages]);let w=(0,M.useCallback)(()=>{let e=_.trim();!e||i||(n(e),v(``))},[_,i,n]),E=(0,M.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),w())},[w]);return(0,P.jsxs)(`div`,{className:`flex flex-col h-full min-h-0 border-b border-border last:border-b-0`,children:[!g&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-muted/50 border-b border-border shrink-0`,children:[(0,P.jsx)(`span`,{className:`text-base`,children:e.avatar}),(0,P.jsx)(`span`,{className:`text-xs font-medium truncate`,children:e.name}),h&&(0,P.jsx)(l,{variant:`outline`,className:`text-[9px] px-1.5 py-0`,children:h}),t.status===`running`&&(0,P.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-emerald-500 animate-pulse`}),(0,P.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[i&&(0,P.jsx)(u,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:r,title:`Stop`,children:(0,P.jsx)(T,{className:`h-3 w-3 text-destructive`})}),m&&(0,P.jsx)(u,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:m,children:(0,P.jsx)(d,{className:`h-3 w-3`})})]})]}),(0,P.jsx)(`div`,{ref:b,onScroll:te,className:`flex-1 min-h-0 overflow-y-auto`,children:(0,P.jsxs)(`div`,{className:s(`space-y-3 p-3`,f?`max-w-none`:`max-w-xl mx-auto`),children:[t.messages.length===0&&!a&&!i&&(0,P.jsx)(`div`,{className:`text-center py-6 text-muted-foreground`,children:(0,P.jsxs)(`p`,{className:`text-xs`,children:[`Send a message to `,e.name]})}),t.messages.map(e=>(0,P.jsx)(S,{role:e.role,content:e.content,thinking:e.thinking,toolCalls:e.toolCalls,compact:e.role===`user`},e.id)),i&&(a||o||c&&c.length>0)&&(0,P.jsx)(S,{role:`assistant`,content:a,thinking:o,toolCalls:c?.map(e=>({id:e.id,name:e.name,input:e.input,output:e.output}))}),i&&!a&&!o&&(!c||c.length===0)&&(0,P.jsxs)(`div`,{className:`flex gap-2 justify-start`,children:[(0,P.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center shrink-0 mt-0.5`,children:(0,P.jsx)(`span`,{className:`text-xs`,children:e.avatar})}),(0,P.jsx)(`div`,{className:`rounded-lg px-3 py-2.5 bg-muted`,children:(0,P.jsxs)(`div`,{className:`flex gap-1`,children:[(0,P.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-muted-foreground/50 animate-bounce [animation-delay:0ms]`}),(0,P.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-muted-foreground/50 animate-bounce [animation-delay:150ms]`}),(0,P.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-muted-foreground/50 animate-bounce [animation-delay:300ms]`})]})})]}),(0,P.jsx)(`div`,{ref:y})]})}),(0,P.jsx)(`div`,{className:`border-t p-2 shrink-0`,children:(0,P.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,P.jsx)(p,{value:_,onChange:e=>v(e.target.value),onKeyDown:E,placeholder:`Message ${e.name}...`,className:`min-h-[36px] max-h-[100px] resize-none text-xs`,rows:1,disabled:i}),i?(0,P.jsx)(u,{variant:`destructive`,size:`icon`,className:`h-[36px] w-[36px] shrink-0`,onClick:r,children:(0,P.jsx)(T,{className:`h-3.5 w-3.5`})}):(0,P.jsx)(u,{size:`icon`,className:`h-[36px] w-[36px] shrink-0`,onClick:w,disabled:!_.trim(),children:(0,P.jsx)(ne,{className:`h-3.5 w-3.5`})})]})})]})}function R({agent:e,session:t,onUpdateSession:n,compact:r,onClose:i,label:a,hideHeader:o,teamStreamId:s}){let{t:c}=j(),{streamingContent:l,streamingThinking:u,streamingToolCalls:d,isStreaming:p,error:m,startStream:h,stopStream:g,consumeStream:_}=D(s?`team/${e.id}/${s}`:t.sessionKey),v=(0,M.useRef)(null);return(0,M.useEffect)(()=>{s&&s!==v.current&&(v.current=s,h(s))},[s,h]),(0,M.useEffect)(()=>{p&&t.status===`idle`&&n(e.id,{status:`running`})},[p,t.status,e.id,n]),(0,M.useEffect)(()=>{if(!p&&(l||d.length>0)&&(t.status===`running`||t.status===`done`)){let r=_();r&&(r.content||r.toolCalls.length>0)&&n(e.id,{status:`done`,messages:[...t.messages,{id:crypto.randomUUID(),role:`assistant`,content:r.content,timestamp:new Date,thinking:r.thinking||void 0,toolCalls:r.toolCalls.map(e=>({id:e.id,name:e.name,input:e.input,output:e.output}))}]})}},[p,l,d,t.status,e.id,t.messages,n,_]),(0,M.useEffect)(()=>{if(m&&t.status===`running`){if(l||d.length>0)return;n(e.id,{status:`error`,messages:[...t.messages,{id:crypto.randomUUID(),role:`system`,content:`Error: ${m}`,timestamp:new Date}]})}},[m,t.status,e.id,t.messages,n,l,d]),(0,P.jsx)(L,{agent:e,session:t,onSend:(0,M.useCallback)(async r=>{let i={id:crypto.randomUUID(),role:`user`,content:r,timestamp:new Date},a=[...t.messages,i];n(e.id,{messages:a,status:`running`});try{let t=e.additionalFolders?.map(e=>e.path),i=await f.chat.startNew(e.dir,r,e.cli??void 0,t?.length?t:void 0),a=`team-use/${e.id}/${i.streamId}`;n(e.id,{sessionKey:a,streamId:i.streamId}),h(i.streamId)}catch(t){n(e.id,{status:`error`,messages:[...a,{id:crypto.randomUUID(),role:`system`,content:`Failed to start: ${t}`,timestamp:new Date}]}),A.error(c(`teamUse.failedToStart`,{name:e.name}))}},[e,t.messages,n,h,c]),onStop:(0,M.useCallback)(()=>{g(),n(e.id,{status:`idle`})},[g,e.id,n]),isStreaming:p,streamingContent:l,streamingThinking:u,streamingToolCalls:d,compact:r,onClose:i,label:a,hideHeader:o})}function z({initialRunId:e,initialExpandedPanels:t,initialSessions:r,initialRunStatus:o}={}){let{t:d}=j(),{id:m,sessionId:h}=i(),x=n(),{data:S,isLoading:ne}=a({queryKey:[`teams`,m],queryFn:()=>f.teams.get(m),enabled:!!m}),{data:T}=a({queryKey:[`agents`],queryFn:()=>f.agents.list({page:1,pageSize:100})}),D=(0,M.useMemo)(()=>T?.data??[],[T?.data]),[O,k]=(0,M.useState)(r??{}),[N,I]=(0,M.useState)(null),[L,z]=(0,M.useState)(e??null),[B,V]=(0,M.useState)(``),H=oe(r?null:L),U=o??H.runStatus,W=U===`running`,[G,K]=(0,M.useState)(`side`),[ce,q]=(0,M.useState)(new Set(t??[])),J=(0,M.useCallback)(e=>{q(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);(0,M.useEffect)(()=>{if(L)for(let[e,n]of Object.entries(H.agentStreamIds))n&&(ie(n,`team/${e}/${n}`),t||q(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n}))},[L,H.agentStreamIds,t]),(0,M.useEffect)(()=>{S&&D.length>0&&k(e=>{let t={...e};for(let e of S.agents)t[e.agentId]||(t[e.agentId]={agentId:e.agentId,messages:[],status:`idle`});return t})},[S,D]),(0,M.useEffect)(()=>{!h||!S||!D.length||f.teamSessions.get(h).then(e=>{V(e.prompt);let t={};for(let n of e.agents){let r=[{id:crypto.randomUUID(),role:`user`,content:e.prompt,timestamp:new Date(e.startedAt)}];n.output&&r.push({id:crypto.randomUUID(),role:`assistant`,content:n.output,timestamp:new Date(e.completedAt??e.startedAt)}),t[n.agentId]={agentId:n.agentId,messages:r,status:F(n.status)},q(e=>{let t=new Set(e);return t.add(n.agentId),t})}k(e=>({...e,...t}))}).catch(()=>{})},[h,S?.id,D.length]),(0,M.useEffect)(()=>{if(!S?.id||L||r||h)return;let e=!1;return f.teams.listActiveRuns().then(t=>{if(e)return;let n=t.data.filter(e=>e.teamId===S.id&&e.status===`running`).sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime())[0];n&&(z(n.id),n.prompt&&V(n.prompt),A.info(`Reconnected to active run`))}).catch(()=>{}),()=>{e=!0}},[S?.id,r,h,L]),(0,M.useEffect)(()=>{if(L)for(let[,e]of Object.entries(H.agentStates)){let t=F(e.status);k(n=>{let r=n[e.agentId];return!r||r.status===t?n:{...n,[e.agentId]:{...r,status:t}}})}},[L,H.agentStates]),(0,M.useEffect)(()=>{if(L)for(let[e,t]of Object.entries(H.agentOutputs))t&&k(n=>{let r=n[e];if(!r)return n;let i=r.messages[r.messages.length-1];return i?.role===`assistant`&&i.content===t?n:{...n,[e]:{...r,messages:[...r.messages,{id:crypto.randomUUID(),role:`assistant`,content:t,timestamp:new Date}]}}})},[L,H.agentOutputs]);let Y=(0,M.useCallback)(async()=>{if(!(!S||!B.trim()))try{let{runId:e}=await f.teams.startRun(S.id,B.trim());z(e),k(e=>{let t={...e};for(let e of S.agents)t[e.agentId]&&(t[e.agentId]={...t[e.agentId],messages:[...t[e.agentId].messages,{id:crypto.randomUUID(),role:`user`,content:B.trim(),timestamp:new Date}],status:`running`});return t}),V(``),A.success(d(`teamUse.teamRunStarted`))}catch(e){A.error(d(`teamUse.failedToStartRun`,{error:String(e)}))}},[S,B,d]),le=(0,M.useCallback)(async()=>{if(L)try{await f.teams.cancelRun(L),A.info(d(`teamUse.teamRunCancelled`))}catch(e){A.error(d(`teamUse.failedToCancel`,{error:String(e)}))}},[L,d]),X=(0,M.useCallback)((e,t)=>{k(n=>({...n,[e]:{...n[e],...t}}))},[]),ue=(0,M.useMemo)(()=>Object.entries(O).filter(([,e])=>e.status===`running`||e.status===`done`||e.status===`error`||e.messages.length>0).map(([e])=>e),[O]),Z=(0,M.useMemo)(()=>{if(!S)return[];let e=new Map(D.map(e=>[e.id,e])),t=e=>{if(L){let t=Object.values(H.agentStates).find(t=>t.agentId===e);if(t){if(t.status===`running`)return`running`;if(t.status===`done`)return`done`;if(t.status===`error`)return`error`}}return O[e]?.status??`idle`};return S.canvas&&S.canvas.nodes.length>0?S.canvas.nodes.map(n=>({id:n.id,type:`team-agent`,position:{x:n.x,y:n.y},data:{agentId:n.agentId,role:n.role??``,agent:e.get(n.agentId),isRouter:n.isRouter,status:t(n.agentId),isSelected:n.id===N},draggable:!1,selectable:!0})):S.agents.map((n,r)=>({id:`fallback_${n.agentId}`,type:`team-agent`,position:{x:S.strategy===`sequential`?0:(r-(S.agents.length-1)/2)*300,y:S.strategy===`sequential`?r*280:S.strategy===`router`&&S.routerConfig?.routerAgentId===n.agentId?0:280},data:{agentId:n.agentId,role:n.role??``,agent:e.get(n.agentId),isRouter:S.strategy===`router`&&S.routerConfig?.routerAgentId===n.agentId,status:t(n.agentId),isSelected:!1},draggable:!1,selectable:!0}))},[S,D,O,N,L,H.agentStates]),[de,fe]=(0,M.useState)(0);(0,M.useEffect)(()=>{if(H.messageEdges.length===0)return;let e=setInterval(()=>fe(e=>e+1),1e3);return()=>clearInterval(e)},[H.messageEdges.length]);let pe=(0,M.useMemo)(()=>{let e=Date.now();return new Set(H.messageEdges.filter(t=>e-t.timestamp<5e3).map(e=>e.edgeId).filter(Boolean))},[H.messageEdges,de]),me=(0,M.useMemo)(()=>{if(!S)return[];if(S.canvas&&S.canvas.edges.length>0)return S.canvas.edges.map(e=>{let t=pe.has(e.id),n=t||U===`completed`;return{id:e.id,source:e.source,sourceHandle:e.sourceHandle,target:e.target,targetHandle:e.targetHandle,markerEnd:{type:y.ArrowClosed,width:16,height:16},style:{strokeWidth:n?3:2,stroke:n?`#22c55e`:`#6b7280`,transition:`stroke 0.5s ease, stroke-width 0.3s ease`},animated:t,className:t?`react-flow__edge-animated-pulse`:``}});let e=Z,t=[];if(S.strategy===`sequential`)for(let n=0;n<e.length-1;n++)t.push({id:`e-${e[n].id}-${e[n+1].id}`,source:e[n].id,sourceHandle:`bottom-out`,target:e[n+1].id,targetHandle:`top-in`,markerEnd:{type:y.ArrowClosed,width:16,height:16},style:{strokeWidth:2,stroke:`#6b7280`},animated:!0});else if(S.strategy===`router`){let n=e.find(e=>e.data.isRouter);if(n)for(let r of e)r.id!==n.id&&t.push({id:`e-${n.id}-${r.id}`,source:n.id,sourceHandle:`bottom-out`,target:r.id,targetHandle:`top-in`,markerEnd:{type:y.ArrowClosed,width:16,height:16},style:{strokeWidth:2,stroke:`#6b7280`},animated:!0})}return t},[S,Z,pe,U]),Q=(0,M.useMemo)(()=>N?Z.find(e=>e.id===N)?.data.agentId??null:null,[N,Z]),he=(0,M.useCallback)((e,t)=>{I(e=>e===t.id?null:t.id)},[]),ge=(0,M.useCallback)(e=>{let t=Z.find(t=>t.data.agentId===e);t&&I(t.id)},[Z]),_e=(0,M.useCallback)(()=>{I(null)},[]);if(ne)return(0,P.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,P.jsx)(re,{className:`h-8 w-8 animate-spin text-muted-foreground`})});if(!S)return(0,P.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:d(`teamUse.teamNotFound`)}),(0,P.jsxs)(u,{variant:`outline`,onClick:()=>x(`/agents?tab=teams`),children:[(0,P.jsx)(b,{className:`h-4 w-4 mr-1`}),` `,d(`teamUse.backToTeams`)]})]});let $=Q?D.find(e=>e.id===Q):null,ve=Q?O[Q]:null,ye=ue.filter(e=>e!==Q);return(0,P.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 border-b bg-background/95 backdrop-blur shrink-0`,children:[(0,P.jsx)(u,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>x(`/agents?tab=teams`),children:(0,P.jsx)(b,{className:`h-4 w-4`})}),(0,P.jsx)(`div`,{className:`h-8 w-8 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,P.jsx)(E,{className:`h-4 w-4 text-primary`})}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h1`,{className:`text-sm font-semibold`,children:S.name}),(0,P.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[S.agents.length,` agents · `,S.strategy]})]}),(0,P.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[H.debateRound&&(0,P.jsxs)(l,{variant:`outline`,className:`text-xs`,children:[`Debate Round `,H.debateRound.current,`/`,H.debateRound.total]}),H.currentRound>0&&!H.debateRound&&(0,P.jsxs)(l,{variant:`outline`,className:`text-xs`,children:[`Round `,H.currentRound,`/`,H.maxRounds]}),W&&(0,P.jsx)(l,{className:`bg-emerald-500/15 text-emerald-500 border-emerald-500/30 animate-pulse`,children:`Running`}),U===`completed`&&(0,P.jsx)(l,{className:`bg-emerald-500/15 text-emerald-500 border-emerald-500/30`,children:`Completed`}),U===`failed`&&(0,P.jsx)(l,{className:`bg-red-500/15 text-red-500 border-red-500/30`,children:`Failed`}),W&&(0,P.jsxs)(u,{variant:`destructive`,size:`sm`,onClick:le,children:[(0,P.jsx)(ae,{className:`h-3.5 w-3.5 mr-1`}),` Stop`]}),(0,P.jsxs)(u,{variant:`ghost`,size:`sm`,className:`h-7 text-xs gap-1`,onClick:()=>x(`/team-sessions?teamId=${S.id}`),children:[(0,P.jsx)(ee,{className:`h-3.5 w-3.5`}),` History`]}),(0,P.jsxs)(`div`,{className:`flex items-center border rounded-lg p-0.5 bg-muted/50`,children:[(0,P.jsx)(u,{variant:G===`side`?`secondary`:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>K(`side`),title:d(`common.sideBySide`),children:(0,P.jsx)(te,{className:`h-3.5 w-3.5`})}),(0,P.jsx)(u,{variant:G===`stack`?`secondary`:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>K(`stack`),title:d(`common.stacked`),children:(0,P.jsx)(C,{className:`h-3.5 w-3.5`})})]})]})]}),(0,P.jsxs)(`div`,{className:s(`flex-1 min-h-0`,G===`side`?`flex`:`flex flex-col`),children:[(0,P.jsx)(`div`,{className:s(`bg-muted/30`,G===`side`?`w-[45%] h-full border-r`:`h-[280px] border-b shrink-0`),children:(0,P.jsxs)(v,{nodes:Z,edges:me,nodeTypes:se,onNodeClick:he,onPaneClick:_e,fitView:!0,fitViewOptions:{padding:.3},proOptions:{hideAttribution:!0},panOnScroll:!0,zoomOnScroll:!0,minZoom:.3,maxZoom:1.5,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,children:[(0,P.jsx)(_,{gap:20,size:1}),(0,P.jsx)(g,{showInteractive:!1})]})}),(0,P.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 min-h-0 overflow-hidden`,children:[!W&&U!==`completed`&&(0,P.jsx)(`div`,{className:`border-b p-3 shrink-0 bg-muted/30`,children:(0,P.jsxs)(`div`,{className:`flex gap-2 max-w-2xl mx-auto`,children:[(0,P.jsx)(p,{value:B,onChange:e=>V(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Y())},placeholder:`Give the team a task (${S.strategy} strategy)...`,className:`min-h-[44px] max-h-[120px] resize-none text-sm`,rows:1}),(0,P.jsxs)(u,{className:`h-[44px] shrink-0 gap-1.5`,onClick:Y,disabled:!B.trim(),children:[(0,P.jsx)(w,{className:`h-4 w-4`}),` Run Team`]})]})}),G===`stack`||ye.length>0||$?G===`stack`?(0,P.jsx)(`div`,{className:`flex-1 flex min-h-0 overflow-x-auto`,children:S.agents.map(e=>e.agentId).map(e=>{let t=D.find(t=>t.id===e),n=O[e];if(!t||!n)return null;let r=S.agents.find(t=>t.agentId===e);return(0,P.jsx)(`div`,{onClick:()=>ge(e),className:s(`flex-1 min-w-[280px] border-r border-border last:border-r-0 flex flex-col min-h-0 cursor-pointer`,e===Q&&`ring-2 ring-primary ring-inset bg-primary/[0.02]`),children:(0,P.jsx)(R,{agent:t,session:n,onUpdateSession:X,compact:!0,label:r?.role,teamStreamId:L?H.agentStreamIds[e]:void 0})},e)})}):(0,P.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-auto`,children:[$&&ve&&(0,P.jsx)(`div`,{className:`flex-1 flex flex-col min-h-[200px]`,children:(0,P.jsx)(R,{agent:$,session:ve,onUpdateSession:X,compact:!0,label:`Selected`,onClose:()=>I(null),teamStreamId:L?H.agentStreamIds[$.id]:void 0})}),ye.map(e=>{let t=D.find(t=>t.id===e),n=O[e];if(!t||!n)return null;let r=S.agents.find(t=>t.agentId===e),i=ce.has(e),a=H.agentIsStreaming[e],o=H.agentStreaming[e]||``,u=n.messages[n.messages.length-1];return(0,P.jsxs)(`div`,{className:`border-t border-border shrink-0`,children:[(0,P.jsxs)(`button`,{onClick:()=>J(e),className:s(`w-full flex items-center gap-2 px-3 py-1.5 hover:bg-muted/80 transition-colors`,a?`bg-emerald-500/5`:`bg-muted/50`),children:[(0,P.jsx)(c,{className:s(`h-3.5 w-3.5 text-muted-foreground transition-transform duration-200`,!i&&`-rotate-90`)}),(0,P.jsx)(`span`,{className:`text-base`,children:t.avatar}),(0,P.jsx)(`span`,{className:`text-xs font-medium truncate`,children:t.name}),r?.role&&(0,P.jsx)(l,{variant:`outline`,className:`text-[9px] px-1.5 py-0`,children:r.role}),a&&(0,P.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-emerald-500 animate-pulse`}),n.status===`done`&&!a&&(0,P.jsx)(l,{variant:`secondary`,className:`text-[9px] bg-emerald-500/15 text-emerald-500 px-1.5 py-0`,children:`Done`}),n.status===`error`&&(0,P.jsx)(l,{variant:`secondary`,className:`text-[9px] bg-red-500/15 text-red-500 px-1.5 py-0`,children:`Error`})]}),!i&&(a||o)&&(0,P.jsx)(`div`,{className:`px-3 py-2 bg-muted/20 border-b border-border/50 cursor-pointer`,onClick:()=>J(e),children:(0,P.jsxs)(`div`,{className:`text-[11px] text-muted-foreground font-mono leading-relaxed max-h-[60px] overflow-hidden relative`,children:[o.split(`
|
|
2
|
-
`).slice(-3).join(`
|
|
3
|
-
`)||`…`,a&&(0,P.jsx)(`span`,{className:`inline-block w-1.5 h-3 bg-emerald-500 animate-pulse ml-0.5 align-middle`}),(0,P.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-4 bg-gradient-to-t from-muted/20 to-transparent pointer-events-none`})]})}),!i&&!a&&!o&&u&&(0,P.jsx)(`div`,{className:`px-3 py-1.5 bg-muted/10 border-b border-border/50 cursor-pointer`,onClick:()=>J(e),children:(0,P.jsxs)(`p`,{className:`text-[10px] text-muted-foreground truncate`,children:[u.content.slice(0,150),u.content.length>150?`…`:``]})}),i&&(0,P.jsx)(`div`,{className:`h-[300px]`,children:(0,P.jsx)(R,{agent:t,session:n,onUpdateSession:X,compact:!0,hideHeader:!0,label:r?.role,teamStreamId:L?H.agentStreamIds[e]:void 0})})]},e)})]}):(0,P.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-muted-foreground`,children:[(0,P.jsx)(E,{className:`h-12 w-12 mb-3 opacity-30`}),(0,P.jsx)(`p`,{className:`font-medium text-sm`,children:U===`idle`?`Run the team or select an agent`:`Select an agent on the canvas`}),(0,P.jsx)(`p`,{className:`text-xs mt-1`,children:U===`idle`?`Enter a prompt above to orchestrate all agents, or click a node to chat directly`:`Click a node to open its chat panel`})]})]})]})]})}export{z as TeamUse};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F as e}from"./src-DUhGoAQb.js";var t=e(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]);export{t};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,l as n,t as r,u as i}from"./vendor-react-BJ8SIkmN.js";import{t as a}from"./useQuery-DvovkaPT.js";import{C as o,K as s,P as c,S as l,V as u,f as d,j as f,m as p,q as m,t as h,w as g,x as _}from"./src-DUhGoAQb.js";import{C as v,S as y,_ as b,b as x,g as S,h as C,m as w,p as T,v as E,w as D,x as O,y as k}from"./vendor-ui-Dpw9mBc-.js";import{t as A}from"./arrow-left-wtNmm6Le.js";import{t as j}from"./code-Brz4KHlI.js";import{t as M}from"./globe-fwFSeXZn.js";import{t as N}from"./grip-vertical-Djo-yR-o.js";import{t as P}from"./layout-grid-DCVGg8ZA.js";import{t as ee}from"./save-Dewm93H6.js";import{t as F}from"./search-Ww0msJQz.js";import{t as I}from"./terminal-CIapYonS.js";import{t as L}from"./wrench-DZBtSPP8.js";import"./utils-DHTPP40O.js";import{D as R,E as z,K as B,O as V,R as H,T as U,V as te,f as ne,j as W,k as re,n as G,t as ie,w as K}from"./index-dc8HGqTp.js";import{t as q}from"./code-editor-x9L6nkh4.js";import{n as ae,t as oe}from"./cron-COUPKvGu.js";var J=e(t(),1),Y=r(),se={"cli-agent":B,bash:I,node:j,http:M,human:V,workflow:U},ce={"cli-agent":`Agent`,bash:`Bash`,node:`Node.js`,http:`HTTP`,human:`Human`,workflow:`Workflow`},X={"cli-agent":{border:`border-violet-500/50`,bg:`bg-violet-500/5`,badge:`bg-violet-500/15 text-violet-400`},bash:{border:`border-amber-500/50`,bg:`bg-amber-500/5`,badge:`bg-amber-500/15 text-amber-400`},node:{border:`border-emerald-500/50`,bg:`bg-emerald-500/5`,badge:`bg-emerald-500/15 text-emerald-400`},http:{border:`border-blue-500/50`,bg:`bg-blue-500/5`,badge:`bg-blue-500/15 text-blue-400`},human:{border:`border-orange-500/50`,bg:`bg-orange-500/5`,badge:`bg-orange-500/15 text-orange-400`},workflow:{border:`border-pink-500/50`,bg:`bg-pink-500/5`,badge:`bg-pink-500/15 text-pink-400`}};function Z({data:e,isLinkedAgent:t,isLinkedTeam:n}){return n?(0,Y.jsx)(R,{className:`h-4 w-4 shrink-0 text-muted-foreground`}):t?null:e.actionType===`cli-agent`&&e.cli?(0,Y.jsx)(G(e.cli),{className:`h-4 w-4 shrink-0 text-muted-foreground`}):(0,Y.jsx)(se[e.actionType]??B,{className:`h-4 w-4 shrink-0 text-muted-foreground`})}function le(e,t,n){return n?{border:`border-cyan-500/50`,bg:`bg-cyan-500/5`,badge:`bg-cyan-500/15 text-cyan-400`}:t?{border:`border-indigo-500/50`,bg:`bg-indigo-500/5`,badge:`bg-indigo-500/15 text-indigo-400`}:X[e]??X[`cli-agent`]}function ue(e,t,n){return n?`Team`:t?`Agent`:ce[e]}function de({data:e,selected:t}){let n=e.actionType,r=!!(n===`cli-agent`&&e.source===`agent`&&e.agentId),i=!!(n===`cli-agent`&&e.source===`team`&&e.teamId),a=le(n,r,i),o=pe(e),c=ue(n,r,i);return(0,Y.jsxs)(`div`,{className:s(`rounded-lg border-2 min-w-[200px] max-w-[260px] transition-all duration-150`,a.border,a.bg,t&&`ring-2 ring-primary ring-offset-1 ring-offset-background`),children:[(0,Y.jsx)(b,{type:`target`,position:y.Left,className:`!bg-muted-foreground !w-2.5 !h-2.5 !border-2 !border-background`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border/50`,children:[(0,Y.jsx)(N,{className:`h-3.5 w-3.5 text-muted-foreground/50 shrink-0 cursor-grab`}),r&&e.agentAvatar&&(0,Y.jsx)(`span`,{className:`text-base shrink-0`,children:e.agentAvatar}),!(r&&e.agentAvatar)&&(0,Y.jsx)(Z,{data:e,isLinkedAgent:r,isLinkedTeam:i}),(0,Y.jsx)(`span`,{className:`text-sm font-medium truncate flex-1`,children:e.label||`Untitled`}),(0,Y.jsx)(`span`,{className:s(`text-[10px] px-1.5 py-0.5 rounded-full font-medium`,a.badge),children:c})]}),(r||i)&&(0,Y.jsx)(`div`,{className:`px-3 py-1.5 border-b border-border/30`,children:(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r?`Agent: ${e.agentName??`Unknown`}`:`Team: ${e.teamName??`Unknown`}`})}),o&&(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground line-clamp-2`,children:o})}),(0,Y.jsx)(b,{type:`source`,position:y.Right,className:`!bg-muted-foreground !w-2.5 !h-2.5 !border-2 !border-background`})]})}function fe(e){if(e.source===`agent`&&e.agentId||e.source===`team`&&e.teamId)return e.prompt?e.prompt.slice(0,80):null;let t=e.skills?.length?e.skills.map(e=>e.startsWith(`/`)?e:`/${e}`).join(` `)+` `:``;return e.prompt?`${t}${e.prompt}`.slice(0,80):null}function pe(e){switch(e.actionType){case`cli-agent`:return fe(e);case`bash`:case`node`:return e.script?e.script.slice(0,80):null;case`http`:return e.httpUrl?`${e.httpMethod??`GET`} ${e.httpUrl}`.slice(0,80):null;case`human`:return e.prompt?e.prompt.slice(0,80):`Waiting for approval`;case`workflow`:return e.targetWorkflowName?`\u2192 ${e.targetWorkflowName}`:`Select a workflow`;default:return null}}var me=(0,J.memo)(de),he=[{type:`cli-agent`,label:`Agent`,icon:B,description:`Run an agent, team, or CLI with a prompt`},{type:`bash`,label:`Bash Script`,icon:I,description:`Execute a bash script`},{type:`node`,label:`Node.js`,icon:j,description:`Run a Node.js script`},{type:`http`,label:`HTTP Request`,icon:M,description:`Make an HTTP request`},{type:`human`,label:`Human`,icon:V,description:`Pause and wait for approval`},{type:`workflow`,label:`Workflow`,icon:U,description:`Trigger another workflow`}];function ge(e,t){e.dataTransfer.setData(`application/workflow-node-type`,t),e.dataTransfer.effectAllowed=`move`}function _e(){return(0,Y.jsxs)(`div`,{className:`w-56 border-r bg-card flex flex-col`,children:[(0,Y.jsx)(`div`,{className:`p-3 border-b`,children:(0,Y.jsx)(`h3`,{className:`text-xs font-semibold uppercase text-muted-foreground tracking-wider`,children:`Nodes`})}),(0,Y.jsx)(`div`,{className:`p-2 space-y-1.5 flex-1 overflow-y-auto`,children:he.map(({type:e,label:t,icon:n,description:r})=>(0,Y.jsxs)(`div`,{draggable:!0,onDragStart:t=>ge(t,e),className:`flex items-start gap-2.5 p-2.5 rounded-md border border-transparent hover:border-border hover:bg-accent/50 cursor-grab active:cursor-grabbing transition-colors select-none`,children:[(0,Y.jsx)(`div`,{className:`mt-0.5 p-1.5 rounded-md bg-muted`,children:(0,Y.jsx)(n,{className:`h-4 w-4 text-muted-foreground`})}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium leading-tight`,children:t}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground leading-snug mt-0.5`,children:r})]})]},e))})]})}function ve(e,t){if(!e.startsWith(`data: `))return{script:t,changed:!1};let n=JSON.parse(e.slice(6));if(n.type===`chunk`)return{script:t+n.content,changed:!0};if(n.type===`done`)return{script:n.script,changed:!0};if(n.type===`error`)throw Error(n.message);return{script:t,changed:!1}}function ye(e,t,n){let r=t;for(let t of e)try{let e=ve(t,r);e.changed&&(r=e.script,n(r))}catch(e){if(e instanceof SyntaxError)continue;throw e}return r}async function be(e,t){let n=e.body?.getReader();if(!n)throw Error(`No response stream`);let r=new TextDecoder,i=``,a=``;for(;;){let{done:e,value:o}=await n.read();if(e)break;i+=r.decode(o,{stream:!0});let s=i.split(`
|
|
2
|
-
`);i=s.pop()??``,a=ye(s,a,t)}return a}function xe({language:e,onGenerated:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(``),[s,c]=(0,J.useState)(!1),[d,f]=(0,J.useState)(``),[p,m]=(0,J.useState)(null),g=(0,J.useRef)(null),v=async()=>{if(!i.trim())return;c(!0),f(``),m(null);let t=new AbortController;g.current=t;try{let n=await fetch(`/api/workflows/generate-script`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({prompt:i.trim(),language:e}),signal:t.signal});if(!n.ok){let e=await n.json().catch(()=>({error:`Generation failed`}));throw Error(e.error??`HTTP ${n.status}`)}f(await be(n,f))}catch(e){if(e.name===`AbortError`)return;m(e instanceof Error?e.message:`Generation failed`)}finally{c(!1),g.current=null}},y=()=>{t(d),r(!1),a(``),f(``),m(null)},b=()=>{g.current&&=(g.current.abort(),null),c(!1)};return(0,Y.jsxs)(_,{open:n,onOpenChange:e=>{r(e),e||(b(),f(``),m(null))},children:[(0,Y.jsxs)(o,{className:`inline-flex items-center gap-1.5 text-xs h-7 px-2 rounded-md hover:bg-accent hover:text-accent-foreground cursor-pointer`,children:[(0,Y.jsx)(z,{className:`h-3.5 w-3.5`}),`Generate with AI`]}),(0,Y.jsx)(l,{className:`w-[480px] p-4`,side:`top`,align:`start`,children:(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`label`,{className:`text-sm font-medium`,children:[`Describe the `,e===`bash`?`Bash`:`Node.js`,` script you need`]}),(0,Y.jsx)(h,{value:i,onChange:e=>a(e.target.value),placeholder:`e.g. "Fetch all open PRs from GitHub and output their titles as JSON"`,rows:3,disabled:s,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!s&&(e.preventDefault(),v())}})]}),p&&(0,Y.jsx)(`div`,{className:`text-xs text-destructive bg-destructive/10 rounded-md p-2`,children:p}),d&&(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:`Preview`}),(0,Y.jsx)(`pre`,{className:`text-xs bg-muted rounded-md p-3 max-h-[200px] overflow-auto whitespace-pre-wrap font-mono`,children:d})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[s&&(0,Y.jsx)(u,{size:`sm`,variant:`outline`,onClick:b,children:`Cancel`}),!s&&d&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(u,{size:`sm`,variant:`outline`,onClick:v,children:`Regenerate`}),(0,Y.jsx)(u,{size:`sm`,onClick:y,children:`Use this script`})]}),!s&&!d&&(0,Y.jsx)(u,{size:`sm`,onClick:v,disabled:!i.trim(),children:`Generate`}),s&&(0,Y.jsxs)(u,{size:`sm`,disabled:!0,children:[(0,Y.jsx)(H,{className:`h-3.5 w-3.5 animate-spin mr-1.5`}),`Generating...`]})]})]})})]})}var Se={builtin:L,"user-skill":W,"workspace-command":I,"workspace-skill":te},Ce={builtin:`Built-in`,"user-skill":`User Skill`,"workspace-command":`Command`,"workspace-skill":`Workspace Skill`};function we({value:e,onChange:t,workspacePath:n,className:r}){let{t:i}=K(),[a,o]=(0,J.useState)([]),[l,u]=(0,J.useState)(!1),[d,p]=(0,J.useState)(!1),[h,g]=(0,J.useState)(``),_=(0,J.useRef)(null),v=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await m.chat.getCommands(n);e||(o(t),u(!1))}catch{e||u(!1)}})(),()=>{e=!0}},[n]),(0,J.useEffect)(()=>{let e=e=>{v.current&&!v.current.contains(e.target)&&p(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let y=(0,J.useMemo)(()=>a.filter(e=>e.enabled),[a]),b=(0,J.useMemo)(()=>{if(!h)return y;let e=h.toLowerCase();return y.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.source.toLowerCase().includes(e))},[y,h]),x=(0,J.useMemo)(()=>{let e=new Map;for(let t of b)e.has(t.source)||e.set(t.source,[]),e.get(t.source).push(t);return e},[b]),S=a.filter(t=>e.includes(t.name)),C=n=>{e.includes(n)?t(e.filter(e=>e!==n)):t([...e,n])},w=n=>{t(e.filter(e=>e!==n))},T=()=>{t([]),g(``)};return(0,Y.jsxs)(`div`,{ref:v,className:s(`relative`,r),children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{p(!d),d||setTimeout(()=>_.current?.focus(),50)},className:s(`flex min-h-9 w-full items-center rounded-md border border-input bg-background px-3 py-1.5 text-sm shadow-sm transition-colors`,`hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,e.length===0&&`text-muted-foreground`),children:[S.length>0?(0,Y.jsx)(`span`,{className:`flex flex-wrap items-center gap-1 flex-1 min-w-0`,children:S.map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs font-mono`,children:[(0,Y.jsx)(W,{className:`h-3 w-3 shrink-0 text-amber-500`}),e.name,(0,Y.jsx)(f,{className:`h-3 w-3 shrink-0 text-muted-foreground hover:text-foreground cursor-pointer`,onClick:t=>{t.stopPropagation(),w(e.name)}})]},e.name))}):(0,Y.jsx)(`span`,{className:`flex-1 text-left`,children:`Select skills...`}),e.length>0?(0,Y.jsx)(f,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground hover:text-foreground ml-1`,onClick:e=>{e.stopPropagation(),T()}}):(0,Y.jsx)(F,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),d&&(0,Y.jsxs)(`div`,{className:`absolute z-50 top-full mt-1 w-full rounded-md border bg-popover shadow-lg max-h-72 flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b`,children:[(0,Y.jsx)(F,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`input`,{ref:_,value:h,onChange:e=>g(e.target.value),placeholder:i(`skillSelect.searchPlaceholder`),className:`flex-1 text-sm bg-transparent outline-none placeholder:text-muted-foreground`})]}),(0,Y.jsxs)(`div`,{className:`overflow-auto flex-1 py-1`,children:[l&&(0,Y.jsx)(ne,{}),!l&&b.length===0&&(0,Y.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted-foreground text-center`,children:h?`No skills match your search`:`No skills available`}),!l&&b.length>0&&Array.from(x.entries()).map(([t,n])=>{let r=Se[t];return(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`px-3 py-1.5 text-[10px] font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5`,children:[(0,Y.jsx)(r,{className:`h-3 w-3`}),Ce[t]]}),n.map(t=>{let n=e.includes(t.name);return(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>C(t.name),className:s(`flex items-center gap-2 w-full px-3 py-1.5 text-left hover:bg-muted transition-colors`,n&&`bg-muted`),children:[(0,Y.jsx)(`span`,{className:s(`flex h-4 w-4 shrink-0 items-center justify-center rounded border`,n?`border-primary bg-primary text-primary-foreground`:`border-muted-foreground/30`),children:n&&(0,Y.jsx)(c,{className:`h-3 w-3`})}),(0,Y.jsx)(`span`,{className:`text-xs font-mono text-foreground shrink-0`,children:t.name}),(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground line-clamp-1`,children:t.description})]},t.name)})]},t)})]})]})]})}function Te({value:e,onChange:t}){let{t:n}=K(),{data:r}=a({queryKey:[`credentials`],queryFn:()=>m.credentials.list({page:1,pageSize:100}),staleTime:3e4}),i=r?.data??[];return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Credential`}),(0,Y.jsxs)(`select`,{value:e??``,onChange:e=>t(e.target.value),className:Q,children:[(0,Y.jsx)(`option`,{value:``,children:n(`nodeConfig.noCredential`)}),i.map(e=>(0,Y.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.type,`)`]},e.id))]}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:n(`nodeConfig.credentialHelp`)})]})}var Ee=[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`],Q=`flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,De={"cli-agent":{label:`Agent`,icon:B},bash:{label:`Bash Script`,icon:I},node:{label:`Node Script`,icon:j},http:{label:`HTTP Request`,icon:M},human:{label:`Human in the Loop`,icon:V},workflow:{label:`Sub-Workflow`,icon:U}};function Oe({node:e,workspacePath:t,onUpdate:n,onDelete:r,onClose:i}){let{t:o}=K(),s=e.data,c=s.actionType,l=De[c],_=l.icon,{data:v}=a({queryKey:[`workflows`,1,100],queryFn:()=>m.workflows.list({page:1,pageSize:100}),staleTime:6e4,enabled:c===`workflow`}),{data:y}=a({queryKey:[`agents`],queryFn:()=>m.agents.list({page:1,pageSize:100}),staleTime:3e4,enabled:c===`cli-agent`}),{data:b}=a({queryKey:[`teams`],queryFn:()=>m.teams.list({page:1,pageSize:100}),staleTime:3e4,enabled:c===`cli-agent`}),x=y?.data??[],S=b?.data??[],C=s.source??`manual`,w=`Instructions for the agent...`;C===`agent`?w=o(`nodeConfig.agentPromptPlaceholder`):C===`team`&&(w=o(`nodeConfig.teamPromptPlaceholder`));let T=t=>n(e.id,t);return(0,Y.jsxs)(`div`,{className:`w-80 border-l bg-card flex flex-col h-full`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between p-3 border-b`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(_,{className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:l.label})]}),(0,Y.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:i,children:(0,Y.jsx)(f,{className:`h-4 w-4`})})]}),(0,Y.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-3 space-y-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Name`}),(0,Y.jsx)(g,{value:s.label,onChange:e=>T({label:e.target.value}),placeholder:o(`nodeConfig.actionNamePlaceholder`)})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Type`}),(0,Y.jsxs)(`select`,{value:c,onChange:e=>T({actionType:e.target.value}),className:Q,children:[(0,Y.jsx)(`option`,{value:`cli-agent`,children:`Agent`}),(0,Y.jsx)(`option`,{value:`bash`,children:`Bash Script`}),(0,Y.jsx)(`option`,{value:`node`,children:`Node Script`}),(0,Y.jsx)(`option`,{value:`http`,children:`HTTP Request`}),(0,Y.jsx)(`option`,{value:`human`,children:`Human in the Loop`}),(0,Y.jsx)(`option`,{value:`workflow`,children:`Sub-Workflow`})]})]}),(0,Y.jsx)(p,{}),c===`cli-agent`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Source`}),(0,Y.jsx)(`div`,{className:`grid grid-cols-3 gap-1 mt-1`,children:[[`manual`,B,`CLI`],[`agent`,B,`Agent`],[`team`,R,`Team`]].map(([e,t,n])=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{let t={source:e,agentId:void 0,agentName:void 0,agentAvatar:void 0,teamId:void 0,teamName:void 0};T(e===`manual`?t:{...t,cli:void 0,model:void 0,skills:[]})},className:`flex items-center justify-center gap-1.5 px-2 py-1.5 rounded-md border text-xs font-medium transition-colors ${C===e?`border-primary bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-accent/50`}`,children:[(0,Y.jsx)(t,{className:`h-3.5 w-3.5`}),n]},e))})]}),C===`agent`&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Agent`}),(0,Y.jsxs)(`select`,{value:s.agentId??``,onChange:e=>{let t=x.find(t=>t.id===e.target.value);T({agentId:e.target.value||void 0,agentName:t?.name,agentAvatar:t?.avatar,label:t?.name??s.label,cli:t?.runtime===`cli`?t.cli??`cursor`:void 0,model:t?.model})},className:Q,children:[(0,Y.jsx)(`option`,{value:``,children:o(`nodeConfig.selectAgent`)}),x.map(e=>(0,Y.jsxs)(`option`,{value:e.id,children:[e.avatar,` `,e.name]},e.id))]}),s.agentId&&(()=>{let e=x.find(e=>e.id===s.agentId);return e?(0,Y.jsxs)(`div`,{className:`mt-2 p-2 rounded-md bg-muted/50 text-[11px] text-muted-foreground space-y-0.5`,children:[(0,Y.jsxs)(`div`,{children:[`Runtime: `,e.runtime===`cli`?e.cli??`CLI`:`API`]}),(0,Y.jsxs)(`div`,{children:[`Model: `,e.model]}),e.description&&(0,Y.jsx)(`div`,{className:`line-clamp-2`,children:e.description})]}):null})()]}),C===`team`&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Team`}),(0,Y.jsxs)(`select`,{value:s.teamId??``,onChange:e=>{let t=S.find(t=>t.id===e.target.value);T({teamId:e.target.value||void 0,teamName:t?.name,label:t?.name??s.label})},className:Q,children:[(0,Y.jsx)(`option`,{value:``,children:o(`nodeConfig.selectTeam`)}),S.map(e=>(0,Y.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.strategy,`)`]},e.id))]}),s.teamId&&(()=>{let e=S.find(e=>e.id===s.teamId);return e?(0,Y.jsxs)(`div`,{className:`mt-2 p-2 rounded-md bg-muted/50 text-[11px] text-muted-foreground space-y-0.5`,children:[(0,Y.jsxs)(`div`,{children:[`Strategy: `,e.strategy]}),(0,Y.jsxs)(`div`,{children:[`Members: `,e.agents.length]}),e.description&&(0,Y.jsx)(`div`,{className:`line-clamp-2`,children:e.description})]}):null})()]}),C===`manual`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`CLI`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(G(s.cli??`cursor`),{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Y.jsxs)(`select`,{value:s.cli??`cursor`,onChange:e=>T({cli:e.target.value,model:``}),className:Q+` flex-1`,children:[(0,Y.jsx)(`option`,{value:`cursor`,children:`Cursor`}),(0,Y.jsx)(`option`,{value:`claude`,children:`Claude Code`})]})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Model`}),(0,Y.jsxs)(`select`,{value:s.model??``,onChange:e=>T({model:e.target.value||void 0}),className:Q,children:[(0,Y.jsx)(`option`,{value:``,children:`Default`}),(s.cli??`cursor`)===`claude`?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`optgroup`,{label:`Opus 4.6`,children:(0,Y.jsx)(`option`,{value:`claude-opus-4-6`,children:`claude-opus-4-6`})}),(0,Y.jsx)(`optgroup`,{label:`Sonnet 4.6`,children:(0,Y.jsx)(`option`,{value:`claude-sonnet-4-6`,children:`claude-sonnet-4-6`})}),(0,Y.jsx)(`optgroup`,{label:`Haiku 4.5`,children:(0,Y.jsx)(`option`,{value:`claude-haiku-4-5-20251001`,children:`claude-haiku-4-5`})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`optgroup`,{label:`GPT 5.4`,children:[(0,Y.jsx)(`option`,{value:`gpt-5.4-xhigh`,children:`gpt-5.4-xhigh`}),(0,Y.jsx)(`option`,{value:`gpt-5.4-high`,children:`gpt-5.4-high`}),(0,Y.jsx)(`option`,{value:`gpt-5.4-medium`,children:`gpt-5.4-medium`}),(0,Y.jsx)(`option`,{value:`gpt-5.4-low`,children:`gpt-5.4-low`}),(0,Y.jsx)(`option`,{value:`gpt-5.4-mini-high`,children:`gpt-5.4-mini-high`}),(0,Y.jsx)(`option`,{value:`gpt-5.4-mini-medium`,children:`gpt-5.4-mini-medium`}),(0,Y.jsx)(`option`,{value:`gpt-5.4-mini-low`,children:`gpt-5.4-mini-low`}),(0,Y.jsx)(`option`,{value:`gpt-5.4-nano-medium`,children:`gpt-5.4-nano-medium`}),(0,Y.jsx)(`option`,{value:`gpt-5.4-nano-low`,children:`gpt-5.4-nano-low`})]}),(0,Y.jsxs)(`optgroup`,{label:`GPT 5.3 Codex`,children:[(0,Y.jsx)(`option`,{value:`gpt-5.3-codex-xhigh`,children:`gpt-5.3-codex-xhigh`}),(0,Y.jsx)(`option`,{value:`gpt-5.3-codex-high`,children:`gpt-5.3-codex-high`}),(0,Y.jsx)(`option`,{value:`gpt-5.3-codex`,children:`gpt-5.3-codex`}),(0,Y.jsx)(`option`,{value:`gpt-5.3-codex-low`,children:`gpt-5.3-codex-low`})]}),(0,Y.jsxs)(`optgroup`,{label:`GPT 5.2`,children:[(0,Y.jsx)(`option`,{value:`gpt-5.2-xhigh`,children:`gpt-5.2-xhigh`}),(0,Y.jsx)(`option`,{value:`gpt-5.2-high`,children:`gpt-5.2-high`}),(0,Y.jsx)(`option`,{value:`gpt-5.2`,children:`gpt-5.2`}),(0,Y.jsx)(`option`,{value:`gpt-5.2-low`,children:`gpt-5.2-low`})]}),(0,Y.jsxs)(`optgroup`,{label:`GPT 5.1`,children:[(0,Y.jsx)(`option`,{value:`gpt-5.1-high`,children:`gpt-5.1-high`}),(0,Y.jsx)(`option`,{value:`gpt-5.1`,children:`gpt-5.1`}),(0,Y.jsx)(`option`,{value:`gpt-5.1-low`,children:`gpt-5.1-low`})]}),(0,Y.jsx)(`optgroup`,{label:`GPT 5 Mini`,children:(0,Y.jsx)(`option`,{value:`gpt-5-mini`,children:`gpt-5-mini`})}),(0,Y.jsxs)(`optgroup`,{label:`Claude 4.6`,children:[(0,Y.jsx)(`option`,{value:`claude-4.6-opus-max-thinking`,children:`claude-4.6-opus-max-thinking`}),(0,Y.jsx)(`option`,{value:`claude-4.6-opus-max`,children:`claude-4.6-opus-max`}),(0,Y.jsx)(`option`,{value:`claude-4.6-opus-high-thinking`,children:`claude-4.6-opus-high-thinking`}),(0,Y.jsx)(`option`,{value:`claude-4.6-opus-high`,children:`claude-4.6-opus-high`}),(0,Y.jsx)(`option`,{value:`claude-4.6-sonnet-medium-thinking`,children:`claude-4.6-sonnet-medium-thinking`}),(0,Y.jsx)(`option`,{value:`claude-4.6-sonnet-medium`,children:`claude-4.6-sonnet-medium`})]}),(0,Y.jsxs)(`optgroup`,{label:`Claude 4.5`,children:[(0,Y.jsx)(`option`,{value:`claude-4.5-opus-high-thinking`,children:`claude-4.5-opus-high-thinking`}),(0,Y.jsx)(`option`,{value:`claude-4.5-opus-high`,children:`claude-4.5-opus-high`}),(0,Y.jsx)(`option`,{value:`claude-4.5-sonnet-thinking`,children:`claude-4.5-sonnet-thinking`}),(0,Y.jsx)(`option`,{value:`claude-4.5-sonnet`,children:`claude-4.5-sonnet`})]}),(0,Y.jsxs)(`optgroup`,{label:`Claude 4`,children:[(0,Y.jsx)(`option`,{value:`claude-4-sonnet-thinking`,children:`claude-4-sonnet-thinking`}),(0,Y.jsx)(`option`,{value:`claude-4-sonnet`,children:`claude-4-sonnet`})]}),(0,Y.jsxs)(`optgroup`,{label:`Composer`,children:[(0,Y.jsx)(`option`,{value:`composer-2`,children:`composer-2`}),(0,Y.jsx)(`option`,{value:`composer-2-fast`,children:`composer-2-fast`}),(0,Y.jsx)(`option`,{value:`composer-1.5`,children:`composer-1.5`})]})]})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Skills`}),(0,Y.jsx)(we,{value:s.skills??[],onChange:e=>T({skills:e}),workspacePath:t})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Prompt`}),(0,Y.jsx)(h,{value:s.prompt??``,onChange:e=>T({prompt:e.target.value}),placeholder:w,rows:6})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Bypass permissions`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`nodeConfig.bypassPermissionsHelp`)})]}),(0,Y.jsx)(d,{checked:s.trustMode??!0,onCheckedChange:e=>T({trustMode:e})})]})]}),c===`bash`&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Script`}),(0,Y.jsx)(xe,{language:`bash`,onGenerated:e=>T({script:e})})]}),(0,Y.jsx)(q,{value:s.script??``,onChange:e=>T({script:e}),language:`bash`,placeholder:`#!/bin/bash
|
|
3
|
-
echo 'Hello'`,minHeight:`160px`})]}),c===`node`&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Script`}),(0,Y.jsx)(xe,{language:`node`,onGenerated:e=>T({script:e})})]}),(0,Y.jsx)(q,{value:s.script??``,onChange:e=>T({script:e}),language:`javascript`,placeholder:`// Node.js ESM script
|
|
4
|
-
console.log('Hello');`,minHeight:`160px`})]}),c===`http`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Te,{value:s.credentialId,onChange:e=>T({credentialId:e||void 0})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Method`}),(0,Y.jsx)(`select`,{value:s.httpMethod??`GET`,onChange:e=>T({httpMethod:e.target.value}),className:Q,children:Ee.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`URL`}),(0,Y.jsx)(g,{value:s.httpUrl??``,onChange:e=>T({httpUrl:e.target.value}),placeholder:`https://api.example.com/endpoint`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Headers (JSON)`}),(0,Y.jsx)(q,{value:s.httpHeaders??``,onChange:e=>T({httpHeaders:e}),language:`json`,placeholder:`{"Content-Type": "application/json"}`,minHeight:`60px`})]}),(s.httpMethod??`GET`)!==`GET`&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Body`}),(0,Y.jsx)(q,{value:s.httpBody??``,onChange:e=>T({httpBody:e}),language:`json`,placeholder:`{"key": "value"}`,minHeight:`80px`})]})]}),c===`human`&&(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Instructions`}),(0,Y.jsx)(h,{value:s.prompt??``,onChange:e=>T({prompt:e.target.value}),placeholder:o(`nodeConfig.reviewerCheckPlaceholder`),rows:4}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:`The workflow will pause here and wait for human approval before continuing.`})]})}),c===`workflow`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Target Workflow`}),(0,Y.jsxs)(`select`,{value:s.targetWorkflowId??``,onChange:e=>{let t=v?.data.find(t=>t.id===e.target.value);T({targetWorkflowId:e.target.value||void 0,targetWorkflowName:t?.name})},className:Q,children:[(0,Y.jsx)(`option`,{value:``,children:`Select a workflow…`}),v?.data.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:`This node will trigger the selected workflow and wait for it to complete.`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Prompt Override`}),(0,Y.jsx)(h,{value:s.prompt??``,onChange:e=>T({prompt:e.target.value}),placeholder:o(`nodeConfig.subWorkflowPromptPlaceholder`),rows:3})]})]}),(0,Y.jsx)(p,{}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Timeout`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`nodeConfig.timeoutDescription`)})]}),(0,Y.jsx)(d,{checked:s.timeoutEnabled??!1,onCheckedChange:e=>T({timeoutEnabled:e,...e?{timeoutMs:s.timeoutMs??5}:{timeoutMs:void 0}})})]}),s.timeoutEnabled&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:o(`nodeConfig.durationMinutes`)}),(0,Y.jsx)(g,{type:`number`,min:1,value:s.timeoutMs??5,onChange:e=>{let t=parseInt(e.target.value,10);!isNaN(t)&&t>0&&T({timeoutMs:t})},placeholder:`5`})]})]}),(0,Y.jsx)(`div`,{className:`p-3 border-t`,children:(0,Y.jsxs)(u,{variant:`destructive`,size:`sm`,className:`w-full`,onClick:()=>r(e.id),children:[(0,Y.jsx)(re,{className:`h-3.5 w-3.5 mr-1.5`}),o(`nodeConfig.deleteNode`)]})})]})}function ke({id:e,sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:o,style:s,markerEnd:c,data:l}){let u=l?.hovered??!1,[d,p,m]=D({sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:o});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(w,{path:d,markerEnd:c,style:{...s,stroke:u?`#f87171`:s?.stroke,strokeWidth:u?2.5:s?.strokeWidth??2}}),u&&(0,Y.jsx)(S,{children:(0,Y.jsx)(`button`,{className:`nodrag nopan absolute flex items-center justify-center w-5 h-5 rounded-full bg-muted border border-border text-muted-foreground shadow-sm hover:bg-red-400/20 hover:text-red-400 hover:border-red-400/50 transition-colors cursor-pointer`,style:{transform:`translate(-50%, -50%) translate(${p}px, ${m}px)`,pointerEvents:`all`},onClick:()=>l?.onDelete?.(e),children:(0,Y.jsx)(f,{className:`h-3 w-3`})})})]})}var Ae={action:me},je={deletable:ke},Me=0;function Ne(){return`node_${++Me}_${Date.now()}`}var Pe={"cli-agent":{cli:`cursor`,prompt:``,skills:[]},bash:{script:``},node:{script:``},http:{httpMethod:`GET`,httpUrl:``,httpHeaders:``,httpBody:``},human:{prompt:``},workflow:{targetWorkflowId:``,prompt:``}},Fe={"cli-agent":`Agent`,bash:`Bash Script`,node:`Node.js Script`,http:`HTTP Request`,human:`Human`,workflow:`Workflow`};function Ie(e,t){let n=new Map;for(let t of e)n.set(t.id,[]);for(let e of t){let t=n.get(e.target);t&&t.push(e.source)}let r=new Map;for(let t of e)r.set(t.id,(n.get(t.id)??[]).length);let i=e.filter(e=>(r.get(e.id)??0)===0).map(e=>e.id),a=[];for(;i.length>0;){let e=i.shift();a.push(e);for(let n of t)if(n.source===e){let e=(r.get(n.target)??1)-1;r.set(n.target,e),e===0&&i.push(n.target)}}for(let t of e)a.includes(t.id)||a.push(t.id);return{sorted:a,incomingEdges:n}}function Le(e,t,n){let r={type:e.actionType,order:t,name:e.label||void 0,dependsOn:n,timeoutMs:e.timeoutEnabled&&e.timeoutMs?e.timeoutMs*6e4:void 0};switch(e.actionType){case`cli-agent`:{let t=e.skills?.length?e.skills.map(e=>`/${e}`).join(` `)+` `:``,n=t?`${t}${e.prompt??``}`.trim():e.prompt||void 0;return{...r,cli:e.cli||`cursor`,model:e.model||void 0,prompt:n,trustMode:e.trustMode??!0,agentId:e.source===`agent`&&e.agentId||void 0,teamId:e.source===`team`&&e.teamId||void 0}}case`bash`:case`node`:return{...r,script:e.script||void 0};case`http`:return{...r,httpMethod:e.httpMethod||`GET`,httpUrl:e.httpUrl||void 0,httpHeaders:e.httpHeaders||void 0,httpBody:e.httpBody||void 0,credentialId:e.credentialId||void 0};case`human`:return{...r,prompt:e.prompt||void 0};case`workflow`:return{...r,targetWorkflowId:e.targetWorkflowId||void 0,prompt:e.prompt||void 0}}}function Re(e,t){let n=new Map;for(let t of e)n.set(t.id,[]);for(let e of t){let t=n.get(e.target);t&&t.push(e.source)}return n}function ze(e,t){let n=new Map,r=[];for(let i of e)(t.get(i.id)??[]).length===0&&(n.set(i.id,0),r.push(i.id));for(;r.length>0;){let i=r.shift(),a=n.get(i);for(let o of e){let e=t.get(o.id)??[];e.includes(i)&&(n.set(o.id,Math.max(n.get(o.id)??0,a+1)),e.every(e=>n.has(e))&&!r.includes(o.id)&&r.push(o.id))}}for(let t of e)n.has(t.id)||n.set(t.id,0);let i=new Map;for(let t of e){let e=n.get(t.id);i.has(e)||i.set(e,[]),i.get(e).push(t.id)}return i}function Be(e,t){let n=ze(e,Re(e,t)),r=new Map;for(let[e,t]of n){let n=-((t.length-1)*140)/2;for(let i=0;i<t.length;i++)r.set(t[i],{x:100+e*350,y:n+i*140})}return r}function Ve({initialNodes:e=[],initialEdges:t=[],workspacePath:n,onActionsChange:r,canvasRef:i}){let a=(0,J.useRef)(null),[o,s]=(0,J.useState)(null),[c,l,d]=x(e),[f,p,m]=k(t),[h,g]=(0,J.useState)(null),[_,y]=(0,J.useState)(null),b=(0,J.useRef)(null),S=(0,J.useMemo)(()=>h?c.find(e=>e.id===h):null,[c,h]),w=(0,J.useCallback)(()=>{let e=new Map(c.map(e=>[e.id,e])),{sorted:t,incomingEdges:n}=Ie(c,f),r=new Map(t.map((e,t)=>[e,t]));return t.map((t,i)=>{let a=e.get(t).data,o=(n.get(t)??[]).map(e=>r.get(e)).filter(e=>e!==void 0);return Le(a,i,o.length>0?JSON.stringify(o):void 0)})},[c,f]);(0,J.useEffect)(()=>{i&&(i.current={getActions:w})},[i,w]);let D=(0,J.useCallback)(()=>{r&&setTimeout(()=>r(w()),0)},[r,w]),A=(0,J.useCallback)(e=>{p(t=>t.filter(t=>t.id!==e)),D()},[p,D]),j=(0,J.useMemo)(()=>f.map(e=>({...e,type:`deletable`,data:{...e.data,onDelete:A,hovered:e.id===_}})),[f,A,_]),M=(0,J.useCallback)(e=>{p(t=>v({...e,type:`deletable`,markerEnd:{type:O.ArrowClosed,width:16,height:16},style:{strokeWidth:2,stroke:`#6b7280`},animated:!0},t)),D()},[p,D]),N=(0,J.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),ee=(0,J.useCallback)(e=>{e.preventDefault();let t=e.dataTransfer.getData(`application/workflow-node-type`);if(!t||!o||!a.current)return;let n=o.screenToFlowPosition({x:e.clientX,y:e.clientY}),r={id:Ne(),type:`action`,position:n,data:{actionType:t,label:Fe[t],...Pe[t]}};l(e=>[...e,r]),g(r.id),D()},[o,l,D]),F=(0,J.useCallback)((e,t)=>{g(t.id)},[]),I=(0,J.useCallback)(()=>{g(null)},[]),L=(0,J.useCallback)((e,t)=>{l(n=>n.map(n=>n.id===e?{...n,data:{...n.data,...t}}:n)),D()},[l,D]),R=(0,J.useCallback)(e=>{l(t=>t.filter(t=>t.id!==e)),p(t=>t.filter(t=>t.source!==e&&t.target!==e)),g(null),D()},[l,p,D]),z=(0,J.useCallback)(()=>{l(e=>{if(e.length===0)return e;let t=Be(e,f);return e.map(e=>({...e,position:t.get(e.id)??e.position}))}),setTimeout(()=>o?.fitView({padding:.5,maxZoom:.7}),50),D()},[f,l,o,D]);return(0,Y.jsxs)(`div`,{className:`flex h-full w-full`,children:[(0,Y.jsx)(_e,{}),(0,Y.jsxs)(`div`,{className:`flex-1 relative`,ref:a,children:[c.length>1&&(0,Y.jsx)(`div`,{className:`absolute top-3 right-3 z-10`,children:(0,Y.jsxs)(u,{variant:`secondary`,size:`sm`,className:`h-8 shadow-md`,onClick:z,children:[(0,Y.jsx)(P,{className:`h-3.5 w-3.5 mr-1.5`}),`Tidy up`]})}),(0,Y.jsxs)(E,{nodes:c,edges:j,onNodesChange:e=>{d(e),D()},onEdgesChange:e=>{m(e),D()},onConnect:M,onInit:s,onDrop:ee,onDragOver:N,onEdgeMouseEnter:(e,t)=>{b.current&&=(clearTimeout(b.current),null),y(t.id)},onEdgeMouseLeave:()=>{b.current=setTimeout(()=>y(null),150)},onNodeClick:F,onPaneClick:I,nodeTypes:Ae,edgeTypes:je,fitView:!0,fitViewOptions:{padding:.5,maxZoom:.7},defaultViewport:{x:0,y:0,zoom:.6},proOptions:{hideAttribution:!0},deleteKeyCode:[`Backspace`,`Delete`],snapToGrid:!0,snapGrid:[16,16],minZoom:.2,maxZoom:2,edgesFocusable:!0,edgesReconnectable:!0,defaultEdgeOptions:{markerEnd:{type:O.ArrowClosed,width:16,height:16},style:{strokeWidth:2,stroke:`#6b7280`},animated:!0,interactionWidth:20},children:[(0,Y.jsx)(T,{gap:16,size:1,color:`hsl(var(--muted-foreground) / 0.08)`}),(0,Y.jsx)(C,{showInteractive:!1})]}),c.length===0&&(0,Y.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center pointer-events-none`,children:(0,Y.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,Y.jsx)(`p`,{className:`text-lg font-medium`,children:`Drag nodes from the palette`}),(0,Y.jsx)(`p`,{className:`text-sm mt-1`,children:`to start building your workflow`})]})})]}),S&&(0,Y.jsx)(Oe,{node:S,workspacePath:n,onUpdate:L,onDelete:R,onClose:()=>g(null)})]})}var $=`flex h-8 rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`;function He(){let{t:e}=K(),{id:t}=i(),r=n(),o=!t||t===`new`,s=(0,J.useRef)(null),[c,l]=(0,J.useState)(``),[f,h]=(0,J.useState)(``),[_,v]=(0,J.useState)(``),[y,b]=(0,J.useState)(`manual`),[x,S]=(0,J.useState)(``),[C,w]=(0,J.useState)(``),[T,E]=(0,J.useState)(``),[D,O]=(0,J.useState)(!1),[k,j]=(0,J.useState)(!1),[M,N]=(0,J.useState)(null),[P,F]=(0,J.useState)(o),{data:I=[]}=a({queryKey:[`workspaces`],queryFn:()=>m.workflows.getWorkspaces(),staleTime:6e4}),{data:L}=a({queryKey:[`workflows`,1,100],queryFn:()=>m.workflows.list({page:1,pageSize:100}),staleTime:3e4}),R=L?.data??[],{data:z}=a({queryKey:[`workflow`,t],queryFn:()=>m.workflows.get(t),enabled:!o&&!!t,staleTime:3e4}),{data:B}=a({queryKey:[`agents`],queryFn:()=>m.agents.list({page:1,pageSize:100}),staleTime:3e4,enabled:!o}),{data:V}=a({queryKey:[`teams`],queryFn:()=>m.teams.list({page:1,pageSize:100}),staleTime:3e4,enabled:!o});(0,J.useEffect)(()=>{if(o&&I.length>0&&!_){let e=I.find(e=>e.isDefault);e&&v(e.path)}},[o,I,_]);let[H,U]=(0,J.useState)([]),[ne,G]=(0,J.useState)([]);(0,J.useEffect)(()=>{if(!z||P)return;let e=z;l(e.name),h(e.description??``),v(e.workspace??``),E(e.cronExpression??``),O(e.summaryEnabled??!1);let t=e.triggers[0];t?(b(t.type),t.type===`event`?S(t.eventName??``):t.type===`workflow`&&w(t.sourceWorkflowId??``)):e.cronExpression?b(`cron`):b(`manual`);let{nodes:n,edges:r}=Je(e,B?.data??[],V?.data??[]);U(n),G(r),F(!0)},[z,P,B,V]);let q=()=>{switch(y){case`manual`:return[];case`workflow`:return C?[{type:`workflow`,sourceWorkflowId:C}]:[];case`event`:return x?[{type:`event`,eventName:x}]:[];case`cron`:return T?[{type:`cron`}]:[]}},se=async()=>{if(s.current){j(!0),N(null);try{let n=s.current.getActions(),i={name:c,description:f||void 0,workspace:_||null,cronExpression:y===`cron`&&T?T:null,summaryEnabled:D,triggers:q(),actions:n};o?(await m.workflows.create(i),r(`/workflows`)):(await m.workflows.update(t,i),ie.success(e(`workflowEdit.workflowSaved`)))}catch(e){N(e instanceof Error?e.message:`Failed to save workflow`)}finally{j(!1)}}},ce=async()=>{if(!(!t||o))try{await m.workflows.delete(t),r(`/workflows`)}catch(e){N(e instanceof Error?e.message:`Failed to delete workflow`)}},X=R.filter(e=>e.id!==t),Z=y===`cron`&&!!T&&!ae(T);return(0,Y.jsxs)(`div`,{className:`flex flex-col h-[calc(100vh-3.5rem)]`,children:[(0,Y.jsxs)(`div`,{className:`border-b bg-card px-4 py-2.5 flex items-center gap-3 shrink-0`,children:[(0,Y.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0`,onClick:()=>r(`/workflows`),children:(0,Y.jsx)(A,{className:`h-4 w-4`})}),(0,Y.jsx)(g,{value:c,onChange:e=>l(e.target.value),placeholder:e(`workflowEdit.namePlaceholder`),className:`h-8 max-w-[240px] font-medium`}),(0,Y.jsx)(g,{value:f,onChange:e=>h(e.target.value),placeholder:e(`workflowEdit.descriptionPlaceholder`),className:`h-8 max-w-[200px] text-sm`}),(0,Y.jsx)(p,{orientation:`vertical`,className:`h-6`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(te,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Y.jsx)(`select`,{value:_,onChange:e=>v(e.target.value),className:$+` max-w-[160px]`,children:I.map(e=>(0,Y.jsx)(`option`,{value:e.path,children:e.name},e.path))})]}),(0,Y.jsx)(p,{orientation:`vertical`,className:`h-6`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`workflowEdit.trigger`)}),(0,Y.jsxs)(`select`,{value:y,onChange:e=>b(e.target.value),className:$+` max-w-[130px]`,children:[(0,Y.jsx)(`option`,{value:`manual`,children:e(`workflowEdit.manual`)}),(0,Y.jsx)(`option`,{value:`workflow`,children:e(`workflowEdit.workflow`)}),(0,Y.jsx)(`option`,{value:`event`,children:e(`workflowEdit.event`)}),(0,Y.jsx)(`option`,{value:`cron`,children:e(`workflowEdit.cron`)})]}),y===`workflow`&&(0,Y.jsxs)(`select`,{value:C,onChange:e=>w(e.target.value),className:$+` max-w-[160px]`,children:[(0,Y.jsx)(`option`,{value:``,children:e(`workflowEdit.select`)}),X.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),y===`event`&&(0,Y.jsx)(g,{value:x,onChange:e=>S(e.target.value),placeholder:e(`workflowEdit.eventNamePlaceholder`),className:`h-8 max-w-[140px]`}),y===`cron`&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(g,{value:T,onChange:e=>E(e.target.value),placeholder:`*/5 * * * *`,className:`h-8 max-w-[120px] font-mono text-xs ${Z?`border-destructive`:``}`,spellCheck:!1}),T&&ae(T)&&(0,Y.jsx)(`span`,{className:`text-[11px] text-emerald-500 whitespace-nowrap`,children:oe(T)})]})]}),(0,Y.jsx)(p,{orientation:`vertical`,className:`h-6`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(W,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:e(`workflowEdit.aiSummary`)}),(0,Y.jsx)(d,{checked:D,onCheckedChange:O})]}),(0,Y.jsx)(`div`,{className:`flex-1`}),M&&(0,Y.jsx)(`span`,{className:`text-xs text-destructive max-w-[200px] truncate`,children:M}),!o&&(0,Y.jsxs)(u,{variant:`ghost`,size:`sm`,className:`h-8 text-destructive hover:text-destructive`,onClick:ce,children:[(0,Y.jsx)(re,{className:`h-3.5 w-3.5 mr-1`}),e(`workflowEdit.delete`)]}),(0,Y.jsxs)(u,{size:`sm`,className:`h-8`,onClick:se,disabled:k||!c||Z,children:[(0,Y.jsx)(ee,{className:`h-3.5 w-3.5 mr-1.5`}),e(k?`common.saving`:`common.save`)]})]}),(0,Y.jsx)(`div`,{className:`flex-1 min-h-0`,children:P&&(0,Y.jsx)(Ve,{initialNodes:H,initialEdges:ne,workspacePath:_||void 0,canvasRef:s})})]})}function Ue(e){let t=new Set(e.map(e=>e.id)),n=new Map,r=0;for(let i of e)if(i.dependsOn)try{let e=JSON.parse(i.dependsOn).filter(e=>t.has(e));n.set(i.id,e),r+=e.length}catch{n.set(i.id,[])}else n.set(i.id,[]);if(r===0&&e.length>1)for(let t=0;t<e.length;t++)n.set(e[t].id,t>0?[e[t-1].id]:[]);return{depsMap:n,validDepCount:r}}function We(e,t,n,r,i,a){for(let o of n){let n=r.get(o.id)??[];if(!n.includes(e))continue;let s=t+1;(!i.has(o.id)||i.get(o.id)<s)&&i.set(o.id,s),n.every(e=>i.has(e))&&!a.includes(o.id)&&a.push(o.id)}}function Ge(e,t){let n=new Map,r=[];for(let i of e)(t.get(i.id)??[]).length===0&&(n.set(i.id,0),r.push(i.id));for(;r.length>0;){let i=r.shift();We(i,n.get(i),e,t,n,r)}return n}function Ke(e,t){let n=Ge(e,t),r=new Map;for(let t of e){let e=n.get(t.id)??0;r.has(e)||r.set(e,[]),r.get(e).push(t)}return r}function qe(e,t,n){let r=e.prompt??``,i=r.match(/^((?:\/\S+\s*)+)/),a=i?i[1].trim().split(/\s+/).map(e=>e.replace(/^\//,``)):[],o=i?r.slice(i[0].length):r,s;s=e.teamId?`team`:e.agentId?`agent`:`manual`;let c=e.agentId?t.find(t=>t.id===e.agentId):void 0,l=e.teamId?n.find(t=>t.id===e.teamId):void 0;return{actionType:e.type,label:e.name??`Action ${e.order+1}`,source:s,agentId:e.agentId??void 0,agentName:c?.name,agentAvatar:c?.avatar,teamId:e.teamId??void 0,teamName:l?.name,cli:e.cli??`cursor`,model:e.model??``,prompt:o,skills:a,trustMode:e.trustMode!==!1,script:e.script??``,httpMethod:e.httpMethod??`GET`,httpUrl:e.httpUrl??``,httpHeaders:e.httpHeaders??``,httpBody:e.httpBody??``,credentialId:e.credentialId??void 0,targetWorkflowId:e.targetWorkflowId??``,timeoutEnabled:e.timeoutMs!=null,timeoutMs:e.timeoutMs==null?void 0:e.timeoutMs/6e4}}function Je(e,t=[],n=[]){let r=[...e.actions].sort((e,t)=>e.order-t.order),i=[],a=[],{depsMap:o}=Ue(r),s=Ke(r,o);for(let[e,r]of s){let s=-((r.length-1)*140)/2+200;for(let c=0;c<r.length;c++){let l=r[c],u=qe(l,t,n);i.push({id:l.id,type:`action`,position:{x:100+e*350,y:s+c*140},data:u});let d=o.get(l.id)??[];for(let e of d)a.push({id:`${e}->${l.id}`,source:e,target:l.id,markerEnd:{type:O.ArrowClosed,width:16,height:16},style:{strokeWidth:2,stroke:`#6b7280`},animated:!0})}}return{nodes:i,edges:a}}export{He as WorkflowEdit};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{d as t,h as n,r,t as i,u as a}from"./vendor-react-BJ8SIkmN.js";import{A as o,D as s,F as c,K as l,M as u,N as d,O as f,P as p,T as m,U as h,V as g,j as ee,k as _,q as v,t as te}from"./src-DUhGoAQb.js";import{S as y,_ as b,h as x,p as S,v as C}from"./vendor-ui-Dpw9mBc-.js";import{t as w}from"./arrow-left-wtNmm6Le.js";import{t as T}from"./circle-check-DLl9fl65.js";import{t as E}from"./circle-x-D_8Tcgt1.js";import{t as D}from"./code-Brz4KHlI.js";import{t as O}from"./globe-fwFSeXZn.js";import{t as ne}from"./play-DXJMtO-K.js";import{t as k}from"./terminal-CIapYonS.js";import{n as A,r as j,t as M}from"./utils-DHTPP40O.js";import{A as re,B as N,K as P,O as F,R as ie,S as ae,T as I,U as L,W as R,X as oe,Y as se,b as ce,d as le,j as ue,u as de,v as fe,w as pe,x as me}from"./index-dc8HGqTp.js";var z=c(`circle-pause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),he=c(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),B=c(`skip-forward`,[[`path`,{d:`M21 4v16`,key:`7j8fe9`}],[`path`,{d:`M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,key:`zs4d6`}]]),V=e(n(),1),H=i(),U={"cli-agent":P,bash:k,node:D,http:O,human:F,workflow:I},ge={"cli-agent":`Agent`,bash:`Bash`,node:`Node.js`,http:`HTTP`,human:`Human`,workflow:`Workflow`};function _e({status:e}){switch(e){case`running`:return(0,H.jsx)(ie,{className:`h-3.5 w-3.5 animate-spin text-blue-400`});case`completed`:return(0,H.jsx)(T,{className:`h-3.5 w-3.5 text-emerald-400`});case`failed`:return(0,H.jsx)(E,{className:`h-3.5 w-3.5 text-red-400`});case`skipped`:return(0,H.jsx)(B,{className:`h-3.5 w-3.5 text-muted-foreground`});case`waiting`:return(0,H.jsx)(z,{className:`h-3.5 w-3.5 animate-pulse text-orange-400`});case`approved`:return(0,H.jsx)(T,{className:`h-3.5 w-3.5 text-emerald-400`});case`rejected`:return(0,H.jsx)(E,{className:`h-3.5 w-3.5 text-red-400`});default:return(0,H.jsx)(L,{className:`h-3.5 w-3.5 text-muted-foreground`})}}var ve={pending:`border-muted-foreground/30`,running:`border-blue-500 shadow-blue-500/20 shadow-md`,completed:`border-emerald-500`,failed:`border-red-500`,skipped:`border-muted-foreground/20`,waiting:`border-orange-500 shadow-orange-500/20 shadow-md`,approved:`border-emerald-500 shadow-emerald-500/20 shadow-md`,rejected:`border-red-500`},W={pending:`bg-card`,running:`bg-blue-500/5`,completed:`bg-emerald-500/5`,failed:`bg-red-500/5`,skipped:`bg-muted/50`,waiting:`bg-orange-500/5`,approved:`bg-emerald-500/5`,rejected:`bg-red-500/5`};function G({status:e,durationMs:t,startedAt:n}){let[r,i]=(0,V.useState)(()=>Date.now());return(0,V.useEffect)(()=>{if(e!==`running`&&e!==`waiting`)return;let t=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(t)},[e]),t!=null&&t>0?(0,H.jsx)(`span`,{className:`text-[10px] font-mono tabular-nums text-muted-foreground`,children:j(t)}):(e===`running`||e===`waiting`)&&n?(0,H.jsx)(`span`,{className:`text-[10px] font-mono tabular-nums text-muted-foreground`,children:j(r-new Date(n).getTime())}):null}function ye({data:e}){let t=U[e.type]??P,n=e.status??`pending`;return(0,H.jsxs)(`div`,{className:l(`rounded-lg border-2 px-4 py-3 min-w-[180px] max-w-[240px] transition-all duration-300`,ve[n],W[n]),children:[(0,H.jsx)(b,{type:`target`,position:y.Left,className:`!bg-muted-foreground !w-2 !h-2`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,H.jsx)(t,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`text-xs font-medium truncate flex-1`,children:e.label}),(0,H.jsx)(_e,{status:n})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:ge[e.type]??e.type}),(0,H.jsx)(G,{status:n,durationMs:e.durationMs,startedAt:e.startedAt})]}),e.prompt&&(0,H.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1 line-clamp-2 italic`,children:e.prompt}),n===`waiting`&&(0,H.jsxs)(`div`,{className:`text-[10px] text-orange-400 mt-1.5 font-medium flex items-center gap-1 animate-pulse`,children:[(0,H.jsx)(z,{className:`h-3 w-3`}),`Awaiting approval`]}),n===`completed`&&e.output&&(0,H.jsx)(`div`,{className:`text-[10px] text-emerald-600 mt-1 line-clamp-2 font-mono`,children:e.output}),n===`failed`&&e.output&&(0,H.jsx)(`div`,{className:`text-[10px] text-red-500 mt-1 line-clamp-2 font-mono`,children:e.output}),(0,H.jsx)(b,{type:`source`,position:y.Right,className:`!bg-muted-foreground !w-2 !h-2`})]})}var be={action:ye};function xe(e){let t=new Set(e.map(e=>e.id)),n=new Map,r=0;for(let i of e)if(i.dependsOn)try{let e=JSON.parse(i.dependsOn).filter(e=>t.has(e));n.set(i.id,e),r+=e.length}catch{n.set(i.id,[])}else n.set(i.id,[]);if(r===0&&e.length>1){let t=[...e].sort((e,t)=>e.order-t.order);for(let e=0;e<t.length;e++)n.set(t[e].id,e>0?[t[e-1].id]:[])}return n}function Se(e,t){let n=new Map,r=[];for(let i of e)(t.get(i.id)??[]).length===0&&(n.set(i.id,0),r.push(i.id));for(;r.length>0;){let i=r.shift(),a=n.get(i);for(let o of e){let e=t.get(o.id)??[];if(!e.includes(i))continue;let s=a+1;(!n.has(o.id)||n.get(o.id)<s)&&n.set(o.id,s),e.every(e=>n.has(e))&&!r.includes(o.id)&&r.push(o.id)}}let i=new Map;for(let t of e){let e=n.get(t.id)??0;i.has(e)||i.set(e,[]),i.get(e).push(t)}return i}function Ce(e){let t=`#6b7280`;return e===`running`?t=`#3b82f6`:e===`completed`?t=`#10b981`:e===`failed`&&(t=`#ef4444`),{stroke:t,strokeWidth:2}}function we({actions:e,agentRuns:t,liveStatus:n,className:r}){let i=(0,V.useMemo)(()=>{let e=new Map;if(t)for(let n of t)e.set(n.actionId,n);return e},[t]),{nodes:a,edges:o}=(0,V.useMemo)(()=>{if(e.length===0)return{nodes:[],edges:[]};let t=xe(e),r=Se(e,t),a=[],o=[];for(let[e,s]of r){let r=-((s.length-1)*120)/2;for(let c=0;c<s.length;c++){let l=s[c],u=i.get(l.id),d=n?.get(l.id),f=d?.status??u?.status??`pending`,p=d?.output??u?.output??null,m=u?.startedAt&&u?.completedAt?M(u.startedAt,u.completedAt):null;a.push({id:l.id,type:`action`,position:{x:e*300,y:r+c*120},data:{label:l.name??`Action ${l.order+1}`,type:l.type,status:f,output:p?.slice(0,200),prompt:l.prompt?.slice(0,100),durationMs:m,startedAt:u?.startedAt??null}});for(let e of t.get(l.id)??[])o.push({id:`${e}->${l.id}`,source:e,target:l.id,animated:f===`running`,style:Ce(f)})}}return{nodes:a,edges:o}},[e,i,n]),s=(0,V.useCallback)(e=>{setTimeout(()=>e.fitView(),50)},[]);return e.length===0?(0,H.jsx)(`div`,{className:l(`flex items-center justify-center text-muted-foreground text-sm`,r),children:`No actions configured`}):(0,H.jsx)(`div`,{className:l(`w-full`,r),style:{height:`100%`},children:(0,H.jsxs)(C,{nodes:a,edges:o,nodeTypes:be,onInit:s,fitView:!0,proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!0,zoomOnScroll:!0,minZoom:.3,maxZoom:1.5,children:[(0,H.jsx)(S,{gap:20,size:1,color:`hsl(var(--muted-foreground) / 0.1)`}),(0,H.jsx)(x,{showInteractive:!1})]})})}function Te({status:e,className:t}){let n=l(`h-3.5 w-3.5 shrink-0`,t);switch(e){case`running`:return(0,H.jsx)(ie,{className:l(n,`animate-spin text-blue-400`)});case`completed`:case`approved`:return(0,H.jsx)(T,{className:l(n,`text-emerald-400`)});case`failed`:case`rejected`:return(0,H.jsx)(E,{className:l(n,`text-red-400`)});case`skipped`:return(0,H.jsx)(B,{className:l(n,`text-muted-foreground`)});case`waiting`:return(0,H.jsx)(z,{className:l(n,`animate-pulse text-orange-400`)});default:return(0,H.jsx)(L,{className:l(n,`text-muted-foreground/50`)})}}function K({startedAt:e,completedAt:t,status:n}){let[r,i]=(0,V.useState)(()=>Date.now());if((0,V.useEffect)(()=>{if(n!==`running`&&n!==`waiting`)return;let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[n]),!e)return null;let a=n===`running`||n===`waiting`,o=null;return t?o=M(e,t):a&&(o=r-new Date(e).getTime()),o==null?null:(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-mono tabular-nums`,children:j(o)})}function Ee(e){let t=new Set(e.map(e=>e.id)),n=new Map,r=0;for(let i of e)if(i.dependsOn)try{let e=JSON.parse(i.dependsOn).filter(e=>t.has(e));n.set(i.id,e),r+=e.length}catch{n.set(i.id,[])}else n.set(i.id,[]);if(r===0&&e.length>1){let t=[...e].sort((e,t)=>e.order-t.order);for(let e=0;e<t.length;e++)n.set(t[e].id,e>0?[t[e-1].id]:[])}return n}function De(e,t){let n=new Map,r=[];for(let i of e)(t.get(i.id)??[]).length===0&&(n.set(i.id,0),r.push(i.id));for(;r.length>0;){let i=r.shift(),a=n.get(i);for(let o of e){let e=t.get(o.id)??[];e.includes(i)&&(n.set(o.id,Math.max(n.get(o.id)??0,a+1)),e.every(e=>n.has(e))&&!r.includes(o.id)&&r.push(o.id))}}return n}function Oe(e){return De(e,Ee(e))}function q(e){return e.stream===`stderr`?`text-red-400/80`:e.text.startsWith(`💭 `)?`text-muted-foreground/50 italic`:e.text.startsWith(`⚙ `)?`text-amber-400/80`:e.text.startsWith(`→ `)?`text-muted-foreground/60`:e.text.startsWith(`⚡ `)?`text-blue-400/70`:`text-foreground/70`}var J={running:`bg-blue-500/5 hover:bg-blue-500/10`,completed:`hover:bg-muted/50`,approved:`hover:bg-muted/50`,failed:`bg-red-500/5 hover:bg-red-500/10`,rejected:`bg-red-500/5 hover:bg-red-500/10`,waiting:`bg-orange-500/5 hover:bg-orange-500/10`,pending:`hover:bg-muted/30`,skipped:`hover:bg-muted/30`};function Y({step:e}){return e.logs.length===0?e.agentRun?.output?(0,H.jsx)(`pre`,{className:l(`whitespace-pre-wrap break-all text-[11px] leading-relaxed px-3 py-1.5`,e.status===`failed`?`text-red-400/80`:`text-foreground/70`),children:e.agentRun.output}):e.status===`pending`?null:(0,H.jsx)(`div`,{className:`text-muted-foreground/40 text-[11px] px-3 py-1.5 italic`,children:`No logs`}):e.logs.map((e,t)=>(0,H.jsx)(`pre`,{className:l(`whitespace-pre-wrap break-all text-[11px] leading-relaxed px-3`,q(e)),children:e.text},e.id??t))}function X({step:e,isExpanded:t,onToggle:n}){let r=e.logs.length>0||e.agentRun?.output||e.status===`running`;return(0,H.jsxs)(`div`,{className:`border-b border-border/50 last:border-b-0`,children:[(0,H.jsxs)(`button`,{onClick:()=>n(e.action.id),className:l(`w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors`,J[e.status]??`hover:bg-muted/30`),children:[(0,H.jsx)(R,{className:l(`h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-150`,t&&`rotate-90`)}),(0,H.jsx)(Te,{status:e.status}),(0,H.jsx)(`span`,{className:`text-xs font-medium truncate flex-1`,children:e.action.name??`Step ${e.action.order+1}`}),(0,H.jsx)(K,{startedAt:e.agentRun?.startedAt,completedAt:e.agentRun?.completedAt,status:e.status})]}),t&&r&&(0,H.jsx)(`div`,{className:`bg-black/20 font-mono overflow-auto max-h-[300px] py-1`,children:(0,H.jsx)(Y,{step:e})})]},e.action.id)}function ke({agentRuns:e,actions:t,liveStatus:n,logEntries:r,runError:i,runStartedAt:a,runCompletedAt:o}){let[s,c]=(0,V.useState)(!1),[l,f]=(0,V.useState)(280),p=(0,V.useRef)(null),m=(0,V.useRef)(!1),h=(0,V.useRef)(0),ee=(0,V.useRef)(0),_=(0,V.useRef)(!0),[v,te]=(0,V.useState)({}),y=(0,V.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.id,n);return e},[t]),b=(0,V.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.actionId,n);return t},[e]),x=(0,V.useMemo)(()=>{let e=new Map;for(let t of r)e.has(t.actionId)||e.set(t.actionId,[]),e.get(t.actionId).push(t);return e},[r]),S=(0,V.useMemo)(()=>Oe(t),[t]),C=(0,V.useMemo)(()=>{let e=new Map;for(let n of t){let t=S.get(n.id)??0;e.has(t)||e.set(t,[]),e.get(t).push(n)}let r=[],i=[...e.keys()].sort((e,t)=>e-t);for(let t of i){let i=e.get(t),a=i.length>1;r.push({layer:t,isParallel:a,steps:i.map(e=>{let t=b.get(e.id);return{action:e,agentRun:t,status:n.get(e.id)?.status??t?.status??`pending`,logs:x.get(e.id)??[]}})})}return r},[t,S,b,n,x]),w=(0,V.useMemo)(()=>{let e=new Set;for(let t of C)for(let n of t.steps){let t=n.action.id;t in v?v[t]&&e.add(t):(n.status===`running`||n.status===`waiting`)&&e.add(t)}return e},[C,v]),T=C.some(e=>e.steps.some(e=>e.status===`running`)),{execDuration:D,hitlDuration:O}=(0,V.useMemo)(()=>{let t=0;for(let n of e)if(y.get(n.actionId)?.type===`human`&&n.startedAt){let e=n.completedAt??new Date().toISOString(),r=M(n.startedAt,e);r&&(t+=r)}let n=null;return a&&(n=o?M(a,o):A(a)),{execDuration:n==null?null:Math.max(0,n-t),hitlDuration:t>0?t:null}},[e,y,a,o]);(0,V.useEffect)(()=>{p.current&&!s&&_.current&&(p.current.scrollTop=p.current.scrollHeight)},[r.length,s]);let ne=()=>{if(!p.current)return;let{scrollTop:e,scrollHeight:t,clientHeight:n}=p.current;_.current=t-e-n<40},re=e=>{e.preventDefault(),m.current=!0,h.current=e.clientY,ee.current=l;let t=e=>{if(!m.current)return;let t=h.current-e.clientY;f(Math.max(100,Math.min(600,ee.current+t)))},n=()=>{m.current=!1,document.removeEventListener(`mousemove`,t),document.removeEventListener(`mouseup`,n)};document.addEventListener(`mousemove`,t),document.addEventListener(`mouseup`,n)},P=e=>{te(t=>({...t,[e]:!w.has(e)}))};return(0,H.jsxs)(`div`,{className:`border-t flex flex-col bg-background`,style:{height:s?`auto`:l},children:[!s&&(0,H.jsx)(`div`,{className:`h-1 cursor-row-resize hover:bg-primary/20 transition-colors`,onMouseDown:re}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b bg-muted/30`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,H.jsx)(k,{className:`h-3.5 w-3.5`}),(0,H.jsx)(`span`,{children:`Pipeline`}),T&&(0,H.jsx)(ie,{className:`h-3 w-3 animate-spin text-blue-400`}),D!=null&&(0,H.jsxs)(`span`,{className:`text-[10px] font-mono tabular-nums text-muted-foreground/70 ml-1`,children:[j(D),O!=null&&(0,H.jsxs)(`span`,{className:`text-orange-400/70`,children:[` + `,j(O),` HITL`]})]})]}),(0,H.jsx)(g,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>c(!s),children:s?(0,H.jsx)(u,{className:`h-3.5 w-3.5`}):(0,H.jsx)(d,{className:`h-3.5 w-3.5`})})]}),!s&&(0,H.jsxs)(`div`,{ref:p,onScroll:ne,className:`flex-1 overflow-auto`,children:[C.length===0?(0,H.jsx)(`div`,{className:`text-muted-foreground text-center py-4 text-xs`,children:`No steps available`}):C.map(e=>e.isParallel?(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1 bg-muted/20 border-b border-border/30`,children:[(0,H.jsx)(N,{className:`h-3 w-3 text-muted-foreground/50`}),(0,H.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/60 font-medium`,children:[`Parallel · `,e.steps.length,` steps`]})]}),(0,H.jsx)(`div`,{className:`border-l-2 border-muted-foreground/15 ml-3`,children:e.steps.map(e=>(0,H.jsx)(X,{step:e,isExpanded:w.has(e.action.id),onToggle:P},e.action.id))})]},`layer-${e.layer}`):e.steps.map(e=>(0,H.jsx)(X,{step:e,isExpanded:w.has(e.action.id),onToggle:P},e.action.id))),i&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 px-3 py-2 border-t border-red-500/20 bg-red-500/5`,children:[(0,H.jsx)(E,{className:`h-3.5 w-3.5 shrink-0`}),(0,H.jsx)(`span`,{className:`text-xs font-semibold`,children:`Pipeline Error`}),(0,H.jsx)(`span`,{className:`text-xs`,children:i})]})]})]})}function Ae(e){switch(e){case`completed`:return`default`;case`running`:return`secondary`;case`failed`:return`destructive`;default:return`outline`}}function je(e,t){return t?j(new Date(t).getTime()-new Date(e).getTime()):`running...`}function Me(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Ne(){let{t:e}=pe(),{id:n}=a(),[i]=t(),c=i.get(`run`),[u,y]=(0,V.useState)([]),[b,x]=(0,V.useState)(0),[S,C]=(0,V.useState)(1),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(null),[k,A]=(0,V.useState)(null),[j,M]=(0,V.useState)(!0),[N,P]=(0,V.useState)([]),I=(0,V.useRef)(null),[L,R]=(0,V.useState)(!1),z=(0,V.useRef)(new Map),{liveStatus:B}=ae(D),{logEntries:U}=me(D),ge=(0,V.useMemo)(()=>{if(N.length===0)return U;if(U.length===0)return N;let e=N[N.length-1]?.timestamp??``,t=U.filter(t=>t.timestamp>e);return[...N,...t]},[N,U]),_e=(0,V.useCallback)(e=>{if(z.current.has(e))return;let t=v.workflows.getRun(e);z.current.set(e,t),setTimeout(()=>z.current.delete(e),3e4)},[]);(0,V.useEffect)(()=>{I.current=D},[D]),(0,V.useEffect)(()=>{n&&Promise.all([v.workflows.get(n),v.workflows.getRuns(n,{page:S,pageSize:20})]).then(([e,t])=>{if(E(e),y(t.data),x(t.total),S===1&&!D&&!c){let e=t.data.find(e=>e.status===`running`);e?O(e.id):t.data.length>0&&O(t.data[0].id)}}).catch(()=>{}).finally(()=>M(!1))},[n,S,c,D]),(0,V.useEffect)(()=>{c&&c!==D&&O(c)},[c,D]),(0,V.useEffect)(()=>{if(!D){A(null),P([]);return}R(!0),A(null),P([]);let e=z.current.get(D)??v.workflows.getRun(D);z.current.delete(D),e.then(e=>{I.current===D&&(A(e),R(!1))}).catch(()=>{I.current===D&&R(!1)}),v.workflows.getRunLogs(D,{page:1,pageSize:200}).then(e=>{I.current===D&&P(e.data)}).catch(()=>{})},[D]),ce(n??null,(0,V.useCallback)(e=>{if(e.type===`workflow-started`&&e.runId&&(I.current=e.runId,O(e.runId),P([]),C(1),n&&v.workflows.getRuns(n,{page:1,pageSize:20}).then(e=>{y(e.data),x(e.total)}).catch(()=>{})),(e.type===`workflow-completed`||e.type===`workflow-failed`)&&e.runId){let t=I.current;e.runId===t&&v.workflows.getRun(t).then(A).catch(()=>{}),n&&v.workflows.getRuns(n,{page:1,pageSize:20}).then(e=>{y(e.data),x(e.total)}).catch(()=>{})}},[n]));let[ve,W]=(0,V.useState)(!1),[G,ye]=(0,V.useState)(``),be=(0,V.useCallback)(()=>{ye(``),W(!0)},[]),xe=(0,V.useCallback)(e=>{setTimeout(()=>{v.workflows.getRuns(e,{page:1,pageSize:20}).then(e=>{y(e.data),x(e.total)}).catch(()=>{})},1500)},[]),Se=(0,V.useCallback)(()=>{if(!n)return;let e=G.trim()?{prompt:G.trim()}:void 0;W(!1),v.workflows.trigger(n,e).then(()=>xe(n)).catch(e=>console.error(`Failed to trigger:`,e))},[n,G,xe]),[Ce,Te]=(0,V.useState)(null),[K,Ee]=(0,V.useState)(null),De=(0,V.useCallback)(async e=>{if(K!==e){Te(null),Ee(e);try{await v.workflows.cancelRun(e),v.workflows.getRun(e).then(A).catch(()=>{}),n&&v.workflows.getRuns(n,{page:S,pageSize:20}).then(e=>{y(e.data),x(e.total)}).catch(()=>{})}catch(e){let t=e instanceof Error?e.message:`Failed to cancel run`;Te(t),console.error(`Failed to cancel run:`,t)}finally{Ee(null)}}},[n,K,S]),Oe=(0,V.useCallback)(async e=>{try{await v.workflows.replayRun(e),setTimeout(()=>{n&&v.workflows.getRuns(n,{page:1,pageSize:20}).then(e=>{y(e.data),x(e.total)}).catch(()=>{})},1500)}catch(e){console.error(`Failed to replay run:`,e)}},[n]),[q,J]=(0,V.useState)(``),[Y,X]=(0,V.useState)(!1),[Ne,Z]=(0,V.useState)(!1),[Pe,Q]=(0,V.useState)(null),[Fe,Ie]=(0,V.useState)(!1),[Le,Re]=(0,V.useState)(!0),$=(0,V.useMemo)(()=>{if(!k||!T)return null;for(let[e,t]of B)if(t.status===`waiting`){let n=T.actions.find(t=>t.id===e);return{actionId:e,prompt:t.prompt??n?.prompt??`Approval required`,actionName:n?.name??`Action`}}for(let e of k.agentRuns)if(e.status===`waiting`&&!B.has(e.actionId)){let t=T.actions.find(t=>t.id===e.actionId);return{actionId:e.actionId,prompt:t?.prompt??`Approval required`,actionName:t?.name??`Action`}}return null},[B,k,T]),ze=(0,V.useRef)(null);(0,V.useEffect)(()=>{$&&$.actionId!==ze.current&&(ze.current=$.actionId,J(``),Q(null)),$||(ze.current=null,Z(!1))},[$]);let Be=(0,V.useCallback)(()=>{!k||!$||(Ie(!0),Q(null),v.workflows.getRunSummary(k.id,$.actionId).then(e=>Q(e.summary)).catch(()=>Q(`Failed to generate summary.`)).finally(()=>Ie(!1)))},[k,$]),Ve=(0,V.useCallback)(async()=>{if(!(!k||!$)){X(!0),oe(k.id,$.actionId,`approved`);try{await v.workflows.approveHumanAction(k.id,$.actionId,q.trim()||void 0),J(``),Z(!1)}catch(e){console.error(`Failed to approve:`,e)}finally{X(!1)}}},[k,$,q]),He=(0,V.useCallback)(async()=>{if(!(!k||!$)){X(!0),oe(k.id,$.actionId,`rejected`);try{await v.workflows.rejectHumanAction(k.id,$.actionId,q.trim()||void 0),J(``),Z(!1)}catch(e){console.error(`Failed to reject:`,e)}finally{X(!1)}}},[k,$,q]);return(0,H.jsxs)(`div`,{className:`flex h-full`,children:[(0,H.jsxs)(`div`,{className:`w-72 border-r flex flex-col shrink-0`,children:[(0,H.jsxs)(`div`,{className:`p-4 border-b space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(r,{to:`/workflows`,children:(0,H.jsx)(g,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,children:(0,H.jsx)(w,{className:`h-4 w-4`})})}),(0,H.jsx)(`h2`,{className:`text-sm font-semibold truncate flex-1`,children:T?.name??`Workflow`})]}),(0,H.jsxs)(g,{size:`sm`,onClick:be,className:`w-full gap-2`,disabled:j,children:[(0,H.jsx)(ne,{className:`h-3.5 w-3.5`}),`Trigger Run`]})]}),(0,H.jsxs)(`div`,{className:`flex-1 overflow-auto`,children:[j&&(0,H.jsx)(le,{count:5}),!j&&(u.length===0?(0,H.jsx)(`div`,{className:`p-4 text-xs text-muted-foreground text-center`,children:`No runs yet. Trigger a run to get started.`}):(0,H.jsxs)(`div`,{className:`divide-y flex flex-col`,children:[u.map(t=>(0,H.jsxs)(`button`,{onMouseEnter:()=>{t.id!==D&&_e(t.id)},onClick:()=>{D&&se(D),O(t.id),P([])},className:l(`w-full text-left px-4 py-3 text-xs hover:bg-muted/50 transition-colors`,D===t.id&&`bg-muted`),children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,H.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:t.id.slice(0,8)}),(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t.status===`running`&&(K===t.id?(0,H.jsx)(`span`,{className:`text-[10px] text-muted-foreground animate-pulse`,children:e(`workflowRuns.stopping`)}):(0,H.jsx)(`button`,{onClick:e=>{e.stopPropagation(),De(t.id)},className:`text-destructive hover:text-destructive/80 transition-colors`,title:e(`common.stopRun`),children:(0,H.jsx)(re,{className:`h-3 w-3`})})),(0,H.jsx)(h,{variant:Ae(t.status),className:`text-[10px] px-1.5 py-0`,children:t.status})]})]}),(0,H.jsxs)(`div`,{className:`flex justify-between text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:Me(t.startedAt)}),(0,H.jsx)(`span`,{children:je(t.startedAt,t.completedAt)})]})]},t.id)),(0,H.jsx)(fe,{page:S,totalPages:Math.ceil(b/20),total:b,pageSize:20,onPageChange:C,compact:!0,className:`py-2`})]}))]})]}),(0,H.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0`,children:[L&&(0,H.jsx)(de,{}),!L&&k&&T?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`px-4 py-3 border-b flex items-center gap-3`,children:[(0,H.jsx)(h,{variant:Ae(k.status),children:k.status}),k.status===`running`&&(0,H.jsxs)(g,{size:`sm`,variant:`destructive`,className:`gap-1.5`,disabled:K===k.id,onClick:()=>De(k.id),children:[(0,H.jsx)(re,{className:`h-3 w-3`}),K===k.id?`Stopping…`:`Stop`]}),k.status!==`running`&&(0,H.jsxs)(g,{size:`sm`,variant:`outline`,className:`gap-1.5`,onClick:()=>Oe(k.id),children:[(0,H.jsx)(he,{className:`h-3 w-3`}),`Replay`]}),(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Started `,Me(k.startedAt)]}),k.completedAt&&(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Duration: `,je(k.startedAt,k.completedAt)]}),(k.error||Ce)&&(0,H.jsx)(`span`,{className:`text-xs text-destructive truncate flex-1`,children:Ce??k.error})]}),$&&(0,H.jsxs)(`div`,{className:`px-4 py-2.5 border-b bg-orange-500/5 border-orange-500/20 flex items-center gap-3`,children:[(0,H.jsx)(`div`,{className:`h-7 w-7 rounded-full bg-orange-500/15 flex items-center justify-center shrink-0`,children:(0,H.jsx)(F,{className:`h-3.5 w-3.5 text-orange-400`})}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-orange-400`,children:`Waiting for approval`}),(0,H.jsx)(h,{variant:`outline`,className:`text-[10px] border-orange-500/30 text-orange-400`,children:$.actionName}),(0,H.jsx)(`div`,{className:`flex-1`}),(0,H.jsxs)(g,{size:`sm`,className:`gap-1.5 h-7 bg-orange-500 hover:bg-orange-600 text-white`,onClick:()=>Z(!0),children:[(0,H.jsx)(F,{className:`h-3 w-3`}),`Review`]})]}),(0,H.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,H.jsx)(we,{actions:T.actions,agentRuns:k.agentRuns,liveStatus:B,className:`h-full`})}),(0,H.jsx)(ke,{agentRuns:k.agentRuns,actions:T.actions,liveStatus:B,logEntries:ge,runError:k.error,runStartedAt:k.startedAt,runCompletedAt:k.completedAt})]}):(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:u.length>0?`Select a run to view execution graph`:`No runs to display`})]}),(0,H.jsx)(m,{open:ve,onOpenChange:W,children:(0,H.jsxs)(s,{className:`sm:max-w-md`,children:[(0,H.jsx)(_,{children:(0,H.jsx)(o,{children:e(`workflowRuns.runWorkflow`)})}),(0,H.jsx)(te,{placeholder:e(`workflowRuns.promptPlaceholder`),value:G,onChange:e=>ye(e.target.value),rows:4,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),Se())}}),(0,H.jsxs)(f,{children:[(0,H.jsx)(g,{variant:`outline`,onClick:()=>W(!1),children:`Cancel`}),(0,H.jsxs)(g,{onClick:Se,className:`gap-1.5`,children:[(0,H.jsx)(ne,{className:`h-3 w-3`}),`Run`]})]})]})}),(0,H.jsx)(m,{open:Ne,onOpenChange:Z,children:(0,H.jsxs)(s,{className:`sm:max-w-lg max-h-[85vh] flex flex-col`,children:[(0,H.jsx)(_,{children:(0,H.jsxs)(o,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`h-8 w-8 rounded-full bg-orange-500/15 flex items-center justify-center`,children:(0,H.jsx)(F,{className:`h-4 w-4 text-orange-400`})}),(0,H.jsx)(`div`,{children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[`Approval Required`,$&&(0,H.jsx)(h,{variant:`outline`,className:`text-[10px] border-orange-500/30 text-orange-400 font-normal`,children:$.actionName})]})})]})}),(0,H.jsxs)(`div`,{className:`flex-1 overflow-y-auto space-y-4`,children:[$&&(0,H.jsxs)(`div`,{className:`rounded-md border bg-muted/30 p-3`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Instructions`}),(0,H.jsx)(`p`,{className:`text-sm`,children:$.prompt})]}),T?.summaryEnabled&&(0,H.jsxs)(H.Fragment,{children:[!Pe&&!Fe&&(0,H.jsxs)(g,{variant:`outline`,size:`sm`,className:`gap-1.5 text-purple-400 border-purple-500/30 hover:bg-purple-500/10 hover:text-purple-300`,onClick:Be,children:[(0,H.jsx)(ue,{className:`h-3.5 w-3.5`}),`Generate AI Summary`]}),Fe&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 py-3 justify-center text-xs text-muted-foreground rounded-md border border-purple-500/20 bg-purple-500/5`,children:[(0,H.jsx)(ie,{className:`h-3.5 w-3.5 animate-spin text-purple-400`}),`Generating summary via Cursor (gpt-5-mini)...`]}),Pe&&!Fe&&(0,H.jsxs)(`div`,{className:`rounded-md border border-purple-500/20 bg-purple-500/5`,children:[(0,H.jsxs)(`button`,{onClick:()=>Re(!Le),className:`w-full flex items-center gap-2 p-3 text-left hover:bg-purple-500/10 transition-colors rounded-t-md`,children:[(0,H.jsx)(ue,{className:`h-3.5 w-3.5 text-purple-400 shrink-0`}),(0,H.jsx)(`span`,{className:`text-xs font-medium text-purple-400 flex-1`,children:`AI Summary`}),(0,H.jsx)(d,{className:l(`h-3.5 w-3.5 text-purple-400 transition-transform`,Le&&`rotate-180`)})]}),Le&&(0,H.jsx)(`div`,{className:`px-3 pb-3 border-t border-purple-500/10`,children:(0,H.jsx)(`div`,{className:`text-sm text-foreground/90 whitespace-pre-wrap pt-2 leading-relaxed`,children:Pe})})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Response (optional)`}),(0,H.jsx)(te,{placeholder:e(`workflowRuns.responsePlaceholder`),value:q,onChange:e=>J(e.target.value),rows:3,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),Ve())},disabled:Y,className:`mt-1`})]})]}),(0,H.jsxs)(f,{className:`flex-row gap-2 sm:gap-2`,children:[(0,H.jsxs)(g,{variant:`destructive`,className:`flex-1 gap-1.5`,onClick:He,disabled:Y,children:[(0,H.jsx)(ee,{className:`h-3.5 w-3.5`}),`Reject`]}),(0,H.jsxs)(g,{className:`flex-1 gap-1.5 bg-emerald-600 hover:bg-emerald-700`,onClick:Ve,disabled:Y,children:[(0,H.jsx)(p,{className:`h-3.5 w-3.5`}),`Approve`]})]})]})})]})}export{Ne as WorkflowRuns};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{h as t,l as n,r,t as i}from"./vendor-react-BJ8SIkmN.js";import{r as a,t as o}from"./useQuery-DvovkaPT.js";import{A as s,B as c,D as l,F as u,H as d,I as f,K as p,L as m,O as ee,T as h,U as g,V as _,k as te,p as v,q as y,t as b,z as x}from"./src-DUhGoAQb.js";import{t as S}from"./copy-C87mjn_Y.js";import{t as C}from"./history-CyBBboEp.js";import{t as w}from"./layout-grid-DCVGg8ZA.js";import{t as T}from"./play-DXJMtO-K.js";import"./utils-DHTPP40O.js";import{C as E,P as D,V as O,k,o as ne,v as A,w as j}from"./index-dc8HGqTp.js";import{t as M}from"./cron-COUPKvGu.js";var N=u(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),re=u(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),P=e(t(),1),F=i(),I={"cli-agent":`#8b5cf6`,bash:`#f59e0b`,node:`#10b981`,http:`#3b82f6`,human:`#f97316`,workflow:`#ec4899`},L={"cli-agent":`M2 6a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6Zm4 1.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm5-1a1 1 0 1 1-2 0 1 1 0 0 1 2 0ZM5.5 10.5h5`,bash:`M3 3l4 4-4 4M9 11h4`,node:`M4 12l-2-2 2-2M10 4l2 2-2 2M8 3l-2 10`,http:`M7 1a6 6 0 1 0 0 12A6 6 0 0 0 7 1ZM1 7h12M7 1c-1.7 2-2.5 4-2.5 6s.8 4 2.5 6M7 1c1.7 2 2.5 4 2.5 6s-.8 4-2.5 6`,human:`M9 11l2 2 4-4M2 13a4 4 0 0 1 8 0M6 4a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z`,workflow:`M7 2v4M7 12v2M3 6a2 2 0 1 0 0 4 2 2 0 0 0 0-4ZM11 6a2 2 0 1 0 0 4 2 2 0 0 0 0-4ZM5 8H3M11 8h-1M7 6V8`},R=26,z=20,B=11,V=42,H=28,U=80,W=40,G=4;function K(e){let t=new Set(e.map(e=>e.id)),n=new Map,r=0;for(let i of e)if(i.dependsOn)try{let e=JSON.parse(i.dependsOn).filter(e=>t.has(e));n.set(i.id,e),r+=e.length}catch{n.set(i.id,[])}else n.set(i.id,[]);if(r===0&&e.length>1)for(let t=0;t<e.length;t++)n.set(e[t].id,t>0?[e[t-1].id]:[]);return n}function q(e,t){let n=new Map,r=[];for(let i of e)(t.get(i.id)??[]).length===0&&(n.set(i.id,0),r.push(i.id));return{layers:n,queue:r}}function J(e,t){let{layers:n,queue:r}=q(e,t);for(;r.length>0;){let i=r.shift(),a=n.get(i);for(let o of e){let e=t.get(o.id)??[];e.includes(i)&&(n.set(o.id,Math.max(n.get(o.id)??0,a+1)),e.every(e=>n.has(e))&&!r.includes(o.id)&&r.push(o.id))}}for(let t of e)n.has(t.id)||n.set(t.id,0);return n}function Y(e,t){let n=new Map;for(let r of e){let e=t.get(r.id);n.has(e)||n.set(e,[]),n.get(e).push(r)}return n}function ie(e,t){let n=Y(e,J(e,t)),r=new Map;for(let[e,t]of n){let n=-((t.length-1)*H)/2;for(let i=0;i<t.length;i++)r.set(t[i].id,{x:U+R/2+e*V,y:n+i*H})}let i=1/0,a=-1/0,o=0;for(let e of r.values())e.y<i&&(i=e.y),e.y>a&&(a=e.y),e.x>o&&(o=e.x);let s=W+z/2-i;for(let e of r.values())e.y+=s;return a+=s,{positions:r,svgW:o+R/2+U,svgH:a+z/2+W}}var X=(0,P.memo)(function({actions:e,height:t=64,className:n}){if(e.length===0)return null;let r=[...e].sort((e,t)=>e.order-t.order),i=K(r),{positions:a,svgW:o,svgH:s}=ie(r,i);return(0,F.jsxs)(`svg`,{viewBox:`0 0 ${o} ${s}`,className:n,style:{width:`100%`,height:t},preserveAspectRatio:`xMidYMid meet`,children:[(0,F.jsx)(`defs`,{children:(0,F.jsx)(`pattern`,{id:`minimap-dots`,x:`0`,y:`0`,width:`16`,height:`16`,patternUnits:`userSpaceOnUse`,children:(0,F.jsx)(`circle`,{cx:`8`,cy:`8`,r:`0.8`,fill:`currentColor`,opacity:`0.08`})})}),(0,F.jsx)(`rect`,{width:o,height:s,fill:`url(#minimap-dots)`}),r.map(e=>{let t=a.get(e.id);return t?(i.get(e.id)??[]).map(n=>{let r=a.get(n);if(!r)return null;let i=r.x+R/2,o=r.y,s=t.x-R/2,c=t.y,l=(i+s)/2;return(0,F.jsx)(`path`,{d:`M${i},${o} C${l},${o} ${l},${c} ${s},${c}`,fill:`none`,stroke:`currentColor`,strokeOpacity:.2,strokeWidth:1.5},`${n}->${e.id}`)}):null}),r.map(e=>{let t=a.get(e.id);if(!t)return null;let n=I[e.type]??`#6b7280`,r=L[e.type];return(0,F.jsxs)(`g`,{children:[(0,F.jsx)(`rect`,{x:t.x-R/2,y:t.y-z/2,width:R,height:z,rx:G,ry:G,fill:n,fillOpacity:.15,stroke:n,strokeWidth:1.2,strokeOpacity:.6}),r&&(0,F.jsx)(`g`,{transform:`translate(${t.x-B/2}, ${t.y-B/2}) scale(${B/14})`,children:(0,F.jsx)(`path`,{d:r,fill:`none`,stroke:n,strokeWidth:1.8,strokeLinecap:`round`,strokeLinejoin:`round`})})]},e.id)})]})});function ae({actions:e,height:t=64}){let n=(0,P.useRef)(null),[r,i]=(0,P.useState)(!1);return(0,P.useEffect)(()=>{let e=n.current;if(!e)return;let t=new IntersectionObserver(([e])=>{e.isIntersecting&&(i(!0),t.disconnect())},{rootMargin:`100px`});return t.observe(e),()=>t.disconnect()},[]),(0,F.jsx)(`div`,{ref:n,children:r?(0,F.jsx)(X,{actions:e,height:t}):(0,F.jsx)(v,{className:`w-full`,style:{height:t}})})}function oe(e){return e.triggers.length===0&&!e.cronExpression}function Z({wf:e}){return(0,F.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[e.triggers.map((t,n)=>(0,F.jsxs)(`div`,{children:[t.type===`workflow`&&(0,F.jsx)(`span`,{children:`After workflow`}),t.type===`event`&&(0,F.jsxs)(`span`,{children:[`Event`,` `,(0,F.jsx)(`code`,{className:`text-[10px] bg-muted px-1 rounded`,children:t.eventName})]}),t.type===`cron`&&e.cronExpression&&(0,F.jsxs)(`span`,{className:`text-emerald-500`,children:[M(e.cronExpression),` `,(0,F.jsx)(`code`,{className:`text-[10px] text-muted-foreground bg-muted px-1 rounded`,children:e.cronExpression})]})]},n)),e.cronExpression&&!e.triggers.some(e=>e.type===`cron`)&&(0,F.jsxs)(`div`,{className:`text-emerald-500`,children:[M(e.cronExpression),` `,(0,F.jsx)(`code`,{className:`text-[10px] text-muted-foreground bg-muted px-1 rounded`,children:e.cronExpression})]})]})}function Q({wf:e,onToggle:t}){return oe(e)?(0,F.jsx)(g,{variant:`outline`,className:`text-[10px]`,children:`Manual`}):(0,F.jsx)(`button`,{onClick:t,className:p(`relative inline-flex h-5 w-9 items-center rounded-full transition-colors`,e.enabled?`bg-emerald-500`:`bg-muted-foreground/30`),title:e.enabled?`Disable workflow`:`Enable workflow`,children:(0,F.jsx)(`span`,{className:p(`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform`,e.enabled?`translate-x-4.5`:`translate-x-0.5`)})})}function $({open:e,menuRef:t,onToggleMenu:n,onClone:r,onDelete:i}){return(0,F.jsxs)(`div`,{className:`relative`,ref:e?t:void 0,children:[(0,F.jsx)(_,{size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0`,onClick:n,children:(0,F.jsx)(N,{className:`h-3.5 w-3.5`})}),e&&(0,F.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-50 w-40 rounded-md border bg-popover shadow-md py-1`,children:[(0,F.jsxs)(`button`,{onClick:r,className:`flex items-center gap-2 px-3 py-1.5 text-xs hover:bg-muted transition-colors w-full text-left`,children:[(0,F.jsx)(S,{className:`h-3 w-3`}),`Clone`]}),(0,F.jsxs)(`button`,{onClick:i,className:`flex items-center gap-2 px-3 py-1.5 text-xs text-destructive hover:bg-destructive/10 transition-colors w-full text-left`,children:[(0,F.jsx)(k,{className:`h-3 w-3`}),`Delete`]})]})]})}var se=(0,P.memo)(function({wf:e,activeCount:t,isMenuOpen:n,menuRef:i,onToggleMenu:a,onToggle:o,onClone:s,onDelete:l,onTrigger:u}){return(0,F.jsxs)(f,{className:p(`relative group overflow-visible flex flex-col h-full`,!e.enabled&&`opacity-60`),children:[t>0&&(0,F.jsx)(d,{duration:8,colorFrom:`#22c55e`,colorTo:`#3b82f6`}),(0,F.jsx)(x,{className:`pb-2`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsx)(c,{className:`text-sm font-medium`,children:(0,F.jsx)(r,{to:`/workflows/${e.id}`,className:`hover:underline`,children:e.name})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t>0&&(0,F.jsxs)(g,{variant:`default`,className:`bg-emerald-500/90 text-white text-[10px] animate-pulse`,children:[t,` active run`,t>1?`s`:``]}),(0,F.jsx)(Q,{wf:e,onToggle:()=>o(e)}),(0,F.jsx)($,{open:n,menuRef:i,onToggleMenu:()=>a(e.id),onClone:()=>s(e.id),onDelete:()=>l(e.id)})]})]})}),(0,F.jsxs)(m,{className:`flex-1 flex flex-col`,children:[e.description&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:e.description}),e.workspace&&(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground mb-1`,children:[(0,F.jsx)(O,{className:`h-3 w-3 shrink-0`}),(0,F.jsx)(`span`,{className:`truncate`,title:e.workspace,children:e.workspace.split(`/`).slice(-2).join(`/`)})]}),(0,F.jsx)(Z,{wf:e}),(0,F.jsx)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mt-1`,children:(0,F.jsxs)(`span`,{children:[e.actions.length,` action(s)`]})}),(0,F.jsxs)(`div`,{className:`mt-auto`,children:[e.actions.length>0&&(0,F.jsx)(`div`,{className:`mt-2 rounded-md bg-muted/30 border border-border/50 px-2 py-1.5`,children:(0,F.jsx)(ae,{actions:e.actions})}),(0,F.jsxs)(`div`,{className:`pt-3 flex items-center justify-end gap-2`,children:[(0,F.jsx)(r,{to:`/workflows/${e.id}/runs`,children:(0,F.jsxs)(_,{size:`sm`,variant:`outline`,className:`gap-1.5`,children:[(0,F.jsx)(C,{className:`h-3 w-3`}),`Runs`]})}),(0,F.jsx)(r,{to:`/workflows/${e.id}`,children:(0,F.jsxs)(_,{size:`sm`,variant:`outline`,className:`gap-1.5`,children:[(0,F.jsx)(D,{className:`h-3 w-3`}),`Edit`]})}),(0,F.jsxs)(_,{size:`sm`,onClick:()=>u(e.id),className:`gap-1.5`,children:[(0,F.jsx)(T,{className:`h-3 w-3`}),`Run`]})]})]})]})]})}),ce=(0,P.memo)(function({wf:e,isMenuOpen:t,menuRef:n,onToggleMenu:i,onToggle:a,onClone:o,onDelete:s,onTrigger:c}){return(0,F.jsx)(f,{className:p(`overflow-visible`,!e.enabled&&`opacity-60`),children:(0,F.jsxs)(`div`,{className:`flex items-center gap-4 px-3 py-0`,children:[(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,F.jsx)(r,{to:`/workflows/${e.id}`,className:`text-sm font-medium hover:underline truncate`,children:e.name}),(0,F.jsx)(Q,{wf:e,onToggle:()=>a(e)})]}),e.description&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground truncate mb-0.5`,children:e.description}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[e.workspace&&(0,F.jsxs)(`span`,{className:`flex items-center gap-1 truncate`,children:[(0,F.jsx)(O,{className:`h-3 w-3 shrink-0`}),e.workspace.split(`/`).slice(-2).join(`/`)]}),(0,F.jsxs)(`span`,{children:[e.actions.length,` action(s)`]})]}),(0,F.jsx)(Z,{wf:e})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-4 shrink-0`,children:[(0,F.jsx)(`div`,{className:`w-[480px]`,children:e.actions.length>0&&(0,F.jsx)(`div`,{className:`rounded-md bg-muted/30 border border-border/50 px-2 py-0`,children:(0,F.jsx)(X,{actions:e.actions,height:120})})}),(0,F.jsxs)(`div`,{className:`flex flex-col items-stretch gap-1.5`,children:[(0,F.jsx)(`div`,{className:`flex justify-end`,children:(0,F.jsx)($,{open:t,menuRef:n,onToggleMenu:()=>i(e.id),onClone:()=>o(e.id),onDelete:()=>s(e.id)})}),(0,F.jsx)(r,{to:`/workflows/${e.id}/runs`,children:(0,F.jsxs)(_,{size:`sm`,variant:`outline`,className:`gap-1.5 w-full`,children:[(0,F.jsx)(C,{className:`h-3 w-3`}),`Runs`]})}),(0,F.jsx)(r,{to:`/workflows/${e.id}`,children:(0,F.jsxs)(_,{size:`sm`,variant:`outline`,className:`gap-1.5 w-full`,children:[(0,F.jsx)(D,{className:`h-3 w-3`}),`Edit`]})}),(0,F.jsxs)(_,{size:`sm`,onClick:()=>c(e.id),className:`gap-1.5`,children:[(0,F.jsx)(T,{className:`h-3 w-3`}),`Run`]})]})]})]})})});function le(){let{t:e}=j(),t=n(),i=a(),[c,u]=(0,P.useState)(null),d=(0,P.useRef)(null),[f,m]=(0,P.useState)(null),[g,v]=(0,P.useState)(``),[x,S]=(0,P.useState)(1),C=E(e=>e.workflowView),D=E(e=>e.setWorkflowView),{data:O,isLoading:k}=o({queryKey:[`workflows`,x,12],queryFn:()=>y.workflows.list({page:x,pageSize:12}),staleTime:3e4}),{data:M}=o({queryKey:[`workflows`,`active-counts`],queryFn:()=>y.workflows.getActiveCounts(),refetchInterval:15e3}),N=O?.data??[];(0,P.useEffect)(()=>{let e=e=>{d.current&&!d.current.contains(e.target)&&u(null)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let I=(0,P.useCallback)(async e=>{try{let t=await y.workflows.toggle(e.id);i.setQueryData([`workflows`,x,12],n=>n&&{...n,data:n.data.map(n=>n.id===e.id?{...n,enabled:t.enabled}:n)})}catch(e){console.error(`Failed to toggle:`,e)}},[i,x,12]),L=(0,P.useCallback)(e=>{v(``),m(e)},[]),R=(0,P.useCallback)(e=>{u(t=>t===e?null:e)},[]),z=()=>{if(!f)return;let e=f,n=g.trim()?{prompt:g.trim()}:void 0;m(null),y.workflows.trigger(e,n).catch(e=>console.error(`Failed to trigger:`,e)).finally(()=>t(`/workflows/${e}/runs`))},B=(0,P.useCallback)(async e=>{try{await y.workflows.clone(e),i.invalidateQueries({queryKey:[`workflows`]}),u(null)}catch(e){console.error(`Failed to clone:`,e)}},[i]),V=(0,P.useCallback)(async e=>{try{await y.workflows.delete(e),i.invalidateQueries({queryKey:[`workflows`]}),u(null)}catch(e){console.error(`Failed to delete:`,e)}},[i]);return(0,F.jsxs)(`div`,{className:`p-6`,children:[(0,F.jsxs)(`div`,{className:`mb-6 flex items-center justify-between`,children:[(0,F.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Workflows`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center rounded-md border bg-muted/30 p-0.5`,children:[(0,F.jsx)(`button`,{onClick:()=>D(`grid`),className:p(`rounded-sm p-1.5 transition-colors`,C===`grid`?`bg-background shadow-sm`:`hover:bg-background/50`),title:e(`workflows.gridView`),children:(0,F.jsx)(w,{className:`h-3.5 w-3.5`})}),(0,F.jsx)(`button`,{onClick:()=>D(`list`),className:p(`rounded-sm p-1.5 transition-colors`,C===`list`?`bg-background shadow-sm`:`hover:bg-background/50`),title:e(`workflows.listView`),children:(0,F.jsx)(re,{className:`h-3.5 w-3.5`})})]}),(0,F.jsx)(r,{to:`/workflows/new`,children:(0,F.jsx)(_,{children:e(`workflows.newWorkflow`)})})]})]}),k&&(0,F.jsx)(ne,{count:6}),!k&&N.length===0&&(0,F.jsxs)(`div`,{className:`text-muted-foreground text-center py-12`,children:[`No workflows configured yet.`,` `,(0,F.jsx)(r,{to:`/workflows/new`,className:`underline`,children:e(`workflows.createOne`)})]}),!k&&N.length>0&&(C===`grid`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3 mb-6`,children:N.map(e=>(0,F.jsx)(se,{wf:e,activeCount:M?.[e.id]??0,isMenuOpen:c===e.id,menuRef:d,onToggleMenu:R,onToggle:I,onClone:B,onDelete:V,onTrigger:L},e.id))}),O&&(0,F.jsx)(A,{page:O.page,totalPages:O.totalPages,total:O.total,pageSize:O.pageSize,onPageChange:S})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`space-y-4 mb-6`,children:N.map(e=>(0,F.jsx)(ce,{wf:e,isMenuOpen:c===e.id,menuRef:d,onToggleMenu:R,onToggle:I,onClone:B,onDelete:V,onTrigger:L},e.id))}),O&&(0,F.jsx)(A,{page:O.page,totalPages:O.totalPages,total:O.total,pageSize:O.pageSize,onPageChange:S})]})),(0,F.jsx)(h,{open:f!==null,onOpenChange:e=>{e||m(null)},children:(0,F.jsxs)(l,{className:`sm:max-w-md`,children:[(0,F.jsx)(te,{children:(0,F.jsx)(s,{children:e(`workflows.runWorkflow`)})}),(0,F.jsx)(b,{placeholder:e(`workflows.promptPlaceholder`),value:g,onChange:e=>v(e.target.value),rows:4,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),z())}}),(0,F.jsxs)(ee,{children:[(0,F.jsx)(_,{variant:`outline`,onClick:()=>m(null),children:`Cancel`}),(0,F.jsxs)(_,{onClick:z,className:`gap-1.5`,children:[(0,F.jsx)(T,{className:`h-3 w-3`}),`Run`]})]})]})})]})}export{le as Workflows};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|