adam-agent-server 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/App-ZRCRM7WR.js +13 -0
  2. package/dist/{adam-automator-skills-UFW5TXCC.js → adam-automator-skills-EZGBICHT.js} +1 -1
  3. package/dist/adam-tools-V5LPU47X.js +1 -0
  4. package/dist/{approval-handler-HQO62WK2.js → approval-handler-PB7PSLUS.js} +1 -1
  5. package/dist/audit-manager-BSBBDUER.js +1 -0
  6. package/dist/bree-engine-7S33CWS7.js +1 -0
  7. package/dist/channels-SITUUC4J.js +1 -0
  8. package/dist/{channels-J4STJ4X2.js → channels-ULFUCUUZ.js} +1 -1
  9. package/dist/{chunk-7446ZS6D.js → chunk-2L2347UQ.js} +1 -1
  10. package/dist/{chunk-FXQAUQTI.js → chunk-2YTDCR6A.js} +1 -1
  11. package/dist/chunk-4PQHGLZH.js +99 -0
  12. package/dist/{chunk-NCFVJCNQ.js → chunk-5EPG2US5.js} +2 -2
  13. package/dist/{chunk-2H7UOW4P.js → chunk-5QZXYKMS.js} +1 -1
  14. package/dist/chunk-5XOTPEAK.js +6 -0
  15. package/dist/{chunk-MDBVKBC7.js → chunk-6KF7OO2B.js} +1 -1
  16. package/dist/{chunk-TSPQ44HT.js → chunk-A5OCDYTW.js} +1 -1
  17. package/dist/{chunk-DWRYIN5N.js → chunk-AQ3ASS4B.js} +1 -1
  18. package/dist/{chunk-GMMWA5EG.js → chunk-B6LOT5CG.js} +1 -1
  19. package/dist/{chunk-MJSSCKMB.js → chunk-BCH2HAIM.js} +2 -2
  20. package/dist/{chunk-4C5ITATX.js → chunk-BQ3ZAYHC.js} +1 -1
  21. package/dist/{chunk-YHVYX3F4.js → chunk-DVN3BFPP.js} +1 -1
  22. package/dist/{chunk-P5ZXNBNV.js → chunk-EQZFOBAJ.js} +1 -1
  23. package/dist/{chunk-G5ESQEXN.js → chunk-FPZEZYUB.js} +1 -1
  24. package/dist/{chunk-YXYIA24D.js → chunk-GSFLLRS7.js} +1 -1
  25. package/dist/{chunk-7ZGSJCX5.js → chunk-HQRUJQN7.js} +1 -1
  26. package/dist/{chunk-52PR7XTN.js → chunk-IKPYPZ64.js} +1 -1
  27. package/dist/{chunk-FZCNYKNT.js → chunk-JJH2RCVC.js} +1 -1
  28. package/dist/chunk-K4C43YDD.js +7 -0
  29. package/dist/{chunk-V32YF3J5.js → chunk-M4YI4WVX.js} +1 -1
  30. package/dist/{chunk-WAG3MNMC.js → chunk-NASJH4NT.js} +1 -1
  31. package/dist/{chunk-TNL2LZB7.js → chunk-NUITL62I.js} +1 -1
  32. package/dist/{chunk-3LY6PD6A.js → chunk-NWMOV23A.js} +1 -1
  33. package/dist/chunk-PHT24MOV.js +1 -0
  34. package/dist/{chunk-ZL5JXLAX.js → chunk-QGYDGZSC.js} +1 -1
  35. package/dist/{chunk-VVSZZK5T.js → chunk-RI3V72RP.js} +2 -2
  36. package/dist/{chunk-RLJYEEQC.js → chunk-RZ7LCZVK.js} +1 -1
  37. package/dist/{chunk-5OQZPUBV.js → chunk-TAF2DBBC.js} +8 -8
  38. package/dist/{chunk-HWLSHTVX.js → chunk-ULTK7RD6.js} +3 -3
  39. package/dist/{chunk-DBP7GPWG.js → chunk-WMB7P64J.js} +1 -1
  40. package/dist/cli.js +2 -2
  41. package/dist/{config-KFPS7IEH.js → config-HBQPBIWL.js} +1 -1
  42. package/dist/{db-PZ2V7UCK.js → db-QEWTZGU3.js} +1 -1
  43. package/dist/{delivery-log-ACNJ66RD.js → delivery-log-AC476GX7.js} +1 -1
  44. package/dist/engine-6K4RG644.js +1 -0
  45. package/dist/{evolution-audit-OQDGPKYI.js → evolution-audit-XMBDUN3T.js} +1 -1
  46. package/dist/index.js +13 -10
  47. package/dist/{learner-QCD6BH2J.js → learner-VCS3Q7BR.js} +1 -1
  48. package/dist/{memories-QGMRSBJJ.js → memories-VMOGFVPU.js} +1 -1
  49. package/dist/{memory-extractor-3MRK43A2.js → memory-extractor-4WJNHYWR.js} +2 -2
  50. package/dist/memory-service-ZS6MBUIC.js +1 -0
  51. package/dist/outbound-gateway-H7RFG6D2.js +1 -0
  52. package/dist/role-presets-XAEOYEAW.js +1 -0
  53. package/dist/role-workspace-NKGAH6J6.js +1 -0
  54. package/dist/{roles-KYXNMO5H.js → roles-ZYCFQMAY.js} +1 -1
  55. package/dist/{session-manager-LZ77OT7A.js → session-manager-COLCNIB7.js} +1 -1
  56. package/dist/task-templates-4KCZOUN5.js +1 -0
  57. package/dist/workflow-executor-Z7JFMR56.js +1 -0
  58. package/package.json +25 -25
  59. package/web/dist/assets/{ChannelDetail-DHT8fW0C.js → ChannelDetail-DnL0_h8q.js} +1 -1
  60. package/web/dist/assets/{Channels-YHGNXcRu.js → Channels-dod8Q4oq.js} +1 -1
  61. package/web/dist/assets/{Dashboard-DsHC5W4C.js → Dashboard-Dl0vA6Ky.js} +1 -1
  62. package/web/dist/assets/{EnvVarEditor-Dxy1Kz1Z.js → EnvVarEditor-C-gErAzC.js} +1 -1
  63. package/web/dist/assets/{EventDefDetail-CwprP2ch.js → EventDefDetail-BhJZGNlX.js} +1 -1
  64. package/web/dist/assets/{Events-B19a8cEG.js → Events-DnNZ9-BN.js} +1 -1
  65. package/web/dist/assets/{Evolution-DT6iZvil.js → Evolution-BBWmrrnr.js} +1 -1
  66. package/web/dist/assets/{GoalDetail-BALsnPQl.js → GoalDetail-uqWQCOj3.js} +1 -1
  67. package/web/dist/assets/{Goals-BJIsKgfH.js → Goals-CylKmR9j.js} +1 -1
  68. package/web/dist/assets/{Logs-Cv15aV3l.js → Logs-6rf0KT0z.js} +1 -1
  69. package/web/dist/assets/{Memories-CKAXhAso.js → Memories-CrBTujU7.js} +1 -1
  70. package/web/dist/assets/{Plugins-NO0S2spH.js → Plugins-VKUSUcSE.js} +1 -1
  71. package/web/dist/assets/{RoleDetail-1FNyCD4u.js → RoleDetail-DJc4CWFN.js} +1 -1
  72. package/web/dist/assets/{Roles-grfjw2zy.js → Roles-6pmjn04G.js} +1 -1
  73. package/web/dist/assets/{Settings-9LRLfa_4.js → Settings-DW1jmrNj.js} +1 -1
  74. package/web/dist/assets/{Strategies-BMyd_7_5.js → Strategies-Bmke6qZo.js} +1 -1
  75. package/web/dist/assets/{Switch-CULsD-kC.js → Switch-CfTpXW9_.js} +1 -1
  76. package/web/dist/assets/{TaskDetail-C2yXy8gE.js → TaskDetail-CwJ_UKgt.js} +1 -1
  77. package/web/dist/assets/Work-DVdWNBEm.js +1 -0
  78. package/web/dist/assets/{index-qYKJGoIB.js → index-DYsO5Awn.js} +2 -2
  79. package/web/dist/index.html +1 -1
  80. package/dist/App-WJMHK5EO.js +0 -13
  81. package/dist/adam-tools-IAZSLWYB.js +0 -1
  82. package/dist/audit-manager-LC5EQXCI.js +0 -1
  83. package/dist/bree-engine-M5CZ6A62.js +0 -1
  84. package/dist/channels-5TFYQN5Z.js +0 -1
  85. package/dist/chunk-FIN36WAP.js +0 -99
  86. package/dist/chunk-GGIHDFRW.js +0 -6
  87. package/dist/chunk-I7ZZKPHE.js +0 -7
  88. package/dist/chunk-YDVTWPNA.js +0 -1
  89. package/dist/engine-5DHYHDAP.js +0 -1
  90. package/dist/memory-service-M5ADGITG.js +0 -1
  91. package/dist/outbound-gateway-QRL36F7K.js +0 -1
  92. package/dist/role-presets-DLO3XS54.js +0 -1
  93. package/dist/role-workspace-URSOBCDH.js +0 -1
  94. package/dist/task-templates-YPNWJOVV.js +0 -1
  95. package/dist/workflow-executor-3WMS2WV3.js +0 -1
  96. package/web/dist/assets/Work-dftf35Me.js +0 -1
