adam-agent-server 1.18.0 → 1.19.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 (131) hide show
  1. package/dist/{App-SIQUVFJY.js → App-522DTURQ.js} +10 -10
  2. package/dist/approval-handler-S3NV7OPO.js +1 -0
  3. package/dist/{artifacts-MAYKOTA2.js → artifacts-NFMM3ORE.js} +1 -1
  4. package/dist/audit-diagnostics-IHU3CJYZ.js +1 -0
  5. package/dist/audit-manager-MUMEEP3C.js +1 -0
  6. package/dist/bree-engine-EEKUQA3U.js +1 -0
  7. package/dist/channels-IDBWHLLE.js +1 -0
  8. package/dist/{channels-2TWTBE6Y.js → channels-ZHCTFSDA.js} +1 -1
  9. package/dist/chat-tool-calls-4BQWZCJH.js +1 -0
  10. package/dist/{chunk-Z2APBKIT.js → chunk-2JM3URDG.js} +1 -1
  11. package/dist/{chunk-OBD4245G.js → chunk-4G4CKAXY.js} +1 -1
  12. package/dist/{chunk-2CE2WUUZ.js → chunk-4ZESWP3J.js} +1 -1
  13. package/dist/{chunk-QYI44EP6.js → chunk-4ZG4UMAK.js} +1 -1
  14. package/dist/{chunk-BE653A45.js → chunk-6GYNUTPP.js} +1 -1
  15. package/dist/{chunk-JROGEBP5.js → chunk-76MMY2XC.js} +1 -1
  16. package/dist/{chunk-BMCNQGUH.js → chunk-7QT2ZX3K.js} +1 -1
  17. package/dist/{chunk-SGLZAIVL.js → chunk-A3YUIWLK.js} +1 -1
  18. package/dist/{chunk-HL373H4P.js → chunk-AMJJ2WGU.js} +1 -1
  19. package/dist/{chunk-NUOTFUNF.js → chunk-CN5NEJXG.js} +1 -1
  20. package/dist/{chunk-O6L4UVLV.js → chunk-DFTRUOT6.js} +1 -1
  21. package/dist/{chunk-JYZTIE2J.js → chunk-DRS5NOAA.js} +1 -1
  22. package/dist/{chunk-6WQFYV3N.js → chunk-EBZCHLYS.js} +1 -1
  23. package/dist/{chunk-SKHMWKJT.js → chunk-EPLSB63A.js} +1 -1
  24. package/dist/{chunk-V2MMQ3SH.js → chunk-FN64ZULV.js} +1 -1
  25. package/dist/chunk-FQHGIY3E.js +1 -0
  26. package/dist/{chunk-NSUXJ2VA.js → chunk-GQS3ED3B.js} +1 -1
  27. package/dist/{chunk-LKGYQJMS.js → chunk-HEHST2E2.js} +1 -1
  28. package/dist/chunk-IAGTZGGV.js +32 -0
  29. package/dist/chunk-ITVCPC7G.js +1 -0
  30. package/dist/{chunk-NXGR3PRY.js → chunk-J2VSAXVU.js} +1 -1
  31. package/dist/{chunk-5G64P4KE.js → chunk-JRRNGKDK.js} +1 -1
  32. package/dist/{chunk-KS24764D.js → chunk-JVYSSJKT.js} +2 -2
  33. package/dist/chunk-JXZCQ5XW.js +1 -0
  34. package/dist/{chunk-LCD5DVS6.js → chunk-KM4EFB4N.js} +1 -1
  35. package/dist/chunk-KQMKRRYW.js +143 -0
  36. package/dist/{chunk-4JHACUZY.js → chunk-L4APYD5A.js} +1 -1
  37. package/dist/{chunk-WY5BOCQP.js → chunk-LMQPGVM7.js} +16 -16
  38. package/dist/chunk-MMVDXKYS.js +14 -0
  39. package/dist/chunk-NKS7LEA7.js +182 -0
  40. package/dist/{chunk-VWX2B6OM.js → chunk-ORFLN4BF.js} +1 -1
  41. package/dist/{chunk-2JIQT2CI.js → chunk-PO66F7UQ.js} +1 -1
  42. package/dist/{chunk-XAPJJAJQ.js → chunk-QJXV4SQE.js} +1 -1
  43. package/dist/{chunk-UCUELFCS.js → chunk-R7Q6FSV4.js} +1 -1
  44. package/dist/{chunk-47HJPIUA.js → chunk-T7EKW3B7.js} +1 -1
  45. package/dist/{chunk-JZBXLN7M.js → chunk-VOH52UDS.js} +1 -1
  46. package/dist/{chunk-HRPMRWHD.js → chunk-VZL2DGC4.js} +1 -1
  47. package/dist/{chunk-IEBAOZED.js → chunk-WDMSZS4W.js} +1 -1
  48. package/dist/{chunk-2A2TXYT3.js → chunk-WG3C43QS.js} +3 -3
  49. package/dist/{chunk-TA5PFK5C.js → chunk-YEGUFMLJ.js} +1 -1
  50. package/dist/{chunk-ZQN6JZIJ.js → chunk-ZGA52HRD.js} +1 -1
  51. package/dist/cli.js +2 -2
  52. package/dist/{config-U624HJKI.js → config-GOJLI3X2.js} +1 -1
  53. package/dist/config-Z6KFEFJO.js +1 -0
  54. package/dist/db-ROXIYW5B.js +1 -0
  55. package/dist/{delivery-log-QMQQHES4.js → delivery-log-TGJZ5HU7.js} +1 -1
  56. package/dist/engine-GN7PJPGQ.js +1 -0
  57. package/dist/{evolution-audit-XF4KZZMP.js → evolution-audit-TFJF666X.js} +1 -1
  58. package/dist/execution-tools-BQD2O25X.js +1 -0
  59. package/dist/{external-api-435WH6V3.js → external-api-DSLQDRZ2.js} +1 -1
  60. package/dist/index.js +41 -39
  61. package/dist/{learner-4CJ7BSCN.js → learner-ACBX3GI7.js} +1 -1
  62. package/dist/{memories-NJFKSOL5.js → memories-RAIR5O2F.js} +1 -1
  63. package/dist/{memory-extractor-UQI75BBK.js → memory-extractor-A6CAOFOX.js} +1 -1
  64. package/dist/{memory-gc-NTZVUGJX.js → memory-gc-W63MGSDH.js} +1 -1
  65. package/dist/memory-service-H4OFUNCF.js +1 -0
  66. package/dist/outbound-gateway-LKRQYPA2.js +1 -0
  67. package/dist/presets-FO6RSGDN.js +1 -0
  68. package/dist/{reflection-job-F4BZA2E3.js → reflection-job-XC2F7GTT.js} +1 -1
  69. package/dist/role-presets-SDA664QG.js +1 -0
  70. package/dist/role-workspace-NGJEJG3H.js +1 -0
  71. package/dist/{roles-WDMUBWQP.js → roles-LZCJ7QFS.js} +1 -1
  72. package/dist/{session-manager-XFUKWEC7.js → session-manager-PU4GH3E4.js} +1 -1
  73. package/dist/skill-registry-XKLE2LXU.js +1 -0
  74. package/dist/{task-templates-BIVCRNXA.js → task-templates-52LAC6OA.js} +1 -1
  75. package/dist/template-dispatch-PJFSWEO2.js +1 -0
  76. package/package.json +1 -1
  77. package/web/dist/assets/{ChannelDetail-D0FBZoAX.js → ChannelDetail-CSq9o5fq.js} +1 -1
  78. package/web/dist/assets/{Channels-Cztxvsa2.js → Channels-CAxTh1Bp.js} +1 -1
  79. package/web/dist/assets/Chat-PUz41HFr.js +2 -0
  80. package/web/dist/assets/{Cost-K8-4xqBe.js → Cost-BHcsPz5T.js} +1 -1
  81. package/web/dist/assets/{Dashboard-BXqFb_Vr.js → Dashboard-BT39_iWc.js} +1 -1
  82. package/web/dist/assets/{EnvVarEditor-FiiJazzp.js → EnvVarEditor-D_1d7bTJ.js} +1 -1
  83. package/web/dist/assets/{EventDefDetail-C3S1G0K8.js → EventDefDetail-jKN3gO_7.js} +1 -1
  84. package/web/dist/assets/{Events-BKxqZ9j6.js → Events-CpeHg3fh.js} +1 -1
  85. package/web/dist/assets/{Evolution-DFcSm6Rw.js → Evolution-DsWyv2_a.js} +1 -1
  86. package/web/dist/assets/{ExtensionDetail-C8aPpyLv.js → ExtensionDetail-CJHNaNii.js} +1 -1
  87. package/web/dist/assets/{Extensions-MLZk05j0.js → Extensions-Pg2vx_ZK.js} +1 -1
  88. package/web/dist/assets/{FeatureRequests-D_4XaQ7F.js → FeatureRequests-3Yl8wTNT.js} +1 -1
  89. package/web/dist/assets/{GoalDetail-DVU7c0aR.js → GoalDetail-L3T1zqqs.js} +1 -1
  90. package/web/dist/assets/{Goals-D3h4WMjU.js → Goals-B-__r-Yq.js} +1 -1
  91. package/web/dist/assets/{Logs-D5MQv6Yw.js → Logs-CMkjUkmu.js} +1 -1
  92. package/web/dist/assets/{Memories-Dls71I2i.js → Memories-Q1eKfPQ2.js} +1 -1
  93. package/web/dist/assets/{Mistakes-BZcTg0vP.js → Mistakes-BROkixt_.js} +1 -1
  94. package/web/dist/assets/{Plugins-CwCHGzI6.js → Plugins-v17MyPVe.js} +1 -1
  95. package/web/dist/assets/{RoleDetail-B2M6ALSl.js → RoleDetail-DCGFBLP1.js} +2 -2
  96. package/web/dist/assets/{Roles-FEHqm_Jf.js → Roles-C7SNebvY.js} +1 -1
  97. package/web/dist/assets/{Settings-rdVQMfqX.js → Settings-QuKwKbKg.js} +1 -1
  98. package/web/dist/assets/{Strategies-CwJ9JQ-X.js → Strategies-CXQYvCkc.js} +1 -1
  99. package/web/dist/assets/{Switch-1JjR4Imr.js → Switch--h1rqagh.js} +1 -1
  100. package/web/dist/assets/{TaskDetail-h12WxjfG.js → TaskDetail-B0G5ZjDD.js} +1 -1
  101. package/web/dist/assets/{Work-CfzFRSZX.js → Work-DbFst_9-.js} +1 -1
  102. package/web/dist/assets/index-D35OGE0z.css +2 -0
  103. package/web/dist/assets/{index-CXEJd-0s.js → index-Dd3NDYZR.js} +2 -2
  104. package/web/dist/assets/{usePluginsWithUsage-4iLJAPjH.js → usePluginsWithUsage-DpTxJuFQ.js} +1 -1
  105. package/web/dist/index.html +2 -2
  106. package/dist/approval-handler-BWA7UIKN.js +0 -1
  107. package/dist/audit-diagnostics-K3LUWXTI.js +0 -1
  108. package/dist/audit-manager-6WL2V6JG.js +0 -1
  109. package/dist/bree-engine-KYD4GKQK.js +0 -1
  110. package/dist/channels-PWDSTYNR.js +0 -1
  111. package/dist/chat-tool-calls-WJDFQ54U.js +0 -1
  112. package/dist/chunk-3UFEOB6P.js +0 -143
  113. package/dist/chunk-MTRLUW7Z.js +0 -1
  114. package/dist/chunk-QTGAK62Z.js +0 -14
  115. package/dist/chunk-TWOJVEO7.js +0 -32
  116. package/dist/chunk-VO24C673.js +0 -1
  117. package/dist/chunk-VPMHZJS2.js +0 -1
  118. package/dist/chunk-ZJ3TS4FL.js +0 -182
  119. package/dist/config-X7A6NA73.js +0 -1
  120. package/dist/db-XODNIJSJ.js +0 -1
  121. package/dist/engine-OQXDHA2R.js +0 -1
  122. package/dist/execution-tools-BR4T4MMW.js +0 -1
  123. package/dist/memory-service-3RLVOF2C.js +0 -1
  124. package/dist/outbound-gateway-NJNSN2ZX.js +0 -1
  125. package/dist/presets-SUJRFRJC.js +0 -1
  126. package/dist/role-presets-VEYTGYA4.js +0 -1
  127. package/dist/role-workspace-AIVHPX5P.js +0 -1
  128. package/dist/skill-registry-LARMNUT5.js +0 -1
  129. package/dist/template-dispatch-6FPJQN6A.js +0 -1
  130. package/web/dist/assets/Chat-Ce72TtUi.js +0 -2
  131. package/web/dist/assets/index-CarTGiGO.css +0 -2
