adam-agent-server 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App-ZRCRM7WR.js +13 -0
- package/dist/{adam-automator-skills-UFW5TXCC.js → adam-automator-skills-EZGBICHT.js} +1 -1
- package/dist/adam-tools-V5LPU47X.js +1 -0
- package/dist/{approval-handler-HQO62WK2.js → approval-handler-PB7PSLUS.js} +1 -1
- package/dist/audit-manager-BSBBDUER.js +1 -0
- package/dist/bree-engine-7S33CWS7.js +1 -0
- package/dist/channels-SITUUC4J.js +1 -0
- package/dist/{channels-J4STJ4X2.js → channels-ULFUCUUZ.js} +1 -1
- package/dist/{chunk-7446ZS6D.js → chunk-2L2347UQ.js} +1 -1
- package/dist/{chunk-FXQAUQTI.js → chunk-2YTDCR6A.js} +1 -1
- package/dist/chunk-4PQHGLZH.js +99 -0
- package/dist/{chunk-NCFVJCNQ.js → chunk-5EPG2US5.js} +2 -2
- package/dist/{chunk-2H7UOW4P.js → chunk-5QZXYKMS.js} +1 -1
- package/dist/chunk-5XOTPEAK.js +6 -0
- package/dist/{chunk-MDBVKBC7.js → chunk-6KF7OO2B.js} +1 -1
- package/dist/{chunk-TSPQ44HT.js → chunk-A5OCDYTW.js} +1 -1
- package/dist/{chunk-DWRYIN5N.js → chunk-AQ3ASS4B.js} +1 -1
- package/dist/{chunk-GMMWA5EG.js → chunk-B6LOT5CG.js} +1 -1
- package/dist/{chunk-MJSSCKMB.js → chunk-BCH2HAIM.js} +2 -2
- package/dist/{chunk-4C5ITATX.js → chunk-BQ3ZAYHC.js} +1 -1
- package/dist/{chunk-YHVYX3F4.js → chunk-DVN3BFPP.js} +1 -1
- package/dist/{chunk-P5ZXNBNV.js → chunk-EQZFOBAJ.js} +1 -1
- package/dist/{chunk-G5ESQEXN.js → chunk-FPZEZYUB.js} +1 -1
- package/dist/{chunk-YXYIA24D.js → chunk-GSFLLRS7.js} +1 -1
- package/dist/{chunk-7ZGSJCX5.js → chunk-HQRUJQN7.js} +1 -1
- package/dist/{chunk-52PR7XTN.js → chunk-IKPYPZ64.js} +1 -1
- package/dist/{chunk-FZCNYKNT.js → chunk-JJH2RCVC.js} +1 -1
- package/dist/chunk-K4C43YDD.js +7 -0
- package/dist/{chunk-V32YF3J5.js → chunk-M4YI4WVX.js} +1 -1
- package/dist/{chunk-WAG3MNMC.js → chunk-NASJH4NT.js} +1 -1
- package/dist/{chunk-TNL2LZB7.js → chunk-NUITL62I.js} +1 -1
- package/dist/{chunk-3LY6PD6A.js → chunk-NWMOV23A.js} +1 -1
- package/dist/chunk-PHT24MOV.js +1 -0
- package/dist/{chunk-ZL5JXLAX.js → chunk-QGYDGZSC.js} +1 -1
- package/dist/{chunk-VVSZZK5T.js → chunk-RI3V72RP.js} +2 -2
- package/dist/{chunk-RLJYEEQC.js → chunk-RZ7LCZVK.js} +1 -1
- package/dist/{chunk-5OQZPUBV.js → chunk-TAF2DBBC.js} +8 -8
- package/dist/{chunk-HWLSHTVX.js → chunk-ULTK7RD6.js} +3 -3
- package/dist/{chunk-DBP7GPWG.js → chunk-WMB7P64J.js} +1 -1
- package/dist/cli.js +2 -2
- package/dist/{config-KFPS7IEH.js → config-HBQPBIWL.js} +1 -1
- package/dist/{db-PZ2V7UCK.js → db-QEWTZGU3.js} +1 -1
- package/dist/{delivery-log-ACNJ66RD.js → delivery-log-AC476GX7.js} +1 -1
- package/dist/engine-6K4RG644.js +1 -0
- package/dist/{evolution-audit-OQDGPKYI.js → evolution-audit-XMBDUN3T.js} +1 -1
- package/dist/index.js +13 -10
- package/dist/{learner-QCD6BH2J.js → learner-VCS3Q7BR.js} +1 -1
- package/dist/{memories-QGMRSBJJ.js → memories-VMOGFVPU.js} +1 -1
- package/dist/{memory-extractor-3MRK43A2.js → memory-extractor-4WJNHYWR.js} +2 -2
- package/dist/memory-service-ZS6MBUIC.js +1 -0
- package/dist/outbound-gateway-H7RFG6D2.js +1 -0
- package/dist/role-presets-XAEOYEAW.js +1 -0
- package/dist/role-workspace-NKGAH6J6.js +1 -0
- package/dist/{roles-KYXNMO5H.js → roles-ZYCFQMAY.js} +1 -1
- package/dist/{session-manager-LZ77OT7A.js → session-manager-COLCNIB7.js} +1 -1
- package/dist/task-templates-4KCZOUN5.js +1 -0
- package/dist/workflow-executor-Z7JFMR56.js +1 -0
- package/package.json +25 -25
- package/web/dist/assets/{ChannelDetail-DHT8fW0C.js → ChannelDetail-DnL0_h8q.js} +1 -1
- package/web/dist/assets/{Channels-YHGNXcRu.js → Channels-dod8Q4oq.js} +1 -1
- package/web/dist/assets/{Dashboard-DsHC5W4C.js → Dashboard-Dl0vA6Ky.js} +1 -1
- package/web/dist/assets/{EnvVarEditor-Dxy1Kz1Z.js → EnvVarEditor-C-gErAzC.js} +1 -1
- package/web/dist/assets/{EventDefDetail-CwprP2ch.js → EventDefDetail-BhJZGNlX.js} +1 -1
- package/web/dist/assets/{Events-B19a8cEG.js → Events-DnNZ9-BN.js} +1 -1
- package/web/dist/assets/{Evolution-DT6iZvil.js → Evolution-BBWmrrnr.js} +1 -1
- package/web/dist/assets/{GoalDetail-BALsnPQl.js → GoalDetail-uqWQCOj3.js} +1 -1
- package/web/dist/assets/{Goals-BJIsKgfH.js → Goals-CylKmR9j.js} +1 -1
- package/web/dist/assets/{Logs-Cv15aV3l.js → Logs-6rf0KT0z.js} +1 -1
- package/web/dist/assets/{Memories-CKAXhAso.js → Memories-CrBTujU7.js} +1 -1
- package/web/dist/assets/{Plugins-NO0S2spH.js → Plugins-VKUSUcSE.js} +1 -1
- package/web/dist/assets/{RoleDetail-1FNyCD4u.js → RoleDetail-DJc4CWFN.js} +1 -1
- package/web/dist/assets/{Roles-grfjw2zy.js → Roles-6pmjn04G.js} +1 -1
- package/web/dist/assets/{Settings-9LRLfa_4.js → Settings-DW1jmrNj.js} +1 -1
- package/web/dist/assets/{Strategies-BMyd_7_5.js → Strategies-Bmke6qZo.js} +1 -1
- package/web/dist/assets/{Switch-CULsD-kC.js → Switch-CfTpXW9_.js} +1 -1
- package/web/dist/assets/{TaskDetail-C2yXy8gE.js → TaskDetail-CwJ_UKgt.js} +1 -1
- package/web/dist/assets/Work-DVdWNBEm.js +1 -0
- package/web/dist/assets/{index-qYKJGoIB.js → index-DYsO5Awn.js} +2 -2
- package/web/dist/index.html +1 -1
- package/dist/App-WJMHK5EO.js +0 -13
- package/dist/adam-tools-IAZSLWYB.js +0 -1
- package/dist/audit-manager-LC5EQXCI.js +0 -1
- package/dist/bree-engine-M5CZ6A62.js +0 -1
- package/dist/channels-5TFYQN5Z.js +0 -1
- package/dist/chunk-FIN36WAP.js +0 -99
- package/dist/chunk-GGIHDFRW.js +0 -6
- package/dist/chunk-I7ZZKPHE.js +0 -7
- package/dist/chunk-YDVTWPNA.js +0 -1
- package/dist/engine-5DHYHDAP.js +0 -1
- package/dist/memory-service-M5ADGITG.js +0 -1
- package/dist/outbound-gateway-QRL36F7K.js +0 -1
- package/dist/role-presets-DLO3XS54.js +0 -1
- package/dist/role-workspace-URSOBCDH.js +0 -1
- package/dist/task-templates-YPNWJOVV.js +0 -1
- package/dist/workflow-executor-3WMS2WV3.js +0 -1
- package/web/dist/assets/Work-dftf35Me.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{$ as t,E as n,N as r,S as i,T as a,V as o,ct as s,et as c,it as l,s as u,tt as d,y as f}from"./vendor-icons-Dk0hMuJz.js";import{r as p,t as m}from"./vendor-react-C6faO6LO.js";import{i as h,n as g}from"./dist-Bdqp1ixJ.js";import{_,a as v,b as y,c as b,d as x,g as ee,i as S,n as te,o as C,p as w,r as T,s as ne,t as re,u as ie,v as ae,x as E}from"./AlertDialog-CfeiyMrc.js";import{i as D,t as O}from"./Button-DuQctNms.js";import{t as oe}from"./vendor-state-DahK0J-G.js";import{i as k,n as A,r as j,t as M}from"./index-qYKJGoIB.js";import{t as N}from"./Card-rKfViPS2.js";import{t as P}from"./PageHeader-CHSgtxPw.js";import{t as se}from"./SectionHeader-C2WpiwJ5.js";import{a as ce,o as le,t as ue}from"./format-CHfBBLog.js";import{t as de}from"./EmptyState-CIdIlMbn.js";import{t as fe}from"./ui-B_uMx2Fy.js";import{t as pe}from"./useIsMobileLayout-C6KIQjuh.js";import{a as me,i as F,n as he,o as I,r as L,t as ge}from"./Table-DuOLbyJQ.js";import{t as _e}from"./Switch-CULsD-kC.js";import{Goals as ve,t as ye}from"./Goals-BJIsKgfH.js";var R=e(s(),1),z=m();function be(e){let t=e+`CollectionProvider`,[n,r]=y(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=R.useRef(null),a=R.useRef(new Map).current;return(0,z.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=ae(s),l=R.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,z.jsx)(c,{ref:D(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=ae(u),p=R.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=R.useRef(null),s=D(t,o),c=a(u,n);return R.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,z.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return R.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var xe=R.createContext(void 0);function B(e){let t=R.useContext(xe);return e||t||`ltr`}var V=`rovingFocusGroup.onEntryFocus`,Se={bubbles:!1,cancelable:!0},H=`RovingFocusGroup`,[U,W,Ce]=be(H),[G,we]=y(H,[Ce]),[Te,Ee]=G(H),K=R.forwardRef((e,t)=>(0,z.jsx)(U.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,z.jsx)(U.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,z.jsx)(De,{...e,ref:t})})}));K.displayName=H;var De=R.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=R.useRef(null),p=D(t,f),m=B(a),[h,g]=ie({prop:o,defaultProp:s??null,onChange:c,caller:H}),[v,y]=R.useState(!1),b=ee(l),x=W(n),S=R.useRef(!1),[te,C]=R.useState(0);return R.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(V,b),()=>e.removeEventListener(V,b)},[b]),(0,z.jsx)(Te,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:R.useCallback(e=>g(e),[g]),onItemShiftTab:R.useCallback(()=>y(!0),[]),onFocusableItemAdd:R.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:R.useCallback(()=>C(e=>e-1),[]),children:(0,z.jsx)(_.div,{tabIndex:v||te===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:E(e.onMouseDown,()=>{S.current=!0}),onFocus:E(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!v){let t=new CustomEvent(V,Se);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);Me([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}S.current=!1}),onBlur:E(e.onBlur,()=>y(!1))})})}),q=`RovingFocusGroupItem`,Oe=R.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=w(),l=a||c,u=Ee(q,n),d=u.currentTabStopId===l,f=W(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return R.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,z.jsx)(U.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,z.jsx)(_.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:E(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:E(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:E(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=je(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?Ne(n,r+1):n.slice(r+1)}setTimeout(()=>Me(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});Oe.displayName=q;var ke={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Ae(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function je(e,t,n){let r=Ae(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return ke[r]}function Me(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ne(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Pe=K,J=Oe,Y=`Tabs`,[Fe,Ie]=y(Y,[we]),Le=we(),[Re,X]=Fe(Y),ze=R.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=B(s),[d,f]=ie({prop:r,onChange:i,defaultProp:a??``,caller:Y});return(0,z.jsx)(Re,{scope:n,baseId:w(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,z.jsx)(_.div,{dir:u,"data-orientation":o,...l,ref:t})})});ze.displayName=Y;var Z=`TabsList`,Be=R.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=X(Z,n),o=Le(n);return(0,z.jsx)(Pe,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,z.jsx)(_.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Be.displayName=Z;var Ve=`TabsTrigger`,He=R.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=X(Ve,n),s=Le(n),c=Q(o.baseId,r),l=Ge(o.baseId,r),u=r===o.value;return(0,z.jsx)(J,{asChild:!0,...s,focusable:!i,active:u,children:(0,z.jsx)(_.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:E(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:E(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:E(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});He.displayName=Ve;var Ue=`TabsContent`,We=R.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=X(Ue,n),c=Q(s.baseId,r),l=Ge(s.baseId,r),u=r===s.value,d=R.useRef(u);return R.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,z.jsx)(x,{present:i||u,children:({present:n})=>(0,z.jsx)(_.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});We.displayName=Ue;function Q(e,t){return`${e}-trigger-${t}`}function Ge(e,t){return`${e}-content-${t}`}var Ke=ze,qe=Be,Je=He,Ye=We,Xe=Ke,Ze=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(qe,{ref:n,className:h(`surface-panel-muted inline-flex min-h-11 items-center justify-center gap-1 rounded-full p-1 text-[var(--app-text-muted)]`,e),...t}));Ze.displayName=qe.displayName;var Qe=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(Je,{ref:n,className:h(`inline-flex items-center justify-center whitespace-nowrap rounded-full px-4 py-2 text-sm font-medium ring-offset-[var(--app-canvas)] transition-[background-color,color,box-shadow] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:surface-panel data-[state=active]:text-[var(--app-text)] data-[state=active]:shadow-[var(--app-shadow-sm)]`,e),...t}));Qe.displayName=Je.displayName;var $e=R.forwardRef(({className:e,...t},n)=>(0,z.jsx)(Ye,{ref:n,className:h(`mt-4 ring-offset-[var(--app-canvas)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2`,e),...t}));$e.displayName=Ye.displayName;var et=[{label:`All`,value:`all`},{label:`Running`,value:`running`},{label:`Pending`,value:`pending`},{label:`Completed`,value:`completed`},{label:`Failed`,value:`failed`},{label:`Cancelled`,value:`cancelled`}],$=new Set([`pending`,`queued`,`running`,`paused`]);function tt(){let e=j(e=>e.tasks),t=j(e=>e.fetchTasks),[n,a]=(0,R.useState)(`all`),[o,s]=(0,R.useState)(!1),[c,u]=(0,R.useState)(``),[m,h]=(0,R.useState)(!1),[_,v]=(0,R.useState)(new Set),[y,b]=(0,R.useState)(!1),x=pe();(0,R.useEffect)(()=>{let e=n===`all`?void 0:n;t(e);let r=setInterval(()=>void t(e),5e3);return()=>clearInterval(r)},[t,n]),(0,R.useEffect)(()=>{v(new Set)},[n]);let ee=async()=>{if(c.trim()){h(!0);try{await g(`/tasks`,{method:`POST`,body:JSON.stringify({prompt:c.trim()})}),u(``),s(!1),t(n===`all`?void 0:n)}finally{h(!1)}}},S=e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},te=()=>{let e=w.filter(e=>$.has(e.status)).map(e=>e.id);v(new Set(e))},C=async()=>{if(_.size!==0){b(!0);try{await g(`/tasks/batch-cancel`,{method:`POST`,body:JSON.stringify({taskIds:Array.from(_)})}),v(new Set),t(n===`all`?void 0:n)}finally{b(!1)}}},w=[...e].sort((e,t)=>t.createdAt-e.createdAt),T=Array.from(_).filter(t=>{let n=e.find(e=>e.id===t);return n&&$.has(n.status)});return(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsx)(se,{title:`Tasks`,description:`Review active execution, cancel work, or create the next task.`,compact:!0,action:(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[_.size>0&&(0,z.jsxs)(O,{variant:`destructive`,size:`sm`,onClick:()=>void C(),disabled:y||T.length===0,children:[(0,z.jsx)(l,{size:fe.sm}),y?`Cancelling...`:`Cancel ${T.length} task${T.length===1?``:`s`}`]}),(0,z.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>void t(n===`all`?void 0:n),children:(0,z.jsx)(f,{size:fe.sm})}),(0,z.jsxs)(O,{size:`sm`,onClick:()=>s(!o),children:[(0,z.jsx)(i,{size:fe.sm}),`New Task`]})]})}),o&&(0,z.jsxs)(N,{className:`flex gap-2`,children:[(0,z.jsx)(`input`,{className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Enter task prompt...`,value:c,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ee()}}),(0,z.jsx)(O,{onClick:()=>void ee(),disabled:m||!c.trim(),children:m?`Creating...`:`Create`}),(0,z.jsx)(O,{variant:`ghost`,onClick:()=>s(!1),children:`Cancel`})]}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-2 md:flex-row md:items-center md:justify-between`,children:[(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:et.map(e=>(0,z.jsx)(`button`,{onClick:()=>a(e.value),className:`rounded-md px-2.5 py-1 text-xs font-medium transition-colors ${n===e.value?`bg-[var(--app-panel-elevated)] text-[var(--app-text)]`:`text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:e.label},e.value))}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[w.some(e=>$.has(e.status))&&(0,z.jsx)(`button`,{onClick:te,className:`text-xs text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,children:`Select all cancellable`}),_.size>0&&(0,z.jsxs)(`button`,{onClick:()=>v(new Set),className:`text-xs text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,children:[`Clear selection (`,_.size,`)`]})]})]}),w.length===0?(0,z.jsx)(N,{padding:!1,children:(0,z.jsx)(de,{icon:(0,z.jsx)(r,{size:32}),title:`No tasks found`,description:n===`all`?`Create a task to get started`:`No tasks with status "${n}"`})}):x?(0,z.jsx)(`div`,{className:`space-y-3`,children:w.map(e=>(0,z.jsx)(N,{className:_.has(e.id)?`border-[var(--app-accent)]/40 bg-[var(--app-accent)]/8`:``,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,z.jsx)(`div`,{className:`pt-1`,children:$.has(e.status)?(0,z.jsx)(`button`,{onClick:()=>S(e.id),className:`flex h-4 w-4 items-center justify-center rounded border transition-colors ${_.has(e.id)?`border-[var(--app-accent-strong)] bg-[var(--app-accent)] text-white`:`border-[var(--app-border-strong)] bg-transparent hover:border-[var(--app-text-muted)]`}`,children:_.has(e.id)&&(0,z.jsx)(d,{size:12})}):(0,z.jsx)(`span`,{className:`inline-block h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,z.jsx)(p,{to:`/tasks/${e.id}`,className:`break-all font-mono text-xs text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:e.id.slice(0,8)}),(0,z.jsx)(`p`,{className:`break-words text-sm font-medium leading-6 text-[var(--app-text)]`,children:le(e.prompt,140)})]}),(0,z.jsx)(M,{variant:A(e.status),children:e.status})]}),(0,z.jsxs)(`div`,{className:`grid gap-2 text-xs text-[var(--app-text-subtle)] sm:grid-cols-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Role`}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-[var(--app-text)]`,children:e.roleId?e.roleId.slice(0,12):`—`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Cost`}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-[var(--app-text)]`,children:e.costUsd==null?`—`:ue(e.costUsd)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Created`}),(0,z.jsx)(`div`,{className:`mt-1 text-[var(--app-text)]`,children:ce(e.createdAt)})]})]})]})]})},e.id))}):(0,z.jsx)(N,{padding:!1,children:(0,z.jsxs)(ge,{children:[(0,z.jsx)(me,{children:(0,z.jsxs)(I,{children:[(0,z.jsx)(F,{className:`w-8`,children:(0,z.jsx)(`button`,{onClick:()=>{_.size>0&&_.size===w.filter(e=>$.has(e.status)).length?v(new Set):te()},className:`flex h-4 w-4 items-center justify-center rounded border transition-colors ${_.size>0&&_.size===w.filter(e=>$.has(e.status)).length?`border-[var(--app-accent-strong)] bg-[var(--app-accent)] text-white`:`border-[var(--app-border-strong)] bg-transparent hover:border-[var(--app-text-muted)]`}`,children:_.size>0&&_.size===w.filter(e=>$.has(e.status)).length&&(0,z.jsx)(d,{size:12})})}),(0,z.jsx)(F,{children:`ID`}),(0,z.jsx)(F,{children:`Prompt`}),(0,z.jsx)(F,{children:`Status`}),(0,z.jsx)(F,{children:`Role`}),(0,z.jsx)(F,{children:`Cost`}),(0,z.jsx)(F,{children:`Created`})]})}),(0,z.jsx)(he,{children:w.map(e=>(0,z.jsxs)(I,{className:_.has(e.id)?`bg-[var(--app-panel-elevated)]/50`:``,children:[(0,z.jsx)(L,{children:$.has(e.status)?(0,z.jsx)(`button`,{onClick:()=>S(e.id),className:`flex h-4 w-4 items-center justify-center rounded border transition-colors ${_.has(e.id)?`border-[var(--app-accent-strong)] bg-[var(--app-accent)] text-white`:`border-[var(--app-border-strong)] bg-transparent hover:border-[var(--app-text-muted)]`}`,children:_.has(e.id)&&(0,z.jsx)(d,{size:12})}):(0,z.jsx)(`span`,{className:`inline-block w-4`})}),(0,z.jsx)(L,{children:(0,z.jsx)(p,{to:`/tasks/${e.id}`,className:`font-mono text-xs text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:e.id.slice(0,8)})}),(0,z.jsx)(L,{children:(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(`div`,{className:`break-words font-medium text-[var(--app-text)]`,children:le(e.prompt,120)}),(0,z.jsxs)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[e.totalDurationMs?ue(e.costUsd??0):`Awaiting completion`,` · `,ce(e.createdAt)]})]})}),(0,z.jsx)(L,{children:(0,z.jsx)(M,{variant:A(e.status),children:e.status})}),(0,z.jsx)(L,{children:(0,z.jsx)(`span`,{className:`font-mono text-xs text-[var(--app-text-subtle)]`,children:e.roleId?e.roleId.slice(0,12):`—`})}),(0,z.jsx)(L,{className:`font-mono text-xs`,children:e.costUsd==null?`—`:ue(e.costUsd)}),(0,z.jsx)(L,{className:`text-xs text-[var(--app-text-subtle)]`,children:ce(e.createdAt)})]},e.id))})]})})]})}function nt(e){return`step-${e+1}`}function rt(){let e=j(e=>e.templates),r=j(e=>e.fetchTemplates),s=j(e=>e.goals),l=j(e=>e.fetchGoals),d=j(e=>e.roles),p=j(e=>e.fetchRoles),[m,h]=(0,R.useState)(!1),[_,y]=(0,R.useState)(``),[x,ee]=(0,R.useState)(`manual`),[w,ie]=(0,R.useState)(``),[ae,E]=(0,R.useState)(``),[D,oe]=(0,R.useState)(``),[A,P]=(0,R.useState)([{id:`step-1`,prompt:``}]),[le,ue]=(0,R.useState)(!1),[fe,pe]=(0,R.useState)(!1),[ve,be]=(0,R.useState)(null),[xe,B]=(0,R.useState)(null),[V,Se]=(0,R.useState)(null),[H,U]=(0,R.useState)(null),[W,Ce]=(0,R.useState)(``),[G,we]=(0,R.useState)(`manual`),[Te,Ee]=(0,R.useState)(``),[K,De]=(0,R.useState)(``),[q,Oe]=(0,R.useState)(``),[ke,Ae]=(0,R.useState)(``),[je,Me]=(0,R.useState)(``),[Ne,Pe]=(0,R.useState)([]),[J,Y]=(0,R.useState)([]),[Fe,Ie]=(0,R.useState)(!1),[Le,Re]=(0,R.useState)(!1),[X,ze]=(0,R.useState)(`prompt`),[Z,Be]=(0,R.useState)([]),[Ve,He]=(0,R.useState)([]),[Ue,We]=(0,R.useState)([]),[Q,Ge]=(0,R.useState)(null),[Ke,qe]=(0,R.useState)([]),[Je,Ye]=(0,R.useState)(!1),Xe=(0,R.useCallback)(async e=>{Ye(!0);try{let t=await g(`/workflow-executions?templateId=${e}&limit=5`);qe(await Promise.all(t.executions.map(async e=>{try{let t=await g(`/workflow-executions/${e.id}`);return{...t.execution,stepTasks:t.stepTasks}}catch{return{...e,stepTasks:[]}}})))}catch{qe([])}finally{Ye(!1)}},[]),Ze=(0,R.useCallback)(e=>{Q===e?(Ge(null),qe([])):(Ge(e),Xe(e))},[Q,Xe]),Qe=(0,R.useMemo)(()=>Object.fromEntries(e.map(e=>[e.id,e.name])),[e]),$e=e=>e.type===`cron`?`Cron: ${e.cron??`—`}`:e.type===`once`?`Once at ${e.runAt?new Date(e.runAt).toLocaleString():`—`}`:e.type===`template_complete`?`When template '${Qe[e.event?.split(`:`)[1]??``]??`[deleted template]`}' completes`:e.type===`event`?`On event '${Ne.find(t=>t.id===e.eventDefId)?.name??`[deleted event]`}'`:e.type;(0,R.useEffect)(()=>{r(),l(),p(),(async()=>{try{Pe(await g(`/event-defs`))}catch{}})()},[r,l,p]);let et=async()=>{if(_.trim()&&!(X===`prompt`&&A.every(e=>!e.prompt.trim()))&&!(X===`goal`&&Z.length===0)){pe(!0);try{let e={name:_.trim(),trigger:{type:x,...x===`cron`&&ae?{cron:ae}:{},...x===`once`&&D?{runAt:new Date(D).toISOString()}:{},...x===`template_complete`&&w?{event:`template_complete:${w}`}:{},...x===`event`&&ke?{eventDefId:ke}:{}},enabled:!0,...Ve.length>0?{deliverTo:Ve}:{},...le?{config:{continueOnError:!0}}:{}};X===`prompt`?e.steps=A.filter(e=>e.prompt.trim()).map((e,t)=>({id:e.id||nt(t),prompt:e.prompt.trim(),...e.roleId?{roleId:e.roleId}:{},...e.dependsOn&&e.dependsOn.length>0?{dependsOn:e.dependsOn}:{},...e.config&&(e.config.timeout!==void 0||e.config.maxTurns!==void 0)?{config:e.config}:{}})):(e.goalIds=Z,e.steps=[]),await g(`/task-templates`,{method:`POST`,body:JSON.stringify(e)}),y(``),P([{id:`step-1`,prompt:``}]),E(``),oe(``),ie(``),Ae(``),Be([]),He([]),h(!1),r()}finally{pe(!1)}}},$=async t=>{let n=e.find(e=>e.id===t);be(t);try{await g(`/task-templates/${t}/run`,{method:`POST`}),k.success(`Triggered: ${n?.name??t}`)}catch(e){let t=e instanceof Error?e.message:`Failed to trigger template`;k.error(`Trigger failed: ${t}`)}finally{be(null)}},tt=async t=>{let n=e.find(e=>e.id===t);try{await g(`/task-templates/${t}`,{method:`DELETE`}),k.success(`Deleted: ${n?.name??t}`),r()}catch(e){let t=e instanceof Error?e.message:`Failed to delete template`;k.error(`Delete failed: ${t}`)}},rt=async t=>{let n=e.find(e=>e.id===t);if(!n)return;if(![`cron`,`once`,`template_complete`].includes(n.trigger.type)){k.error(`Toggle not applicable for manual triggers`);return}let i=!n.enabled;try{await g(`/task-templates/${t}`,{method:`PATCH`,body:JSON.stringify({enabled:i})}),k.success(`${n.name} ${i?`enabled`:`disabled`}`),r()}catch(e){let t=e instanceof Error?e.message:`Failed to toggle template`;k.error(`Toggle failed: ${t}`)}},it=e=>{U(e.id),Ce(e.name),we(e.trigger.type===`workflow_complete`?`template_complete`:e.trigger.type),Ee(e.trigger.cron??``),De(e.trigger.runAt?new Date(e.trigger.runAt).toISOString().slice(0,16):``),Y(e.steps.map(e=>({id:e.id,prompt:e.prompt,roleId:e.roleId,dependsOn:e.dependsOn,config:e.config}))),Ie(e.config?.continueOnError??!1),We(e.deliverTo??[]),Oe(e.trigger.type===`template_complete`||e.trigger.type===`workflow_complete`?e.trigger.event?.split(`:`)[1]??``:``),Me(e.trigger.eventDefId??``)},at=async()=>{if(!(!H||!W.trim()||J.every(e=>!e.prompt.trim()))){Re(!0);try{await g(`/task-templates/${H}`,{method:`PATCH`,body:JSON.stringify({name:W.trim(),trigger:{type:G,...G===`cron`&&Te?{cron:Te}:{},...G===`once`&&K?{runAt:new Date(K).toISOString()}:{},...G===`template_complete`&&q?{event:`template_complete:${q}`}:{},...G===`event`&&je?{eventDefId:je}:{}},steps:J.filter(e=>e.prompt.trim()).map((e,t)=>({id:e.id||nt(t),prompt:e.prompt.trim(),...e.roleId?{roleId:e.roleId}:{},...e.dependsOn&&e.dependsOn.length>0?{dependsOn:e.dependsOn}:{},...e.config&&(e.config.timeout!==void 0||e.config.maxTurns!==void 0)?{config:e.config}:{}})),enabled:e.find(e=>e.id===H)?.enabled??!0,...Fe?{config:{continueOnError:!0}}:{config:{}},deliverTo:Ue.length>0?Ue:void 0})}),U(null),r(),k.success(`Template updated`)}catch(e){let t=e instanceof Error?e.message:`Failed to update template`;k.error(t)}finally{Re(!1)}}},ot=e.find(e=>e.id===xe),st=e.find(e=>e.id===V);return(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsx)(se,{title:`Automations`,description:`Reusable workflows, manual triggers, and recent workflow runs.`,compact:!0,action:(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>void r(),children:(0,z.jsx)(f,{size:14})}),(0,z.jsxs)(O,{size:`sm`,onClick:()=>h(!m),children:[(0,z.jsx)(i,{size:14}),`New Automation`]})]})}),m&&(0,z.jsxs)(N,{className:`space-y-3`,children:[(0,z.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Template name`,value:_,onChange:e=>y(e.target.value)}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Triggered by:`}),(0,z.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:x,onChange:e=>ee(e.target.value),children:[(0,z.jsx)(`option`,{value:`manual`,children:`Manual`}),(0,z.jsx)(`option`,{value:`cron`,children:`Schedule (Cron)`}),(0,z.jsx)(`option`,{value:`once`,children:`One-time`}),(0,z.jsx)(`option`,{value:`template_complete`,children:`Template completion`}),(0,z.jsx)(`option`,{value:`event`,children:`Event (definition)`})]}),x===`template_complete`&&(0,z.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:w,onChange:e=>ie(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`-- Select target template --`}),e.filter(e=>e.id!==H).map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),x===`event`&&(0,z.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:ke,onChange:e=>Ae(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`-- Select event --`}),Ne.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),x===`cron`&&(0,z.jsx)(`input`,{className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Cron expression (e.g. */5 * * * *)`,value:ae,onChange:e=>E(e.target.value)}),x===`once`&&(0,z.jsx)(`input`,{type:`datetime-local`,className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:D,onChange:e=>oe(e.target.value)})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,z.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Action type:`}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>ze(`prompt`),className:`rounded px-2 py-1 text-xs ${X===`prompt`?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:`Custom Prompt`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>ze(`goal`),className:`rounded px-2 py-1 text-xs ${X===`goal`?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:`Goal Reference`})]})]}),X===`prompt`?(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Steps`}),(0,z.jsxs)(O,{variant:`ghost`,size:`sm`,onClick:()=>P([...A,{id:nt(A.length),prompt:``}]),children:[(0,z.jsx)(i,{size:12}),` Add Step`]})]}),A.map((e,t)=>(0,z.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] p-2 space-y-1.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--app-text-subtle)]`,children:e.id}),(0,z.jsxs)(`select`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-xs text-[var(--app-text)]`,value:e.roleId??``,onChange:n=>{let r=[...A];r[t]={...e,roleId:n.target.value||void 0},P(r)},children:[(0,z.jsx)(`option`,{value:``,children:`Role (template default)`}),d.filter(e=>e.source!==`system`).map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),A.length>1&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>P(A.filter((e,n)=>n!==t)),className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,children:(0,z.jsx)(u,{size:12})})]}),(0,z.jsx)(`textarea`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Step ${t+1} prompt${t>0?` (use {{`+A[t-1].id+`.result}} for prev output)`:``}`,rows:2,value:e.prompt,onChange:n=>{let r=[...A];r[t]={...e,prompt:n.target.value},P(r)}}),t>0&&(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`depends on:`}),A.slice(0,t).map(n=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>{let r=e.dependsOn??[],i=[...A];i[t]={...e,dependsOn:r.includes(n.id)?r.filter(e=>e!==n.id):[...r,n.id]},P(i)},className:`rounded px-1.5 py-0.5 text-[10px] ${(e.dependsOn??[]).includes(n.id)?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:n.id},n.id))]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`timeout(s):`,(0,z.jsx)(`input`,{type:`number`,min:0,placeholder:`default`,className:`w-20 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.config?.timeout??``,onChange:n=>{let r=[...A],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,config:{...e.config,timeout:i}},P(r)}})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`max turns:`,(0,z.jsx)(`input`,{type:`number`,min:0,placeholder:`default`,className:`w-20 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.config?.maxTurns??``,onChange:n=>{let r=[...A],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,config:{...e.config,maxTurns:i}},P(r)}})]})]})]},e.id))]}):(0,z.jsx)(`div`,{className:`space-y-1`,children:s.length===0?(0,z.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`No goals available`}):s.map(e=>(0,z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-[var(--app-text)] hover:text-[var(--app-text)] cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:Z.includes(e.id),onChange:t=>{t.target.checked?Be([...Z,e.id]):Be(Z.filter(t=>t!==e.id))},className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-elevated)]`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name}),(0,z.jsx)(M,{variant:`muted`,className:`text-[10px]`,children:e.status})]},e.id))}),A.length>1&&(0,z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-[var(--app-text)] cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:le,onChange:e=>ue(e.target.checked),className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-elevated)]`}),`Continue on error (skip failed step dependents, run independent steps)`]}),(0,z.jsx)(ye,{value:Ve,onChange:He}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(O,{onClick:()=>void et(),disabled:fe||!_.trim()||X===`prompt`&&A.every(e=>!e.prompt.trim())||X===`goal`&&Z.length===0||x===`template_complete`&&!w,children:fe?`Creating...`:`Create`}),(0,z.jsx)(O,{variant:`ghost`,onClick:()=>h(!1),children:`Cancel`})]})]}),H!==null&&(0,z.jsxs)(N,{className:`space-y-3`,children:[(0,z.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Edit Automation`}),(0,z.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Template name`,value:W,onChange:e=>Ce(e.target.value)}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Triggered by:`}),(0,z.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:G,onChange:e=>we(e.target.value),children:[(0,z.jsx)(`option`,{value:`manual`,children:`Manual`}),(0,z.jsx)(`option`,{value:`cron`,children:`Schedule (Cron)`}),(0,z.jsx)(`option`,{value:`once`,children:`One-time`}),(0,z.jsx)(`option`,{value:`template_complete`,children:`Template completion`}),(0,z.jsx)(`option`,{value:`event`,children:`Event (definition)`})]}),G===`template_complete`&&(0,z.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:q,onChange:e=>Oe(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`-- Select target template --`}),e.filter(e=>e.id!==H).map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),G===`event`&&(0,z.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:je,onChange:e=>Me(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`-- Select event --`}),Ne.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),G===`cron`&&(0,z.jsx)(`input`,{className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Cron expression`,value:Te,onChange:e=>Ee(e.target.value)}),G===`once`&&(0,z.jsx)(`input`,{type:`datetime-local`,className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:K,onChange:e=>De(e.target.value)})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Steps`}),(0,z.jsxs)(O,{variant:`ghost`,size:`sm`,onClick:()=>Y([...J,{id:nt(J.length),prompt:``}]),children:[(0,z.jsx)(i,{size:12}),` Add Step`]})]}),J.map((e,t)=>(0,z.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] p-2 space-y-1.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--app-text-subtle)]`,children:e.id}),(0,z.jsxs)(`select`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-xs text-[var(--app-text)]`,value:e.roleId??``,onChange:n=>{let r=[...J];r[t]={...e,roleId:n.target.value||void 0},Y(r)},children:[(0,z.jsx)(`option`,{value:``,children:`Role (template default)`}),d.filter(e=>e.source!==`system`).map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),J.length>1&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>Y(J.filter((e,n)=>n!==t)),className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,children:(0,z.jsx)(u,{size:12})})]}),(0,z.jsx)(`textarea`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Step ${t+1} prompt`,rows:2,value:e.prompt,onChange:n=>{let r=[...J];r[t]={...e,prompt:n.target.value},Y(r)}}),t>0&&(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`depends on:`}),J.slice(0,t).map(n=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>{let r=e.dependsOn??[],i=[...J];i[t]={...e,dependsOn:r.includes(n.id)?r.filter(e=>e!==n.id):[...r,n.id]},Y(i)},className:`rounded px-1.5 py-0.5 text-[10px] ${(e.dependsOn??[]).includes(n.id)?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:n.id},n.id))]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`timeout(s):`,(0,z.jsx)(`input`,{type:`number`,min:0,placeholder:`default`,className:`w-20 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.config?.timeout??``,onChange:n=>{let r=[...J],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,config:{...e.config,timeout:i}},Y(r)}})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`max turns:`,(0,z.jsx)(`input`,{type:`number`,min:0,placeholder:`default`,className:`w-20 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.config?.maxTurns??``,onChange:n=>{let r=[...J],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,config:{...e.config,maxTurns:i}},Y(r)}})]})]})]},e.id))]}),J.length>1&&(0,z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-[var(--app-text)] cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:Fe,onChange:e=>Ie(e.target.checked),className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-elevated)]`}),`Continue on error`]}),(0,z.jsx)(ye,{value:Ue,onChange:We}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(O,{onClick:()=>void at(),disabled:Le||!W.trim()||J.every(e=>!e.prompt.trim()),children:Le?`Saving...`:`Save`}),(0,z.jsx)(O,{variant:`ghost`,onClick:()=>U(null),children:`Cancel`})]})]}),(0,z.jsx)(N,{padding:!1,children:e.length===0?(0,z.jsx)(de,{icon:(0,z.jsx)(o,{size:32}),title:`No automations`,description:`Create an automation to run recurring tasks`}):(0,z.jsxs)(ge,{children:[(0,z.jsx)(me,{children:(0,z.jsxs)(I,{children:[(0,z.jsx)(F,{children:`Name`}),(0,z.jsx)(F,{children:`Trigger`}),(0,z.jsx)(F,{children:`Schedule`}),(0,z.jsx)(F,{children:`Steps`}),(0,z.jsx)(F,{children:`Enabled`}),(0,z.jsx)(F,{children:`Created`}),(0,z.jsx)(F,{children:`Webhook URL`}),(0,z.jsx)(F,{children:`Actions`})]})}),(0,z.jsx)(he,{children:e.map(e=>(0,z.jsxs)(R.Fragment,{children:[(0,z.jsxs)(I,{children:[(0,z.jsx)(L,{className:`font-medium text-[var(--app-text)]`,children:(0,z.jsxs)(`button`,{type:`button`,onClick:()=>Ze(e.id),className:`flex items-center gap-1 hover:text-[var(--app-accent)] transition-colors`,children:[Q===e.id?(0,z.jsx)(c,{size:12}):(0,z.jsx)(t,{size:12}),e.name]})}),(0,z.jsx)(L,{children:(0,z.jsx)(M,{variant:e.trigger.type===`cron`?`info`:(e.trigger.type,`muted`),children:$e(e.trigger)})}),(0,z.jsx)(L,{className:`font-mono text-xs`,children:e.trigger.type===`once`&&e.trigger.runAt?new Date(e.trigger.runAt).toLocaleString():e.trigger.cron??`—`}),(0,z.jsx)(L,{className:`font-mono text-xs`,children:e.goalIds&&e.goalIds.length>0?`Goals: ${e.goalIds.length}`:(()=>{let t=new Set(e.steps.filter(e=>e.roleId).map(e=>e.roleId));return t.size>0?`${e.steps.length} steps / ${t.size} roles`:String(e.steps.length)})()}),(0,z.jsx)(L,{children:[`cron`,`once`,`template_complete`].every(t=>e.trigger.type!==t)?(0,z.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`—`}):(0,z.jsx)(_e,{checked:e.enabled,onCheckedChange:()=>void rt(e.id),"aria-label":`Toggle ${e.name}`})}),(0,z.jsx)(L,{className:`text-xs text-[var(--app-text-subtle)]`,children:e.createdAt?ce(e.createdAt):`—`}),(0,z.jsx)(L,{className:`font-mono text-xs text-[var(--app-text-muted)]`,children:e.enabled?`POST /webhooks/${e.id}`:`—`}),(0,z.jsx)(L,{children:(0,z.jsxs)(`div`,{className:`flex gap-1`,children:[(0,z.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>it(e),title:`Edit`,children:(0,z.jsx)(n,{size:12})}),(0,z.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>B(e.id),disabled:ve===e.id,title:`Run now`,children:(0,z.jsx)(a,{size:12})}),(0,z.jsx)(O,{variant:`ghost`,size:`sm`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,onClick:()=>Se(e.id),title:`Delete`,children:(0,z.jsx)(u,{size:12})})]})})]}),Q===e.id&&(0,z.jsx)(I,{children:(0,z.jsxs)(L,{colSpan:8,className:`bg-[var(--app-panel)]/50 p-3`,children:[(0,z.jsx)(`div`,{className:`text-xs text-[var(--app-text-muted)] mb-2 font-medium`,children:`Recent Executions`}),Je?(0,z.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Loading...`}):Ke.length===0?(0,z.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`No executions yet`}):(0,z.jsx)(`div`,{className:`space-y-1.5`,children:Ke.map(t=>{let n=Object.entries(t.stepStatuses),r=n.filter(([,e])=>e.status===`completed`).length,i=n.filter(([,e])=>e.status===`failed`).length,a=n.filter(([,e])=>e.status===`skipped`).length,o=n.filter(([,e])=>e.status===`cancelled`).length,s=n.length,c=new Map(t.stepTasks.filter(e=>e.stepId).map(e=>[e.stepId,e])),l=[...e.steps.map(e=>e.id),...Object.keys(t.stepStatuses).filter(t=>!e.steps.some(e=>e.id===t))];return(0,z.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-canvas)]/50 p-2.5 space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,z.jsx)(M,{variant:t.status===`completed`?`success`:t.status===`failed`?`destructive`:t.status===`partial`?`warning`:t.status===`cancelled`?`secondary`:`muted`,children:t.status}),(0,z.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:new Date(t.startedAt).toLocaleString()}),s>0&&(0,z.jsxs)(`span`,{className:`text-[var(--app-text-muted)]`,children:[r,`/`,s,` steps`,(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[i>0&&(0,z.jsxs)(`span`,{className:`text-[var(--app-danger)]`,children:[i,` failed`]}),a>0&&(0,z.jsxs)(`span`,{className:`text-[var(--app-warning)]`,children:[a,` skipped`]}),o>0&&(0,z.jsxs)(`span`,{className:`text-[var(--app-text)]`,children:[o,` cancelled`]})]})]}),t.completedAt&&(0,z.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[Math.round((t.completedAt-t.startedAt)/1e3),`s`]}),(0,z.jsx)(`span`,{className:`font-mono text-[var(--app-text-subtle)] truncate max-w-[120px]`,children:t.id.slice(0,8)})]}),(0,z.jsx)(`div`,{className:`space-y-1.5`,children:l.map(n=>{let r=t.stepStatuses[n];if(!r)return null;let i=e.steps.find(e=>e.id===n),a=c.get(n),o=a?.roleId??r.roleId??i?.roleId,s=d.find(e=>e.id===o)?.name??o,l=a?.error??r.error??a?.result??r.result;return(0,z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] gap-2 rounded bg-[var(--app-panel)]/60 px-2 py-1.5 text-xs`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:n}),s&&(0,z.jsxs)(`span`,{className:`text-[var(--app-warning-soft-text)]`,children:[`@`,s]}),i?.dependsOn&&i.dependsOn.length>0&&(0,z.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`after `,i.dependsOn.join(`, `)]})]}),l&&(0,z.jsx)(`div`,{className:`mt-1 truncate ${r.status===`failed`?`text-[var(--app-danger-soft-text)]`:r.status===`skipped`?`text-[var(--app-warning-soft-text)]`:r.status===`cancelled`?`text-[var(--app-text)]`:`text-[var(--app-text-muted)]`}`,children:l})]}),(0,z.jsx)(M,{variant:r.status===`completed`?`success`:r.status===`failed`?`destructive`:r.status===`skipped`?`warning`:r.status===`cancelled`?`secondary`:`muted`,children:r.status}),(0,z.jsxs)(`div`,{className:`text-right text-[var(--app-text-subtle)]`,children:[a?.completedAt&&(0,z.jsxs)(`div`,{children:[Math.max(0,Math.round((a.completedAt-a.createdAt)/1e3)),`s`]}),a?.id&&(0,z.jsx)(`div`,{className:`font-mono`,children:a.id.slice(0,8)})]})]},`${t.id}-${n}`)})})]},t.id)})})]})})]},e.id))})]})}),(0,z.jsx)(re,{open:xe!==null,onOpenChange:e=>{e||B(null)},children:(0,z.jsxs)(S,{children:[(0,z.jsxs)(ne,{children:[(0,z.jsx)(b,{children:`Run Template`}),(0,z.jsxs)(v,{children:[`Run “`,ot?.name,`” now? This will execute the template immediately.`]})]}),(0,z.jsxs)(C,{children:[(0,z.jsx)(T,{children:`Cancel`}),(0,z.jsx)(te,{onClick:()=>{xe&&$(xe),B(null)},children:`Run Now`})]})]})}),(0,z.jsx)(re,{open:V!==null,onOpenChange:e=>{e||Se(null)},children:(0,z.jsxs)(S,{children:[(0,z.jsxs)(ne,{children:[(0,z.jsx)(b,{children:`Delete Template`}),(0,z.jsxs)(v,{children:[`Delete “`,st?.name,`”? This action cannot be undone.`]})]}),(0,z.jsxs)(C,{children:[(0,z.jsx)(T,{children:`Cancel`}),(0,z.jsx)(te,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger)]`,onClick:()=>{V&&tt(V),Se(null)},children:`Delete`})]})]})})]})}function it(){let{tasks:e,templates:t,goals:n}=j(oe(e=>({tasks:e.tasks,templates:e.templates,goals:e.goals}))),r=j(e=>e.fetchTasks),i=j(e=>e.fetchTemplates),a=j(e=>e.fetchGoals);return(0,R.useEffect)(()=>{r(),i(),a()},[r,i,a]),(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsx)(P,{eyebrow:`Operations`,title:`Work`,description:`Tasks, automations, and goals in one place.`,metrics:[{label:`Running`,value:e.filter(e=>e.status===`running`).length},{label:`Automations`,value:t.length},{label:`Goals`,value:n.length}],compact:!0}),(0,z.jsxs)(Xe,{defaultValue:`tasks`,children:[(0,z.jsxs)(Ze,{children:[(0,z.jsx)(Qe,{value:`tasks`,children:`Tasks`}),(0,z.jsx)(Qe,{value:`automations`,children:`Automations`}),(0,z.jsx)(Qe,{value:`goals`,children:`Goals`})]}),(0,z.jsx)($e,{value:`tasks`,children:(0,z.jsx)(tt,{})}),(0,z.jsx)($e,{value:`automations`,children:(0,z.jsx)(rt,{})}),(0,z.jsx)($e,{value:`goals`,children:(0,z.jsx)(ve,{})})]})]})}export{it as Work};
|