adam-agent-server 1.17.0 → 1.18.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 (141) hide show
  1. package/dist/approval-handler-BWA7UIKN.js +1 -0
  2. package/dist/{artifacts-DMY2MI2F.js → artifacts-MAYKOTA2.js} +1 -1
  3. package/dist/audit-diagnostics-K3LUWXTI.js +1 -0
  4. package/dist/audit-manager-6WL2V6JG.js +1 -0
  5. package/dist/bree-engine-KYD4GKQK.js +1 -0
  6. package/dist/{channels-VYNJFXDD.js → channels-2TWTBE6Y.js} +1 -1
  7. package/dist/channels-PWDSTYNR.js +1 -0
  8. package/dist/{chat-tool-calls-WQGFYTUV.js → chat-tool-calls-WJDFQ54U.js} +1 -1
  9. package/dist/{chunk-P76VP2UH.js → chunk-2A2TXYT3.js} +5 -5
  10. package/dist/chunk-2CE2WUUZ.js +1 -0
  11. package/dist/{chunk-YEBC67DJ.js → chunk-2JIQT2CI.js} +1 -1
  12. package/dist/chunk-3MROEPGR.js +1 -0
  13. package/dist/{chunk-725BGAO2.js → chunk-3UFEOB6P.js} +1 -1
  14. package/dist/{chunk-VVBN35YG.js → chunk-47HJPIUA.js} +1 -1
  15. package/dist/{chunk-PBKZDNNV.js → chunk-4JHACUZY.js} +1 -1
  16. package/dist/{chunk-D5PAJ3CB.js → chunk-6WQFYV3N.js} +1 -1
  17. package/dist/{chunk-BRUHXRKK.js → chunk-AUSR5JYV.js} +1 -1
  18. package/dist/{chunk-ED2JAMEN.js → chunk-BE653A45.js} +1 -1
  19. package/dist/{chunk-3RITIMKB.js → chunk-BMCNQGUH.js} +1 -1
  20. package/dist/{chunk-32D5GWJD.js → chunk-HRPMRWHD.js} +1 -1
  21. package/dist/{chunk-QWIBCFPC.js → chunk-IEBAOZED.js} +2 -2
  22. package/dist/{chunk-OII5SDMS.js → chunk-JROGEBP5.js} +1 -1
  23. package/dist/{chunk-DCTNMUQ5.js → chunk-JYZTIE2J.js} +1 -1
  24. package/dist/{chunk-5WBFQMJL.js → chunk-JZBXLN7M.js} +1 -1
  25. package/dist/{chunk-A2S67EQG.js → chunk-KS24764D.js} +2 -2
  26. package/dist/{chunk-WDSCTXT7.js → chunk-LCD5DVS6.js} +1 -1
  27. package/dist/{chunk-3GK65T2V.js → chunk-LKGYQJMS.js} +1 -1
  28. package/dist/{chunk-FMJVKJJE.js → chunk-MTRLUW7Z.js} +1 -1
  29. package/dist/{chunk-3VUEB67V.js → chunk-NSUXJ2VA.js} +1 -1
  30. package/dist/{chunk-73GP6K5S.js → chunk-NUOTFUNF.js} +1 -1
  31. package/dist/chunk-NXGR3PRY.js +1 -0
  32. package/dist/{chunk-4WJ2VSEJ.js → chunk-O6L4UVLV.js} +1 -1
  33. package/dist/{chunk-UUJ24BNJ.js → chunk-OBD4245G.js} +1 -1
  34. package/dist/{chunk-TNBQFCXR.js → chunk-QTGAK62Z.js} +2 -2
  35. package/dist/{chunk-K3HWZBE5.js → chunk-QYI44EP6.js} +1 -1
  36. package/dist/{chunk-MQTK4Q6M.js → chunk-SGLZAIVL.js} +1 -1
  37. package/dist/chunk-SKHMWKJT.js +80 -0
  38. package/dist/{chunk-TO27F23C.js → chunk-T2Z2JDPY.js} +1 -1
  39. package/dist/chunk-TA5PFK5C.js +5 -0
  40. package/dist/{chunk-UAF4KNXE.js → chunk-TWOJVEO7.js} +2 -2
  41. package/dist/{chunk-NV5ZXKKF.js → chunk-UCUELFCS.js} +1 -1
  42. package/dist/{chunk-2WPUKCDA.js → chunk-V2MMQ3SH.js} +1 -1
  43. package/dist/{chunk-7IXYCDUF.js → chunk-VPMHZJS2.js} +1 -1
  44. package/dist/{chunk-3R7VGMAK.js → chunk-VWX2B6OM.js} +1 -1
  45. package/dist/{chunk-VARIYH6K.js → chunk-WY5BOCQP.js} +98 -37
  46. package/dist/{chunk-2RBYM3X7.js → chunk-XAPJJAJQ.js} +1 -1
  47. package/dist/{chunk-A57SY3E4.js → chunk-Z2APBKIT.js} +1 -1
  48. package/dist/chunk-ZJ3TS4FL.js +182 -0
  49. package/dist/{chunk-VSSKQAG5.js → chunk-ZQN6JZIJ.js} +1 -1
  50. package/dist/cli.js +1 -1
  51. package/dist/{config-ZDKMTZJC.js → config-U624HJKI.js} +1 -1
  52. package/dist/config-X7A6NA73.js +1 -0
  53. package/dist/{db-LIKGSZCL.js → db-XODNIJSJ.js} +1 -1
  54. package/dist/{delivery-log-2ILFP673.js → delivery-log-QMQQHES4.js} +1 -1
  55. package/dist/engine-OQXDHA2R.js +1 -0
  56. package/dist/{evolution-audit-BDQM6NAX.js → evolution-audit-XF4KZZMP.js} +1 -1
  57. package/dist/execution-tools-BR4T4MMW.js +1 -0
  58. package/dist/{external-api-7GB3U775.js → external-api-435WH6V3.js} +1 -1
  59. package/dist/index.js +65 -45
  60. package/dist/{learner-V2HBTRAE.js → learner-4CJ7BSCN.js} +1 -1
  61. package/dist/{memories-B3QGTYLX.js → memories-NJFKSOL5.js} +1 -1
  62. package/dist/{memory-extractor-RYZ3VU7A.js → memory-extractor-UQI75BBK.js} +1 -1
  63. package/dist/{memory-gc-5AYND3RL.js → memory-gc-NTZVUGJX.js} +1 -1
  64. package/dist/memory-service-3RLVOF2C.js +1 -0
  65. package/dist/outbound-gateway-NJNSN2ZX.js +1 -0
  66. package/dist/presets-SUJRFRJC.js +1 -0
  67. package/dist/{reflection-job-P6GIQVQN.js → reflection-job-F4BZA2E3.js} +1 -1
  68. package/dist/role-presets-VEYTGYA4.js +1 -0
  69. package/dist/role-workspace-AIVHPX5P.js +1 -0
  70. package/dist/{roles-B6YC4GDC.js → roles-WDMUBWQP.js} +1 -1
  71. package/dist/runtime-OMLPOMCA.js +1 -0
  72. package/dist/session-manager-XFUKWEC7.js +1 -0
  73. package/dist/skill-registry-LARMNUT5.js +1 -0
  74. package/dist/{task-templates-MNCF7JON.js → task-templates-BIVCRNXA.js} +1 -1
  75. package/dist/template-dispatch-6FPJQN6A.js +1 -0
  76. package/package.json +1 -1
  77. package/web/dist/assets/{ArtifactDetail-Dt_xkaYJ.js → ArtifactDetail-DDTEAl2E.js} +1 -1
  78. package/web/dist/assets/{Artifacts-DlPMk9VQ.js → Artifacts-BrhnC1Ef.js} +1 -1
  79. package/web/dist/assets/{ChannelDetail-kYtMmy6P.js → ChannelDetail-D0FBZoAX.js} +1 -1
  80. package/web/dist/assets/{Channels-BppR0Qc_.js → Channels-Cztxvsa2.js} +1 -1
  81. package/web/dist/assets/{Chat-BLVREMCu.js → Chat-Ce72TtUi.js} +2 -2
  82. package/web/dist/assets/Cost-K8-4xqBe.js +4 -0
  83. package/web/dist/assets/{Dashboard-XURc0f15.js → Dashboard-BXqFb_Vr.js} +1 -1
  84. package/web/dist/assets/{EnvVarEditor-DR-bSU0w.js → EnvVarEditor-FiiJazzp.js} +1 -1
  85. package/web/dist/assets/{EventDefDetail-DtkbGbQ0.js → EventDefDetail-C3S1G0K8.js} +1 -1
  86. package/web/dist/assets/{Events-C_J4jvDh.js → Events-BKxqZ9j6.js} +1 -1
  87. package/web/dist/assets/{Evolution-CEaSpRAm.js → Evolution-DFcSm6Rw.js} +1 -1
  88. package/web/dist/assets/{ExtensionDetail-D5Qfq-W4.js → ExtensionDetail-C8aPpyLv.js} +1 -1
  89. package/web/dist/assets/Extensions-MLZk05j0.js +1 -0
  90. package/web/dist/assets/{FeatureRequests-D8WEYtoU.js → FeatureRequests-D_4XaQ7F.js} +1 -1
  91. package/web/dist/assets/{GoalDetail-DnMS_WWw.js → GoalDetail-DVU7c0aR.js} +1 -1
  92. package/web/dist/assets/{Goals-BeKwpAss.js → Goals-D3h4WMjU.js} +1 -1
  93. package/web/dist/assets/LineChart-Ck1vfYHs.js +33 -0
  94. package/web/dist/assets/{Logs-BfXBv-dV.js → Logs-D5MQv6Yw.js} +1 -1
  95. package/web/dist/assets/{Memories-QRH7O8qP.js → Memories-Dls71I2i.js} +1 -1
  96. package/web/dist/assets/{Mistakes-mXU9PXft.js → Mistakes-BZcTg0vP.js} +1 -1
  97. package/web/dist/assets/{Plugins-C8v4AsvM.js → Plugins-CwCHGzI6.js} +1 -1
  98. package/web/dist/assets/RoleDetail-B2M6ALSl.js +3 -0
  99. package/web/dist/assets/{Roles-B8dQCKuS.js → Roles-FEHqm_Jf.js} +1 -1
  100. package/web/dist/assets/Settings-rdVQMfqX.js +1 -0
  101. package/web/dist/assets/{Strategies-DFUWEKfU.js → Strategies-CwJ9JQ-X.js} +1 -1
  102. package/web/dist/assets/{Switch-BcS5rOWb.js → Switch-1JjR4Imr.js} +1 -1
  103. package/web/dist/assets/{TaskDetail-BdhBhvKg.js → TaskDetail-h12WxjfG.js} +1 -1
  104. package/web/dist/assets/{Work-D-t80Ekv.js → Work-CfzFRSZX.js} +1 -1
  105. package/web/dist/assets/api-BP4ZP9kk.js +1 -0
  106. package/web/dist/assets/index-CXEJd-0s.js +12 -0
  107. package/web/dist/assets/index-CarTGiGO.css +2 -0
  108. package/web/dist/assets/{usePluginsWithUsage-DE13JW16.js → usePluginsWithUsage-4iLJAPjH.js} +1 -1
  109. package/web/dist/index.html +3 -3
  110. package/dist/approval-handler-FONN2EGB.js +0 -1
  111. package/dist/audit-diagnostics-D4M4SA5O.js +0 -1
  112. package/dist/audit-manager-YEOJRE6K.js +0 -1
  113. package/dist/bree-engine-RGTBKKFE.js +0 -1
  114. package/dist/channels-WFU4CVGW.js +0 -1
  115. package/dist/chunk-2V2H5PG5.js +0 -182
  116. package/dist/chunk-4G2OZPP5.js +0 -1
  117. package/dist/chunk-CFPXWGFD.js +0 -1
  118. package/dist/chunk-FJ3DUJXO.js +0 -1
  119. package/dist/chunk-OH6VBBDV.js +0 -1
  120. package/dist/chunk-SJTIMT5U.js +0 -5
  121. package/dist/config-GRL6O2ZY.js +0 -1
  122. package/dist/engine-JVPM3XE5.js +0 -1
  123. package/dist/execution-tools-7MK257DY.js +0 -1
  124. package/dist/memory-service-XI3JZQ4E.js +0 -1
  125. package/dist/outbound-gateway-O27KKVOI.js +0 -1
  126. package/dist/presets-UAH3OG3C.js +0 -1
  127. package/dist/role-presets-RVYTO5FS.js +0 -1
  128. package/dist/role-workspace-KOTVFJD3.js +0 -1
  129. package/dist/runtime-C3XN33A3.js +0 -1
  130. package/dist/session-manager-HO2ZCB47.js +0 -1
  131. package/dist/skill-registry-X2GY7SMI.js +0 -1
  132. package/dist/template-dispatch-BAMKX3QH.js +0 -1
  133. package/web/dist/assets/Extensions-B_egkUP1.js +0 -1
  134. package/web/dist/assets/RoleDetail-Ct-k3uoK.js +0 -35
  135. package/web/dist/assets/Settings-CqtCBP6I.js +0 -1
  136. package/web/dist/assets/api-BRfbZQSW.js +0 -1
  137. package/web/dist/assets/index-DWU9AURw.css +0 -2
  138. package/web/dist/assets/index-PIFMZAPo.js +0 -12
  139. /package/web/dist/assets/{NotFound-DuH6sFz7.js → NotFound-t66RIvqO.js} +0 -0
  140. /package/web/dist/assets/{Table-D2K039zr.js → Table-CvSmzzkm.js} +0 -0
  141. /package/web/dist/assets/{Tabs-BwyLSH2c.js → Tabs-DWk9HyNd.js} +0 -0
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,Q as n,Z as r,c as i,l as a,xt as o}from"./vendor-icons-Bc_e_XXa.js";import{t as s}from"./vendor-react-bQ_cvNuA.js";import{n as c}from"./dist-CgGno8kE.js";import{t as l}from"./Button-CRNb8sD3.js";import{t as u}from"./api-BRfbZQSW.js";import{p as d}from"./index-PIFMZAPo.js";import{a as f,i as p,t as m}from"./Card-Cwvv0An8.js";import{t as h}from"./ui-D1crlGpt.js";var g=e(o(),1),_=s(),v=g.forwardRef(({className:e,type:t,...n},r)=>(0,_.jsx)(`input`,{type:t,className:c(`flex h-8 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));v.displayName=`Input`;var y=/^[A-Za-z_][A-Za-z0-9_]*$/,b=/key|token|secret|password|credential/i;function x({envVars:e,onSave:o,mode:s,roleId:c,title:x=`Environment Variables`}){let[S,C]=(0,g.useState)([]),[w,T]=(0,g.useState)(!1),[E,D]=(0,g.useState)(new Set),[O,k]=(0,g.useState)([]),[A,j]=(0,g.useState)(!1);(0,g.useEffect)(()=>{C(Object.entries(e??{}).map(([e,t])=>({key:e,value:t,isNew:!1})))},[e]);let M=(0,g.useCallback)(async()=>{try{let e=await u(s===`global`?`/config/env-diff`:`/roles/${c}/env-diff`);k(s===`global`?e.diffs.filter(e=>e.configPath?.startsWith(`defaults.env.`)):e.diffs),j(e.envFileExists)}catch{}},[s,c]);(0,g.useEffect)(()=>{M()},[M]);let N=()=>{let t=Object.fromEntries(S.filter(e=>e.key.trim()).map(e=>[e.key,e.value]));return JSON.stringify(t)!==JSON.stringify(e)},P=()=>{C(e=>[...e,{key:``,value:``,isNew:!0}])},F=e=>{C(t=>t.filter((t,n)=>n!==e))},I=(e,t,n)=>{C(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))},L=e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},R=()=>{let e=new Set;for(let t of S){let n=t.key.trim();if(n){if(!y.test(n))return`Invalid key format: "${n}"`;if(n.startsWith(`ANTHROPIC_`))return`ANTHROPIC_* keys are managed in the Anthropic section`;if(e.has(n))return`Duplicate key: "${n}"`;e.add(n)}}return e.size>100?`Maximum 100 environment variables`:null},z=async()=>{let e=R();if(e){d.error(e);return}T(!0);try{let e={};for(let t of S){let n=t.key.trim();n&&(e[n]=t.value)}s===`global`?await u(`/config/env`,{method:`PUT`,body:JSON.stringify(e)}):await u(`/roles/${c}`,{method:`PATCH`,body:JSON.stringify({envVars:e})}),d.success(`Environment variables saved`),o(),M()}catch(e){d.error(e instanceof Error?e.message:`Failed to save`)}finally{T(!1)}},B=async()=>{try{await u(s===`global`?`/config/sync-to-env`:`/roles/${c}/sync-to-env`,{method:`POST`}),d.success(`Synced DB to .env`),M()}catch(e){d.error(e instanceof Error?e.message:`Sync failed`)}},V=async()=>{try{await u(s===`global`?`/config/load-from-env`:`/roles/${c}/load-from-env`,{method:`POST`}),d.success(`Loaded .env to DB`),o(),M()}catch(e){d.error(e instanceof Error?e.message:`Load failed`)}};return(0,_.jsxs)(m,{children:[(0,_.jsxs)(p,{children:[(0,_.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,_.jsx)(f,{className:`text-sm`,children:x}),(0,_.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,_.jsxs)(l,{variant:`ghost`,size:`sm`,onClick:P,children:[(0,_.jsx)(t,{size:h.sm}),`Add`]}),N()&&(0,_.jsx)(l,{size:`sm`,onClick:()=>void z(),disabled:w,children:w?`Saving...`:`Save`})]})]}),s===`global`&&(0,_.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] mt-1`,children:`ANTHROPIC_* variables are managed in the Anthropic section above.`})]}),O.length>0&&A&&(0,_.jsx)(`div`,{className:`mx-4 mb-3 rounded border border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg)] p-3`,children:(0,_.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,_.jsx)(i,{size:14,className:`text-[var(--app-warning)]`}),(0,_.jsxs)(`span`,{className:`text-xs text-[var(--app-warning)]`,children:[`.env and DB differ on `,O.length,` key(s): `,O.map(e=>e.envKey).join(`, `)]})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-2 md:justify-end`,children:[(0,_.jsx)(l,{variant:`ghost`,size:`sm`,className:`text-xs`,onClick:()=>void B(),children:`DB → .env`}),(0,_.jsx)(l,{variant:`ghost`,size:`sm`,className:`text-xs`,onClick:()=>void V(),children:`.env → DB`})]})]})}),(0,_.jsxs)(`div`,{className:`px-4 pb-4 space-y-2`,children:[S.length===0&&(0,_.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] py-2`,children:`No environment variables configured.`}),S.map((e,t)=>{let i=b.test(e.key),o=E.has(e.key)||e.isNew;return(0,_.jsxs)(`div`,{className:`flex flex-col gap-2 md:flex-row md:items-center`,children:[(0,_.jsx)(v,{className:`w-full font-mono text-xs md:w-48`,placeholder:`KEY_NAME`,value:e.key,onChange:e=>I(t,`key`,e.target.value)}),(0,_.jsx)(`span`,{className:`hidden text-[var(--app-text-subtle)] md:inline`,children:`=`}),(0,_.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,_.jsx)(v,{className:`font-mono text-xs pr-8`,type:i&&!o?`password`:`text`,placeholder:`value`,value:e.value,onChange:e=>I(t,`value`,e.target.value)}),i&&(0,_.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,onClick:()=>L(e.key),children:o?(0,_.jsx)(n,{size:12}):(0,_.jsx)(r,{size:12})})]}),(0,_.jsx)(l,{variant:`ghost`,size:`sm`,className:`self-end text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)] md:self-auto`,onClick:()=>F(t),children:(0,_.jsx)(a,{size:14})})]},t)})]})]})}export{x as t};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,Q as n,Z as r,c as i,l as a,xt as o}from"./vendor-icons-Bc_e_XXa.js";import{t as s}from"./vendor-react-bQ_cvNuA.js";import{n as c}from"./dist-CgGno8kE.js";import{t as l}from"./Button-CRNb8sD3.js";import{t as u}from"./api-BP4ZP9kk.js";import{p as d}from"./index-CXEJd-0s.js";import{a as f,i as p,t as m}from"./Card-Cwvv0An8.js";import{t as h}from"./ui-D1crlGpt.js";var g=e(o(),1),_=s(),v=g.forwardRef(({className:e,type:t,...n},r)=>(0,_.jsx)(`input`,{type:t,className:c(`flex h-8 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:opacity-50`,e),ref:r,...n}));v.displayName=`Input`;var y=/^[A-Za-z_][A-Za-z0-9_]*$/,b=/key|token|secret|password|credential/i;function x({envVars:e,onSave:o,mode:s,roleId:c,title:x=`Environment Variables`}){let[S,C]=(0,g.useState)([]),[w,T]=(0,g.useState)(!1),[E,D]=(0,g.useState)(new Set),[O,k]=(0,g.useState)([]),[A,j]=(0,g.useState)(!1);(0,g.useEffect)(()=>{C(Object.entries(e??{}).map(([e,t])=>({key:e,value:t,isNew:!1})))},[e]);let M=(0,g.useCallback)(async()=>{try{let e=await u(s===`global`?`/config/env-diff`:`/roles/${c}/env-diff`);k(s===`global`?e.diffs.filter(e=>e.configPath?.startsWith(`defaults.env.`)):e.diffs),j(e.envFileExists)}catch{}},[s,c]);(0,g.useEffect)(()=>{M()},[M]);let N=()=>{let t=Object.fromEntries(S.filter(e=>e.key.trim()).map(e=>[e.key,e.value]));return JSON.stringify(t)!==JSON.stringify(e)},P=()=>{C(e=>[...e,{key:``,value:``,isNew:!0}])},F=e=>{C(t=>t.filter((t,n)=>n!==e))},I=(e,t,n)=>{C(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))},L=e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},R=()=>{let e=new Set;for(let t of S){let n=t.key.trim();if(n){if(!y.test(n))return`Invalid key format: "${n}"`;if(n.startsWith(`ANTHROPIC_`))return`ANTHROPIC_* keys are managed in the Anthropic section`;if(e.has(n))return`Duplicate key: "${n}"`;e.add(n)}}return e.size>100?`Maximum 100 environment variables`:null},z=async()=>{let e=R();if(e){d.error(e);return}T(!0);try{let e={};for(let t of S){let n=t.key.trim();n&&(e[n]=t.value)}s===`global`?await u(`/config/env`,{method:`PUT`,body:JSON.stringify(e)}):await u(`/roles/${c}`,{method:`PATCH`,body:JSON.stringify({envVars:e})}),d.success(`Environment variables saved`),o(),M()}catch(e){d.error(e instanceof Error?e.message:`Failed to save`)}finally{T(!1)}},B=async()=>{try{await u(s===`global`?`/config/sync-to-env`:`/roles/${c}/sync-to-env`,{method:`POST`}),d.success(`Synced DB to .env`),M()}catch(e){d.error(e instanceof Error?e.message:`Sync failed`)}},V=async()=>{try{await u(s===`global`?`/config/load-from-env`:`/roles/${c}/load-from-env`,{method:`POST`}),d.success(`Loaded .env to DB`),o(),M()}catch(e){d.error(e instanceof Error?e.message:`Load failed`)}};return(0,_.jsxs)(m,{children:[(0,_.jsxs)(p,{children:[(0,_.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,_.jsx)(f,{className:`text-sm`,children:x}),(0,_.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,_.jsxs)(l,{variant:`ghost`,size:`sm`,onClick:P,children:[(0,_.jsx)(t,{size:h.sm}),`Add`]}),N()&&(0,_.jsx)(l,{size:`sm`,onClick:()=>void z(),disabled:w,children:w?`Saving...`:`Save`})]})]}),s===`global`&&(0,_.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] mt-1`,children:`ANTHROPIC_* variables are managed in the Anthropic section above.`})]}),O.length>0&&A&&(0,_.jsx)(`div`,{className:`mx-4 mb-3 rounded border border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg)] p-3`,children:(0,_.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,_.jsx)(i,{size:14,className:`text-[var(--app-warning)]`}),(0,_.jsxs)(`span`,{className:`text-xs text-[var(--app-warning)]`,children:[`.env and DB differ on `,O.length,` key(s): `,O.map(e=>e.envKey).join(`, `)]})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-2 md:justify-end`,children:[(0,_.jsx)(l,{variant:`ghost`,size:`sm`,className:`text-xs`,onClick:()=>void B(),children:`DB → .env`}),(0,_.jsx)(l,{variant:`ghost`,size:`sm`,className:`text-xs`,onClick:()=>void V(),children:`.env → DB`})]})]})}),(0,_.jsxs)(`div`,{className:`px-4 pb-4 space-y-2`,children:[S.length===0&&(0,_.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] py-2`,children:`No environment variables configured.`}),S.map((e,t)=>{let i=b.test(e.key),o=E.has(e.key)||e.isNew;return(0,_.jsxs)(`div`,{className:`flex flex-col gap-2 md:flex-row md:items-center`,children:[(0,_.jsx)(v,{className:`w-full font-mono text-xs md:w-48`,placeholder:`KEY_NAME`,value:e.key,onChange:e=>I(t,`key`,e.target.value)}),(0,_.jsx)(`span`,{className:`hidden text-[var(--app-text-subtle)] md:inline`,children:`=`}),(0,_.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,_.jsx)(v,{className:`font-mono text-xs pr-8`,type:i&&!o?`password`:`text`,placeholder:`value`,value:e.value,onChange:e=>I(t,`value`,e.target.value)}),i&&(0,_.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,onClick:()=>L(e.key),children:o?(0,_.jsx)(n,{size:12}):(0,_.jsx)(r,{size:12})})]}),(0,_.jsx)(l,{variant:`ghost`,size:`sm`,className:`self-end text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)] md:self-auto`,onClick:()=>F(t),children:(0,_.jsx)(a,{size:14})})]},t)})]})]})}export{x as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{vt as t,w as n,xt as r}from"./vendor-icons-Bc_e_XXa.js";import{d as i,f as a,t as o}from"./vendor-react-bQ_cvNuA.js";import{t as s}from"./Button-CRNb8sD3.js";import{t as c}from"./api-BRfbZQSW.js";import{p as l,t as u}from"./index-PIFMZAPo.js";import{t as d}from"./Card-Cwvv0An8.js";import{t as f}from"./SectionHeader-NZWZgoOs.js";import{t as p}from"./EmptyState-BvQA1o5K.js";import{a as m,i as h,n as g,o as _,r as v,t as y}from"./Table-D2K039zr.js";var b=e(r(),1),x=o(),S={webhook:`info`,directory_watch:`warning`,cron:`success`,manual:`muted`},C={running:`info`,completed:`success`,failed:`destructive`,partial:`warning`,cancelled:`muted`};function w(){let{id:e}=a(),r=i(),[o,w]=(0,b.useState)(null),[T,E]=(0,b.useState)(!0),[D,O]=(0,b.useState)([]),[k,A]=(0,b.useState)(!1),[j,M]=(0,b.useState)(0),[N,P]=(0,b.useState)(!1),[F,I]=(0,b.useState)([]),[L,R]=(0,b.useState)(!1),[z,B]=(0,b.useState)(0),[V,H]=(0,b.useState)(!1),[U,W]=(0,b.useState)(`config`),G=(0,b.useCallback)(async()=>{if(e){E(!0);try{w(await c(`/event-defs/${e}`))}catch{l.error(`Event not found`),r(`/events`)}finally{E(!1)}}},[e,r]),K=(0,b.useCallback)(async(t=0)=>{if(e){A(!0);try{let n=t===0?void 0:new Date(Date.now()-10080*60*1e3).toISOString(),r=await c(`/event-defs/${e}/firings?${new URLSearchParams({limit:`20`,...n?{since:n}:{}})}`);O(t===0?r:e=>[...e,...r]),P(r.length===20),M(t)}catch{l.error(`Failed to load firings`)}finally{A(!1)}}},[e]);(0,b.useEffect)(()=>{G()},[G]),(0,b.useEffect)(()=>{U===`firings`&&D.length===0&&K(0)},[U,K,D.length]);let q=(0,b.useCallback)(async(t=0)=>{if(e){R(!0);try{let n=await c(`/event-defs/${e}/dispatches?${new URLSearchParams({limit:`20`,offset:String(t*20)})}`);I(t===0?n:e=>[...e,...n]),H(n.length===20),B(t)}catch{l.error(`Failed to load dispatches`)}finally{R(!1)}}},[e]);return(0,b.useEffect)(()=>{U===`dispatches`&&F.length===0&&q(0)},[U,q,F.length]),T?(0,x.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,x.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):o?(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>r(`/events`),children:(0,x.jsx)(t,{size:14})}),(0,x.jsx)(f,{title:o.name,description:o.description,compact:!0,action:(0,x.jsx)(`div`,{className:`flex gap-2`,children:(0,x.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void G(),children:(0,x.jsx)(n,{size:14})})})})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(u,{variant:S[o.sourceType],children:o.sourceType===`directory_watch`?`file watcher`:o.sourceType}),(0,x.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-medium ${o.enabled?`bg-green-900/30 text-green-400`:`bg-gray-800/30 text-gray-400`}`,children:o.enabled?`Enabled`:`Disabled`}),(0,x.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`Created `,new Date(o.createdAt).toLocaleDateString()]})]}),o.sourceType===`webhook`&&(0,x.jsxs)(d,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Webhook URL`}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsxs)(`code`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-1.5 font-mono text-xs text-[var(--app-text)] break-all`,children:[window.location.origin,`/webhooks/events/`,o.id]}),(0,x.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>{if(!o)return;let e=`${window.location.origin}/webhooks/events/${o.id}`;navigator.clipboard.writeText(e),l.success(`Webhook URL copied to clipboard`)},children:`Copy`})]}),(0,x.jsxs)(`p`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`Send a POST request with JSON body: `,(0,x.jsx)(`code`,{className:`rounded bg-[var(--app-panel)] px-1`,children:`{ "type": "event.name", "payload": {...} }`})]})]}),(()=>{let e=o.sourceConfig?.cron;return e?(0,x.jsxs)(d,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Schedule`}),(0,x.jsx)(`code`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-1.5 font-mono text-sm text-[var(--app-text)]`,children:e})]}):null})(),(()=>{let e=o.sourceConfig?.path;return e?(0,x.jsxs)(d,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Watch Directory`}),(0,x.jsx)(`code`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-1.5 font-mono text-sm text-[var(--app-text)] break-all`,children:e})]}):null})(),(0,x.jsxs)(`div`,{className:`flex gap-1 border-b border-[var(--app-border)]`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>W(`config`),className:`px-4 py-2 text-sm transition-colors ${U===`config`?`border-b-2 border-[var(--app-accent)] text-[var(--app-text)]`:`text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:`Configuration`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>W(`firings`),className:`px-4 py-2 text-sm transition-colors ${U===`firings`?`border-b-2 border-[var(--app-accent)] text-[var(--app-text)]`:`text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:`Firings`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>W(`dispatches`),className:`px-4 py-2 text-sm transition-colors ${U===`dispatches`?`border-b-2 border-[var(--app-accent)] text-[var(--app-text)]`:`text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:`Dispatches`})]}),U===`firings`&&(0,x.jsx)(d,{padding:!1,children:k&&D.length===0?(0,x.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,x.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):D.length===0?(0,x.jsx)(p,{icon:(0,x.jsx)(n,{size:32}),title:`No firings yet`,description:`This event has not been triggered yet.`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(y,{children:[(0,x.jsx)(m,{children:(0,x.jsxs)(_,{children:[(0,x.jsx)(h,{children:`Occurred At`}),(0,x.jsx)(h,{children:`Type`}),(0,x.jsx)(h,{children:`Source`}),(0,x.jsx)(h,{children:`Confidence`}),(0,x.jsx)(h,{children:`Payload`})]})}),(0,x.jsx)(g,{children:D.map(e=>(0,x.jsxs)(_,{children:[(0,x.jsx)(v,{className:`text-xs text-[var(--app-text-muted)] whitespace-nowrap`,children:new Date(e.occurredAt).toLocaleString()}),(0,x.jsx)(v,{children:(0,x.jsx)(`code`,{className:`text-xs font-mono text-[var(--app-text)]`,children:e.type})}),(0,x.jsx)(v,{className:`text-xs text-[var(--app-text-muted)]`,children:e.source}),(0,x.jsx)(v,{className:`text-xs`,children:(0,x.jsx)(`span`,{className:e.confidence<1?`text-yellow-400`:`text-[var(--app-text-muted)]`,children:e.confidence})}),(0,x.jsx)(v,{className:`max-w-[200px]`,children:(0,x.jsxs)(`code`,{className:`text-xs font-mono text-[var(--app-text-muted)] truncate block`,children:[JSON.stringify(e.payload).slice(0,60),JSON.stringify(e.payload).length>60?`...`:``]})})]},e.id))})]}),N&&(0,x.jsx)(`div`,{className:`flex justify-center p-3 border-t border-[var(--app-border)]`,children:(0,x.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void K(j+1),disabled:k,children:k?`Loading...`:`Load more`})})]})}),U===`dispatches`&&(0,x.jsx)(d,{padding:!1,children:L&&F.length===0?(0,x.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,x.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):F.length===0?(0,x.jsx)(p,{icon:(0,x.jsx)(n,{size:32}),title:`No dispatches yet`,description:`No task template has been dispatched from this event. Bind a template (trigger=event, eventDefId=this event) to see dispatch history.`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(y,{children:[(0,x.jsx)(m,{children:(0,x.jsxs)(_,{children:[(0,x.jsx)(h,{children:`Started At`}),(0,x.jsx)(h,{children:`Template`}),(0,x.jsx)(h,{children:`Status`}),(0,x.jsx)(h,{children:`Duration`}),(0,x.jsx)(h,{children:`Error`})]})}),(0,x.jsx)(g,{children:F.map(e=>{let t=e.completedAt?`${e.completedAt-e.startedAt}ms`:`—`;return(0,x.jsxs)(_,{children:[(0,x.jsx)(v,{className:`text-xs text-[var(--app-text-muted)] whitespace-nowrap`,children:new Date(e.startedAt).toLocaleString()}),(0,x.jsx)(v,{children:(0,x.jsx)(`button`,{type:`button`,onClick:()=>r(`/templates/${e.templateId}`),className:`text-[var(--app-text)] hover:text-[var(--app-accent)] transition-colors text-left`,children:e.templateName??e.templateId})}),(0,x.jsx)(v,{children:(0,x.jsx)(u,{variant:C[e.status],children:e.status})}),(0,x.jsx)(v,{className:`text-xs text-[var(--app-text-muted)]`,children:t}),(0,x.jsx)(v,{className:`max-w-[300px]`,children:e.error?(0,x.jsx)(`code`,{className:`text-xs font-mono text-[var(--app-danger)] truncate block`,title:e.error,children:e.error.length>80?`${e.error.slice(0,80)}…`:e.error}):(0,x.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`—`})})]},e.executionId)})})]}),V&&(0,x.jsx)(`div`,{className:`flex justify-center p-3 border-t border-[var(--app-border)]`,children:(0,x.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void q(z+1),disabled:L,children:L?`Loading...`:`Load more`})})]})})]}):null}export{w as EventDefDetail};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{vt as t,w as n,xt as r}from"./vendor-icons-Bc_e_XXa.js";import{d as i,f as a,t as o}from"./vendor-react-bQ_cvNuA.js";import{t as s}from"./Button-CRNb8sD3.js";import{t as c}from"./api-BP4ZP9kk.js";import{p as l,t as u}from"./index-CXEJd-0s.js";import{t as d}from"./Card-Cwvv0An8.js";import{t as f}from"./SectionHeader-NZWZgoOs.js";import{t as p}from"./EmptyState-BvQA1o5K.js";import{a as m,i as h,n as g,o as _,r as v,t as y}from"./Table-CvSmzzkm.js";var b=e(r(),1),x=o(),S={webhook:`info`,directory_watch:`warning`,cron:`success`,manual:`muted`},C={running:`info`,completed:`success`,failed:`destructive`,partial:`warning`,cancelled:`muted`};function w(){let{id:e}=a(),r=i(),[o,w]=(0,b.useState)(null),[T,E]=(0,b.useState)(!0),[D,O]=(0,b.useState)([]),[k,A]=(0,b.useState)(!1),[j,M]=(0,b.useState)(0),[N,P]=(0,b.useState)(!1),[F,I]=(0,b.useState)([]),[L,R]=(0,b.useState)(!1),[z,B]=(0,b.useState)(0),[V,H]=(0,b.useState)(!1),[U,W]=(0,b.useState)(`config`),G=(0,b.useCallback)(async()=>{if(e){E(!0);try{w(await c(`/event-defs/${e}`))}catch{l.error(`Event not found`),r(`/events`)}finally{E(!1)}}},[e,r]),K=(0,b.useCallback)(async(t=0)=>{if(e){A(!0);try{let n=t===0?void 0:new Date(Date.now()-10080*60*1e3).toISOString(),r=await c(`/event-defs/${e}/firings?${new URLSearchParams({limit:`20`,...n?{since:n}:{}})}`);O(t===0?r:e=>[...e,...r]),P(r.length===20),M(t)}catch{l.error(`Failed to load firings`)}finally{A(!1)}}},[e]);(0,b.useEffect)(()=>{G()},[G]),(0,b.useEffect)(()=>{U===`firings`&&D.length===0&&K(0)},[U,K,D.length]);let q=(0,b.useCallback)(async(t=0)=>{if(e){R(!0);try{let n=await c(`/event-defs/${e}/dispatches?${new URLSearchParams({limit:`20`,offset:String(t*20)})}`);I(t===0?n:e=>[...e,...n]),H(n.length===20),B(t)}catch{l.error(`Failed to load dispatches`)}finally{R(!1)}}},[e]);return(0,b.useEffect)(()=>{U===`dispatches`&&F.length===0&&q(0)},[U,q,F.length]),T?(0,x.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,x.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):o?(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>r(`/events`),children:(0,x.jsx)(t,{size:14})}),(0,x.jsx)(f,{title:o.name,description:o.description,compact:!0,action:(0,x.jsx)(`div`,{className:`flex gap-2`,children:(0,x.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void G(),children:(0,x.jsx)(n,{size:14})})})})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(u,{variant:S[o.sourceType],children:o.sourceType===`directory_watch`?`file watcher`:o.sourceType}),(0,x.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-medium ${o.enabled?`bg-green-900/30 text-green-400`:`bg-gray-800/30 text-gray-400`}`,children:o.enabled?`Enabled`:`Disabled`}),(0,x.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`Created `,new Date(o.createdAt).toLocaleDateString()]})]}),o.sourceType===`webhook`&&(0,x.jsxs)(d,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Webhook URL`}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsxs)(`code`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-1.5 font-mono text-xs text-[var(--app-text)] break-all`,children:[window.location.origin,`/webhooks/events/`,o.id]}),(0,x.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>{if(!o)return;let e=`${window.location.origin}/webhooks/events/${o.id}`;navigator.clipboard.writeText(e),l.success(`Webhook URL copied to clipboard`)},children:`Copy`})]}),(0,x.jsxs)(`p`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`Send a POST request with JSON body: `,(0,x.jsx)(`code`,{className:`rounded bg-[var(--app-panel)] px-1`,children:`{ "type": "event.name", "payload": {...} }`})]})]}),(()=>{let e=o.sourceConfig?.cron;return e?(0,x.jsxs)(d,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Schedule`}),(0,x.jsx)(`code`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-1.5 font-mono text-sm text-[var(--app-text)]`,children:e})]}):null})(),(()=>{let e=o.sourceConfig?.path;return e?(0,x.jsxs)(d,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Watch Directory`}),(0,x.jsx)(`code`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-1.5 font-mono text-sm text-[var(--app-text)] break-all`,children:e})]}):null})(),(0,x.jsxs)(`div`,{className:`flex gap-1 border-b border-[var(--app-border)]`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>W(`config`),className:`px-4 py-2 text-sm transition-colors ${U===`config`?`border-b-2 border-[var(--app-accent)] text-[var(--app-text)]`:`text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:`Configuration`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>W(`firings`),className:`px-4 py-2 text-sm transition-colors ${U===`firings`?`border-b-2 border-[var(--app-accent)] text-[var(--app-text)]`:`text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:`Firings`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>W(`dispatches`),className:`px-4 py-2 text-sm transition-colors ${U===`dispatches`?`border-b-2 border-[var(--app-accent)] text-[var(--app-text)]`:`text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:`Dispatches`})]}),U===`firings`&&(0,x.jsx)(d,{padding:!1,children:k&&D.length===0?(0,x.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,x.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):D.length===0?(0,x.jsx)(p,{icon:(0,x.jsx)(n,{size:32}),title:`No firings yet`,description:`This event has not been triggered yet.`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(y,{children:[(0,x.jsx)(m,{children:(0,x.jsxs)(_,{children:[(0,x.jsx)(h,{children:`Occurred At`}),(0,x.jsx)(h,{children:`Type`}),(0,x.jsx)(h,{children:`Source`}),(0,x.jsx)(h,{children:`Confidence`}),(0,x.jsx)(h,{children:`Payload`})]})}),(0,x.jsx)(g,{children:D.map(e=>(0,x.jsxs)(_,{children:[(0,x.jsx)(v,{className:`text-xs text-[var(--app-text-muted)] whitespace-nowrap`,children:new Date(e.occurredAt).toLocaleString()}),(0,x.jsx)(v,{children:(0,x.jsx)(`code`,{className:`text-xs font-mono text-[var(--app-text)]`,children:e.type})}),(0,x.jsx)(v,{className:`text-xs text-[var(--app-text-muted)]`,children:e.source}),(0,x.jsx)(v,{className:`text-xs`,children:(0,x.jsx)(`span`,{className:e.confidence<1?`text-yellow-400`:`text-[var(--app-text-muted)]`,children:e.confidence})}),(0,x.jsx)(v,{className:`max-w-[200px]`,children:(0,x.jsxs)(`code`,{className:`text-xs font-mono text-[var(--app-text-muted)] truncate block`,children:[JSON.stringify(e.payload).slice(0,60),JSON.stringify(e.payload).length>60?`...`:``]})})]},e.id))})]}),N&&(0,x.jsx)(`div`,{className:`flex justify-center p-3 border-t border-[var(--app-border)]`,children:(0,x.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void K(j+1),disabled:k,children:k?`Loading...`:`Load more`})})]})}),U===`dispatches`&&(0,x.jsx)(d,{padding:!1,children:L&&F.length===0?(0,x.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,x.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):F.length===0?(0,x.jsx)(p,{icon:(0,x.jsx)(n,{size:32}),title:`No dispatches yet`,description:`No task template has been dispatched from this event. Bind a template (trigger=event, eventDefId=this event) to see dispatch history.`}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(y,{children:[(0,x.jsx)(m,{children:(0,x.jsxs)(_,{children:[(0,x.jsx)(h,{children:`Started At`}),(0,x.jsx)(h,{children:`Template`}),(0,x.jsx)(h,{children:`Status`}),(0,x.jsx)(h,{children:`Duration`}),(0,x.jsx)(h,{children:`Error`})]})}),(0,x.jsx)(g,{children:F.map(e=>{let t=e.completedAt?`${e.completedAt-e.startedAt}ms`:`—`;return(0,x.jsxs)(_,{children:[(0,x.jsx)(v,{className:`text-xs text-[var(--app-text-muted)] whitespace-nowrap`,children:new Date(e.startedAt).toLocaleString()}),(0,x.jsx)(v,{children:(0,x.jsx)(`button`,{type:`button`,onClick:()=>r(`/templates/${e.templateId}`),className:`text-[var(--app-text)] hover:text-[var(--app-accent)] transition-colors text-left`,children:e.templateName??e.templateId})}),(0,x.jsx)(v,{children:(0,x.jsx)(u,{variant:C[e.status],children:e.status})}),(0,x.jsx)(v,{className:`text-xs text-[var(--app-text-muted)]`,children:t}),(0,x.jsx)(v,{className:`max-w-[300px]`,children:e.error?(0,x.jsx)(`code`,{className:`text-xs font-mono text-[var(--app-danger)] truncate block`,title:e.error,children:e.error.length>80?`${e.error.slice(0,80)}…`:e.error}):(0,x.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`—`})})]},e.executionId)})})]}),V&&(0,x.jsx)(`div`,{className:`flex justify-center p-3 border-t border-[var(--app-border)]`,children:(0,x.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void q(z+1),disabled:L,children:L?`Loading...`:`Load more`})})]})})]}):null}export{w as EventDefDetail};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{A as t,D as n,j as ee,l as te,t as ne,w as re,xt as r}from"./vendor-icons-Bc_e_XXa.js";import{d as ie,t as i}from"./vendor-react-bQ_cvNuA.js";import"./es2015-BkFSNOYE.js";import{t as a}from"./Button-CRNb8sD3.js";import{t as o}from"./api-BRfbZQSW.js";import{a as ae,c as s,i as c,l,o as u,p as d,r as f,s as oe,t as se,u as ce}from"./index-PIFMZAPo.js";import{t as p}from"./Card-Cwvv0An8.js";import{t as le}from"./SectionHeader-NZWZgoOs.js";import{a as ue}from"./format-ZWN4JNj-.js";import{t as de}from"./EmptyState-BvQA1o5K.js";import{a as fe,i as m,n as pe,o as h,r as g,t as me}from"./Table-D2K039zr.js";import{t as he}from"./Switch-BcS5rOWb.js";var _=e(r(),1),v=i(),ge={webhook:`info`,directory_watch:`warning`,cron:`success`,manual:`muted`};function y(e){let t=e.trim().split(/\s+/);return t.length===5?t.every(e=>/^(\*|(\*\/)?\d+(-\d+)?(,\d+(-\d+)?)*)$/.test(e)):!1}function b(){let e=ie(),[r,i]=(0,_.useState)([]),[b,x]=(0,_.useState)(!0),[_e,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)(``),[T,ve]=(0,_.useState)(`webhook`),[E,D]=(0,_.useState)(``),[O,k]=(0,_.useState)(``),[A,j]=(0,_.useState)(``),[M,N]=(0,_.useState)(``),[P,F]=(0,_.useState)(!1),[I,L]=(0,_.useState)(null),[R,z]=(0,_.useState)(``),[B,ye]=(0,_.useState)(``),[V,be]=(0,_.useState)(`webhook`),[H,U]=(0,_.useState)(``),[W,G]=(0,_.useState)(``),[K,q]=(0,_.useState)(``),[xe,Se]=(0,_.useState)(!1),[J,Y]=(0,_.useState)(null),[X,Z]=(0,_.useState)(null),[Q,Ce]=(0,_.useState)(``),[we,Te]=(0,_.useState)(!1),$=(0,_.useCallback)(async()=>{x(!0);try{i(await o(`/event-defs`))}catch{d.error(`Failed to load events`)}finally{x(!1)}},[]);(0,_.useEffect)(()=>{$()},[$]);let Ee=async()=>{if(C.trim()){if(T===`cron`&&!y(A)){N(`Invalid cron expression (expected 5 fields: minute hour day month weekday)`);return}F(!0);try{let e={name:C.trim(),sourceType:T,description:E.trim()||void 0,enabled:!0};T===`directory_watch`&&O.trim()?e.sourceConfig={path:O.trim(),stability_delay_ms:5e3}:T===`cron`&&A.trim()&&(e.sourceConfig={cron:A.trim()}),await o(`/event-defs`,{method:`POST`,body:JSON.stringify(e)}),w(``),D(``),k(``),j(``),N(``),S(!1),$(),d.success(`Event created`)}catch(e){let t=e instanceof Error?e.message:`Failed to create event`;d.error(t)}finally{F(!1)}}},De=e=>{L(e.id),z(e.name),ye(e.description??``),be(e.sourceType),U(e.sourceConfig?.path??``),G(e.sourceConfig?.cron??``),q(``)},Oe=async()=>{if(!(!I||!R.trim())){if(V===`cron`&&!y(W)){q(`Invalid cron expression`);return}Se(!0);try{let e={name:R.trim(),description:B.trim()||void 0};V===`directory_watch`?e.sourceConfig={path:H.trim(),stability_delay_ms:5e3}:V===`cron`&&(e.sourceConfig={cron:W.trim()}),await o(`/event-defs/${I}`,{method:`PATCH`,body:JSON.stringify(e)}),L(null),$(),d.success(`Event updated`)}catch(e){let t=e instanceof Error?e.message:`Failed to update event`;d.error(t)}finally{Se(!1)}}},ke=async e=>{try{await o(`/event-defs/${e.id}`,{method:`PATCH`,body:JSON.stringify({enabled:!e.enabled})}),$()}catch(e){let t=e instanceof Error?e.message:`Failed to toggle`;d.error(t)}},Ae=async e=>{try{await o(`/event-defs/${e}`,{method:`DELETE`}),Y(null),$(),d.success(`Event deleted`)}catch(e){let t=e instanceof Error?e.message:`Failed to delete`;d.error(t)}},je=async e=>{Te(!0);try{let t={};if(Q.trim())try{t.payload=JSON.parse(Q)}catch{t.payload={raw:Q}}await o(`/event-defs/${e}/fire`,{method:`POST`,body:JSON.stringify(t)}),Z(null),Ce(``),d.success(`Event fired`)}catch(e){let t=e instanceof Error?e.message:`Failed to fire event`;d.error(t)}finally{Te(!1)}},Me=r.find(e=>e.id===J);return(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsx)(le,{title:`Events`,description:`Event definitions that trigger automations. Configure webhooks, schedules, or file watchers.`,compact:!0,action:(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>void $(),children:(0,v.jsx)(re,{size:14})}),(0,v.jsxs)(a,{size:`sm`,onClick:()=>S(!_e),children:[(0,v.jsx)(n,{size:14}),`New Event`]})]})}),_e&&(0,v.jsxs)(p,{className:`space-y-3`,children:[(0,v.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`New Event`}),(0,v.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:`Event name`,value:C,onChange:e=>w(e.target.value)}),(0,v.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:`Description (optional)`,value:E,onChange:e=>D(e.target.value)}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Source:`}),(0,v.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:T,onChange:e=>ve(e.target.value),children:[(0,v.jsx)(`option`,{value:`webhook`,children:`Webhook (HTTP)`}),(0,v.jsx)(`option`,{value:`cron`,children:`Schedule (Cron)`}),(0,v.jsx)(`option`,{value:`directory_watch`,children:`File Watcher`}),(0,v.jsx)(`option`,{value:`manual`,children:`Manual`})]})]}),T===`directory_watch`&&(0,v.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:`Watch directory path (absolute)`,value:O,onChange:e=>k(e.target.value)}),T===`cron`&&(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.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:`Cron expression (minute hour day month weekday)`,value:A,onChange:e=>{j(e.target.value),N(``)}}),M&&(0,v.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:M})]}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(a,{onClick:()=>void Ee(),disabled:P||!C.trim()||T===`directory_watch`&&!O.trim(),children:P?`Creating...`:`Create`}),(0,v.jsx)(a,{variant:`ghost`,onClick:()=>S(!1),children:`Cancel`})]})]}),I!==null&&(r.find(e=>e.id===I)?(0,v.jsxs)(p,{className:`space-y-3`,children:[(0,v.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Edit Event`}),(0,v.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:`Event name`,value:R,onChange:e=>z(e.target.value)}),(0,v.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:`Description (optional)`,value:B,onChange:e=>ye(e.target.value)}),V===`directory_watch`&&(0,v.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:`Watch directory path`,value:H,onChange:e=>U(e.target.value)}),V===`cron`&&(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.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:`Cron expression`,value:W,onChange:e=>{G(e.target.value),q(``)}}),K&&(0,v.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:K})]}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(a,{onClick:()=>void Oe(),disabled:xe||!R.trim(),children:xe?`Saving...`:`Save`}),(0,v.jsx)(a,{variant:`ghost`,onClick:()=>L(null),children:`Cancel`})]})]}):null),(0,v.jsx)(p,{padding:!1,children:b?(0,v.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,v.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):r.length===0?(0,v.jsx)(de,{icon:(0,v.jsx)(ne,{size:32}),title:`No events`,description:`Events are triggered by webhooks, schedules, or file changes and can start automations.`}):(0,v.jsxs)(me,{children:[(0,v.jsx)(fe,{children:(0,v.jsxs)(h,{children:[(0,v.jsx)(m,{children:`Name`}),(0,v.jsx)(m,{children:`Source`}),(0,v.jsx)(m,{children:`Enabled`}),(0,v.jsx)(m,{children:`Last Fired`}),(0,v.jsx)(m,{children:`Actions`})]})}),(0,v.jsx)(pe,{children:r.map(n=>(0,v.jsxs)(h,{children:[(0,v.jsxs)(g,{children:[(0,v.jsx)(`button`,{type:`button`,onClick:()=>e(`/events/${n.id}`),className:`font-medium text-[var(--app-text)] hover:text-[var(--app-accent)] transition-colors text-left`,children:n.name}),n.description&&(0,v.jsx)(`div`,{className:`text-xs text-[var(--app-text-muted)] truncate max-w-[200px]`,children:n.description})]}),(0,v.jsx)(g,{children:(0,v.jsx)(se,{variant:ge[n.sourceType],children:n.sourceType===`directory_watch`?`file watcher`:n.sourceType})}),(0,v.jsx)(g,{children:(0,v.jsx)(he,{checked:n.enabled,onCheckedChange:()=>void ke(n),"aria-label":`Toggle ${n.name}`})}),(0,v.jsx)(g,{className:`text-xs text-[var(--app-text-muted)]`,children:n.lastFiredAt?ue(n.lastFiredAt):`—`}),(0,v.jsx)(g,{children:(0,v.jsxs)(`div`,{className:`flex gap-1`,children:[(0,v.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>De(n),title:`Edit`,children:(0,v.jsx)(ee,{size:12})}),n.sourceType===`manual`&&n.enabled&&(0,v.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>Z(n.id),title:`Fire now`,children:(0,v.jsx)(t,{size:12})}),(0,v.jsx)(a,{variant:`ghost`,size:`sm`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,onClick:()=>Y(n.id),title:`Delete`,children:(0,v.jsx)(te,{size:12})})]})})]},n.id))})]})}),(0,v.jsx)(f,{open:X!==null,onOpenChange:e=>{e||Z(null)},children:(0,v.jsxs)(u,{children:[(0,v.jsxs)(l,{children:[(0,v.jsx)(ce,{children:`Fire Event`}),(0,v.jsx)(oe,{children:`Fire the manual event immediately. Optionally provide a JSON payload.`})]}),(0,v.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder='{}' focus:border-[var(--app-accent)] focus:outline-none font-mono`,rows:4,placeholder:`{"key": "value"}`,value:Q,onChange:e=>Ce(e.target.value)}),(0,v.jsxs)(s,{children:[(0,v.jsx)(ae,{children:`Cancel`}),(0,v.jsx)(c,{onClick:()=>{X&&je(X),Z(null)},disabled:we,children:we?`Firing...`:`Fire Event`})]})]})}),(0,v.jsx)(f,{open:J!==null,onOpenChange:e=>{e||Y(null)},children:(0,v.jsxs)(u,{children:[(0,v.jsxs)(l,{children:[(0,v.jsx)(ce,{children:`Delete Event`}),(0,v.jsxs)(oe,{children:[`Delete “`,Me?.name,`”? This action cannot be undone.`]})]}),(0,v.jsxs)(s,{children:[(0,v.jsx)(ae,{children:`Cancel`}),(0,v.jsx)(c,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger)]`,onClick:()=>{J&&Ae(J)},children:`Delete`})]})]})})]})}export{b as Events};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{A as t,D as n,j as ee,l as te,t as ne,w as re,xt as r}from"./vendor-icons-Bc_e_XXa.js";import{d as ie,t as i}from"./vendor-react-bQ_cvNuA.js";import"./es2015-BkFSNOYE.js";import{t as a}from"./Button-CRNb8sD3.js";import{t as o}from"./api-BP4ZP9kk.js";import{a as ae,c as s,i as c,l,o as u,p as d,r as f,s as oe,t as se,u as ce}from"./index-CXEJd-0s.js";import{t as p}from"./Card-Cwvv0An8.js";import{t as le}from"./SectionHeader-NZWZgoOs.js";import{a as ue}from"./format-ZWN4JNj-.js";import{t as de}from"./EmptyState-BvQA1o5K.js";import{a as fe,i as m,n as pe,o as h,r as g,t as me}from"./Table-CvSmzzkm.js";import{t as he}from"./Switch-1JjR4Imr.js";var _=e(r(),1),v=i(),ge={webhook:`info`,directory_watch:`warning`,cron:`success`,manual:`muted`};function y(e){let t=e.trim().split(/\s+/);return t.length===5?t.every(e=>/^(\*|(\*\/)?\d+(-\d+)?(,\d+(-\d+)?)*)$/.test(e)):!1}function b(){let e=ie(),[r,i]=(0,_.useState)([]),[b,x]=(0,_.useState)(!0),[_e,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)(``),[T,ve]=(0,_.useState)(`webhook`),[E,D]=(0,_.useState)(``),[O,k]=(0,_.useState)(``),[A,j]=(0,_.useState)(``),[M,N]=(0,_.useState)(``),[P,F]=(0,_.useState)(!1),[I,L]=(0,_.useState)(null),[R,z]=(0,_.useState)(``),[B,ye]=(0,_.useState)(``),[V,be]=(0,_.useState)(`webhook`),[H,U]=(0,_.useState)(``),[W,G]=(0,_.useState)(``),[K,q]=(0,_.useState)(``),[xe,Se]=(0,_.useState)(!1),[J,Y]=(0,_.useState)(null),[X,Z]=(0,_.useState)(null),[Q,Ce]=(0,_.useState)(``),[we,Te]=(0,_.useState)(!1),$=(0,_.useCallback)(async()=>{x(!0);try{i(await o(`/event-defs`))}catch{d.error(`Failed to load events`)}finally{x(!1)}},[]);(0,_.useEffect)(()=>{$()},[$]);let Ee=async()=>{if(C.trim()){if(T===`cron`&&!y(A)){N(`Invalid cron expression (expected 5 fields: minute hour day month weekday)`);return}F(!0);try{let e={name:C.trim(),sourceType:T,description:E.trim()||void 0,enabled:!0};T===`directory_watch`&&O.trim()?e.sourceConfig={path:O.trim(),stability_delay_ms:5e3}:T===`cron`&&A.trim()&&(e.sourceConfig={cron:A.trim()}),await o(`/event-defs`,{method:`POST`,body:JSON.stringify(e)}),w(``),D(``),k(``),j(``),N(``),S(!1),$(),d.success(`Event created`)}catch(e){let t=e instanceof Error?e.message:`Failed to create event`;d.error(t)}finally{F(!1)}}},De=e=>{L(e.id),z(e.name),ye(e.description??``),be(e.sourceType),U(e.sourceConfig?.path??``),G(e.sourceConfig?.cron??``),q(``)},Oe=async()=>{if(!(!I||!R.trim())){if(V===`cron`&&!y(W)){q(`Invalid cron expression`);return}Se(!0);try{let e={name:R.trim(),description:B.trim()||void 0};V===`directory_watch`?e.sourceConfig={path:H.trim(),stability_delay_ms:5e3}:V===`cron`&&(e.sourceConfig={cron:W.trim()}),await o(`/event-defs/${I}`,{method:`PATCH`,body:JSON.stringify(e)}),L(null),$(),d.success(`Event updated`)}catch(e){let t=e instanceof Error?e.message:`Failed to update event`;d.error(t)}finally{Se(!1)}}},ke=async e=>{try{await o(`/event-defs/${e.id}`,{method:`PATCH`,body:JSON.stringify({enabled:!e.enabled})}),$()}catch(e){let t=e instanceof Error?e.message:`Failed to toggle`;d.error(t)}},Ae=async e=>{try{await o(`/event-defs/${e}`,{method:`DELETE`}),Y(null),$(),d.success(`Event deleted`)}catch(e){let t=e instanceof Error?e.message:`Failed to delete`;d.error(t)}},je=async e=>{Te(!0);try{let t={};if(Q.trim())try{t.payload=JSON.parse(Q)}catch{t.payload={raw:Q}}await o(`/event-defs/${e}/fire`,{method:`POST`,body:JSON.stringify(t)}),Z(null),Ce(``),d.success(`Event fired`)}catch(e){let t=e instanceof Error?e.message:`Failed to fire event`;d.error(t)}finally{Te(!1)}},Me=r.find(e=>e.id===J);return(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsx)(le,{title:`Events`,description:`Event definitions that trigger automations. Configure webhooks, schedules, or file watchers.`,compact:!0,action:(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>void $(),children:(0,v.jsx)(re,{size:14})}),(0,v.jsxs)(a,{size:`sm`,onClick:()=>S(!_e),children:[(0,v.jsx)(n,{size:14}),`New Event`]})]})}),_e&&(0,v.jsxs)(p,{className:`space-y-3`,children:[(0,v.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`New Event`}),(0,v.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:`Event name`,value:C,onChange:e=>w(e.target.value)}),(0,v.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:`Description (optional)`,value:E,onChange:e=>D(e.target.value)}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Source:`}),(0,v.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:T,onChange:e=>ve(e.target.value),children:[(0,v.jsx)(`option`,{value:`webhook`,children:`Webhook (HTTP)`}),(0,v.jsx)(`option`,{value:`cron`,children:`Schedule (Cron)`}),(0,v.jsx)(`option`,{value:`directory_watch`,children:`File Watcher`}),(0,v.jsx)(`option`,{value:`manual`,children:`Manual`})]})]}),T===`directory_watch`&&(0,v.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:`Watch directory path (absolute)`,value:O,onChange:e=>k(e.target.value)}),T===`cron`&&(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.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:`Cron expression (minute hour day month weekday)`,value:A,onChange:e=>{j(e.target.value),N(``)}}),M&&(0,v.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:M})]}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(a,{onClick:()=>void Ee(),disabled:P||!C.trim()||T===`directory_watch`&&!O.trim(),children:P?`Creating...`:`Create`}),(0,v.jsx)(a,{variant:`ghost`,onClick:()=>S(!1),children:`Cancel`})]})]}),I!==null&&(r.find(e=>e.id===I)?(0,v.jsxs)(p,{className:`space-y-3`,children:[(0,v.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Edit Event`}),(0,v.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:`Event name`,value:R,onChange:e=>z(e.target.value)}),(0,v.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:`Description (optional)`,value:B,onChange:e=>ye(e.target.value)}),V===`directory_watch`&&(0,v.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:`Watch directory path`,value:H,onChange:e=>U(e.target.value)}),V===`cron`&&(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.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:`Cron expression`,value:W,onChange:e=>{G(e.target.value),q(``)}}),K&&(0,v.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:K})]}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(a,{onClick:()=>void Oe(),disabled:xe||!R.trim(),children:xe?`Saving...`:`Save`}),(0,v.jsx)(a,{variant:`ghost`,onClick:()=>L(null),children:`Cancel`})]})]}):null),(0,v.jsx)(p,{padding:!1,children:b?(0,v.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,v.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):r.length===0?(0,v.jsx)(de,{icon:(0,v.jsx)(ne,{size:32}),title:`No events`,description:`Events are triggered by webhooks, schedules, or file changes and can start automations.`}):(0,v.jsxs)(me,{children:[(0,v.jsx)(fe,{children:(0,v.jsxs)(h,{children:[(0,v.jsx)(m,{children:`Name`}),(0,v.jsx)(m,{children:`Source`}),(0,v.jsx)(m,{children:`Enabled`}),(0,v.jsx)(m,{children:`Last Fired`}),(0,v.jsx)(m,{children:`Actions`})]})}),(0,v.jsx)(pe,{children:r.map(n=>(0,v.jsxs)(h,{children:[(0,v.jsxs)(g,{children:[(0,v.jsx)(`button`,{type:`button`,onClick:()=>e(`/events/${n.id}`),className:`font-medium text-[var(--app-text)] hover:text-[var(--app-accent)] transition-colors text-left`,children:n.name}),n.description&&(0,v.jsx)(`div`,{className:`text-xs text-[var(--app-text-muted)] truncate max-w-[200px]`,children:n.description})]}),(0,v.jsx)(g,{children:(0,v.jsx)(se,{variant:ge[n.sourceType],children:n.sourceType===`directory_watch`?`file watcher`:n.sourceType})}),(0,v.jsx)(g,{children:(0,v.jsx)(he,{checked:n.enabled,onCheckedChange:()=>void ke(n),"aria-label":`Toggle ${n.name}`})}),(0,v.jsx)(g,{className:`text-xs text-[var(--app-text-muted)]`,children:n.lastFiredAt?ue(n.lastFiredAt):`—`}),(0,v.jsx)(g,{children:(0,v.jsxs)(`div`,{className:`flex gap-1`,children:[(0,v.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>De(n),title:`Edit`,children:(0,v.jsx)(ee,{size:12})}),n.sourceType===`manual`&&n.enabled&&(0,v.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>Z(n.id),title:`Fire now`,children:(0,v.jsx)(t,{size:12})}),(0,v.jsx)(a,{variant:`ghost`,size:`sm`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,onClick:()=>Y(n.id),title:`Delete`,children:(0,v.jsx)(te,{size:12})})]})})]},n.id))})]})}),(0,v.jsx)(f,{open:X!==null,onOpenChange:e=>{e||Z(null)},children:(0,v.jsxs)(u,{children:[(0,v.jsxs)(l,{children:[(0,v.jsx)(ce,{children:`Fire Event`}),(0,v.jsx)(oe,{children:`Fire the manual event immediately. Optionally provide a JSON payload.`})]}),(0,v.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder='{}' focus:border-[var(--app-accent)] focus:outline-none font-mono`,rows:4,placeholder:`{"key": "value"}`,value:Q,onChange:e=>Ce(e.target.value)}),(0,v.jsxs)(s,{children:[(0,v.jsx)(ae,{children:`Cancel`}),(0,v.jsx)(c,{onClick:()=>{X&&je(X),Z(null)},disabled:we,children:we?`Firing...`:`Fire Event`})]})]})}),(0,v.jsx)(f,{open:J!==null,onOpenChange:e=>{e||Y(null)},children:(0,v.jsxs)(u,{children:[(0,v.jsxs)(l,{children:[(0,v.jsx)(ce,{children:`Delete Event`}),(0,v.jsxs)(oe,{children:[`Delete “`,Me?.name,`”? This action cannot be undone.`]})]}),(0,v.jsxs)(s,{children:[(0,v.jsx)(ae,{children:`Cancel`}),(0,v.jsx)(c,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger)]`,onClick:()=>{J&&Ae(J)},children:`Delete`})]})]})})]})}export{b as Events};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{q as t,w as n,xt as r}from"./vendor-icons-Bc_e_XXa.js";import{t as i}from"./vendor-react-bQ_cvNuA.js";import{t as a}from"./Button-CRNb8sD3.js";import{t as o}from"./api-BRfbZQSW.js";import{f as s,t as c}from"./index-PIFMZAPo.js";import{t as l}from"./Card-Cwvv0An8.js";import{t as u}from"./PageHeader-acLQTYct.js";import{a as d}from"./format-ZWN4JNj-.js";import{t as f}from"./EmptyState-BvQA1o5K.js";var p=e(r(),1),m=i();function h(){let e=s(e=>e.roles),r=s(e=>e.fetchRoles),[i,h]=(0,p.useState)([]),[g,_]=(0,p.useState)(!0),[v,y]=(0,p.useState)(`all`);(0,p.useEffect)(()=>{r()},[r]);let b=(0,p.useCallback)(async()=>{_(!0);try{let e=new URLSearchParams({limit:`50`});v!==`all`&&e.set(`roleId`,v),h(await o(`/evolution-audit?${e}`))}catch{h([])}finally{_(!1)}},[v]);(0,p.useEffect)(()=>{b()},[b]);let x=t=>t?e.find(e=>e.id===t)?.name??t.slice(0,8):`System`;return(0,m.jsxs)(`div`,{className:`space-y-5`,children:[(0,m.jsx)(u,{eyebrow:`Learning`,title:`Evolution Audit`,compact:!0,description:`Rule mutations and diagnostic reports across roles.`,metrics:[{label:`Visible`,value:i.length},{label:`Role Filter`,value:v===`all`?`All`:x(v)},{label:`Catalog`,value:e.length}],actions:(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsxs)(`select`,{className:`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`,value:v,onChange:e=>y(e.target.value),children:[(0,m.jsx)(`option`,{value:`all`,children:`All roles`}),e.map(e=>(0,m.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,m.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>void b(),children:(0,m.jsx)(n,{size:14})})]})}),(0,m.jsx)(l,{children:g?(0,m.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,m.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):i.length===0?(0,m.jsx)(f,{icon:(0,m.jsx)(t,{size:32}),title:`No evolution records`,description:`Evolution occurs when roles accumulate enough task experience.`,className:`py-8`}):(0,m.jsxs)(`div`,{className:`space-y-4`,children:[(0,m.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[i.length,` records`]}),i.map(e=>(0,m.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] p-3`,children:[(0,m.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,m.jsx)(c,{variant:`info`,children:x(e.roleId)}),(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:d(e.timestamp)}),e.triggerTaskId&&(0,m.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`triggered by task `,e.triggerTaskId.slice(0,8)]})]}),e.diff.includes(`--- Diagnostic Report ---`)?(0,m.jsxs)(`div`,{className:`space-y-2`,children:[(0,m.jsxs)(`div`,{className:`rounded bg-[var(--app-canvas)] p-2`,children:[(0,m.jsx)(`p`,{className:`mb-1 text-[10px] font-medium text-[var(--app-text-muted)]`,children:`Diagnostic Report`}),(0,m.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-[var(--app-text-muted)]`,children:e.diff.split(`--- Rules Diff ---`)[0]?.replace(`--- Diagnostic Report ---
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{q as t,w as n,xt as r}from"./vendor-icons-Bc_e_XXa.js";import{t as i}from"./vendor-react-bQ_cvNuA.js";import{t as a}from"./Button-CRNb8sD3.js";import{t as o}from"./api-BP4ZP9kk.js";import{f as s,t as c}from"./index-CXEJd-0s.js";import{t as l}from"./Card-Cwvv0An8.js";import{t as u}from"./PageHeader-acLQTYct.js";import{a as d}from"./format-ZWN4JNj-.js";import{t as f}from"./EmptyState-BvQA1o5K.js";var p=e(r(),1),m=i();function h(){let e=s(e=>e.roles),r=s(e=>e.fetchRoles),[i,h]=(0,p.useState)([]),[g,_]=(0,p.useState)(!0),[v,y]=(0,p.useState)(`all`);(0,p.useEffect)(()=>{r()},[r]);let b=(0,p.useCallback)(async()=>{_(!0);try{let e=new URLSearchParams({limit:`50`});v!==`all`&&e.set(`roleId`,v),h(await o(`/evolution-audit?${e}`))}catch{h([])}finally{_(!1)}},[v]);(0,p.useEffect)(()=>{b()},[b]);let x=t=>t?e.find(e=>e.id===t)?.name??t.slice(0,8):`System`;return(0,m.jsxs)(`div`,{className:`space-y-5`,children:[(0,m.jsx)(u,{eyebrow:`Learning`,title:`Evolution Audit`,compact:!0,description:`Rule mutations and diagnostic reports across roles.`,metrics:[{label:`Visible`,value:i.length},{label:`Role Filter`,value:v===`all`?`All`:x(v)},{label:`Catalog`,value:e.length}],actions:(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsxs)(`select`,{className:`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`,value:v,onChange:e=>y(e.target.value),children:[(0,m.jsx)(`option`,{value:`all`,children:`All roles`}),e.map(e=>(0,m.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,m.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>void b(),children:(0,m.jsx)(n,{size:14})})]})}),(0,m.jsx)(l,{children:g?(0,m.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,m.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):i.length===0?(0,m.jsx)(f,{icon:(0,m.jsx)(t,{size:32}),title:`No evolution records`,description:`Evolution occurs when roles accumulate enough task experience.`,className:`py-8`}):(0,m.jsxs)(`div`,{className:`space-y-4`,children:[(0,m.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[i.length,` records`]}),i.map(e=>(0,m.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] p-3`,children:[(0,m.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,m.jsx)(c,{variant:`info`,children:x(e.roleId)}),(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:d(e.timestamp)}),e.triggerTaskId&&(0,m.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`triggered by task `,e.triggerTaskId.slice(0,8)]})]}),e.diff.includes(`--- Diagnostic Report ---`)?(0,m.jsxs)(`div`,{className:`space-y-2`,children:[(0,m.jsxs)(`div`,{className:`rounded bg-[var(--app-canvas)] p-2`,children:[(0,m.jsx)(`p`,{className:`mb-1 text-[10px] font-medium text-[var(--app-text-muted)]`,children:`Diagnostic Report`}),(0,m.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-[var(--app-text-muted)]`,children:e.diff.split(`--- Rules Diff ---`)[0]?.replace(`--- Diagnostic Report ---
2
2
  `,``).trim()})]}),(0,m.jsxs)(`div`,{className:`rounded bg-[var(--app-canvas)] p-2`,children:[(0,m.jsx)(`p`,{className:`mb-1 text-[10px] font-medium text-[var(--app-text-muted)]`,children:`Rules Changes`}),(0,m.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap font-mono text-xs`,children:(e.diff.split(`--- Rules Diff ---`)[1]??``).trim().split(`
3
3
  `).map((e,t)=>(0,m.jsxs)(`span`,{className:e.startsWith(`+`)?`text-[var(--app-success)]`:e.startsWith(`-`)?`text-[var(--app-danger)]`:`text-[var(--app-text-muted)]`,children:[e,`
4
4
  `]},t))})]})]}):(0,m.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap rounded bg-[var(--app-canvas)] p-2 font-mono text-xs`,children:e.diff.split(`
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{ft as t,l as n,pt as r,xt as i,z as a}from"./vendor-icons-Bc_e_XXa.js";import{d as o,f as s,t as c}from"./vendor-react-bQ_cvNuA.js";import{t as l}from"./Button-CRNb8sD3.js";import{c as u,o as d}from"./api-BRfbZQSW.js";import{p as f}from"./index-PIFMZAPo.js";import{t as p}from"./Card-Cwvv0An8.js";import{t as m}from"./PageHeader-acLQTYct.js";import{t as h}from"./ui-D1crlGpt.js";var g=e(i(),1),_=c();function v({meta:e}){let[n,i]=(0,g.useState)(!1);return(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`button`,{className:`flex items-center gap-1 text-xs text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,onClick:()=>i(e=>!e),children:[n?(0,_.jsx)(r,{size:12}):(0,_.jsx)(t,{size:12}),`_meta`]}),n&&(0,_.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-lg bg-black/20 p-3 text-xs text-[var(--app-text-muted)]`,children:JSON.stringify(e,null,2)})]})}function y({fieldKey:e,field:t,value:n}){let r=n==null?t.default===void 0?``:String(t.default):String(n);return(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`label`,{className:`text-xs font-medium text-[var(--app-text)]`,children:[t.title,t.required&&(0,_.jsx)(`span`,{className:`ml-1 text-red-400`,children:`*`}),t.sensitive&&(0,_.jsx)(`span`,{className:`ml-1 text-[var(--app-text-subtle)]`,children:`(sensitive)`})]}),t.description&&(0,_.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:t.description}),(0,_.jsx)(`input`,{type:t.sensitive?`password`:`text`,readOnly:!0,defaultValue:r,placeholder:`${e}`,className:`w-full rounded-lg border border-[var(--app-border)] bg-black/20 px-3 py-1.5 text-xs text-[var(--app-text)] outline-none`})]})}function b(){let{name:e}=s(),t=o(),[r,i]=(0,g.useState)(null),[c,b]=(0,g.useState)(null),[x,S]=(0,g.useState)(!0),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(!1),D=(0,g.useCallback)(async()=>{if(e){S(!0);try{let t=await u(e);i(t);try{b(JSON.parse(t.manifestJson))}catch{}}catch{f.error(`Extension not found`),t(`/extensions`)}finally{S(!1)}}},[e,t]);(0,g.useEffect)(()=>{D()},[D]);async function O(){if(r){w(!0);try{await d(r.name),f.success(`Uninstalled ${r.name}`),t(`/extensions`)}catch{f.error(`Failed to uninstall extension`),w(!1)}}}if(x)return(0,_.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,_.jsx)(a,{size:24,className:`animate-spin text-[var(--app-text-subtle)]`})});if(!r||!c)return null;let k=(()=>{try{return r.defaultConfigJson?JSON.parse(r.defaultConfigJson):{}}catch{return{}}})();return(0,_.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,_.jsx)(m,{title:c.display_name??r.name,description:`v${r.version} · Source: ${r.installSource}`,actions:(0,_.jsxs)(l,{variant:`destructive`,onClick:()=>E(!0),disabled:C,children:[(0,_.jsx)(n,{size:h.md}),`卸载`]})}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto space-y-4 p-4`,children:[(0,_.jsxs)(p,{className:`p-4 space-y-2`,children:[(0,_.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)]`,children:c.description}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-[var(--app-text-subtle)]`,children:[(0,_.jsxs)(`span`,{children:[`Author: `,c.author.name]}),c.author.email&&(0,_.jsx)(`span`,{children:c.author.email}),c.homepage&&(0,_.jsx)(`a`,{href:c.homepage,target:`_blank`,rel:`noreferrer`,className:`text-[var(--app-accent)] hover:underline`,children:`Homepage`})]})]}),c.tools&&c.tools.length>0&&(0,_.jsxs)(p,{className:`p-4`,children:[(0,_.jsxs)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-[var(--app-text-subtle)]`,children:[`Tools (`,c.tools.length,`)`]}),(0,_.jsx)(`div`,{className:`space-y-2`,children:c.tools.map(e=>(0,_.jsxs)(`div`,{className:`rounded-lg border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,_.jsx)(`p`,{className:`font-mono text-xs font-medium text-[var(--app-text)]`,children:e.name}),e.description&&(0,_.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--app-text-muted)]`,children:e.description})]},e.name))})]}),c.user_config&&Object.keys(c.user_config).length>0&&(0,_.jsxs)(p,{className:`p-4`,children:[(0,_.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-[var(--app-text-subtle)]`,children:`Configuration`}),(0,_.jsx)(`div`,{className:`space-y-3`,children:Object.entries(c.user_config).map(([e,t])=>(0,_.jsx)(y,{fieldKey:e,field:t,value:k[e]},e))})]}),c._meta&&Object.keys(c._meta).length>0&&(0,_.jsx)(p,{className:`p-4`,children:(0,_.jsx)(v,{meta:c._meta})}),(0,_.jsxs)(p,{className:`p-4`,children:[(0,_.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-[var(--app-text-subtle)]`,children:`Server`}),(0,_.jsxs)(`div`,{className:`space-y-1 text-xs text-[var(--app-text)]`,children:[(0,_.jsxs)(`p`,{children:[`Type: `,(0,_.jsx)(`span`,{className:`font-mono`,children:c.server.type})]}),(0,_.jsxs)(`p`,{children:[`Command: `,(0,_.jsx)(`span`,{className:`font-mono`,children:c.server.mcp_config.command})]}),c.server.mcp_config.args&&c.server.mcp_config.args.length>0&&(0,_.jsxs)(`p`,{children:[`Args: `,(0,_.jsx)(`span`,{className:`font-mono`,children:c.server.mcp_config.args.join(` `)})]})]})]})]}),T&&(0,_.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,children:(0,_.jsxs)(`div`,{className:`w-full max-w-sm rounded-2xl border border-[var(--app-border)] bg-[var(--app-bg)] p-6 shadow-2xl`,children:[(0,_.jsx)(`h2`,{className:`mb-2 text-base font-semibold text-[var(--app-text)]`,children:`Uninstall extension?`}),(0,_.jsxs)(`p`,{className:`mb-4 text-sm text-[var(--app-text-subtle)]`,children:[`This will remove `,(0,_.jsx)(`strong`,{children:r.name}),` from the DB and delete its files from disk. This cannot be undone.`]}),(0,_.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,_.jsx)(l,{variant:`ghost`,onClick:()=>E(!1),disabled:C,children:`Cancel`}),(0,_.jsxs)(l,{variant:`destructive`,onClick:()=>void O(),disabled:C,children:[C?(0,_.jsx)(a,{size:h.md,className:`animate-spin`}):(0,_.jsx)(n,{size:h.md}),`Uninstall`]})]})]})})]})}export{b as ExtensionDetail};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{ft as t,l as n,pt as r,xt as i,z as a}from"./vendor-icons-Bc_e_XXa.js";import{d as o,f as s,t as c}from"./vendor-react-bQ_cvNuA.js";import{t as l}from"./Button-CRNb8sD3.js";import{o as u,u as d}from"./api-BP4ZP9kk.js";import{p as f}from"./index-CXEJd-0s.js";import{t as p}from"./Card-Cwvv0An8.js";import{t as m}from"./PageHeader-acLQTYct.js";import{t as h}from"./ui-D1crlGpt.js";var g=e(i(),1),_=c();function v({meta:e}){let[n,i]=(0,g.useState)(!1);return(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`button`,{className:`flex items-center gap-1 text-xs text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,onClick:()=>i(e=>!e),children:[n?(0,_.jsx)(r,{size:12}):(0,_.jsx)(t,{size:12}),`_meta`]}),n&&(0,_.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-lg bg-black/20 p-3 text-xs text-[var(--app-text-muted)]`,children:JSON.stringify(e,null,2)})]})}function y({fieldKey:e,field:t,value:n}){let r=n==null?t.default===void 0?``:String(t.default):String(n);return(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`label`,{className:`text-xs font-medium text-[var(--app-text)]`,children:[t.title,t.required&&(0,_.jsx)(`span`,{className:`ml-1 text-red-400`,children:`*`}),t.sensitive&&(0,_.jsx)(`span`,{className:`ml-1 text-[var(--app-text-subtle)]`,children:`(sensitive)`})]}),t.description&&(0,_.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:t.description}),(0,_.jsx)(`input`,{type:t.sensitive?`password`:`text`,readOnly:!0,defaultValue:r,placeholder:`${e}`,className:`w-full rounded-lg border border-[var(--app-border)] bg-black/20 px-3 py-1.5 text-xs text-[var(--app-text)] outline-none`})]})}function b(){let{name:e}=s(),t=o(),[r,i]=(0,g.useState)(null),[c,b]=(0,g.useState)(null),[x,S]=(0,g.useState)(!0),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(!1),D=(0,g.useCallback)(async()=>{if(e){S(!0);try{let t=await d(e);i(t);try{b(JSON.parse(t.manifestJson))}catch{}}catch{f.error(`Extension not found`),t(`/extensions`)}finally{S(!1)}}},[e,t]);(0,g.useEffect)(()=>{D()},[D]);async function O(){if(r){w(!0);try{await u(r.name),f.success(`Uninstalled ${r.name}`),t(`/extensions`)}catch{f.error(`Failed to uninstall extension`),w(!1)}}}if(x)return(0,_.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,_.jsx)(a,{size:24,className:`animate-spin text-[var(--app-text-subtle)]`})});if(!r||!c)return null;let k=(()=>{try{return r.defaultConfigJson?JSON.parse(r.defaultConfigJson):{}}catch{return{}}})();return(0,_.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,_.jsx)(m,{title:c.display_name??r.name,description:`v${r.version} · Source: ${r.installSource}`,actions:(0,_.jsxs)(l,{variant:`destructive`,onClick:()=>E(!0),disabled:C,children:[(0,_.jsx)(n,{size:h.md}),`卸载`]})}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto space-y-4 p-4`,children:[(0,_.jsxs)(p,{className:`p-4 space-y-2`,children:[(0,_.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)]`,children:c.description}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-[var(--app-text-subtle)]`,children:[(0,_.jsxs)(`span`,{children:[`Author: `,c.author.name]}),c.author.email&&(0,_.jsx)(`span`,{children:c.author.email}),c.homepage&&(0,_.jsx)(`a`,{href:c.homepage,target:`_blank`,rel:`noreferrer`,className:`text-[var(--app-accent)] hover:underline`,children:`Homepage`})]})]}),c.tools&&c.tools.length>0&&(0,_.jsxs)(p,{className:`p-4`,children:[(0,_.jsxs)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-[var(--app-text-subtle)]`,children:[`Tools (`,c.tools.length,`)`]}),(0,_.jsx)(`div`,{className:`space-y-2`,children:c.tools.map(e=>(0,_.jsxs)(`div`,{className:`rounded-lg border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,_.jsx)(`p`,{className:`font-mono text-xs font-medium text-[var(--app-text)]`,children:e.name}),e.description&&(0,_.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--app-text-muted)]`,children:e.description})]},e.name))})]}),c.user_config&&Object.keys(c.user_config).length>0&&(0,_.jsxs)(p,{className:`p-4`,children:[(0,_.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-[var(--app-text-subtle)]`,children:`Configuration`}),(0,_.jsx)(`div`,{className:`space-y-3`,children:Object.entries(c.user_config).map(([e,t])=>(0,_.jsx)(y,{fieldKey:e,field:t,value:k[e]},e))})]}),c._meta&&Object.keys(c._meta).length>0&&(0,_.jsx)(p,{className:`p-4`,children:(0,_.jsx)(v,{meta:c._meta})}),(0,_.jsxs)(p,{className:`p-4`,children:[(0,_.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-[var(--app-text-subtle)]`,children:`Server`}),(0,_.jsxs)(`div`,{className:`space-y-1 text-xs text-[var(--app-text)]`,children:[(0,_.jsxs)(`p`,{children:[`Type: `,(0,_.jsx)(`span`,{className:`font-mono`,children:c.server.type})]}),(0,_.jsxs)(`p`,{children:[`Command: `,(0,_.jsx)(`span`,{className:`font-mono`,children:c.server.mcp_config.command})]}),c.server.mcp_config.args&&c.server.mcp_config.args.length>0&&(0,_.jsxs)(`p`,{children:[`Args: `,(0,_.jsx)(`span`,{className:`font-mono`,children:c.server.mcp_config.args.join(` `)})]})]})]})]}),T&&(0,_.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,children:(0,_.jsxs)(`div`,{className:`w-full max-w-sm rounded-2xl border border-[var(--app-border)] bg-[var(--app-bg)] p-6 shadow-2xl`,children:[(0,_.jsx)(`h2`,{className:`mb-2 text-base font-semibold text-[var(--app-text)]`,children:`Uninstall extension?`}),(0,_.jsxs)(`p`,{className:`mb-4 text-sm text-[var(--app-text-subtle)]`,children:[`This will remove `,(0,_.jsx)(`strong`,{children:r.name}),` from the DB and delete its files from disk. This cannot be undone.`]}),(0,_.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,_.jsx)(l,{variant:`ghost`,onClick:()=>E(!1),disabled:C,children:`Cancel`}),(0,_.jsxs)(l,{variant:`destructive`,onClick:()=>void O(),disabled:C,children:[C?(0,_.jsx)(a,{size:h.md,className:`animate-spin`}):(0,_.jsx)(n,{size:h.md}),`Uninstall`]})]})]})})]})}export{b as ExtensionDetail};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{N as t,c as n,ft as r,n as i,pt as a,s as o,xt as s,z as c}from"./vendor-icons-Bc_e_XXa.js";import{d as l,t as u}from"./vendor-react-bQ_cvNuA.js";import{t as d}from"./Button-CRNb8sD3.js";import{f,i as p,p as m,w as h}from"./api-BP4ZP9kk.js";import{p as g}from"./index-CXEJd-0s.js";import{t as _}from"./Card-Cwvv0An8.js";import{t as v}from"./PageHeader-acLQTYct.js";import{t as y}from"./EmptyState-BvQA1o5K.js";import{t as b}from"./ui-D1crlGpt.js";var x=e(s(),1),S=u();function C({snapshot:e,onClear:t}){let[i,o]=(0,x.useState)(!1),[s,l]=(0,x.useState)(null);if(e.count===0)return null;async function u(e){l(e.roleId);try{await p(e.roleId),t(e.roleId),g.success(`Cleared legacy mcp_servers for ${e.roleName}`)}catch{g.error(`Failed to clear legacy mcp_servers`)}finally{l(null)}}return(0,S.jsxs)(`div`,{className:`mb-4 rounded-xl border border-yellow-500/30 bg-yellow-500/5 p-4`,children:[(0,S.jsxs)(`button`,{className:`flex w-full items-center gap-2 text-left`,onClick:()=>o(e=>!e),children:[(0,S.jsx)(n,{size:b.sm,className:`shrink-0 text-yellow-400`}),(0,S.jsxs)(`span`,{className:`flex-1 text-sm font-medium text-yellow-300`,children:[e.count,` role`,e.count===1?``:`s`,` with legacy`,` `,(0,S.jsx)(`code`,{className:`font-mono`,children:`mcp_servers`}),` field`]}),i?(0,S.jsx)(a,{size:b.sm,className:`text-yellow-400`}):(0,S.jsx)(r,{size:b.sm,className:`text-yellow-400`})]}),i&&(0,S.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,S.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`These roles have an inline `,(0,S.jsx)(`code`,{className:`font-mono`,children:`mcp_servers`}),` config that predates the Extensions system. Click "Clear" to zero it out — the column is preserved, only its value is reset to `,(0,S.jsx)(`code`,{className:`font-mono`,children:`{}`}),`.`]}),e.rows.map(e=>(0,S.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-[var(--app-border)] bg-black/20 px-3 py-2`,children:[(0,S.jsx)(`span`,{className:`text-sm text-[var(--app-text)]`,children:e.roleName}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>void u(e),disabled:s===e.roleId,children:s===e.roleId?(0,S.jsx)(c,{size:b.sm,className:`animate-spin`}):`Clear`})]},e.roleId))]})]})}function w({onClose:e,onSuccess:t}){let n=(0,x.useRef)(null),[r,a]=(0,x.useState)(!1),[s,l]=(0,x.useState)(!1);async function u(n){if(!n.name.endsWith(`.mcpb`)){g.error(`Only .mcpb files are supported`);return}a(!0);try{let r=await h(n);t(r),g.success(`Installed extension: ${r.name} v${r.version}`),e()}catch(e){let t=e instanceof Error?e.message:`Upload failed`;g.error(t)}finally{a(!1)}}function f(e){let t=e.target.files?.[0];t&&u(t)}function p(e){e.preventDefault(),l(!1);let t=e.dataTransfer.files[0];t&&u(t)}return(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,children:(0,S.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-[var(--app-border)] bg-[var(--app-bg)] p-6 shadow-2xl`,children:[(0,S.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,S.jsx)(`h2`,{className:`text-base font-semibold text-[var(--app-text)]`,children:`Import Extension`}),(0,S.jsx)(`button`,{onClick:e,className:`text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,children:(0,S.jsx)(i,{size:b.lg})})]}),(0,S.jsx)(`div`,{className:`flex min-h-[140px] cursor-pointer flex-col items-center justify-center gap-3 rounded-xl border-2 border-dashed p-6 transition-colors ${s?`border-[var(--app-accent)] bg-[var(--app-accent)]/10`:`border-[var(--app-border)] hover:border-[var(--app-text-subtle)]`}`,onClick:()=>n.current?.click(),onDragOver:e=>{e.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:p,children:r?(0,S.jsx)(c,{size:32,className:`animate-spin text-[var(--app-accent)]`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(o,{size:32,className:`text-[var(--app-text-subtle)]`}),(0,S.jsxs)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:[`Drop a `,(0,S.jsx)(`code`,{className:`font-mono`,children:`.mcpb`}),` file here, or click to browse`]})]})}),(0,S.jsx)(`input`,{ref:n,type:`file`,accept:`.mcpb`,className:`hidden`,onChange:f}),(0,S.jsx)(`div`,{className:`mt-4 flex justify-end gap-2`,children:(0,S.jsx)(d,{variant:`ghost`,onClick:e,disabled:r,children:`Cancel`})})]})})}function T({health:e}){return e?e.lastStatus===`success`?(0,S.jsx)(`span`,{title:`Last ok ${e.lastRunAt?new Date(e.lastRunAt).toLocaleString():``}`,className:`text-green-500 text-sm`,children:`✅`}):(0,S.jsx)(`span`,{title:e.lastError??`Failed`,className:`text-red-500 text-sm`,children:`❌`}):(0,S.jsx)(`span`,{title:`Never run`,className:`text-gray-500 text-sm`,children:`⏳`})}function E({extension:e}){let n=l(),r={};try{r=JSON.parse(e.manifestJson)}catch{}return(0,S.jsx)(_,{className:`cursor-pointer p-4 transition-colors hover:border-[var(--app-accent)]/50`,onClick:()=>n(`/extensions/${e.name}`),children:(0,S.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsx)(`p`,{className:`truncate font-medium text-[var(--app-text)]`,children:e.name}),(0,S.jsxs)(`p`,{className:`mt-0.5 text-xs text-[var(--app-text-subtle)]`,children:[`v`,e.version]}),r.description&&(0,S.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-[var(--app-text-muted)]`,children:r.description})]}),(0,S.jsxs)(`div`,{className:`flex flex-col items-end gap-1 shrink-0`,children:[(0,S.jsx)(T,{health:e.health}),(0,S.jsx)(t,{size:b.md,className:`mt-0.5 text-[var(--app-text-subtle)]`})]})]})})}function D(){let[e,n]=(0,x.useState)([]),[r,i]=(0,x.useState)({count:0,rows:[]}),[a,s]=(0,x.useState)(!0),[l,u]=(0,x.useState)(!1),p=(0,x.useCallback)(async()=>{s(!0);try{let[e,t]=await Promise.all([f(),m()]);n(e),i(t)}catch{g.error(`Failed to load extensions`)}finally{s(!1)}},[]);(0,x.useEffect)(()=>{p()},[p]);function h(e){i(t=>({count:t.count-1,rows:t.rows.filter(t=>t.roleId!==e)}))}function _(e){n(t=>{let n=t.findIndex(t=>t.name===e.name);if(n>=0){let r=[...t];return r[n]=e,r}return[e,...t]})}return(0,S.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,S.jsx)(v,{title:`Extensions`,description:a?`Loading…`:`${e.length} installed`,actions:(0,S.jsxs)(d,{onClick:()=>u(!0),children:[(0,S.jsx)(o,{size:b.md}),`Import`]})}),(0,S.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,S.jsx)(C,{snapshot:r,onClear:h}),a?(0,S.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,S.jsx)(c,{size:24,className:`animate-spin text-[var(--app-text-subtle)]`})}):e.length===0?(0,S.jsx)(y,{icon:(0,S.jsx)(t,{size:32,className:`text-[var(--app-text-subtle)]`}),title:`还没装任何 extension`,description:`Click Import to upload a .mcpb package.`,action:(0,S.jsxs)(d,{onClick:()=>u(!0),children:[(0,S.jsx)(o,{size:b.md}),`Import`]})}):(0,S.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,S.jsx)(E,{extension:e},e.id))})]}),l&&(0,S.jsx)(w,{onClose:()=>u(!1),onSuccess:_})]})}export{D as Extensions};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{xt as t}from"./vendor-icons-Bc_e_XXa.js";import{t as n}from"./vendor-react-bQ_cvNuA.js";import{t as r}from"./Button-CRNb8sD3.js";import{t as i}from"./api-BRfbZQSW.js";import{t as a}from"./index-PIFMZAPo.js";import{t as o}from"./Card-Cwvv0An8.js";import{t as s}from"./SectionHeader-NZWZgoOs.js";import{t as c}from"./EmptyState-BvQA1o5K.js";var l=e(t(),1),u=n(),d={new:`muted`,reviewed:`success`,dismissed:`secondary`,converted:`warning`};function f(e){let t=Date.now()-e;if(Math.floor(t/6e4)<1)return`just now`;let n=Math.floor(t/36e5);return n<24?`${n}h ago`:`${Math.floor(t/864e5)}d ago`}function p(){let[e,t]=(0,l.useState)([]),[n,p]=(0,l.useState)(!0),[m,h]=(0,l.useState)(`all`),[g,_]=(0,l.useState)(null),[v,y]=(0,l.useState)(null),b=(0,l.useCallback)(async()=>{p(!0);try{let e=new URLSearchParams({limit:`200`});m!==`all`&&e.set(`status`,m),t((await i(`/feature-requests?${e}`)).featureRequests)}catch{t([])}finally{p(!1)}},[m]);(0,l.useEffect)(()=>{b()},[b]);let x=async(e,t)=>{y(e);try{await i(`/feature-requests/${e}`,{method:`PATCH`,body:JSON.stringify({status:t})}),await b()}finally{y(null)}};return(0,u.jsxs)(`div`,{className:`space-y-5`,children:[(0,u.jsx)(s,{title:`Feature Requests`,description:`Unmet user needs identified by the Feature Miner role.`,compact:!0,action:(0,u.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>void b(),children:`Refresh`})}),(0,u.jsx)(`div`,{className:`flex gap-2`,children:[`all`,`new`,`reviewed`,`dismissed`,`converted`].map(e=>(0,u.jsx)(`button`,{type:`button`,onClick:()=>h(e),className:`rounded px-3 py-1.5 text-xs font-medium transition-colors ${m===e?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:e===`all`?`All`:e.charAt(0).toUpperCase()+e.slice(1)},e))}),n?(0,u.jsx)(o,{children:(0,u.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)]`,children:`Loading...`})}):e.length===0?(0,u.jsx)(o,{children:(0,u.jsx)(c,{title:`No feature requests`,description:`Run the Feature Mining template to extract unmet needs from chat sessions.`})}):(0,u.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,u.jsxs)(o,{padding:!1,children:[(0,u.jsx)(`div`,{className:`p-4 cursor-pointer hover:bg-black/[0.02]`,onClick:()=>_(g===e.id?null:e.id),role:`button`,tabIndex:0,onKeyDown:t=>{t.key===`Enter`&&_(g===e.id?null:e.id)},children:(0,u.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,u.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(a,{variant:d[e.status],children:e.status}),(0,u.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:f(e.extractedAt)}),e.tags&&e.tags.length>0&&(0,u.jsx)(`div`,{className:`flex gap-1`,children:e.tags.slice(0,3).map(e=>(0,u.jsx)(`span`,{className:`rounded border border-[var(--app-border)] px-1.5 py-0.5 text-[10px] text-[var(--app-text-muted)]`,children:e},e))})]}),e.summary?(0,u.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)]`,children:e.summary}):null,(0,u.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)] line-clamp-2`,children:e.content})]})})}),g===e.id&&(0,u.jsxs)(`div`,{className:`border-t border-[var(--app-border)] p-4 space-y-3`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Content`}),(0,u.jsx)(`p`,{className:`text-sm text-[var(--app-text)]`,children:e.content})]}),e.evidenceQuote&&(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Evidence Quote`}),(0,u.jsx)(`blockquote`,{className:`border-l-2 border-[var(--app-border)] pl-3 text-sm text-[var(--app-text-muted)] italic`,children:e.evidenceQuote})]}),e.tags&&e.tags.length>0&&(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Tags`}),(0,u.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.tags.map(e=>(0,u.jsx)(`span`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-0.5 text-xs text-[var(--app-text)]`,children:e},e))})]}),(0,u.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,u.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Extracted: `,new Date(e.extractedAt).toLocaleString()]}),e.sourceSessionId&&(0,u.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Session: `,e.sourceSessionId.slice(0,8)]})]}),(0,u.jsx)(`div`,{className:`flex gap-2 pt-1`,children:[`new`,`reviewed`,`dismissed`,`converted`].map(t=>(0,u.jsx)(r,{variant:e.status===t?`default`:`ghost`,size:`sm`,disabled:v===e.id||e.status===t,onClick:n=>{n.stopPropagation(),x(e.id,t)},children:t.charAt(0).toUpperCase()+t.slice(1)},t))})]})]},e.id))})]})}export{p as FeatureRequests};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{xt as t}from"./vendor-icons-Bc_e_XXa.js";import{t as n}from"./vendor-react-bQ_cvNuA.js";import{t as r}from"./Button-CRNb8sD3.js";import{t as i}from"./api-BP4ZP9kk.js";import{t as a}from"./index-CXEJd-0s.js";import{t as o}from"./Card-Cwvv0An8.js";import{t as s}from"./SectionHeader-NZWZgoOs.js";import{t as c}from"./EmptyState-BvQA1o5K.js";var l=e(t(),1),u=n(),d={new:`muted`,reviewed:`success`,dismissed:`secondary`,converted:`warning`};function f(e){let t=Date.now()-e;if(Math.floor(t/6e4)<1)return`just now`;let n=Math.floor(t/36e5);return n<24?`${n}h ago`:`${Math.floor(t/864e5)}d ago`}function p(){let[e,t]=(0,l.useState)([]),[n,p]=(0,l.useState)(!0),[m,h]=(0,l.useState)(`all`),[g,_]=(0,l.useState)(null),[v,y]=(0,l.useState)(null),b=(0,l.useCallback)(async()=>{p(!0);try{let e=new URLSearchParams({limit:`200`});m!==`all`&&e.set(`status`,m),t((await i(`/feature-requests?${e}`)).featureRequests)}catch{t([])}finally{p(!1)}},[m]);(0,l.useEffect)(()=>{b()},[b]);let x=async(e,t)=>{y(e);try{await i(`/feature-requests/${e}`,{method:`PATCH`,body:JSON.stringify({status:t})}),await b()}finally{y(null)}};return(0,u.jsxs)(`div`,{className:`space-y-5`,children:[(0,u.jsx)(s,{title:`Feature Requests`,description:`Unmet user needs identified by the Feature Miner role.`,compact:!0,action:(0,u.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>void b(),children:`Refresh`})}),(0,u.jsx)(`div`,{className:`flex gap-2`,children:[`all`,`new`,`reviewed`,`dismissed`,`converted`].map(e=>(0,u.jsx)(`button`,{type:`button`,onClick:()=>h(e),className:`rounded px-3 py-1.5 text-xs font-medium transition-colors ${m===e?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:e===`all`?`All`:e.charAt(0).toUpperCase()+e.slice(1)},e))}),n?(0,u.jsx)(o,{children:(0,u.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)]`,children:`Loading...`})}):e.length===0?(0,u.jsx)(o,{children:(0,u.jsx)(c,{title:`No feature requests`,description:`Run the Feature Mining template to extract unmet needs from chat sessions.`})}):(0,u.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,u.jsxs)(o,{padding:!1,children:[(0,u.jsx)(`div`,{className:`p-4 cursor-pointer hover:bg-black/[0.02]`,onClick:()=>_(g===e.id?null:e.id),role:`button`,tabIndex:0,onKeyDown:t=>{t.key===`Enter`&&_(g===e.id?null:e.id)},children:(0,u.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,u.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(a,{variant:d[e.status],children:e.status}),(0,u.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:f(e.extractedAt)}),e.tags&&e.tags.length>0&&(0,u.jsx)(`div`,{className:`flex gap-1`,children:e.tags.slice(0,3).map(e=>(0,u.jsx)(`span`,{className:`rounded border border-[var(--app-border)] px-1.5 py-0.5 text-[10px] text-[var(--app-text-muted)]`,children:e},e))})]}),e.summary?(0,u.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)]`,children:e.summary}):null,(0,u.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)] line-clamp-2`,children:e.content})]})})}),g===e.id&&(0,u.jsxs)(`div`,{className:`border-t border-[var(--app-border)] p-4 space-y-3`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Content`}),(0,u.jsx)(`p`,{className:`text-sm text-[var(--app-text)]`,children:e.content})]}),e.evidenceQuote&&(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Evidence Quote`}),(0,u.jsx)(`blockquote`,{className:`border-l-2 border-[var(--app-border)] pl-3 text-sm text-[var(--app-text-muted)] italic`,children:e.evidenceQuote})]}),e.tags&&e.tags.length>0&&(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Tags`}),(0,u.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.tags.map(e=>(0,u.jsx)(`span`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-0.5 text-xs text-[var(--app-text)]`,children:e},e))})]}),(0,u.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,u.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Extracted: `,new Date(e.extractedAt).toLocaleString()]}),e.sourceSessionId&&(0,u.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Session: `,e.sourceSessionId.slice(0,8)]})]}),(0,u.jsx)(`div`,{className:`flex gap-2 pt-1`,children:[`new`,`reviewed`,`dismissed`,`converted`].map(t=>(0,u.jsx)(r,{variant:e.status===t?`default`:`ghost`,size:`sm`,disabled:v===e.id||e.status===t,onClick:n=>{n.stopPropagation(),x(e.id,t)},children:t.charAt(0).toUpperCase()+t.slice(1)},t))})]})]},e.id))})]})}export{p as FeatureRequests};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{U as t,at as n,m as r,rt as i,vt as a,xt as o}from"./vendor-icons-Bc_e_XXa.js";import{f as s,r as c,t as l}from"./vendor-react-bQ_cvNuA.js";import{t as u}from"./api-BRfbZQSW.js";import{t as d}from"./index-PIFMZAPo.js";import{a as f,i as p,t as m}from"./Card-Cwvv0An8.js";import{t as h}from"./PageHeader-acLQTYct.js";import{t as g}from"./SectionHeader-NZWZgoOs.js";import{n as _}from"./format-ZWN4JNj-.js";var v=e(o(),1),y=l();function b(){let{id:e}=s(),[o,l]=(0,v.useState)(null),[b,S]=(0,v.useState)([]),[C,w]=(0,v.useState)(null);if((0,v.useEffect)(()=>{e&&(async()=>{try{let t=await u(`/goals/${e}`);l(t.goal),w(null);try{S((await u(`/strategies?role=${t.goal.roleId}`)).strategies??[])}catch{}}catch(e){w(e instanceof Error?e.message:`Failed to load goal`)}})()},[e]),C)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Goals`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-danger)]`,children:C})]});if(!o)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Goals`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let T=o.targetValue>0?Math.min(100,o.currentValue/o.targetValue*100):0,E=o.deadline>0&&o.deadline<Date.now()&&o.status!==`completed`;return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Goals`]}),(0,y.jsx)(h,{eyebrow:`Goal`,title:o.name,compact:!0,description:o.description||`Progress, delivery targets, and strategy support before raw metrics.`,metrics:[{label:`Status`,value:(0,y.jsx)(d,{variant:(e=>e===`completed`?`success`:e===`executing`||e===`evaluating`?`warning`:e===`failed`?`destructive`:`secondary`)(o.status),children:o.status})},{label:`Role`,value:o.roleId},{label:`Metric`,value:o.metricType},{label:`Progress`,value:`${T.toFixed(1)}%`}]}),(0,y.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Goal ID`}),(0,y.jsx)(`p`,{className:`mt-2 truncate font-mono text-sm text-[var(--app-text)]`,children:o.id})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Current delta`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:Math.max(o.targetValue-o.currentValue,0)})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Strategies in play`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:b.length})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Deadline state`}),(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium ${E?`text-[var(--app-danger-soft-text)]`:`text-[var(--app-text)]`}`,children:E?`Overdue`:`On track`})]})]}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,y.jsx)(x,{icon:r,label:`Progress`,value:`${o.currentValue} / ${o.targetValue}`}),(0,y.jsx)(x,{icon:n,label:E?`Overdue`:`Deadline`,value:_(o.deadline),mono:!0}),(0,y.jsx)(x,{icon:i,label:`Budget`,value:`$${o.budgetUsd.toFixed(2)}`}),(0,y.jsx)(x,{icon:t,label:`Created`,value:_(o.createdAt),mono:!0})]}),(0,y.jsx)(g,{title:`Progress`,compact:!0,description:`Completion first, then delivery targets and strategy support.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Progress`})}),(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`flex-1 h-3 rounded-full bg-[var(--app-panel-muted)] overflow-hidden`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full transition-[width] ${E?`bg-[var(--app-danger)]`:`bg-[var(--app-accent)]`}`,style:{width:`${T}%`}})}),(0,y.jsxs)(`span`,{className:`text-sm text-[var(--app-text)] font-mono`,children:[T.toFixed(1),`%`]})]}),(0,y.jsxs)(`div`,{className:`mt-2 flex items-center justify-between text-xs text-[var(--app-text-subtle)]`,children:[(0,y.jsxs)(`span`,{children:[o.currentValue,` current`]}),(0,y.jsxs)(`span`,{children:[o.targetValue,` target`]})]})]}),(o.deliverTo??[]).length>0&&(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Delivery Targets`})}),(0,y.jsx)(`div`,{className:`space-y-1.5`,children:(o.deliverTo??[]).map((e,t)=>(0,y.jsx)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:e.type===`channel`?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d,{variant:`outline`,children:`Channel`}),(0,y.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d,{variant:`outline`,children:`Session`}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Chat session`})]})},t))})]}),b.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(g,{title:`Strategy Support`,compact:!0,description:`Strategy candidates already associated with the goal's role.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,y.jsx)(t,{size:14}),` Strategies (`,b.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>(0,y.jsx)(`div`,{className:`flex items-center justify-between text-sm border-b border-[var(--app-border)] pb-2`,children:(0,y.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,y.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:e.taskType})]})},e.id))})]})]})]})}function x({icon:e,label:t,value:n,mono:r}){return(0,y.jsxs)(m,{className:`flex flex-col gap-1`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[var(--app-text-subtle)]`,children:[(0,y.jsx)(e,{size:12}),(0,y.jsx)(`span`,{className:`text-xs`,children:t})]}),(0,y.jsx)(`span`,{className:`text-sm text-[var(--app-text)] truncate ${r?`font-mono text-xs`:``}`,children:n})]})}export{b as GoalDetail};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{U as t,at as n,m as r,rt as i,vt as a,xt as o}from"./vendor-icons-Bc_e_XXa.js";import{f as s,r as c,t as l}from"./vendor-react-bQ_cvNuA.js";import{t as u}from"./api-BP4ZP9kk.js";import{t as d}from"./index-CXEJd-0s.js";import{a as f,i as p,t as m}from"./Card-Cwvv0An8.js";import{t as h}from"./PageHeader-acLQTYct.js";import{t as g}from"./SectionHeader-NZWZgoOs.js";import{n as _}from"./format-ZWN4JNj-.js";var v=e(o(),1),y=l();function b(){let{id:e}=s(),[o,l]=(0,v.useState)(null),[b,S]=(0,v.useState)([]),[C,w]=(0,v.useState)(null);if((0,v.useEffect)(()=>{e&&(async()=>{try{let t=await u(`/goals/${e}`);l(t.goal),w(null);try{S((await u(`/strategies?role=${t.goal.roleId}`)).strategies??[])}catch{}}catch(e){w(e instanceof Error?e.message:`Failed to load goal`)}})()},[e]),C)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Goals`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-danger)]`,children:C})]});if(!o)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Goals`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let T=o.targetValue>0?Math.min(100,o.currentValue/o.targetValue*100):0,E=o.deadline>0&&o.deadline<Date.now()&&o.status!==`completed`;return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(a,{size:14}),` Back to Goals`]}),(0,y.jsx)(h,{eyebrow:`Goal`,title:o.name,compact:!0,description:o.description||`Progress, delivery targets, and strategy support before raw metrics.`,metrics:[{label:`Status`,value:(0,y.jsx)(d,{variant:(e=>e===`completed`?`success`:e===`executing`||e===`evaluating`?`warning`:e===`failed`?`destructive`:`secondary`)(o.status),children:o.status})},{label:`Role`,value:o.roleId},{label:`Metric`,value:o.metricType},{label:`Progress`,value:`${T.toFixed(1)}%`}]}),(0,y.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Goal ID`}),(0,y.jsx)(`p`,{className:`mt-2 truncate font-mono text-sm text-[var(--app-text)]`,children:o.id})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Current delta`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:Math.max(o.targetValue-o.currentValue,0)})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Strategies in play`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:b.length})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Deadline state`}),(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium ${E?`text-[var(--app-danger-soft-text)]`:`text-[var(--app-text)]`}`,children:E?`Overdue`:`On track`})]})]}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,y.jsx)(x,{icon:r,label:`Progress`,value:`${o.currentValue} / ${o.targetValue}`}),(0,y.jsx)(x,{icon:n,label:E?`Overdue`:`Deadline`,value:_(o.deadline),mono:!0}),(0,y.jsx)(x,{icon:i,label:`Budget`,value:`$${o.budgetUsd.toFixed(2)}`}),(0,y.jsx)(x,{icon:t,label:`Created`,value:_(o.createdAt),mono:!0})]}),(0,y.jsx)(g,{title:`Progress`,compact:!0,description:`Completion first, then delivery targets and strategy support.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Progress`})}),(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`flex-1 h-3 rounded-full bg-[var(--app-panel-muted)] overflow-hidden`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full transition-[width] ${E?`bg-[var(--app-danger)]`:`bg-[var(--app-accent)]`}`,style:{width:`${T}%`}})}),(0,y.jsxs)(`span`,{className:`text-sm text-[var(--app-text)] font-mono`,children:[T.toFixed(1),`%`]})]}),(0,y.jsxs)(`div`,{className:`mt-2 flex items-center justify-between text-xs text-[var(--app-text-subtle)]`,children:[(0,y.jsxs)(`span`,{children:[o.currentValue,` current`]}),(0,y.jsxs)(`span`,{children:[o.targetValue,` target`]})]})]}),(o.deliverTo??[]).length>0&&(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Delivery Targets`})}),(0,y.jsx)(`div`,{className:`space-y-1.5`,children:(o.deliverTo??[]).map((e,t)=>(0,y.jsx)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:e.type===`channel`?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d,{variant:`outline`,children:`Channel`}),(0,y.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d,{variant:`outline`,children:`Session`}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Chat session`})]})},t))})]}),b.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(g,{title:`Strategy Support`,compact:!0,description:`Strategy candidates already associated with the goal's role.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,y.jsx)(t,{size:14}),` Strategies (`,b.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>(0,y.jsx)(`div`,{className:`flex items-center justify-between text-sm border-b border-[var(--app-border)] pb-2`,children:(0,y.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,y.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:e.taskType})]})},e.id))})]})]})]})}function x({icon:e,label:t,value:n,mono:r}){return(0,y.jsxs)(m,{className:`flex flex-col gap-1`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[var(--app-text-subtle)]`,children:[(0,y.jsx)(e,{size:12}),(0,y.jsx)(`span`,{className:`text-xs`,children:t})]}),(0,y.jsx)(`span`,{className:`text-sm text-[var(--app-text)] truncate ${r?`font-mono text-xs`:``}`,children:n})]})}export{b as GoalDetail};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{A as t,D as n,M as r,j as i,l as a,m as o,n as s,w as c,xt as l}from"./vendor-icons-Bc_e_XXa.js";import{t as u}from"./vendor-react-bQ_cvNuA.js";import"./es2015-BkFSNOYE.js";import{t as d}from"./Button-CRNb8sD3.js";import{t as f}from"./api-BRfbZQSW.js";import{a as p,c as m,d as h,f as g,i as _,l as v,n as ee,o as y,p as b,r as x,s as S,t as C,u as te}from"./index-PIFMZAPo.js";import{a as ne,i as re,t as w}from"./Card-Cwvv0An8.js";import{t as T}from"./PageHeader-acLQTYct.js";import{n as E,t as D}from"./format-ZWN4JNj-.js";import{t as O}from"./EmptyState-BvQA1o5K.js";var k=e(l(),1),A=u();function j({value:e,onChange:t,label:n=`Delivery Targets`}){let[r,i]=(0,k.useState)([]),[a,o]=(0,k.useState)(!1);(0,k.useEffect)(()=>{let e=!1;return Promise.all([f(`/channels`).catch(()=>({channels:[]})),f(`/chat/sessions`).catch(()=>({sessions:[]}))]).then(([t,n])=>{if(e)return;let r=new Map(t.channels.map(e=>[e.id,e])),a=[];for(let e of n.sessions)if(e.source.type===`channel`&&e.source.channelId&&e.source.chatId){let t=r.get(e.source.channelId);a.push({id:e.id,channelId:e.source.channelId,channelName:t?.name??e.source.channelId.slice(0,8),platform:t?.platform??`unknown`,chatId:e.source.chatId})}for(let e of t.channels)e.enabled&&e.platform===`email`&&typeof e.config.address==`string`&&a.push({id:`email:${e.id}`,channelId:e.id,channelName:e.name,platform:e.platform,chatId:e.config.address});let o=new Set;i(a.filter(e=>{let t=`${e.channelId}:${e.chatId}`;return o.has(t)?!1:(o.add(t),!0)}))}),()=>{e=!0}},[]);let s=(t,n)=>e.some(e=>e.type===`channel`&&e.channelId===t&&e.chatId===n),c=(n,r)=>{s(n,r)?t(e.filter(e=>!(e.type===`channel`&&e.channelId===n&&e.chatId===r))):t([...e,{type:`channel`,channelId:n,chatId:r}])},l=e.filter(e=>e.type===`channel`).length;return(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:n}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!a),className:`mt-1 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-left text-sm text-[var(--app-text)] hover:border-[var(--app-border-strong)] focus:border-[var(--app-accent)] focus:outline-none`,children:l===0?`Default (current session)`:`${l} channel${l>1?`s`:``} selected`}),a&&(0,A.jsxs)(`div`,{className:`absolute z-10 mt-1 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] py-1 shadow-lg`,children:[r.length===0?(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-[var(--app-text-subtle)]`,children:`No channel delivery targets available.`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`px-3 py-1 text-xs text-[var(--app-text-subtle)]`,children:`Channel conversations`}),r.map(e=>(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 px-3 py-1.5 text-xs text-[var(--app-text)] hover:bg-[var(--app-panel-muted)]`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:s(e.channelId,e.chatId),onChange:()=>c(e.channelId,e.chatId),className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-muted)]`}),(0,A.jsx)(`span`,{className:`truncate font-medium`,children:e.channelName}),(0,A.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`(`,e.platform,`)`]})]},`${e.channelId}:${e.chatId}`))]}),l>0&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>{t([]),o(!1)},className:`mt-1 w-full border-t border-[var(--app-border)] px-3 py-1 text-left text-xs text-[var(--app-danger)] hover:bg-[var(--app-panel-muted)]`,children:`Clear all`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`w-full border-t border-[var(--app-border)] px-3 py-1 text-left text-xs text-[var(--app-text-subtle)] hover:bg-[var(--app-panel-muted)]`,children:`Done`})]})]})}var M={active:`paused`,paused:`active`,completed:`active`,failed:`active`},N={active:(0,A.jsx)(r,{size:12}),paused:(0,A.jsx)(t,{size:12}),completed:(0,A.jsx)(c,{size:12}),failed:(0,A.jsx)(c,{size:12})};function P(){let e=g(e=>e.goals),r=g(e=>e.fetchGoals),l=g(e=>e.updateGoal),u=g(e=>e.deleteGoal),[P,F]=(0,k.useState)(!1),[I,L]=(0,k.useState)(``),[R,z]=(0,k.useState)(!1),[B,V]=(0,k.useState)(null),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(``),[K,q]=(0,k.useState)(``),[J,Y]=(0,k.useState)([]),[X,Z]=(0,k.useState)([]),[Q,ie]=(0,k.useState)([]),[$,ae]=(0,k.useState)([]),oe=e.filter(e=>e.status===`active`).length,se=e.filter(e=>e.status===`paused`).length,ce=e.filter(e=>e.status===`completed`).length;(0,k.useEffect)(()=>{r();let e=setInterval(()=>void r(),1e4);return()=>clearInterval(e)},[r]);let le=async()=>{if(I.trim()){z(!0),V(null);try{await f(`/goals`,{method:`POST`,body:JSON.stringify({input:I.trim(),deliverTo:Q.length>0?Q:void 0,reportTo:$.length>0?$:void 0})}),L(``),F(!1),r()}catch(e){V(e instanceof Error?e.message:`Failed to create goal`)}finally{z(!1)}}};return(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsx)(T,{eyebrow:`Operations`,title:`Goals`,compact:!0,description:`Long-running outcomes, budgets, and delivery targets.`,metrics:[{label:`Active`,value:oe},{label:`Paused`,value:se},{label:`Completed`,value:ce}],actions:(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>void r(),children:(0,A.jsx)(c,{size:14})}),(0,A.jsxs)(d,{size:`sm`,onClick:()=>F(!P),children:[(0,A.jsx)(n,{size:14}),`New Goal`]})]})}),P&&(0,A.jsxs)(w,{className:`space-y-3`,children:[(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Describe your goal in natural language...`,rows:3,value:I,onChange:e=>L(e.target.value)}),(0,A.jsx)(j,{value:Q,onChange:ie,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:$,onChange:ae,label:`Report To (status)`}),B&&(0,A.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:B}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(d,{onClick:()=>void le(),disabled:R||!I.trim(),children:R?`Creating...`:`Create`}),(0,A.jsx)(d,{variant:`ghost`,onClick:()=>F(!1),children:`Cancel`})]})]}),e.length===0?(0,A.jsx)(O,{icon:(0,A.jsx)(o,{size:32}),title:`No goals`,description:`Create a goal to start goal-driven task orchestration`}):(0,A.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>{let n=e.targetValue>0?Math.min(100,Math.round(e.currentValue/e.targetValue*100)):0,r=new Date(e.deadline).getTime()<Date.now()&&e.status!==`completed`,o=H===e.id;return(0,A.jsxs)(w,{children:[(0,A.jsxs)(re,{children:[o?(0,A.jsx)(`input`,{className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:W,onChange:e=>G(e.target.value),autoFocus:!0}):(0,A.jsx)(ne,{className:`max-w-full text-[var(--app-text)] text-sm font-medium truncate sm:max-w-[180px]`,children:e.name}),(0,A.jsx)(C,{variant:ee(e.status),children:e.status})]}),o?(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-xs text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none mb-3`,placeholder:`Description...`,rows:2,value:K,onChange:e=>q(e.target.value)}):e.description?(0,A.jsx)(`p`,{className:`text-xs text-[var(--app-text-muted)] mb-3 line-clamp-2`,children:e.description}):null,o&&(0,A.jsxs)(`div`,{className:`mb-3 space-y-2`,children:[(0,A.jsx)(j,{value:J,onChange:Y,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:X,onChange:Z,label:`Report To (status)`})]}),(0,A.jsxs)(`div`,{className:`mb-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,A.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Progress`}),(0,A.jsxs)(`span`,{className:`font-mono text-xs text-[var(--app-text)]`,children:[n,`%`]})]}),(0,A.jsx)(`div`,{className:`h-1.5 rounded-full bg-[var(--app-panel-elevated)]`,children:(0,A.jsx)(`div`,{className:`h-full rounded-full transition-[width] ${n>=100?`bg-[var(--app-success)]`:`bg-[var(--app-accent)]`}`,style:{width:`${n}%`}})}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between mt-1`,children:[(0,A.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--app-text-subtle)]`,children:[e.currentValue,` / `,e.targetValue]}),(0,A.jsx)(`span`,{className:`font-mono text-[10px] text-[var(--app-text-subtle)]`,children:e.metricType})]})]}),(0,A.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Role`}),(0,A.jsx)(C,{variant:`muted`,className:`text-[10px]`,children:e.roleId})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Budget`}),(0,A.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:D(e.budgetUsd)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)] ${r?`text-[var(--app-danger)]`:``}`,children:`Deadline`}),(0,A.jsx)(`span`,{className:`text-[var(--app-text)] ${r?`text-[var(--app-danger)]`:``}`,children:E(e.deadline)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Created`}),(0,A.jsx)(`span`,{className:`text-[var(--app-text-muted)]`,children:E(e.createdAt)})]})]}),(0,A.jsx)(`div`,{className:`flex items-center gap-1 mt-3 pt-3 border-t border-[var(--app-border)]`,children:o?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(d,{size:`sm`,variant:`ghost`,onClick:async()=>{try{await l(e.id,{name:W,description:K,deliverTo:J,reportTo:X}),U(null),b.success(`Goal updated`)}catch(e){b.error(e instanceof Error?e.message:`Failed to update`)}},children:`Save`}),(0,A.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>U(null),children:(0,A.jsx)(s,{size:14})})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(d,{size:`sm`,variant:`ghost`,title:`Edit`,onClick:()=>{U(e.id),G(e.name),q(e.description??``),Y(e.deliverTo??[]),Z(e.reportTo??[])},children:(0,A.jsx)(i,{size:14})}),(0,A.jsxs)(d,{size:`sm`,variant:`ghost`,title:`Change to ${M[e.status]}`,onClick:async()=>{try{await l(e.id,{status:M[e.status]}),b.success(`Status changed to ${M[e.status]}`)}catch(e){b.error(e instanceof Error?e.message:`Failed to update status`)}},children:[N[e.status]??(0,A.jsx)(t,{size:12}),(0,A.jsx)(`span`,{className:`text-xs`,children:M[e.status]})]}),(0,A.jsx)(`div`,{className:`ml-auto`,children:(0,A.jsxs)(x,{children:[(0,A.jsx)(h,{asChild:!0,children:(0,A.jsx)(d,{size:`sm`,variant:`ghost`,title:`Delete`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,children:(0,A.jsx)(a,{size:14})})}),(0,A.jsxs)(y,{children:[(0,A.jsxs)(v,{children:[(0,A.jsx)(te,{children:`Delete goal`}),(0,A.jsxs)(S,{children:[`This will permanently delete "`,e.name,`". This action cannot be undone.`]})]}),(0,A.jsxs)(m,{children:[(0,A.jsx)(p,{children:`Cancel`}),(0,A.jsx)(_,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger-strong)]`,onClick:async()=>{try{await u(e.id),b.success(`Goal deleted`)}catch(e){b.error(e instanceof Error?e.message:`Failed to delete`)}},children:`Delete`})]})]})]})})]})})]},e.id)})})]})}export{P as Goals,j as t};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{A as t,D as n,M as r,j as i,l as a,m as o,n as s,w as c,xt as l}from"./vendor-icons-Bc_e_XXa.js";import{t as u}from"./vendor-react-bQ_cvNuA.js";import"./es2015-BkFSNOYE.js";import{t as d}from"./Button-CRNb8sD3.js";import{t as f}from"./api-BP4ZP9kk.js";import{a as p,c as m,d as h,f as g,i as _,l as v,n as ee,o as y,p as b,r as x,s as S,t as C,u as te}from"./index-CXEJd-0s.js";import{a as ne,i as re,t as w}from"./Card-Cwvv0An8.js";import{t as T}from"./PageHeader-acLQTYct.js";import{n as E,t as D}from"./format-ZWN4JNj-.js";import{t as O}from"./EmptyState-BvQA1o5K.js";var k=e(l(),1),A=u();function j({value:e,onChange:t,label:n=`Delivery Targets`}){let[r,i]=(0,k.useState)([]),[a,o]=(0,k.useState)(!1);(0,k.useEffect)(()=>{let e=!1;return Promise.all([f(`/channels`).catch(()=>({channels:[]})),f(`/chat/sessions`).catch(()=>({sessions:[]}))]).then(([t,n])=>{if(e)return;let r=new Map(t.channels.map(e=>[e.id,e])),a=[];for(let e of n.sessions)if(e.source.type===`channel`&&e.source.channelId&&e.source.chatId){let t=r.get(e.source.channelId);a.push({id:e.id,channelId:e.source.channelId,channelName:t?.name??e.source.channelId.slice(0,8),platform:t?.platform??`unknown`,chatId:e.source.chatId})}for(let e of t.channels)e.enabled&&e.platform===`email`&&typeof e.config.address==`string`&&a.push({id:`email:${e.id}`,channelId:e.id,channelName:e.name,platform:e.platform,chatId:e.config.address});let o=new Set;i(a.filter(e=>{let t=`${e.channelId}:${e.chatId}`;return o.has(t)?!1:(o.add(t),!0)}))}),()=>{e=!0}},[]);let s=(t,n)=>e.some(e=>e.type===`channel`&&e.channelId===t&&e.chatId===n),c=(n,r)=>{s(n,r)?t(e.filter(e=>!(e.type===`channel`&&e.channelId===n&&e.chatId===r))):t([...e,{type:`channel`,channelId:n,chatId:r}])},l=e.filter(e=>e.type===`channel`).length;return(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:n}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!a),className:`mt-1 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-left text-sm text-[var(--app-text)] hover:border-[var(--app-border-strong)] focus:border-[var(--app-accent)] focus:outline-none`,children:l===0?`Default (current session)`:`${l} channel${l>1?`s`:``} selected`}),a&&(0,A.jsxs)(`div`,{className:`absolute z-10 mt-1 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] py-1 shadow-lg`,children:[r.length===0?(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-[var(--app-text-subtle)]`,children:`No channel delivery targets available.`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`px-3 py-1 text-xs text-[var(--app-text-subtle)]`,children:`Channel conversations`}),r.map(e=>(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 px-3 py-1.5 text-xs text-[var(--app-text)] hover:bg-[var(--app-panel-muted)]`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:s(e.channelId,e.chatId),onChange:()=>c(e.channelId,e.chatId),className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-muted)]`}),(0,A.jsx)(`span`,{className:`truncate font-medium`,children:e.channelName}),(0,A.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`(`,e.platform,`)`]})]},`${e.channelId}:${e.chatId}`))]}),l>0&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>{t([]),o(!1)},className:`mt-1 w-full border-t border-[var(--app-border)] px-3 py-1 text-left text-xs text-[var(--app-danger)] hover:bg-[var(--app-panel-muted)]`,children:`Clear all`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`w-full border-t border-[var(--app-border)] px-3 py-1 text-left text-xs text-[var(--app-text-subtle)] hover:bg-[var(--app-panel-muted)]`,children:`Done`})]})]})}var M={active:`paused`,paused:`active`,completed:`active`,failed:`active`},N={active:(0,A.jsx)(r,{size:12}),paused:(0,A.jsx)(t,{size:12}),completed:(0,A.jsx)(c,{size:12}),failed:(0,A.jsx)(c,{size:12})};function P(){let e=g(e=>e.goals),r=g(e=>e.fetchGoals),l=g(e=>e.updateGoal),u=g(e=>e.deleteGoal),[P,F]=(0,k.useState)(!1),[I,L]=(0,k.useState)(``),[R,z]=(0,k.useState)(!1),[B,V]=(0,k.useState)(null),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(``),[K,q]=(0,k.useState)(``),[J,Y]=(0,k.useState)([]),[X,Z]=(0,k.useState)([]),[Q,ie]=(0,k.useState)([]),[$,ae]=(0,k.useState)([]),oe=e.filter(e=>e.status===`active`).length,se=e.filter(e=>e.status===`paused`).length,ce=e.filter(e=>e.status===`completed`).length;(0,k.useEffect)(()=>{r();let e=setInterval(()=>void r(),1e4);return()=>clearInterval(e)},[r]);let le=async()=>{if(I.trim()){z(!0),V(null);try{await f(`/goals`,{method:`POST`,body:JSON.stringify({input:I.trim(),deliverTo:Q.length>0?Q:void 0,reportTo:$.length>0?$:void 0})}),L(``),F(!1),r()}catch(e){V(e instanceof Error?e.message:`Failed to create goal`)}finally{z(!1)}}};return(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsx)(T,{eyebrow:`Operations`,title:`Goals`,compact:!0,description:`Long-running outcomes, budgets, and delivery targets.`,metrics:[{label:`Active`,value:oe},{label:`Paused`,value:se},{label:`Completed`,value:ce}],actions:(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>void r(),children:(0,A.jsx)(c,{size:14})}),(0,A.jsxs)(d,{size:`sm`,onClick:()=>F(!P),children:[(0,A.jsx)(n,{size:14}),`New Goal`]})]})}),P&&(0,A.jsxs)(w,{className:`space-y-3`,children:[(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Describe your goal in natural language...`,rows:3,value:I,onChange:e=>L(e.target.value)}),(0,A.jsx)(j,{value:Q,onChange:ie,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:$,onChange:ae,label:`Report To (status)`}),B&&(0,A.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:B}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(d,{onClick:()=>void le(),disabled:R||!I.trim(),children:R?`Creating...`:`Create`}),(0,A.jsx)(d,{variant:`ghost`,onClick:()=>F(!1),children:`Cancel`})]})]}),e.length===0?(0,A.jsx)(O,{icon:(0,A.jsx)(o,{size:32}),title:`No goals`,description:`Create a goal to start goal-driven task orchestration`}):(0,A.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>{let n=e.targetValue>0?Math.min(100,Math.round(e.currentValue/e.targetValue*100)):0,r=new Date(e.deadline).getTime()<Date.now()&&e.status!==`completed`,o=H===e.id;return(0,A.jsxs)(w,{children:[(0,A.jsxs)(re,{children:[o?(0,A.jsx)(`input`,{className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:W,onChange:e=>G(e.target.value),autoFocus:!0}):(0,A.jsx)(ne,{className:`max-w-full text-[var(--app-text)] text-sm font-medium truncate sm:max-w-[180px]`,children:e.name}),(0,A.jsx)(C,{variant:ee(e.status),children:e.status})]}),o?(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-xs text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none mb-3`,placeholder:`Description...`,rows:2,value:K,onChange:e=>q(e.target.value)}):e.description?(0,A.jsx)(`p`,{className:`text-xs text-[var(--app-text-muted)] mb-3 line-clamp-2`,children:e.description}):null,o&&(0,A.jsxs)(`div`,{className:`mb-3 space-y-2`,children:[(0,A.jsx)(j,{value:J,onChange:Y,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:X,onChange:Z,label:`Report To (status)`})]}),(0,A.jsxs)(`div`,{className:`mb-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,A.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Progress`}),(0,A.jsxs)(`span`,{className:`font-mono text-xs text-[var(--app-text)]`,children:[n,`%`]})]}),(0,A.jsx)(`div`,{className:`h-1.5 rounded-full bg-[var(--app-panel-elevated)]`,children:(0,A.jsx)(`div`,{className:`h-full rounded-full transition-[width] ${n>=100?`bg-[var(--app-success)]`:`bg-[var(--app-accent)]`}`,style:{width:`${n}%`}})}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between mt-1`,children:[(0,A.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--app-text-subtle)]`,children:[e.currentValue,` / `,e.targetValue]}),(0,A.jsx)(`span`,{className:`font-mono text-[10px] text-[var(--app-text-subtle)]`,children:e.metricType})]})]}),(0,A.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Role`}),(0,A.jsx)(C,{variant:`muted`,className:`text-[10px]`,children:e.roleId})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Budget`}),(0,A.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:D(e.budgetUsd)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)] ${r?`text-[var(--app-danger)]`:``}`,children:`Deadline`}),(0,A.jsx)(`span`,{className:`text-[var(--app-text)] ${r?`text-[var(--app-danger)]`:``}`,children:E(e.deadline)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Created`}),(0,A.jsx)(`span`,{className:`text-[var(--app-text-muted)]`,children:E(e.createdAt)})]})]}),(0,A.jsx)(`div`,{className:`flex items-center gap-1 mt-3 pt-3 border-t border-[var(--app-border)]`,children:o?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(d,{size:`sm`,variant:`ghost`,onClick:async()=>{try{await l(e.id,{name:W,description:K,deliverTo:J,reportTo:X}),U(null),b.success(`Goal updated`)}catch(e){b.error(e instanceof Error?e.message:`Failed to update`)}},children:`Save`}),(0,A.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>U(null),children:(0,A.jsx)(s,{size:14})})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(d,{size:`sm`,variant:`ghost`,title:`Edit`,onClick:()=>{U(e.id),G(e.name),q(e.description??``),Y(e.deliverTo??[]),Z(e.reportTo??[])},children:(0,A.jsx)(i,{size:14})}),(0,A.jsxs)(d,{size:`sm`,variant:`ghost`,title:`Change to ${M[e.status]}`,onClick:async()=>{try{await l(e.id,{status:M[e.status]}),b.success(`Status changed to ${M[e.status]}`)}catch(e){b.error(e instanceof Error?e.message:`Failed to update status`)}},children:[N[e.status]??(0,A.jsx)(t,{size:12}),(0,A.jsx)(`span`,{className:`text-xs`,children:M[e.status]})]}),(0,A.jsx)(`div`,{className:`ml-auto`,children:(0,A.jsxs)(x,{children:[(0,A.jsx)(h,{asChild:!0,children:(0,A.jsx)(d,{size:`sm`,variant:`ghost`,title:`Delete`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,children:(0,A.jsx)(a,{size:14})})}),(0,A.jsxs)(y,{children:[(0,A.jsxs)(v,{children:[(0,A.jsx)(te,{children:`Delete goal`}),(0,A.jsxs)(S,{children:[`This will permanently delete "`,e.name,`". This action cannot be undone.`]})]}),(0,A.jsxs)(m,{children:[(0,A.jsx)(p,{children:`Cancel`}),(0,A.jsx)(_,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger-strong)]`,onClick:async()=>{try{await u(e.id),b.success(`Goal deleted`)}catch(e){b.error(e instanceof Error?e.message:`Failed to delete`)}},children:`Delete`})]})]})]})})]})})]},e.id)})})]})}export{P as Goals,j as t};