@@ -1 +1 @@
1
- import{d as c,e as S,f as $,g as P}from"./chunk-XAPJJAJQ.js";import{b as R}from"./chunk-Z2APBKIT.js";import{e as T,g as D,i as N}from"./chunk-NSUXJ2VA.js";import{D as x,F as k,L,b as f,p as E}from"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import{c as p,h}from"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";h();var w=p("agent");function I(n){let o=c(n);if(!o){w.debug({taskId:n},"No plan found for task, skipping review");return}let i=R(n,1e3),a=o.plan.steps,s=i.filter(e=>e.type==="tool_result"||e.type==="permission_denied").map(e=>({toolName:e.toolName??"unknown",output:e.content,planStepIndex:e.planStepIndex,permissionDenied:e.type==="permission_denied"})),t=[],r=new Set(s.map(e=>e.planStepIndex).filter(e=>e!==void 0));for(let e of a)r.has(e.index)||t.push({stepIndex:e.index,planned:e.description,actual:"Not executed",deviationType:"skipped"});let d=s.filter(e=>e.planStepIndex===void 0);for(let e of d)t.push({stepIndex:-1,planned:"",actual:`${e.toolName}: ${e.output.slice(0,200)}`,deviationType:"added"});let u=s.filter(e=>e.permissionDenied);for(let e of u)t.push({stepIndex:e.planStepIndex??-1,planned:e.planStepIndex!==void 0?a.find(b=>b.index===e.planStepIndex)?.description??"Unknown":"",actual:`PERMISSION DENIED: ${e.toolName}`,deviationType:"failed"});let l=a.length,g=s.length,v=l>0?Math.max(0,1-t.filter(e=>e.deviationType!=="added").length/l):1,y={stepsPlanned:l,stepsExecuted:g,deviations:t,overallAccuracy:v};return $(o.id,y),w.info({taskId:n,planId:o.id,stepsPlanned:l,stepsExecuted:g,deviationCount:t.length,accuracy:v},"Deviation report generated"),y}function A(n){return n.deviations.filter(i=>i.deviationType==="failed"||i.deviationType==="skipped").length===0&&n.overallAccuracy>=.7}E();L();N();h();var m=p("agent");function C(n){let o=[],i=[];for(let a of n)a.startsWith("[-]")?i.push(a):o.push(a);return{stylePreferences:o,avoidedActions:i}}function U(n,o){let i=[],s=f(n)?.prompt.slice(0,100)??"unknown task";A(o)&&i.push(`[+] Task "${s}" completed successfully with ${o.overallAccuracy*100}% plan accuracy (${o.stepsExecuted} steps). [sourceTaskId:${n}]`);for(let t of o.deviations)switch(t.deviationType){case"skipped":i.push(`[-] Planned step "${t.planned}" was skipped during "${s}". Consider if this step is necessary for similar tasks. [sourceTaskId:${n}]`);break;case"failed":i.push(`[-] Step failed: "${t.actual}" during "${s}". Check permissions and tool availability. [sourceTaskId:${n}]`);break;case"added":i.push(`[~] Unplanned action: "${t.actual}" during "${s}". Consider adding to plan for similar tasks. [sourceTaskId:${n}]`);break;case"modified":i.push(`[~] Step modified: planned "${t.planned}" but did "${t.actual}" during "${s}". [sourceTaskId:${n}]`);break}return i}async function H(n){let o=c(n);if(!o){m.debug({taskId:n},"No plan for task, skipping review/learn");return}let i=I(n);if(!i)return;let a=U(n,i);if(a.length===0)return;P(o.id,a);let s=f(n);if(s?.roleId){let t=x(s.roleId);if(t){let r=C(a),d={stylePreferences:[...t.learnedRules.stylePreferences,...r.stylePreferences],avoidedActions:[...t.learnedRules.avoidedActions,...r.avoidedActions],pinnedParameters:t.learnedRules.pinnedParameters};k(s.roleId,{learnedRules:d});let u=T(t.name);D(u,{...t,learnedRules:d}),m.info({roleId:s.roleId,newRulesCount:a.length},"Role learnedRules updated and CLAUDE.md written")}}S(o.id,"completed"),m.info({taskId:n,planId:o.id,rulesExtracted:a.length,accuracy:i.overallAccuracy},"Task review and learning completed")}export{U as extractRulesFromDeviation,H as processTaskReview};
1
+ import{d as c,e as S,f as $,g as P}from"./chunk-QJXV4SQE.js";import{b as R}from"./chunk-2JM3URDG.js";import{e as T,g as D,i as N}from"./chunk-GQS3ED3B.js";import{D as x,F as k,L,b as f,p as E}from"./chunk-WG3C43QS.js";import"./chunk-CN5NEJXG.js";import"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import{c as p,h}from"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";h();var w=p("agent");function I(n){let o=c(n);if(!o){w.debug({taskId:n},"No plan found for task, skipping review");return}let i=R(n,1e3),a=o.plan.steps,s=i.filter(e=>e.type==="tool_result"||e.type==="permission_denied").map(e=>({toolName:e.toolName??"unknown",output:e.content,planStepIndex:e.planStepIndex,permissionDenied:e.type==="permission_denied"})),t=[],r=new Set(s.map(e=>e.planStepIndex).filter(e=>e!==void 0));for(let e of a)r.has(e.index)||t.push({stepIndex:e.index,planned:e.description,actual:"Not executed",deviationType:"skipped"});let d=s.filter(e=>e.planStepIndex===void 0);for(let e of d)t.push({stepIndex:-1,planned:"",actual:`${e.toolName}: ${e.output.slice(0,200)}`,deviationType:"added"});let u=s.filter(e=>e.permissionDenied);for(let e of u)t.push({stepIndex:e.planStepIndex??-1,planned:e.planStepIndex!==void 0?a.find(b=>b.index===e.planStepIndex)?.description??"Unknown":"",actual:`PERMISSION DENIED: ${e.toolName}`,deviationType:"failed"});let l=a.length,g=s.length,v=l>0?Math.max(0,1-t.filter(e=>e.deviationType!=="added").length/l):1,y={stepsPlanned:l,stepsExecuted:g,deviations:t,overallAccuracy:v};return $(o.id,y),w.info({taskId:n,planId:o.id,stepsPlanned:l,stepsExecuted:g,deviationCount:t.length,accuracy:v},"Deviation report generated"),y}function A(n){return n.deviations.filter(i=>i.deviationType==="failed"||i.deviationType==="skipped").length===0&&n.overallAccuracy>=.7}E();L();N();h();var m=p("agent");function C(n){let o=[],i=[];for(let a of n)a.startsWith("[-]")?i.push(a):o.push(a);return{stylePreferences:o,avoidedActions:i}}function U(n,o){let i=[],s=f(n)?.prompt.slice(0,100)??"unknown task";A(o)&&i.push(`[+] Task "${s}" completed successfully with ${o.overallAccuracy*100}% plan accuracy (${o.stepsExecuted} steps). [sourceTaskId:${n}]`);for(let t of o.deviations)switch(t.deviationType){case"skipped":i.push(`[-] Planned step "${t.planned}" was skipped during "${s}". Consider if this step is necessary for similar tasks. [sourceTaskId:${n}]`);break;case"failed":i.push(`[-] Step failed: "${t.actual}" during "${s}". Check permissions and tool availability. [sourceTaskId:${n}]`);break;case"added":i.push(`[~] Unplanned action: "${t.actual}" during "${s}". Consider adding to plan for similar tasks. [sourceTaskId:${n}]`);break;case"modified":i.push(`[~] Step modified: planned "${t.planned}" but did "${t.actual}" during "${s}". [sourceTaskId:${n}]`);break}return i}async function H(n){let o=c(n);if(!o){m.debug({taskId:n},"No plan for task, skipping review/learn");return}let i=I(n);if(!i)return;let a=U(n,i);if(a.length===0)return;P(o.id,a);let s=f(n);if(s?.roleId){let t=x(s.roleId);if(t){let r=C(a),d={stylePreferences:[...t.learnedRules.stylePreferences,...r.stylePreferences],avoidedActions:[...t.learnedRules.avoidedActions,...r.avoidedActions],pinnedParameters:t.learnedRules.pinnedParameters};k(s.roleId,{learnedRules:d});let u=T(t.name);D(u,{...t,learnedRules:d}),m.info({roleId:s.roleId,newRulesCount:a.length},"Role learnedRules updated and CLAUDE.md written")}}S(o.id,"completed"),m.info({taskId:n,planId:o.id,rulesExtracted:a.length,accuracy:i.overallAccuracy},"Task review and learning completed")}export{U as extractRulesFromDeviation,H as processTaskReview};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r}from"./chunk-V2MMQ3SH.js";import"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{p as DEFAULT_HYBRID_CONFIG,l as DEFAULT_SCORING_WEIGHTS,m as calculateRecency,n as calculateSmallvilleScore,q as cleanupMemories,h as cosineSimilarity,f as countMemoriesByRole,a as createMemory,k as deleteMemory,b as getMemory,o as getRoleScoringWeights,g as listMemoriesByRole,e as markSuperseded,j as searchByBM25,i as searchByVector,r as searchHybrid,c as updateMemory,d as updateMemoryRetrievalCount};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r}from"./chunk-FN64ZULV.js";import"./chunk-WG3C43QS.js";import"./chunk-CN5NEJXG.js";import"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{p as DEFAULT_HYBRID_CONFIG,l as DEFAULT_SCORING_WEIGHTS,m as calculateRecency,n as calculateSmallvilleScore,q as cleanupMemories,h as cosineSimilarity,f as countMemoriesByRole,a as createMemory,k as deleteMemory,b as getMemory,o as getRoleScoringWeights,g as listMemoriesByRole,e as markSuperseded,j as searchByBM25,i as searchByVector,r as searchHybrid,c as updateMemory,d as updateMemoryRetrievalCount};
@@ -1 +1 @@
1
- import{b as i}from"./chunk-Z2APBKIT.js";import{b as p}from"./chunk-T2Z2JDPY.js";import{a}from"./chunk-V2MMQ3SH.js";import"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-3MROEPGR.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";import{v4 as u}from"uuid";function l(o){let r=o.toolName,e=o.toolOutput||o.content;if(r==="Write"||r==="Edit")return{content:`Modified file via ${r}: ${e.slice(0,400)}`,importance:4,type:"event"};if(r==="Bash"){let t=o.toolInput?.command?.slice(0,100)||"Bash";return e.includes("FAIL")||e.includes("error:")||e.includes("Error:")?{content:`Command failed: ${t} ${e.slice(0,300)}`,importance:4,type:"event"}:e.includes("success")||e.includes("done")||e.includes("OK")?{content:`Command succeeded: ${t}`,importance:2,type:"event"}:{content:`Executed: ${t}`,importance:1,type:"event"}}return null}function y(o){let r=i(o,500,0),e=[];for(let t of r)if((t.type==="tool_result"||t.type==="tool_call")&&t.toolName){let n=l(t);n&&e.push(n)}else t.type==="error"&&e.push({content:`Error occurred: ${t.content.slice(0,400)}`,importance:4,type:"event"});return{facts:e}}function f(o){let r=o.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(e=>e.length>2);return[...new Set(r)].slice(0,20)}async function M(o,r){let{facts:e}=y(o);for(let n of e)if(n.type!=="event")throw new Error(`extractKeyFacts produced non-event fact (type=${n.type}) \u2014 GAP-08 invariant violated`);let t=0;for(let n of e){let c=n.content.slice(0,500),s;try{s=await p(c)}catch{}let m=f(c),d={id:u(),roleId:r,type:n.type,content:c,embedding:s,keywords:m,importance:n.importance,sourceType:"task_complete",sourceTaskId:o,createdAt:Date.now(),lastAccessed:Date.now(),retrievedCount:0,tier:"episodic"};a(d),t++}return t}export{y as extractKeyFacts,M as processTaskCompletion};
1
+ import{b as i}from"./chunk-2JM3URDG.js";import{b as p}from"./chunk-T2Z2JDPY.js";import{a}from"./chunk-FN64ZULV.js";import"./chunk-WG3C43QS.js";import"./chunk-CN5NEJXG.js";import"./chunk-3MROEPGR.js";import"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";import{v4 as u}from"uuid";function l(o){let r=o.toolName,e=o.toolOutput||o.content;if(r==="Write"||r==="Edit")return{content:`Modified file via ${r}: ${e.slice(0,400)}`,importance:4,type:"event"};if(r==="Bash"){let t=o.toolInput?.command?.slice(0,100)||"Bash";return e.includes("FAIL")||e.includes("error:")||e.includes("Error:")?{content:`Command failed: ${t} ${e.slice(0,300)}`,importance:4,type:"event"}:e.includes("success")||e.includes("done")||e.includes("OK")?{content:`Command succeeded: ${t}`,importance:2,type:"event"}:{content:`Executed: ${t}`,importance:1,type:"event"}}return null}function y(o){let r=i(o,500,0),e=[];for(let t of r)if((t.type==="tool_result"||t.type==="tool_call")&&t.toolName){let n=l(t);n&&e.push(n)}else t.type==="error"&&e.push({content:`Error occurred: ${t.content.slice(0,400)}`,importance:4,type:"event"});return{facts:e}}function f(o){let r=o.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(e=>e.length>2);return[...new Set(r)].slice(0,20)}async function M(o,r){let{facts:e}=y(o);for(let n of e)if(n.type!=="event")throw new Error(`extractKeyFacts produced non-event fact (type=${n.type}) \u2014 GAP-08 invariant violated`);let t=0;for(let n of e){let c=n.content.slice(0,500),s;try{s=await p(c)}catch{}let m=f(c),d={id:u(),roleId:r,type:n.type,content:c,embedding:s,keywords:m,importance:n.importance,sourceType:"task_complete",sourceTaskId:o,createdAt:Date.now(),lastAccessed:Date.now(),retrievedCount:0,tier:"episodic"};a(d),t++}return t}export{y as extractKeyFacts,M as processTaskCompletion};
@@ -1 +1 @@
1
- import{d as f,e as p}from"./chunk-2JIQT2CI.js";import{c as m}from"./chunk-QYI44EP6.js";import"./chunk-V2MMQ3SH.js";import{K as l,L as y}from"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-3MROEPGR.js";import{n as a,p as g}from"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import{c,h as E}from"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";g();y();E();var R=c("manager");function C(b){let o=a(),i=Date.now(),s=i-b.observationTtlDays*864e5,n=o.prepare("DELETE FROM memories WHERE created_at < ? AND kind = 'observation'").run(s).changes,d=o.prepare("SELECT DISTINCT role_id FROM beliefs WHERE status='active'").all().map(e=>e.role_id),r=0;for(let e of d){let u=l(e),v=m(e,{onlyActive:!0});for(let t of v)t.isAnti||f(t,u)&&(p(t.id),r++)}return o.prepare("UPDATE server_state SET last_memory_gc_at = ? WHERE id = 1").run(i),R.info({observationsDeleted:n,beliefsArchived:r,obsCutoff:s},"Memory GC completed"),{observationsDeleted:n,beliefsArchived:r}}export{C as memoryGcTick};
1
+ import{d as f,e as p}from"./chunk-PO66F7UQ.js";import{c as m}from"./chunk-4ZG4UMAK.js";import"./chunk-FN64ZULV.js";import{K as l,L as y}from"./chunk-WG3C43QS.js";import"./chunk-CN5NEJXG.js";import"./chunk-3MROEPGR.js";import{o as a,q as g}from"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import{c,h as E}from"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";g();y();E();var R=c("manager");function C(b){let o=a(),i=Date.now(),s=i-b.observationTtlDays*864e5,n=o.prepare("DELETE FROM memories WHERE created_at < ? AND kind = 'observation'").run(s).changes,d=o.prepare("SELECT DISTINCT role_id FROM beliefs WHERE status='active'").all().map(e=>e.role_id),r=0;for(let e of d){let u=l(e),v=m(e,{onlyActive:!0});for(let t of v)t.isAnti||f(t,u)&&(p(t.id),r++)}return o.prepare("UPDATE server_state SET last_memory_gc_at = ? WHERE id = 1").run(i),R.info({observationsDeleted:n,beliefsArchived:r,obsCutoff:s},"Memory GC completed"),{observationsDeleted:n,beliefsArchived:r}}export{C as memoryGcTick};
@@ -0,0 +1 @@
1
+ import{c as a,d as b,e as c}from"./chunk-HEHST2E2.js";import"./chunk-PO66F7UQ.js";import"./chunk-4ZG4UMAK.js";import"./chunk-T2Z2JDPY.js";import"./chunk-FN64ZULV.js";import"./chunk-WG3C43QS.js";import"./chunk-CN5NEJXG.js";import"./chunk-3MROEPGR.js";import"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{b as getRelevantMemoryContext,a as queryMemory,c as queryMemoryByTier};
@@ -0,0 +1 @@
1
+ import{h as a,i as b,j as c,k as d}from"./chunk-IAGTZGGV.js";import"./chunk-DRS5NOAA.js";import"./chunk-VZL2DGC4.js";import"./chunk-YEGUFMLJ.js";import"./chunk-4G4CKAXY.js";import"./chunk-L4APYD5A.js";import"./chunk-ORFLN4BF.js";import"./chunk-L7JP7DUO.js";import"./chunk-WG3C43QS.js";import"./chunk-EBZCHLYS.js";import"./chunk-CN5NEJXG.js";import"./chunk-J2VSAXVU.js";import"./chunk-3MROEPGR.js";import"./chunk-6GYNUTPP.js";import"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{a as OutboundGateway,b as _resetChannelManagerModuleCache,c as getOutboundGateway,d as isRecentlySent};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-DFTRUOT6.js";import"./chunk-MMVDXKYS.js";import"./chunk-FQHGIY3E.js";import"./chunk-2JM3URDG.js";import"./chunk-L4APYD5A.js";import"./chunk-GQS3ED3B.js";import"./chunk-ORFLN4BF.js";import"./chunk-L7JP7DUO.js";import"./chunk-HEHST2E2.js";import"./chunk-PO66F7UQ.js";import"./chunk-4ZG4UMAK.js";import"./chunk-T2Z2JDPY.js";import"./chunk-FN64ZULV.js";import"./chunk-WG3C43QS.js";import"./chunk-CN5NEJXG.js";import"./chunk-3MROEPGR.js";import"./chunk-6GYNUTPP.js";import"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{a as ADAM_AUTOMATOR_PRESET,d as CHAT_MANAGER_ROLE_ID,e as PRESET_ROLE_NAMES,b as ROLE_PRESETS,c as TEMPLATE_PRESETS,h as ensureAdamAutomatorRole,g as ensureChatManagerRole,l as getPresetRole,j as getPresetRoles,m as getPresetTemplate,k as getPresetTemplates,i as initializeDefaultRoles,f as isPresetRole,o as restorePreset,n as seedPresets};
@@ -1,4 +1,4 @@
1
- import{d as x}from"./chunk-SKHMWKJT.js";import{a as O}from"./chunk-SGLZAIVL.js";import"./chunk-IEBAOZED.js";import{a as I}from"./chunk-L7JP7DUO.js";import{a as v,c as N,d as F,e as A}from"./chunk-QYI44EP6.js";import{b as j}from"./chunk-T2Z2JDPY.js";import{g as U}from"./chunk-V2MMQ3SH.js";import{K as $,L as H}from"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import{e as m}from"./chunk-3MROEPGR.js";import{n as M,p as P}from"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import{c as b,h as E}from"./chunk-EZLBMUQD.js";import{c as S,e as V}from"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";P();E();V();import{v4 as T}from"uuid";E();var J=5;function C(){try{let e=m().memory?.reflection?.maxBudgetUsd;if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e}catch{}return J}var K=b("manager");function W(e){let t=e.trim(),s=t.match(/^```(\w*)\s*/);return s&&(t=t.slice(s[0].length)),t.endsWith("```")&&(t=t.slice(0,t.length-3)),t.trim()}function Y(e,t){let s=W(e),c;try{c=JSON.parse(s)}catch{return{action:"coexist"}}if(!c||typeof c!="object")return{action:"coexist"};let n=c;if(n.action==="coexist")return{action:"coexist"};if(n.action==="merge"){let o=typeof n.intoBeliefId=="string"?n.intoBeliefId.trim():"",i=typeof n.mergedContent=="string"?n.mergedContent.trim():"";return o.length>0&&i.length>0&&t.some(r=>r.id===o)?{action:"merge",intoBeliefId:o,mergedContent:i}:{action:"coexist"}}if(n.action==="supersede"){let o=typeof n.oldBeliefId=="string"?n.oldBeliefId.trim():"";return o.length>0&&t.some(i=>i.id===o)?{action:"supersede",oldBeliefId:o}:{action:"coexist"}}return{action:"coexist"}}async function L(e,t){if(t.length===0)return{action:"coexist"};let c=m().anthropic?.defaultHaikuModel||"claude-haiku-4-5",o=`You are a belief conflict resolver.
1
+ import{d as x}from"./chunk-EPLSB63A.js";import{a as O}from"./chunk-A3YUIWLK.js";import"./chunk-WDMSZS4W.js";import{a as I}from"./chunk-L7JP7DUO.js";import{a as v,c as N,d as F,e as A}from"./chunk-4ZG4UMAK.js";import{b as j}from"./chunk-T2Z2JDPY.js";import{g as U}from"./chunk-FN64ZULV.js";import{K as $,L as H}from"./chunk-WG3C43QS.js";import"./chunk-CN5NEJXG.js";import{e as m}from"./chunk-3MROEPGR.js";import{o as M,q as P}from"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import{c as b,h as E}from"./chunk-EZLBMUQD.js";import{c as S,e as V}from"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";P();E();V();import{v4 as T}from"uuid";E();var J=5;function C(){try{let e=m().memory?.reflection?.maxBudgetUsd;if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e}catch{}return J}var K=b("manager");function W(e){let t=e.trim(),s=t.match(/^```(\w*)\s*/);return s&&(t=t.slice(s[0].length)),t.endsWith("```")&&(t=t.slice(0,t.length-3)),t.trim()}function Y(e,t){let s=W(e),c;try{c=JSON.parse(s)}catch{return{action:"coexist"}}if(!c||typeof c!="object")return{action:"coexist"};let n=c;if(n.action==="coexist")return{action:"coexist"};if(n.action==="merge"){let o=typeof n.intoBeliefId=="string"?n.intoBeliefId.trim():"",i=typeof n.mergedContent=="string"?n.mergedContent.trim():"";return o.length>0&&i.length>0&&t.some(r=>r.id===o)?{action:"merge",intoBeliefId:o,mergedContent:i}:{action:"coexist"}}if(n.action==="supersede"){let o=typeof n.oldBeliefId=="string"?n.oldBeliefId.trim():"";return o.length>0&&t.some(i=>i.id===o)?{action:"supersede",oldBeliefId:o}:{action:"coexist"}}return{action:"coexist"}}async function L(e,t){if(t.length===0)return{action:"coexist"};let c=m().anthropic?.defaultHaikuModel||"claude-haiku-4-5",o=`You are a belief conflict resolver.
2
2
 
3
3
  Existing beliefs for this role:
4
4
  ${t.map((i,r)=>`${r+1}. id=${i.id} ${i.content}`).join(`
@@ -0,0 +1 @@
1
+ import"./chunk-QMW7VEPC.js";import{a,d as b,e as c,f as d,g as e,h as f,i as g}from"./chunk-DFTRUOT6.js";import"./chunk-MMVDXKYS.js";import"./chunk-FQHGIY3E.js";import"./chunk-2JM3URDG.js";import"./chunk-L4APYD5A.js";import"./chunk-GQS3ED3B.js";import"./chunk-ORFLN4BF.js";import"./chunk-L7JP7DUO.js";import"./chunk-HEHST2E2.js";import"./chunk-PO66F7UQ.js";import"./chunk-4ZG4UMAK.js";import"./chunk-T2Z2JDPY.js";import"./chunk-FN64ZULV.js";import"./chunk-WG3C43QS.js";import"./chunk-CN5NEJXG.js";import"./chunk-3MROEPGR.js";import"./chunk-6GYNUTPP.js";import"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{a as ADAM_AUTOMATOR_PRESET,b as CHAT_MANAGER_ROLE_ID,c as PRESET_ROLE_NAMES,f as ensureAdamAutomatorRole,e as ensureChatManagerRole,g as initializeDefaultRoles,d as isPresetRole};
@@ -0,0 +1 @@
1
+ import{e as a,f as b,g as c,h as d,i as e}from"./chunk-GQS3ED3B.js";import"./chunk-WG3C43QS.js";import"./chunk-CN5NEJXG.js";import"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";e();export{b as ensureRoleWorkspace,a as getRoleWorkspacePath,d as syncRoleSettings,c as writeRoleCLAUDEmd};
@@ -1 +1 @@
1
- import{B as a,C as b,D as c,E as d,F as e,G as f,H as g,I as h,J as i,K as j,L as k}from"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";k();export{b as createRole,h as deleteRole,c as getRole,d as getRoleByName,j as getRoleTaskSeq,g as hasActiveTasks,i as incrementRoleTaskSeq,f as listRoles,e as updateRole,a as validateAdditionalDirectories};
1
+ import{B as a,C as b,D as c,E as d,F as e,G as f,H as g,I as h,J as i,K as j,L as k}from"./chunk-WG3C43QS.js";import"./chunk-CN5NEJXG.js";import"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";k();export{b as createRole,h as deleteRole,c as getRole,d as getRoleByName,j as getRoleTaskSeq,g as hasActiveTasks,i as incrementRoleTaskSeq,f as listRoles,e as updateRole,a as validateAdditionalDirectories};
@@ -1 +1 @@
1
- import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q}from"./chunk-2CE2WUUZ.js";import"./chunk-IEBAOZED.js";import{f as a}from"./chunk-TA5PFK5C.js";import"./chunk-L7JP7DUO.js";import"./chunk-T2Z2JDPY.js";import"./chunk-V2MMQ3SH.js";import"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-47HJPIUA.js";import"./chunk-NXGR3PRY.js";import"./chunk-5G64P4KE.js";import"./chunk-3MROEPGR.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{q as _resetForTest,f as archiveSession,c as createSession,h as deleteSession,d as getActiveSession,e as getSession,n as getTimeoutPollerInterval,j as incrementMessageCount,o as initSessionManager,k as listSessions,g as restoreSession,p as shutdownSessionManager,l as startTimeoutPoller,m as stopTimeoutPoller,i as touchSession,a as updateSessionSdkId,b as warmCache};
1
+ import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q}from"./chunk-4ZESWP3J.js";import"./chunk-WDMSZS4W.js";import{f as a}from"./chunk-YEGUFMLJ.js";import"./chunk-L7JP7DUO.js";import"./chunk-T2Z2JDPY.js";import"./chunk-FN64ZULV.js";import"./chunk-WG3C43QS.js";import"./chunk-CN5NEJXG.js";import"./chunk-T7EKW3B7.js";import"./chunk-J2VSAXVU.js";import"./chunk-JRRNGKDK.js";import"./chunk-3MROEPGR.js";import"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{q as _resetForTest,f as archiveSession,c as createSession,h as deleteSession,d as getActiveSession,e as getSession,n as getTimeoutPollerInterval,j as incrementMessageCount,o as initSessionManager,k as listSessions,g as restoreSession,p as shutdownSessionManager,l as startTimeoutPoller,m as stopTimeoutPoller,i as touchSession,a as updateSessionSdkId,b as warmCache};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-ZGA52HRD.js";import"./chunk-KM4EFB4N.js";import"./chunk-GQS3ED3B.js";import"./chunk-WG3C43QS.js";import"./chunk-CN5NEJXG.js";import"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{a as SkillRegistry};
@@ -1 +1 @@
1
- import{n as a,o as b,p as c,q as d,r as e,s as f,t as g,u as h,v as i,w as j,x as k,y as l}from"./chunk-VWX2B6OM.js";import"./chunk-2A2TXYT3.js";import"./chunk-NUOTFUNF.js";import"./chunk-WY5BOCQP.js";import"./chunk-VO24C673.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{b as TemplateRoleConfigError,a as TemplateValidationError,e as createTaskTemplate,l as deleteTaskTemplate,j as disableTaskTemplate,i as enableTaskTemplate,f as getTaskTemplate,k as getTaskTemplateDependents,h as listTaskTemplates,g as updateTaskTemplate,d as validateTemplateDefinition,c as validateTemplateRoleConfig};
1
+ import{n as a,o as b,p as c,q as d,r as e,s as f,t as g,u as h,v as i,w as j,x as k,y as l}from"./chunk-ORFLN4BF.js";import"./chunk-WG3C43QS.js";import"./chunk-CN5NEJXG.js";import"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{b as TemplateRoleConfigError,a as TemplateValidationError,e as createTaskTemplate,l as deleteTaskTemplate,j as disableTaskTemplate,i as enableTaskTemplate,f as getTaskTemplate,k as getTaskTemplateDependents,h as listTaskTemplates,g as updateTaskTemplate,d as validateTemplateDefinition,c as validateTemplateRoleConfig};
@@ -0,0 +1 @@
1
+ import{t as a}from"./chunk-KQMKRRYW.js";import"./chunk-R7Q6FSV4.js";import"./chunk-QJXV4SQE.js";import"./chunk-EPLSB63A.js";import"./chunk-KM4EFB4N.js";import"./chunk-4ZESWP3J.js";import"./chunk-4N5G7ND2.js";import"./chunk-WDMSZS4W.js";import"./chunk-NNMQGISW.js";import"./chunk-IAGTZGGV.js";import"./chunk-DRS5NOAA.js";import"./chunk-VZL2DGC4.js";import"./chunk-YEGUFMLJ.js";import"./chunk-4G4CKAXY.js";import"./chunk-FQHGIY3E.js";import"./chunk-2JM3URDG.js";import"./chunk-L4APYD5A.js";import"./chunk-GQS3ED3B.js";import"./chunk-ORFLN4BF.js";import"./chunk-L7JP7DUO.js";import"./chunk-T2Z2JDPY.js";import"./chunk-FN64ZULV.js";import"./chunk-WG3C43QS.js";import"./chunk-EBZCHLYS.js";import"./chunk-CN5NEJXG.js";import"./chunk-T7EKW3B7.js";import"./chunk-J2VSAXVU.js";import"./chunk-JRRNGKDK.js";import"./chunk-3MROEPGR.js";import"./chunk-6GYNUTPP.js";import"./chunk-LMQPGVM7.js";import"./chunk-ITVCPC7G.js";import"./chunk-EZLBMUQD.js";import"./chunk-5M6IGE5G.js";import"./chunk-5PELJRUQ.js";export{a as dispatchTemplate};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adam-agent-server",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
4
4
  "description": "Goal-driven AI agent orchestration server with Role+Skill model, real-time streaming, and multi-channel delivery",
5
5
  "license": "MIT",
6
6
  "author": "norvyn https://x.com/norvynzhang https://github.com/n0rvyn norvynzhang@gmail.com",
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{F as t,G as n,O as r,at 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)([]),[T,E]=(0,v.useState)(null);if((0,v.useEffect)(()=>{e&&((async()=>{try{l((await u(`/channels/${e}`)).channel),E(null)}catch(e){E(e instanceof Error?e.message:`Failed to load channel`)}})(),u(`/delivery-rules`).then(t=>S(t.filter(t=>t.target.type===`channel`&&t.target.channelId===e))).catch(()=>S([])),u(`/delivery-rules`).then(async t=>{let n=t.filter(t=>t.target.type===`channel`&&t.target.channelId===e),r=[];for(let e of n.slice(0,3))try{let t=await u(`/delivery-rules/${e.id}/log`);r.push(...t.log??[])}catch{}r.sort((e,t)=>t.createdAt-e.createdAt),w(r.slice(0,20))}).catch(()=>w([])))},[e]),T)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/channels`,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 Channels`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-danger)]`,children:T})]});if(!o)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/channels`,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 Channels`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let D=e=>e===`connected`?`success`:e===`connecting`?`warning`:e===`error`?`destructive`:`secondary`,O=e=>{switch(e){case`wechat`:return`WeChat`;case`telegram`:return`Telegram`;case`slack`:return`Slack`;case`discord`:return`Discord`;default:return e.charAt(0).toUpperCase()+e.slice(1)}},k={...o.config};for(let e of[`botToken`,`apiKey`,`secret`,`password`,`token`])e in k&&(k[e]=`********`);return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsxs)(c,{to:`/channels`,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 Channels`]}),(0,y.jsx)(h,{eyebrow:`Channel`,title:o.name,compact:!0,description:`Connectivity, delivery policy, and recent outbound activity.`,metrics:[{label:`Status`,value:(0,y.jsx)(d,{variant:D(o.status),children:o.status})},{label:`Platform`,value:O(o.platform)},{label:`Enabled`,value:o.enabled?`Yes`:`No`},{label:`Messages`,value:o.messageCount}]}),(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:`Channel 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:`Linked role`}),(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium text-[var(--app-text)]`,children:o.linkedRoleId?`${o.linkedRoleId.slice(0,8)}...`:`None`})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Delivery rules`}),(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:`Recent delivery events`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:C.length})]})]}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,y.jsx)(x,{icon:i,label:`Created`,value:_(o.createdAt),mono:!0}),(0,y.jsx)(x,{icon:t,label:`Messages`,value:String(o.messageCount),mono:!0}),o.lastMessageAt&&(0,y.jsx)(x,{icon:i,label:`Last Message`,value:_(o.lastMessageAt),mono:!0}),o.linkedRoleId&&(0,y.jsx)(x,{icon:r,label:`Linked Role`,value:o.linkedRoleId.slice(0,8)+`...`,mono:!0})]}),(0,y.jsx)(g,{title:`Configuration`,compact:!0,description:`Raw config stays available below, but status and traffic stay first.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Configuration`})}),Object.keys(k).length>0&&(0,y.jsx)(`div`,{className:`mb-4 grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:Object.entries(k).slice(0,6).map(([e,t])=>(0,y.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,y.jsx)(`p`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:e}),(0,y.jsx)(`p`,{className:`mt-1 truncate text-sm text-[var(--app-text)]`,children:String(t)})]},e))}),(0,y.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap rounded-md bg-[var(--app-panel-elevated)] p-3 font-mono text-xs text-[var(--app-text)]`,children:JSON.stringify(k,null,2)})]}),(0,y.jsx)(g,{title:`Delivery Activity`,compact:!0,description:`Rules and log entries stay grouped as one operational block.`}),b.length>0&&(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,y.jsx)(n,{size:14}),` Delivery Rules (`,b.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>(0,y.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)]/50 p-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(d,{variant:`outline`,children:e.eventType}),e.enabled?(0,y.jsx)(d,{variant:`success`,children:`active`}):(0,y.jsx)(d,{variant:`secondary`,children:`disabled`}),(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`max `,e.maxPerMinute,`/min`]})]}),(0,y.jsxs)(`p`,{className:`mt-1 text-xs text-[var(--app-text-muted)] font-mono`,children:[`Rule: `,e.id]})]},e.id))})]}),C.length>0&&(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}),` Delivery Log (`,C.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:C.slice(0,10).map(e=>(0,y.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-[var(--app-border)] p-2`,children:[(0,y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,y.jsx)(`span`,{className:`text-sm text-[var(--app-text)] font-mono`,children:e.taskId.slice(0,8)}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:_(e.createdAt)})]}),(0,y.jsx)(d,{variant:e.status===`delivered`?`default`:e.status===`failed`?`destructive`:`outline`,children:e.status})]},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 ChannelDetail};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{F as t,G as n,O as r,at 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-Dd3NDYZR.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)([]),[T,E]=(0,v.useState)(null);if((0,v.useEffect)(()=>{e&&((async()=>{try{l((await u(`/channels/${e}`)).channel),E(null)}catch(e){E(e instanceof Error?e.message:`Failed to load channel`)}})(),u(`/delivery-rules`).then(t=>S(t.filter(t=>t.target.type===`channel`&&t.target.channelId===e))).catch(()=>S([])),u(`/delivery-rules`).then(async t=>{let n=t.filter(t=>t.target.type===`channel`&&t.target.channelId===e),r=[];for(let e of n.slice(0,3))try{let t=await u(`/delivery-rules/${e.id}/log`);r.push(...t.log??[])}catch{}r.sort((e,t)=>t.createdAt-e.createdAt),w(r.slice(0,20))}).catch(()=>w([])))},[e]),T)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/channels`,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 Channels`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-danger)]`,children:T})]});if(!o)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/channels`,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 Channels`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let D=e=>e===`connected`?`success`:e===`connecting`?`warning`:e===`error`?`destructive`:`secondary`,O=e=>{switch(e){case`wechat`:return`WeChat`;case`telegram`:return`Telegram`;case`slack`:return`Slack`;case`discord`:return`Discord`;default:return e.charAt(0).toUpperCase()+e.slice(1)}},k={...o.config};for(let e of[`botToken`,`apiKey`,`secret`,`password`,`token`])e in k&&(k[e]=`********`);return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsxs)(c,{to:`/channels`,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 Channels`]}),(0,y.jsx)(h,{eyebrow:`Channel`,title:o.name,compact:!0,description:`Connectivity, delivery policy, and recent outbound activity.`,metrics:[{label:`Status`,value:(0,y.jsx)(d,{variant:D(o.status),children:o.status})},{label:`Platform`,value:O(o.platform)},{label:`Enabled`,value:o.enabled?`Yes`:`No`},{label:`Messages`,value:o.messageCount}]}),(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:`Channel 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:`Linked role`}),(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium text-[var(--app-text)]`,children:o.linkedRoleId?`${o.linkedRoleId.slice(0,8)}...`:`None`})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Delivery rules`}),(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:`Recent delivery events`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:C.length})]})]}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,y.jsx)(x,{icon:i,label:`Created`,value:_(o.createdAt),mono:!0}),(0,y.jsx)(x,{icon:t,label:`Messages`,value:String(o.messageCount),mono:!0}),o.lastMessageAt&&(0,y.jsx)(x,{icon:i,label:`Last Message`,value:_(o.lastMessageAt),mono:!0}),o.linkedRoleId&&(0,y.jsx)(x,{icon:r,label:`Linked Role`,value:o.linkedRoleId.slice(0,8)+`...`,mono:!0})]}),(0,y.jsx)(g,{title:`Configuration`,compact:!0,description:`Raw config stays available below, but status and traffic stay first.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Configuration`})}),Object.keys(k).length>0&&(0,y.jsx)(`div`,{className:`mb-4 grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:Object.entries(k).slice(0,6).map(([e,t])=>(0,y.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,y.jsx)(`p`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:e}),(0,y.jsx)(`p`,{className:`mt-1 truncate text-sm text-[var(--app-text)]`,children:String(t)})]},e))}),(0,y.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap rounded-md bg-[var(--app-panel-elevated)] p-3 font-mono text-xs text-[var(--app-text)]`,children:JSON.stringify(k,null,2)})]}),(0,y.jsx)(g,{title:`Delivery Activity`,compact:!0,description:`Rules and log entries stay grouped as one operational block.`}),b.length>0&&(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,y.jsx)(n,{size:14}),` Delivery Rules (`,b.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>(0,y.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)]/50 p-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(d,{variant:`outline`,children:e.eventType}),e.enabled?(0,y.jsx)(d,{variant:`success`,children:`active`}):(0,y.jsx)(d,{variant:`secondary`,children:`disabled`}),(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`max `,e.maxPerMinute,`/min`]})]}),(0,y.jsxs)(`p`,{className:`mt-1 text-xs text-[var(--app-text-muted)] font-mono`,children:[`Rule: `,e.id]})]},e.id))})]}),C.length>0&&(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}),` Delivery Log (`,C.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:C.slice(0,10).map(e=>(0,y.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-[var(--app-border)] p-2`,children:[(0,y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-baseline gap-2`,children:[(0,y.jsx)(`span`,{className:`text-sm text-[var(--app-text)] font-mono`,children:e.taskId.slice(0,8)}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:_(e.createdAt)})]}),(0,y.jsx)(d,{variant:e.status===`delivered`?`default`:e.status===`failed`?`destructive`:`outline`,children:e.status})]},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 ChannelDetail};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,F as n,O as r,T as i,j as a,k as o,l as s,n as c,xt as l}from"./vendor-icons-Bc_e_XXa.js";import{t as u}from"./vendor-react-bQ_cvNuA.js";import{t as d}from"./Button-CRNb8sD3.js";import{t as f}from"./api-BP4ZP9kk.js";import{t as p}from"./index-CXEJd-0s.js";import{a as m,i as h,t as g}from"./Card-Cwvv0An8.js";import{t as _}from"./PageHeader-acLQTYct.js";import{t as v}from"./SectionHeader-NZWZgoOs.js";import{t as y}from"./EmptyState-BvQA1o5K.js";import{t as b}from"./ui-D1crlGpt.js";var x=e(l(),1),S=u(),C=[`telegram`,`slack`,`discord`,`openclaw`,`wechat`,`whatsapp`,`email`],w={telegram:`{
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,F as n,O as r,T as i,j as a,k as o,l as s,n as c,xt as l}from"./vendor-icons-Bc_e_XXa.js";import{t as u}from"./vendor-react-bQ_cvNuA.js";import{t as d}from"./Button-CRNb8sD3.js";import{t as f}from"./api-BP4ZP9kk.js";import{t as p}from"./index-Dd3NDYZR.js";import{a as m,i as h,t as g}from"./Card-Cwvv0An8.js";import{t as _}from"./PageHeader-acLQTYct.js";import{t as v}from"./SectionHeader-NZWZgoOs.js";import{t as y}from"./EmptyState-BvQA1o5K.js";import{t as b}from"./ui-D1crlGpt.js";var x=e(l(),1),S=u(),C=[`telegram`,`slack`,`discord`,`openclaw`,`wechat`,`whatsapp`,`email`],w={telegram:`{
2
2
  "botToken": ""
3
3
  }`,slack:`{
4
4
  "botToken": "",
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/api-BP4ZP9kk.js","assets/rolldown-runtime-Dw2cE7zH.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{C as t,D as n,I as r,L as i,W as a,Y as o,_ as s,b as c,ft as l,g as u,it as d,l as f,mt as p,n as m,ot as h,pt as g,ut as _,xt as v,yt as y}from"./vendor-icons-Bc_e_XXa.js";import{p as b,t as x}from"./vendor-react-bQ_cvNuA.js";import{r as S}from"./dist-CgGno8kE.js";import{t as C}from"./Button-CRNb8sD3.js";import{n as w}from"./vendor-state-BMVR_B0I.js";import{t as T}from"./api-BP4ZP9kk.js";import{t as E}from"./PageHeader-acLQTYct.js";import{a as D}from"./format-ZWN4JNj-.js";import{t as O}from"./EmptyState-BvQA1o5K.js";import{t as k}from"./ui-D1crlGpt.js";import{t as A}from"./useIsMobileLayout-BogOiFTv.js";var j=e(v(),1),M=w((e,t)=>({sessions:[],activeSessionId:null,messages:[],loading:!1,sending:!1,_chatWs:null,_chatWsReconnectDelay:1e3,fetchSessions:async()=>{try{e({sessions:(await T(`/chat/sessions`)).sessions})}catch{}},fetchMessages:async t=>{e({loading:!0});try{e({messages:(await T(`/chat/sessions/${t}`)).messages,loading:!1})}catch{e({messages:[],loading:!1})}},sendMessage:async n=>{if(t().sending)return null;e({sending:!0});try{let r=await T(`/chat/messages`,{method:`POST`,body:JSON.stringify({content:n,source:{type:`web`},sessionId:t().activeSessionId??void 0})});return e({activeSessionId:r.sessionId,sending:!1}),t().fetchSessions(),r}catch{return e({sending:!1}),null}},sendApprovalResponse:async(n,r)=>{if(t().sending)return null;e({sending:!0});try{let i=await T(`/chat/messages`,{method:`POST`,body:JSON.stringify({content:r,source:{type:`web`},sessionId:t().activeSessionId??void 0,buttonPayload:{promptId:n,value:r}})});return e({activeSessionId:i.sessionId,sending:!1}),t().fetchSessions(),i}catch{return e({sending:!1}),null}},createSession:async()=>{try{let t=await T(`/chat/sessions`,{method:`POST`,body:JSON.stringify({source:{type:`web`}})});return e(e=>({sessions:[t.session,...e.sessions],activeSessionId:t.session.id,messages:[]})),t.session}catch{return null}},archiveSession:async t=>{try{await T(`/chat/sessions/${t}/archive`,{method:`POST`}),e(e=>({sessions:e.sessions.map(e=>e.id===t?{...e,status:`archived`}:e),activeSessionId:e.activeSessionId===t?null:e.activeSessionId,messages:e.activeSessionId===t?[]:e.messages}))}catch{}},restoreSession:async t=>{try{await T(`/chat/sessions/${t}/restore`,{method:`POST`}),e(e=>({sessions:e.sessions.map(e=>e.id===t?{...e,status:`active`}:e)}))}catch{}},deleteSession:async t=>{try{await T(`/chat/sessions/${t}`,{method:`DELETE`}),e(e=>({sessions:e.sessions.filter(e=>e.id!==t),activeSessionId:e.activeSessionId===t?null:e.activeSessionId,messages:e.activeSessionId===t?[]:e.messages}))}catch{}},setActiveSession:n=>{e({activeSessionId:n,messages:[]}),n&&t().fetchMessages(n)},connectChatStream:()=>{let n=t()._chatWs;if(n&&n.readyState<=1)return;let r=window.location.protocol===`https:`?`wss:`:`ws:`,i=localStorage.getItem(`adam_api_key`),a=new URL(`${r}//${window.location.host}/chat/stream`);i&&a.searchParams.set(`api_key`,i);let o=new WebSocket(a.toString()),s=!1;o.onopen=()=>{s=!0,e({_chatWs:o,_chatWsReconnectDelay:1e3})},o.onclose=async()=>{if(!s&&i){let{verifyApiKey:e,clearStoredApiKey:t,redirectToLogin:n}=await b(async()=>{let{verifyApiKey:e,clearStoredApiKey:t,redirectToLogin:n}=await import(`./api-BP4ZP9kk.js`).then(e=>e.n);return{verifyApiKey:e,clearStoredApiKey:t,redirectToLogin:n}},__vite__mapDeps([0,1]));if(!await e(i).catch(()=>!0)){t(),n();return}}let n=t()._chatWsReconnectDelay;e({_chatWs:null,_chatWsReconnectDelay:Math.min(n*2,1e4)}),setTimeout(()=>{t().connectChatStream()},n)},o.onerror=()=>{o.close()},o.onmessage=n=>{try{let r=JSON.parse(n.data);if(r.type===`chat_message`&&r.message){let n=r.message,{activeSessionId:i,messages:a}=t();if(n.sessionId!==i||a.some(e=>e.id===n.id))return;e(e=>({messages:[...e.messages,n]}))}else r.type===`session_created`&&t().fetchSessions()}catch{}},e({_chatWs:o})},disconnectChatStream:()=>{let n=t()._chatWs;n&&(n.onclose=null,n.onerror=null,n.onmessage=null,n.close(),e({_chatWs:null}))}})),N=x();function P({message:e}){return(0,N.jsxs)(`div`,{className:`chat-status-report flex items-center gap-2 px-3 py-1 text-xs text-[var(--app-text-subtle)] opacity-60`,"data-testid":`status-report-line`,children:[(0,N.jsx)(`span`,{className:`select-none`,children:`›`}),(0,N.jsx)(`span`,{className:`flex-1 truncate`,children:e.content}),(0,N.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:D(typeof e.createdAt==`number`?e.createdAt:new Date(e.createdAt).getTime())})]})}function F({messages:e}){let[t,n]=(0,j.useState)(!1),r=e.length;return(0,N.jsxs)(`div`,{className:`chat-status-report-group`,"data-testid":`status-report-group`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:S(`flex w-full items-center gap-2 rounded border border-[var(--app-border)] bg-white/[0.02] px-3 py-1.5 text-xs text-[var(--app-text-muted)] transition-colors hover:border-[var(--app-border-strong)]`),"aria-expanded":t,children:[(0,N.jsx)(l,{size:12,className:S(`transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),(0,N.jsxs)(`span`,{children:[r,` 步进展`]})]}),t?(0,N.jsx)(`div`,{className:`mt-1 space-y-0.5 border-l border-[var(--app-border)] pl-3`,children:e.map(e=>(0,N.jsx)(P,{message:e},e.id))}):null]})}var I={report:o,media:a,data:d,scratch:f,archive:y};function L(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function R({attachment:e,onPreview:t}){let n=e.purpose?I[e.purpose]:o;return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>t?.(e),className:S(`inline-flex items-center gap-2 rounded-md border border-[var(--app-border)] bg-white/[0.04] px-3 py-1.5 text-xs text-[var(--app-text-muted)] transition-colors hover:border-[var(--app-border-strong)] hover:text-[var(--app-text)]`),title:`${e.filename} · ${L(e.size)} · ${e.mimeType}${e.purpose?` · purpose=${e.purpose}`:``}`,"data-testid":`attachment-chip`,"data-purpose":e.purpose??`unknown`,children:[(0,N.jsx)(n,{size:14,"aria-hidden":`true`}),(0,N.jsx)(`span`,{className:`font-medium text-[var(--app-text)]`,children:e.filename}),(0,N.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`· `,L(e.size)]})]})}var z=[`var(--app-log-adam)`,`var(--app-log-manager)`,`var(--app-log-scheduler)`,`var(--app-log-ws)`,`var(--app-log-store)`,`var(--app-log-embedding)`];function B(e){if(!e)return`var(--app-text-subtle)`;let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return z[Math.abs(t)%z.length]}function V(e){return e?`T-${e.replace(/-/g,``).slice(0,8).toUpperCase()}`:``}function ee(e,t=3){let n=[],r=[],i=()=>{if(r.length!==0){if(r.length>=t)n.push({type:`status-group`,messages:r});else for(let e of r)n.push({type:`single`,message:e});r=[]}};for(let t of e)t.kind===`status_report`?r.push(t):(i(),n.push({type:`single`,message:t}));return i(),n}function te(e){let t=[],n=new Map,r=[];for(let i of e){if(!i.threadRoot){t.push(i);continue}n.has(i.threadRoot)||(n.set(i.threadRoot,[]),r.push(i.threadRoot)),n.get(i.threadRoot).push(i)}let i=[{threadRoot:null,messages:t}];for(let e of r)i.push({threadRoot:e,messages:n.get(e)});return i}function H({message:e}){let t=B(e.roleId),n=V(e.taskId),r=e.mirroredToTargets&&e.mirroredToTargets.length>0;return(0,N.jsxs)(`div`,{className:S(`chat-result-delivery surface-panel-elevated rounded-xl px-4 py-3 text-sm leading-7`),"data-testid":`result-delivery-card`,"data-task-short-id":n,children:[(0,N.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-[11px] uppercase tracking-[0.16em]`,children:[(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-[10px] font-semibold`,style:{borderColor:t,color:t},"data-testid":`role-pill`,children:[(0,N.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full`,style:{background:t},"aria-hidden":`true`}),n||`Adam`]}),(0,N.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:D(typeof e.createdAt==`number`?e.createdAt:new Date(e.createdAt).getTime())})]}),(0,N.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-[var(--app-text)]`,children:e.content}),e.attachments&&e.attachments.length>0?(0,N.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2 border-t border-[var(--app-border)] pt-3`,children:e.attachments.map(e=>(0,N.jsx)(R,{attachment:e},e.artifactId))}):null,r?(0,N.jsxs)(`div`,{className:`chat-mirror-suffix mt-2 text-[11px] italic text-[var(--app-text-subtle)]`,"data-testid":`mirror-suffix`,children:[`(also delivered to:`,` `,e.mirroredToTargets.map(e=>e.channelId??e.sessionId??`unknown`).join(`, `),` `,`@`,` `,new Date(typeof e.createdAt==`number`?e.createdAt:new Date(e.createdAt).getTime()).toLocaleTimeString([],{hour12:!1,hour:`2-digit`,minute:`2-digit`}),`)`]}):null]})}function U({message:e}){let t=M(e=>e.sendApprovalResponse),n=M(e=>e.messages),[r,i]=(0,j.useState)(`pending`),[a,o]=(0,j.useState)(``),[s,l]=(0,j.useState)(null),[u,d]=(0,j.useState)(``),[f,h]=(0,j.useState)(``),g=e.approvalShape??`yes_no`,v=e.promptId??``;(0,j.useEffect)(()=>{if(r!==`submitted`||!v||s===null)return;let e=n.find(e=>e.kind!==`system_note`||e.createdAt<s||!e.content.includes(`#${v}`)?!1:/过期|已处理|未找到/.test(e.content));e&&(i(`stale`),d(e.content))},[r,n,v,s]);let y=async e=>{if(!v||r!==`pending`)return;let n=Date.now();await t(v,e)&&(i(`submitted`),o(e),l(n))};if(r===`stale`)return(0,N.jsxs)(`div`,{className:`chat-approval-card chat-approval-stale surface-panel rounded-xl px-4 py-3 text-sm opacity-70`,"data-testid":`approval-card`,"data-state":`stale`,children:[(0,N.jsxs)(`div`,{className:`mb-1 text-[11px] uppercase tracking-[0.16em] text-[var(--app-kicker)]`,children:[`approval · #`,v]}),(0,N.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e.content}),(0,N.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-md bg-[var(--app-warning-soft-bg)] px-2 py-1 text-xs font-medium text-[var(--app-warning-soft-text)]`,children:[(0,N.jsx)(_,{size:12,"aria-hidden":`true`}),u]})]});if(r===`submitted`){let t=s?new Date(s).toLocaleTimeString([],{hour12:!1,hour:`2-digit`,minute:`2-digit`}):``;return(0,N.jsxs)(`div`,{className:`chat-approval-card chat-approval-resolved surface-panel rounded-xl px-4 py-3 text-sm opacity-60`,"data-testid":`approval-card`,"data-state":`submitted`,children:[(0,N.jsxs)(`div`,{className:`mb-1 text-[11px] uppercase tracking-[0.16em] text-[var(--app-kicker)]`,children:[`approval · #`,v]}),(0,N.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e.content}),(0,N.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-md bg-[var(--app-success-soft-bg)] px-2 py-1 text-xs font-medium text-[var(--app-success-soft-text)]`,children:[(0,N.jsx)(p,{size:12,"aria-hidden":`true`}),`已提交「`,a,`」 `,t]})]})}return(0,N.jsxs)(`div`,{className:S(`chat-approval-card surface-panel-elevated rounded-xl px-4 py-3 text-sm`),"data-testid":`approval-card`,"data-state":`pending`,"data-shape":g,children:[(0,N.jsxs)(`div`,{className:`mb-1 text-[11px] uppercase tracking-[0.16em] text-[var(--app-kicker)]`,children:[`approval · #`,v]}),(0,N.jsx)(`div`,{className:`mb-3 text-[var(--app-text)]`,children:e.content}),g===`yes_no`?(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsxs)(C,{size:`sm`,onClick:()=>void y(`批准`),"aria-label":`Approve`,"data-testid":`approve-button`,children:[(0,N.jsx)(p,{size:14,"aria-hidden":`true`}),`批准`]}),(0,N.jsxs)(C,{size:`sm`,variant:`secondary`,onClick:()=>void y(`拒绝`),"aria-label":`Reject`,"data-testid":`reject-button`,children:[(0,N.jsx)(m,{size:14,"aria-hidden":`true`}),`拒绝`]})]}):null,g===`choose_one`?(0,N.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,N.jsx)(C,{size:`sm`,onClick:()=>void y(`批准`),"data-testid":`approve-button`,children:`批准`}),(0,N.jsx)(C,{size:`sm`,variant:`secondary`,onClick:()=>void y(`拒绝`),"data-testid":`reject-button`,children:`拒绝`})]}):null,g===`free_input`?(0,N.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,N.jsx)(`input`,{type:`text`,value:f,onChange:e=>h(e.target.value),className:`flex-1 rounded-lg border border-[var(--app-border)] bg-white/[0.04] px-3 py-2 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-border-strong)] focus:outline-none focus:ring-1 focus:ring-[var(--app-accent)]`,placeholder:`输入回复...`,"data-testid":`free-input`}),(0,N.jsxs)(C,{size:`sm`,onClick:()=>void y(f.trim()),disabled:!f.trim(),"data-testid":`submit-button`,children:[(0,N.jsx)(c,{size:14,"aria-hidden":`true`}),`提交`]})]}):null,(0,N.jsxs)(`div`,{className:`mt-2 text-[11px] text-[var(--app-text-subtle)]`,children:[`看不到按钮?回 #`,v,` 表态。`]})]})}function W({message:e}){return(0,N.jsxs)(`div`,{className:`chat-system-note flex items-center gap-2 rounded border-l-2 border-[var(--app-text-subtle)] bg-white/[0.02] px-3 py-1.5 text-xs italic text-[var(--app-text-subtle)]`,"data-testid":`system-note`,role:`note`,children:[(0,N.jsx)(`span`,{className:`select-none`,children:`●`}),(0,N.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:e.content})]})}function G({message:e}){return(0,N.jsxs)(`div`,{className:`chat-audit-note flex items-start gap-2 rounded border-l-2 border-amber-500/70 bg-amber-500/[0.06] px-3 py-2 text-xs text-[var(--app-text-subtle)]`,"data-testid":`audit-note`,role:`note`,children:[(0,N.jsx)(`span`,{className:`select-none text-amber-500`,children:`⚠️`}),(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(`div`,{className:`mb-0.5 font-medium uppercase tracking-[0.12em] text-amber-500/90`,children:`自检 · 审计边车`}),(0,N.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:e.content})]})]})}function K({message:e}){switch(e.kind??(e.role===`user`?`user_message`:`assistant_text`)){case`status_report`:return(0,N.jsx)(P,{message:e});case`result_delivery`:return(0,N.jsx)(H,{message:e});case`approval_prompt`:return(0,N.jsx)(U,{message:e});case`system_note`:return(0,N.jsx)(W,{message:e});case`audit_note`:return(0,N.jsx)(G,{message:e});default:return(0,N.jsx)(q,{message:e})}}function q({message:e}){let t=e.role===`user`,n=t?`You`:e.taskId?`Adam · execution`:`Adam`;return(0,N.jsx)(`div`,{className:S(`flex`,t?`justify-end`:`justify-start`),children:(0,N.jsxs)(`div`,{className:S(`max-w-[85%] rounded-lg px-4 py-3 text-sm leading-7 shadow-[var(--app-shadow-md)]`,t?`surface-accent text-white`:`surface-panel text-[var(--app-text)]`),children:[(0,N.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-[11px] uppercase tracking-[0.16em]`,children:[(0,N.jsx)(`span`,{className:t?`text-white/70`:`text-[var(--app-kicker)]`,children:n}),(0,N.jsx)(`span`,{className:t?`text-white/45`:`text-[var(--app-text-subtle)]`,children:D(typeof e.createdAt==`number`?e.createdAt:new Date(e.createdAt).getTime())})]}),(0,N.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:e.content})]})})}function J({onSend:e,disabled:t,placeholder:n=`Type a message...`,starterActions:r=[],showStarterActions:i=!0,compact:a=!1}){let[o,s]=(0,j.useState)(``),l=(0,j.useRef)(null),u=()=>{let n=o.trim();!n||t||(e(n),s(``),l.current&&(l.current.style.height=`auto`))},d=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),u())},f=()=>{let e=l.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,120)}px`)};return(0,N.jsxs)(`div`,{className:a?`rounded-xl border border-[var(--app-border)] bg-white/[0.03] p-3`:`surface-panel-elevated rounded-xl p-3`,children:[i&&r.length>0?(0,N.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:r.map(e=>(0,N.jsx)(`button`,{type:`button`,onClick:()=>{s(e.value),requestAnimationFrame(()=>l.current?.focus())},className:`rounded-full border border-[var(--app-border)] bg-white/[0.04] px-3 py-1.5 text-xs font-medium text-[var(--app-text-muted)] transition-colors hover:border-[var(--app-border-strong)] hover:text-[var(--app-text)]`,children:e.label},e.label))}):null,(0,N.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,N.jsx)(`textarea`,{ref:l,value:o,onChange:e=>{s(e.target.value),f()},onKeyDown:d,placeholder:n,disabled:t,rows:1,className:`min-h-12 flex-1 resize-none rounded-lg border border-[var(--app-border)] bg-white/[0.04] px-4 py-3 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-border-strong)] focus:outline-none focus:ring-1 focus:ring-[var(--app-accent)] disabled:opacity-50`}),(0,N.jsxs)(C,{onClick:u,disabled:t||!o.trim(),size:`default`,"aria-label":`Send message`,children:[(0,N.jsx)(c,{size:16}),`Send`]})]}),(0,N.jsx)(`div`,{className:`mt-2 text-xs text-[var(--app-text-subtle)]`,children:`Enter to send; Shift+Enter for a new line.`})]})}function Y({session:e,isActive:n,onSelect:r,onArchive:i,onRestore:a,onDelete:o}){let s=e.status===`archived`,c=(e,t)=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),t())};return(0,N.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:r,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())},className:S(`group flex w-full flex-col gap-1 rounded-lg border px-3 py-3 text-left transition-colors`,n?`border-[var(--app-border-strong)] bg-white/[0.08] text-[var(--app-text)]`:`border-transparent text-[var(--app-text-muted)] hover:border-[var(--app-border)] hover:bg-white/[0.04] hover:text-[var(--app-text)]`,s&&`opacity-60`),"aria-label":e.title??e.id.slice(0,8),children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.title??e.id.slice(0,8)}),(0,N.jsxs)(`div`,{className:S(`flex gap-0.5 transition-opacity`,n?`opacity-100`:`opacity-100 lg:opacity-0 lg:group-hover:opacity-100 lg:group-focus-within:opacity-100`),children:[s?(0,N.jsx)(C,{variant:`ghost`,size:`icon`,className:`h-6 w-6 text-[var(--app-text-subtle)] hover:text-[var(--app-success)]`,onClick:e=>{e.stopPropagation(),a()},onKeyDown:e=>c(e,a),title:`Restore session`,"aria-label":`Restore session`,children:(0,N.jsx)(t,{size:k.xs})}):(0,N.jsx)(C,{variant:`ghost`,size:`icon`,className:`h-6 w-6 text-[var(--app-text-subtle)] hover:text-[var(--app-warning)]`,onClick:e=>{e.stopPropagation(),i()},onKeyDown:e=>c(e,i),title:`Archive session`,"aria-label":`Archive session`,children:(0,N.jsx)(y,{size:k.xs})}),(0,N.jsx)(C,{variant:`ghost`,size:`icon`,className:`h-6 w-6 text-[var(--app-text-subtle)] hover:text-[var(--app-danger)]`,onClick:e=>{e.stopPropagation(),o()},onKeyDown:e=>c(e,o),title:`Delete session`,"aria-label":`Delete session`,children:(0,N.jsx)(f,{size:k.xs})})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-[var(--app-text-subtle)]`,children:[(0,N.jsxs)(`span`,{children:[e.messageCount,` turns`]}),(0,N.jsx)(`span`,{children:D(e.lastActiveAt)}),s&&(0,N.jsx)(`span`,{className:`rounded-full border border-[var(--app-border)] bg-white/[0.04] px-1.5 py-0.5 text-[9px] uppercase tracking-[0.16em]`,children:`archived`})]})]})}function X({sessions:e,activeSessionId:t,onSelectSession:r,onNewSession:i,onArchiveSession:a,onRestoreSession:o,onDeleteSession:s,onClose:c}){let{recentSessions:l,earlierSessions:u,archivedSessions:d,activeSessions:f}=(0,j.useMemo)(()=>{let t=Date.now(),n=1440*60*1e3,r=e.filter(e=>e.status===`active`);return{recentSessions:r.filter(e=>t-e.lastActiveAt<n),earlierSessions:r.filter(e=>t-e.lastActiveAt>=n),archivedSessions:e.filter(e=>e.status===`archived`),activeSessions:r}},[e]);return(0,N.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--app-border)] px-4 py-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`span`,{className:`text-section-label`,children:`Sessions`}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-subtle)]`,children:`Switch context or reopen archived work.`})]}),(0,N.jsxs)(C,{variant:`ghost`,size:`sm`,onClick:i,"aria-label":`New session`,children:[(0,N.jsx)(n,{size:14}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`New`})]})]}),(0,N.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-2 py-2`,children:[f.length===0&&d.length===0&&(0,N.jsx)(`div`,{className:`px-2 py-6 text-center text-xs text-[var(--app-text-subtle)]`,children:`No sessions yet`}),l.length>0&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{className:`mb-2 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-[var(--app-text-subtle)]`,children:`Today`}),(0,N.jsx)(`div`,{className:`space-y-1`,children:l.map(e=>(0,N.jsx)(Y,{session:e,isActive:e.id===t,onSelect:()=>{r(e.id),c?.()},onArchive:()=>a(e.id),onRestore:()=>o(e.id),onDelete:()=>s(e.id)},e.id))})]}),u.length>0&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{className:`mb-2 mt-4 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-[var(--app-text-subtle)]`,children:`Earlier`}),(0,N.jsx)(`div`,{className:`space-y-1`,children:u.map(e=>(0,N.jsx)(Y,{session:e,isActive:e.id===t,onSelect:()=>{r(e.id),c?.()},onArchive:()=>a(e.id),onRestore:()=>o(e.id),onDelete:()=>s(e.id)},e.id))})]}),d.length>0&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{className:`mb-2 mt-4 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-[var(--app-text-subtle)]`,children:`Archived`}),(0,N.jsx)(`div`,{className:`space-y-1`,children:d.map(e=>(0,N.jsx)(Y,{session:e,isActive:e.id===t,onSelect:()=>{r(e.id),c?.()},onArchive:()=>a(e.id),onRestore:()=>o(e.id),onDelete:()=>s(e.id)},e.id))})]})]})]})}var Z=(e,t)=>`chat:thread-fold:${e}:${t}`;function ne(e){let t=e.some(e=>e.kind===`result_delivery`),n=e.some(e=>e.kind===`approval_prompt`);return!t||n}function re({sessionId:e,threadRoot:t,messages:n,children:r}){let i=ne(n),a=Z(e,t),[o,s]=(0,j.useState)(()=>{if(typeof window>`u`)return!i;let e=window.localStorage.getItem(a);return e===`1`?!0:e===`0`?!1:!i});(0,j.useEffect)(()=>{try{window.localStorage.setItem(a,o?`1`:`0`)}catch{}},[o,a]);let c=n.find(e=>e.kind===`user_message`)??n[0],l=n.find(e=>e.taskId)?.taskId,u=n.find(e=>e.roleId)?.roleId,d=B(u),f=V(l),p=(c?.content??``).slice(0,30)+((c?.content?.length??0)>30?`...`:``);return(0,N.jsxs)(`div`,{className:S(`chat-thread-container relative rounded-xl border border-[var(--app-border)] bg-white/[0.015] pl-3`),"data-testid":`thread-container`,"data-thread-root":t,"data-collapsed":o?`1`:`0`,children:[(0,N.jsx)(`div`,{className:`absolute left-0 top-0 h-full w-1 rounded-l-xl`,style:{background:d},"aria-hidden":`true`}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>s(!o),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-xs uppercase tracking-[0.16em] text-[var(--app-text-muted)] transition-colors hover:text-[var(--app-text)]`,"aria-expanded":!o,"data-testid":`thread-toggle`,children:[(0,N.jsx)(g,{size:12,className:S(`transition-transform`,o&&`-rotate-90`),"aria-hidden":`true`}),(0,N.jsx)(`span`,{style:{color:d},children:f||`Thread`}),(0,N.jsx)(`span`,{className:`text-[var(--app-text-subtle)] normal-case tracking-normal`,children:p})]}),o?null:(0,N.jsx)(`div`,{className:`space-y-2 px-3 pb-3`,children:r})]})}var Q=[{label:`Debug a failure`,value:`Review the most recent failed task and explain the next fix.`},{label:`Summarize status`,value:`Summarize the current system status, blockers, and active work.`},{label:`Plan a task`,value:`Break down the next implementation task into a concrete execution plan.`}];function ie(){let e=M(e=>e.sessions),t=M(e=>e.activeSessionId),a=M(e=>e.messages),o=M(e=>e.sending),c=M(e=>e.fetchSessions),l=M(e=>e.sendMessage),d=M(e=>e.createSession),f=M(e=>e.archiveSession),p=M(e=>e.restoreSession),g=M(e=>e.deleteSession),_=M(e=>e.setActiveSession),v=M(e=>e.connectChatStream),y=M(e=>e.disconnectChatStream),b=(0,j.useRef)(null),[x,S]=(0,j.useState)(!1),w=A(1024),T=e.filter(e=>e.status===`active`),D=e.filter(e=>e.status===`archived`),P=e.length>0,I=a.length>0,L=e.find(e=>e.id===t)??null;(0,j.useEffect)(()=>{c()},[c]),(0,j.useEffect)(()=>(v(),()=>y()),[v,y]),(0,j.useEffect)(()=>{b.current?.scrollIntoView?.({behavior:`smooth`})},[a]),(0,j.useEffect)(()=>{w||S(!1)},[w]),(0,j.useEffect)(()=>{if(t||e.length===0)return;let n=[...e].filter(e=>e.status===`active`).sort((e,t)=>t.lastActiveAt-e.lastActiveAt)[0]??[...e].sort((e,t)=>t.lastActiveAt-e.lastActiveAt)[0];n&&_(n.id)},[t,e,_]);let R=async e=>{await l(e)};return(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-5`,children:[(0,N.jsx)(E,{title:`Chat`,description:P?`Resume the latest session, inspect context, and keep the composer in view.`:`Start the first session and use Adam as the working surface for review, debugging, and planning.`,compact:!0,className:`px-4 py-3 lg:px-4 lg:py-3`,actions:(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsxs)(C,{variant:`secondary`,size:`sm`,onClick:()=>void d(),children:[(0,N.jsx)(n,{size:14}),`New Session`]}),(0,N.jsxs)(C,{variant:`secondary`,size:`sm`,className:`lg:hidden`,onClick:()=>S(!0),"aria-label":`Manage sessions`,children:[(0,N.jsx)(i,{size:16}),`Sessions`]})]})}),x?(0,N.jsxs)(`div`,{className:`fixed inset-0 z-40 lg:hidden`,role:`dialog`,"aria-modal":`true`,"aria-label":`Session manager`,children:[(0,N.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:()=>S(!1)}),(0,N.jsxs)(`div`,{className:`relative z-50 h-full w-full max-w-sm border-r border-[var(--app-border)] bg-[var(--app-canvas)] shadow-[var(--app-shadow-lg)]`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--app-border)] px-4 py-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{className:`text-section-label`,children:`Sessions`}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-subtle)]`,children:`Switch, archive, restore, or start a new conversation.`})]}),(0,N.jsx)(C,{variant:`ghost`,size:`icon`,onClick:()=>S(!1),"aria-label":`Close session manager`,children:(0,N.jsx)(m,{size:16})})]}),(0,N.jsx)(X,{sessions:e,activeSessionId:t,onSelectSession:_,onNewSession:()=>{d(),S(!1)},onArchiveSession:e=>void f(e),onRestoreSession:e=>void p(e),onDeleteSession:e=>void g(e),onClose:()=>S(!1)})]})]}):null,(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden rounded-xl border border-[var(--app-border)] bg-[color-mix(in_oklch,var(--app-canvas)_88%,transparent)] shadow-[var(--app-shadow-lg)]`,children:[(0,N.jsx)(`div`,{className:`hidden w-72 flex-shrink-0 border-r border-[var(--app-border)] bg-[color-mix(in_oklch,var(--app-canvas)_90%,transparent)] lg:block`,children:(0,N.jsx)(X,{sessions:e,activeSessionId:t,onSelectSession:_,onNewSession:()=>void d(),onArchiveSession:e=>void f(e),onRestoreSession:e=>void p(e),onDeleteSession:e=>void g(e)})}),(0,N.jsxs)(`div`,{className:`flex flex-1 flex-col`,children:[(0,N.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 py-4 lg:px-6`,children:I?(0,N.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-3`,children:[te(a).map(e=>{if(e.threadRoot===null)return e.messages.map(e=>(0,N.jsx)(K,{message:e},e.id));let n=ee(e.messages);return(0,N.jsx)(re,{sessionId:t??``,threadRoot:e.threadRoot,messages:e.messages,children:n.map((e,t)=>e.type===`single`?(0,N.jsx)(K,{message:e.message},e.message.id):(0,N.jsx)(F,{messages:e.messages},`status-group-${t}-${e.messages[0]?.id??``}`))},e.threadRoot)}),(0,N.jsx)(`div`,{ref:b})]}):P?(0,N.jsx)(`div`,{className:`mx-auto flex h-full w-full max-w-4xl items-start`,children:(0,N.jsxs)(`div`,{className:`surface-panel-muted flex w-full flex-col gap-4 rounded-xl p-5`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,N.jsxs)(`div`,{className:`space-y-1`,children:[(0,N.jsx)(`p`,{className:`text-kicker`,children:`Working Surface`}),(0,N.jsx)(`h2`,{className:`text-xl font-semibold text-[var(--app-text)]`,children:L?`Session ${L.title??L.id.slice(0,8)}`:`Pick a session to continue`}),(0,N.jsx)(`p`,{className:`max-w-2xl text-sm leading-6 text-[var(--app-text-muted)]`,children:L?`This session has no loaded transcript yet. Continue here or start a new thread without leaving the page.`:`Archived history exists, but no session is active. Select one from the rail or start a new conversation.`})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-[var(--app-text-subtle)]`,children:[(0,N.jsxs)(`span`,{children:[T.length,` active`]}),(0,N.jsxs)(`span`,{children:[D.length,` archived`]})]})]}),(0,N.jsx)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:Q.map(e=>(0,N.jsxs)(`button`,{type:`button`,onClick:()=>void R(e.value),className:`rounded-xl border border-[var(--app-border)] bg-white/[0.03] p-4 text-left transition-colors hover:border-[var(--app-border-strong)] hover:bg-white/[0.05]`,children:[(0,N.jsx)(`div`,{className:`text-sm font-semibold text-[var(--app-text)]`,children:e.label}),(0,N.jsx)(`div`,{className:`mt-1 text-sm leading-6 text-[var(--app-text-muted)]`,children:e.value})]},e.label))})]})}):(0,N.jsx)(O,{icon:(0,N.jsx)(r,{size:k.hero}),title:`Start a conversation with Adam`,description:`Use the starter prompts below to inspect recent work, diagnose failures, or create an execution plan.`,className:`h-full min-h-[24rem]`,action:(0,N.jsxs)(`div`,{className:`grid gap-3 text-left sm:grid-cols-3`,children:[(0,N.jsx)($,{icon:s,title:`Inspect live status`,description:`Summarize active work, risk, and recent changes.`}),(0,N.jsx)($,{icon:u,title:`Dig into a task`,description:`Review recent execution output and the next concrete step.`}),(0,N.jsx)($,{icon:h,title:`Recover context`,description:`Continue from the latest session without losing history.`})]})})}),(0,N.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-4 pb-4 lg:px-6`,children:(0,N.jsx)(J,{onSend:R,disabled:o,starterActions:Q,showStarterActions:!P&&!I,compact:P})})]})]})]})}function $({icon:e,title:t,description:n}){return(0,N.jsxs)(`div`,{className:`surface-panel-muted rounded-lg p-4`,children:[(0,N.jsx)(`div`,{className:`mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white/[0.05] text-[var(--app-kicker)]`,children:(0,N.jsx)(e,{size:k.lg})}),(0,N.jsx)(`div`,{className:`text-sm font-semibold text-[var(--app-text)]`,children:t}),(0,N.jsx)(`div`,{className:`mt-1 text-sm leading-6 text-[var(--app-text-muted)]`,children:n})]})}export{ie as Chat};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{ft as t,lt as n,pt as r,w as i,xt as a}from"./vendor-icons-Bc_e_XXa.js";import{h as o,t as s}from"./vendor-react-bQ_cvNuA.js";import{r as c}from"./dist-CgGno8kE.js";import{t as l}from"./Button-CRNb8sD3.js";import{c as u,l as d}from"./api-BP4ZP9kk.js";import{f,t as p}from"./index-CXEJd-0s.js";import{t as m}from"./Card-Cwvv0An8.js";import{t as h}from"./PageHeader-acLQTYct.js";import{t as g}from"./EmptyState-BvQA1o5K.js";import{$ as _,A as v,B as y,Ct as b,D as x,Dt as S,E as C,Et as ee,G as w,H as T,I as E,J as te,K as D,L as ne,M as O,N as k,O as A,R as j,S as re,St as M,T as ie,Tt as N,U as P,V as F,W as I,X as ae,Y as oe,Z as se,_ as L,_t as R,a as ce,at as le,b as ue,c as de,ct as fe,dt as pe,et as me,ft as he,g as ge,gt as _e,h as ve,ht as ye,i as be,it as xe,j as Se,lt as Ce,m as we,mt as Te,n as Ee,nt as De,o as Oe,ot as ke,p as Ae,pt as je,q as Me,r as Ne,rt as Pe,s as Fe,st as z,t as Ie,tt as Le,ut as B,v as Re,vt as ze,wt as V,x as Be,xt as H,y as Ve,yt as He,z as Ue}from"./LineChart-Ck1vfYHs.js";var U=e(a());function W(){return W=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},W.apply(null,arguments)}function We(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ge(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?We(Object(n),!0).forEach(function(t){Ke(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):We(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ke(e,t,n){return(t=qe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function qe(e){var t=Je(e,`string`);return typeof t==`symbol`?t:t+``}function Je(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var G=32,Ye={align:`center`,iconSize:14,inactiveColor:`#ccc`,layout:`horizontal`,verticalAlign:`middle`,labelStyle:{}};function Xe(e){if(typeof e==`object`&&e&&`strokeDasharray`in e)return String(e.strokeDasharray)}function Ze(e){var{data:t,iconType:n,inactiveColor:r}=e,i=G/2,a=G/6,o=G/3,s=t.inactive?r:t.color,c=n??t.type;if(c===`none`)return null;if(c===`plainline`)return U.createElement(`line`,{strokeWidth:4,fill:`none`,stroke:s,strokeDasharray:Xe(t.payload),x1:0,y1:i,x2:G,y2:i,className:`recharts-legend-icon`});if(c===`line`)return U.createElement(`path`,{strokeWidth:4,fill:`none`,stroke:s,d:`M0,${i}h${o}
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{ft as t,lt as n,pt as r,w as i,xt as a}from"./vendor-icons-Bc_e_XXa.js";import{h as o,t as s}from"./vendor-react-bQ_cvNuA.js";import{r as c}from"./dist-CgGno8kE.js";import{t as l}from"./Button-CRNb8sD3.js";import{c as u,l as d}from"./api-BP4ZP9kk.js";import{f,t as p}from"./index-Dd3NDYZR.js";import{t as m}from"./Card-Cwvv0An8.js";import{t as h}from"./PageHeader-acLQTYct.js";import{t as g}from"./EmptyState-BvQA1o5K.js";import{$ as _,A as v,B as y,Ct as b,D as x,Dt as S,E as C,Et as ee,G as w,H as T,I as E,J as te,K as D,L as ne,M as O,N as k,O as A,R as j,S as re,St as M,T as ie,Tt as N,U as P,V as F,W as I,X as ae,Y as oe,Z as se,_ as L,_t as R,a as ce,at as le,b as ue,c as de,ct as fe,dt as pe,et as me,ft as he,g as ge,gt as _e,h as ve,ht as ye,i as be,it as xe,j as Se,lt as Ce,m as we,mt as Te,n as Ee,nt as De,o as Oe,ot as ke,p as Ae,pt as je,q as Me,r as Ne,rt as Pe,s as Fe,st as z,t as Ie,tt as Le,ut as B,v as Re,vt as ze,wt as V,x as Be,xt as H,y as Ve,yt as He,z as Ue}from"./LineChart-Ck1vfYHs.js";var U=e(a());function W(){return W=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},W.apply(null,arguments)}function We(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ge(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?We(Object(n),!0).forEach(function(t){Ke(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):We(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ke(e,t,n){return(t=qe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function qe(e){var t=Je(e,`string`);return typeof t==`symbol`?t:t+``}function Je(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var G=32,Ye={align:`center`,iconSize:14,inactiveColor:`#ccc`,layout:`horizontal`,verticalAlign:`middle`,labelStyle:{}};function Xe(e){if(typeof e==`object`&&e&&`strokeDasharray`in e)return String(e.strokeDasharray)}function Ze(e){var{data:t,iconType:n,inactiveColor:r}=e,i=G/2,a=G/6,o=G/3,s=t.inactive?r:t.color,c=n??t.type;if(c===`none`)return null;if(c===`plainline`)return U.createElement(`line`,{strokeWidth:4,fill:`none`,stroke:s,strokeDasharray:Xe(t.payload),x1:0,y1:i,x2:G,y2:i,className:`recharts-legend-icon`});if(c===`line`)return U.createElement(`path`,{strokeWidth:4,fill:`none`,stroke:s,d:`M0,${i}h${o}
2
2
  A${a},${a},0,1,1,${2*o},${i}
3
3
  H${G}M${2*o},${i}
4
4
  A${a},${a},0,1,1,${o},${i}`,className:`recharts-legend-icon`});if(c===`rect`)return U.createElement(`path`,{stroke:`none`,fill:s,d:`M0,${G/8}h${G}v${G*3/4}h${-G}z`,className:`recharts-legend-icon`});if(U.isValidElement(t.legendIcon)){var l=Ge({},t);return delete l.legendIcon,U.cloneElement(t.legendIcon,l)}return U.createElement(_e,{fill:s,cx:i,cy:i,size:G,sizeType:`diameter`,type:c})}function Qe(e){var{payload:t,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:o,labelStyle:s}=e,l={x:0,y:0,width:G,height:G},u={display:r===`horizontal`?`inline-block`:`block`,marginRight:10},d={display:`inline-block`,verticalAlign:`middle`,marginRight:4};return t.map((t,r)=>{var f=t.formatter||i,p=c({"recharts-legend-item":!0,[`legend-item-${r}`]:!0,inactive:t.inactive});if(t.type===`none`)return null;var m=typeof s==`object`?Ge({},s):{};m.color=t.inactive?a:m.color||t.color;var h=f?f(t.value,t,r):t.value;return U.createElement(`li`,W({className:p,style:u,key:`legend-item-${r}`},ye(e,t,r)),U.createElement(N,{width:n,height:n,viewBox:l,style:d,"aria-label":`${t.value} legend icon`},U.createElement(Ze,{data:t,iconType:o,inactiveColor:a})),U.createElement(`span`,{className:`recharts-legend-item-text`,style:m},h))})}var $e=e=>{var t=Te(e,Ye),{payload:n,layout:r,align:i}=t;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r===`horizontal`?i:`left`};return U.createElement(`ul`,{className:`recharts-default-legend`,style:a},U.createElement(Qe,W({},t,{payload:n})))};function et(){return he(Ce)}var tt=e(o()),nt=[`contextPayload`];function rt(){return rt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},rt.apply(null,arguments)}function it(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function K(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?it(Object(n),!0).forEach(function(t){at(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):it(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function at(e,t,n){return(t=ot(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ot(e){var t=st(e,`string`);return typeof t==`symbol`?t:t+``}function st(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ct(e,t){if(e==null)return{};var n,r,i=lt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function lt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function ut(e){return e.value}function dt(e){var{contextPayload:t}=e,n=ct(e,nt),r=je(t,e.payloadUniqBy,ut),i=K(K({},n),{},{payload:r});return U.isValidElement(e.content)?U.cloneElement(e.content,i):typeof e.content==`function`?U.createElement(e.content,i):U.createElement($e,i)}function ft(e,t,n,r,i,a){var{layout:o,align:s,verticalAlign:c}=t,l,u;return(!e||(e.left===void 0||e.left===null)&&(e.right===void 0||e.right===null))&&(l=s===`center`&&o===`vertical`?{left:((r||0)-a.width)/2}:s===`right`?{right:n&&n.right||0}:{left:n&&n.left||0}),(!e||(e.top===void 0||e.top===null)&&(e.bottom===void 0||e.bottom===null))&&(u=c===`middle`?{top:((i||0)-a.height)/2}:c===`bottom`?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),K(K({},l),u)}function pt(e){var t=pe();return(0,U.useEffect)(()=>{t(I(e))},[t,e]),null}function mt(e){var t=pe();return(0,U.useEffect)(()=>(t(w(e)),()=>{t(w({width:0,height:0}))}),[t,e]),null}function ht(e,t,n,r){return e===`vertical`&&t!=null?{height:t}:e===`horizontal`?{width:n||r}:null}var gt={align:`center`,iconSize:14,inactiveColor:`#ccc`,itemSorter:`value`,layout:`horizontal`,verticalAlign:`bottom`};function _t(e){var t=Te(e,gt),n=et(),r=b(),i=se(),{width:a,height:o,wrapperStyle:s,portal:c}=t,[l,u]=fe([n]),d=ae(),f=te();if(d==null||f==null)return null;var p=d-(i?.left||0)-(i?.right||0),m=ht(t.layout,o,a,p),h=c?s:K(K({position:`absolute`,width:m?.width||a||`auto`,height:m?.height||o||`auto`},ft(s,t,i,d,f,l)),s),g=c??r;return g==null||n==null?null:(0,tt.createPortal)(U.createElement(`div`,{className:`recharts-legend-wrapper`,style:h,ref:u},U.createElement(pt,{layout:t.layout,align:t.align,verticalAlign:t.verticalAlign,itemSorter:t.itemSorter}),!c&&U.createElement(mt,{width:l.width,height:l.height}),U.createElement(dt,rt({},t,m,{margin:i,chartWidth:d,chartHeight:f,contextPayload:n}))),g)}var vt=U.memo(_t,P);vt.displayName=`Legend`;function yt(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function bt(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var xt=(e,t,n)=>v(e,`xAxis`,yt(e,t),n),St=(e,t,n)=>O(e,`xAxis`,yt(e,t),n),Ct=(e,t,n)=>v(e,`yAxis`,bt(e,t),n),wt=(e,t,n)=>O(e,`yAxis`,bt(e,t),n),Tt=B([D,xt,Ct,St,wt],(e,t,n,r,i)=>ke(e,`xAxis`)?Le(t,r,!1):Le(n,i,!1)),Et=B([k,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),Dt=e=>ke(D(e),`xAxis`)?`yAxis`:`xAxis`,Ot=(e,t)=>Dt(e)===`yAxis`?bt(e,t):yt(e,t),kt=B([D,xt,Ct,St,wt,B([Et,(e,t,n)=>Se(e,Dt(e),Ot(e,t),n)],(e,t)=>{if(!(e==null||t==null)){var{stackId:n}=e,r=E(e);if(!(n==null||r==null)){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),Ue,Tt,Et,j],(e,t,n,r,i,a,o,s,c,l)=>{var{chartData:u,dataStartIndex:d,dataEndIndex:f}=o;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var{data:p}=c,m=p&&p.length>0?p:u?.slice(d,f+1);if(m!=null)return Qt({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:d,areaSettings:c,stackedData:a,displayedData:m,chartBaseValue:l,bandSize:s})}}),At=[`id`],jt=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function q(){return q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},q.apply(null,arguments)}function Mt(e,t){if(e==null)return{};var n,r,i=Nt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Nt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Pt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function J(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Pt(Object(n),!0).forEach(function(t){Ft(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ft(e,t,n){return(t=It(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function It(e){var t=Lt(e,`string`);return typeof t==`symbol`?t:t+``}function Lt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Y(e,t){return e&&e!==`none`?e:t}var Rt=e=>{var{dataKey:t,name:n,stroke:r,fill:i,legendType:a,hide:o}=e;return[{inactive:o,dataKey:t,type:a,color:Y(r,i),value:xe(n,t),payload:e}]},zt=U.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:M,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:xe(o,t),hide:s,type:l,color:Y(r,a),unit:c,graphicalItemId:u}};return U.createElement(Ve,{tooltipEntrySettings:d})});function Bt(e){var{clipPathId:t,points:n,props:r}=e,{needClip:i,dot:a,dataKey:o}=r,s=S(r);return U.createElement(ve,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function Vt(e){var{showLabels:t,children:n,points:r}=e,i=r.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return J(J({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return U.createElement(Be,{value:t?i:void 0},n)}function Ht(e){var{points:t,baseLine:n,needClip:r,clipPathId:i,props:a}=e,{layout:o,type:s,stroke:c,connectNulls:l,isRange:u}=a,{id:d}=a,f=Mt(a,At),p=S(f),m=ee(f);return U.createElement(U.Fragment,null,t?.length>1&&U.createElement(V,{clipPath:r?`url(#clipPath-${i})`:void 0},U.createElement(T,q({},m,{id:d,points:t,connectNulls:l,type:s,baseLine:n,layout:o,stroke:`none`,className:`recharts-area-area`})),c!==`none`&&U.createElement(T,q({},p,{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:t})),c!==`none`&&u&&Array.isArray(n)&&U.createElement(T,q({},p,{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:n}))),U.createElement(Bt,{points:t,props:f,clipPathId:i}))}function Ut(e){var{alpha:t,baseLine:n,points:r,strokeWidth:i}=e,a=r[0]?.y,o=r[r.length-1]?.y;if(!z(a)||!z(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return H(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),H(c)?U.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function Wt(e){var{alpha:t,baseLine:n,points:r,strokeWidth:i}=e,a=r[0]?.x,o=r[r.length-1]?.x;if(!z(a)||!z(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return H(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),H(c)?U.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function Gt(e){var{alpha:t,layout:n,points:r,baseLine:i,strokeWidth:a}=e;return n===`vertical`?U.createElement(Ut,{alpha:t,points:r,baseLine:i,strokeWidth:a}):U.createElement(Wt,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function Kt(e){var{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=e,{points:o,baseLine:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,onAnimationStart:f,onAnimationEnd:p}=r,m=y((0,U.useMemo)(()=>({points:o,baseLine:s}),[o,s]),`recharts-area-`),h=Me(),[g,_]=(0,U.useState)(!1),v=!g,b=(0,U.useCallback)(()=>{typeof p==`function`&&p(),_(!1)},[p]),x=(0,U.useCallback)(()=>{typeof f==`function`&&f(),_(!0)},[f]);if(h==null)return null;var S=i.current,C=a.current;return U.createElement(Vt,{showLabels:v,points:o},r.children,U.createElement(F,{animationId:m,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:b,onAnimationStart:x,key:m},e=>{if(S){var l=S.length/o.length,u=e===1?o:o.map((t,n)=>{var r=Math.floor(n*l);if(S[r]){var i=S[r];return J(J({},t),{},{x:R(i.x,t.x,e),y:R(i.y,t.y,e)})}return t}),d=H(s)?R(C,s,e):He(s)||ze(s)?R(C,0,e):s.map((t,n)=>{var r=Math.floor(n*l);if(Array.isArray(C)&&C[r]){var i=C[r];return J(J({},t),{},{x:R(i.x,t.x,e),y:R(i.y,t.y,e)})}return t});return e>0&&(i.current=u,a.current=d),U.createElement(Ht,{points:u,baseLine:d,needClip:t,clipPathId:n,props:r})}return e>0&&(i.current=o,a.current=s),U.createElement(V,null,c&&U.createElement(`defs`,null,U.createElement(`clipPath`,{id:`animationClipPath-${n}`},U.createElement(Gt,{alpha:e,points:o,baseLine:s,layout:h,strokeWidth:r.strokeWidth}))),U.createElement(V,{clipPath:`url(#animationClipPath-${n})`},U.createElement(Ht,{points:o,baseLine:s,needClip:t,clipPathId:n,props:r})))}),U.createElement(re,{label:r.label}))}function qt(e){var{needClip:t,clipPathId:n,props:r}=e,i=(0,U.useRef)(null),a=(0,U.useRef)();return U.createElement(Kt,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var Jt=class extends U.PureComponent{render(){var{hide:e,dot:t,points:n,className:r,top:i,left:a,needClip:o,xAxisId:s,yAxisId:l,width:u,height:d,id:f,baseLine:p,zIndex:m}=this.props;if(e)return null;var h=c(`recharts-area`,r),g=f,{r:_,strokeWidth:v}=Oe(t),y=ue(t),b=_*2+v,S=o?`url(#clipPath-${y?``:`dots-`}${g})`:void 0;return U.createElement(x,{zIndex:m},U.createElement(V,{className:h},o&&U.createElement(`defs`,null,U.createElement(Fe,{clipPathId:g,xAxisId:s,yAxisId:l}),!y&&U.createElement(`clipPath`,{id:`clipPath-dots-${g}`},U.createElement(`rect`,{x:a-b/2,y:i-b/2,width:u+b,height:d+b}))),U.createElement(qt,{needClip:o,clipPathId:g,props:this.props})),U.createElement(Ae,{points:n,mainColor:Y(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:S}),this.props.isRange&&Array.isArray(p)&&U.createElement(Ae,{points:p,mainColor:Y(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:S}))}},Yt={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,xAxisId:0,yAxisId:0,zIndex:ne.area};function Xt(e){var{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,connectNulls:a,dot:o,fill:s,fillOpacity:c,hide:l,isAnimationActive:u,legendType:d,stroke:f,xAxisId:p,yAxisId:m}=e,h=Mt(e,jt),g=oe(),_=A(),{needClip:v}=de(p,m),y=me(),{points:b,isRange:x,baseLine:S}=he(t=>kt(t,e.id,y))??{},C=we();if(g!==`horizontal`&&g!==`vertical`||C==null||_!==`AreaChart`&&_!==`ComposedChart`)return null;var{height:ee,width:w,x:T,y:E}=C;return!b||!b.length?null:U.createElement(Jt,q({},h,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:S,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:ee,hide:l,layout:g,isAnimationActive:u,isRange:x,legendType:d,needClip:v,points:b,stroke:f,width:w,left:T,top:E,xAxisId:p,yAxisId:m}))}var Zt=(e,t,n,r,i)=>{var a=n??t;if(H(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function Qt(e){var{areaSettings:{connectNulls:t,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:o,xAxis:s,yAxis:c,displayedData:l,dataStartIndex:u,xAxisTicks:d,yAxisTicks:f,bandSize:p}=e,m=i&&i.length,h=Zt(a,o,n,s,c),g=a===`horizontal`,_=!1,v=l.map((e,n)=>{var a;if(m)a=i[u+n];else{var o=le(e,r);Array.isArray(o)?(a=o,_=!0):a=[h,o]}var l=a?.[1]??null,v=l==null||m&&!t&&le(e,r)==null;return g?{x:De({axis:s,ticks:d,bandSize:p,entry:e,index:n}),y:v?null:c.scale.map(l)??null,value:a,payload:e}:{x:v?null:s.scale.map(l)??null,y:De({axis:c,ticks:f,bandSize:p,entry:e,index:n}),value:a,payload:e}});return{points:v,baseLine:(m||_?v.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return g?{x:e.x,y:t!=null&&e.y!=null?c.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:s.scale.map(t)??null,y:e.y,payload:e.payload}}):g?c.scale.map(h):s.scale.map(h))??0,isRange:_}}function $t(e){var t=Te(e,Yt),n=me();return U.createElement(L,{id:t.id,type:`area`},e=>U.createElement(U.Fragment,null,U.createElement(Re,{legendPayload:Rt(t)}),U.createElement(zt,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),U.createElement(ge,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:Pe(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),U.createElement(Xt,q({},t,{id:e}))))}var en=U.memo($t,P);en.displayName=`Area`;var tn=[`axis`],nn=(0,U.forwardRef)((e,t)=>U.createElement(Ee,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:tn,tooltipPayloadSearcher:C,categoricalChartProps:e,ref:t})),X=s(),rn=-new Date().getTimezoneOffset(),Z=[`#6366f1`,`#10b981`,`#f59e0b`,`#ef4444`,`#06b6d4`,`#a855f7`,`#84cc16`,`#ec4899`];function Q(e){return e<1e-4?`$0.0000`:`$${e.toFixed(4)}`}function $(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function an(e,t,n){let r=Date.now();if(e===`today`){let e=new Date;return e.setHours(0,0,0,0),{from:e.getTime(),to:r}}return e===`7d`?{from:r-7*864e5,to:r}:e===`30d`?{from:r-30*864e5,to:r}:{from:t??r-864e5,to:n??r}}function on(){let e=f(e=>e.roles),a=f(e=>e.fetchRoles),[o,s]=(0,U.useState)(`7d`),[c,v]=(0,U.useState)(``),[y,b]=(0,U.useState)(``),[x,S]=(0,U.useState)(`day`),[C,ee]=(0,U.useState)(`model`),[w,T]=(0,U.useState)(`total`),[E,te]=(0,U.useState)(null),[D,ne]=(0,U.useState)(!0),[O,k]=(0,U.useState)(null),[A,j]=(0,U.useState)({}),[re,M]=(0,U.useState)({});(0,U.useEffect)(()=>{a()},[a]);let N=o===`custom`?{from:c?new Date(`${c}T00:00:00`).getTime():Date.now()-7*864e5,to:y?new Date(`${y}T23:59:59.999`).getTime():Date.now()}:void 0,{from:P,to:F}=an(o,N?.from,N?.to),I=(0,U.useCallback)(async()=>{ne(!0),k(null);try{te(await d({from:P,to:F,groupBy:C,granularity:x,tzOffsetMinutes:rn,...w===`total`?{}:{trendStackBy:w}}))}catch{te(null)}finally{ne(!1)}},[P,F,C,x,w]);(0,U.useEffect)(()=>{I()},[I]);let ae=t=>t===`system`?`System / non-role`:e.find(e=>e.id===t)?.name??t.slice(0,8),oe=e=>C===`role`?ae(e):e,se=async e=>{if(O===e){k(null);return}if(k(e),!A[e]){M(t=>({...t,[e]:!0}));try{let t=await u({groupBy:C,groupKey:e,from:P,to:F,tzOffsetMinutes:rn});j(n=>({...n,[e]:t}))}catch{j(t=>({...t,[e]:[]}))}finally{M(t=>({...t,[e]:!1}))}}},L=E&&(E.callCount>0||E.groups.length>0);return(0,X.jsxs)(`div`,{className:`space-y-5`,children:[(0,X.jsx)(h,{eyebrow:`Cost`,title:`Platform Spend`,compact:!0,description:`LLM cost breakdown by model, role, source, and date.`,metrics:[{label:`Total`,value:E?Q(E.totalCostUsd):`—`},{label:`Calls`,value:E?.callCount??`—`},{label:`Top Model`,value:E?.topModel??`—`}],actions:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[[`today`,`7d`,`30d`,`custom`].map(e=>(0,X.jsx)(`button`,{className:`rounded px-2 py-1 text-xs ${o===e?`bg-[var(--app-accent)] text-white`:`border border-[var(--app-border)] text-[var(--app-text-subtle)] hover:border-[var(--app-accent)]`}`,onClick:()=>s(e),children:e===`today`?`Today`:e===`7d`?`7 days`:e===`30d`?`30 days`:`Custom`},e)),o===`custom`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{type:`date`,"aria-label":`From date`,className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1 text-xs text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:c,onChange:e=>v(e.target.value)}),(0,X.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`→`}),(0,X.jsx)(`input`,{type:`date`,"aria-label":`To date`,className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1 text-xs text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:y,onChange:e=>b(e.target.value)})]}),(0,X.jsxs)(`select`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1 text-xs text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:x,onChange:e=>S(e.target.value),children:[(0,X.jsx)(`option`,{value:`day`,children:`Daily`}),(0,X.jsx)(`option`,{value:`week`,children:`Weekly`}),(0,X.jsx)(`option`,{value:`month`,children:`Monthly`})]}),(0,X.jsx)(l,{variant:`ghost`,size:`sm`,onClick:()=>void I(),children:(0,X.jsx)(i,{size:14})})]})}),E&&(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-6`,children:[(()=>{let e=(E.thresholdUsd??0)>0&&o===`today`&&E.totalCostUsd>(E.thresholdUsd??0);return(0,X.jsxs)(m,{className:`p-3`,children:[(0,X.jsx)(`p`,{className:`text-[10px] uppercase tracking-wide text-[var(--app-text-subtle)]`,children:`Total Spend`}),(0,X.jsx)(`p`,{className:`mt-1 text-2xl font-semibold ${e?`text-[var(--app-danger)]`:`text-[var(--app-text)]`}`,children:Q(E.totalCostUsd)}),e&&(0,X.jsxs)(p,{variant:`destructive`,className:`mt-1 text-[10px]`,children:[`over $`,(E.thresholdUsd??0).toFixed(2),` limit`]}),E.unpricedCallCount>0&&(0,X.jsxs)(p,{variant:`warning`,className:`mt-1 text-[10px]`,children:[E.unpricedCallCount,` call`,E.unpricedCallCount===1?``:`s`,` unpriced — cost unknown`]})]})})(),(0,X.jsxs)(m,{className:`p-3`,children:[(0,X.jsx)(`p`,{className:`text-[10px] uppercase tracking-wide text-[var(--app-text-subtle)]`,children:`Input Tokens`}),(0,X.jsx)(`p`,{className:`mt-1 text-2xl font-semibold text-[var(--app-text)]`,children:$(E.tokens.input)})]}),(0,X.jsxs)(m,{className:`p-3`,children:[(0,X.jsx)(`p`,{className:`text-[10px] uppercase tracking-wide text-[var(--app-text-subtle)]`,children:`Output Tokens`}),(0,X.jsx)(`p`,{className:`mt-1 text-2xl font-semibold text-[var(--app-text)]`,children:$(E.tokens.output)})]}),(0,X.jsxs)(m,{className:`p-3`,children:[(0,X.jsx)(`p`,{className:`text-[10px] uppercase tracking-wide text-[var(--app-text-subtle)]`,children:`Cache Read`}),(0,X.jsx)(`p`,{className:`mt-1 text-2xl font-semibold text-[var(--app-text)]`,children:$(E.tokens.cacheRead)})]}),(0,X.jsxs)(m,{className:`p-3`,children:[(0,X.jsx)(`p`,{className:`text-[10px] uppercase tracking-wide text-[var(--app-text-subtle)]`,children:`Cache Creation`}),(0,X.jsx)(`p`,{className:`mt-1 text-2xl font-semibold text-[var(--app-text)]`,children:$(E.tokens.cacheCreation)})]}),(0,X.jsxs)(m,{className:`p-3`,children:[(0,X.jsx)(`p`,{className:`text-[10px] uppercase tracking-wide text-[var(--app-text-subtle)]`,children:`LLM Calls`}),(0,X.jsx)(`p`,{className:`mt-1 text-2xl font-semibold text-[var(--app-text)]`,children:E.callCount}),E.topModel&&(0,X.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-[var(--app-text-subtle)]`,children:E.topModel})]})]}),L&&E&&E.trend.length>0&&(0,X.jsxs)(m,{children:[(0,X.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Spend Over Time`}),(0,X.jsx)(`div`,{className:`ml-auto flex items-center gap-1`,children:[[`total`,`Total`],[`source`,`By source`],[`model`,`By model`]].map(([e,t])=>(0,X.jsx)(`button`,{className:`rounded px-2 py-0.5 text-[11px] ${w===e?`bg-[var(--app-accent)] text-white`:`border border-[var(--app-border)] text-[var(--app-text-subtle)] hover:border-[var(--app-accent)]`}`,onClick:()=>T(e),children:t},e))})]}),(0,X.jsx)(_,{width:`100%`,height:180,children:w===`total`||!E.trendStacked||!E.trendStackKeys?(0,X.jsxs)(Ie,{data:E.trend,margin:{top:4,right:12,left:-10,bottom:4},children:[(0,X.jsx)(be,{dataKey:`bucket`,tick:{fontSize:10}}),(0,X.jsx)(Ne,{tick:{fontSize:10},tickFormatter:e=>`$${e.toFixed(3)}`}),(0,X.jsx)(ie,{formatter:e=>[Q(Number(e)),`Cost`],contentStyle:{fontSize:11}}),(0,X.jsx)(ce,{type:`monotone`,dataKey:`costUsd`,stroke:`var(--app-accent)`,strokeWidth:2,dot:!1})]}):(0,X.jsxs)(nn,{data:E.trendStacked,margin:{top:4,right:12,left:-10,bottom:4},children:[(0,X.jsx)(be,{dataKey:`bucket`,tick:{fontSize:10}}),(0,X.jsx)(Ne,{tick:{fontSize:10},tickFormatter:e=>`$${e.toFixed(3)}`}),(0,X.jsx)(ie,{formatter:(e,t)=>[Q(Number(e)),String(t)],contentStyle:{fontSize:11}}),(0,X.jsx)(vt,{wrapperStyle:{fontSize:10}}),E.trendStackKeys.map((e,t)=>(0,X.jsx)(en,{type:`monotone`,dataKey:e,stackId:`1`,stroke:Z[t%Z.length],fill:Z[t%Z.length],fillOpacity:.6},e))]})})]}),(0,X.jsxs)(m,{children:[(0,X.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Breakdown by`}),[`model`,`role`,`source`,`date`].map(e=>(0,X.jsx)(`button`,{className:`rounded px-2 py-0.5 text-xs ${C===e?`bg-[var(--app-accent)] text-white`:`border border-[var(--app-border)] text-[var(--app-text-subtle)] hover:border-[var(--app-accent)]`}`,onClick:()=>{ee(e),k(null)},children:e.charAt(0).toUpperCase()+e.slice(1)},e))]}),D?(0,X.jsx)(`div`,{className:`flex items-center justify-center py-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)]`})}):L?(0,X.jsx)(`div`,{className:`overflow-x-auto`,children:(0,X.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`border-b border-[var(--app-border)] text-left text-[var(--app-text-subtle)]`,children:[(0,X.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:C.charAt(0).toUpperCase()+C.slice(1)}),(0,X.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Cost`}),(0,X.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Calls`}),(0,X.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Input`}),(0,X.jsx)(`th`,{className:`pb-2 font-medium`,children:`Output`})]})}),(0,X.jsx)(`tbody`,{children:E.groups.map(e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`tr`,{className:`cursor-pointer border-b border-[var(--app-border)] hover:bg-[var(--app-canvas)]`,onClick:()=>void se(e.key),children:[(0,X.jsx)(`td`,{className:`py-2 pr-3`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[O===e.key?(0,X.jsx)(r,{size:12}):(0,X.jsx)(t,{size:12}),(0,X.jsx)(`span`,{className:`font-medium text-[var(--app-text)]`,children:oe(e.key)})]})}),(0,X.jsx)(`td`,{className:`py-2 pr-3 font-mono text-[var(--app-text)]`,children:Q(e.costUsd)}),(0,X.jsx)(`td`,{className:`py-2 pr-3 text-[var(--app-text-subtle)]`,children:e.callCount}),(0,X.jsx)(`td`,{className:`py-2 pr-3 text-[var(--app-text-subtle)]`,children:$(e.inputTokens)}),(0,X.jsx)(`td`,{className:`py-2 text-[var(--app-text-subtle)]`,children:$(e.outputTokens)})]},e.key),O===e.key&&(0,X.jsx)(`tr`,{className:`bg-[var(--app-canvas)]`,children:(0,X.jsx)(`td`,{colSpan:5,className:`px-4 py-3`,children:re[e.key]?(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-[var(--app-text-subtle)]`,children:[(0,X.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`}),(0,X.jsx)(`span`,{children:`Loading…`})]}):!A[e.key]||A[e.key].length===0?(0,X.jsx)(`p`,{className:`text-[var(--app-text-subtle)]`,children:`No calls in this window.`}):(0,X.jsxs)(`table`,{className:`w-full text-[11px]`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`text-left text-[var(--app-text-subtle)]`,children:[(0,X.jsx)(`th`,{className:`pb-1 pr-3 font-medium`,children:`Call ID`}),(0,X.jsx)(`th`,{className:`pb-1 pr-3 font-medium`,children:`Model`}),(0,X.jsx)(`th`,{className:`pb-1 pr-3 font-medium`,children:`Source`}),(0,X.jsx)(`th`,{className:`pb-1 pr-3 font-medium`,children:`Cost`}),(0,X.jsx)(`th`,{className:`pb-1 pr-3 font-medium`,children:`Tokens In/Out`}),(0,X.jsx)(`th`,{className:`pb-1 font-medium`,children:`Priced`})]})}),(0,X.jsx)(`tbody`,{children:A[e.key].map(e=>(0,X.jsxs)(`tr`,{className:`border-t border-[var(--app-border)]`,children:[(0,X.jsxs)(`td`,{className:`py-1 pr-3 font-mono text-[var(--app-text-subtle)]`,children:[e.callId.slice(0,12),`…`]}),(0,X.jsx)(`td`,{className:`py-1 pr-3 text-[var(--app-text)]`,children:e.model}),(0,X.jsx)(`td`,{className:`py-1 pr-3`,children:(0,X.jsx)(p,{variant:`info`,children:e.source})}),(0,X.jsx)(`td`,{className:`py-1 pr-3 font-mono text-[var(--app-text)]`,children:Q(e.costUsd)}),(0,X.jsxs)(`td`,{className:`py-1 pr-3 text-[var(--app-text-subtle)]`,children:[$(e.inputTokens),` / `,$(e.outputTokens)]}),(0,X.jsx)(`td`,{className:`py-1`,children:e.priced?(0,X.jsx)(p,{variant:`success`,children:`priced`}):(0,X.jsx)(p,{variant:`warning`,children:`unpriced`})})]},e.callId))})]})})},`${e.key}-detail`)]}))})]})}):(0,X.jsx)(g,{icon:(0,X.jsx)(n,{size:32}),title:`No cost in this window`,description:`No LLM calls recorded for the selected range. Pre-release history was backfilled from task runs (source=task only); chat and evaluation costs are tracked going forward.`,className:`py-8`})]})]})}export{on as Cost};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{B as t,bt as n,lt as r,st as i,ut as a,xt as o}from"./vendor-icons-Bc_e_XXa.js";import{r as s,t as c}from"./vendor-react-bQ_cvNuA.js";import{t as l}from"./vendor-state-BMVR_B0I.js";import{f as u,n as d,t as f}from"./index-CXEJd-0s.js";import{a as p,i as m,r as h,t as g}from"./Card-Cwvv0An8.js";import{t as _}from"./PageHeader-acLQTYct.js";import{t as v}from"./SectionHeader-NZWZgoOs.js";import{a as y,o as b,t as x}from"./format-ZWN4JNj-.js";var S=e(o(),1),C=c();function w(){let{tasks:e,goals:o,roles:c,stats:w,readiness:D,executionPool:O}=u(l(e=>({tasks:e.tasks,goals:e.goals,roles:e.roles,stats:e.stats,readiness:e.readiness,executionPool:e.executionPool}))),k=u(e=>e.fetchTasks),A=u(e=>e.fetchGoals),j=u(e=>e.fetchRoles),M=u(e=>e.fetchExecutionPool);(0,S.useEffect)(()=>{k(),A(),j(),M();let e=setInterval(()=>{k(),M()},5e3);return()=>clearInterval(e)},[k,A,j,M]);let N=e.filter(e=>e.status===`running`).length,P=e.filter(e=>e.status===`queued`||e.status===`pending`).length,F=e.filter(e=>e.status===`failed`).length,I=(0,S.useMemo)(()=>[...e].sort((e,t)=>t.createdAt-e.createdAt),[e]),L=(0,S.useMemo)(()=>I.slice(0,4),[I]),R=(0,S.useMemo)(()=>I.find(e=>e.status===`failed`)||I.find(e=>e.status===`running`)||I[0],[I]),z=(0,S.useMemo)(()=>D?Object.entries(D.checks):[],[D]),B=(0,S.useMemo)(()=>z.filter(([,e])=>e).length,[z]),V=R?.roleId?c.find(e=>e.id===R.roleId)?.name??R.roleId.slice(0,8):`Unassigned`,H=R?`/tasks/${R.id}`:`/work`,U=R?`Open task`:`Open work`,W=R?R.status===`failed`?`Review the failed task before queueing more work.`:R.status===`running`?`Track this active run and its next result.`:`Use the latest completed run as the starting point for follow-up work.`:`Queue work, review recent runs, or launch an automation.`,G=R?R.status===`failed`?`surface-critical`:R.status===`running`?`surface-accent`:`surface-panel-elevated`:`surface-panel-muted`,K=G===`surface-critical`?`critical`:G===`surface-accent`?`accent`:`neutral`,q=K===`accent`||K===`critical`,J=q?`text-white`:`text-[var(--app-text)]`,Y=q?`text-white/70`:`text-[var(--app-text-subtle)]`,X=q?`text-white/76`:`text-[var(--app-text-muted)]`;return(0,C.jsxs)(`div`,{className:`space-y-6`,children:[(0,C.jsx)(_,{title:`Dashboard`,description:`Queue health, execution readiness, and the next task that needs attention.`,metrics:[{label:`Server`,value:D?.status===`ready`?`Ready`:`Attention`},{label:`Running`,value:w.activeTasks||N},{label:`Queued`,value:w.queuedTasks||P},{label:`Goals`,value:o.length},{label:`Execution Pool`,value:`${O.active}/${O.max} | ${O.queued} queued`}],compact:!0,className:`px-4 py-3 lg:px-4 lg:py-3`,actions:D?(0,C.jsx)(`span`,{role:`status`,"aria-live":`polite`,children:(0,C.jsx)(f,{variant:D.status===`ready`?`success`:`destructive`,children:D.status===`ready`?`Server Ready`:`Not Ready`})}):null}),(0,C.jsxs)(`div`,{className:`grid items-start gap-4 xl:grid-cols-2`,children:[(0,C.jsxs)(g,{className:`${G} self-start ${q?`text-white`:``}`,children:[(0,C.jsxs)(m,{className:`mb-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`p`,{className:`text-kicker ${Y}`,children:`Current Focus`}),(0,C.jsx)(p,{className:`mt-2 ${J}`,children:R?b(R.prompt,92):`No active blockers`})]}),R?(0,C.jsx)(f,{variant:d(R.status),children:R.status}):null]}),(0,C.jsx)(h,{className:X,children:W}),(0,C.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))_auto]`,children:[(0,C.jsx)(E,{tone:K,label:`Created`,value:R?y(R.createdAt):`Idle`}),(0,C.jsx)(E,{tone:K,label:`Cost`,value:R?.costUsd==null?`No cost`:x(R.costUsd)}),(0,C.jsx)(E,{tone:K,label:`Role`,value:V}),(0,C.jsx)(s,{to:H,className:`inline-flex items-center justify-center rounded-lg border px-3 py-2 text-sm font-medium transition-colors ${q?`border-white/20 bg-white/10 text-white hover:bg-white/14`:`border-[var(--app-border)] bg-white/[0.05] text-[var(--app-text)] hover:border-[var(--app-border-strong)]`}`,children:U})]})]}),(0,C.jsxs)(g,{className:`surface-panel-elevated self-start`,children:[(0,C.jsx)(v,{title:`System Checks`,description:`${B}/${z.length||0} checks passing`,compact:!0}),D?(0,C.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:Object.entries(D.checks).map(([e,t])=>(0,C.jsxs)(`div`,{className:`surface-panel-muted flex items-center justify-between rounded-lg px-3 py-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(i,{size:10,className:t?`fill-[var(--app-success)] text-[var(--app-success)]`:`fill-[var(--app-danger)] text-[var(--app-danger)]`}),(0,C.jsx)(`span`,{className:`text-sm capitalize text-[var(--app-text)]`,children:e})]}),(0,C.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:t?`healthy`:`attention`})]},e))}):(0,C.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Loading...`})]})]}),(0,C.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,role:`region`,"aria-label":`Server statistics`,children:[(0,C.jsx)(T,{icon:t,label:`Active Tasks`,value:w.activeTasks||N,color:`text-[var(--app-accent)]`}),(()=>{let e=c.filter(e=>e.status===`active`).length,t=c.length,r=c.filter(e=>e.status===`probation`).length,i=c.filter(e=>e.status===`retired`).length,a=[r>0?`${r} probation`:``,i>0?`${i} retired`:``].filter(Boolean).join(` · `);return(0,C.jsx)(T,{icon:n,label:`Role Health`,value:a?`${e}/${t} | ${a}`:`${e}/${t}`,color:i>0?`text-[var(--app-danger)]`:r>0?`text-[var(--app-warning)]`:`text-[var(--app-success)]`})})(),(0,C.jsx)(T,{icon:a,label:`Failed`,value:F,color:`text-[var(--app-danger)]`}),(0,C.jsx)(T,{icon:r,label:`Cost Today`,value:x(w.totalCostToday),color:`text-[var(--app-accent-strong)]`})]}),(0,C.jsxs)(g,{padding:!1,children:[(0,C.jsx)(`div`,{className:`px-4 pt-4`,children:(0,C.jsx)(v,{title:`Recent Tasks`,description:`Latest executions across the control plane.`,action:(0,C.jsx)(s,{to:`/work`,className:`text-sm font-medium text-[var(--app-accent-strong)] hover:underline`,children:`View all`})})}),(0,C.jsx)(`div`,{className:`mt-4 space-y-3 px-4 pb-4`,children:L.length===0?(0,C.jsx)(`div`,{className:`surface-panel-muted rounded-lg px-4 py-6 text-sm text-[var(--app-text-subtle)]`,children:`No tasks yet`}):L.map(e=>(0,C.jsxs)(s,{to:`/tasks/${e.id}`,className:`surface-panel-muted flex flex-col gap-3 rounded-lg px-4 py-4 transition-colors hover:border-[var(--app-border-strong)] hover:bg-white/[0.05] lg:flex-row lg:items-start lg:justify-between`,children:[(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(f,{variant:d(e.status),children:e.status}),(0,C.jsx)(`span`,{className:`font-mono text-xs text-[var(--app-text-subtle)]`,children:e.id.slice(0,8)}),e.roleId?(0,C.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`role `,e.roleId.slice(0,12)]}):null]}),(0,C.jsx)(`div`,{className:`text-sm font-medium text-[var(--app-text)]`,children:b(e.prompt,128)})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 text-xs text-[var(--app-text-subtle)]`,children:[(0,C.jsx)(`span`,{children:y(e.createdAt)}),(0,C.jsx)(`span`,{children:e.costUsd==null?`no cost`:x(e.costUsd)})]})]},e.id))})]})]})}function T({icon:e,label:t,value:n,color:r}){return(0,C.jsxs)(g,{className:`surface-panel-muted flex items-center gap-3`,children:[(0,C.jsx)(`div`,{className:`rounded-lg bg-white/[0.05] p-3 ${r}`,children:(0,C.jsx)(e,{size:16})}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-xl font-semibold text-[var(--app-text)]`,children:n}),(0,C.jsx)(`div`,{className:`text-xs uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:t})]})]})}function E({label:e,value:t,tone:n=`accent`}){let r=n===`accent`||n===`critical`;return(0,C.jsxs)(`div`,{className:r?`rounded-lg border border-white/12 bg-black/10 px-3 py-3`:`surface-focus-metric rounded-lg px-3 py-3`,children:[(0,C.jsx)(`div`,{className:r?`text-[10px] uppercase tracking-[0.16em] text-white/62`:`text-[10px] uppercase tracking-[0.16em] text-[var(--app-text-subtle)]`,children:e}),(0,C.jsx)(`div`,{className:r?`mt-1 text-lg font-semibold text-white`:`mt-1 text-lg font-semibold text-[var(--app-text)]`,children:t})]})}export{w as Dashboard};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{B as t,bt as n,lt as r,st as i,ut as a,xt as o}from"./vendor-icons-Bc_e_XXa.js";import{r as s,t as c}from"./vendor-react-bQ_cvNuA.js";import{t as l}from"./vendor-state-BMVR_B0I.js";import{f as u,n as d,t as f}from"./index-Dd3NDYZR.js";import{a as p,i as m,r as h,t as g}from"./Card-Cwvv0An8.js";import{t as _}from"./PageHeader-acLQTYct.js";import{t as v}from"./SectionHeader-NZWZgoOs.js";import{a as y,o as b,t as x}from"./format-ZWN4JNj-.js";var S=e(o(),1),C=c();function w(){let{tasks:e,goals:o,roles:c,stats:w,readiness:D,executionPool:O}=u(l(e=>({tasks:e.tasks,goals:e.goals,roles:e.roles,stats:e.stats,readiness:e.readiness,executionPool:e.executionPool}))),k=u(e=>e.fetchTasks),A=u(e=>e.fetchGoals),j=u(e=>e.fetchRoles),M=u(e=>e.fetchExecutionPool);(0,S.useEffect)(()=>{k(),A(),j(),M();let e=setInterval(()=>{k(),M()},5e3);return()=>clearInterval(e)},[k,A,j,M]);let N=e.filter(e=>e.status===`running`).length,P=e.filter(e=>e.status===`queued`||e.status===`pending`).length,F=e.filter(e=>e.status===`failed`).length,I=(0,S.useMemo)(()=>[...e].sort((e,t)=>t.createdAt-e.createdAt),[e]),L=(0,S.useMemo)(()=>I.slice(0,4),[I]),R=(0,S.useMemo)(()=>I.find(e=>e.status===`failed`)||I.find(e=>e.status===`running`)||I[0],[I]),z=(0,S.useMemo)(()=>D?Object.entries(D.checks):[],[D]),B=(0,S.useMemo)(()=>z.filter(([,e])=>e).length,[z]),V=R?.roleId?c.find(e=>e.id===R.roleId)?.name??R.roleId.slice(0,8):`Unassigned`,H=R?`/tasks/${R.id}`:`/work`,U=R?`Open task`:`Open work`,W=R?R.status===`failed`?`Review the failed task before queueing more work.`:R.status===`running`?`Track this active run and its next result.`:`Use the latest completed run as the starting point for follow-up work.`:`Queue work, review recent runs, or launch an automation.`,G=R?R.status===`failed`?`surface-critical`:R.status===`running`?`surface-accent`:`surface-panel-elevated`:`surface-panel-muted`,K=G===`surface-critical`?`critical`:G===`surface-accent`?`accent`:`neutral`,q=K===`accent`||K===`critical`,J=q?`text-white`:`text-[var(--app-text)]`,Y=q?`text-white/70`:`text-[var(--app-text-subtle)]`,X=q?`text-white/76`:`text-[var(--app-text-muted)]`;return(0,C.jsxs)(`div`,{className:`space-y-6`,children:[(0,C.jsx)(_,{title:`Dashboard`,description:`Queue health, execution readiness, and the next task that needs attention.`,metrics:[{label:`Server`,value:D?.status===`ready`?`Ready`:`Attention`},{label:`Running`,value:w.activeTasks||N},{label:`Queued`,value:w.queuedTasks||P},{label:`Goals`,value:o.length},{label:`Execution Pool`,value:`${O.active}/${O.max} | ${O.queued} queued`}],compact:!0,className:`px-4 py-3 lg:px-4 lg:py-3`,actions:D?(0,C.jsx)(`span`,{role:`status`,"aria-live":`polite`,children:(0,C.jsx)(f,{variant:D.status===`ready`?`success`:`destructive`,children:D.status===`ready`?`Server Ready`:`Not Ready`})}):null}),(0,C.jsxs)(`div`,{className:`grid items-start gap-4 xl:grid-cols-2`,children:[(0,C.jsxs)(g,{className:`${G} self-start ${q?`text-white`:``}`,children:[(0,C.jsxs)(m,{className:`mb-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`p`,{className:`text-kicker ${Y}`,children:`Current Focus`}),(0,C.jsx)(p,{className:`mt-2 ${J}`,children:R?b(R.prompt,92):`No active blockers`})]}),R?(0,C.jsx)(f,{variant:d(R.status),children:R.status}):null]}),(0,C.jsx)(h,{className:X,children:W}),(0,C.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))_auto]`,children:[(0,C.jsx)(E,{tone:K,label:`Created`,value:R?y(R.createdAt):`Idle`}),(0,C.jsx)(E,{tone:K,label:`Cost`,value:R?.costUsd==null?`No cost`:x(R.costUsd)}),(0,C.jsx)(E,{tone:K,label:`Role`,value:V}),(0,C.jsx)(s,{to:H,className:`inline-flex items-center justify-center rounded-lg border px-3 py-2 text-sm font-medium transition-colors ${q?`border-white/20 bg-white/10 text-white hover:bg-white/14`:`border-[var(--app-border)] bg-white/[0.05] text-[var(--app-text)] hover:border-[var(--app-border-strong)]`}`,children:U})]})]}),(0,C.jsxs)(g,{className:`surface-panel-elevated self-start`,children:[(0,C.jsx)(v,{title:`System Checks`,description:`${B}/${z.length||0} checks passing`,compact:!0}),D?(0,C.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:Object.entries(D.checks).map(([e,t])=>(0,C.jsxs)(`div`,{className:`surface-panel-muted flex items-center justify-between rounded-lg px-3 py-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(i,{size:10,className:t?`fill-[var(--app-success)] text-[var(--app-success)]`:`fill-[var(--app-danger)] text-[var(--app-danger)]`}),(0,C.jsx)(`span`,{className:`text-sm capitalize text-[var(--app-text)]`,children:e})]}),(0,C.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:t?`healthy`:`attention`})]},e))}):(0,C.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Loading...`})]})]}),(0,C.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,role:`region`,"aria-label":`Server statistics`,children:[(0,C.jsx)(T,{icon:t,label:`Active Tasks`,value:w.activeTasks||N,color:`text-[var(--app-accent)]`}),(()=>{let e=c.filter(e=>e.status===`active`).length,t=c.length,r=c.filter(e=>e.status===`probation`).length,i=c.filter(e=>e.status===`retired`).length,a=[r>0?`${r} probation`:``,i>0?`${i} retired`:``].filter(Boolean).join(` · `);return(0,C.jsx)(T,{icon:n,label:`Role Health`,value:a?`${e}/${t} | ${a}`:`${e}/${t}`,color:i>0?`text-[var(--app-danger)]`:r>0?`text-[var(--app-warning)]`:`text-[var(--app-success)]`})})(),(0,C.jsx)(T,{icon:a,label:`Failed`,value:F,color:`text-[var(--app-danger)]`}),(0,C.jsx)(T,{icon:r,label:`Cost Today`,value:x(w.totalCostToday),color:`text-[var(--app-accent-strong)]`})]}),(0,C.jsxs)(g,{padding:!1,children:[(0,C.jsx)(`div`,{className:`px-4 pt-4`,children:(0,C.jsx)(v,{title:`Recent Tasks`,description:`Latest executions across the control plane.`,action:(0,C.jsx)(s,{to:`/work`,className:`text-sm font-medium text-[var(--app-accent-strong)] hover:underline`,children:`View all`})})}),(0,C.jsx)(`div`,{className:`mt-4 space-y-3 px-4 pb-4`,children:L.length===0?(0,C.jsx)(`div`,{className:`surface-panel-muted rounded-lg px-4 py-6 text-sm text-[var(--app-text-subtle)]`,children:`No tasks yet`}):L.map(e=>(0,C.jsxs)(s,{to:`/tasks/${e.id}`,className:`surface-panel-muted flex flex-col gap-3 rounded-lg px-4 py-4 transition-colors hover:border-[var(--app-border-strong)] hover:bg-white/[0.05] lg:flex-row lg:items-start lg:justify-between`,children:[(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(f,{variant:d(e.status),children:e.status}),(0,C.jsx)(`span`,{className:`font-mono text-xs text-[var(--app-text-subtle)]`,children:e.id.slice(0,8)}),e.roleId?(0,C.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`role `,e.roleId.slice(0,12)]}):null]}),(0,C.jsx)(`div`,{className:`text-sm font-medium text-[var(--app-text)]`,children:b(e.prompt,128)})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 text-xs text-[var(--app-text-subtle)]`,children:[(0,C.jsx)(`span`,{children:y(e.createdAt)}),(0,C.jsx)(`span`,{children:e.costUsd==null?`no cost`:x(e.costUsd)})]})]},e.id))})]})]})}function T({icon:e,label:t,value:n,color:r}){return(0,C.jsxs)(g,{className:`surface-panel-muted flex items-center gap-3`,children:[(0,C.jsx)(`div`,{className:`rounded-lg bg-white/[0.05] p-3 ${r}`,children:(0,C.jsx)(e,{size:16})}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-xl font-semibold text-[var(--app-text)]`,children:n}),(0,C.jsx)(`div`,{className:`text-xs uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:t})]})]})}function E({label:e,value:t,tone:n=`accent`}){let r=n===`accent`||n===`critical`;return(0,C.jsxs)(`div`,{className:r?`rounded-lg border border-white/12 bg-black/10 px-3 py-3`:`surface-focus-metric rounded-lg px-3 py-3`,children:[(0,C.jsx)(`div`,{className:r?`text-[10px] uppercase tracking-[0.16em] text-white/62`:`text-[10px] uppercase tracking-[0.16em] text-[var(--app-text-subtle)]`,children:e}),(0,C.jsx)(`div`,{className:r?`mt-1 text-lg font-semibold text-white`:`mt-1 text-lg font-semibold text-[var(--app-text)]`,children:t})]})}export{w as Dashboard};
@@ -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-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
+ 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-Dd3NDYZR.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-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
+ 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-Dd3NDYZR.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-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
+ 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-Dd3NDYZR.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--h1rqagh.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-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 ---
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-Dd3NDYZR.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(`