@@ -1 +1 @@
1
- import{d as l,e as D,f as S,g as $}from"./chunk-TNL2LZB7.js";import{b as h}from"./chunk-7446ZS6D.js";import{b as u}from"./chunk-I7ZZKPHE.js";import{e as R,g as T,j as C}from"./chunk-DBP7GPWG.js";import{l as k,n as x,r as N}from"./chunk-7ZGSJCX5.js";import"./chunk-G5ESQEXN.js";import"./chunk-NCFVJCNQ.js";import"./chunk-WBAPIPST.js";import{c as d,h as y}from"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";y();var w=d("agent");function I(n){let o=l(n);if(!o){w.debug({taskId:n},"No plan found for task, skipping review");return}let i=h(n,1e3),s=o.plan.steps,a=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(a.map(e=>e.planStepIndex).filter(e=>e!==void 0));for(let e of s)r.has(e.index)||t.push({stepIndex:e.index,planned:e.description,actual:"Not executed",deviationType:"skipped"});let c=a.filter(e=>e.planStepIndex===void 0);for(let e of c)t.push({stepIndex:-1,planned:"",actual:`${e.toolName}: ${e.output.slice(0,200)}`,deviationType:"added"});let b=a.filter(e=>e.permissionDenied);for(let e of b)t.push({stepIndex:e.planStepIndex??-1,planned:e.planStepIndex!==void 0?s.find(E=>E.index===e.planStepIndex)?.description??"Unknown":"",actual:`PERMISSION DENIED: ${e.toolName}`,deviationType:"failed"});let p=s.length,m=a.length,g=p>0?Math.max(0,1-t.filter(e=>e.deviationType!=="added").length/p):1,v={stepsPlanned:p,stepsExecuted:m,deviations:t,overallAccuracy:g};return S(o.id,v),w.info({taskId:n,planId:o.id,stepsPlanned:p,stepsExecuted:m,deviationCount:t.length,accuracy:g},"Deviation report generated"),v}function P(n){return n.deviations.filter(i=>i.deviationType==="failed"||i.deviationType==="skipped").length===0&&n.overallAccuracy>=.7}N();C();y();var f=d("agent");function L(n,o){let i=[],a=u(n)?.prompt.slice(0,100)??"unknown task";P(o)&&i.push(`[+] Task "${a}" 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 "${a}". Consider if this step is necessary for similar tasks. [sourceTaskId:${n}]`);break;case"failed":i.push(`[-] Step failed: "${t.actual}" during "${a}". Check permissions and tool availability. [sourceTaskId:${n}]`);break;case"added":i.push(`[~] Unplanned action: "${t.actual}" during "${a}". Consider adding to plan for similar tasks. [sourceTaskId:${n}]`);break;case"modified":i.push(`[~] Step modified: planned "${t.planned}" but did "${t.actual}" during "${a}". [sourceTaskId:${n}]`);break}return i}async function z(n){let o=l(n);if(!o){f.debug({taskId:n},"No plan for task, skipping review/learn");return}let i=I(n);if(!i)return;let s=L(n,i);if(s.length===0)return;$(o.id,s);let a=u(n);if(a?.roleId){let t=k(a.roleId);if(t){let r=[...t.learnedRules,...s];x(a.roleId,{learnedRules:r});let c=R(t.name);T(c,{...t,learnedRules:r}),f.info({roleId:a.roleId,newRulesCount:s.length},"Role learnedRules updated and CLAUDE.md written")}}D(o.id,"completed"),f.info({taskId:n,planId:o.id,rulesExtracted:s.length,accuracy:i.overallAccuracy},"Task review and learning completed")}export{L as extractRulesFromDeviation,z as processTaskReview};
1
+ import{d as l,e as D,f as S,g as $}from"./chunk-NUITL62I.js";import{b as h}from"./chunk-2L2347UQ.js";import{b as u}from"./chunk-K4C43YDD.js";import{e as R,g as T,j as C}from"./chunk-WMB7P64J.js";import{l as k,n as x,r as N}from"./chunk-HQRUJQN7.js";import"./chunk-FPZEZYUB.js";import"./chunk-5EPG2US5.js";import"./chunk-WBAPIPST.js";import{c as d,h as y}from"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";y();var w=d("agent");function I(n){let o=l(n);if(!o){w.debug({taskId:n},"No plan found for task, skipping review");return}let i=h(n,1e3),s=o.plan.steps,a=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(a.map(e=>e.planStepIndex).filter(e=>e!==void 0));for(let e of s)r.has(e.index)||t.push({stepIndex:e.index,planned:e.description,actual:"Not executed",deviationType:"skipped"});let c=a.filter(e=>e.planStepIndex===void 0);for(let e of c)t.push({stepIndex:-1,planned:"",actual:`${e.toolName}: ${e.output.slice(0,200)}`,deviationType:"added"});let b=a.filter(e=>e.permissionDenied);for(let e of b)t.push({stepIndex:e.planStepIndex??-1,planned:e.planStepIndex!==void 0?s.find(E=>E.index===e.planStepIndex)?.description??"Unknown":"",actual:`PERMISSION DENIED: ${e.toolName}`,deviationType:"failed"});let p=s.length,m=a.length,g=p>0?Math.max(0,1-t.filter(e=>e.deviationType!=="added").length/p):1,v={stepsPlanned:p,stepsExecuted:m,deviations:t,overallAccuracy:g};return S(o.id,v),w.info({taskId:n,planId:o.id,stepsPlanned:p,stepsExecuted:m,deviationCount:t.length,accuracy:g},"Deviation report generated"),v}function P(n){return n.deviations.filter(i=>i.deviationType==="failed"||i.deviationType==="skipped").length===0&&n.overallAccuracy>=.7}N();C();y();var f=d("agent");function L(n,o){let i=[],a=u(n)?.prompt.slice(0,100)??"unknown task";P(o)&&i.push(`[+] Task "${a}" 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 "${a}". Consider if this step is necessary for similar tasks. [sourceTaskId:${n}]`);break;case"failed":i.push(`[-] Step failed: "${t.actual}" during "${a}". Check permissions and tool availability. [sourceTaskId:${n}]`);break;case"added":i.push(`[~] Unplanned action: "${t.actual}" during "${a}". Consider adding to plan for similar tasks. [sourceTaskId:${n}]`);break;case"modified":i.push(`[~] Step modified: planned "${t.planned}" but did "${t.actual}" during "${a}". [sourceTaskId:${n}]`);break}return i}async function z(n){let o=l(n);if(!o){f.debug({taskId:n},"No plan for task, skipping review/learn");return}let i=I(n);if(!i)return;let s=L(n,i);if(s.length===0)return;$(o.id,s);let a=u(n);if(a?.roleId){let t=k(a.roleId);if(t){let r=[...t.learnedRules,...s];x(a.roleId,{learnedRules:r});let c=R(t.name);T(c,{...t,learnedRules:r}),f.info({roleId:a.roleId,newRulesCount:s.length},"Role learnedRules updated and CLAUDE.md written")}}D(o.id,"completed"),f.info({taskId:n,planId:o.id,rulesExtracted:s.length,accuracy:i.overallAccuracy},"Task review and learning completed")}export{L as extractRulesFromDeviation,z as processTaskReview};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"./chunk-YHVYX3F4.js";import"./chunk-7ZGSJCX5.js";import"./chunk-G5ESQEXN.js";import"./chunk-NCFVJCNQ.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{o as DEFAULT_HYBRID_CONFIG,k as DEFAULT_SCORING_WEIGHTS,l as calculateRecency,m as calculateSmallvilleScore,p as cleanupMemories,f as countMemoriesByRole,a as createMemory,j as deleteMemory,b as getMemory,n as getRoleScoringWeights,g as listMemoriesByRole,e as markSuperseded,i as searchByBM25,h as searchByVector,q 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}from"./chunk-DVN3BFPP.js";import"./chunk-HQRUJQN7.js";import"./chunk-FPZEZYUB.js";import"./chunk-5EPG2US5.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{o as DEFAULT_HYBRID_CONFIG,k as DEFAULT_SCORING_WEIGHTS,l as calculateRecency,m as calculateSmallvilleScore,p as cleanupMemories,f as countMemoriesByRole,a as createMemory,j as deleteMemory,b as getMemory,n as getRoleScoringWeights,g as listMemoriesByRole,e as markSuperseded,i as searchByBM25,h as searchByVector,q as searchHybrid,c as updateMemory,d as updateMemoryRetrievalCount};
@@ -1,6 +1,6 @@
1
- import{a as v}from"./chunk-TSPQ44HT.js";import{a as p}from"./chunk-SWP2JC54.js";import{a as h}from"./chunk-IZNEOYRP.js";import{b as g}from"./chunk-7446ZS6D.js";import{a as l,g as w}from"./chunk-YHVYX3F4.js";import"./chunk-7ZGSJCX5.js";import"./chunk-G5ESQEXN.js";import{b as u,d as M}from"./chunk-NCFVJCNQ.js";import"./chunk-WBAPIPST.js";import{c as y,h as b}from"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";b();M();import{v4 as $}from"uuid";var x=y("manager"),d=150,C=50;function N(e){return u().prepare("SELECT importance_trigger_curr FROM roles WHERE id = ?").get(e)?.importance_trigger_curr??d}function f(e,t){u().prepare("UPDATE roles SET importance_trigger_curr = ? WHERE id = ?").run(t,e)}function _(e,t){let r=N(e)-t;return f(e,r),r<=0}async function S(e){let t=w(e,C,0);if(t.length===0){f(e,d);return}let r=`Based on these recent experiences, what are the key insights and patterns?
1
+ import{a as v}from"./chunk-A5OCDYTW.js";import{a as p}from"./chunk-SWP2JC54.js";import{a as h}from"./chunk-IZNEOYRP.js";import{b as g}from"./chunk-2L2347UQ.js";import{a as l,g as w}from"./chunk-DVN3BFPP.js";import"./chunk-HQRUJQN7.js";import"./chunk-FPZEZYUB.js";import{b as u,d as M}from"./chunk-5EPG2US5.js";import"./chunk-WBAPIPST.js";import{c as y,h as b}from"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";b();M();import{v4 as $}from"uuid";var x=y("manager"),d=150,C=50;function N(e){return u().prepare("SELECT importance_trigger_curr FROM roles WHERE id = ?").get(e)?.importance_trigger_curr??d}function f(e,t){u().prepare("UPDATE roles SET importance_trigger_curr = ? WHERE id = ?").run(t,e)}function _(e,t){let r=N(e)-t;return f(e,r),r<=0}async function S(e){let t=w(e,C,0);if(t.length===0){f(e,d);return}let r=`Based on these recent experiences, what are the key insights and patterns?
2
2
 
3
3
  ${t.slice(0,20).map((c,m)=>`${m+1}. [${c.type}] (importance: ${c.importance}) ${c.content}`).join(`
4
4
  `)}
5
5
 
6
- Provide 1-3 high-level insights.`,o;try{o=(await h(r,"You are an agent self-reflection system. Analyze the experiences and produce concise, actionable insights. Respond with 1-3 high-level insights, each on its own line.")).trim()||E(t)}catch{o=E(t)}let i;try{i=await p(o)}catch{}let a=o.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(c=>c.length>2),s={id:$(),roleId:e,type:"reflection",content:o,embedding:i,keywords:[...new Set(a)].slice(0,20),importance:5,sourceType:"reflection",evidence:t.slice(0,10).map(c=>c.id),createdAt:Date.now(),lastAccessed:Date.now(),retrievedCount:0,tier:"semantic"};l(s);try{let{markSuperseded:c}=await import("./memories-QGMRSBJJ.js"),m=t.slice(0,10).map(T=>T.id);c(m,s.id)}catch{}try{v({timestamp:Date.now(),oldRules:"",newRules:o,diff:o,roleId:e,source:"reflection"})}catch{}f(e,d),x.info({roleId:e,preview:o.slice(0,100)},"Generated reflection")}function E(e){let t=e.filter(i=>i.type==="event"),n=t.filter(i=>i.content.includes("Error")||i.content.includes("failed")),r=t.filter(i=>i.content.includes("Modified file")),o=[];return r.length>0&&o.push(`Made ${r.length} file modifications in recent tasks.`),n.length>0&&o.push(`Encountered ${n.length} errors.`),t.length>0&&o.push(`Total ${t.length} significant events observed.`),o.length>0?`Reflection: ${o.join(" ")}`:"Reflection: No significant patterns observed in recent activity."}async function R(e,t){_(e,t)&&await S(e)}import{v4 as A}from"uuid";function L(e){let t=e.toolName,n=e.toolOutput||e.content;if(t==="Write"||t==="Edit")return{content:`Modified file via ${t}: ${n.slice(0,400)}`,importance:4,type:"event"};if(t==="Bash"){let r=e.toolInput?.command?.slice(0,100)||"Bash";return n.includes("FAIL")||n.includes("error:")||n.includes("Error:")?{content:`Command failed: ${r} ${n.slice(0,300)}`,importance:4,type:"event"}:n.includes("success")||n.includes("done")||n.includes("OK")?{content:`Command succeeded: ${r}`,importance:2,type:"event"}:{content:`Executed: ${r}`,importance:1,type:"event"}}return t==="Read"?{content:`Read file: ${e.toolInput?.file_path||e.toolInput?.path||"unknown"}`,importance:1,type:"thought"}:t==="Glob"||t==="Grep"?{content:`Searched: ${t} - ${e.toolInput?.pattern||"query"}`,importance:2,type:"thought"}:null}function F(e){let t=g(e,500,0),n=[];for(let r of t)if((r.type==="tool_result"||r.type==="tool_call")&&r.toolName){let o=L(r);o&&n.push(o)}else r.type==="error"&&n.push({content:`Error occurred: ${r.content.slice(0,400)}`,importance:4,type:"event"});return{facts:n}}function k(e){let t=e.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(n=>n.length>2);return[...new Set(t)].slice(0,20)}async function V(e,t){let n=!1;try{let{searchByBM25:i}=await import("./memories-QGMRSBJJ.js");n=i(t,e,5).filter(s=>s.sourceTaskId===e).some(s=>s.type==="thought")}catch{}let{facts:r}=F(e),o=0;for(let i of r){if(n&&i.importance<=2)continue;let a=i.content.slice(0,500),s;try{s=await p(a)}catch{}let c=k(a),m={id:A(),roleId:t,type:i.type,content:a,embedding:s,keywords:c,importance:i.importance,sourceType:"task_complete",sourceTaskId:e,createdAt:Date.now(),lastAccessed:Date.now(),retrievedCount:0,tier:"episodic"};l(m),o++,await R(t,i.importance)}return o}export{F as extractKeyFacts,V as processTaskCompletion};
6
+ Provide 1-3 high-level insights.`,o;try{o=(await h(r,"You are an agent self-reflection system. Analyze the experiences and produce concise, actionable insights. Respond with 1-3 high-level insights, each on its own line.")).trim()||E(t)}catch{o=E(t)}let i;try{i=await p(o)}catch{}let a=o.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(c=>c.length>2),s={id:$(),roleId:e,type:"reflection",content:o,embedding:i,keywords:[...new Set(a)].slice(0,20),importance:5,sourceType:"reflection",evidence:t.slice(0,10).map(c=>c.id),createdAt:Date.now(),lastAccessed:Date.now(),retrievedCount:0,tier:"semantic"};l(s);try{let{markSuperseded:c}=await import("./memories-VMOGFVPU.js"),m=t.slice(0,10).map(T=>T.id);c(m,s.id)}catch{}try{v({timestamp:Date.now(),oldRules:"",newRules:o,diff:o,roleId:e,source:"reflection"})}catch{}f(e,d),x.info({roleId:e,preview:o.slice(0,100)},"Generated reflection")}function E(e){let t=e.filter(i=>i.type==="event"),n=t.filter(i=>i.content.includes("Error")||i.content.includes("failed")),r=t.filter(i=>i.content.includes("Modified file")),o=[];return r.length>0&&o.push(`Made ${r.length} file modifications in recent tasks.`),n.length>0&&o.push(`Encountered ${n.length} errors.`),t.length>0&&o.push(`Total ${t.length} significant events observed.`),o.length>0?`Reflection: ${o.join(" ")}`:"Reflection: No significant patterns observed in recent activity."}async function R(e,t){_(e,t)&&await S(e)}import{v4 as A}from"uuid";function L(e){let t=e.toolName,n=e.toolOutput||e.content;if(t==="Write"||t==="Edit")return{content:`Modified file via ${t}: ${n.slice(0,400)}`,importance:4,type:"event"};if(t==="Bash"){let r=e.toolInput?.command?.slice(0,100)||"Bash";return n.includes("FAIL")||n.includes("error:")||n.includes("Error:")?{content:`Command failed: ${r} ${n.slice(0,300)}`,importance:4,type:"event"}:n.includes("success")||n.includes("done")||n.includes("OK")?{content:`Command succeeded: ${r}`,importance:2,type:"event"}:{content:`Executed: ${r}`,importance:1,type:"event"}}return t==="Read"?{content:`Read file: ${e.toolInput?.file_path||e.toolInput?.path||"unknown"}`,importance:1,type:"thought"}:t==="Glob"||t==="Grep"?{content:`Searched: ${t} - ${e.toolInput?.pattern||"query"}`,importance:2,type:"thought"}:null}function F(e){let t=g(e,500,0),n=[];for(let r of t)if((r.type==="tool_result"||r.type==="tool_call")&&r.toolName){let o=L(r);o&&n.push(o)}else r.type==="error"&&n.push({content:`Error occurred: ${r.content.slice(0,400)}`,importance:4,type:"event"});return{facts:n}}function k(e){let t=e.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(n=>n.length>2);return[...new Set(t)].slice(0,20)}async function V(e,t){let n=!1;try{let{searchByBM25:i}=await import("./memories-VMOGFVPU.js");n=i(t,e,5).filter(s=>s.sourceTaskId===e).some(s=>s.type==="thought")}catch{}let{facts:r}=F(e),o=0;for(let i of r){if(n&&i.importance<=2)continue;let a=i.content.slice(0,500),s;try{s=await p(a)}catch{}let c=k(a),m={id:A(),roleId:t,type:i.type,content:a,embedding:s,keywords:c,importance:i.importance,sourceType:"task_complete",sourceTaskId:e,createdAt:Date.now(),lastAccessed:Date.now(),retrievedCount:0,tier:"episodic"};l(m),o++,await R(t,i.importance)}return o}export{F as extractKeyFacts,V as processTaskCompletion};
@@ -0,0 +1 @@
1
+ import{a,b,c}from"./chunk-IKPYPZ64.js";import"./chunk-SWP2JC54.js";import"./chunk-DVN3BFPP.js";import"./chunk-HQRUJQN7.js";import"./chunk-FPZEZYUB.js";import"./chunk-5EPG2US5.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{b as getRelevantMemoryContext,a as queryMemory,c as queryMemoryByTier};
@@ -0,0 +1 @@
1
+ import{a,b,c}from"./chunk-RI3V72RP.js";import"./chunk-GSFLLRS7.js";import"./chunk-L7JP7DUO.js";import"./chunk-RZ7LCZVK.js";import"./chunk-5EPG2US5.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{a as OutboundGateway,b as getOutboundGateway,c as isRecentlySent};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e}from"./chunk-BCH2HAIM.js";import"./chunk-WMB7P64J.js";import"./chunk-HQRUJQN7.js";import"./chunk-FPZEZYUB.js";import"./chunk-5EPG2US5.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{a as CHAT_MANAGER_ROLE_ID,b as PRESET_ROLE_NAMES,e as ensureAdamAutomatorRole,d as initializeDefaultRoles,c as isPresetRole};
@@ -0,0 +1 @@
1
+ import{e as a,f as b,g as c,h as d,j as e}from"./chunk-WMB7P64J.js";import"./chunk-HQRUJQN7.js";import"./chunk-FPZEZYUB.js";import"./chunk-5EPG2US5.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";e();export{b as ensureRoleWorkspace,a as getRoleWorkspacePath,d as syncRoleSettings,c as writeRoleCLAUDEmd};
@@ -1 +1 @@
1
- import{j as a,k as b,l as c,m as d,n as e,o as f,p as g,r as h}from"./chunk-7ZGSJCX5.js";import"./chunk-G5ESQEXN.js";import"./chunk-NCFVJCNQ.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";h();export{b as createRole,g as deleteRole,c as getRole,d as getRoleByName,f as listRoles,e as updateRole,a as validateAdditionalDirectories};
1
+ import{j as a,k as b,l as c,m as d,n as e,o as f,p as g,r as h}from"./chunk-HQRUJQN7.js";import"./chunk-FPZEZYUB.js";import"./chunk-5EPG2US5.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";h();export{b as createRole,g as deleteRole,c as getRole,d as getRoleByName,f as listRoles,e as updateRole,a as validateAdditionalDirectories};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"./chunk-V32YF3J5.js";import"./chunk-FXQAUQTI.js";import"./chunk-SWP2JC54.js";import"./chunk-GMMWA5EG.js";import"./chunk-L7JP7DUO.js";import"./chunk-YHVYX3F4.js";import"./chunk-PG6LMSX6.js";import"./chunk-UQJZU3R5.js";import"./chunk-7IFLU3CY.js";import"./chunk-GSMC3VUM.js";import"./chunk-7ZGSJCX5.js";import"./chunk-G5ESQEXN.js";import"./chunk-NCFVJCNQ.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{p as _resetForTest,e as archiveSession,b as createSession,g as deleteSession,c as getActiveSession,d as getSession,m as getTimeoutPollerInterval,i as incrementMessageCount,n as initSessionManager,j as listSessions,f as restoreSession,o as shutdownSessionManager,k as startTimeoutPoller,l as stopTimeoutPoller,h as touchSession,a as warmCache};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"./chunk-M4YI4WVX.js";import"./chunk-2YTDCR6A.js";import"./chunk-SWP2JC54.js";import"./chunk-B6LOT5CG.js";import"./chunk-L7JP7DUO.js";import"./chunk-DVN3BFPP.js";import"./chunk-PG6LMSX6.js";import"./chunk-UQJZU3R5.js";import"./chunk-7IFLU3CY.js";import"./chunk-GSMC3VUM.js";import"./chunk-HQRUJQN7.js";import"./chunk-FPZEZYUB.js";import"./chunk-5EPG2US5.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{p as _resetForTest,e as archiveSession,b as createSession,g as deleteSession,c as getActiveSession,d as getSession,m as getTimeoutPollerInterval,i as incrementMessageCount,n as initSessionManager,j as listSessions,f as restoreSession,o as shutdownSessionManager,k as startTimeoutPoller,l as stopTimeoutPoller,h as touchSession,a as warmCache};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i,j}from"./chunk-5XOTPEAK.js";import"./chunk-5EPG2US5.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{a as TemplateRoleConfigError,c as createTaskTemplate,j as deleteTaskTemplate,h as disableTaskTemplate,g as enableTaskTemplate,d as getTaskTemplate,i as getTaskTemplateDependents,f as listTaskTemplates,e as updateTaskTemplate,b as validateTemplateRoleConfig};
@@ -0,0 +1 @@
1
+ import{e as a}from"./chunk-ULTK7RD6.js";import"./chunk-6KF7OO2B.js";import"./chunk-IZNEOYRP.js";import"./chunk-N4ES7TCL.js";import"./chunk-NWMOV23A.js";import"./chunk-2L2347UQ.js";import"./chunk-K4C43YDD.js";import"./chunk-RI3V72RP.js";import"./chunk-GSFLLRS7.js";import"./chunk-WMB7P64J.js";import"./chunk-L7JP7DUO.js";import"./chunk-RZ7LCZVK.js";import"./chunk-PG6LMSX6.js";import"./chunk-UQJZU3R5.js";import"./chunk-7IFLU3CY.js";import"./chunk-GSMC3VUM.js";import"./chunk-HQRUJQN7.js";import"./chunk-FPZEZYUB.js";import"./chunk-5EPG2US5.js";import"./chunk-WBAPIPST.js";import"./chunk-MRTJFYPR.js";import"./chunk-FCV2DPZQ.js";export{a as WorkflowExecutor};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adam-agent-server",
3
- "version": "1.6.0",
3
+ "version": "1.7.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
  "type": "module",
