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.
Files changed (96) hide show
  1. package/dist/App-ZRCRM7WR.js +13 -0
  2. package/dist/{adam-automator-skills-UFW5TXCC.js → adam-automator-skills-EZGBICHT.js} +1 -1
  3. package/dist/adam-tools-V5LPU47X.js +1 -0
  4. package/dist/{approval-handler-HQO62WK2.js → approval-handler-PB7PSLUS.js} +1 -1
  5. package/dist/audit-manager-BSBBDUER.js +1 -0
  6. package/dist/bree-engine-7S33CWS7.js +1 -0
  7. package/dist/channels-SITUUC4J.js +1 -0
  8. package/dist/{channels-J4STJ4X2.js → channels-ULFUCUUZ.js} +1 -1
  9. package/dist/{chunk-7446ZS6D.js → chunk-2L2347UQ.js} +1 -1
  10. package/dist/{chunk-FXQAUQTI.js → chunk-2YTDCR6A.js} +1 -1
  11. package/dist/chunk-4PQHGLZH.js +99 -0
  12. package/dist/{chunk-NCFVJCNQ.js → chunk-5EPG2US5.js} +2 -2
  13. package/dist/{chunk-2H7UOW4P.js → chunk-5QZXYKMS.js} +1 -1
  14. package/dist/chunk-5XOTPEAK.js +6 -0
  15. package/dist/{chunk-MDBVKBC7.js → chunk-6KF7OO2B.js} +1 -1
  16. package/dist/{chunk-TSPQ44HT.js → chunk-A5OCDYTW.js} +1 -1
  17. package/dist/{chunk-DWRYIN5N.js → chunk-AQ3ASS4B.js} +1 -1
  18. package/dist/{chunk-GMMWA5EG.js → chunk-B6LOT5CG.js} +1 -1
  19. package/dist/{chunk-MJSSCKMB.js → chunk-BCH2HAIM.js} +2 -2
  20. package/dist/{chunk-4C5ITATX.js → chunk-BQ3ZAYHC.js} +1 -1
  21. package/dist/{chunk-YHVYX3F4.js → chunk-DVN3BFPP.js} +1 -1
  22. package/dist/{chunk-P5ZXNBNV.js → chunk-EQZFOBAJ.js} +1 -1
  23. package/dist/{chunk-G5ESQEXN.js → chunk-FPZEZYUB.js} +1 -1
  24. package/dist/{chunk-YXYIA24D.js → chunk-GSFLLRS7.js} +1 -1
  25. package/dist/{chunk-7ZGSJCX5.js → chunk-HQRUJQN7.js} +1 -1
  26. package/dist/{chunk-52PR7XTN.js → chunk-IKPYPZ64.js} +1 -1
  27. package/dist/{chunk-FZCNYKNT.js → chunk-JJH2RCVC.js} +1 -1
  28. package/dist/chunk-K4C43YDD.js +7 -0
  29. package/dist/{chunk-V32YF3J5.js → chunk-M4YI4WVX.js} +1 -1
  30. package/dist/{chunk-WAG3MNMC.js → chunk-NASJH4NT.js} +1 -1
  31. package/dist/{chunk-TNL2LZB7.js → chunk-NUITL62I.js} +1 -1
  32. package/dist/{chunk-3LY6PD6A.js → chunk-NWMOV23A.js} +1 -1
  33. package/dist/chunk-PHT24MOV.js +1 -0
  34. package/dist/{chunk-ZL5JXLAX.js → chunk-QGYDGZSC.js} +1 -1
  35. package/dist/{chunk-VVSZZK5T.js → chunk-RI3V72RP.js} +2 -2
  36. package/dist/{chunk-RLJYEEQC.js → chunk-RZ7LCZVK.js} +1 -1
  37. package/dist/{chunk-5OQZPUBV.js → chunk-TAF2DBBC.js} +8 -8
  38. package/dist/{chunk-HWLSHTVX.js → chunk-ULTK7RD6.js} +3 -3
  39. package/dist/{chunk-DBP7GPWG.js → chunk-WMB7P64J.js} +1 -1
  40. package/dist/cli.js +2 -2
  41. package/dist/{config-KFPS7IEH.js → config-HBQPBIWL.js} +1 -1
  42. package/dist/{db-PZ2V7UCK.js → db-QEWTZGU3.js} +1 -1
  43. package/dist/{delivery-log-ACNJ66RD.js → delivery-log-AC476GX7.js} +1 -1
  44. package/dist/engine-6K4RG644.js +1 -0
  45. package/dist/{evolution-audit-OQDGPKYI.js → evolution-audit-XMBDUN3T.js} +1 -1
  46. package/dist/index.js +13 -10
  47. package/dist/{learner-QCD6BH2J.js → learner-VCS3Q7BR.js} +1 -1
  48. package/dist/{memories-QGMRSBJJ.js → memories-VMOGFVPU.js} +1 -1
  49. package/dist/{memory-extractor-3MRK43A2.js → memory-extractor-4WJNHYWR.js} +2 -2
  50. package/dist/memory-service-ZS6MBUIC.js +1 -0
  51. package/dist/outbound-gateway-H7RFG6D2.js +1 -0
  52. package/dist/role-presets-XAEOYEAW.js +1 -0
  53. package/dist/role-workspace-NKGAH6J6.js +1 -0
  54. package/dist/{roles-KYXNMO5H.js → roles-ZYCFQMAY.js} +1 -1
  55. package/dist/{session-manager-LZ77OT7A.js → session-manager-COLCNIB7.js} +1 -1
  56. package/dist/task-templates-4KCZOUN5.js +1 -0
  57. package/dist/workflow-executor-Z7JFMR56.js +1 -0
  58. package/package.json +25 -25
  59. package/web/dist/assets/{ChannelDetail-DHT8fW0C.js → ChannelDetail-DnL0_h8q.js} +1 -1
  60. package/web/dist/assets/{Channels-YHGNXcRu.js → Channels-dod8Q4oq.js} +1 -1
  61. package/web/dist/assets/{Dashboard-DsHC5W4C.js → Dashboard-Dl0vA6Ky.js} +1 -1
  62. package/web/dist/assets/{EnvVarEditor-Dxy1Kz1Z.js → EnvVarEditor-C-gErAzC.js} +1 -1
  63. package/web/dist/assets/{EventDefDetail-CwprP2ch.js → EventDefDetail-BhJZGNlX.js} +1 -1
  64. package/web/dist/assets/{Events-B19a8cEG.js → Events-DnNZ9-BN.js} +1 -1
  65. package/web/dist/assets/{Evolution-DT6iZvil.js → Evolution-BBWmrrnr.js} +1 -1
  66. package/web/dist/assets/{GoalDetail-BALsnPQl.js → GoalDetail-uqWQCOj3.js} +1 -1
  67. package/web/dist/assets/{Goals-BJIsKgfH.js → Goals-CylKmR9j.js} +1 -1
  68. package/web/dist/assets/{Logs-Cv15aV3l.js → Logs-6rf0KT0z.js} +1 -1
  69. package/web/dist/assets/{Memories-CKAXhAso.js → Memories-CrBTujU7.js} +1 -1
  70. package/web/dist/assets/{Plugins-NO0S2spH.js → Plugins-VKUSUcSE.js} +1 -1
  71. package/web/dist/assets/{RoleDetail-1FNyCD4u.js → RoleDetail-DJc4CWFN.js} +1 -1
  72. package/web/dist/assets/{Roles-grfjw2zy.js → Roles-6pmjn04G.js} +1 -1
  73. package/web/dist/assets/{Settings-9LRLfa_4.js → Settings-DW1jmrNj.js} +1 -1
  74. package/web/dist/assets/{Strategies-BMyd_7_5.js → Strategies-Bmke6qZo.js} +1 -1
  75. package/web/dist/assets/{Switch-CULsD-kC.js → Switch-CfTpXW9_.js} +1 -1
  76. package/web/dist/assets/{TaskDetail-C2yXy8gE.js → TaskDetail-CwJ_UKgt.js} +1 -1
  77. package/web/dist/assets/Work-DVdWNBEm.js +1 -0
  78. package/web/dist/assets/{index-qYKJGoIB.js → index-DYsO5Awn.js} +2 -2
  79. package/web/dist/index.html +1 -1
  80. package/dist/App-WJMHK5EO.js +0 -13
  81. package/dist/adam-tools-IAZSLWYB.js +0 -1
  82. package/dist/audit-manager-LC5EQXCI.js +0 -1
  83. package/dist/bree-engine-M5CZ6A62.js +0 -1
  84. package/dist/channels-5TFYQN5Z.js +0 -1
  85. package/dist/chunk-FIN36WAP.js +0 -99
  86. package/dist/chunk-GGIHDFRW.js +0 -6
  87. package/dist/chunk-I7ZZKPHE.js +0 -7
  88. package/dist/chunk-YDVTWPNA.js +0 -1
  89. package/dist/engine-5DHYHDAP.js +0 -1
  90. package/dist/memory-service-M5ADGITG.js +0 -1
  91. package/dist/outbound-gateway-QRL36F7K.js +0 -1
  92. package/dist/role-presets-DLO3XS54.js +0 -1
  93. package/dist/role-workspace-URSOBCDH.js +0 -1
  94. package/dist/task-templates-YPNWJOVV.js +0 -1
  95. package/dist/workflow-executor-3WMS2WV3.js +0 -1
  96. package/web/dist/assets/Work-dftf35Me.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{_ as t,ct as n,j as r,m as i,n as a,y as o}from"./vendor-icons-Dk0hMuJz.js";import{l as s,t as c}from"./vendor-react-C6faO6LO.js";import{n as l}from"./dist-Bdqp1ixJ.js";import{a as u,c as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./AlertDialog-CfeiyMrc.js";import{t as v}from"./Button-DuQctNms.js";import{r as y}from"./index-qYKJGoIB.js";import{t as b}from"./Card-rKfViPS2.js";import{t as x}from"./PageHeader-CHSgtxPw.js";import{t as S}from"./SectionHeader-C2WpiwJ5.js";import{i as C}from"./format-CHfBBLog.js";import{t as w}from"./EmptyState-CIdIlMbn.js";import{t as T}from"./ui-B_uMx2Fy.js";import{t as E}from"./EnvVarEditor-Dxy1Kz1Z.js";var D=e(n(),1),O=c(),k={anthropic:{label:`Anthropic`,paths:[`anthropic.apiKey`,`anthropic.baseUrl`,`anthropic.model`,`anthropic.defaultOpusModel`,`anthropic.defaultSonnetModel`,`anthropic.defaultHaikuModel`,`anthropic.smallFastModel`]},defaults:{label:`Defaults`,paths:[`defaults.model`,`defaults.effort`,`defaults.maxTurns`,`defaults.maxBudgetUsd`,`defaults.timeout`,`defaults.approvalTimeout`]},server:{label:`Server`,paths:[`server.port`,`server.host`,`server.apiKey`],mutablePaths:[`server.timezone`]},logging:{label:`Logging`,paths:[`logging.level`]},evolution:{label:`Evolution`,paths:[`roles.evolution.triggerEvery`,`roles.evolution.reflectionThreshold`]},chat:{label:`Chat`,paths:[`chat.sessionTimeoutMinutes`,`chat.maxSessionTurns`,`chat.autoTitle`,`chat.archiveExtractMemory`]},workflow:{label:`Workflow`,paths:[`watchdog.rules.artifactCleanup.enabled`,`watchdog.rules.artifactCleanup.ttlDays`,`watchdog.rules.artifactCleanup.orphanGcMinAgeHours`]}},A={anthropic:`Model endpoints and provider-specific defaults.`,defaults:`Global execution defaults applied when a role does not override them.`,server:`Network surface and host-level configuration.`,logging:`Verbosity and runtime observability controls.`,evolution:`Thresholds that govern role adaptation over time.`,chat:`Session lifecycle and archive behavior for chat mode.`,workflow:`Cleanup rules and artifact retention for background work.`},ee=[`defaults.deniedReadPaths`,`defaults.approvalRequired`],j=new Set([`anthropic.apiKey`,`server.apiKey`]),M={"anthropic.apiKey":`API Key`,"anthropic.baseUrl":`Base URL`,"anthropic.model":`Model`,"anthropic.defaultOpusModel":`Default Opus Model`,"anthropic.defaultSonnetModel":`Default Sonnet Model`,"anthropic.defaultHaikuModel":`Default Haiku Model`,"anthropic.smallFastModel":`Small Fast Model`,"defaults.model":`Default Model`,"defaults.effort":`Effort Level`,"defaults.maxTurns":`Max Turns`,"defaults.maxBudgetUsd":`Max Budget (USD)`,"defaults.timeout":`Timeout (seconds)`,"defaults.approvalTimeout":`Approval Timeout (seconds)`,"server.port":`Port`,"server.host":`Host`,"server.apiKey":`API Key (server auth)`,"server.timezone":`Timezone`,"logging.level":`Log Level`,"roles.evolution.triggerEvery":`Evolution Trigger Every (tasks)`,"roles.evolution.reflectionThreshold":`Reflection Threshold (tokens)`,"chat.sessionTimeoutMinutes":`Session Timeout (minutes)`,"chat.maxSessionTurns":`Max Session Turns`,"chat.autoTitle":`Auto-generate Session Title`,"chat.archiveExtractMemory":`Extract Memory on Archive`,"watchdog.rules.artifactCleanup.enabled":`Workflow Artifact Cleanup Enabled`,"watchdog.rules.artifactCleanup.ttlDays":`Artifact Retention (days)`,"watchdog.rules.artifactCleanup.orphanGcMinAgeHours":`Orphan File GC Min Age (hours)`},te={"defaults.effort":[`low`,`medium`,`high`,`max`],"logging.level":[`debug`,`info`,`warn`,`error`],"server.timezone":[`system`,`Asia/Shanghai`,`Asia/Tokyo`,`Asia/Singapore`,`America/New_York`,`America/Los_Angeles`,`America/Chicago`,`Europe/London`,`Europe/Berlin`,`Europe/Paris`,`UTC`]};function N(){let[e,n]=(0,D.useState)({}),[a,c]=(0,D.useState)([]),[T,N]=(0,D.useState)({}),[F,I]=(0,D.useState)(new Set),[L,R]=(0,D.useState)(!1),[z,B]=(0,D.useState)(null),[ne,V]=(0,D.useState)(!0),[H,U]=(0,D.useState)(null),[W,G]=(0,D.useState)({}),[K,q]=(0,D.useState)(new Set),[J,Y]=(0,D.useState)({}),X=y(e=>e.configVersion);(0,D.useEffect)(()=>{if(F.size===0)return;let e=e=>{e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[F.size]);let Z=s(({currentLocation:e,nextLocation:t})=>F.size>0&&e.pathname!==t.pathname),Q=(0,D.useCallback)(async()=>{try{let e=await l(`/config`);n(e.config),c(e.mutable);let t={};for(let[n,r]of Object.entries(e.config))t[n]=String(r.value??``);N(t),I(new Set);let r=e.config[`server.timezone`]?.value;r&&C(r);let i={};for(let t of ee){let n=e.config[t];n&&(i[t]=Array.isArray(n.value)?n.value:[])}G(i),q(new Set),U(await l(`/config/env-diff`)),Y((await l(`/config/env`)).env)}catch(e){B({type:`error`,text:e instanceof Error?e.message:`Failed to load config`})}finally{V(!1)}},[]);(0,D.useEffect)(()=>{Q()},[Q]),(0,D.useEffect)(()=>{X>0&&Q()},[X,Q]);let re=async()=>{await l(`/config/sync-to-env`,{method:`POST`}),B({type:`success`,text:`Synced DB values to .env`}),U(null)},ie=async()=>{await l(`/config/load-from-env`,{method:`POST`}),B({type:`success`,text:`Loaded .env values to DB`}),Q()},$=(e,t)=>{N(n=>({...n,[e]:t})),I(t=>new Set(t).add(e)),B(null)},ae=async()=>{if(F.size!==0){R(!0),B(null);try{let t={};for(let n of F){let r=e[n],i=T[n];if(r&&typeof r.value==`number`&&(i=Number(i),isNaN(i))){B({type:`error`,text:`"${M[n]??n}" must be a number`}),R(!1);return}t[n]=i}let n=await l(`/config`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...Object.fromEntries(Array.from(K).map(e=>[e,W[e]??[]]))})});if(n.updated.length>0&&(B({type:`success`,text:`Updated ${n.updated.length} setting(s)`}),n.updated.includes(`server.timezone`))){let e=T[`server.timezone`];C(e)}n.errors.length>0&&B({type:`error`,text:n.errors.join(`; `)}),I(new Set),Q()}catch(e){B({type:`error`,text:e instanceof Error?e.message:`Save failed`})}finally{R(!1)}}};return ne?(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,O.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):Object.keys(e).length===0?(0,O.jsx)(w,{icon:(0,O.jsx)(i,{size:32}),title:`No configuration`,description:`Config API not available`}):(0,O.jsxs)(`div`,{className:`space-y-5`,children:[(0,O.jsx)(x,{eyebrow:`Configuration`,title:`Settings`,compact:!0,description:`Mutable fields, pending edits, and environment drift.`,metrics:[{label:`Editable`,value:a.length},{label:`Pending`,value:F.size+K.size},{label:`Env Drift`,value:H?.diffs.length??0}],actions:(0,O.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,O.jsx)(v,{variant:`ghost`,size:`sm`,onClick:()=>void Q(),children:(0,O.jsx)(o,{size:14})}),F.size>0&&(0,O.jsxs)(v,{size:`sm`,onClick:()=>void ae(),disabled:L,children:[(0,O.jsx)(t,{size:14}),L?`Saving...`:`Save (${F.size})`]})]})}),(0,O.jsx)(S,{title:`Configuration Groups`,compact:!0,description:`Fields stay in place while changeable, restart-required, and pending state are clarified.`}),z&&(0,O.jsx)(`div`,{className:`rounded-lg border px-4 py-3 text-sm ${z.type===`success`?`border-[var(--app-success-soft-border)] bg-[var(--app-success-soft-bg)] text-[var(--app-success-soft-text)]`:`border-[var(--app-danger-soft-border)] bg-[var(--app-danger-soft-bg)] text-[var(--app-danger-soft-text)]`}`,children:z.text}),H&&H.diffs.length>0&&(0,O.jsx)(b,{className:`surface-accent`,children:(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`p`,{className:`text-sm font-medium text-[var(--app-text)]`,children:[`.env and DB have `,H.diffs.length,` different value(s)`]}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-muted)]`,children:H.diffs.map(e=>e.envKey).join(`, `)})]}),(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-2 md:justify-end`,children:[(0,O.jsx)(v,{variant:`ghost`,size:`sm`,onClick:re,children:`Sync DB → .env`}),(0,O.jsx)(v,{variant:`ghost`,size:`sm`,onClick:ie,children:`Load .env → DB`})]})]})}),Object.entries(k).map(([t,{label:n,paths:i,mutablePaths:o}])=>{let s=[...i,...o??[]],c=s.filter(e=>a.includes(e)).length;return(0,O.jsxs)(b,{children:[(0,O.jsxs)(`div`,{className:`mb-4 flex items-start justify-between gap-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-medium text-[var(--app-text)]`,children:n}),(0,O.jsx)(`p`,{className:`mt-1 text-sm text-[var(--app-text-muted)]`,children:A[t]??`Configuration values for this system area.`})]}),(0,O.jsxs)(`div`,{className:`rounded-full border border-[var(--app-border)] bg-black/10 px-3 py-1.5 text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:[c,`/`,s.length,` editable`]})]}),(0,O.jsx)(`div`,{className:`space-y-3`,children:s.map(t=>{let n=e[t];if(!n)return null;let i=a.includes(t),o=M[t]??t,s=T[t]??String(n.value??``),c=F.has(t),l=te[t];return(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-[var(--app-border)] bg-black/10 px-3 py-3 md:flex-row md:items-center md:gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 md:w-56 md:shrink-0`,children:[!i&&(0,O.jsx)(r,{size:12,className:`text-[var(--app-text-subtle)]`}),(0,O.jsx)(`label`,{className:`text-sm text-[var(--app-text-muted)]`,children:o}),!i&&(0,O.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`restart required`})]}),(0,O.jsx)(`div`,{className:`min-w-0 flex-1`,children:l?(0,O.jsx)(`select`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none disabled:opacity-50`,value:s,onChange:e=>$(t,e.target.value),disabled:!i,children:l.map(e=>(0,O.jsx)(`option`,{value:e,children:e},e))}):(0,O.jsx)(`input`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none disabled:opacity-50`,type:j.has(t)?`password`:`text`,value:s,onChange:e=>$(t,e.target.value),disabled:!i,placeholder:j.has(t)?`Enter to update`:void 0})}),(0,O.jsx)(`div`,{className:`text-left md:w-16 md:text-right`,children:c&&i&&(0,O.jsx)(`span`,{className:`text-[10px] text-[var(--app-warning)]`,children:`modified`})})]},t)})})]},t)}),(0,O.jsx)(E,{envVars:J,onSave:()=>void Q(),mode:`global`,title:`Environment Variables`}),(0,O.jsx)(P,{mutablePaths:a,listValues:W,listDirty:K,setListValues:G,setListDirty:e=>q(e),dirty:F}),(0,O.jsx)(_,{open:Z.state===`blocked`,children:(0,O.jsxs)(f,{children:[(0,O.jsxs)(g,{children:[(0,O.jsx)(d,{children:`Unsaved Changes`}),(0,O.jsxs)(u,{children:[`You have `,F.size+K.size,` unsaved change(s). Discard and leave?`]})]}),(0,O.jsxs)(m,{children:[(0,O.jsx)(h,{onClick:()=>Z.reset?.(),children:`Stay`}),(0,O.jsx)(p,{onClick:()=>Z.proceed?.(),children:`Discard`})]})]})})]})}function P({mutablePaths:e,listValues:t,listDirty:n,setListValues:i,setListDirty:o,dirty:s}){let[c,l]=(0,D.useState)(``),[u,d]=(0,D.useState)(``),f=e.includes(`defaults.deniedReadPaths`),p=e.includes(`defaults.approvalRequired`),m=t[`defaults.deniedReadPaths`]??[],h=t[`defaults.approvalRequired`]??[],g=[`~/.ssh`,`~/.aws`,`~/.gnupg`,`/etc/shadow`],_=[`rm -rf *`,`git push*`,`git reset*`,`curl * -X POST*`,`curl * --request POST*`],y=e=>g.some(t=>e===(t.startsWith(`~/`),t)||e===t),x=e=>_.includes(e),S=()=>{let e=c.trim();!e||m.includes(e)||(i(t=>({...t,"defaults.deniedReadPaths":[...m,e]})),o(e=>new Set(e).add(`defaults.deniedReadPaths`)),l(``))},C=e=>{y(e)||(i(t=>({...t,"defaults.deniedReadPaths":m.filter(t=>t!==e)})),o(e=>new Set(e).add(`defaults.deniedReadPaths`)))},w=()=>{let e=u.trim();!e||h.includes(e)||(i(t=>({...t,"defaults.approvalRequired":[...h,e]})),o(e=>new Set(e).add(`defaults.approvalRequired`)),d(``))},E=e=>{x(e)||(i(t=>({...t,"defaults.approvalRequired":h.filter(t=>t!==e)})),o(e=>new Set(e).add(`defaults.approvalRequired`)))},k=s.size+n.size;return(0,O.jsxs)(b,{children:[(0,O.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Advanced`}),k>0&&(0,O.jsxs)(`span`,{className:`text-[10px] text-[var(--app-warning)]`,children:[n.size,` modified`]})]}),(0,O.jsxs)(`div`,{className:`mb-6`,children:[(0,O.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,O.jsx)(`h3`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Denied Read Paths`}),!f&&(0,O.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[(0,O.jsx)(r,{size:T.xs}),` restart required`]})]}),(0,O.jsxs)(`p`,{className:`mb-2 text-xs text-[var(--app-text-subtle)]`,children:[`Paths blocked at both the SDK and OS layer for all roles. System defaults (locked) cannot be removed. Uses `,(0,O.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`*`}),` as wildcard.`]}),(0,O.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:m.map(e=>{let t=y(e);return(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border px-2 py-0.5 text-xs ${t?`border-[var(--app-border)] bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)]`:`border-[var(--app-danger-soft-border)] bg-[var(--app-danger-soft-bg)] text-[var(--app-danger-soft-text)]`}`,children:[t&&(0,O.jsx)(r,{size:T.xs}),e,!t&&f&&(0,O.jsx)(`button`,{type:`button`,className:`ml-0.5 text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,onClick:()=>C(e),children:(0,O.jsx)(a,{size:T.xs})})]},e)})}),f&&(0,O.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,O.jsx)(`input`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1 text-xs text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`/absolute/path or ~/path`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S())}}),(0,O.jsx)(v,{variant:`ghost`,size:`sm`,className:`scale-75`,onClick:()=>S(),children:`Add`})]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,O.jsx)(`h3`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Approval Required Patterns`}),!p&&(0,O.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[(0,O.jsx)(r,{size:T.xs}),` restart required`]})]}),(0,O.jsxs)(`p`,{className:`mb-2 text-xs text-[var(--app-text-subtle)]`,children:[`Operations matching these glob patterns require user approval before execution. Uses SDK Permission Rule glob syntax (`,(0,O.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`*`}),` = wildcard, e.g.,`,` `,(0,O.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`rm -rf *`}),`).`]}),(0,O.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:h.map(e=>{let t=x(e);return(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border px-2 py-0.5 text-xs ${t?`border-[var(--app-border)] bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)]`:`border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg)] text-[var(--app-warning-soft-text)]`}`,children:[t&&(0,O.jsx)(r,{size:T.xs}),e,!t&&p&&(0,O.jsx)(`button`,{type:`button`,className:`ml-0.5 text-[var(--app-warning)] hover:text-[var(--app-warning-soft-text)]`,onClick:()=>E(e),children:(0,O.jsx)(a,{size:T.xs})})]},e)})}),p&&(0,O.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,O.jsx)(`input`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1 text-xs text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`e.g. "curl * --request POST *"`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),w())}}),(0,O.jsx)(v,{variant:`ghost`,size:`sm`,className:`scale-75`,onClick:()=>w(),children:`Add`})]})]})]})}export{N as Settings};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{_ as t,ct as n,j as r,m as i,n as a,y as o}from"./vendor-icons-Dk0hMuJz.js";import{l as s,t as c}from"./vendor-react-C6faO6LO.js";import{n as l}from"./dist-Bdqp1ixJ.js";import{a as u,c as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./AlertDialog-CfeiyMrc.js";import{t as v}from"./Button-DuQctNms.js";import{r as y}from"./index-DYsO5Awn.js";import{t as b}from"./Card-rKfViPS2.js";import{t as x}from"./PageHeader-CHSgtxPw.js";import{t as S}from"./SectionHeader-C2WpiwJ5.js";import{i as C}from"./format-CHfBBLog.js";import{t as w}from"./EmptyState-CIdIlMbn.js";import{t as T}from"./ui-B_uMx2Fy.js";import{t as E}from"./EnvVarEditor-C-gErAzC.js";var D=e(n(),1),O=c(),k={anthropic:{label:`Anthropic`,paths:[`anthropic.apiKey`,`anthropic.baseUrl`,`anthropic.model`,`anthropic.defaultOpusModel`,`anthropic.defaultSonnetModel`,`anthropic.defaultHaikuModel`,`anthropic.smallFastModel`]},defaults:{label:`Defaults`,paths:[`defaults.model`,`defaults.effort`,`defaults.maxTurns`,`defaults.maxBudgetUsd`,`defaults.timeout`,`defaults.approvalTimeout`]},server:{label:`Server`,paths:[`server.port`,`server.host`,`server.apiKey`],mutablePaths:[`server.timezone`]},logging:{label:`Logging`,paths:[`logging.level`]},evolution:{label:`Evolution`,paths:[`roles.evolution.triggerEvery`,`roles.evolution.reflectionThreshold`]},chat:{label:`Chat`,paths:[`chat.sessionTimeoutMinutes`,`chat.maxSessionTurns`,`chat.autoTitle`,`chat.archiveExtractMemory`]},workflow:{label:`Workflow`,paths:[`watchdog.rules.artifactCleanup.enabled`,`watchdog.rules.artifactCleanup.ttlDays`,`watchdog.rules.artifactCleanup.orphanGcMinAgeHours`]}},A={anthropic:`Model endpoints and provider-specific defaults.`,defaults:`Global execution defaults applied when a role does not override them.`,server:`Network surface and host-level configuration.`,logging:`Verbosity and runtime observability controls.`,evolution:`Thresholds that govern role adaptation over time.`,chat:`Session lifecycle and archive behavior for chat mode.`,workflow:`Cleanup rules and artifact retention for background work.`},ee=[`defaults.deniedReadPaths`,`defaults.approvalRequired`],j=new Set([`anthropic.apiKey`,`server.apiKey`]),M={"anthropic.apiKey":`API Key`,"anthropic.baseUrl":`Base URL`,"anthropic.model":`Model`,"anthropic.defaultOpusModel":`Default Opus Model`,"anthropic.defaultSonnetModel":`Default Sonnet Model`,"anthropic.defaultHaikuModel":`Default Haiku Model`,"anthropic.smallFastModel":`Small Fast Model`,"defaults.model":`Default Model`,"defaults.effort":`Effort Level`,"defaults.maxTurns":`Max Turns`,"defaults.maxBudgetUsd":`Max Budget (USD)`,"defaults.timeout":`Timeout (seconds)`,"defaults.approvalTimeout":`Approval Timeout (seconds)`,"server.port":`Port`,"server.host":`Host`,"server.apiKey":`API Key (server auth)`,"server.timezone":`Timezone`,"logging.level":`Log Level`,"roles.evolution.triggerEvery":`Evolution Trigger Every (tasks)`,"roles.evolution.reflectionThreshold":`Reflection Threshold (tokens)`,"chat.sessionTimeoutMinutes":`Session Timeout (minutes)`,"chat.maxSessionTurns":`Max Session Turns`,"chat.autoTitle":`Auto-generate Session Title`,"chat.archiveExtractMemory":`Extract Memory on Archive`,"watchdog.rules.artifactCleanup.enabled":`Workflow Artifact Cleanup Enabled`,"watchdog.rules.artifactCleanup.ttlDays":`Artifact Retention (days)`,"watchdog.rules.artifactCleanup.orphanGcMinAgeHours":`Orphan File GC Min Age (hours)`},te={"defaults.effort":[`low`,`medium`,`high`,`max`],"logging.level":[`debug`,`info`,`warn`,`error`],"server.timezone":[`system`,`Asia/Shanghai`,`Asia/Tokyo`,`Asia/Singapore`,`America/New_York`,`America/Los_Angeles`,`America/Chicago`,`Europe/London`,`Europe/Berlin`,`Europe/Paris`,`UTC`]};function N(){let[e,n]=(0,D.useState)({}),[a,c]=(0,D.useState)([]),[T,N]=(0,D.useState)({}),[F,I]=(0,D.useState)(new Set),[L,R]=(0,D.useState)(!1),[z,B]=(0,D.useState)(null),[ne,V]=(0,D.useState)(!0),[H,U]=(0,D.useState)(null),[W,G]=(0,D.useState)({}),[K,q]=(0,D.useState)(new Set),[J,Y]=(0,D.useState)({}),X=y(e=>e.configVersion);(0,D.useEffect)(()=>{if(F.size===0)return;let e=e=>{e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[F.size]);let Z=s(({currentLocation:e,nextLocation:t})=>F.size>0&&e.pathname!==t.pathname),Q=(0,D.useCallback)(async()=>{try{let e=await l(`/config`);n(e.config),c(e.mutable);let t={};for(let[n,r]of Object.entries(e.config))t[n]=String(r.value??``);N(t),I(new Set);let r=e.config[`server.timezone`]?.value;r&&C(r);let i={};for(let t of ee){let n=e.config[t];n&&(i[t]=Array.isArray(n.value)?n.value:[])}G(i),q(new Set),U(await l(`/config/env-diff`)),Y((await l(`/config/env`)).env)}catch(e){B({type:`error`,text:e instanceof Error?e.message:`Failed to load config`})}finally{V(!1)}},[]);(0,D.useEffect)(()=>{Q()},[Q]),(0,D.useEffect)(()=>{X>0&&Q()},[X,Q]);let re=async()=>{await l(`/config/sync-to-env`,{method:`POST`}),B({type:`success`,text:`Synced DB values to .env`}),U(null)},ie=async()=>{await l(`/config/load-from-env`,{method:`POST`}),B({type:`success`,text:`Loaded .env values to DB`}),Q()},$=(e,t)=>{N(n=>({...n,[e]:t})),I(t=>new Set(t).add(e)),B(null)},ae=async()=>{if(F.size!==0){R(!0),B(null);try{let t={};for(let n of F){let r=e[n],i=T[n];if(r&&typeof r.value==`number`&&(i=Number(i),isNaN(i))){B({type:`error`,text:`"${M[n]??n}" must be a number`}),R(!1);return}t[n]=i}let n=await l(`/config`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...Object.fromEntries(Array.from(K).map(e=>[e,W[e]??[]]))})});if(n.updated.length>0&&(B({type:`success`,text:`Updated ${n.updated.length} setting(s)`}),n.updated.includes(`server.timezone`))){let e=T[`server.timezone`];C(e)}n.errors.length>0&&B({type:`error`,text:n.errors.join(`; `)}),I(new Set),Q()}catch(e){B({type:`error`,text:e instanceof Error?e.message:`Save failed`})}finally{R(!1)}}};return ne?(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,O.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):Object.keys(e).length===0?(0,O.jsx)(w,{icon:(0,O.jsx)(i,{size:32}),title:`No configuration`,description:`Config API not available`}):(0,O.jsxs)(`div`,{className:`space-y-5`,children:[(0,O.jsx)(x,{eyebrow:`Configuration`,title:`Settings`,compact:!0,description:`Mutable fields, pending edits, and environment drift.`,metrics:[{label:`Editable`,value:a.length},{label:`Pending`,value:F.size+K.size},{label:`Env Drift`,value:H?.diffs.length??0}],actions:(0,O.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,O.jsx)(v,{variant:`ghost`,size:`sm`,onClick:()=>void Q(),children:(0,O.jsx)(o,{size:14})}),F.size>0&&(0,O.jsxs)(v,{size:`sm`,onClick:()=>void ae(),disabled:L,children:[(0,O.jsx)(t,{size:14}),L?`Saving...`:`Save (${F.size})`]})]})}),(0,O.jsx)(S,{title:`Configuration Groups`,compact:!0,description:`Fields stay in place while changeable, restart-required, and pending state are clarified.`}),z&&(0,O.jsx)(`div`,{className:`rounded-lg border px-4 py-3 text-sm ${z.type===`success`?`border-[var(--app-success-soft-border)] bg-[var(--app-success-soft-bg)] text-[var(--app-success-soft-text)]`:`border-[var(--app-danger-soft-border)] bg-[var(--app-danger-soft-bg)] text-[var(--app-danger-soft-text)]`}`,children:z.text}),H&&H.diffs.length>0&&(0,O.jsx)(b,{className:`surface-accent`,children:(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`p`,{className:`text-sm font-medium text-[var(--app-text)]`,children:[`.env and DB have `,H.diffs.length,` different value(s)`]}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-muted)]`,children:H.diffs.map(e=>e.envKey).join(`, `)})]}),(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-2 md:justify-end`,children:[(0,O.jsx)(v,{variant:`ghost`,size:`sm`,onClick:re,children:`Sync DB → .env`}),(0,O.jsx)(v,{variant:`ghost`,size:`sm`,onClick:ie,children:`Load .env → DB`})]})]})}),Object.entries(k).map(([t,{label:n,paths:i,mutablePaths:o}])=>{let s=[...i,...o??[]],c=s.filter(e=>a.includes(e)).length;return(0,O.jsxs)(b,{children:[(0,O.jsxs)(`div`,{className:`mb-4 flex items-start justify-between gap-4`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{className:`text-sm font-medium text-[var(--app-text)]`,children:n}),(0,O.jsx)(`p`,{className:`mt-1 text-sm text-[var(--app-text-muted)]`,children:A[t]??`Configuration values for this system area.`})]}),(0,O.jsxs)(`div`,{className:`rounded-full border border-[var(--app-border)] bg-black/10 px-3 py-1.5 text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:[c,`/`,s.length,` editable`]})]}),(0,O.jsx)(`div`,{className:`space-y-3`,children:s.map(t=>{let n=e[t];if(!n)return null;let i=a.includes(t),o=M[t]??t,s=T[t]??String(n.value??``),c=F.has(t),l=te[t];return(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-[var(--app-border)] bg-black/10 px-3 py-3 md:flex-row md:items-center md:gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 md:w-56 md:shrink-0`,children:[!i&&(0,O.jsx)(r,{size:12,className:`text-[var(--app-text-subtle)]`}),(0,O.jsx)(`label`,{className:`text-sm text-[var(--app-text-muted)]`,children:o}),!i&&(0,O.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`restart required`})]}),(0,O.jsx)(`div`,{className:`min-w-0 flex-1`,children:l?(0,O.jsx)(`select`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none disabled:opacity-50`,value:s,onChange:e=>$(t,e.target.value),disabled:!i,children:l.map(e=>(0,O.jsx)(`option`,{value:e,children:e},e))}):(0,O.jsx)(`input`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none disabled:opacity-50`,type:j.has(t)?`password`:`text`,value:s,onChange:e=>$(t,e.target.value),disabled:!i,placeholder:j.has(t)?`Enter to update`:void 0})}),(0,O.jsx)(`div`,{className:`text-left md:w-16 md:text-right`,children:c&&i&&(0,O.jsx)(`span`,{className:`text-[10px] text-[var(--app-warning)]`,children:`modified`})})]},t)})})]},t)}),(0,O.jsx)(E,{envVars:J,onSave:()=>void Q(),mode:`global`,title:`Environment Variables`}),(0,O.jsx)(P,{mutablePaths:a,listValues:W,listDirty:K,setListValues:G,setListDirty:e=>q(e),dirty:F}),(0,O.jsx)(_,{open:Z.state===`blocked`,children:(0,O.jsxs)(f,{children:[(0,O.jsxs)(g,{children:[(0,O.jsx)(d,{children:`Unsaved Changes`}),(0,O.jsxs)(u,{children:[`You have `,F.size+K.size,` unsaved change(s). Discard and leave?`]})]}),(0,O.jsxs)(m,{children:[(0,O.jsx)(h,{onClick:()=>Z.reset?.(),children:`Stay`}),(0,O.jsx)(p,{onClick:()=>Z.proceed?.(),children:`Discard`})]})]})})]})}function P({mutablePaths:e,listValues:t,listDirty:n,setListValues:i,setListDirty:o,dirty:s}){let[c,l]=(0,D.useState)(``),[u,d]=(0,D.useState)(``),f=e.includes(`defaults.deniedReadPaths`),p=e.includes(`defaults.approvalRequired`),m=t[`defaults.deniedReadPaths`]??[],h=t[`defaults.approvalRequired`]??[],g=[`~/.ssh`,`~/.aws`,`~/.gnupg`,`/etc/shadow`],_=[`rm -rf *`,`git push*`,`git reset*`,`curl * -X POST*`,`curl * --request POST*`],y=e=>g.some(t=>e===(t.startsWith(`~/`),t)||e===t),x=e=>_.includes(e),S=()=>{let e=c.trim();!e||m.includes(e)||(i(t=>({...t,"defaults.deniedReadPaths":[...m,e]})),o(e=>new Set(e).add(`defaults.deniedReadPaths`)),l(``))},C=e=>{y(e)||(i(t=>({...t,"defaults.deniedReadPaths":m.filter(t=>t!==e)})),o(e=>new Set(e).add(`defaults.deniedReadPaths`)))},w=()=>{let e=u.trim();!e||h.includes(e)||(i(t=>({...t,"defaults.approvalRequired":[...h,e]})),o(e=>new Set(e).add(`defaults.approvalRequired`)),d(``))},E=e=>{x(e)||(i(t=>({...t,"defaults.approvalRequired":h.filter(t=>t!==e)})),o(e=>new Set(e).add(`defaults.approvalRequired`)))},k=s.size+n.size;return(0,O.jsxs)(b,{children:[(0,O.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,O.jsx)(`h2`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Advanced`}),k>0&&(0,O.jsxs)(`span`,{className:`text-[10px] text-[var(--app-warning)]`,children:[n.size,` modified`]})]}),(0,O.jsxs)(`div`,{className:`mb-6`,children:[(0,O.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,O.jsx)(`h3`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Denied Read Paths`}),!f&&(0,O.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[(0,O.jsx)(r,{size:T.xs}),` restart required`]})]}),(0,O.jsxs)(`p`,{className:`mb-2 text-xs text-[var(--app-text-subtle)]`,children:[`Paths blocked at both the SDK and OS layer for all roles. System defaults (locked) cannot be removed. Uses `,(0,O.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`*`}),` as wildcard.`]}),(0,O.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:m.map(e=>{let t=y(e);return(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border px-2 py-0.5 text-xs ${t?`border-[var(--app-border)] bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)]`:`border-[var(--app-danger-soft-border)] bg-[var(--app-danger-soft-bg)] text-[var(--app-danger-soft-text)]`}`,children:[t&&(0,O.jsx)(r,{size:T.xs}),e,!t&&f&&(0,O.jsx)(`button`,{type:`button`,className:`ml-0.5 text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,onClick:()=>C(e),children:(0,O.jsx)(a,{size:T.xs})})]},e)})}),f&&(0,O.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,O.jsx)(`input`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1 text-xs text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`/absolute/path or ~/path`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S())}}),(0,O.jsx)(v,{variant:`ghost`,size:`sm`,className:`scale-75`,onClick:()=>S(),children:`Add`})]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,O.jsx)(`h3`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Approval Required Patterns`}),!p&&(0,O.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[(0,O.jsx)(r,{size:T.xs}),` restart required`]})]}),(0,O.jsxs)(`p`,{className:`mb-2 text-xs text-[var(--app-text-subtle)]`,children:[`Operations matching these glob patterns require user approval before execution. Uses SDK Permission Rule glob syntax (`,(0,O.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`*`}),` = wildcard, e.g.,`,` `,(0,O.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`rm -rf *`}),`).`]}),(0,O.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:h.map(e=>{let t=x(e);return(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border px-2 py-0.5 text-xs ${t?`border-[var(--app-border)] bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)]`:`border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg)] text-[var(--app-warning-soft-text)]`}`,children:[t&&(0,O.jsx)(r,{size:T.xs}),e,!t&&p&&(0,O.jsx)(`button`,{type:`button`,className:`ml-0.5 text-[var(--app-warning)] hover:text-[var(--app-warning-soft-text)]`,onClick:()=>E(e),children:(0,O.jsx)(a,{size:T.xs})})]},e)})}),p&&(0,O.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,O.jsx)(`input`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1 text-xs text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`e.g. "curl * --request POST *"`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),w())}}),(0,O.jsx)(v,{variant:`ghost`,size:`sm`,className:`scale-75`,onClick:()=>w(),children:`Add`})]})]})]})}export{N as Settings};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{P as t,ct as n,y as r}from"./vendor-icons-Dk0hMuJz.js";import{t as i}from"./vendor-react-C6faO6LO.js";import{t as a}from"./Button-DuQctNms.js";import{r as o,t as s}from"./index-qYKJGoIB.js";import{t as c}from"./Card-rKfViPS2.js";import{t as l}from"./PageHeader-CHSgtxPw.js";import{a as u}from"./format-CHfBBLog.js";import{t as d}from"./EmptyState-CIdIlMbn.js";import{a as f,i as p,n as m,o as h,r as g,t as _}from"./Table-DuOLbyJQ.js";var v=e(n(),1),y=i(),b={engineer:`info`,analyst:`warning`,content_creator:`success`,reviewer:`muted`};function x(){let e=o(e=>e.strategies),n=o(e=>e.fetchStrategies);(0,v.useEffect)(()=>{n()},[n]);let i=new Map;for(let t of e){let e=i.get(t.roleId)??[];e.push(t),i.set(t.roleId,e)}return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsx)(l,{compact:!0,title:`Strategies`,description:`Bandit strategies grouped by role.`,metrics:[{label:`Catalog`,value:e.length},{label:`Roles`,value:i.size},{label:`Mature`,value:e.filter(e=>e.totalTrials>=10).length}],className:`px-4 py-3 lg:px-4 lg:py-3`,actions:(0,y.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>void n(),children:(0,y.jsx)(r,{size:14})})}),e.length===0?(0,y.jsx)(c,{className:`p-4`,children:(0,y.jsx)(d,{icon:(0,y.jsx)(t,{size:32}),title:`No strategies`,description:`Strategies are created by the Thompson Sampling engine as agents process tasks.`,compact:!0})}):Array.from(i.entries()).map(([e,t])=>(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(s,{variant:b[e]??`muted`,children:e}),(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[t.length,` strategies`]})]}),(0,y.jsx)(c,{padding:!1,children:(0,y.jsxs)(_,{children:[(0,y.jsx)(f,{children:(0,y.jsxs)(h,{children:[(0,y.jsx)(p,{children:`Name`}),(0,y.jsx)(p,{children:`Task Type`}),(0,y.jsx)(p,{children:`Alpha`}),(0,y.jsx)(p,{children:`Beta`}),(0,y.jsx)(p,{children:`Trials`}),(0,y.jsx)(p,{children:`Avg Reward`}),(0,y.jsx)(p,{children:`Created`})]})}),(0,y.jsx)(m,{children:t.map(e=>(0,y.jsxs)(h,{children:[(0,y.jsx)(g,{className:`font-medium text-[var(--app-text)]`,children:e.name}),(0,y.jsx)(g,{children:(0,y.jsx)(`span`,{className:`rounded bg-[var(--app-panel-elevated)] px-1.5 py-0.5 font-mono text-[10px] text-[var(--app-text-muted)]`,children:e.taskType})}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.alpha.toFixed(2)}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.beta.toFixed(2)}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.totalTrials}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.avgReward==null?`—`:e.avgReward.toFixed(3)}),(0,y.jsx)(g,{className:`text-xs text-[var(--app-text-subtle)]`,children:u(e.createdAt)})]},e.id))})]})})]},e))]})}export{x as Strategies};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{P as t,ct as n,y as r}from"./vendor-icons-Dk0hMuJz.js";import{t as i}from"./vendor-react-C6faO6LO.js";import{t as a}from"./Button-DuQctNms.js";import{r as o,t as s}from"./index-DYsO5Awn.js";import{t as c}from"./Card-rKfViPS2.js";import{t as l}from"./PageHeader-CHSgtxPw.js";import{a as u}from"./format-CHfBBLog.js";import{t as d}from"./EmptyState-CIdIlMbn.js";import{a as f,i as p,n as m,o as h,r as g,t as _}from"./Table-DuOLbyJQ.js";var v=e(n(),1),y=i(),b={engineer:`info`,analyst:`warning`,content_creator:`success`,reviewer:`muted`};function x(){let e=o(e=>e.strategies),n=o(e=>e.fetchStrategies);(0,v.useEffect)(()=>{n()},[n]);let i=new Map;for(let t of e){let e=i.get(t.roleId)??[];e.push(t),i.set(t.roleId,e)}return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsx)(l,{compact:!0,title:`Strategies`,description:`Bandit strategies grouped by role.`,metrics:[{label:`Catalog`,value:e.length},{label:`Roles`,value:i.size},{label:`Mature`,value:e.filter(e=>e.totalTrials>=10).length}],className:`px-4 py-3 lg:px-4 lg:py-3`,actions:(0,y.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>void n(),children:(0,y.jsx)(r,{size:14})})}),e.length===0?(0,y.jsx)(c,{className:`p-4`,children:(0,y.jsx)(d,{icon:(0,y.jsx)(t,{size:32}),title:`No strategies`,description:`Strategies are created by the Thompson Sampling engine as agents process tasks.`,compact:!0})}):Array.from(i.entries()).map(([e,t])=>(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(s,{variant:b[e]??`muted`,children:e}),(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[t.length,` strategies`]})]}),(0,y.jsx)(c,{padding:!1,children:(0,y.jsxs)(_,{children:[(0,y.jsx)(f,{children:(0,y.jsxs)(h,{children:[(0,y.jsx)(p,{children:`Name`}),(0,y.jsx)(p,{children:`Task Type`}),(0,y.jsx)(p,{children:`Alpha`}),(0,y.jsx)(p,{children:`Beta`}),(0,y.jsx)(p,{children:`Trials`}),(0,y.jsx)(p,{children:`Avg Reward`}),(0,y.jsx)(p,{children:`Created`})]})}),(0,y.jsx)(m,{children:t.map(e=>(0,y.jsxs)(h,{children:[(0,y.jsx)(g,{className:`font-medium text-[var(--app-text)]`,children:e.name}),(0,y.jsx)(g,{children:(0,y.jsx)(`span`,{className:`rounded bg-[var(--app-panel-elevated)] px-1.5 py-0.5 font-mono text-[10px] text-[var(--app-text-muted)]`,children:e.taskType})}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.alpha.toFixed(2)}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.beta.toFixed(2)}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.totalTrials}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.avgReward==null?`—`:e.avgReward.toFixed(3)}),(0,y.jsx)(g,{className:`text-xs text-[var(--app-text-subtle)]`,children:u(e.createdAt)})]},e.id))})]})})]},e))]})}export{x as Strategies};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{ct as t}from"./vendor-icons-Dk0hMuJz.js";import{t as n}from"./vendor-react-C6faO6LO.js";import{i as r}from"./dist-Bdqp1ixJ.js";import{_ as i,b as a,u as o,x as s}from"./AlertDialog-CfeiyMrc.js";import{i as c}from"./Button-DuQctNms.js";import{a as l}from"./index-qYKJGoIB.js";var u=e(t(),1);function d(e){let t=u.useRef({value:e,previous:e});return u.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var f=n(),p=`Switch`,[m,h]=a(p),[g,_]=m(p),v=u.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:a,defaultChecked:l,required:d,disabled:m,value:h=`on`,onCheckedChange:_,form:v,...y}=e,[b,x]=u.useState(null),w=c(t,e=>x(e)),T=u.useRef(!1),E=b?v||!!b.closest(`form`):!0,[D,O]=o({prop:a,defaultProp:l??!1,onChange:_,caller:p});return(0,f.jsxs)(g,{scope:n,checked:D,disabled:m,children:[(0,f.jsx)(i.button,{type:`button`,role:`switch`,"aria-checked":D,"aria-required":d,"data-state":C(D),"data-disabled":m?``:void 0,disabled:m,value:h,...y,ref:w,onClick:s(e.onClick,e=>{O(e=>!e),E&&(T.current=e.isPropagationStopped(),T.current||e.stopPropagation())})}),E&&(0,f.jsx)(S,{control:b,bubbles:!T.current,name:r,value:h,checked:D,required:d,disabled:m,form:v,style:{transform:`translateX(-100%)`}})]})});v.displayName=p;var y=`SwitchThumb`,b=u.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,a=_(y,n);return(0,f.jsx)(i.span,{"data-state":C(a.checked),"data-disabled":a.disabled?``:void 0,...r,ref:t})});b.displayName=y;var x=`SwitchBubbleInput`,S=u.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=u.useRef(null),s=c(o,a),p=d(n),m=l(t);return u.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(p!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[p,n,r]),(0,f.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...m,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});S.displayName=x;function C(e){return e?`checked`:`unchecked`}var w=v,T=b,E=u.forwardRef(({className:e,...t},n)=>(0,f.jsx)(w,{className:r(`peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--app-canvas)] disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-[var(--app-accent)] data-[state=unchecked]:bg-[var(--app-panel-muted)]`,e),...t,ref:n,children:(0,f.jsx)(T,{className:r(`pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`)})}));E.displayName=w.displayName;export{E as t};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{ct as t}from"./vendor-icons-Dk0hMuJz.js";import{t as n}from"./vendor-react-C6faO6LO.js";import{i as r}from"./dist-Bdqp1ixJ.js";import{_ as i,b as a,u as o,x as s}from"./AlertDialog-CfeiyMrc.js";import{i as c}from"./Button-DuQctNms.js";import{a as l}from"./index-DYsO5Awn.js";var u=e(t(),1);function d(e){let t=u.useRef({value:e,previous:e});return u.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var f=n(),p=`Switch`,[m,h]=a(p),[g,_]=m(p),v=u.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:a,defaultChecked:l,required:d,disabled:m,value:h=`on`,onCheckedChange:_,form:v,...y}=e,[b,x]=u.useState(null),w=c(t,e=>x(e)),T=u.useRef(!1),E=b?v||!!b.closest(`form`):!0,[D,O]=o({prop:a,defaultProp:l??!1,onChange:_,caller:p});return(0,f.jsxs)(g,{scope:n,checked:D,disabled:m,children:[(0,f.jsx)(i.button,{type:`button`,role:`switch`,"aria-checked":D,"aria-required":d,"data-state":C(D),"data-disabled":m?``:void 0,disabled:m,value:h,...y,ref:w,onClick:s(e.onClick,e=>{O(e=>!e),E&&(T.current=e.isPropagationStopped(),T.current||e.stopPropagation())})}),E&&(0,f.jsx)(S,{control:b,bubbles:!T.current,name:r,value:h,checked:D,required:d,disabled:m,form:v,style:{transform:`translateX(-100%)`}})]})});v.displayName=p;var y=`SwitchThumb`,b=u.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,a=_(y,n);return(0,f.jsx)(i.span,{"data-state":C(a.checked),"data-disabled":a.disabled?``:void 0,...r,ref:t})});b.displayName=y;var x=`SwitchBubbleInput`,S=u.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=u.useRef(null),s=c(o,a),p=d(n),m=l(t);return u.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(p!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[p,n,r]),(0,f.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...m,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});S.displayName=x;function C(e){return e?`checked`:`unchecked`}var w=v,T=b,E=u.forwardRef(({className:e,...t},n)=>(0,f.jsx)(w,{className:r(`peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--app-canvas)] disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-[var(--app-accent)] data-[state=unchecked]:bg-[var(--app-panel-muted)]`,e),...t,ref:n,children:(0,f.jsx)(T,{className:r(`pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`)})}));E.displayName=w.displayName;export{E as t};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{B as t,I as n,K as r,L as i,Y as a,a as o,at as s,ct as c,it as l,p as u,q as d}from"./vendor-icons-Dk0hMuJz.js";import{f,r as p,t as m}from"./vendor-react-C6faO6LO.js";import{n as h,r as g}from"./dist-Bdqp1ixJ.js";import{t as _}from"./Button-DuQctNms.js";import{n as v,t as y}from"./index-qYKJGoIB.js";import{i as b,n as x,r as S,t as C}from"./Card-rKfViPS2.js";import{t as w}from"./PageHeader-CHSgtxPw.js";import{t as T}from"./SectionHeader-C2WpiwJ5.js";import{a as E,n as D,r as O,t as k}from"./format-CHfBBLog.js";import{t as A}from"./ui-B_uMx2Fy.js";var j=e(c(),1),M=m(),N={reasoning:`text-[var(--app-accent)]`,tool_call:`text-[var(--app-accent-strong)]`,tool_result:`text-[var(--app-success)]`,approval_request:`text-[var(--app-warning)]`,approval_response:`text-[var(--app-warning-strong)]`,permission_denied:`text-[var(--app-indicator-alert)]`,error:`text-[var(--app-danger)]`,plugin_error:`text-[var(--app-danger)]`};function P({logs:e}){let[t,n]=(0,j.useState)(new Set);return e.length===0?(0,M.jsx)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:`No execution steps yet.`}):(0,M.jsx)(`div`,{className:`space-y-0`,children:e.map((r,i)=>{let o=i>0?e[i-1].timestamp:null,s=o?r.timestamp-o:null,c=r.type===`plugin_error`,l=t.has(i)?r.content:r.content.length>200?r.content.slice(0,200)+`...`:r.content;return(0,M.jsxs)(`div`,{className:`flex gap-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,M.jsx)(a,{size:10,className:`mt-1.5 flex-shrink-0 fill-current ${N[r.type]??`text-[var(--app-text-subtle)]`} ${c?`rounded-full ring-2 ring-[var(--app-danger)]`:``}`}),i<e.length-1&&(0,M.jsx)(`div`,{className:`mt-0.5 w-0.5 flex-1 bg-[var(--app-border)]`})]}),(0,M.jsxs)(`div`,{className:`flex-1 pb-4 ${c?`rounded-lg border border-[var(--app-danger)]/40 bg-[var(--app-danger-soft-bg-subtle)] p-3`:``}`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,M.jsxs)(`span`,{className:`text-xs font-mono text-[var(--app-text-subtle)]`,children:[`#`,r.index]}),(0,M.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:r.toolName??r.type}),c&&(0,M.jsx)(y,{variant:`destructive`,children:`Plugin Error`}),(0,M.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:E(r.timestamp)}),s!=null&&s>0&&(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`+`,s,`ms`]}),r.truncated&&(0,M.jsx)(y,{variant:`outline`,children:`truncated`})]}),l&&(0,M.jsx)(`button`,{className:`mt-2 w-full rounded-lg border border-[var(--app-border)] bg-white/[0.03] px-3 py-3 text-left font-mono text-xs text-[var(--app-text-muted)] transition-colors hover:border-[var(--app-border-strong)] hover:text-[var(--app-text)]`,onClick:()=>{n(e=>{let t=new Set(e);return t.has(i)?t.delete(i):t.add(i),t})},children:l})]})]},r.id)})})}function F(){let{id:e}=f(),[a,c]=(0,j.useState)(null),[m,E]=(0,j.useState)([]),[N,F]=(0,j.useState)([]),[R,z]=(0,j.useState)([]),[B,V]=(0,j.useState)(null),[H,U]=(0,j.useState)(null),[W,G]=(0,j.useState)(!1),[K,q]=(0,j.useState)(!1),[J,Y]=(0,j.useState)(!1),[X,Z]=(0,j.useState)(!1),Q=(0,j.useMemo)(()=>{if(!a)return`No diagnostics yet`;let e=[];return a.error&&e.push(`error`),N.length>0&&e.push(`${N.length} steps`),R.length>0&&e.push(`${R.length} delivery events`),e.length>0?e.join(` · `):`No diagnostics yet`},[R.length,N.length,a]);(0,j.useEffect)(()=>{if(!e)return;let t=!1,n=async()=>{if(!t)try{let n=await h(`/tasks/${e}`);if(t)return;c(n.task),U(null)}catch(e){if(t)return;U(e instanceof Error?e.message:`Failed to load task`)}};n(),h(`/tasks/${e}/plan`).then(e=>{t||E(e.plans)}).catch(()=>{t||E([])}),h(`/tasks/${e}/logs?limit=200`).then(e=>{t||F(e.logs)}).catch(()=>{t||F([])}),g(e).then(e=>{t||z(e)}).catch(()=>{t||z([])});let r=setInterval(n,3e3);return()=>{t=!0,clearInterval(r)}},[e]),(0,j.useEffect)(()=>{if(!a?.roleId||!e)return;let t=!1;return h(`/roles/${a.roleId}/scores?limit=100`).then(n=>{t||V(n.scores.find(t=>t.taskId===e)??null)}).catch(()=>{t||V(null)}),()=>{t=!0}},[a?.roleId,e]);let $=async()=>{if(e){G(!0);try{await h(`/tasks/${e}/cancel`,{method:`POST`}),c(e=>e&&{...e,status:`cancelled`})}finally{G(!1)}}};if(H)return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(p,{to:`/work`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,M.jsx)(s,{size:A.sm}),` Back to Tasks`]}),(0,M.jsx)(C,{className:`text-center text-[var(--app-danger)]`,children:H})]});if(!a)return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(p,{to:`/work`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,M.jsx)(s,{size:A.sm}),` Back to Tasks`]}),(0,M.jsx)(C,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let ee=[`running`,`queued`,`pending`,`paused`].includes(a.status);return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsx)(w,{eyebrow:`Task`,title:`Task Detail`,compact:!0,description:`Summary, execution, result, and diagnostics.`,metrics:[{label:`Status`,value:(0,M.jsx)(y,{variant:v(a.status),children:a.status})},{label:`Task`,value:a.id.slice(0,8)},{label:`Elapsed`,value:a.totalDurationMs?O(a.totalDurationMs):a.startedAt?O(Date.now()-a.startedAt):`—`},{label:`Spend`,value:a.costUsd==null?`—`:k(a.costUsd)}],actions:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(p,{to:`/work`,className:`inline-flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,M.jsx)(s,{size:A.sm}),` Back to Tasks`]}),ee&&(0,M.jsxs)(_,{variant:`destructive`,size:`sm`,onClick:()=>void $(),disabled:W,children:[(0,M.jsx)(l,{size:A.sm}),W?`Cancelling...`:`Cancel Task`]})]})}),(0,M.jsx)(C,{className:`surface-accent text-white`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between`,children:[(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`p`,{className:`text-kicker text-white/70`,children:`Summary`}),(0,M.jsx)(`p`,{className:`mt-2 text-base leading-7 text-white`,children:a.prompt.length>220&&!K?`${a.prompt.slice(0,220)}…`:a.prompt})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a.prompt.length>220?(0,M.jsxs)(_,{variant:`secondary`,size:`sm`,onClick:()=>q(e=>!e),children:[(0,M.jsx)(t,{size:A.sm}),K?`Collapse prompt`:`Show full prompt`]}):null,(0,M.jsxs)(_,{variant:`secondary`,size:`sm`,onClick:()=>Z(e=>!e),children:[(0,M.jsx)(u,{size:A.sm}),X?`Hide diagnostics`:`Show diagnostics`]})]})]})}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,M.jsx)(L,{icon:d,label:`Created`,value:D(a.createdAt)}),(0,M.jsx)(L,{icon:d,label:`Duration`,value:a.totalDurationMs?O(a.totalDurationMs):a.startedAt?O(Date.now()-a.startedAt):`—`}),(0,M.jsx)(L,{icon:r,label:`Cost`,value:a.costUsd==null?`—`:k(a.costUsd)}),(0,M.jsx)(L,{icon:i,label:`Turns`,value:String(a.numTurns??`—`)})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,M.jsx)(L,{icon:o,label:`Role`,value:a.roleId??`—`,mono:!0}),(0,M.jsx)(L,{icon:n,label:`Parent`,value:a.parentId??`—`,mono:!0}),a.templateId?(0,M.jsxs)(p,{to:`/work`,className:`block`,children:[(0,M.jsx)(L,{icon:n,label:`Template`,value:a.templateId,mono:!0}),(0,M.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:`View in Automations →`})]}):(0,M.jsx)(L,{icon:n,label:`Template`,value:`—`,mono:!0}),a.sourceSessionId&&(0,M.jsx)(L,{icon:i,label:`Source Session`,value:a.sourceSessionId.slice(0,8),mono:!0})]}),(a.deliverTo||a.reportTo)&&(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Delivery Targets`}),(0,M.jsx)(x,{children:`Where results and status updates are sent after execution.`})]})}),(0,M.jsxs)(`div`,{className:`space-y-3`,children:[a.deliverTo&&a.deliverTo.length>0&&(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] mb-1`,children:`Output`}),(0,M.jsx)(`div`,{className:`space-y-1`,children:a.deliverTo.map((e,t)=>(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:[(0,M.jsx)(y,{variant:`outline`,children:e.type===`channel`?`Channel`:`Session`}),e.type===`channel`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`session `,e.sessionId?.slice(0,8)]})]},`d-${t}`))})]}),a.reportTo&&a.reportTo.length>0&&(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] mb-1`,children:`Status Reports`}),(0,M.jsx)(`div`,{className:`space-y-1`,children:a.reportTo.map((e,t)=>(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:[(0,M.jsx)(y,{variant:`outline`,children:e.type===`channel`?`Channel`:`Session`}),e.type===`channel`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`session `,e.sessionId?.slice(0,8)]})]},`r-${t}`))})]})]})]}),B&&(a.status===`completed`||a.status===`failed`)&&(0,M.jsx)(I,{score:B}),a.tokenUsage&&(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Token Usage`}),(0,M.jsx)(x,{children:`Input and output token totals for this execution.`})]})}),(0,M.jsxs)(`div`,{className:`flex gap-6 text-sm`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Input:`}),` `,(0,M.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:a.tokenUsage.input.toLocaleString()})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Output:`}),` `,(0,M.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:a.tokenUsage.output.toLocaleString()})]})]})]}),m.length>0&&(()=>{let e=m[0],t=e.plan.overallRisk===`high`?`destructive`:e.plan.overallRisk===`medium`?`warning`:`secondary`;return(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Execution Plan`}),(0,M.jsx)(x,{children:`Expected steps, risk, and permissions before execution.`})]}),(0,M.jsxs)(y,{variant:t,children:[e.plan.overallRisk.toUpperCase(),` RISK`]}),(0,M.jsx)(y,{variant:`outline`,children:e.status})]})}),(0,M.jsxs)(`h4`,{className:`text-sm font-medium text-[var(--app-text)] mb-2`,children:[`Plan Steps (`,e.plan.steps.length,`)`]}),(0,M.jsx)(`div`,{className:`space-y-2`,children:e.plan.steps.map(e=>(0,M.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)]/50 p-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsxs)(`span`,{className:`text-xs font-mono text-[var(--app-text-subtle)]`,children:[`#`,e.index]}),(0,M.jsx)(`span`,{className:`text-sm text-[var(--app-text)]`,children:e.description})]}),(0,M.jsx)(y,{variant:e.riskLevel===`high`?`destructive`:e.riskLevel===`medium`?`warning`:`secondary`,children:e.riskLevel})]}),(0,M.jsxs)(`div`,{className:`mt-1 text-xs text-[var(--app-text-muted)]`,children:[`Tools: `,e.toolsNeeded.join(`, `)||`none`]}),e.expectedOutput&&(0,M.jsxs)(`div`,{className:`mt-0.5 text-xs text-[var(--app-text-subtle)]`,children:[`Expected: `,e.expectedOutput]})]},e.index))}),Object.keys(e.plan.requiredPermissions).length>0&&(0,M.jsxs)(`div`,{className:`mt-2`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)] mb-1`,children:`Required Permissions`}),(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.keys(e.plan.requiredPermissions).map(e=>(0,M.jsx)(y,{variant:`secondary`,children:e},e))})]}),e.deviationReport&&(0,M.jsxs)(`div`,{className:`mt-3 rounded-md border border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg-subtle)] p-3`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-warning)] mb-2`,children:`Deviation Report`}),(0,M.jsxs)(`div`,{className:`text-xs text-[var(--app-text-muted)] mb-2`,children:[`Planned: `,e.deviationReport.stepsPlanned,` | Executed: `,e.deviationReport.stepsExecuted,` | Accuracy: `,(e.deviationReport.overallAccuracy*100).toFixed(0),`%`]}),e.deviationReport.deviations.length>0&&(0,M.jsx)(`div`,{className:`space-y-1`,children:e.deviationReport.deviations.map((e,t)=>(0,M.jsxs)(`div`,{className:`text-xs`,children:[(0,M.jsxs)(`span`,{className:`text-[var(--app-warning)] font-mono`,children:[`[`,e.deviationType,`]`]}),(0,M.jsxs)(`span`,{className:`text-[var(--app-text-muted)]`,children:[` Step `,e.stepIndex,`: `]}),(0,M.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.actual})]},t))})]}),e.learnedRules&&e.learnedRules.length>0&&(0,M.jsxs)(`div`,{className:`mt-3`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)] mb-2`,children:`Learned Rules`}),(0,M.jsx)(`ul`,{className:`space-y-1`,children:e.learnedRules.map((e,t)=>(0,M.jsxs)(`li`,{className:`text-xs text-[var(--app-text-muted)] flex items-start gap-1.5`,children:[(0,M.jsx)(`span`,{className:`text-[var(--app-accent)] mt-0.5`,children:`*`}),e]},t))})]})]})})(),N.length>0&&(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(b,{children:[`Execution Timeline (`,N.length,` steps)`]}),(0,M.jsx)(x,{children:`Ordered execution events, tool calls, and error markers.`})]})}),(0,M.jsx)(P,{logs:N})]}),a.result&&(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Result`}),(0,M.jsx)(x,{children:`The final task output. Raw text stays collapsed until needed.`})]}),a.result.length>360?(0,M.jsx)(_,{variant:`ghost`,size:`sm`,onClick:()=>Y(e=>!e),children:J?`Collapse`:`Expand`}):null]})}),(0,M.jsx)(`pre`,{className:`max-h-96 overflow-auto whitespace-pre-wrap rounded-md bg-[var(--app-panel-elevated)] p-3 font-mono text-xs text-[var(--app-text)]`,children:a.result.length>360&&!J?`${a.result.slice(0,360)}…`:a.result})]}),a.error&&(()=>{let e=[`plugin`,`--plugin-dir`,`failed to load plugin`],t=a.error.toLowerCase(),n=e.some(e=>t.includes(e)),r=n?a.error.split(`
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{B as t,I as n,K as r,L as i,Y as a,a as o,at as s,ct as c,it as l,p as u,q as d}from"./vendor-icons-Dk0hMuJz.js";import{f,r as p,t as m}from"./vendor-react-C6faO6LO.js";import{n as h,r as g}from"./dist-Bdqp1ixJ.js";import{t as _}from"./Button-DuQctNms.js";import{n as v,t as y}from"./index-DYsO5Awn.js";import{i as b,n as x,r as S,t as C}from"./Card-rKfViPS2.js";import{t as w}from"./PageHeader-CHSgtxPw.js";import{t as T}from"./SectionHeader-C2WpiwJ5.js";import{a as E,n as D,r as O,t as k}from"./format-CHfBBLog.js";import{t as A}from"./ui-B_uMx2Fy.js";var j=e(c(),1),M=m(),N={reasoning:`text-[var(--app-accent)]`,tool_call:`text-[var(--app-accent-strong)]`,tool_result:`text-[var(--app-success)]`,approval_request:`text-[var(--app-warning)]`,approval_response:`text-[var(--app-warning-strong)]`,permission_denied:`text-[var(--app-indicator-alert)]`,error:`text-[var(--app-danger)]`,plugin_error:`text-[var(--app-danger)]`};function P({logs:e}){let[t,n]=(0,j.useState)(new Set);return e.length===0?(0,M.jsx)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:`No execution steps yet.`}):(0,M.jsx)(`div`,{className:`space-y-0`,children:e.map((r,i)=>{let o=i>0?e[i-1].timestamp:null,s=o?r.timestamp-o:null,c=r.type===`plugin_error`,l=t.has(i)?r.content:r.content.length>200?r.content.slice(0,200)+`...`:r.content;return(0,M.jsxs)(`div`,{className:`flex gap-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,M.jsx)(a,{size:10,className:`mt-1.5 flex-shrink-0 fill-current ${N[r.type]??`text-[var(--app-text-subtle)]`} ${c?`rounded-full ring-2 ring-[var(--app-danger)]`:``}`}),i<e.length-1&&(0,M.jsx)(`div`,{className:`mt-0.5 w-0.5 flex-1 bg-[var(--app-border)]`})]}),(0,M.jsxs)(`div`,{className:`flex-1 pb-4 ${c?`rounded-lg border border-[var(--app-danger)]/40 bg-[var(--app-danger-soft-bg-subtle)] p-3`:``}`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,M.jsxs)(`span`,{className:`text-xs font-mono text-[var(--app-text-subtle)]`,children:[`#`,r.index]}),(0,M.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:r.toolName??r.type}),c&&(0,M.jsx)(y,{variant:`destructive`,children:`Plugin Error`}),(0,M.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:E(r.timestamp)}),s!=null&&s>0&&(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`+`,s,`ms`]}),r.truncated&&(0,M.jsx)(y,{variant:`outline`,children:`truncated`})]}),l&&(0,M.jsx)(`button`,{className:`mt-2 w-full rounded-lg border border-[var(--app-border)] bg-white/[0.03] px-3 py-3 text-left font-mono text-xs text-[var(--app-text-muted)] transition-colors hover:border-[var(--app-border-strong)] hover:text-[var(--app-text)]`,onClick:()=>{n(e=>{let t=new Set(e);return t.has(i)?t.delete(i):t.add(i),t})},children:l})]})]},r.id)})})}function F(){let{id:e}=f(),[a,c]=(0,j.useState)(null),[m,E]=(0,j.useState)([]),[N,F]=(0,j.useState)([]),[R,z]=(0,j.useState)([]),[B,V]=(0,j.useState)(null),[H,U]=(0,j.useState)(null),[W,G]=(0,j.useState)(!1),[K,q]=(0,j.useState)(!1),[J,Y]=(0,j.useState)(!1),[X,Z]=(0,j.useState)(!1),Q=(0,j.useMemo)(()=>{if(!a)return`No diagnostics yet`;let e=[];return a.error&&e.push(`error`),N.length>0&&e.push(`${N.length} steps`),R.length>0&&e.push(`${R.length} delivery events`),e.length>0?e.join(` · `):`No diagnostics yet`},[R.length,N.length,a]);(0,j.useEffect)(()=>{if(!e)return;let t=!1,n=async()=>{if(!t)try{let n=await h(`/tasks/${e}`);if(t)return;c(n.task),U(null)}catch(e){if(t)return;U(e instanceof Error?e.message:`Failed to load task`)}};n(),h(`/tasks/${e}/plan`).then(e=>{t||E(e.plans)}).catch(()=>{t||E([])}),h(`/tasks/${e}/logs?limit=200`).then(e=>{t||F(e.logs)}).catch(()=>{t||F([])}),g(e).then(e=>{t||z(e)}).catch(()=>{t||z([])});let r=setInterval(n,3e3);return()=>{t=!0,clearInterval(r)}},[e]),(0,j.useEffect)(()=>{if(!a?.roleId||!e)return;let t=!1;return h(`/roles/${a.roleId}/scores?limit=100`).then(n=>{t||V(n.scores.find(t=>t.taskId===e)??null)}).catch(()=>{t||V(null)}),()=>{t=!0}},[a?.roleId,e]);let $=async()=>{if(e){G(!0);try{await h(`/tasks/${e}/cancel`,{method:`POST`}),c(e=>e&&{...e,status:`cancelled`})}finally{G(!1)}}};if(H)return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(p,{to:`/work`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,M.jsx)(s,{size:A.sm}),` Back to Tasks`]}),(0,M.jsx)(C,{className:`text-center text-[var(--app-danger)]`,children:H})]});if(!a)return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(p,{to:`/work`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,M.jsx)(s,{size:A.sm}),` Back to Tasks`]}),(0,M.jsx)(C,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let ee=[`running`,`queued`,`pending`,`paused`].includes(a.status);return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsx)(w,{eyebrow:`Task`,title:`Task Detail`,compact:!0,description:`Summary, execution, result, and diagnostics.`,metrics:[{label:`Status`,value:(0,M.jsx)(y,{variant:v(a.status),children:a.status})},{label:`Task`,value:a.id.slice(0,8)},{label:`Elapsed`,value:a.totalDurationMs?O(a.totalDurationMs):a.startedAt?O(Date.now()-a.startedAt):`—`},{label:`Spend`,value:a.costUsd==null?`—`:k(a.costUsd)}],actions:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(p,{to:`/work`,className:`inline-flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,M.jsx)(s,{size:A.sm}),` Back to Tasks`]}),ee&&(0,M.jsxs)(_,{variant:`destructive`,size:`sm`,onClick:()=>void $(),disabled:W,children:[(0,M.jsx)(l,{size:A.sm}),W?`Cancelling...`:`Cancel Task`]})]})}),(0,M.jsx)(C,{className:`surface-accent text-white`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between`,children:[(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`p`,{className:`text-kicker text-white/70`,children:`Summary`}),(0,M.jsx)(`p`,{className:`mt-2 text-base leading-7 text-white`,children:a.prompt.length>220&&!K?`${a.prompt.slice(0,220)}…`:a.prompt})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a.prompt.length>220?(0,M.jsxs)(_,{variant:`secondary`,size:`sm`,onClick:()=>q(e=>!e),children:[(0,M.jsx)(t,{size:A.sm}),K?`Collapse prompt`:`Show full prompt`]}):null,(0,M.jsxs)(_,{variant:`secondary`,size:`sm`,onClick:()=>Z(e=>!e),children:[(0,M.jsx)(u,{size:A.sm}),X?`Hide diagnostics`:`Show diagnostics`]})]})]})}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,M.jsx)(L,{icon:d,label:`Created`,value:D(a.createdAt)}),(0,M.jsx)(L,{icon:d,label:`Duration`,value:a.totalDurationMs?O(a.totalDurationMs):a.startedAt?O(Date.now()-a.startedAt):`—`}),(0,M.jsx)(L,{icon:r,label:`Cost`,value:a.costUsd==null?`—`:k(a.costUsd)}),(0,M.jsx)(L,{icon:i,label:`Turns`,value:String(a.numTurns??`—`)})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,M.jsx)(L,{icon:o,label:`Role`,value:a.roleId??`—`,mono:!0}),(0,M.jsx)(L,{icon:n,label:`Parent`,value:a.parentId??`—`,mono:!0}),a.templateId?(0,M.jsxs)(p,{to:`/work`,className:`block`,children:[(0,M.jsx)(L,{icon:n,label:`Template`,value:a.templateId,mono:!0}),(0,M.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:`View in Automations →`})]}):(0,M.jsx)(L,{icon:n,label:`Template`,value:`—`,mono:!0}),a.sourceSessionId&&(0,M.jsx)(L,{icon:i,label:`Source Session`,value:a.sourceSessionId.slice(0,8),mono:!0})]}),(a.deliverTo||a.reportTo)&&(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Delivery Targets`}),(0,M.jsx)(x,{children:`Where results and status updates are sent after execution.`})]})}),(0,M.jsxs)(`div`,{className:`space-y-3`,children:[a.deliverTo&&a.deliverTo.length>0&&(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] mb-1`,children:`Output`}),(0,M.jsx)(`div`,{className:`space-y-1`,children:a.deliverTo.map((e,t)=>(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:[(0,M.jsx)(y,{variant:`outline`,children:e.type===`channel`?`Channel`:`Session`}),e.type===`channel`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`session `,e.sessionId?.slice(0,8)]})]},`d-${t}`))})]}),a.reportTo&&a.reportTo.length>0&&(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] mb-1`,children:`Status Reports`}),(0,M.jsx)(`div`,{className:`space-y-1`,children:a.reportTo.map((e,t)=>(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:[(0,M.jsx)(y,{variant:`outline`,children:e.type===`channel`?`Channel`:`Session`}),e.type===`channel`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`session `,e.sessionId?.slice(0,8)]})]},`r-${t}`))})]})]})]}),B&&(a.status===`completed`||a.status===`failed`)&&(0,M.jsx)(I,{score:B}),a.tokenUsage&&(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Token Usage`}),(0,M.jsx)(x,{children:`Input and output token totals for this execution.`})]})}),(0,M.jsxs)(`div`,{className:`flex gap-6 text-sm`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Input:`}),` `,(0,M.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:a.tokenUsage.input.toLocaleString()})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Output:`}),` `,(0,M.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:a.tokenUsage.output.toLocaleString()})]})]})]}),m.length>0&&(()=>{let e=m[0],t=e.plan.overallRisk===`high`?`destructive`:e.plan.overallRisk===`medium`?`warning`:`secondary`;return(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Execution Plan`}),(0,M.jsx)(x,{children:`Expected steps, risk, and permissions before execution.`})]}),(0,M.jsxs)(y,{variant:t,children:[e.plan.overallRisk.toUpperCase(),` RISK`]}),(0,M.jsx)(y,{variant:`outline`,children:e.status})]})}),(0,M.jsxs)(`h4`,{className:`text-sm font-medium text-[var(--app-text)] mb-2`,children:[`Plan Steps (`,e.plan.steps.length,`)`]}),(0,M.jsx)(`div`,{className:`space-y-2`,children:e.plan.steps.map(e=>(0,M.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)]/50 p-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsxs)(`span`,{className:`text-xs font-mono text-[var(--app-text-subtle)]`,children:[`#`,e.index]}),(0,M.jsx)(`span`,{className:`text-sm text-[var(--app-text)]`,children:e.description})]}),(0,M.jsx)(y,{variant:e.riskLevel===`high`?`destructive`:e.riskLevel===`medium`?`warning`:`secondary`,children:e.riskLevel})]}),(0,M.jsxs)(`div`,{className:`mt-1 text-xs text-[var(--app-text-muted)]`,children:[`Tools: `,e.toolsNeeded.join(`, `)||`none`]}),e.expectedOutput&&(0,M.jsxs)(`div`,{className:`mt-0.5 text-xs text-[var(--app-text-subtle)]`,children:[`Expected: `,e.expectedOutput]})]},e.index))}),Object.keys(e.plan.requiredPermissions).length>0&&(0,M.jsxs)(`div`,{className:`mt-2`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)] mb-1`,children:`Required Permissions`}),(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.keys(e.plan.requiredPermissions).map(e=>(0,M.jsx)(y,{variant:`secondary`,children:e},e))})]}),e.deviationReport&&(0,M.jsxs)(`div`,{className:`mt-3 rounded-md border border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg-subtle)] p-3`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-warning)] mb-2`,children:`Deviation Report`}),(0,M.jsxs)(`div`,{className:`text-xs text-[var(--app-text-muted)] mb-2`,children:[`Planned: `,e.deviationReport.stepsPlanned,` | Executed: `,e.deviationReport.stepsExecuted,` | Accuracy: `,(e.deviationReport.overallAccuracy*100).toFixed(0),`%`]}),e.deviationReport.deviations.length>0&&(0,M.jsx)(`div`,{className:`space-y-1`,children:e.deviationReport.deviations.map((e,t)=>(0,M.jsxs)(`div`,{className:`text-xs`,children:[(0,M.jsxs)(`span`,{className:`text-[var(--app-warning)] font-mono`,children:[`[`,e.deviationType,`]`]}),(0,M.jsxs)(`span`,{className:`text-[var(--app-text-muted)]`,children:[` Step `,e.stepIndex,`: `]}),(0,M.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.actual})]},t))})]}),e.learnedRules&&e.learnedRules.length>0&&(0,M.jsxs)(`div`,{className:`mt-3`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)] mb-2`,children:`Learned Rules`}),(0,M.jsx)(`ul`,{className:`space-y-1`,children:e.learnedRules.map((e,t)=>(0,M.jsxs)(`li`,{className:`text-xs text-[var(--app-text-muted)] flex items-start gap-1.5`,children:[(0,M.jsx)(`span`,{className:`text-[var(--app-accent)] mt-0.5`,children:`*`}),e]},t))})]})]})})(),N.length>0&&(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(b,{children:[`Execution Timeline (`,N.length,` steps)`]}),(0,M.jsx)(x,{children:`Ordered execution events, tool calls, and error markers.`})]})}),(0,M.jsx)(P,{logs:N})]}),a.result&&(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Result`}),(0,M.jsx)(x,{children:`The final task output. Raw text stays collapsed until needed.`})]}),a.result.length>360?(0,M.jsx)(_,{variant:`ghost`,size:`sm`,onClick:()=>Y(e=>!e),children:J?`Collapse`:`Expand`}):null]})}),(0,M.jsx)(`pre`,{className:`max-h-96 overflow-auto whitespace-pre-wrap rounded-md bg-[var(--app-panel-elevated)] p-3 font-mono text-xs text-[var(--app-text)]`,children:a.result.length>360&&!J?`${a.result.slice(0,360)}…`:a.result})]}),a.error&&(()=>{let e=[`plugin`,`--plugin-dir`,`failed to load plugin`],t=a.error.toLowerCase(),n=e.some(e=>t.includes(e)),r=n?a.error.split(`
2
2
  `).find(t=>e.some(e=>t.toLowerCase().includes(e))):null;return(0,M.jsxs)(C,{className:n?`border-[var(--app-danger)]`:``,children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Error`}),(0,M.jsx)(x,{children:`Execution failed or returned an error condition.`})]}),n&&(0,M.jsx)(y,{variant:`warning`,children:`Plugin Issue`})]})}),n&&r&&(0,M.jsx)(`div`,{className:`mb-2 rounded bg-[var(--app-warning-soft-bg-subtle)] px-2 py-1 text-xs text-[var(--app-warning)]`,children:r}),(0,M.jsx)(`pre`,{className:`max-h-96 overflow-auto whitespace-pre-wrap rounded-md bg-[var(--app-danger-soft-bg-subtle)] p-3 font-mono text-xs text-[var(--app-danger)]`,children:a.error})]})})(),(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Diagnostics`}),(0,M.jsx)(x,{children:Q})]})}),X?R.length>0?(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsx)(T,{title:`Delivery Log`,description:`Recent delivery attempts and outcomes.`}),(0,M.jsx)(`div`,{className:`space-y-2`,children:R.map(e=>{let t=e.status===`delivered`?`success`:e.status===`pending`?`secondary`:`destructive`,n=e.target.type===`webhook`?e.target.webhookUrl:e.target.type===`channel`?`channel ${e.target.channelId.slice(0,8)}`:`session ${e.target.sessionId?.slice(0,8)}`;return(0,M.jsxs)(`div`,{className:`surface-panel-muted rounded-lg px-3 py-3 text-sm`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(y,{variant:t,children:e.status}),(0,M.jsx)(`span`,{className:`font-mono text-xs text-[var(--app-text-subtle)]`,children:n}),e.messageType?(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`(`,e.messageType,`)`]}):null]}),e.error?(0,M.jsx)(`p`,{className:`mt-2 text-xs text-[var(--app-danger-soft-text)]`,children:e.error}):null,(0,M.jsxs)(`p`,{className:`mt-2 text-xs text-[var(--app-text-subtle)]`,children:[D(e.createdAt),e.deliveredAt&&` \u2192 ${D(e.deliveredAt)}`]})]},e.id)})})]}):(0,M.jsx)(`div`,{className:`surface-panel-muted rounded-lg px-4 py-4 text-sm text-[var(--app-text-subtle)]`,children:`No delivery events recorded yet.`}):(0,M.jsx)(`div`,{className:`surface-panel-muted rounded-lg px-4 py-4 text-sm text-[var(--app-text-subtle)]`,children:`Diagnostics are hidden by default because this section can contain raw execution details and operational data.`})]})]})}function I({score:e}){let t=[{label:`Task Success`,value:e.scores.taskSuccess,weight:`30%`},{label:`Plan Accuracy`,value:e.scores.planAccuracy,weight:`25%`},{label:`Permission Compliance`,value:e.scores.permissionCompliance,weight:`25%`},{label:`Efficiency`,value:e.scores.efficiency,weight:`20%`}];return(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsx)(b,{children:`Quality Score`})}),(0,M.jsxs)(`div`,{className:`space-y-3`,children:[t.map(e=>(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`mb-1 flex items-center justify-between text-xs`,children:[(0,M.jsxs)(`span`,{className:`text-[var(--app-text-muted)]`,children:[e.label,` `,(0,M.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`(`,e.weight,`)`]})]}),(0,M.jsxs)(`span`,{className:`font-mono text-[var(--app-text)]`,children:[(e.value*100).toFixed(0),`%`]})]}),(0,M.jsx)(`div`,{className:`h-1.5 w-full rounded-full bg-[var(--app-panel-elevated)]`,children:(0,M.jsx)(`div`,{className:`h-full rounded-full ${e.value<.4?`bg-[var(--app-danger)]`:`bg-[var(--app-accent)]`}`,style:{width:`${e.value*100}%`}})})]},e.label)),(0,M.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-[var(--app-border)] pt-2`,children:[(0,M.jsx)(`span`,{className:`text-sm text-[var(--app-text)]`,children:`Weighted Score`}),(0,M.jsxs)(`span`,{className:`font-mono text-sm font-semibold text-[var(--app-text)]`,children:[(e.scores.weighted*100).toFixed(0),`%`]})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsx)(`span`,{className:`text-sm text-[var(--app-text)]`,children:`EMA (after this task)`}),(0,M.jsxs)(`span`,{className:`font-mono text-sm font-semibold ${e.emaScore<.4?`text-[var(--app-danger)]`:`text-[var(--app-success)]`}`,children:[(e.emaScore*100).toFixed(0),`%`]})]})]})]})}function L({icon:e,label:t,value:n,mono:r}){return(0,M.jsxs)(C,{className:`flex flex-col gap-1`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[var(--app-text-subtle)]`,children:[(0,M.jsx)(e,{size:12}),(0,M.jsx)(`span`,{className:`text-xs`,children:t})]}),(0,M.jsx)(`span`,{className:`text-sm text-[var(--app-text)] truncate ${r?`font-mono text-xs`:``}`,children:n})]})}export{F as TaskDetail};
@@ -0,0 +1 @@
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 C,o as te,p as w,r as ne,s as re,t as ie,u as ae,v as T,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-DYsO5Awn.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 ge,r as I,t as _e}from"./Table-DuOLbyJQ.js";import{t as ve}from"./Switch-CfTpXW9_.js";import{Goals as ye,t as be}from"./Goals-CylKmR9j.js";var L=e(s(),1),R=m();function xe(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=L.useRef(null),a=L.useRef(new Map).current;return(0,R.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=T(s),l=L.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,R.jsx)(c,{ref:D(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=T(u),p=L.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=L.useRef(null),s=D(t,o),c=a(u,n);return L.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,R.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return L.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 Se=L.createContext(void 0);function Ce(e){let t=L.useContext(Se);return e||t||`ltr`}var z=`rovingFocusGroup.onEntryFocus`,we={bubbles:!1,cancelable:!0},B=`RovingFocusGroup`,[V,Te,H]=xe(B),[Ee,De]=y(B,[H]),[U,Oe]=Ee(B),W=L.forwardRef((e,t)=>(0,R.jsx)(V.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(V.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(ke,{...e,ref:t})})}));W.displayName=B;var ke=L.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=L.useRef(null),p=D(t,f),m=Ce(a),[h,g]=ae({prop:o,defaultProp:s??null,onChange:c,caller:B}),[v,y]=L.useState(!1),b=ee(l),x=Te(n),S=L.useRef(!1),[C,te]=L.useState(0);return L.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(z,b),()=>e.removeEventListener(z,b)},[b]),(0,R.jsx)(U,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:L.useCallback(e=>g(e),[g]),onItemShiftTab:L.useCallback(()=>y(!0),[]),onFocusableItemAdd:L.useCallback(()=>te(e=>e+1),[]),onFocusableItemRemove:L.useCallback(()=>te(e=>e-1),[]),children:(0,R.jsx)(_.div,{tabIndex:v||C===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(z,we);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);Pe([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))})})}),G=`RovingFocusGroupItem`,Ae=L.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=w(),l=a||c,u=Oe(G,n),d=u.currentTabStopId===l,f=Te(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return L.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,R.jsx)(V.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,R.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=Ne(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?Fe(n,r+1):n.slice(r+1)}setTimeout(()=>Pe(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});Ae.displayName=G;var je={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Me(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function Ne(e,t,n){let r=Me(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return je[r]}function Pe(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Fe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ie=W,Le=Ae,K=`Tabs`,[Re,ze]=y(K,[De]),Be=De(),[Ve,q]=Re(K),J=L.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=Ce(s),[d,f]=ae({prop:r,onChange:i,defaultProp:a??``,caller:K});return(0,R.jsx)(Ve,{scope:n,baseId:w(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,R.jsx)(_.div,{dir:u,"data-orientation":o,...l,ref:t})})});J.displayName=K;var He=`TabsList`,Ue=L.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=q(He,n),o=Be(n);return(0,R.jsx)(Ie,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,R.jsx)(_.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Ue.displayName=He;var We=`TabsTrigger`,Ge=L.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=q(We,n),s=Be(n),c=X(o.baseId,r),l=qe(o.baseId,r),u=r===o.value;return(0,R.jsx)(Le,{asChild:!0,...s,focusable:!i,active:u,children:(0,R.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)})})})});Ge.displayName=We;var Y=`TabsContent`,Ke=L.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=q(Y,n),c=X(s.baseId,r),l=qe(s.baseId,r),u=r===s.value,d=L.useRef(u);return L.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,R.jsx)(x,{present:i||u,children:({present:n})=>(0,R.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})})});Ke.displayName=Y;function X(e,t){return`${e}-trigger-${t}`}function qe(e,t){return`${e}-content-${t}`}var Je=J,Ye=Ue,Xe=Ge,Ze=Ke,Qe=Je,$e=L.forwardRef(({className:e,...t},n)=>(0,R.jsx)(Ye,{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}));$e.displayName=Ye.displayName;var Z=L.forwardRef(({className:e,...t},n)=>(0,R.jsx)(Xe,{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}));Z.displayName=Xe.displayName;var Q=L.forwardRef(({className:e,...t},n)=>(0,R.jsx)(Ze,{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}));Q.displayName=Ze.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`},{label:`Blocked`,value:`blocked`}],$=new Set([`pending`,`queued`,`running`,`paused`]);function tt(){let e=j(e=>e.tasks),t=j(e=>e.fetchTasks),[n,a]=(0,L.useState)(`all`),[o,s]=(0,L.useState)(!1),[c,u]=(0,L.useState)(``),[m,h]=(0,L.useState)(!1),[_,v]=(0,L.useState)(new Set),[y,b]=(0,L.useState)(!1),x=pe();(0,L.useEffect)(()=>{let e=n===`all`?void 0:n;t(e);let r=setInterval(()=>void t(e),5e3);return()=>clearInterval(r)},[t,n]),(0,L.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})},C=()=>{let e=w.filter(e=>$.has(e.status)).map(e=>e.id);v(new Set(e))},te=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),ne=Array.from(_).filter(t=>{let n=e.find(e=>e.id===t);return n&&$.has(n.status)});return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsx)(se,{title:`Tasks`,description:`Review active execution, cancel work, or create the next task.`,compact:!0,action:(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[_.size>0&&(0,R.jsxs)(O,{variant:`destructive`,size:`sm`,onClick:()=>void te(),disabled:y||ne.length===0,children:[(0,R.jsx)(l,{size:fe.sm}),y?`Cancelling...`:`Cancel ${ne.length} task${ne.length===1?``:`s`}`]}),(0,R.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>void t(n===`all`?void 0:n),children:(0,R.jsx)(f,{size:fe.sm})}),(0,R.jsxs)(O,{size:`sm`,onClick:()=>s(!o),children:[(0,R.jsx)(i,{size:fe.sm}),`New Task`]})]})}),o&&(0,R.jsxs)(N,{className:`flex gap-2`,children:[(0,R.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,R.jsx)(O,{onClick:()=>void ee(),disabled:m||!c.trim(),children:m?`Creating...`:`Create`}),(0,R.jsx)(O,{variant:`ghost`,onClick:()=>s(!1),children:`Cancel`})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 md:flex-row md:items-center md:justify-between`,children:[(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:et.map(e=>(0,R.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,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[w.some(e=>$.has(e.status))&&(0,R.jsx)(`button`,{onClick:C,className:`text-xs text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,children:`Select all cancellable`}),_.size>0&&(0,R.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,R.jsx)(N,{padding:!1,children:(0,R.jsx)(de,{icon:(0,R.jsx)(r,{size:32}),title:`No tasks found`,description:n===`all`?`Create a task to get started`:`No tasks with status "${n}"`})}):x?(0,R.jsx)(`div`,{className:`space-y-3`,children:w.map(e=>(0,R.jsx)(N,{className:_.has(e.id)?`border-[var(--app-accent)]/40 bg-[var(--app-accent)]/8`:``,children:(0,R.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,R.jsx)(`div`,{className:`pt-1`,children:$.has(e.status)?(0,R.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,R.jsx)(d,{size:12})}):(0,R.jsx)(`span`,{className:`inline-block h-4 w-4`})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,R.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,R.jsx)(`p`,{className:`break-words text-sm font-medium leading-6 text-[var(--app-text)]`,children:le(e.prompt,140)})]}),(0,R.jsx)(M,{variant:A(e.status),children:e.status})]}),(0,R.jsxs)(`div`,{className:`grid gap-2 text-xs text-[var(--app-text-subtle)] sm:grid-cols-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Role`}),(0,R.jsx)(`div`,{className:`mt-1 font-mono text-[var(--app-text)]`,children:e.roleId?e.roleId.slice(0,12):`—`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Cost`}),(0,R.jsx)(`div`,{className:`mt-1 font-mono text-[var(--app-text)]`,children:e.costUsd==null?`—`:ue(e.costUsd)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Created`}),(0,R.jsx)(`div`,{className:`mt-1 text-[var(--app-text)]`,children:ce(e.createdAt)})]})]})]})]})},e.id))}):(0,R.jsx)(N,{padding:!1,children:(0,R.jsxs)(_e,{children:[(0,R.jsx)(me,{children:(0,R.jsxs)(ge,{children:[(0,R.jsx)(F,{className:`w-8`,children:(0,R.jsx)(`button`,{onClick:()=>{_.size>0&&_.size===w.filter(e=>$.has(e.status)).length?v(new Set):C()},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,R.jsx)(d,{size:12})})}),(0,R.jsx)(F,{children:`ID`}),(0,R.jsx)(F,{children:`Prompt`}),(0,R.jsx)(F,{children:`Status`}),(0,R.jsx)(F,{children:`Role`}),(0,R.jsx)(F,{children:`Cost`}),(0,R.jsx)(F,{children:`Created`})]})}),(0,R.jsx)(he,{children:w.map(e=>(0,R.jsxs)(ge,{className:_.has(e.id)?`bg-[var(--app-panel-elevated)]/50`:``,children:[(0,R.jsx)(I,{children:$.has(e.status)?(0,R.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,R.jsx)(d,{size:12})}):(0,R.jsx)(`span`,{className:`inline-block w-4`})}),(0,R.jsx)(I,{children:(0,R.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,R.jsx)(I,{children:(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`div`,{className:`break-words font-medium text-[var(--app-text)]`,children:le(e.prompt,120)}),(0,R.jsxs)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[e.totalDurationMs?ue(e.costUsd??0):`Awaiting completion`,` · `,ce(e.createdAt)]})]})}),(0,R.jsx)(I,{children:(0,R.jsx)(M,{variant:A(e.status),children:e.status})}),(0,R.jsx)(I,{children:(0,R.jsx)(`span`,{className:`font-mono text-xs text-[var(--app-text-subtle)]`,children:e.roleId?e.roleId.slice(0,12):`—`})}),(0,R.jsx)(I,{className:`font-mono text-xs`,children:e.costUsd==null?`—`:ue(e.costUsd)}),(0,R.jsx)(I,{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,L.useState)(!1),[_,y]=(0,L.useState)(``),[x,ee]=(0,L.useState)(`manual`),[w,ae]=(0,L.useState)(``),[T,E]=(0,L.useState)(``),[D,oe]=(0,L.useState)(``),[A,P]=(0,L.useState)([{id:`step-1`,prompt:``}]),[le,ue]=(0,L.useState)(!1),[fe,pe]=(0,L.useState)(!1),[ye,xe]=(0,L.useState)(null),[Se,Ce]=(0,L.useState)(null),[z,we]=(0,L.useState)(null),[B,V]=(0,L.useState)(null),[Te,H]=(0,L.useState)(`template_only`),[Ee,De]=(0,L.useState)(!1),[U,Oe]=(0,L.useState)(null),[W,ke]=(0,L.useState)(``),[G,Ae]=(0,L.useState)(`manual`),[je,Me]=(0,L.useState)(``),[Ne,Pe]=(0,L.useState)(``),[Fe,Ie]=(0,L.useState)(``),[Le,K]=(0,L.useState)(``),[Re,ze]=(0,L.useState)(``),[Be,Ve]=(0,L.useState)([]),[q,J]=(0,L.useState)([]),[He,Ue]=(0,L.useState)(!1),[We,Ge]=(0,L.useState)(!1),[Y,Ke]=(0,L.useState)(`prompt`),[X,qe]=(0,L.useState)([]),[Je,Ye]=(0,L.useState)([]),[Xe,Ze]=(0,L.useState)([]),[Qe,$e]=(0,L.useState)(null),[Z,Q]=(0,L.useState)([]),[et,$]=(0,L.useState)(!1),tt=(0,L.useCallback)(async e=>{$(!0);try{let t=await g(`/workflow-executions?templateId=${e}&limit=5`);Q(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{Q([])}finally{$(!1)}},[]),rt=(0,L.useCallback)(e=>{Qe===e?($e(null),Q([])):($e(e),tt(e))},[Qe,tt]),it=(0,L.useMemo)(()=>Object.fromEntries(e.map(e=>[e.id,e.name])),[e]),at=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 '${it[e.event?.split(`:`)[1]??``]??`[deleted template]`}' completes`:e.type===`event`?`On event '${Be.find(t=>t.id===e.eventDefId)?.name??`[deleted event]`}'`:e.type;(0,L.useEffect)(()=>{r(),l(),p(),(async()=>{try{Ve(await g(`/event-defs`))}catch{}})()},[r,l,p]);let ot=async()=>{if(_.trim()&&!(Y===`prompt`&&A.every(e=>!e.prompt.trim()))&&!(Y===`goal`&&X.length===0)){pe(!0);try{let e={name:_.trim(),trigger:{type:x,...x===`cron`&&T?{cron:T}:{},...x===`once`&&D?{runAt:new Date(D).toISOString()}:{},...x===`template_complete`&&w?{event:`template_complete:${w}`}:{},...x===`event`&&Le?{eventDefId:Le}:{}},enabled:!0,...Je.length>0?{deliverTo:Je}:{},...le?{config:{continueOnError:!0}}:{}};Y===`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=X,e.steps=[]),await g(`/task-templates`,{method:`POST`,body:JSON.stringify(e)}),y(``),P([{id:`step-1`,prompt:``}]),E(``),oe(``),ae(``),K(``),qe([]),Ye([]),h(!1),r()}finally{pe(!1)}}},st=async t=>{let n=e.find(e=>e.id===t);xe(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{xe(null)}},ct=async e=>{we(e),H(`template_only`),V(null);try{V((await g(`/task-templates/${e}/dependents`)).dependents)}catch{V({executionCount:0,taskCount:0})}},lt=async(t,n)=>{let i=e.find(e=>e.id===t);De(!0);try{let e=await g(`/task-templates/${t}?mode=${n}`,{method:`DELETE`}),a=[];e.deletedCounts.workflowExecutions>0&&a.push(`${e.deletedCounts.workflowExecutions} execution${e.deletedCounts.workflowExecutions===1?``:`s`}`),e.deletedCounts.tasks>0&&a.push(`${e.deletedCounts.tasks} task${e.deletedCounts.tasks===1?``:`s`}`);let o=a.length?` (+ ${a.join(`, `)})`:``;k.success(`Deleted: ${i?.name??t}${o}`),r()}catch(e){let t=e instanceof Error?e.message:`Failed to delete template`;k.error(`Delete failed: ${t}`)}finally{De(!1)}},ut=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}`)}},dt=e=>{Oe(e.id),ke(e.name),Ae(e.trigger.type===`workflow_complete`?`template_complete`:e.trigger.type),Me(e.trigger.cron??``),Pe(e.trigger.runAt?new Date(e.trigger.runAt).toISOString().slice(0,16):``),J(e.steps.map(e=>({id:e.id,prompt:e.prompt,roleId:e.roleId,dependsOn:e.dependsOn,config:e.config}))),Ue(e.config?.continueOnError??!1),Ze(e.deliverTo??[]),Ie(e.trigger.type===`template_complete`||e.trigger.type===`workflow_complete`?e.trigger.event?.split(`:`)[1]??``:``),ze(e.trigger.eventDefId??``)},ft=async()=>{if(!(!U||!W.trim()||q.every(e=>!e.prompt.trim()))){Ge(!0);try{await g(`/task-templates/${U}`,{method:`PATCH`,body:JSON.stringify({name:W.trim(),trigger:{type:G,...G===`cron`&&je?{cron:je}:{},...G===`once`&&Ne?{runAt:new Date(Ne).toISOString()}:{},...G===`template_complete`&&Fe?{event:`template_complete:${Fe}`}:{},...G===`event`&&Re?{eventDefId:Re}:{}},steps:q.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===U)?.enabled??!0,...He?{config:{continueOnError:!0}}:{config:{}},deliverTo:Xe.length>0?Xe:void 0})}),Oe(null),r(),k.success(`Template updated`)}catch(e){let t=e instanceof Error?e.message:`Failed to update template`;k.error(t)}finally{Ge(!1)}}},pt=e.find(e=>e.id===Se),mt=e.find(e=>e.id===z);return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsx)(se,{title:`Automations`,description:`Reusable workflows, manual triggers, and recent workflow runs.`,compact:!0,action:(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>void r(),children:(0,R.jsx)(f,{size:14})}),(0,R.jsxs)(O,{size:`sm`,onClick:()=>h(!m),children:[(0,R.jsx)(i,{size:14}),`New Automation`]})]})}),m&&(0,R.jsxs)(N,{className:`space-y-3`,children:[(0,R.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,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Triggered by:`}),(0,R.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,R.jsx)(`option`,{value:`manual`,children:`Manual`}),(0,R.jsx)(`option`,{value:`cron`,children:`Schedule (Cron)`}),(0,R.jsx)(`option`,{value:`once`,children:`One-time`}),(0,R.jsx)(`option`,{value:`template_complete`,children:`Template completion`}),(0,R.jsx)(`option`,{value:`event`,children:`Event (definition)`})]}),x===`template_complete`&&(0,R.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=>ae(e.target.value),children:[(0,R.jsx)(`option`,{value:``,children:`-- Select target template --`}),e.filter(e=>e.id!==U).map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),x===`event`&&(0,R.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:Le,onChange:e=>K(e.target.value),children:[(0,R.jsx)(`option`,{value:``,children:`-- Select event --`}),Be.map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),x===`cron`&&(0,R.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:T,onChange:e=>E(e.target.value)}),x===`once`&&(0,R.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,R.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,R.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Action type:`}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>Ke(`prompt`),className:`rounded px-2 py-1 text-xs ${Y===`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,R.jsx)(`button`,{type:`button`,onClick:()=>Ke(`goal`),className:`rounded px-2 py-1 text-xs ${Y===`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`})]})]}),Y===`prompt`?(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Steps`}),(0,R.jsxs)(O,{variant:`ghost`,size:`sm`,onClick:()=>P([...A,{id:nt(A.length),prompt:``}]),children:[(0,R.jsx)(i,{size:12}),` Add Step`]})]}),A.map((e,t)=>(0,R.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] p-2 space-y-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--app-text-subtle)]`,children:e.id}),(0,R.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,R.jsx)(`option`,{value:``,children:`Role (template default)`}),d.filter(e=>e.source!==`system`).map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),A.length>1&&(0,R.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,R.jsx)(u,{size:12})})]}),(0,R.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,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`depends on:`}),A.slice(0,t).map(n=>(0,R.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,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`timeout(s):`,(0,R.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,R.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`max turns:`,(0,R.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,R.jsx)(`div`,{className:`space-y-1`,children:s.length===0?(0,R.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`No goals available`}):s.map(e=>(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-[var(--app-text)] hover:text-[var(--app-text)] cursor-pointer`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:X.includes(e.id),onChange:t=>{t.target.checked?qe([...X,e.id]):qe(X.filter(t=>t!==e.id))},className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-elevated)]`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name}),(0,R.jsx)(M,{variant:`muted`,className:`text-[10px]`,children:e.status})]},e.id))}),A.length>1&&(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-[var(--app-text)] cursor-pointer`,children:[(0,R.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,R.jsx)(be,{value:Je,onChange:Ye}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(O,{onClick:()=>void ot(),disabled:fe||!_.trim()||Y===`prompt`&&A.every(e=>!e.prompt.trim())||Y===`goal`&&X.length===0||x===`template_complete`&&!w,children:fe?`Creating...`:`Create`}),(0,R.jsx)(O,{variant:`ghost`,onClick:()=>h(!1),children:`Cancel`})]})]}),U!==null&&(0,R.jsxs)(N,{className:`space-y-3`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Edit Automation`}),(0,R.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=>ke(e.target.value)}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Triggered by:`}),(0,R.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=>Ae(e.target.value),children:[(0,R.jsx)(`option`,{value:`manual`,children:`Manual`}),(0,R.jsx)(`option`,{value:`cron`,children:`Schedule (Cron)`}),(0,R.jsx)(`option`,{value:`once`,children:`One-time`}),(0,R.jsx)(`option`,{value:`template_complete`,children:`Template completion`}),(0,R.jsx)(`option`,{value:`event`,children:`Event (definition)`})]}),G===`template_complete`&&(0,R.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:Fe,onChange:e=>Ie(e.target.value),children:[(0,R.jsx)(`option`,{value:``,children:`-- Select target template --`}),e.filter(e=>e.id!==U).map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),G===`event`&&(0,R.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:Re,onChange:e=>ze(e.target.value),children:[(0,R.jsx)(`option`,{value:``,children:`-- Select event --`}),Be.map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),G===`cron`&&(0,R.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:je,onChange:e=>Me(e.target.value)}),G===`once`&&(0,R.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:Ne,onChange:e=>Pe(e.target.value)})]}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Steps`}),(0,R.jsxs)(O,{variant:`ghost`,size:`sm`,onClick:()=>J([...q,{id:nt(q.length),prompt:``}]),children:[(0,R.jsx)(i,{size:12}),` Add Step`]})]}),q.map((e,t)=>(0,R.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] p-2 space-y-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--app-text-subtle)]`,children:e.id}),(0,R.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=[...q];r[t]={...e,roleId:n.target.value||void 0},J(r)},children:[(0,R.jsx)(`option`,{value:``,children:`Role (template default)`}),d.filter(e=>e.source!==`system`).map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),q.length>1&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>J(q.filter((e,n)=>n!==t)),className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,children:(0,R.jsx)(u,{size:12})})]}),(0,R.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=[...q];r[t]={...e,prompt:n.target.value},J(r)}}),t>0&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`depends on:`}),q.slice(0,t).map(n=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>{let r=e.dependsOn??[],i=[...q];i[t]={...e,dependsOn:r.includes(n.id)?r.filter(e=>e!==n.id):[...r,n.id]},J(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,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`timeout(s):`,(0,R.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=[...q],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,config:{...e.config,timeout:i}},J(r)}})]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`max turns:`,(0,R.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=[...q],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,config:{...e.config,maxTurns:i}},J(r)}})]})]})]},e.id))]}),q.length>1&&(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-[var(--app-text)] cursor-pointer`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:He,onChange:e=>Ue(e.target.checked),className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-elevated)]`}),`Continue on error`]}),(0,R.jsx)(be,{value:Xe,onChange:Ze}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(O,{onClick:()=>void ft(),disabled:We||!W.trim()||q.every(e=>!e.prompt.trim()),children:We?`Saving...`:`Save`}),(0,R.jsx)(O,{variant:`ghost`,onClick:()=>Oe(null),children:`Cancel`})]})]}),(0,R.jsx)(N,{padding:!1,children:e.length===0?(0,R.jsx)(de,{icon:(0,R.jsx)(o,{size:32}),title:`No automations`,description:`Create an automation to run recurring tasks`}):(0,R.jsxs)(_e,{children:[(0,R.jsx)(me,{children:(0,R.jsxs)(ge,{children:[(0,R.jsx)(F,{children:`Name`}),(0,R.jsx)(F,{children:`Trigger`}),(0,R.jsx)(F,{children:`Schedule`}),(0,R.jsx)(F,{children:`Steps`}),(0,R.jsx)(F,{children:`Enabled`}),(0,R.jsx)(F,{children:`Created`}),(0,R.jsx)(F,{children:`Webhook URL`}),(0,R.jsx)(F,{children:`Actions`})]})}),(0,R.jsx)(he,{children:e.map(e=>(0,R.jsxs)(L.Fragment,{children:[(0,R.jsxs)(ge,{children:[(0,R.jsx)(I,{className:`font-medium text-[var(--app-text)]`,children:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>rt(e.id),className:`flex items-center gap-1 hover:text-[var(--app-accent)] transition-colors`,children:[Qe===e.id?(0,R.jsx)(c,{size:12}):(0,R.jsx)(t,{size:12}),e.name]})}),(0,R.jsx)(I,{children:(0,R.jsx)(M,{variant:e.trigger.type===`cron`?`info`:(e.trigger.type,`muted`),children:at(e.trigger)})}),(0,R.jsx)(I,{className:`font-mono text-xs`,children:e.trigger.type===`once`&&e.trigger.runAt?new Date(e.trigger.runAt).toLocaleString():e.trigger.cron??`—`}),(0,R.jsx)(I,{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,R.jsx)(I,{children:[`cron`,`once`,`template_complete`].every(t=>e.trigger.type!==t)?(0,R.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`—`}):(0,R.jsx)(ve,{checked:e.enabled,onCheckedChange:()=>void ut(e.id),"aria-label":`Toggle ${e.name}`})}),(0,R.jsx)(I,{className:`text-xs text-[var(--app-text-subtle)]`,children:e.createdAt?ce(e.createdAt):`—`}),(0,R.jsx)(I,{className:`font-mono text-xs text-[var(--app-text-muted)]`,children:e.enabled?`POST /webhooks/${e.id}`:`—`}),(0,R.jsx)(I,{children:(0,R.jsxs)(`div`,{className:`flex gap-1`,children:[(0,R.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>dt(e),title:`Edit`,children:(0,R.jsx)(n,{size:12})}),(0,R.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>Ce(e.id),disabled:ye===e.id,title:`Run now`,children:(0,R.jsx)(a,{size:12})}),(0,R.jsx)(O,{variant:`ghost`,size:`sm`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,onClick:()=>{ct(e.id)},title:`Delete`,children:(0,R.jsx)(u,{size:12})})]})})]}),Qe===e.id&&(0,R.jsx)(ge,{children:(0,R.jsxs)(I,{colSpan:8,className:`bg-[var(--app-panel)]/50 p-3`,children:[(0,R.jsx)(`div`,{className:`text-xs text-[var(--app-text-muted)] mb-2 font-medium`,children:`Recent Executions`}),et?(0,R.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Loading...`}):Z.length===0?(0,R.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`No executions yet`}):(0,R.jsx)(`div`,{className:`space-y-1.5`,children:Z.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,R.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-canvas)]/50 p-2.5 space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,R.jsx)(M,{variant:t.status===`completed`?`success`:t.status===`failed`?`destructive`:t.status===`partial`?`warning`:t.status===`cancelled`?`secondary`:`muted`,children:t.status}),(0,R.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:new Date(t.startedAt).toLocaleString()}),s>0&&(0,R.jsxs)(`span`,{className:`text-[var(--app-text-muted)]`,children:[r,`/`,s,` steps`,(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[i>0&&(0,R.jsxs)(`span`,{className:`text-[var(--app-danger)]`,children:[i,` failed`]}),a>0&&(0,R.jsxs)(`span`,{className:`text-[var(--app-warning)]`,children:[a,` skipped`]}),o>0&&(0,R.jsxs)(`span`,{className:`text-[var(--app-text)]`,children:[o,` cancelled`]})]})]}),t.completedAt&&(0,R.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[Math.round((t.completedAt-t.startedAt)/1e3),`s`]}),(0,R.jsx)(`span`,{className:`font-mono text-[var(--app-text-subtle)] truncate max-w-[120px]`,children:t.id.slice(0,8)})]}),(0,R.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,R.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,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:n}),s&&(0,R.jsxs)(`span`,{className:`text-[var(--app-warning-soft-text)]`,children:[`@`,s]}),i?.dependsOn&&i.dependsOn.length>0&&(0,R.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`after `,i.dependsOn.join(`, `)]})]}),l&&(0,R.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,R.jsx)(M,{variant:r.status===`completed`?`success`:r.status===`failed`?`destructive`:r.status===`skipped`?`warning`:r.status===`cancelled`?`secondary`:`muted`,children:r.status}),(0,R.jsxs)(`div`,{className:`text-right text-[var(--app-text-subtle)]`,children:[a?.completedAt&&(0,R.jsxs)(`div`,{children:[Math.max(0,Math.round((a.completedAt-a.createdAt)/1e3)),`s`]}),a?.id&&(0,R.jsx)(`div`,{className:`font-mono`,children:a.id.slice(0,8)})]})]},`${t.id}-${n}`)})})]},t.id)})})]})})]},e.id))})]})}),(0,R.jsx)(ie,{open:Se!==null,onOpenChange:e=>{e||Ce(null)},children:(0,R.jsxs)(S,{children:[(0,R.jsxs)(re,{children:[(0,R.jsx)(b,{children:`Run Template`}),(0,R.jsxs)(v,{children:[`Run “`,pt?.name,`” now? This will execute the template immediately.`]})]}),(0,R.jsxs)(te,{children:[(0,R.jsx)(ne,{children:`Cancel`}),(0,R.jsx)(C,{onClick:()=>{Se&&st(Se),Ce(null)},children:`Run Now`})]})]})}),(0,R.jsx)(ie,{open:z!==null,onOpenChange:e=>{e||(we(null),V(null),H(`template_only`))},children:(0,R.jsxs)(S,{children:[(0,R.jsxs)(re,{children:[(0,R.jsx)(b,{children:`Delete Template`}),(0,R.jsx)(v,{children:B===null?(0,R.jsx)(R.Fragment,{children:`Loading…`}):B.taskCount===0&&B.executionCount===0?(0,R.jsxs)(R.Fragment,{children:[`Delete “`,mt?.name,`”? This action cannot be undone.`]}):B.taskCount===0?(0,R.jsxs)(R.Fragment,{children:[`“`,mt?.name,`” has `,B.executionCount,` execution`,B.executionCount===1?``:`s`,` which will be removed. Delete?`]}):(0,R.jsxs)(R.Fragment,{children:[`“`,mt?.name,`” has`,` `,B.executionCount>0&&(0,R.jsxs)(R.Fragment,{children:[B.executionCount,` execution`,B.executionCount===1?``:`s`]}),B.executionCount>0&&B.taskCount>0&&` and `,B.taskCount,` task`,B.taskCount===1?``:`s`,`. Choose what to delete:`]})})]}),B!==null&&B.taskCount>0&&(0,R.jsxs)(`div`,{className:`space-y-2 px-1`,children:[(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2`,children:[(0,R.jsx)(`input`,{type:`radio`,name:`deleteMode`,value:`template_only`,checked:Te===`template_only`,onChange:()=>H(`template_only`),className:`mt-1`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-sm font-medium`,children:`Template only`}),(0,R.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Removes the automation. Tasks remain under the Tasks tab as history.`})]})]}),(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2`,children:[(0,R.jsx)(`input`,{type:`radio`,name:`deleteMode`,value:`with_tasks`,checked:Te===`with_tasks`,onChange:()=>H(`with_tasks`),className:`mt-1`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-sm font-medium`,children:`Template and its tasks`}),(0,R.jsxs)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Also deletes `,B.taskCount,` task`,B.taskCount===1?``:`s`,` and their score history. Cannot be undone.`]})]})]})]}),(0,R.jsxs)(te,{children:[(0,R.jsx)(ne,{disabled:Ee,children:`Cancel`}),(0,R.jsx)(C,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger)]`,disabled:Ee||B===null,onClick:()=>{z&&lt(z,B&&B.taskCount>0?Te:`template_only`),we(null),V(null),H(`template_only`)},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,L.useEffect)(()=>{r(),i(),a()},[r,i,a]),(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.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,R.jsxs)(Qe,{defaultValue:`tasks`,children:[(0,R.jsxs)($e,{children:[(0,R.jsx)(Z,{value:`tasks`,children:`Tasks`}),(0,R.jsx)(Z,{value:`automations`,children:`Automations`}),(0,R.jsx)(Z,{value:`goals`,children:`Goals`})]}),(0,R.jsx)(Q,{value:`tasks`,children:(0,R.jsx)(tt,{})}),(0,R.jsx)(Q,{value:`automations`,children:(0,R.jsx)(rt,{})}),(0,R.jsx)(Q,{value:`goals`,children:(0,R.jsx)(ye,{})})]})]})}export{it as Work};