@@ -17,48 +17,48 @@
17
17
  "onnxruntime-node": "^1.24.3"
18
18
  },
19
19
  "dependencies": {
20
- "@anthropic-ai/claude-agent-sdk": "^0.2.92",
20
+ "@anthropic-ai/claude-agent-sdk": "^0.2.112",
21
21
  "@anthropic-ai/sdk": "^0.80.0",
22
- "@fastify/cors": "^10.0.0",
23
- "@fastify/static": "^9.0.0",
22
+ "@fastify/cors": "^10.1.0",
23
+ "@fastify/static": "^9.1.1",
24
24
  "@fastify/swagger": "^9.7.0",
25
25
  "@fastify/swagger-ui": "^5.2.5",
26
- "@fastify/websocket": "^11.0.0",
27
- "better-sqlite3": "^11.0.0",
26
+ "@fastify/websocket": "^11.2.0",
27
+ "better-sqlite3": "^11.10.0",
28
28
  "bree": "^9.2.9",
29
- "discord.js": "^14.16.0",
30
- "chalk": "^5.0.0",
31
- "commander": "^13.0.0",
29
+ "chalk": "^5.6.2",
30
+ "commander": "^13.1.0",
32
31
  "cron-parser": "^5.5.0",
33
- "fastify": "^5.0.0",
34
- "ink": "^5.0.0",
32
+ "discord.js": "^14.26.3",
33
+ "fastify": "^5.8.5",
34
+ "ink": "^5.2.1",
35
35
  "ink-spinner": "^5.0.0",
36
36
  "ink-text-input": "^6.0.0",
37
37
  "pino": "^10.3.1",
38
38
  "pino-pretty": "^13.1.3",
39
- "react": "^18.0.0",
40
- "uuid": "^11.0.0",
41
- "yaml": "^2.6.0",
39
+ "react": "^18.3.1",
40
+ "uuid": "^11.1.0",
41
+ "yaml": "^2.8.3",
42
42
  "zod": "^4.3.6"
43
43
  },
44
44
  "devDependencies": {
45
- "conventional-commits-parser": "^3.0.0",
46
45
  "@testing-library/react": "^16.3.2",
47
- "@types/better-sqlite3": "^7.6.0",
48
- "@types/node": "^22.0.0",
49
- "@types/react": "^18.0.0",
46
+ "@types/better-sqlite3": "^7.6.13",
47
+ "@types/node": "^22.19.17",
48
+ "@types/react": "^18.3.28",
50
49
  "@types/react-dom": "^19.2.3",
51
50
  "@types/uuid": "^10.0.0",
52
51
  "@types/ws": "^8.18.1",
53
- "@vitest/coverage-v8": "^4.1.0",
54
- "happy-dom": "^20.8.4",
52
+ "@vitest/coverage-v8": "^4.1.4",
53
+ "conventional-commits-parser": "^3.2.4",
54
+ "happy-dom": "^20.9.0",
55
55
  "ink-testing-library": "^4.0.0",
56
56
  "react-dom": "^18.3.1",
57
- "tsup": "^8.0.0",
58
- "tsx": "^4.0.0",
59
- "typescript": "^5.7.0",
60
- "vitest": "^4.1.0",
61
- "ws": "^8.19.0"
57
+ "tsup": "^8.5.1",
58
+ "tsx": "^4.21.0",
59
+ "typescript": "^5.9.3",
60
+ "vitest": "^4.1.4",
61
+ "ws": "^8.20.0"
62
62
  },
63
63
  "engines": {
64
64
  "node": ">=20.0.0"
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{C as t,L as n,O as r,at as i,ct as a,q as o}from"./vendor-icons-Dk0hMuJz.js";import{f as s,r as c,t as l}from"./vendor-react-C6faO6LO.js";import{n as u}from"./dist-Bdqp1ixJ.js";import{t as d}from"./index-qYKJGoIB.js";import{i as f,r as p,t as m}from"./Card-rKfViPS2.js";import{t as h}from"./PageHeader-CHSgtxPw.js";import{t as g}from"./SectionHeader-C2WpiwJ5.js";import{n as _}from"./format-CHfBBLog.js";var v=e(a(),1),y=l();function b(){let{id:e}=s(),[a,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)(i,{size:14}),` Back to Channels`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-danger)]`,children:T})]});if(!a)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)(i,{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={...a.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)(i,{size:14}),` Back to Channels`]}),(0,y.jsx)(h,{eyebrow:`Channel`,title:a.name,compact:!0,description:`Connectivity, delivery policy, and recent outbound activity.`,metrics:[{label:`Status`,value:(0,y.jsx)(d,{variant:D(a.status),children:a.status})},{label:`Platform`,value:O(a.platform)},{label:`Enabled`,value:a.enabled?`Yes`:`No`},{label:`Messages`,value:a.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:a.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:a.linkedRoleId?`${a.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:o,label:`Created`,value:_(a.createdAt),mono:!0}),(0,y.jsx)(x,{icon:r,label:`Messages`,value:String(a.messageCount),mono:!0}),a.lastMessageAt&&(0,y.jsx)(x,{icon:o,label:`Last Message`,value:_(a.lastMessageAt),mono:!0}),a.linkedRoleId&&(0,y.jsx)(x,{icon:t,label:`Linked Role`,value:a.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)(r,{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{C as t,L as n,O as r,at as i,ct as a,q as o}from"./vendor-icons-Dk0hMuJz.js";import{f as s,r as c,t as l}from"./vendor-react-C6faO6LO.js";import{n as u}from"./dist-Bdqp1ixJ.js";import{t as d}from"./index-DYsO5Awn.js";import{i as f,r as p,t as m}from"./Card-rKfViPS2.js";import{t as h}from"./PageHeader-CHSgtxPw.js";import{t as g}from"./SectionHeader-C2WpiwJ5.js";import{n as _}from"./format-CHfBBLog.js";var v=e(a(),1),y=l();function b(){let{id:e}=s(),[a,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)(i,{size:14}),` Back to Channels`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-danger)]`,children:T})]});if(!a)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)(i,{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={...a.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)(i,{size:14}),` Back to Channels`]}),(0,y.jsx)(h,{eyebrow:`Channel`,title:a.name,compact:!0,description:`Connectivity, delivery policy, and recent outbound activity.`,metrics:[{label:`Status`,value:(0,y.jsx)(d,{variant:D(a.status),children:a.status})},{label:`Platform`,value:O(a.platform)},{label:`Enabled`,value:a.enabled?`Yes`:`No`},{label:`Messages`,value:a.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:a.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:a.linkedRoleId?`${a.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:o,label:`Created`,value:_(a.createdAt),mono:!0}),(0,y.jsx)(x,{icon:r,label:`Messages`,value:String(a.messageCount),mono:!0}),a.lastMessageAt&&(0,y.jsx)(x,{icon:o,label:`Last Message`,value:_(a.lastMessageAt),mono:!0}),a.linkedRoleId&&(0,y.jsx)(x,{icon:t,label:`Linked Role`,value:a.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)(r,{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{C as t,E as n,O as r,S as i,b as a,ct as o,n as s,s as c,w as l}from"./vendor-icons-Dk0hMuJz.js";import{t as u}from"./vendor-react-C6faO6LO.js";import{n as d}from"./dist-Bdqp1ixJ.js";import{t as f}from"./Button-DuQctNms.js";import{t as p}from"./index-qYKJGoIB.js";import{i as m,r as h,t as g}from"./Card-rKfViPS2.js";import{t as _}from"./PageHeader-CHSgtxPw.js";import{t as v}from"./SectionHeader-C2WpiwJ5.js";import{t as y}from"./EmptyState-CIdIlMbn.js";import{t as b}from"./ui-B_uMx2Fy.js";var x=e(o(),1),S=u(),C=[`telegram`,`slack`,`discord`,`openclaw`,`wechat`,`whatsapp`],w={telegram:`{
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{C as t,E as n,O as r,S as i,b as a,ct as o,n as s,s as c,w as l}from"./vendor-icons-Dk0hMuJz.js";import{t as u}from"./vendor-react-C6faO6LO.js";import{n as d}from"./dist-Bdqp1ixJ.js";import{t as f}from"./Button-DuQctNms.js";import{t as p}from"./index-DYsO5Awn.js";import{i as m,r as h,t as g}from"./Card-rKfViPS2.js";import{t as _}from"./PageHeader-CHSgtxPw.js";import{t as v}from"./SectionHeader-C2WpiwJ5.js";import{t as y}from"./EmptyState-CIdIlMbn.js";import{t as b}from"./ui-B_uMx2Fy.js";var x=e(o(),1),S=u(),C=[`telegram`,`slack`,`discord`,`openclaw`,`wechat`,`whatsapp`],w={telegram:`{
2
2
  "botToken": ""
3
3
  }`,slack:`{
4
4
  "botToken": "",
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{N as t,Q as n,Y as r,Z as i,ct as a,st as o}from"./vendor-icons-Dk0hMuJz.js";import{r as s,t as c}from"./vendor-react-C6faO6LO.js";import{t as l}from"./vendor-state-DahK0J-G.js";import{n as u,r as d,t as f}from"./index-qYKJGoIB.js";import{i as p,n as m,r as h,t as g}from"./Card-rKfViPS2.js";import{t as _}from"./PageHeader-CHSgtxPw.js";import{t as v}from"./SectionHeader-C2WpiwJ5.js";import{a as y,o as b,t as x}from"./format-CHfBBLog.js";var S=e(a(),1),C=c();function w(){let{tasks:e,goals:a,roles:c,stats:w,readiness:D,executionPool:O}=d(l(e=>({tasks:e.tasks,goals:e.goals,roles:e.roles,stats:e.stats,readiness:e.readiness,executionPool:e.executionPool}))),k=d(e=>e.fetchTasks),A=d(e=>e.fetchGoals),j=d(e=>e.fetchRoles),M=d(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:a.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)(h,{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:u(R.status),children:R.status}):null]}),(0,C.jsx)(m,{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)(r,{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,n=c.filter(e=>e.status===`probation`).length,r=c.filter(e=>e.status===`retired`).length,i=[n>0?`${n} probation`:``,r>0?`${r} retired`:``].filter(Boolean).join(` · `);return(0,C.jsx)(T,{icon:o,label:`Role Health`,value:i?`${e}/${t} | ${i}`:`${e}/${t}`,color:r>0?`text-[var(--app-danger)]`:n>0?`text-[var(--app-warning)]`:`text-[var(--app-success)]`})})(),(0,C.jsx)(T,{icon:n,label:`Failed`,value:F,color:`text-[var(--app-danger)]`}),(0,C.jsx)(T,{icon:i,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:u(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{N as t,Q as n,Y as r,Z as i,ct as a,st as o}from"./vendor-icons-Dk0hMuJz.js";import{r as s,t as c}from"./vendor-react-C6faO6LO.js";import{t as l}from"./vendor-state-DahK0J-G.js";import{n as u,r as d,t as f}from"./index-DYsO5Awn.js";import{i as p,n as m,r as h,t as g}from"./Card-rKfViPS2.js";import{t as _}from"./PageHeader-CHSgtxPw.js";import{t as v}from"./SectionHeader-C2WpiwJ5.js";import{a as y,o as b,t as x}from"./format-CHfBBLog.js";var S=e(a(),1),C=c();function w(){let{tasks:e,goals:a,roles:c,stats:w,readiness:D,executionPool:O}=d(l(e=>({tasks:e.tasks,goals:e.goals,roles:e.roles,stats:e.stats,readiness:e.readiness,executionPool:e.executionPool}))),k=d(e=>e.fetchTasks),A=d(e=>e.fetchGoals),j=d(e=>e.fetchRoles),M=d(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:a.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)(h,{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:u(R.status),children:R.status}):null]}),(0,C.jsx)(m,{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)(r,{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,n=c.filter(e=>e.status===`probation`).length,r=c.filter(e=>e.status===`retired`).length,i=[n>0?`${n} probation`:``,r>0?`${r} retired`:``].filter(Boolean).join(` · `);return(0,C.jsx)(T,{icon:o,label:`Role Health`,value:i?`${e}/${t} | ${i}`:`${e}/${t}`,color:r>0?`text-[var(--app-danger)]`:n>0?`text-[var(--app-warning)]`:`text-[var(--app-success)]`})})(),(0,C.jsx)(T,{icon:n,label:`Failed`,value:F,color:`text-[var(--app-danger)]`}),(0,C.jsx)(T,{icon:i,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:u(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{H as t,S as n,U as r,ct as i,o as a,s as o}from"./vendor-icons-Dk0hMuJz.js";import{t as s}from"./vendor-react-C6faO6LO.js";import{i as c,n as l}from"./dist-Bdqp1ixJ.js";import{t as u}from"./Button-DuQctNms.js";import{i as d}from"./index-qYKJGoIB.js";import{i as f,r as p,t as m}from"./Card-rKfViPS2.js";import{t as h}from"./ui-B_uMx2Fy.js";var g=e(i(),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:i,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 l(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 l(`/config/env`,{method:`PUT`,body:JSON.stringify(e)}):await l(`/roles/${c}`,{method:`PATCH`,body:JSON.stringify({envVars:e})}),d.success(`Environment variables saved`),i(),M()}catch(e){d.error(e instanceof Error?e.message:`Failed to save`)}finally{T(!1)}},B=async()=>{try{await l(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 l(s===`global`?`/config/load-from-env`:`/roles/${c}/load-from-env`,{method:`POST`}),d.success(`Loaded .env to DB`),i(),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)(u,{variant:`ghost`,size:`sm`,onClick:P,children:[(0,_.jsx)(n,{size:h.sm}),`Add`]}),N()&&(0,_.jsx)(u,{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)(a,{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)(u,{variant:`ghost`,size:`sm`,className:`text-xs`,onClick:()=>void B(),children:`DB → .env`}),(0,_.jsx)(u,{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,n)=>{let i=b.test(e.key),a=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(n,`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&&!a?`password`:`text`,placeholder:`value`,value:e.value,onChange:e=>I(n,`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:a?(0,_.jsx)(r,{size:12}):(0,_.jsx)(t,{size:12})})]}),(0,_.jsx)(u,{variant:`ghost`,size:`sm`,className:`self-end text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)] md:self-auto`,onClick:()=>F(n),children:(0,_.jsx)(o,{size:14})})]},n)})]})]})}export{x as t};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{H as t,S as n,U as r,ct as i,o as a,s as o}from"./vendor-icons-Dk0hMuJz.js";import{t as s}from"./vendor-react-C6faO6LO.js";import{i as c,n as l}from"./dist-Bdqp1ixJ.js";import{t as u}from"./Button-DuQctNms.js";import{i as d}from"./index-DYsO5Awn.js";import{i as f,r as p,t as m}from"./Card-rKfViPS2.js";import{t as h}from"./ui-B_uMx2Fy.js";var g=e(i(),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:i,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 l(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 l(`/config/env`,{method:`PUT`,body:JSON.stringify(e)}):await l(`/roles/${c}`,{method:`PATCH`,body:JSON.stringify({envVars:e})}),d.success(`Environment variables saved`),i(),M()}catch(e){d.error(e instanceof Error?e.message:`Failed to save`)}finally{T(!1)}},B=async()=>{try{await l(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 l(s===`global`?`/config/load-from-env`:`/roles/${c}/load-from-env`,{method:`POST`}),d.success(`Loaded .env to DB`),i(),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)(u,{variant:`ghost`,size:`sm`,onClick:P,children:[(0,_.jsx)(n,{size:h.sm}),`Add`]}),N()&&(0,_.jsx)(u,{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)(a,{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)(u,{variant:`ghost`,size:`sm`,className:`text-xs`,onClick:()=>void B(),children:`DB → .env`}),(0,_.jsx)(u,{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,n)=>{let i=b.test(e.key),a=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(n,`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&&!a?`password`:`text`,placeholder:`value`,value:e.value,onChange:e=>I(n,`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:a?(0,_.jsx)(r,{size:12}):(0,_.jsx)(t,{size:12})})]}),(0,_.jsx)(u,{variant:`ghost`,size:`sm`,className:`self-end text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)] md:self-auto`,onClick:()=>F(n),children:(0,_.jsx)(o,{size:14})})]},n)})]})]})}export{x as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{at as t,ct as n,y as r}from"./vendor-icons-Dk0hMuJz.js";import{d as i,f as a,t as o}from"./vendor-react-C6faO6LO.js";import{n as s}from"./dist-Bdqp1ixJ.js";import{t as c}from"./Button-DuQctNms.js";import{i as l,t as u}from"./index-qYKJGoIB.js";import{t as d}from"./Card-rKfViPS2.js";import{t as f}from"./SectionHeader-C2WpiwJ5.js";import{t as p}from"./EmptyState-CIdIlMbn.js";import{a as m,i as h,n as g,o as _,r as v,t as y}from"./Table-DuOLbyJQ.js";var b=e(n(),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(),n=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 s(`/event-defs/${e}`))}catch{l.error(`Event not found`),n(`/events`)}finally{E(!1)}}},[e,n]),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 s(`/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 s(`/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)(c,{variant:`ghost`,size:`sm`,onClick:()=>n(`/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)(c,{variant:`ghost`,size:`sm`,onClick:()=>void G(),children:(0,x.jsx)(r,{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)(c,{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)(r,{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)(c,{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)(r,{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:()=>n(`/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)(c,{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{at as t,ct as n,y as r}from"./vendor-icons-Dk0hMuJz.js";import{d as i,f as a,t as o}from"./vendor-react-C6faO6LO.js";import{n as s}from"./dist-Bdqp1ixJ.js";import{t as c}from"./Button-DuQctNms.js";import{i as l,t as u}from"./index-DYsO5Awn.js";import{t as d}from"./Card-rKfViPS2.js";import{t as f}from"./SectionHeader-C2WpiwJ5.js";import{t as p}from"./EmptyState-CIdIlMbn.js";import{a as m,i as h,n as g,o as _,r as v,t as y}from"./Table-DuOLbyJQ.js";var b=e(n(),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(),n=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 s(`/event-defs/${e}`))}catch{l.error(`Event not found`),n(`/events`)}finally{E(!1)}}},[e,n]),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 s(`/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 s(`/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)(c,{variant:`ghost`,size:`sm`,onClick:()=>n(`/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)(c,{variant:`ghost`,size:`sm`,onClick:()=>void G(),children:(0,x.jsx)(r,{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)(c,{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)(r,{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)(c,{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)(r,{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:()=>n(`/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)(c,{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{E as t,S as n,T as ee,ct as r,s as te,t as ne,y as re}from"./vendor-icons-Dk0hMuJz.js";import{d as ie,t as i}from"./vendor-react-C6faO6LO.js";import{n as a}from"./dist-Bdqp1ixJ.js";import{a as ae,c as oe,i as o,n as s,o as c,r as l,s as u,t as d}from"./AlertDialog-CfeiyMrc.js";import{t as f}from"./Button-DuQctNms.js";import{i as p,t as se}from"./index-qYKJGoIB.js";import{t as m}from"./Card-rKfViPS2.js";import{t as ce}from"./SectionHeader-C2WpiwJ5.js";import{a as le}from"./format-CHfBBLog.js";import{t as ue}from"./EmptyState-CIdIlMbn.js";import{a as de,i as h,n as fe,o as g,r as _,t as pe}from"./Table-DuOLbyJQ.js";import{t as me}from"./Switch-CULsD-kC.js";var v=e(r(),1),y=i(),he={webhook:`info`,directory_watch:`warning`,cron:`success`,manual:`muted`};function b(e){let t=e.trim().split(/\s+/);return t.length===5?t.every(e=>/^(\*|(\*\/)?\d+(-\d+)?(,\d+(-\d+)?)*)$/.test(e)):!1}function x(){let e=ie(),[r,i]=(0,v.useState)([]),[x,ge]=(0,v.useState)(!0),[_e,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(``),[T,ve]=(0,v.useState)(`webhook`),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(``),[M,N]=(0,v.useState)(``),[P,F]=(0,v.useState)(!1),[I,L]=(0,v.useState)(null),[R,ye]=(0,v.useState)(``),[z,B]=(0,v.useState)(``),[V,be]=(0,v.useState)(`webhook`),[H,U]=(0,v.useState)(``),[W,G]=(0,v.useState)(``),[xe,K]=(0,v.useState)(``),[Se,q]=(0,v.useState)(!1),[J,Y]=(0,v.useState)(null),[X,Z]=(0,v.useState)(null),[Q,Ce]=(0,v.useState)(``),[we,Te]=(0,v.useState)(!1),$=(0,v.useCallback)(async()=>{ge(!0);try{i(await a(`/event-defs`))}catch{p.error(`Failed to load events`)}finally{ge(!1)}},[]);(0,v.useEffect)(()=>{$()},[$]);let Ee=async()=>{if(C.trim()){if(T===`cron`&&!b(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 a(`/event-defs`,{method:`POST`,body:JSON.stringify(e)}),w(``),D(``),k(``),j(``),N(``),S(!1),$(),p.success(`Event created`)}catch(e){let t=e instanceof Error?e.message:`Failed to create event`;p.error(t)}finally{F(!1)}}},De=e=>{L(e.id),ye(e.name),B(e.description??``),be(e.sourceType),U(e.sourceConfig?.path??``),G(e.sourceConfig?.cron??``),K(``)},Oe=async()=>{if(!(!I||!R.trim())){if(V===`cron`&&!b(W)){K(`Invalid cron expression`);return}q(!0);try{let e={name:R.trim(),description:z.trim()||void 0};V===`directory_watch`?e.sourceConfig={path:H.trim(),stability_delay_ms:5e3}:V===`cron`&&(e.sourceConfig={cron:W.trim()}),await a(`/event-defs/${I}`,{method:`PATCH`,body:JSON.stringify(e)}),L(null),$(),p.success(`Event updated`)}catch(e){let t=e instanceof Error?e.message:`Failed to update event`;p.error(t)}finally{q(!1)}}},ke=async e=>{try{await a(`/event-defs/${e.id}`,{method:`PATCH`,body:JSON.stringify({enabled:!e.enabled})}),$()}catch(e){let t=e instanceof Error?e.message:`Failed to toggle`;p.error(t)}},Ae=async e=>{try{await a(`/event-defs/${e}`,{method:`DELETE`}),Y(null),$(),p.success(`Event deleted`)}catch(e){let t=e instanceof Error?e.message:`Failed to delete`;p.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 a(`/event-defs/${e}/fire`,{method:`POST`,body:JSON.stringify(t)}),Z(null),Ce(``),p.success(`Event fired`)}catch(e){let t=e instanceof Error?e.message:`Failed to fire event`;p.error(t)}finally{Te(!1)}},Me=r.find(e=>e.id===J);return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsx)(ce,{title:`Events`,description:`Event definitions that trigger automations. Configure webhooks, schedules, or file watchers.`,compact:!0,action:(0,y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,y.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>void $(),children:(0,y.jsx)(re,{size:14})}),(0,y.jsxs)(f,{size:`sm`,onClick:()=>S(!_e),children:[(0,y.jsx)(n,{size:14}),`New Event`]})]})}),_e&&(0,y.jsxs)(m,{className:`space-y-3`,children:[(0,y.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`New Event`}),(0,y.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,y.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,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Source:`}),(0,y.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,y.jsx)(`option`,{value:`webhook`,children:`Webhook (HTTP)`}),(0,y.jsx)(`option`,{value:`cron`,children:`Schedule (Cron)`}),(0,y.jsx)(`option`,{value:`directory_watch`,children:`File Watcher`}),(0,y.jsx)(`option`,{value:`manual`,children:`Manual`})]})]}),T===`directory_watch`&&(0,y.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,y.jsxs)(`div`,{className:`space-y-1`,children:[(0,y.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,y.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:M})]}),(0,y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,y.jsx)(f,{onClick:()=>void Ee(),disabled:P||!C.trim()||T===`directory_watch`&&!O.trim(),children:P?`Creating...`:`Create`}),(0,y.jsx)(f,{variant:`ghost`,onClick:()=>S(!1),children:`Cancel`})]})]}),I!==null&&(r.find(e=>e.id===I)?(0,y.jsxs)(m,{className:`space-y-3`,children:[(0,y.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Edit Event`}),(0,y.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=>ye(e.target.value)}),(0,y.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:z,onChange:e=>B(e.target.value)}),V===`directory_watch`&&(0,y.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,y.jsxs)(`div`,{className:`space-y-1`,children:[(0,y.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),K(``)}}),xe&&(0,y.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:xe})]}),(0,y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,y.jsx)(f,{onClick:()=>void Oe(),disabled:Se||!R.trim(),children:Se?`Saving...`:`Save`}),(0,y.jsx)(f,{variant:`ghost`,onClick:()=>L(null),children:`Cancel`})]})]}):null),(0,y.jsx)(m,{padding:!1,children:x?(0,y.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,y.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,y.jsx)(ue,{icon:(0,y.jsx)(ne,{size:32}),title:`No events`,description:`Events are triggered by webhooks, schedules, or file changes and can start automations.`}):(0,y.jsxs)(pe,{children:[(0,y.jsx)(de,{children:(0,y.jsxs)(g,{children:[(0,y.jsx)(h,{children:`Name`}),(0,y.jsx)(h,{children:`Source`}),(0,y.jsx)(h,{children:`Enabled`}),(0,y.jsx)(h,{children:`Last Fired`}),(0,y.jsx)(h,{children:`Actions`})]})}),(0,y.jsx)(fe,{children:r.map(n=>(0,y.jsxs)(g,{children:[(0,y.jsxs)(_,{children:[(0,y.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,y.jsx)(`div`,{className:`text-xs text-[var(--app-text-muted)] truncate max-w-[200px]`,children:n.description})]}),(0,y.jsx)(_,{children:(0,y.jsx)(se,{variant:he[n.sourceType],children:n.sourceType===`directory_watch`?`file watcher`:n.sourceType})}),(0,y.jsx)(_,{children:(0,y.jsx)(me,{checked:n.enabled,onCheckedChange:()=>void ke(n),"aria-label":`Toggle ${n.name}`})}),(0,y.jsx)(_,{className:`text-xs text-[var(--app-text-muted)]`,children:n.lastFiredAt?le(n.lastFiredAt):`—`}),(0,y.jsx)(_,{children:(0,y.jsxs)(`div`,{className:`flex gap-1`,children:[(0,y.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>De(n),title:`Edit`,children:(0,y.jsx)(t,{size:12})}),n.sourceType===`manual`&&n.enabled&&(0,y.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>Z(n.id),title:`Fire now`,children:(0,y.jsx)(ee,{size:12})}),(0,y.jsx)(f,{variant:`ghost`,size:`sm`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,onClick:()=>Y(n.id),title:`Delete`,children:(0,y.jsx)(te,{size:12})})]})})]},n.id))})]})}),(0,y.jsx)(d,{open:X!==null,onOpenChange:e=>{e||Z(null)},children:(0,y.jsxs)(o,{children:[(0,y.jsxs)(u,{children:[(0,y.jsx)(oe,{children:`Fire Event`}),(0,y.jsx)(ae,{children:`Fire the manual event immediately. Optionally provide a JSON payload.`})]}),(0,y.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,y.jsxs)(c,{children:[(0,y.jsx)(l,{children:`Cancel`}),(0,y.jsx)(s,{onClick:()=>{X&&je(X),Z(null)},disabled:we,children:we?`Firing...`:`Fire Event`})]})]})}),(0,y.jsx)(d,{open:J!==null,onOpenChange:e=>{e||Y(null)},children:(0,y.jsxs)(o,{children:[(0,y.jsxs)(u,{children:[(0,y.jsx)(oe,{children:`Delete Event`}),(0,y.jsxs)(ae,{children:[`Delete “`,Me?.name,`”? This action cannot be undone.`]})]}),(0,y.jsxs)(c,{children:[(0,y.jsx)(l,{children:`Cancel`}),(0,y.jsx)(s,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger)]`,onClick:()=>{J&&Ae(J)},children:`Delete`})]})]})})]})}export{x as Events};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{E as t,S as n,T as ee,ct as r,s as te,t as ne,y as re}from"./vendor-icons-Dk0hMuJz.js";import{d as ie,t as i}from"./vendor-react-C6faO6LO.js";import{n as a}from"./dist-Bdqp1ixJ.js";import{a as ae,c as oe,i as o,n as s,o as c,r as l,s as u,t as d}from"./AlertDialog-CfeiyMrc.js";import{t as f}from"./Button-DuQctNms.js";import{i as p,t as se}from"./index-DYsO5Awn.js";import{t as m}from"./Card-rKfViPS2.js";import{t as ce}from"./SectionHeader-C2WpiwJ5.js";import{a as le}from"./format-CHfBBLog.js";import{t as ue}from"./EmptyState-CIdIlMbn.js";import{a as de,i as h,n as fe,o as g,r as _,t as pe}from"./Table-DuOLbyJQ.js";import{t as me}from"./Switch-CfTpXW9_.js";var v=e(r(),1),y=i(),he={webhook:`info`,directory_watch:`warning`,cron:`success`,manual:`muted`};function b(e){let t=e.trim().split(/\s+/);return t.length===5?t.every(e=>/^(\*|(\*\/)?\d+(-\d+)?(,\d+(-\d+)?)*)$/.test(e)):!1}function x(){let e=ie(),[r,i]=(0,v.useState)([]),[x,ge]=(0,v.useState)(!0),[_e,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(``),[T,ve]=(0,v.useState)(`webhook`),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(``),[M,N]=(0,v.useState)(``),[P,F]=(0,v.useState)(!1),[I,L]=(0,v.useState)(null),[R,ye]=(0,v.useState)(``),[z,B]=(0,v.useState)(``),[V,be]=(0,v.useState)(`webhook`),[H,U]=(0,v.useState)(``),[W,G]=(0,v.useState)(``),[xe,K]=(0,v.useState)(``),[Se,q]=(0,v.useState)(!1),[J,Y]=(0,v.useState)(null),[X,Z]=(0,v.useState)(null),[Q,Ce]=(0,v.useState)(``),[we,Te]=(0,v.useState)(!1),$=(0,v.useCallback)(async()=>{ge(!0);try{i(await a(`/event-defs`))}catch{p.error(`Failed to load events`)}finally{ge(!1)}},[]);(0,v.useEffect)(()=>{$()},[$]);let Ee=async()=>{if(C.trim()){if(T===`cron`&&!b(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 a(`/event-defs`,{method:`POST`,body:JSON.stringify(e)}),w(``),D(``),k(``),j(``),N(``),S(!1),$(),p.success(`Event created`)}catch(e){let t=e instanceof Error?e.message:`Failed to create event`;p.error(t)}finally{F(!1)}}},De=e=>{L(e.id),ye(e.name),B(e.description??``),be(e.sourceType),U(e.sourceConfig?.path??``),G(e.sourceConfig?.cron??``),K(``)},Oe=async()=>{if(!(!I||!R.trim())){if(V===`cron`&&!b(W)){K(`Invalid cron expression`);return}q(!0);try{let e={name:R.trim(),description:z.trim()||void 0};V===`directory_watch`?e.sourceConfig={path:H.trim(),stability_delay_ms:5e3}:V===`cron`&&(e.sourceConfig={cron:W.trim()}),await a(`/event-defs/${I}`,{method:`PATCH`,body:JSON.stringify(e)}),L(null),$(),p.success(`Event updated`)}catch(e){let t=e instanceof Error?e.message:`Failed to update event`;p.error(t)}finally{q(!1)}}},ke=async e=>{try{await a(`/event-defs/${e.id}`,{method:`PATCH`,body:JSON.stringify({enabled:!e.enabled})}),$()}catch(e){let t=e instanceof Error?e.message:`Failed to toggle`;p.error(t)}},Ae=async e=>{try{await a(`/event-defs/${e}`,{method:`DELETE`}),Y(null),$(),p.success(`Event deleted`)}catch(e){let t=e instanceof Error?e.message:`Failed to delete`;p.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 a(`/event-defs/${e}/fire`,{method:`POST`,body:JSON.stringify(t)}),Z(null),Ce(``),p.success(`Event fired`)}catch(e){let t=e instanceof Error?e.message:`Failed to fire event`;p.error(t)}finally{Te(!1)}},Me=r.find(e=>e.id===J);return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsx)(ce,{title:`Events`,description:`Event definitions that trigger automations. Configure webhooks, schedules, or file watchers.`,compact:!0,action:(0,y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,y.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>void $(),children:(0,y.jsx)(re,{size:14})}),(0,y.jsxs)(f,{size:`sm`,onClick:()=>S(!_e),children:[(0,y.jsx)(n,{size:14}),`New Event`]})]})}),_e&&(0,y.jsxs)(m,{className:`space-y-3`,children:[(0,y.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`New Event`}),(0,y.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,y.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,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Source:`}),(0,y.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,y.jsx)(`option`,{value:`webhook`,children:`Webhook (HTTP)`}),(0,y.jsx)(`option`,{value:`cron`,children:`Schedule (Cron)`}),(0,y.jsx)(`option`,{value:`directory_watch`,children:`File Watcher`}),(0,y.jsx)(`option`,{value:`manual`,children:`Manual`})]})]}),T===`directory_watch`&&(0,y.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,y.jsxs)(`div`,{className:`space-y-1`,children:[(0,y.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,y.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:M})]}),(0,y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,y.jsx)(f,{onClick:()=>void Ee(),disabled:P||!C.trim()||T===`directory_watch`&&!O.trim(),children:P?`Creating...`:`Create`}),(0,y.jsx)(f,{variant:`ghost`,onClick:()=>S(!1),children:`Cancel`})]})]}),I!==null&&(r.find(e=>e.id===I)?(0,y.jsxs)(m,{className:`space-y-3`,children:[(0,y.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Edit Event`}),(0,y.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=>ye(e.target.value)}),(0,y.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:z,onChange:e=>B(e.target.value)}),V===`directory_watch`&&(0,y.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,y.jsxs)(`div`,{className:`space-y-1`,children:[(0,y.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),K(``)}}),xe&&(0,y.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:xe})]}),(0,y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,y.jsx)(f,{onClick:()=>void Oe(),disabled:Se||!R.trim(),children:Se?`Saving...`:`Save`}),(0,y.jsx)(f,{variant:`ghost`,onClick:()=>L(null),children:`Cancel`})]})]}):null),(0,y.jsx)(m,{padding:!1,children:x?(0,y.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,y.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,y.jsx)(ue,{icon:(0,y.jsx)(ne,{size:32}),title:`No events`,description:`Events are triggered by webhooks, schedules, or file changes and can start automations.`}):(0,y.jsxs)(pe,{children:[(0,y.jsx)(de,{children:(0,y.jsxs)(g,{children:[(0,y.jsx)(h,{children:`Name`}),(0,y.jsx)(h,{children:`Source`}),(0,y.jsx)(h,{children:`Enabled`}),(0,y.jsx)(h,{children:`Last Fired`}),(0,y.jsx)(h,{children:`Actions`})]})}),(0,y.jsx)(fe,{children:r.map(n=>(0,y.jsxs)(g,{children:[(0,y.jsxs)(_,{children:[(0,y.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,y.jsx)(`div`,{className:`text-xs text-[var(--app-text-muted)] truncate max-w-[200px]`,children:n.description})]}),(0,y.jsx)(_,{children:(0,y.jsx)(se,{variant:he[n.sourceType],children:n.sourceType===`directory_watch`?`file watcher`:n.sourceType})}),(0,y.jsx)(_,{children:(0,y.jsx)(me,{checked:n.enabled,onCheckedChange:()=>void ke(n),"aria-label":`Toggle ${n.name}`})}),(0,y.jsx)(_,{className:`text-xs text-[var(--app-text-muted)]`,children:n.lastFiredAt?le(n.lastFiredAt):`—`}),(0,y.jsx)(_,{children:(0,y.jsxs)(`div`,{className:`flex gap-1`,children:[(0,y.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>De(n),title:`Edit`,children:(0,y.jsx)(t,{size:12})}),n.sourceType===`manual`&&n.enabled&&(0,y.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>Z(n.id),title:`Fire now`,children:(0,y.jsx)(ee,{size:12})}),(0,y.jsx)(f,{variant:`ghost`,size:`sm`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,onClick:()=>Y(n.id),title:`Delete`,children:(0,y.jsx)(te,{size:12})})]})})]},n.id))})]})}),(0,y.jsx)(d,{open:X!==null,onOpenChange:e=>{e||Z(null)},children:(0,y.jsxs)(o,{children:[(0,y.jsxs)(u,{children:[(0,y.jsx)(oe,{children:`Fire Event`}),(0,y.jsx)(ae,{children:`Fire the manual event immediately. Optionally provide a JSON payload.`})]}),(0,y.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,y.jsxs)(c,{children:[(0,y.jsx)(l,{children:`Cancel`}),(0,y.jsx)(s,{onClick:()=>{X&&je(X),Z(null)},disabled:we,children:we?`Firing...`:`Fire Event`})]})]})}),(0,y.jsx)(d,{open:J!==null,onOpenChange:e=>{e||Y(null)},children:(0,y.jsxs)(o,{children:[(0,y.jsxs)(u,{children:[(0,y.jsx)(oe,{children:`Delete Event`}),(0,y.jsxs)(ae,{children:[`Delete “`,Me?.name,`”? This action cannot be undone.`]})]}),(0,y.jsxs)(c,{children:[(0,y.jsx)(l,{children:`Cancel`}),(0,y.jsx)(s,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger)]`,onClick:()=>{J&&Ae(J)},children:`Delete`})]})]})})]})}export{x as Events};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{ct as t,y as n,z as r}from"./vendor-icons-Dk0hMuJz.js";import{t as i}from"./vendor-react-C6faO6LO.js";import{n as a}from"./dist-Bdqp1ixJ.js";import{t as o}from"./Button-DuQctNms.js";import{r as s,t as c}from"./index-qYKJGoIB.js";import{t as l}from"./Card-rKfViPS2.js";import{t as u}from"./PageHeader-CHSgtxPw.js";import{a as d}from"./format-CHfBBLog.js";import{t as f}from"./EmptyState-CIdIlMbn.js";var p=e(t(),1),m=i();function h(){let e=s(e=>e.roles),t=s(e=>e.fetchRoles),[i,h]=(0,p.useState)([]),[g,_]=(0,p.useState)(!0),[v,y]=(0,p.useState)(`all`);(0,p.useEffect)(()=>{t()},[t]);let b=(0,p.useCallback)(async()=>{_(!0);try{let e=new URLSearchParams({limit:`50`});v!==`all`&&e.set(`roleId`,v),h(await a(`/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)(o,{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)(r,{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{ct as t,y as n,z as r}from"./vendor-icons-Dk0hMuJz.js";import{t as i}from"./vendor-react-C6faO6LO.js";import{n as a}from"./dist-Bdqp1ixJ.js";import{t as o}from"./Button-DuQctNms.js";import{r as s,t as c}from"./index-DYsO5Awn.js";import{t as l}from"./Card-rKfViPS2.js";import{t as u}from"./PageHeader-CHSgtxPw.js";import{a as d}from"./format-CHfBBLog.js";import{t as f}from"./EmptyState-CIdIlMbn.js";var p=e(t(),1),m=i();function h(){let e=s(e=>e.roles),t=s(e=>e.fetchRoles),[i,h]=(0,p.useState)([]),[g,_]=(0,p.useState)(!0),[v,y]=(0,p.useState)(`all`);(0,p.useEffect)(()=>{t()},[t]);let b=(0,p.useCallback)(async()=>{_(!0);try{let e=new URLSearchParams({limit:`50`});v!==`all`&&e.set(`roleId`,v),h(await a(`/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)(o,{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)(r,{size:32}),title:`No evolution records`,description:`Evolution occurs when roles accumulate enough task experience.`,className:`py-8`}):(0,m.jsxs)(`div`,{className:`space-y-4`,children:[(0,m.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[i.length,` records`]}),i.map(e=>(0,m.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] p-3`,children:[(0,m.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,m.jsx)(c,{variant:`info`,children:x(e.roleId)}),(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:d(e.timestamp)}),e.triggerTaskId&&(0,m.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`triggered by task `,e.triggerTaskId.slice(0,8)]})]}),e.diff.includes(`--- Diagnostic Report ---`)?(0,m.jsxs)(`div`,{className:`space-y-2`,children:[(0,m.jsxs)(`div`,{className:`rounded bg-[var(--app-canvas)] p-2`,children:[(0,m.jsx)(`p`,{className:`mb-1 text-[10px] font-medium text-[var(--app-text-muted)]`,children:`Diagnostic Report`}),(0,m.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-[var(--app-text-muted)]`,children:e.diff.split(`--- Rules Diff ---`)[0]?.replace(`--- Diagnostic Report ---
2
2
  `,``).trim()})]}),(0,m.jsxs)(`div`,{className:`rounded bg-[var(--app-canvas)] p-2`,children:[(0,m.jsx)(`p`,{className:`mb-1 text-[10px] font-medium text-[var(--app-text-muted)]`,children:`Rules Changes`}),(0,m.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap font-mono text-xs`,children:(e.diff.split(`--- Rules Diff ---`)[1]??``).trim().split(`
3
3
  `).map((e,t)=>(0,m.jsxs)(`span`,{className:e.startsWith(`+`)?`text-[var(--app-success)]`:e.startsWith(`-`)?`text-[var(--app-danger)]`:`text-[var(--app-text-muted)]`,children:[e,`
4
4
  `]},t))})]})]}):(0,m.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap rounded bg-[var(--app-canvas)] p-2 font-mono text-xs`,children:e.diff.split(`
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{I as t,K as n,at as r,ct as i,l as a,q as o}from"./vendor-icons-Dk0hMuJz.js";import{f as s,r as c,t as l}from"./vendor-react-C6faO6LO.js";import{n as u}from"./dist-Bdqp1ixJ.js";import{t as d}from"./index-qYKJGoIB.js";import{i as f,r as p,t as m}from"./Card-rKfViPS2.js";import{t as h}from"./PageHeader-CHSgtxPw.js";import{t as g}from"./SectionHeader-C2WpiwJ5.js";import{n as _}from"./format-CHfBBLog.js";var v=e(i(),1),y=l();function b(){let{id:e}=s(),[i,l]=(0,v.useState)(null),[b,S]=(0,v.useState)([]),[C,w]=(0,v.useState)(null);if((0,v.useEffect)(()=>{e&&(async()=>{try{let t=await u(`/goals/${e}`);l(t.goal),w(null);try{S((await u(`/strategies?role=${t.goal.roleId}`)).strategies??[])}catch{}}catch(e){w(e instanceof Error?e.message:`Failed to load goal`)}})()},[e]),C)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(r,{size:14}),` Back to Goals`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-danger)]`,children:C})]});if(!i)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(r,{size:14}),` Back to Goals`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let T=i.targetValue>0?Math.min(100,i.currentValue/i.targetValue*100):0,E=i.deadline>0&&i.deadline<Date.now()&&i.status!==`completed`;return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(r,{size:14}),` Back to Goals`]}),(0,y.jsx)(h,{eyebrow:`Goal`,title:i.name,compact:!0,description:i.description||`Progress, delivery targets, and strategy support before raw metrics.`,metrics:[{label:`Status`,value:(0,y.jsx)(d,{variant:(e=>e===`completed`?`success`:e===`executing`||e===`evaluating`?`warning`:e===`failed`?`destructive`:`secondary`)(i.status),children:i.status})},{label:`Role`,value:i.roleId},{label:`Metric`,value:i.metricType},{label:`Progress`,value:`${T.toFixed(1)}%`}]}),(0,y.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Goal ID`}),(0,y.jsx)(`p`,{className:`mt-2 truncate font-mono text-sm text-[var(--app-text)]`,children:i.id})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Current delta`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:Math.max(i.targetValue-i.currentValue,0)})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Strategies in play`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:b.length})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Deadline state`}),(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium ${E?`text-[var(--app-danger-soft-text)]`:`text-[var(--app-text)]`}`,children:E?`Overdue`:`On track`})]})]}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,y.jsx)(x,{icon:a,label:`Progress`,value:`${i.currentValue} / ${i.targetValue}`}),(0,y.jsx)(x,{icon:o,label:E?`Overdue`:`Deadline`,value:_(i.deadline),mono:!0}),(0,y.jsx)(x,{icon:n,label:`Budget`,value:`$${i.budgetUsd.toFixed(2)}`}),(0,y.jsx)(x,{icon:t,label:`Created`,value:_(i.createdAt),mono:!0})]}),(0,y.jsx)(g,{title:`Progress`,compact:!0,description:`Completion first, then delivery targets and strategy support.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Progress`})}),(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`flex-1 h-3 rounded-full bg-[var(--app-panel-muted)] overflow-hidden`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full transition-[width] ${E?`bg-[var(--app-danger)]`:`bg-[var(--app-accent)]`}`,style:{width:`${T}%`}})}),(0,y.jsxs)(`span`,{className:`text-sm text-[var(--app-text)] font-mono`,children:[T.toFixed(1),`%`]})]}),(0,y.jsxs)(`div`,{className:`mt-2 flex items-center justify-between text-xs text-[var(--app-text-subtle)]`,children:[(0,y.jsxs)(`span`,{children:[i.currentValue,` current`]}),(0,y.jsxs)(`span`,{children:[i.targetValue,` target`]})]})]}),(i.deliverTo??[]).length>0&&(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Delivery Targets`})}),(0,y.jsx)(`div`,{className:`space-y-1.5`,children:(i.deliverTo??[]).map((e,t)=>(0,y.jsx)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:e.type===`channel`?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d,{variant:`outline`,children:`Channel`}),(0,y.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d,{variant:`outline`,children:`Session`}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Chat session`})]})},t))})]}),b.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(g,{title:`Strategy Support`,compact:!0,description:`Strategy candidates already associated with the goal's role.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,y.jsx)(t,{size:14}),` Strategies (`,b.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>(0,y.jsxs)(`div`,{className:`flex items-center justify-between text-sm border-b border-[var(--app-border)] pb-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,y.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:e.taskType})]}),(0,y.jsxs)(d,{variant:`outline`,children:[e.trialCount,` trials`]})]},e.id))})]})]})]})}function x({icon:e,label:t,value:n,mono:r}){return(0,y.jsxs)(m,{className:`flex flex-col gap-1`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[var(--app-text-subtle)]`,children:[(0,y.jsx)(e,{size:12}),(0,y.jsx)(`span`,{className:`text-xs`,children:t})]}),(0,y.jsx)(`span`,{className:`text-sm text-[var(--app-text)] truncate ${r?`font-mono text-xs`:``}`,children:n})]})}export{b as GoalDetail};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{I as t,K as n,at as r,ct as i,l as a,q as o}from"./vendor-icons-Dk0hMuJz.js";import{f as s,r as c,t as l}from"./vendor-react-C6faO6LO.js";import{n as u}from"./dist-Bdqp1ixJ.js";import{t as d}from"./index-DYsO5Awn.js";import{i as f,r as p,t as m}from"./Card-rKfViPS2.js";import{t as h}from"./PageHeader-CHSgtxPw.js";import{t as g}from"./SectionHeader-C2WpiwJ5.js";import{n as _}from"./format-CHfBBLog.js";var v=e(i(),1),y=l();function b(){let{id:e}=s(),[i,l]=(0,v.useState)(null),[b,S]=(0,v.useState)([]),[C,w]=(0,v.useState)(null);if((0,v.useEffect)(()=>{e&&(async()=>{try{let t=await u(`/goals/${e}`);l(t.goal),w(null);try{S((await u(`/strategies?role=${t.goal.roleId}`)).strategies??[])}catch{}}catch(e){w(e instanceof Error?e.message:`Failed to load goal`)}})()},[e]),C)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(r,{size:14}),` Back to Goals`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-danger)]`,children:C})]});if(!i)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(r,{size:14}),` Back to Goals`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let T=i.targetValue>0?Math.min(100,i.currentValue/i.targetValue*100):0,E=i.deadline>0&&i.deadline<Date.now()&&i.status!==`completed`;return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsxs)(c,{to:`/goals`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(r,{size:14}),` Back to Goals`]}),(0,y.jsx)(h,{eyebrow:`Goal`,title:i.name,compact:!0,description:i.description||`Progress, delivery targets, and strategy support before raw metrics.`,metrics:[{label:`Status`,value:(0,y.jsx)(d,{variant:(e=>e===`completed`?`success`:e===`executing`||e===`evaluating`?`warning`:e===`failed`?`destructive`:`secondary`)(i.status),children:i.status})},{label:`Role`,value:i.roleId},{label:`Metric`,value:i.metricType},{label:`Progress`,value:`${T.toFixed(1)}%`}]}),(0,y.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Goal ID`}),(0,y.jsx)(`p`,{className:`mt-2 truncate font-mono text-sm text-[var(--app-text)]`,children:i.id})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Current delta`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:Math.max(i.targetValue-i.currentValue,0)})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Strategies in play`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:b.length})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Deadline state`}),(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium ${E?`text-[var(--app-danger-soft-text)]`:`text-[var(--app-text)]`}`,children:E?`Overdue`:`On track`})]})]}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,y.jsx)(x,{icon:a,label:`Progress`,value:`${i.currentValue} / ${i.targetValue}`}),(0,y.jsx)(x,{icon:o,label:E?`Overdue`:`Deadline`,value:_(i.deadline),mono:!0}),(0,y.jsx)(x,{icon:n,label:`Budget`,value:`$${i.budgetUsd.toFixed(2)}`}),(0,y.jsx)(x,{icon:t,label:`Created`,value:_(i.createdAt),mono:!0})]}),(0,y.jsx)(g,{title:`Progress`,compact:!0,description:`Completion first, then delivery targets and strategy support.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Progress`})}),(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`flex-1 h-3 rounded-full bg-[var(--app-panel-muted)] overflow-hidden`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full transition-[width] ${E?`bg-[var(--app-danger)]`:`bg-[var(--app-accent)]`}`,style:{width:`${T}%`}})}),(0,y.jsxs)(`span`,{className:`text-sm text-[var(--app-text)] font-mono`,children:[T.toFixed(1),`%`]})]}),(0,y.jsxs)(`div`,{className:`mt-2 flex items-center justify-between text-xs text-[var(--app-text-subtle)]`,children:[(0,y.jsxs)(`span`,{children:[i.currentValue,` current`]}),(0,y.jsxs)(`span`,{children:[i.targetValue,` target`]})]})]}),(i.deliverTo??[]).length>0&&(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Delivery Targets`})}),(0,y.jsx)(`div`,{className:`space-y-1.5`,children:(i.deliverTo??[]).map((e,t)=>(0,y.jsx)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:e.type===`channel`?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d,{variant:`outline`,children:`Channel`}),(0,y.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d,{variant:`outline`,children:`Session`}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Chat session`})]})},t))})]}),b.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(g,{title:`Strategy Support`,compact:!0,description:`Strategy candidates already associated with the goal's role.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,y.jsx)(t,{size:14}),` Strategies (`,b.length,`)`]})}),(0,y.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>(0,y.jsxs)(`div`,{className:`flex items-center justify-between text-sm border-b border-[var(--app-border)] pb-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,y.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),(0,y.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:e.taskType})]}),(0,y.jsxs)(d,{variant:`outline`,children:[e.trialCount,` trials`]})]},e.id))})]})]})]})}function x({icon:e,label:t,value:n,mono:r}){return(0,y.jsxs)(m,{className:`flex flex-col gap-1`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[var(--app-text-subtle)]`,children:[(0,y.jsx)(e,{size:12}),(0,y.jsx)(`span`,{className:`text-xs`,children:t})]}),(0,y.jsx)(`span`,{className:`text-sm text-[var(--app-text)] truncate ${r?`font-mono text-xs`:``}`,children:n})]})}export{b as GoalDetail};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,E as n,S as r,T as i,ct as a,l as o,n as s,s as c,y as l}from"./vendor-icons-Dk0hMuJz.js";import{t as u}from"./vendor-react-C6faO6LO.js";import{n as d}from"./dist-Bdqp1ixJ.js";import{a as f,c as p,i as m,l as h,n as ee,o as g,r as _,s as te,t as v}from"./AlertDialog-CfeiyMrc.js";import{t as y}from"./Button-DuQctNms.js";import{i as b,n as x,r as S,t as C}from"./index-qYKJGoIB.js";import{i as ne,r as re,t as w}from"./Card-rKfViPS2.js";import{t as T}from"./PageHeader-CHSgtxPw.js";import{n as E,t as D}from"./format-CHfBBLog.js";import{t as O}from"./EmptyState-CIdIlMbn.js";var k=e(a(),1),A=u();function j({value:e,onChange:t,label:n=`Delivery Targets`}){let[r,i]=(0,k.useState)([]),[a,o]=(0,k.useState)(!1);(0,k.useEffect)(()=>{let e=!1;return Promise.all([d(`/channels`).catch(()=>({channels:[]})),d(`/chat/sessions`).catch(()=>({sessions:[]}))]).then(([t,n])=>{if(e)return;let r=new Map(t.channels.map(e=>[e.id,e])),a=[];for(let e of n.sessions)if(e.source.type===`channel`&&e.source.channelId&&e.source.chatId){let t=r.get(e.source.channelId);a.push({id:e.id,channelId:e.source.channelId,channelName:t?.name??e.source.channelId.slice(0,8),platform:t?.platform??`unknown`,chatId:e.source.chatId})}let o=new Set;i(a.filter(e=>{let t=`${e.channelId}:${e.chatId}`;return o.has(t)?!1:(o.add(t),!0)}))}),()=>{e=!0}},[]);let s=(t,n)=>e.some(e=>e.type===`channel`&&e.channelId===t&&e.chatId===n),c=(n,r)=>{s(n,r)?t(e.filter(e=>!(e.type===`channel`&&e.channelId===n&&e.chatId===r))):t([...e,{type:`channel`,channelId:n,chatId:r}])},l=e.filter(e=>e.type===`channel`).length;return(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:n}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!a),className:`mt-1 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-left text-sm text-[var(--app-text)] hover:border-[var(--app-border-strong)] focus:border-[var(--app-accent)] focus:outline-none`,children:l===0?`Default (current session)`:`${l} channel${l>1?`s`:``} selected`}),a&&(0,A.jsxs)(`div`,{className:`absolute z-10 mt-1 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] py-1 shadow-lg`,children:[r.length===0?(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-[var(--app-text-subtle)]`,children:`No active channel conversations. Start a chat on WeChat/Telegram first.`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`px-3 py-1 text-xs text-[var(--app-text-subtle)]`,children:`Channel conversations`}),r.map(e=>(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 px-3 py-1.5 text-xs text-[var(--app-text)] hover:bg-[var(--app-panel-muted)]`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:s(e.channelId,e.chatId),onChange:()=>c(e.channelId,e.chatId),className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-muted)]`}),(0,A.jsx)(`span`,{className:`truncate font-medium`,children:e.channelName}),(0,A.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`(`,e.platform,`)`]})]},`${e.channelId}:${e.chatId}`))]}),l>0&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>{t([]),o(!1)},className:`mt-1 w-full border-t border-[var(--app-border)] px-3 py-1 text-left text-xs text-[var(--app-danger)] hover:bg-[var(--app-panel-muted)]`,children:`Clear all`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`w-full border-t border-[var(--app-border)] px-3 py-1 text-left text-xs text-[var(--app-text-subtle)] hover:bg-[var(--app-panel-muted)]`,children:`Done`})]})]})}var M={active:`paused`,paused:`active`,completed:`active`,failed:`active`},N={active:(0,A.jsx)(t,{size:12}),paused:(0,A.jsx)(i,{size:12}),completed:(0,A.jsx)(l,{size:12}),failed:(0,A.jsx)(l,{size:12})};function P(){let e=S(e=>e.goals),t=S(e=>e.fetchGoals),a=S(e=>e.updateGoal),u=S(e=>e.deleteGoal),[P,F]=(0,k.useState)(!1),[I,L]=(0,k.useState)(``),[R,z]=(0,k.useState)(!1),[B,V]=(0,k.useState)(null),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(``),[K,q]=(0,k.useState)(``),[J,Y]=(0,k.useState)([]),[X,Z]=(0,k.useState)([]),[Q,ie]=(0,k.useState)([]),[$,ae]=(0,k.useState)([]),oe=e.filter(e=>e.status===`active`).length,se=e.filter(e=>e.status===`paused`).length,ce=e.filter(e=>e.status===`completed`).length;(0,k.useEffect)(()=>{t();let e=setInterval(()=>void t(),1e4);return()=>clearInterval(e)},[t]);let le=async()=>{if(I.trim()){z(!0),V(null);try{await d(`/goals`,{method:`POST`,body:JSON.stringify({input:I.trim(),deliverTo:Q.length>0?Q:void 0,reportTo:$.length>0?$:void 0})}),L(``),F(!1),t()}catch(e){V(e instanceof Error?e.message:`Failed to create goal`)}finally{z(!1)}}};return(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsx)(T,{eyebrow:`Operations`,title:`Goals`,compact:!0,description:`Long-running outcomes, budgets, and delivery targets.`,metrics:[{label:`Active`,value:oe},{label:`Paused`,value:se},{label:`Completed`,value:ce}],actions:(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(y,{variant:`ghost`,size:`sm`,onClick:()=>void t(),children:(0,A.jsx)(l,{size:14})}),(0,A.jsxs)(y,{size:`sm`,onClick:()=>F(!P),children:[(0,A.jsx)(r,{size:14}),`New Goal`]})]})}),P&&(0,A.jsxs)(w,{className:`space-y-3`,children:[(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Describe your goal in natural language...`,rows:3,value:I,onChange:e=>L(e.target.value)}),(0,A.jsx)(j,{value:Q,onChange:ie,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:$,onChange:ae,label:`Report To (status)`}),B&&(0,A.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:B}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(y,{onClick:()=>void le(),disabled:R||!I.trim(),children:R?`Creating...`:`Create`}),(0,A.jsx)(y,{variant:`ghost`,onClick:()=>F(!1),children:`Cancel`})]})]}),e.length===0?(0,A.jsx)(O,{icon:(0,A.jsx)(o,{size:32}),title:`No goals`,description:`Create a goal to start goal-driven task orchestration`}):(0,A.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>{let t=e.targetValue>0?Math.min(100,Math.round(e.currentValue/e.targetValue*100)):0,r=new Date(e.deadline).getTime()<Date.now()&&e.status!==`completed`,o=H===e.id;return(0,A.jsxs)(w,{children:[(0,A.jsxs)(re,{children:[o?(0,A.jsx)(`input`,{className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:W,onChange:e=>G(e.target.value),autoFocus:!0}):(0,A.jsx)(ne,{className:`max-w-full text-[var(--app-text)] text-sm font-medium truncate sm:max-w-[180px]`,children:e.name}),(0,A.jsx)(C,{variant:x(e.status),children:e.status})]}),o?(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-xs text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none mb-3`,placeholder:`Description...`,rows:2,value:K,onChange:e=>q(e.target.value)}):e.description?(0,A.jsx)(`p`,{className:`text-xs text-[var(--app-text-muted)] mb-3 line-clamp-2`,children:e.description}):null,o&&(0,A.jsxs)(`div`,{className:`mb-3 space-y-2`,children:[(0,A.jsx)(j,{value:J,onChange:Y,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:X,onChange:Z,label:`Report To (status)`})]}),(0,A.jsxs)(`div`,{className:`mb-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,A.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Progress`}),(0,A.jsxs)(`span`,{className:`font-mono text-xs text-[var(--app-text)]`,children:[t,`%`]})]}),(0,A.jsx)(`div`,{className:`h-1.5 rounded-full bg-[var(--app-panel-elevated)]`,children:(0,A.jsx)(`div`,{className:`h-full rounded-full transition-[width] ${t>=100?`bg-[var(--app-success)]`:`bg-[var(--app-accent)]`}`,style:{width:`${t}%`}})}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between mt-1`,children:[(0,A.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--app-text-subtle)]`,children:[e.currentValue,` / `,e.targetValue]}),(0,A.jsx)(`span`,{className:`font-mono text-[10px] text-[var(--app-text-subtle)]`,children:e.metricType})]})]}),(0,A.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Role`}),(0,A.jsx)(C,{variant:`muted`,className:`text-[10px]`,children:e.roleId})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Budget`}),(0,A.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:D(e.budgetUsd)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)] ${r?`text-[var(--app-danger)]`:``}`,children:`Deadline`}),(0,A.jsx)(`span`,{className:`text-[var(--app-text)] ${r?`text-[var(--app-danger)]`:``}`,children:E(e.deadline)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Created`}),(0,A.jsx)(`span`,{className:`text-[var(--app-text-muted)]`,children:E(e.createdAt)})]})]}),(0,A.jsx)(`div`,{className:`flex items-center gap-1 mt-3 pt-3 border-t border-[var(--app-border)]`,children:o?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(y,{size:`sm`,variant:`ghost`,onClick:async()=>{try{await a(e.id,{name:W,description:K,deliverTo:J,reportTo:X}),U(null),b.success(`Goal updated`)}catch(e){b.error(e instanceof Error?e.message:`Failed to update`)}},children:`Save`}),(0,A.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>U(null),children:(0,A.jsx)(s,{size:14})})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(y,{size:`sm`,variant:`ghost`,title:`Edit`,onClick:()=>{U(e.id),G(e.name),q(e.description??``),Y(e.deliverTo??[]),Z(e.reportTo??[])},children:(0,A.jsx)(n,{size:14})}),(0,A.jsxs)(y,{size:`sm`,variant:`ghost`,title:`Change to ${M[e.status]}`,onClick:async()=>{try{await a(e.id,{status:M[e.status]}),b.success(`Status changed to ${M[e.status]}`)}catch(e){b.error(e instanceof Error?e.message:`Failed to update status`)}},children:[N[e.status]??(0,A.jsx)(i,{size:12}),(0,A.jsx)(`span`,{className:`text-xs`,children:M[e.status]})]}),(0,A.jsx)(`div`,{className:`ml-auto`,children:(0,A.jsxs)(v,{children:[(0,A.jsx)(h,{asChild:!0,children:(0,A.jsx)(y,{size:`sm`,variant:`ghost`,title:`Delete`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,children:(0,A.jsx)(c,{size:14})})}),(0,A.jsxs)(m,{children:[(0,A.jsxs)(te,{children:[(0,A.jsx)(p,{children:`Delete goal`}),(0,A.jsxs)(f,{children:[`This will permanently delete "`,e.name,`". This action cannot be undone.`]})]}),(0,A.jsxs)(g,{children:[(0,A.jsx)(_,{children:`Cancel`}),(0,A.jsx)(ee,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger-strong)]`,onClick:async()=>{try{await u(e.id),b.success(`Goal deleted`)}catch(e){b.error(e instanceof Error?e.message:`Failed to delete`)}},children:`Delete`})]})]})]})})]})})]},e.id)})})]})}export{P as Goals,j as t};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,E as n,S as r,T as i,ct as a,l as o,n as s,s as c,y as l}from"./vendor-icons-Dk0hMuJz.js";import{t as u}from"./vendor-react-C6faO6LO.js";import{n as d}from"./dist-Bdqp1ixJ.js";import{a as f,c as p,i as m,l as h,n as ee,o as g,r as _,s as te,t as v}from"./AlertDialog-CfeiyMrc.js";import{t as y}from"./Button-DuQctNms.js";import{i as b,n as x,r as S,t as C}from"./index-DYsO5Awn.js";import{i as ne,r as re,t as w}from"./Card-rKfViPS2.js";import{t as T}from"./PageHeader-CHSgtxPw.js";import{n as E,t as D}from"./format-CHfBBLog.js";import{t as O}from"./EmptyState-CIdIlMbn.js";var k=e(a(),1),A=u();function j({value:e,onChange:t,label:n=`Delivery Targets`}){let[r,i]=(0,k.useState)([]),[a,o]=(0,k.useState)(!1);(0,k.useEffect)(()=>{let e=!1;return Promise.all([d(`/channels`).catch(()=>({channels:[]})),d(`/chat/sessions`).catch(()=>({sessions:[]}))]).then(([t,n])=>{if(e)return;let r=new Map(t.channels.map(e=>[e.id,e])),a=[];for(let e of n.sessions)if(e.source.type===`channel`&&e.source.channelId&&e.source.chatId){let t=r.get(e.source.channelId);a.push({id:e.id,channelId:e.source.channelId,channelName:t?.name??e.source.channelId.slice(0,8),platform:t?.platform??`unknown`,chatId:e.source.chatId})}let o=new Set;i(a.filter(e=>{let t=`${e.channelId}:${e.chatId}`;return o.has(t)?!1:(o.add(t),!0)}))}),()=>{e=!0}},[]);let s=(t,n)=>e.some(e=>e.type===`channel`&&e.channelId===t&&e.chatId===n),c=(n,r)=>{s(n,r)?t(e.filter(e=>!(e.type===`channel`&&e.channelId===n&&e.chatId===r))):t([...e,{type:`channel`,channelId:n,chatId:r}])},l=e.filter(e=>e.type===`channel`).length;return(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:n}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!a),className:`mt-1 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-left text-sm text-[var(--app-text)] hover:border-[var(--app-border-strong)] focus:border-[var(--app-accent)] focus:outline-none`,children:l===0?`Default (current session)`:`${l} channel${l>1?`s`:``} selected`}),a&&(0,A.jsxs)(`div`,{className:`absolute z-10 mt-1 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] py-1 shadow-lg`,children:[r.length===0?(0,A.jsx)(`div`,{className:`px-3 py-2 text-xs text-[var(--app-text-subtle)]`,children:`No active channel conversations. Start a chat on WeChat/Telegram first.`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`px-3 py-1 text-xs text-[var(--app-text-subtle)]`,children:`Channel conversations`}),r.map(e=>(0,A.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 px-3 py-1.5 text-xs text-[var(--app-text)] hover:bg-[var(--app-panel-muted)]`,children:[(0,A.jsx)(`input`,{type:`checkbox`,checked:s(e.channelId,e.chatId),onChange:()=>c(e.channelId,e.chatId),className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-muted)]`}),(0,A.jsx)(`span`,{className:`truncate font-medium`,children:e.channelName}),(0,A.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`(`,e.platform,`)`]})]},`${e.channelId}:${e.chatId}`))]}),l>0&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>{t([]),o(!1)},className:`mt-1 w-full border-t border-[var(--app-border)] px-3 py-1 text-left text-xs text-[var(--app-danger)] hover:bg-[var(--app-panel-muted)]`,children:`Clear all`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`w-full border-t border-[var(--app-border)] px-3 py-1 text-left text-xs text-[var(--app-text-subtle)] hover:bg-[var(--app-panel-muted)]`,children:`Done`})]})]})}var M={active:`paused`,paused:`active`,completed:`active`,failed:`active`},N={active:(0,A.jsx)(t,{size:12}),paused:(0,A.jsx)(i,{size:12}),completed:(0,A.jsx)(l,{size:12}),failed:(0,A.jsx)(l,{size:12})};function P(){let e=S(e=>e.goals),t=S(e=>e.fetchGoals),a=S(e=>e.updateGoal),u=S(e=>e.deleteGoal),[P,F]=(0,k.useState)(!1),[I,L]=(0,k.useState)(``),[R,z]=(0,k.useState)(!1),[B,V]=(0,k.useState)(null),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(``),[K,q]=(0,k.useState)(``),[J,Y]=(0,k.useState)([]),[X,Z]=(0,k.useState)([]),[Q,ie]=(0,k.useState)([]),[$,ae]=(0,k.useState)([]),oe=e.filter(e=>e.status===`active`).length,se=e.filter(e=>e.status===`paused`).length,ce=e.filter(e=>e.status===`completed`).length;(0,k.useEffect)(()=>{t();let e=setInterval(()=>void t(),1e4);return()=>clearInterval(e)},[t]);let le=async()=>{if(I.trim()){z(!0),V(null);try{await d(`/goals`,{method:`POST`,body:JSON.stringify({input:I.trim(),deliverTo:Q.length>0?Q:void 0,reportTo:$.length>0?$:void 0})}),L(``),F(!1),t()}catch(e){V(e instanceof Error?e.message:`Failed to create goal`)}finally{z(!1)}}};return(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsx)(T,{eyebrow:`Operations`,title:`Goals`,compact:!0,description:`Long-running outcomes, budgets, and delivery targets.`,metrics:[{label:`Active`,value:oe},{label:`Paused`,value:se},{label:`Completed`,value:ce}],actions:(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(y,{variant:`ghost`,size:`sm`,onClick:()=>void t(),children:(0,A.jsx)(l,{size:14})}),(0,A.jsxs)(y,{size:`sm`,onClick:()=>F(!P),children:[(0,A.jsx)(r,{size:14}),`New Goal`]})]})}),P&&(0,A.jsxs)(w,{className:`space-y-3`,children:[(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Describe your goal in natural language...`,rows:3,value:I,onChange:e=>L(e.target.value)}),(0,A.jsx)(j,{value:Q,onChange:ie,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:$,onChange:ae,label:`Report To (status)`}),B&&(0,A.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:B}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(y,{onClick:()=>void le(),disabled:R||!I.trim(),children:R?`Creating...`:`Create`}),(0,A.jsx)(y,{variant:`ghost`,onClick:()=>F(!1),children:`Cancel`})]})]}),e.length===0?(0,A.jsx)(O,{icon:(0,A.jsx)(o,{size:32}),title:`No goals`,description:`Create a goal to start goal-driven task orchestration`}):(0,A.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>{let t=e.targetValue>0?Math.min(100,Math.round(e.currentValue/e.targetValue*100)):0,r=new Date(e.deadline).getTime()<Date.now()&&e.status!==`completed`,o=H===e.id;return(0,A.jsxs)(w,{children:[(0,A.jsxs)(re,{children:[o?(0,A.jsx)(`input`,{className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:W,onChange:e=>G(e.target.value),autoFocus:!0}):(0,A.jsx)(ne,{className:`max-w-full text-[var(--app-text)] text-sm font-medium truncate sm:max-w-[180px]`,children:e.name}),(0,A.jsx)(C,{variant:x(e.status),children:e.status})]}),o?(0,A.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-xs text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none mb-3`,placeholder:`Description...`,rows:2,value:K,onChange:e=>q(e.target.value)}):e.description?(0,A.jsx)(`p`,{className:`text-xs text-[var(--app-text-muted)] mb-3 line-clamp-2`,children:e.description}):null,o&&(0,A.jsxs)(`div`,{className:`mb-3 space-y-2`,children:[(0,A.jsx)(j,{value:J,onChange:Y,label:`Deliver To (results)`}),(0,A.jsx)(j,{value:X,onChange:Z,label:`Report To (status)`})]}),(0,A.jsxs)(`div`,{className:`mb-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,A.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Progress`}),(0,A.jsxs)(`span`,{className:`font-mono text-xs text-[var(--app-text)]`,children:[t,`%`]})]}),(0,A.jsx)(`div`,{className:`h-1.5 rounded-full bg-[var(--app-panel-elevated)]`,children:(0,A.jsx)(`div`,{className:`h-full rounded-full transition-[width] ${t>=100?`bg-[var(--app-success)]`:`bg-[var(--app-accent)]`}`,style:{width:`${t}%`}})}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between mt-1`,children:[(0,A.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--app-text-subtle)]`,children:[e.currentValue,` / `,e.targetValue]}),(0,A.jsx)(`span`,{className:`font-mono text-[10px] text-[var(--app-text-subtle)]`,children:e.metricType})]})]}),(0,A.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Role`}),(0,A.jsx)(C,{variant:`muted`,className:`text-[10px]`,children:e.roleId})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Budget`}),(0,A.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:D(e.budgetUsd)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)] ${r?`text-[var(--app-danger)]`:``}`,children:`Deadline`}),(0,A.jsx)(`span`,{className:`text-[var(--app-text)] ${r?`text-[var(--app-danger)]`:``}`,children:E(e.deadline)})]}),(0,A.jsxs)(`div`,{className:`flex justify-between`,children:[(0,A.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Created`}),(0,A.jsx)(`span`,{className:`text-[var(--app-text-muted)]`,children:E(e.createdAt)})]})]}),(0,A.jsx)(`div`,{className:`flex items-center gap-1 mt-3 pt-3 border-t border-[var(--app-border)]`,children:o?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(y,{size:`sm`,variant:`ghost`,onClick:async()=>{try{await a(e.id,{name:W,description:K,deliverTo:J,reportTo:X}),U(null),b.success(`Goal updated`)}catch(e){b.error(e instanceof Error?e.message:`Failed to update`)}},children:`Save`}),(0,A.jsx)(y,{size:`sm`,variant:`ghost`,onClick:()=>U(null),children:(0,A.jsx)(s,{size:14})})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(y,{size:`sm`,variant:`ghost`,title:`Edit`,onClick:()=>{U(e.id),G(e.name),q(e.description??``),Y(e.deliverTo??[]),Z(e.reportTo??[])},children:(0,A.jsx)(n,{size:14})}),(0,A.jsxs)(y,{size:`sm`,variant:`ghost`,title:`Change to ${M[e.status]}`,onClick:async()=>{try{await a(e.id,{status:M[e.status]}),b.success(`Status changed to ${M[e.status]}`)}catch(e){b.error(e instanceof Error?e.message:`Failed to update status`)}},children:[N[e.status]??(0,A.jsx)(i,{size:12}),(0,A.jsx)(`span`,{className:`text-xs`,children:M[e.status]})]}),(0,A.jsx)(`div`,{className:`ml-auto`,children:(0,A.jsxs)(v,{children:[(0,A.jsx)(h,{asChild:!0,children:(0,A.jsx)(y,{size:`sm`,variant:`ghost`,title:`Delete`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,children:(0,A.jsx)(c,{size:14})})}),(0,A.jsxs)(m,{children:[(0,A.jsxs)(te,{children:[(0,A.jsx)(p,{children:`Delete goal`}),(0,A.jsxs)(f,{children:[`This will permanently delete "`,e.name,`". This action cannot be undone.`]})]}),(0,A.jsxs)(g,{children:[(0,A.jsx)(_,{children:`Cancel`}),(0,A.jsx)(ee,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger-strong)]`,onClick:async()=>{try{await u(e.id),b.success(`Goal deleted`)}catch(e){b.error(e instanceof Error?e.message:`Failed to delete`)}},children:`Delete`})]})]})]})})]})})]},e.id)})})]})}export{P as Goals,j as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,T as n,W as r,c as i,ct as a}from"./vendor-icons-Dk0hMuJz.js";import{t as o}from"./vendor-react-C6faO6LO.js";import{t as s}from"./Button-DuQctNms.js";import{r as c}from"./index-qYKJGoIB.js";import{t as l}from"./Card-rKfViPS2.js";import{t as u}from"./PageHeader-CHSgtxPw.js";import{t as d}from"./EmptyState-CIdIlMbn.js";import{t as f}from"./ui-B_uMx2Fy.js";var p=e(a(),1),m=o(),h={debug:`text-[var(--app-text-subtle)]`,info:`text-[var(--app-accent)]`,warn:`text-[var(--app-warning)]`,error:`text-[var(--app-danger)]`},g={adam:`text-[var(--app-log-adam)]`,manager:`text-[var(--app-log-manager)]`,worker:`text-[var(--app-success)]`,scheduler:`text-[var(--app-log-scheduler)]`,api:`text-[var(--app-accent)]`,ws:`text-[var(--app-log-ws)]`,store:`text-[var(--app-log-store)]`,embedding:`text-[var(--app-log-embedding)]`},_=[`adam`,`manager`,`worker`,`scheduler`,`api`,`ws`,`store`,`embedding`],v=[`debug`,`info`,`warn`,`error`];function y(){let e=c(e=>e.logs),a=(0,p.useRef)(null),[o,y]=(0,p.useState)(!0),[x,S]=(0,p.useState)(null),[C,w]=(0,p.useState)(null),T=(0,p.useMemo)(()=>e.filter(e=>!(x&&e.level!==x||C&&e.component!==C)),[e,x,C]);return(0,p.useEffect)(()=>{o&&a.current&&(a.current.scrollTop=a.current.scrollHeight)},[T,o]),(0,m.jsxs)(`div`,{className:`flex h-full flex-col gap-5`,children:[(0,m.jsx)(u,{title:`Logs`,compact:!0,description:`Backend events with inline filters and a stable reading surface.`,metrics:[{label:`Visible`,value:T.length},{label:`Total`,value:e.length},{label:`Mode`,value:o?`Live`:`Paused`}],className:`px-4 py-3 lg:px-4 lg:py-3`,actions:(0,m.jsxs)(`div`,{className:`flex gap-2`,children:[(0,m.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>y(!o),title:o?`Pause auto-scroll`:`Resume auto-scroll`,children:o?(0,m.jsx)(t,{size:f.sm}):(0,m.jsx)(n,{size:f.sm})}),(0,m.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>{c.setState({logs:[]})},title:`Clear logs`,children:(0,m.jsx)(r,{size:f.sm})})]})}),(0,m.jsx)(l,{className:`surface-panel-muted py-3`,children:(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Level:`}),(0,m.jsxs)(`div`,{className:`flex gap-1`,children:[(0,m.jsx)(b,{active:x===null,onClick:()=>S(null),children:`All`}),v.map(e=>(0,m.jsx)(b,{active:x===e,onClick:()=>S(x===e?null:e),children:e},e))]})]}),(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Component:`}),(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,m.jsx)(b,{active:C===null,onClick:()=>w(null),children:`All`}),_.map(e=>(0,m.jsx)(b,{active:C===e,onClick:()=>w(C===e?null:e),children:e},e))]})]})]})}),(0,m.jsx)(l,{padding:!1,className:`flex-1 min-h-0`,children:T.length===0?(0,m.jsx)(`div`,{className:`p-4`,children:(0,m.jsx)(d,{icon:(0,m.jsx)(i,{size:32}),title:`No log entries`,description:`Log events will appear here in real-time via WebSocket.`,compact:!0,className:`min-h-[10rem]`})}):(0,m.jsx)(`div`,{ref:a,className:`h-full max-h-[calc(100vh-280px)] overflow-y-auto p-3 font-mono text-xs leading-5`,children:T.map((e,t)=>{let n=new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,fractionalSecondDigits:3}),r=h[e.level]??`text-[var(--app-text-muted)]`,i=g[e.component]??`text-[var(--app-text-muted)]`;return(0,m.jsxs)(`div`,{className:`flex gap-2 hover:bg-[var(--app-panel-elevated)]/30 px-1 rounded`,children:[(0,m.jsx)(`span`,{className:`text-[var(--app-text-subtle)] shrink-0`,children:n}),(0,m.jsx)(`span`,{className:`w-12 shrink-0 uppercase ${r}`,children:e.level.padEnd(5)}),(0,m.jsxs)(`span`,{className:`w-20 shrink-0 ${i}`,children:[`[`,e.component,`]`]}),(0,m.jsx)(`span`,{className:`text-[var(--app-text)] break-all`,children:e.msg})]},t)})})}),(0,m.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-[var(--app-text-subtle)]`,children:[(0,m.jsxs)(`span`,{children:[T.length,` entries `,T.length!==e.length&&`(${e.length} total)`]}),(0,m.jsx)(`span`,{children:o?`Following live feed`:`Scroll paused`})]})]})}function b({active:e,onClick:t,children:n}){return(0,m.jsx)(`button`,{onClick:t,className:`rounded px-2 py-0.5 text-xs transition-colors ${e?`bg-[var(--app-panel-muted)] text-[var(--app-text)]`:`text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:n})}export{y as Logs};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,T as n,W as r,c as i,ct as a}from"./vendor-icons-Dk0hMuJz.js";import{t as o}from"./vendor-react-C6faO6LO.js";import{t as s}from"./Button-DuQctNms.js";import{r as c}from"./index-DYsO5Awn.js";import{t as l}from"./Card-rKfViPS2.js";import{t as u}from"./PageHeader-CHSgtxPw.js";import{t as d}from"./EmptyState-CIdIlMbn.js";import{t as f}from"./ui-B_uMx2Fy.js";var p=e(a(),1),m=o(),h={debug:`text-[var(--app-text-subtle)]`,info:`text-[var(--app-accent)]`,warn:`text-[var(--app-warning)]`,error:`text-[var(--app-danger)]`},g={adam:`text-[var(--app-log-adam)]`,manager:`text-[var(--app-log-manager)]`,worker:`text-[var(--app-success)]`,scheduler:`text-[var(--app-log-scheduler)]`,api:`text-[var(--app-accent)]`,ws:`text-[var(--app-log-ws)]`,store:`text-[var(--app-log-store)]`,embedding:`text-[var(--app-log-embedding)]`},_=[`adam`,`manager`,`worker`,`scheduler`,`api`,`ws`,`store`,`embedding`],v=[`debug`,`info`,`warn`,`error`];function y(){let e=c(e=>e.logs),a=(0,p.useRef)(null),[o,y]=(0,p.useState)(!0),[x,S]=(0,p.useState)(null),[C,w]=(0,p.useState)(null),T=(0,p.useMemo)(()=>e.filter(e=>!(x&&e.level!==x||C&&e.component!==C)),[e,x,C]);return(0,p.useEffect)(()=>{o&&a.current&&(a.current.scrollTop=a.current.scrollHeight)},[T,o]),(0,m.jsxs)(`div`,{className:`flex h-full flex-col gap-5`,children:[(0,m.jsx)(u,{title:`Logs`,compact:!0,description:`Backend events with inline filters and a stable reading surface.`,metrics:[{label:`Visible`,value:T.length},{label:`Total`,value:e.length},{label:`Mode`,value:o?`Live`:`Paused`}],className:`px-4 py-3 lg:px-4 lg:py-3`,actions:(0,m.jsxs)(`div`,{className:`flex gap-2`,children:[(0,m.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>y(!o),title:o?`Pause auto-scroll`:`Resume auto-scroll`,children:o?(0,m.jsx)(t,{size:f.sm}):(0,m.jsx)(n,{size:f.sm})}),(0,m.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>{c.setState({logs:[]})},title:`Clear logs`,children:(0,m.jsx)(r,{size:f.sm})})]})}),(0,m.jsx)(l,{className:`surface-panel-muted py-3`,children:(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Level:`}),(0,m.jsxs)(`div`,{className:`flex gap-1`,children:[(0,m.jsx)(b,{active:x===null,onClick:()=>S(null),children:`All`}),v.map(e=>(0,m.jsx)(b,{active:x===e,onClick:()=>S(x===e?null:e),children:e},e))]})]}),(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Component:`}),(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,m.jsx)(b,{active:C===null,onClick:()=>w(null),children:`All`}),_.map(e=>(0,m.jsx)(b,{active:C===e,onClick:()=>w(C===e?null:e),children:e},e))]})]})]})}),(0,m.jsx)(l,{padding:!1,className:`flex-1 min-h-0`,children:T.length===0?(0,m.jsx)(`div`,{className:`p-4`,children:(0,m.jsx)(d,{icon:(0,m.jsx)(i,{size:32}),title:`No log entries`,description:`Log events will appear here in real-time via WebSocket.`,compact:!0,className:`min-h-[10rem]`})}):(0,m.jsx)(`div`,{ref:a,className:`h-full max-h-[calc(100vh-280px)] overflow-y-auto p-3 font-mono text-xs leading-5`,children:T.map((e,t)=>{let n=new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,fractionalSecondDigits:3}),r=h[e.level]??`text-[var(--app-text-muted)]`,i=g[e.component]??`text-[var(--app-text-muted)]`;return(0,m.jsxs)(`div`,{className:`flex gap-2 hover:bg-[var(--app-panel-elevated)]/30 px-1 rounded`,children:[(0,m.jsx)(`span`,{className:`text-[var(--app-text-subtle)] shrink-0`,children:n}),(0,m.jsx)(`span`,{className:`w-12 shrink-0 uppercase ${r}`,children:e.level.padEnd(5)}),(0,m.jsxs)(`span`,{className:`w-20 shrink-0 ${i}`,children:[`[`,e.component,`]`]}),(0,m.jsx)(`span`,{className:`text-[var(--app-text)] break-all`,children:e.msg})]},t)})})}),(0,m.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-[var(--app-text-subtle)]`,children:[(0,m.jsxs)(`span`,{children:[T.length,` entries `,T.length!==e.length&&`(${e.length} total)`]}),(0,m.jsx)(`span`,{children:o?`Following live feed`:`Scroll paused`})]})]})}function b({active:e,onClick:t,children:n}){return(0,m.jsx)(`button`,{onClick:t,className:`rounded px-2 py-0.5 text-xs transition-colors ${e?`bg-[var(--app-panel-muted)] text-[var(--app-text)]`:`text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:n})}export{y as Logs};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{ct as t,g as n,rt as r,y as i}from"./vendor-icons-Dk0hMuJz.js";import{t as a}from"./vendor-react-C6faO6LO.js";import{n as o}from"./dist-Bdqp1ixJ.js";import{t as s}from"./Button-DuQctNms.js";import{r as c,t as l}from"./index-qYKJGoIB.js";import{t as u}from"./Card-rKfViPS2.js";import{t as d}from"./PageHeader-CHSgtxPw.js";import{t as f}from"./SectionHeader-C2WpiwJ5.js";import{a as p}from"./format-CHfBBLog.js";import{t as m}from"./EmptyState-CIdIlMbn.js";var h=e(t(),1),g=a();function _(){let e=c(e=>e.roles),t=c(e=>e.fetchRoles),[a,_]=(0,h.useState)(``),[v,y]=(0,h.useState)([]),[b,x]=(0,h.useState)(!1),[S,C]=(0,h.useState)(``),[w,T]=(0,h.useState)(!1),[E,D]=(0,h.useState)(`all`),[O,k]=(0,h.useState)(new Set);(0,h.useEffect)(()=>{t()},[t]),(0,h.useEffect)(()=>{!a&&e.length>0&&_(e[0].id)},[e,a]);let A=(0,h.useCallback)(async()=>{if(a){x(!0);try{y((await o(`/memories/${a}?limit=100`)).memories)}catch{y([])}finally{x(!1)}}},[a]);(0,h.useEffect)(()=>{a&&A()},[a,A]);let j=async()=>{if(!(!S.trim()||!a)){T(!0);try{y((await o(`/memories/query`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentId:a,prompt:S.trim(),topK:20})})).memories)}catch{y([])}finally{T(!1)}}},M=()=>{C(``),A()},N=v.filter(e=>E===`high`?e.importance>3:E===`medium`?e.importance===3:E===`low`?e.importance<3:!0),P=e=>e>=4?`text-[var(--app-danger)]`:e===3?`text-[var(--app-warning)]`:`text-[var(--app-text-subtle)]`;return(0,g.jsxs)(`div`,{className:`space-y-5`,children:[(0,g.jsx)(d,{eyebrow:`Knowledge`,title:`Memories`,compact:!0,description:`What each role is retaining and how retrieval changes the visible recall set.`,metrics:[{label:`Role`,value:e.find(e=>e.id===a)?.name??`None`},{label:`Visible`,value:N.length},{label:`High Importance`,value:v.filter(e=>e.importance>3).length}],actions:(0,g.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void A(),children:(0,g.jsx)(i,{size:14})})}),(0,g.jsx)(f,{title:`Recall Controls`,compact:!0,description:`Switch role context, run a retrieval query, or narrow by importance.`}),(0,g.jsx)(u,{className:`surface-panel-muted`,children:(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,g.jsx)(`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:a,onChange:e=>_(e.target.value),children:e.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,g.jsx)(`input`,{className:`w-64 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] placeholder-slate-600 focus:border-[var(--app-accent)] focus:outline-none`,value:S,onChange:e=>C(e.target.value),onKeyDown:e=>e.key===`Enter`&&void j(),placeholder:`Search memories...`}),(0,g.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>void j(),disabled:w,children:(0,g.jsx)(n,{size:14})}),S&&(0,g.jsx)(s,{size:`sm`,variant:`ghost`,onClick:M,children:`Clear`})]}),(0,g.jsx)(`div`,{className:`flex gap-1`,children:[`all`,`high`,`medium`,`low`].map(e=>(0,g.jsx)(`button`,{className:`rounded px-2 py-1 text-xs transition-colors ${E===e?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:bg-[var(--app-panel-muted)]`}`,onClick:()=>D(e),children:e},e))})]})}),(0,g.jsx)(u,{children:b||w?(0,g.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,g.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):N.length===0?(0,g.jsx)(m,{icon:(0,g.jsx)(r,{size:32}),title:`No memories`,description:S?`No results for this query`:`This agent has no memories yet`,className:`py-8`}):(0,g.jsxs)(`div`,{className:`space-y-3`,children:[(0,g.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[N.length,` memories`]}),N.map(e=>(0,g.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] p-3`,children:[(0,g.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[(0,g.jsx)(l,{variant:e.type===`reflection`?`info`:e.type===`thought`?`warning`:`muted`,children:e.type}),(0,g.jsx)(l,{variant:`muted`,children:e.sourceType}),(0,g.jsx)(`span`,{className:`text-xs font-medium ${P(e.importance)}`,children:`*`.repeat(e.importance)}),e.score!=null&&(0,g.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`score: `,e.score.toFixed(3)]})]}),(0,g.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-[var(--app-text)]`,children:e.content}),(0,g.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:e.keywords.map(e=>(0,g.jsx)(`span`,{className:`rounded bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-[10px] text-[var(--app-text-subtle)]`,children:e},e))}),e.type===`reflection`&&e.evidence&&e.evidence.length>0&&(0,g.jsxs)(`div`,{className:`mt-2`,children:[(0,g.jsxs)(`button`,{className:`text-[10px] text-[var(--app-accent)] hover:text-[var(--app-accent)]`,onClick:()=>k(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),children:[O.has(e.id)?`Hide`:`Show`,` evidence (`,e.evidence.length,` memories)`]}),O.has(e.id)&&(0,g.jsx)(`div`,{className:`mt-1.5 space-y-1 border-l-2 border-[var(--app-border)] pl-2`,children:e.evidence.map(e=>{let t=v.find(t=>t.id===e);return(0,g.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:t?t.content.slice(0,120)+(t.content.length>120?`...`:``):(0,g.jsxs)(`span`,{className:`italic`,children:[`Memory `,e.slice(0,8),` (not in current view)`]})},e)})})]}),(0,g.jsxs)(`p`,{className:`mt-1.5 text-[10px] text-[var(--app-text-subtle)]`,children:[p(e.createdAt),` | accessed `,e.retrievedCount,`x | last: `,p(e.lastAccessed)]})]},e.id))]})})]})}export{_ as Memories};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{ct as t,g as n,rt as r,y as i}from"./vendor-icons-Dk0hMuJz.js";import{t as a}from"./vendor-react-C6faO6LO.js";import{n as o}from"./dist-Bdqp1ixJ.js";import{t as s}from"./Button-DuQctNms.js";import{r as c,t as l}from"./index-DYsO5Awn.js";import{t as u}from"./Card-rKfViPS2.js";import{t as d}from"./PageHeader-CHSgtxPw.js";import{t as f}from"./SectionHeader-C2WpiwJ5.js";import{a as p}from"./format-CHfBBLog.js";import{t as m}from"./EmptyState-CIdIlMbn.js";var h=e(t(),1),g=a();function _(){let e=c(e=>e.roles),t=c(e=>e.fetchRoles),[a,_]=(0,h.useState)(``),[v,y]=(0,h.useState)([]),[b,x]=(0,h.useState)(!1),[S,C]=(0,h.useState)(``),[w,T]=(0,h.useState)(!1),[E,D]=(0,h.useState)(`all`),[O,k]=(0,h.useState)(new Set);(0,h.useEffect)(()=>{t()},[t]),(0,h.useEffect)(()=>{!a&&e.length>0&&_(e[0].id)},[e,a]);let A=(0,h.useCallback)(async()=>{if(a){x(!0);try{y((await o(`/memories/${a}?limit=100`)).memories)}catch{y([])}finally{x(!1)}}},[a]);(0,h.useEffect)(()=>{a&&A()},[a,A]);let j=async()=>{if(!(!S.trim()||!a)){T(!0);try{y((await o(`/memories/query`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentId:a,prompt:S.trim(),topK:20})})).memories)}catch{y([])}finally{T(!1)}}},M=()=>{C(``),A()},N=v.filter(e=>E===`high`?e.importance>3:E===`medium`?e.importance===3:E===`low`?e.importance<3:!0),P=e=>e>=4?`text-[var(--app-danger)]`:e===3?`text-[var(--app-warning)]`:`text-[var(--app-text-subtle)]`;return(0,g.jsxs)(`div`,{className:`space-y-5`,children:[(0,g.jsx)(d,{eyebrow:`Knowledge`,title:`Memories`,compact:!0,description:`What each role is retaining and how retrieval changes the visible recall set.`,metrics:[{label:`Role`,value:e.find(e=>e.id===a)?.name??`None`},{label:`Visible`,value:N.length},{label:`High Importance`,value:v.filter(e=>e.importance>3).length}],actions:(0,g.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void A(),children:(0,g.jsx)(i,{size:14})})}),(0,g.jsx)(f,{title:`Recall Controls`,compact:!0,description:`Switch role context, run a retrieval query, or narrow by importance.`}),(0,g.jsx)(u,{className:`surface-panel-muted`,children:(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,g.jsx)(`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:a,onChange:e=>_(e.target.value),children:e.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,g.jsx)(`input`,{className:`w-64 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] placeholder-slate-600 focus:border-[var(--app-accent)] focus:outline-none`,value:S,onChange:e=>C(e.target.value),onKeyDown:e=>e.key===`Enter`&&void j(),placeholder:`Search memories...`}),(0,g.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>void j(),disabled:w,children:(0,g.jsx)(n,{size:14})}),S&&(0,g.jsx)(s,{size:`sm`,variant:`ghost`,onClick:M,children:`Clear`})]}),(0,g.jsx)(`div`,{className:`flex gap-1`,children:[`all`,`high`,`medium`,`low`].map(e=>(0,g.jsx)(`button`,{className:`rounded px-2 py-1 text-xs transition-colors ${E===e?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:bg-[var(--app-panel-muted)]`}`,onClick:()=>D(e),children:e},e))})]})}),(0,g.jsx)(u,{children:b||w?(0,g.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,g.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):N.length===0?(0,g.jsx)(m,{icon:(0,g.jsx)(r,{size:32}),title:`No memories`,description:S?`No results for this query`:`This agent has no memories yet`,className:`py-8`}):(0,g.jsxs)(`div`,{className:`space-y-3`,children:[(0,g.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[N.length,` memories`]}),N.map(e=>(0,g.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] p-3`,children:[(0,g.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[(0,g.jsx)(l,{variant:e.type===`reflection`?`info`:e.type===`thought`?`warning`:`muted`,children:e.type}),(0,g.jsx)(l,{variant:`muted`,children:e.sourceType}),(0,g.jsx)(`span`,{className:`text-xs font-medium ${P(e.importance)}`,children:`*`.repeat(e.importance)}),e.score!=null&&(0,g.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`score: `,e.score.toFixed(3)]})]}),(0,g.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-[var(--app-text)]`,children:e.content}),(0,g.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:e.keywords.map(e=>(0,g.jsx)(`span`,{className:`rounded bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-[10px] text-[var(--app-text-subtle)]`,children:e},e))}),e.type===`reflection`&&e.evidence&&e.evidence.length>0&&(0,g.jsxs)(`div`,{className:`mt-2`,children:[(0,g.jsxs)(`button`,{className:`text-[10px] text-[var(--app-accent)] hover:text-[var(--app-accent)]`,onClick:()=>k(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),children:[O.has(e.id)?`Hide`:`Show`,` evidence (`,e.evidence.length,` memories)`]}),O.has(e.id)&&(0,g.jsx)(`div`,{className:`mt-1.5 space-y-1 border-l-2 border-[var(--app-border)] pl-2`,children:e.evidence.map(e=>{let t=v.find(t=>t.id===e);return(0,g.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:t?t.content.slice(0,120)+(t.content.length>120?`...`:``):(0,g.jsxs)(`span`,{className:`italic`,children:[`Memory `,e.slice(0,8),` (not in current view)`]})},e)})})]}),(0,g.jsxs)(`p`,{className:`mt-1.5 text-[10px] text-[var(--app-text-subtle)]`,children:[p(e.createdAt),` | accessed `,e.retrievedCount,`x | last: `,p(e.lastAccessed)]})]},e.id))]})})]})}export{_ as Memories};