adam-agent-server 1.13.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -5
- package/dist/App-6TRGTNZ7.js +13 -0
- package/dist/approval-handler-YLO3V75T.js +1 -0
- package/dist/audit-diagnostics-MASYIEGZ.js +1 -0
- package/dist/audit-manager-LYBXP7U4.js +1 -0
- package/dist/bree-engine-AA7EVKTG.js +1 -0
- package/dist/{channels-WFC26TED.js → channels-2IL6USWL.js} +1 -1
- package/dist/channels-6BEGHNOK.js +1 -0
- package/dist/chat-tool-calls-KARPW7PE.js +1 -0
- package/dist/chunk-245WE5AF.js +1 -0
- package/dist/chunk-2N4EOZZ4.js +9 -0
- package/dist/chunk-3BRHWRZ5.js +2 -0
- package/dist/chunk-3KNR2F6H.js +3 -0
- package/dist/chunk-42V6ZPCS.js +5 -0
- package/dist/chunk-6NWIZ3BH.js +220 -0
- package/dist/chunk-APAOIZN4.js +114 -0
- package/dist/chunk-ASPPM7TQ.js +1 -0
- package/dist/chunk-BKNXRSJU.js +4 -0
- package/dist/{chunk-MRTJFYPR.js → chunk-BLCNUT53.js} +1 -1
- package/dist/chunk-BPXS4QEO.js +1006 -0
- package/dist/chunk-CLNYHWZ6.js +5 -0
- package/dist/chunk-D3SPXZZY.js +6 -0
- package/dist/{chunk-SWP2JC54.js → chunk-DRO3DG7X.js} +1 -1
- package/dist/chunk-EVUZ5LH2.js +1 -0
- package/dist/chunk-F6U5TMM3.js +5 -0
- package/dist/chunk-FD4IKMXV.js +1 -0
- package/dist/chunk-GXWB47NF.js +9 -0
- package/dist/{chunk-PXGK5H5C.js → chunk-I7LJ4432.js} +1 -1
- package/dist/chunk-ICAM2GUU.js +1 -0
- package/dist/{chunk-B44X7JAJ.js → chunk-IRUR4DVD.js} +1 -1
- package/dist/chunk-ISKCTUI7.js +9 -0
- package/dist/{chunk-7T4B2MZ7.js → chunk-J3VYLSJI.js} +1 -1
- package/dist/chunk-KJNAORKM.js +15 -0
- package/dist/chunk-L47LZYVG.js +21 -0
- package/dist/chunk-LU3D53ZV.js +34 -0
- package/dist/{chunk-YKYRNTPV.js → chunk-N2OLEUAQ.js} +1 -1
- package/dist/{chunk-PHT24MOV.js → chunk-NLTYJUQG.js} +1 -1
- package/dist/chunk-NNMQGISW.js +1 -0
- package/dist/chunk-NPGZRSGL.js +5 -0
- package/dist/chunk-NTVLV7NI.js +1 -0
- package/dist/chunk-NUJSTEV4.js +1 -0
- package/dist/{chunk-FUWPDXXG.js → chunk-NWGRLNUM.js} +1 -1
- package/dist/chunk-OQ3JOTPK.js +1 -0
- package/dist/chunk-RBJPQYV3.js +6 -0
- package/dist/chunk-SVUP3F4V.js +14 -0
- package/dist/chunk-TLMG5W3L.js +4 -0
- package/dist/chunk-TLP4ZMJB.js +19 -0
- package/dist/{chunk-WQFNB2MQ.js → chunk-TZCMK3UG.js} +6 -6
- package/dist/chunk-UFWMUBFH.js +25 -0
- package/dist/chunk-VKKDSXMR.js +1 -0
- package/dist/chunk-VNXTBIPI.js +31 -0
- package/dist/chunk-XF7YHFVR.js +15 -0
- package/dist/{chunk-X5V4VMET.js → chunk-XIVFVKMB.js} +2 -2
- package/dist/chunk-XYZVMTNN.js +1 -0
- package/dist/{chunk-Q2JQFDAK.js → chunk-XZEBYOFR.js} +3 -3
- package/dist/chunk-Z6LHGA27.js +1 -0
- package/dist/cli.js +10 -10
- package/dist/config-VHWLMFIN.js +1 -0
- package/dist/{config-GKVOAMY2.js → config-XO7TGH27.js} +1 -1
- package/dist/db-WCTOLFAZ.js +1 -0
- package/dist/delivery-log-ML4RJOBM.js +1 -0
- package/dist/dist-HCSYRPJU.js +1 -0
- package/dist/engine-XLH4VL6Y.js +1 -0
- package/dist/evolution-audit-HLU7LQL6.js +1 -0
- package/dist/execution-tools-SYP3GR6T.js +1 -0
- package/dist/{external-api-DOVGA3ML.js → external-api-YMEFVZGG.js} +1 -1
- package/dist/index.js +240 -36
- package/dist/learner-NJXX2RUL.js +1 -0
- package/dist/{logger-WEXZORHP.js → logger-PAMNFWI3.js} +1 -1
- package/dist/memories-JDTQM3UN.js +1 -0
- package/dist/memory-extractor-5PTMCSOX.js +1 -0
- package/dist/memory-gc-BCHTOSXK.js +1 -0
- package/dist/memory-service-66EMRJXO.js +1 -0
- package/dist/onnxruntime_binding-2BPLI7ZQ.node +0 -0
- package/dist/onnxruntime_binding-5J67DTMJ.node +0 -0
- package/dist/onnxruntime_binding-7ZZLEQ2F.node +0 -0
- package/dist/onnxruntime_binding-KDCXAPN5.node +0 -0
- package/dist/onnxruntime_binding-R73P2IQW.node +0 -0
- package/dist/outbound-gateway-3INYZDOR.js +1 -0
- package/dist/presets-DT3J2ON4.js +1 -0
- package/dist/reflection-job-ST4ANCGB.js +23 -0
- package/dist/role-presets-3IQKCSVQ.js +1 -0
- package/dist/role-workspace-SIHNI6HO.js +1 -0
- package/dist/roles-F6AEM6B5.js +1 -0
- package/dist/{runtime-QA2DCZYQ.js → runtime-TWLGJSL6.js} +1 -1
- package/dist/session-manager-JTQRJI7R.js +1 -0
- package/dist/skill-registry-4JT62GEF.js +1 -0
- package/dist/target-resolution-PSSBM4LX.js +1 -0
- package/dist/task-templates-6G46OVYT.js +1 -0
- package/dist/template-dispatch-2K7KV7YS.js +1 -0
- package/dist/template-execution-artifacts-NEPSVD2B.js +1 -0
- package/dist/trace-context-UR7DI5ME.js +1 -0
- package/package.json +34 -14
- package/web/dist/assets/{Button-VPwTNGpF.js → Button-fLMsJd5o.js} +1 -1
- package/web/dist/assets/{Card-C2N6k4gh.js → Card-cy-gHU0O.js} +1 -1
- package/web/dist/assets/{ChannelDetail-DktmpO0A.js → ChannelDetail-CsKBPHkT.js} +1 -1
- package/web/dist/assets/Channels-DMutLV9r.js +14 -0
- package/web/dist/assets/Chat-DWTs-iOw.js +2 -0
- package/web/dist/assets/Dashboard-CoatfhW8.js +1 -0
- package/web/dist/assets/{EmptyState-CWS9PJND.js → EmptyState-C5kVDHc7.js} +1 -1
- package/web/dist/assets/{EnvVarEditor-D0kGIBcl.js → EnvVarEditor-BvRsHayG.js} +1 -1
- package/web/dist/assets/{EventDefDetail-BiXTA6LF.js → EventDefDetail-zuJydp12.js} +1 -1
- package/web/dist/assets/Events-nCImjXyr.js +1 -0
- package/web/dist/assets/{Evolution-C884p_CE.js → Evolution-Br41g99g.js} +1 -1
- package/web/dist/assets/ExtensionDetail-BXlphIkn.js +1 -0
- package/web/dist/assets/Extensions-3lhbw0A2.js +1 -0
- package/web/dist/assets/{FeatureRequests-Ck0WQnXX.js → FeatureRequests-oaXQNu43.js} +1 -1
- package/web/dist/assets/{GoalDetail-DJOyf7By.js → GoalDetail-DRDg1JDv.js} +1 -1
- package/web/dist/assets/Goals-DGmKvtGA.js +1 -0
- package/web/dist/assets/{Logs-6r7fnBn7.js → Logs-BZKxhdnb.js} +1 -1
- package/web/dist/assets/{Memories-CvPaqv5r.js → Memories-DhJJk-KB.js} +1 -1
- package/web/dist/assets/{Mistakes-aUhkqHDC.js → Mistakes-DxThj9as.js} +1 -1
- package/web/dist/assets/{NotFound-R6tIzhL0.js → NotFound-buXr2gl7.js} +1 -1
- package/web/dist/assets/{PageHeader-D9lLjo0N.js → PageHeader-BgNbz3JV.js} +1 -1
- package/web/dist/assets/Plugins-BXrsGsXs.js +1 -0
- package/web/dist/assets/RoleDetail-rClUsHwS.js +35 -0
- package/web/dist/assets/Roles-DH9cRv8h.js +1 -0
- package/web/dist/assets/{SectionHeader-BB3H3F_P.js → SectionHeader-CwX6m1f6.js} +1 -1
- package/web/dist/assets/Settings-My2lOEWv.js +1 -0
- package/web/dist/assets/{Strategies-DUps-2I9.js → Strategies-YLMryJlG.js} +1 -1
- package/web/dist/assets/{Switch-B_R_EX9s.js → Switch-PNpjNoGn.js} +1 -1
- package/web/dist/assets/{Table-D4lT5uHx.js → Table-BrERwl-F.js} +1 -1
- package/web/dist/assets/{Tabs-CwzWpI-7.js → Tabs-CGHmpUAD.js} +1 -1
- package/web/dist/assets/TaskDetail-Bkaq0NwW.js +2 -0
- package/web/dist/assets/Work-4OcGMu_a.js +1 -0
- package/web/dist/assets/api-BkdixMz9.js +1 -0
- package/web/dist/assets/{es2015-DCW7LI8d.js → es2015-JqLIWAgH.js} +1 -1
- package/web/dist/assets/index-C-e-qpXc.js +12 -0
- package/web/dist/assets/index-DGTVc0qD.css +2 -0
- package/web/dist/assets/{useIsMobileLayout-D6Tz5o5h.js → useIsMobileLayout-Blj4Mk4K.js} +1 -1
- package/web/dist/assets/{usePluginsWithUsage-CSQr03vZ.js → usePluginsWithUsage-Ch9WCFTb.js} +1 -1
- package/web/dist/assets/vendor-icons-U4igmrUq.js +1 -0
- package/web/dist/assets/{vendor-react-CIkiuNDu.js → vendor-react-Bp_V-Hsf.js} +1 -1
- package/web/dist/assets/{vendor-state-CEOsUh-T.js → vendor-state-Zjl_6-V3.js} +1 -1
- package/web/dist/index.html +8 -8
- package/dist/App-5QZKMPRM.js +0 -13
- package/dist/adam-tools-SQD2V4RJ.js +0 -1
- package/dist/approval-handler-J6RUTICJ.js +0 -1
- package/dist/audit-manager-CWVHQAUI.js +0 -1
- package/dist/bree-engine-VGEYMVNP.js +0 -1
- package/dist/channels-OOIM62BX.js +0 -1
- package/dist/chunk-2BXTT4P2.js +0 -6
- package/dist/chunk-47COBMRF.js +0 -1
- package/dist/chunk-6JBSBSCL.js +0 -1
- package/dist/chunk-6WRZJVQ2.js +0 -1
- package/dist/chunk-7IFLU3CY.js +0 -4
- package/dist/chunk-AQO6IIHV.js +0 -684
- package/dist/chunk-AVM3O74V.js +0 -5
- package/dist/chunk-B544JOZM.js +0 -3
- package/dist/chunk-DZIEY4CH.js +0 -47
- package/dist/chunk-E4WIUUL4.js +0 -27
- package/dist/chunk-HDHMNT6D.js +0 -1
- package/dist/chunk-JYHOGBCP.js +0 -12
- package/dist/chunk-M3RZWIW3.js +0 -50
- package/dist/chunk-N4ES7TCL.js +0 -1
- package/dist/chunk-NPIXYK5G.js +0 -5
- package/dist/chunk-O7XQSONJ.js +0 -5
- package/dist/chunk-OZL6VNOR.js +0 -146
- package/dist/chunk-Q2ISNOBQ.js +0 -1
- package/dist/chunk-QYRI4HYA.js +0 -1
- package/dist/chunk-R2WB5BKF.js +0 -7
- package/dist/chunk-RMGBR3XZ.js +0 -21
- package/dist/chunk-S6OV7Z6K.js +0 -1
- package/dist/chunk-SC2DDRYB.js +0 -5
- package/dist/chunk-SGIKNIC5.js +0 -49
- package/dist/chunk-TI3AKKWZ.js +0 -80
- package/dist/chunk-U2LBBBWO.js +0 -8
- package/dist/chunk-UXDTFTG5.js +0 -10
- package/dist/chunk-Y5FFL6UO.js +0 -5
- package/dist/chunk-ZFDULJGB.js +0 -3
- package/dist/chunk-ZQ4PNKMQ.js +0 -10
- package/dist/config-DRFRLIVN.js +0 -1
- package/dist/db-FACSMWEY.js +0 -1
- package/dist/delivery-log-JIQMHBJ5.js +0 -1
- package/dist/dist-CDWBOTZS.js +0 -1
- package/dist/engine-OHYWUUMJ.js +0 -1
- package/dist/evolution-audit-M7FSYRQR.js +0 -1
- package/dist/learner-OUNQSWN7.js +0 -1
- package/dist/memories-ABE7PMQL.js +0 -1
- package/dist/memory-extractor-ZX2NJIBV.js +0 -6
- package/dist/memory-service-UWER3T2S.js +0 -1
- package/dist/onnxruntime_binding-6Q6HXASN.node +0 -0
- package/dist/onnxruntime_binding-EKZT2NRK.node +0 -0
- package/dist/onnxruntime_binding-P6S7V3CI.node +0 -0
- package/dist/onnxruntime_binding-PJNNIIUO.node +0 -0
- package/dist/onnxruntime_binding-UN6SPTQK.node +0 -0
- package/dist/outbound-gateway-XDCGAXXW.js +0 -1
- package/dist/presets-RMW3WO5P.js +0 -1
- package/dist/role-presets-FAXQRBII.js +0 -1
- package/dist/role-workspace-ISGPO25D.js +0 -1
- package/dist/roles-WNKRM6FD.js +0 -1
- package/dist/session-manager-SOJXQHHY.js +0 -1
- package/dist/task-templates-IS3DJCZB.js +0 -1
- package/dist/token-estimator-HMPVGDCN.js +0 -1
- package/dist/workflow-executor-LOMKVFPV.js +0 -1
- package/web/dist/assets/Channels-ozCXdZMq.js +0 -12
- package/web/dist/assets/Chat-CggvtidD.js +0 -2
- package/web/dist/assets/Dashboard-z37ZVhzH.js +0 -1
- package/web/dist/assets/Events-C4P3jjZd.js +0 -1
- package/web/dist/assets/Goals-CDZWDuXR.js +0 -1
- package/web/dist/assets/Plugins-CtwoMUoj.js +0 -1
- package/web/dist/assets/RoleDetail-B32225ae.js +0 -33
- package/web/dist/assets/Roles-CGYsxuq8.js +0 -1
- package/web/dist/assets/Settings-D2jrO8-G.js +0 -1
- package/web/dist/assets/TaskDetail-DKminIM_.js +0 -2
- package/web/dist/assets/Work-uD_6IieV.js +0 -1
- package/web/dist/assets/api-D-UzHSDq.js +0 -1
- package/web/dist/assets/index-6f2jcj0h.css +0 -2
- package/web/dist/assets/index-Bl-2p6d8.js +0 -12
- package/web/dist/assets/vendor-icons-jzPiR6xl.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as c,e as S,f as $,g as P}from"./chunk-J3VYLSJI.js";import{b as R}from"./chunk-F6U5TMM3.js";import{e as T,g as D,i as N}from"./chunk-VNXTBIPI.js";import{C as x,E as k,I as L,b as f,o as E}from"./chunk-KJNAORKM.js";import"./chunk-IRUR4DVD.js";import"./chunk-BPXS4QEO.js";import"./chunk-WBAPIPST.js";import{c as p,h}from"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";h();var w=p("agent");function I(n){let o=c(n);if(!o){w.debug({taskId:n},"No plan found for task, skipping review");return}let i=R(n,1e3),a=o.plan.steps,s=i.filter(e=>e.type==="tool_result"||e.type==="permission_denied").map(e=>({toolName:e.toolName??"unknown",output:e.content,planStepIndex:e.planStepIndex,permissionDenied:e.type==="permission_denied"})),t=[],r=new Set(s.map(e=>e.planStepIndex).filter(e=>e!==void 0));for(let e of a)r.has(e.index)||t.push({stepIndex:e.index,planned:e.description,actual:"Not executed",deviationType:"skipped"});let d=s.filter(e=>e.planStepIndex===void 0);for(let e of d)t.push({stepIndex:-1,planned:"",actual:`${e.toolName}: ${e.output.slice(0,200)}`,deviationType:"added"});let u=s.filter(e=>e.permissionDenied);for(let e of u)t.push({stepIndex:e.planStepIndex??-1,planned:e.planStepIndex!==void 0?a.find(b=>b.index===e.planStepIndex)?.description??"Unknown":"",actual:`PERMISSION DENIED: ${e.toolName}`,deviationType:"failed"});let l=a.length,g=s.length,v=l>0?Math.max(0,1-t.filter(e=>e.deviationType!=="added").length/l):1,y={stepsPlanned:l,stepsExecuted:g,deviations:t,overallAccuracy:v};return $(o.id,y),w.info({taskId:n,planId:o.id,stepsPlanned:l,stepsExecuted:g,deviationCount:t.length,accuracy:v},"Deviation report generated"),y}function A(n){return n.deviations.filter(i=>i.deviationType==="failed"||i.deviationType==="skipped").length===0&&n.overallAccuracy>=.7}E();L();N();h();var m=p("agent");function C(n){let o=[],i=[];for(let a of n)a.startsWith("[-]")?i.push(a):o.push(a);return{stylePreferences:o,avoidedActions:i}}function U(n,o){let i=[],s=f(n)?.prompt.slice(0,100)??"unknown task";A(o)&&i.push(`[+] Task "${s}" completed successfully with ${o.overallAccuracy*100}% plan accuracy (${o.stepsExecuted} steps). [sourceTaskId:${n}]`);for(let t of o.deviations)switch(t.deviationType){case"skipped":i.push(`[-] Planned step "${t.planned}" was skipped during "${s}". Consider if this step is necessary for similar tasks. [sourceTaskId:${n}]`);break;case"failed":i.push(`[-] Step failed: "${t.actual}" during "${s}". Check permissions and tool availability. [sourceTaskId:${n}]`);break;case"added":i.push(`[~] Unplanned action: "${t.actual}" during "${s}". Consider adding to plan for similar tasks. [sourceTaskId:${n}]`);break;case"modified":i.push(`[~] Step modified: planned "${t.planned}" but did "${t.actual}" during "${s}". [sourceTaskId:${n}]`);break}return i}async function H(n){let o=c(n);if(!o){m.debug({taskId:n},"No plan for task, skipping review/learn");return}let i=I(n);if(!i)return;let a=U(n,i);if(a.length===0)return;P(o.id,a);let s=f(n);if(s?.roleId){let t=x(s.roleId);if(t){let r=C(a),d={stylePreferences:[...t.learnedRules.stylePreferences,...r.stylePreferences],avoidedActions:[...t.learnedRules.avoidedActions,...r.avoidedActions],pinnedParameters:t.learnedRules.pinnedParameters};k(s.roleId,{learnedRules:d});let u=T(t.name);D(u,{...t,learnedRules:d}),m.info({roleId:s.roleId,newRulesCount:a.length},"Role learnedRules updated and CLAUDE.md written")}}S(o.id,"completed"),m.info({taskId:n,planId:o.id,rulesExtracted:a.length,accuracy:i.overallAccuracy},"Task review and learning completed")}export{U as extractRulesFromDeviation,H as processTaskReview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h}from"./chunk-BLCNUT53.js";import"./chunk-FCV2DPZQ.js";h();export{g as getComponentFilter,e as getLogLevel,c as getLogger,b as logger,a as onLogEvent,f as setComponentFilter,d as setLogLevel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r}from"./chunk-XIVFVKMB.js";import"./chunk-KJNAORKM.js";import"./chunk-IRUR4DVD.js";import"./chunk-BPXS4QEO.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{p as DEFAULT_HYBRID_CONFIG,l as DEFAULT_SCORING_WEIGHTS,m as calculateRecency,n as calculateSmallvilleScore,q as cleanupMemories,h as cosineSimilarity,f as countMemoriesByRole,a as createMemory,k as deleteMemory,b as getMemory,o as getRoleScoringWeights,g as listMemoriesByRole,e as markSuperseded,j as searchByBM25,i as searchByVector,r as searchHybrid,c as updateMemory,d as updateMemoryRetrievalCount};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as i}from"./chunk-F6U5TMM3.js";import{a}from"./chunk-DRO3DG7X.js";import{a as p}from"./chunk-XIVFVKMB.js";import"./chunk-KJNAORKM.js";import"./chunk-IRUR4DVD.js";import"./chunk-BPXS4QEO.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";import{v4 as u}from"uuid";function l(o){let r=o.toolName,e=o.toolOutput||o.content;if(r==="Write"||r==="Edit")return{content:`Modified file via ${r}: ${e.slice(0,400)}`,importance:4,type:"event"};if(r==="Bash"){let t=o.toolInput?.command?.slice(0,100)||"Bash";return e.includes("FAIL")||e.includes("error:")||e.includes("Error:")?{content:`Command failed: ${t} ${e.slice(0,300)}`,importance:4,type:"event"}:e.includes("success")||e.includes("done")||e.includes("OK")?{content:`Command succeeded: ${t}`,importance:2,type:"event"}:{content:`Executed: ${t}`,importance:1,type:"event"}}return null}function y(o){let r=i(o,500,0),e=[];for(let t of r)if((t.type==="tool_result"||t.type==="tool_call")&&t.toolName){let n=l(t);n&&e.push(n)}else t.type==="error"&&e.push({content:`Error occurred: ${t.content.slice(0,400)}`,importance:4,type:"event"});return{facts:e}}function f(o){let r=o.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(e=>e.length>2);return[...new Set(r)].slice(0,20)}async function M(o,r){let{facts:e}=y(o);for(let n of e)if(n.type!=="event")throw new Error(`extractKeyFacts produced non-event fact (type=${n.type}) \u2014 GAP-08 invariant violated`);let t=0;for(let n of e){let c=n.content.slice(0,500),s;try{s=await a(c)}catch{}let m=f(c),d={id:u(),roleId:r,type:n.type,content:c,embedding:s,keywords:m,importance:n.importance,sourceType:"task_complete",sourceTaskId:o,createdAt:Date.now(),lastAccessed:Date.now(),retrievedCount:0,tier:"episodic"};p(d),t++}return t}export{y as extractKeyFacts,M as processTaskCompletion};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{l,n as c}from"./chunk-BPXS4QEO.js";import"./chunk-WBAPIPST.js";import{c as a,h as b}from"./chunk-BLCNUT53.js";import"./chunk-FCV2DPZQ.js";c();b();var f=a("manager");function E(e){let o=l(),t=Date.now(),n=t-e.observationTtlDays*864e5,r=t-e.beliefStaleDays*864e5,s=o.prepare("DELETE FROM memories WHERE created_at < ? AND kind = 'observation'").run(n).changes,i=o.prepare("DELETE FROM beliefs WHERE confidence < ? AND last_used_at < ? AND is_anti = 0").run(e.beliefConfidenceMin,r).changes;return o.prepare("UPDATE server_state SET last_memory_gc_at = ? WHERE id = 1").run(t),f.info({observationsDeleted:s,beliefsDeleted:i,obsCutoff:n,beliefCutoff:r},"Memory GC completed"),{observationsDeleted:s,beliefsDeleted:i}}export{E as memoryGcTick};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d}from"./chunk-D3SPXZZY.js";import"./chunk-ISKCTUI7.js";import"./chunk-DRO3DG7X.js";import"./chunk-XIVFVKMB.js";import"./chunk-KJNAORKM.js";import"./chunk-IRUR4DVD.js";import"./chunk-Z6LHGA27.js";import"./chunk-BPXS4QEO.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{c as getRelevantMemoryContext,a as queryMemory,d as queryMemoryByTier,b as selectBeliefsForContext};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as a,d as b,e as c,f as d}from"./chunk-UFWMUBFH.js";import"./chunk-LU3D53ZV.js";import"./chunk-NPGZRSGL.js";import"./chunk-3KNR2F6H.js";import"./chunk-NWGRLNUM.js";import"./chunk-CLNYHWZ6.js";import"./chunk-BKNXRSJU.js";import"./chunk-RBJPQYV3.js";import"./chunk-KJNAORKM.js";import"./chunk-L7JP7DUO.js";import"./chunk-IRUR4DVD.js";import"./chunk-ASPPM7TQ.js";import"./chunk-Z6LHGA27.js";import"./chunk-L47LZYVG.js";import"./chunk-BPXS4QEO.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{a as OutboundGateway,b as _resetChannelManagerModuleCache,c as getOutboundGateway,d as isRecentlySent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-XZEBYOFR.js";import"./chunk-VNXTBIPI.js";import"./chunk-RBJPQYV3.js";import"./chunk-KJNAORKM.js";import"./chunk-IRUR4DVD.js";import"./chunk-BPXS4QEO.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{a as ADAM_AUTOMATOR_PRESET,d as CHAT_MANAGER_ROLE_ID,e as PRESET_ROLE_NAMES,b as ROLE_PRESETS,c as TEMPLATE_PRESETS,h as ensureAdamAutomatorRole,g as ensureChatManagerRole,l as getPresetRole,j as getPresetRoles,m as getPresetTemplate,k as getPresetTemplates,i as initializeDefaultRoles,f as isPresetRole,o as restorePreset,n as seedPresets};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import{a as y}from"./chunk-XYZVMTNN.js";import{a as M}from"./chunk-TZCMK3UG.js";import{a as B,c as T,d as A,e as x}from"./chunk-ISKCTUI7.js";import{a as k}from"./chunk-DRO3DG7X.js";import{g as I}from"./chunk-XIVFVKMB.js";import"./chunk-KJNAORKM.js";import{a as O}from"./chunk-L7JP7DUO.js";import"./chunk-IRUR4DVD.js";import{d as g}from"./chunk-Z6LHGA27.js";import{l as R,n as $}from"./chunk-BPXS4QEO.js";import"./chunk-WBAPIPST.js";import{c as p,h as v}from"./chunk-BLCNUT53.js";import{c as N,e as L}from"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";$();v();L();import{v4 as E}from"uuid";v();var U=5;function C(){try{let e=g().memory?.reflection?.maxBudgetUsd;if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e}catch{}return U}var P=p("manager");function D(e){let n=e.trim(),l=n.match(/^```(\w*)\s*/);return l&&(n=n.slice(l[0].length)),n.endsWith("```")&&(n=n.slice(0,n.length-3)),n.trim()}function j(e,n){let l=D(e),a;try{a=JSON.parse(l)}catch{return{action:"coexist"}}if(!a||typeof a!="object")return{action:"coexist"};let t=a;if(t.action==="coexist")return{action:"coexist"};if(t.action==="merge"){let o=typeof t.intoBeliefId=="string"?t.intoBeliefId.trim():"",i=typeof t.mergedContent=="string"?t.mergedContent.trim():"";return o.length>0&&i.length>0&&n.some(r=>r.id===o)?{action:"merge",intoBeliefId:o,mergedContent:i}:{action:"coexist"}}if(t.action==="supersede"){let o=typeof t.oldBeliefId=="string"?t.oldBeliefId.trim():"";return o.length>0&&n.some(i=>i.id===o)?{action:"supersede",oldBeliefId:o}:{action:"coexist"}}return{action:"coexist"}}async function S(e,n){if(n.length===0)return{action:"coexist"};let a=g().anthropic?.defaultHaikuModel||"claude-haiku-4-5",o=`You are a belief conflict resolver.
|
|
2
|
+
|
|
3
|
+
Existing beliefs for this role:
|
|
4
|
+
${n.map((i,r)=>`${r+1}. id=${i.id} (conf=${i.confidence.toFixed(2)}, used=${i.useCount}) ${i.content}`).join(`
|
|
5
|
+
`)}
|
|
6
|
+
|
|
7
|
+
New candidate belief: "${e.content}"
|
|
8
|
+
|
|
9
|
+
Choose ONE of three actions and output exactly one JSON object on one line with no code fences:
|
|
10
|
+
- "coexist": candidate is meaningfully different from existing beliefs; keep both.
|
|
11
|
+
- "merge": candidate overlaps significantly with one existing belief; merge into it with the "intoBeliefId" field pointing to the existing belief's id, and "mergedContent" being the combined text.
|
|
12
|
+
- "supersede": candidate directly contradicts an existing belief; "oldBeliefId" is the existing belief's id.
|
|
13
|
+
|
|
14
|
+
Examples:
|
|
15
|
+
{"action":"coexist"}
|
|
16
|
+
{"action":"merge","intoBeliefId":"bid-123","mergedContent":"Merged belief text."}
|
|
17
|
+
{"action":"supersede","oldBeliefId":"bid-456"}
|
|
18
|
+
|
|
19
|
+
Respond with only the JSON object.`;try{let i=await y(o,{systemPrompt:"You output exactly one JSON line classifying a belief conflict. No prose.",model:a,maxBudgetUsd:C(),maxTurns:10});return j(i,n)}catch(i){return P.warn({err:i,content:e.content},"Haiku failed for belief conflict resolution; coexisting"),{action:"coexist"}}}var f=p("manager");function H(e){let n=e.trim(),l=n.match(/^```(\w*)\s*/);l&&(n=n.slice(l[0].length)),n.endsWith("```")&&(n=n.slice(0,n.length-3)),n=n.trim();let a;try{a=JSON.parse(n)}catch{return[]}return Array.isArray(a)?a.filter(t=>t!==null&&typeof t=="object").map(t=>{let o=typeof t.content=="string"?t.content.trim():"";if(!o)return null;let i=typeof t.confidence=="number"?Math.max(0,Math.min(1,t.confidence)):.5,r=Array.isArray(t.evidence_indices)?t.evidence_indices.filter(c=>Number.isInteger(c)).map(Number):[];return{content:o,confidence:i,evidence_indices:r}}).filter(t=>t!==null&&t.content.length>0):[]}async function V(e,n){let a=g().anthropic?.defaultHaikuModel||"claude-haiku-4-5",o=n.slice(0,30).map((r,c)=>`${c}. (importance:${r.importance}) ${r.content}`).join(`
|
|
20
|
+
`),i=`Below are recent observations from agent ${e}. Extract 1 to 4 structured beliefs a future task would benefit from knowing. Each belief should be a single concrete actionable sentence, NOT a count or summary statistic. Cite which observation indices support each belief. Return ONLY a JSON array on one line. Each item: {"content": "<belief>", "confidence": <0..1>, "evidence_indices": [<int>, ...]}. Example: [{"content":"TTS audio must pass an audibility check before delivery","confidence":0.7,"evidence_indices":[2,5]}]
|
|
21
|
+
|
|
22
|
+
Observations:
|
|
23
|
+
${o}`;try{let r=await y(i,{systemPrompt:"You output exactly one JSON array of belief candidates. No prose. No code fences.",model:a,maxBudgetUsd:C(),maxTurns:10}),c=H(r);return f.info({roleId:e,rawLen:r.length,rawHead:r.slice(0,400),rawTail:r.length>400?r.slice(-200):"",parsedCount:c.length},"reflection_haiku_result"),c}catch(r){return f.warn({err:r,roleId:e},"reflection_haiku_failed"),O.emit({type:"log_event",timestamp:Date.now(),level:"warn",component:"reflection",msg:"reflection_haiku_failed",metadata:{roleId:e,err:String(r)}}),[]}}async function F(e){let t=I(e,500,0).filter(c=>c.importance>=3);if(t.length===0)return f.info({roleId:e,written:0,reason:"no_recent_observations"},"reflection_completed"),{written:0};let o=await V(e,t);if(o.length===0)return f.info({roleId:e,written:0,recentCount:t.length,reason:"no_candidates_parsed"},"reflection_completed"),{written:0};let i=0,r=0;for(let c of o){let _=c.evidence_indices.filter(s=>s>=0&&s<t.length).map(s=>t[s].id);if(_.length===0){r++,f.debug({roleId:e,content:c.content.slice(0,120),evidenceIndices:c.evidence_indices,recentRange:[0,t.length-1]},"reflection_candidate_skipped_empty_evidence");continue}let u;try{u=await k(c.content)}catch(s){f.debug({roleId:e,err:s.message},"reflection_embedding_failed")}let h=[];u?h=A(e,u,5).map(s=>s.node):h=T(e).slice(0,5);let m=await S({content:c.content},h),d=Date.now();if(m.action==="coexist")B({id:E(),roleId:e,content:c.content,confidence:c.confidence??.5,useCount:0,successCount:0,isAnti:!1,evidenceObsIds:_,embedding:u,createdAt:d,lastUsedAt:d,lastValidatedAt:d}),i++;else if(m.action==="merge"){let s=h.find(w=>w.id===m.intoBeliefId),b=E();B({id:b,roleId:e,content:m.mergedContent,confidence:Math.min(1,s.confidence+.1),useCount:s.useCount,successCount:s.successCount,isAnti:!1,evidenceObsIds:[...s.evidenceObsIds,..._],embedding:u,createdAt:d,lastUsedAt:d,lastValidatedAt:d}),x(s.id,b),i++}else if(m.action==="supersede"){let s=h.find(w=>w.id===m.oldBeliefId),b=E();B({id:b,roleId:e,content:c.content,confidence:c.confidence??.6,useCount:s.useCount,successCount:s.successCount,isAnti:!1,evidenceObsIds:_,embedding:u,createdAt:d,lastUsedAt:d,lastValidatedAt:d}),x(s.id,b),i++}}try{M({timestamp:Date.now(),oldRules:"",newRules:`reflection: wrote ${i} belief(s) for role ${e}`,diff:`written=${i}`,roleId:e,source:"reflection",traceId:N()})}catch{}return f.info({roleId:e,written:i,observed:t.length,candidatesCount:o.length,skippedNoEvidence:r},"reflection_completed"),{written:i}}v();var J=p("manager");async function ge(e){let n=R(),l=Date.now()-e*6e4,a=n.prepare("SELECT id, last_reflection_at FROM roles WHERE last_reflection_at IS NULL OR last_reflection_at < ?").all(l),t=[];for(let o of a){n.prepare("UPDATE roles SET last_reflection_at = ? WHERE id = ?").run(Date.now(),o.id);try{await F(o.id),t.push(o.id)}catch(i){J.warn({err:i,roleId:o.id},"Reflection tick: role failed; slot remains claimed")}}return t}export{ge as reflectionTick};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-QMW7VEPC.js";import{a,d as b,e as c,f as d,g as e,h as f,i as g}from"./chunk-XZEBYOFR.js";import"./chunk-VNXTBIPI.js";import"./chunk-RBJPQYV3.js";import"./chunk-KJNAORKM.js";import"./chunk-IRUR4DVD.js";import"./chunk-BPXS4QEO.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{a as ADAM_AUTOMATOR_PRESET,b as CHAT_MANAGER_ROLE_ID,c as PRESET_ROLE_NAMES,f as ensureAdamAutomatorRole,e as ensureChatManagerRole,g as initializeDefaultRoles,d as isPresetRole};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as a,f as b,g as c,h as d,i as e}from"./chunk-VNXTBIPI.js";import"./chunk-KJNAORKM.js";import"./chunk-IRUR4DVD.js";import"./chunk-BPXS4QEO.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";e();export{b as ensureRoleWorkspace,a as getRoleWorkspacePath,d as syncRoleSettings,c as writeRoleCLAUDEmd};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as a,B as b,C as c,D as d,E as e,F as f,G as g,H as h,I as i}from"./chunk-KJNAORKM.js";import"./chunk-IRUR4DVD.js";import"./chunk-BPXS4QEO.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";i();export{b as createRole,h as deleteRole,c as getRole,d as getRoleByName,g as hasActiveTasks,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}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-Z6LHGA27.js";import"./chunk-FCV2DPZQ.js";export{a as MUTABLE_PATHS,b as RESTART_REQUIRED_PATHS,f as buildSdkAuthEnv,i as buildSdkEnv,g as filterAnthropicKeys,k as getNestedValue,d as getRuntimeConfig,c as initRuntimeConfig,l as isMutablePath,m as isRestartRequiredPath,e as loadPersistedConfig,h as maskSensitiveEnvValues,j as updateMutableConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"./chunk-I7LJ4432.js";import"./chunk-DRO3DG7X.js";import"./chunk-XIVFVKMB.js";import"./chunk-XF7YHFVR.js";import"./chunk-NWGRLNUM.js";import"./chunk-KJNAORKM.js";import"./chunk-L7JP7DUO.js";import"./chunk-IRUR4DVD.js";import"./chunk-VKKDSXMR.js";import"./chunk-ASPPM7TQ.js";import"./chunk-TLMG5W3L.js";import"./chunk-Z6LHGA27.js";import"./chunk-BPXS4QEO.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.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}from"./chunk-2N4EOZZ4.js";import"./chunk-ICAM2GUU.js";import"./chunk-VNXTBIPI.js";import"./chunk-KJNAORKM.js";import"./chunk-IRUR4DVD.js";import"./chunk-BPXS4QEO.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{a as SkillRegistry};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-NUJSTEV4.js";import"./chunk-NNMQGISW.js";import"./chunk-BLCNUT53.js";import"./chunk-FCV2DPZQ.js";export{a as getDefaultChatIdForChannel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as a,o as b,p as c,q as d,r as e,s as f,t as g,u as h,v as i,w as j,x as k,y as l}from"./chunk-RBJPQYV3.js";import"./chunk-KJNAORKM.js";import"./chunk-IRUR4DVD.js";import"./chunk-BPXS4QEO.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{b as TemplateRoleConfigError,a as TemplateValidationError,e as createTaskTemplate,l as deleteTaskTemplate,j as disableTaskTemplate,i as enableTaskTemplate,f as getTaskTemplate,k as getTaskTemplateDependents,h as listTaskTemplates,g as updateTaskTemplate,d as validateTemplateDefinition,c as validateTemplateRoleConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as a}from"./chunk-APAOIZN4.js";import"./chunk-TLP4ZMJB.js";import"./chunk-J3VYLSJI.js";import"./chunk-XYZVMTNN.js";import"./chunk-I7LJ4432.js";import"./chunk-NUJSTEV4.js";import"./chunk-ICAM2GUU.js";import"./chunk-FD4IKMXV.js";import"./chunk-F6U5TMM3.js";import"./chunk-DRO3DG7X.js";import"./chunk-XIVFVKMB.js";import"./chunk-XF7YHFVR.js";import"./chunk-NNMQGISW.js";import"./chunk-UFWMUBFH.js";import"./chunk-LU3D53ZV.js";import"./chunk-NPGZRSGL.js";import"./chunk-3KNR2F6H.js";import"./chunk-NWGRLNUM.js";import"./chunk-CLNYHWZ6.js";import"./chunk-BKNXRSJU.js";import"./chunk-VNXTBIPI.js";import"./chunk-RBJPQYV3.js";import"./chunk-KJNAORKM.js";import"./chunk-L7JP7DUO.js";import"./chunk-IRUR4DVD.js";import"./chunk-VKKDSXMR.js";import"./chunk-ASPPM7TQ.js";import"./chunk-TLMG5W3L.js";import"./chunk-Z6LHGA27.js";import"./chunk-L47LZYVG.js";import"./chunk-BPXS4QEO.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{a as dispatchTemplate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-L47LZYVG.js";import"./chunk-BPXS4QEO.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-FCV2DPZQ.js";l();export{i as appendArtifactToCollection,j as convertPrimaryFileToCollectionInTransaction,a as createArtifact,f as deleteArtifactById,d as deleteArtifactsByExecution,e as deleteArtifactsByExecutionAndStep,h as ensureUniqueArtifactKey,b as getArtifact,g as isArtifactCollectionManifest,c as listArtifactsByExecution,k as listExpiredExecutions};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e}from"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";e();export{c as getCurrentTraceId,d as getTraceStore,a as withNewTrace,b as withTrace};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adam-agent-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "Goal-driven AI agent orchestration server with Role+Skill model, real-time streaming, and multi-channel delivery",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "norvyn https://x.com/norvynzhang https://github.com/n0rvyn norvynzhang@gmail.com",
|
|
@@ -15,51 +15,67 @@
|
|
|
15
15
|
"adam": "dist/cli.js"
|
|
16
16
|
},
|
|
17
17
|
"optionalDependencies": {
|
|
18
|
-
"onnxruntime-node": "^1.
|
|
18
|
+
"onnxruntime-node": "^1.26.0"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@anthropic-ai/claude-agent-sdk": "^0.2.
|
|
21
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.141",
|
|
22
22
|
"@anthropic-ai/sdk": "^0.80.0",
|
|
23
23
|
"@fastify/cors": "^10.1.0",
|
|
24
|
-
"@fastify/
|
|
24
|
+
"@fastify/multipart": "^10.0.0",
|
|
25
|
+
"@fastify/static": "^9.1.3",
|
|
25
26
|
"@fastify/swagger": "^9.7.0",
|
|
26
|
-
"@fastify/swagger-ui": "^5.2.
|
|
27
|
+
"@fastify/swagger-ui": "^5.2.6",
|
|
27
28
|
"@fastify/websocket": "^11.2.0",
|
|
29
|
+
"adm-zip": "^0.5.17",
|
|
30
|
+
"ajv": "^8.20.0",
|
|
28
31
|
"better-sqlite3": "^11.10.0",
|
|
29
32
|
"bree": "^9.2.9",
|
|
30
33
|
"chalk": "^5.6.2",
|
|
31
34
|
"commander": "^13.1.0",
|
|
32
35
|
"cron-parser": "^5.5.0",
|
|
33
|
-
"discord.js": "^14.26.
|
|
36
|
+
"discord.js": "^14.26.4",
|
|
34
37
|
"fastify": "^5.8.5",
|
|
38
|
+
"html-to-text": "^9.0.5",
|
|
39
|
+
"image-size": "^2.0.2",
|
|
40
|
+
"imapflow": "^1.3.3",
|
|
35
41
|
"ink": "^5.2.1",
|
|
42
|
+
"ink-select-input": "^6.2.0",
|
|
36
43
|
"ink-spinner": "^5.0.0",
|
|
37
44
|
"ink-text-input": "^6.0.0",
|
|
45
|
+
"mailparser": "^3.9.8",
|
|
46
|
+
"markdown-it": "^14.1.1",
|
|
47
|
+
"nodemailer": "^7.0.13",
|
|
48
|
+
"pdf-lib": "^1.17.1",
|
|
38
49
|
"pino": "^10.3.1",
|
|
39
50
|
"pino-pretty": "^13.1.3",
|
|
40
51
|
"react": "^18.3.1",
|
|
41
|
-
"uuid": "^11.1.
|
|
42
|
-
"yaml": "^2.
|
|
43
|
-
"zod": "^4.3
|
|
52
|
+
"uuid": "^11.1.1",
|
|
53
|
+
"yaml": "^2.9.0",
|
|
54
|
+
"zod": "^4.4.3"
|
|
44
55
|
},
|
|
45
56
|
"devDependencies": {
|
|
46
57
|
"@testing-library/react": "^16.3.2",
|
|
58
|
+
"@types/adm-zip": "^0.5.8",
|
|
47
59
|
"@types/better-sqlite3": "^7.6.13",
|
|
48
|
-
"@types/
|
|
60
|
+
"@types/html-to-text": "^9.0.4",
|
|
61
|
+
"@types/mailparser": "^3.4.6",
|
|
62
|
+
"@types/markdown-it": "^14.1.2",
|
|
63
|
+
"@types/node": "^22.19.19",
|
|
64
|
+
"@types/nodemailer": "^7.0.11",
|
|
49
65
|
"@types/react": "^18.3.28",
|
|
50
66
|
"@types/react-dom": "^19.2.3",
|
|
51
67
|
"@types/uuid": "^10.0.0",
|
|
52
68
|
"@types/ws": "^8.18.1",
|
|
53
|
-
"@vitest/coverage-v8": "^4.1.
|
|
69
|
+
"@vitest/coverage-v8": "^4.1.6",
|
|
54
70
|
"conventional-commits-parser": "^3.2.4",
|
|
55
71
|
"happy-dom": "^20.9.0",
|
|
56
72
|
"ink-testing-library": "^4.0.0",
|
|
57
73
|
"react-dom": "^18.3.1",
|
|
58
74
|
"tsup": "^8.5.1",
|
|
59
|
-
"tsx": "^4.
|
|
75
|
+
"tsx": "^4.22.0",
|
|
60
76
|
"typescript": "^5.9.3",
|
|
61
|
-
"vitest": "^4.1.
|
|
62
|
-
"ws": "^8.20.
|
|
77
|
+
"vitest": "^4.1.6",
|
|
78
|
+
"ws": "^8.20.1"
|
|
63
79
|
},
|
|
64
80
|
"engines": {
|
|
65
81
|
"node": ">=20.0.0"
|
|
@@ -74,7 +90,11 @@
|
|
|
74
90
|
"test:coverage": "vitest run --coverage",
|
|
75
91
|
"test:e2e": "vitest run src/__tests__/e2e/",
|
|
76
92
|
"test:unit": "vitest run --exclude 'src/__tests__/e2e/**'",
|
|
93
|
+
"pretest:unit": "tsx scripts/audit-test-db-isolation.ts",
|
|
94
|
+
"pretest": "tsx scripts/audit-test-db-isolation.ts",
|
|
77
95
|
"typecheck": "tsc --noEmit",
|
|
96
|
+
"audit:tool-receipts": "tsx scripts/audit-tool-receipts.ts",
|
|
97
|
+
"audit:test-isolation": "tsx scripts/audit-test-db-isolation.ts",
|
|
78
98
|
"postinstall": "npm rebuild better-sqlite3 2>/dev/null || true"
|
|
79
99
|
}
|
|
80
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{mt as t}from"./vendor-icons-U4igmrUq.js";import{t as n}from"./vendor-react-Bp_V-Hsf.js";import{n as r,t as i}from"./dist-CgGno8kE.js";var a=e(t(),1);function o(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function s(...e){return t=>{let n=!1,r=e.map(e=>{let r=o(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():o(e[t],null)}}}}function c(...e){return a.useCallback(s(...e),e)}var l=n(),u=Symbol.for(`react.lazy`),d=a.use;function f(e){return typeof e==`object`&&!!e&&`then`in e}function p(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===u&&`_payload`in e&&f(e._payload)}function m(e){let t=g(e),n=a.forwardRef((e,n)=>{let{children:r,...i}=e;p(r)&&typeof d==`function`&&(r=d(r._payload));let o=a.Children.toArray(r),s=o.find(v);if(s){let e=s.props.children,r=o.map(t=>t===s?a.Children.count(e)>1?a.Children.only(null):a.isValidElement(e)?e.props.children:null:t);return(0,l.jsx)(t,{...i,ref:n,children:a.isValidElement(e)?a.cloneElement(e,void 0,r):null})}return(0,l.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var h=m(`Slot`);function g(e){let t=a.forwardRef((e,t)=>{let{children:n,...r}=e;if(p(n)&&typeof d==`function`&&(n=d(n._payload)),a.isValidElement(n)){let e=b(n),i=y(r,n.props);return n.type!==a.Fragment&&(i.ref=t?s(t,e):e),a.cloneElement(n,i)}return a.Children.count(n)>1?a.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var _=Symbol(`radix.slottable`);function v(e){return a.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===_}function y(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function b(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var x=i(`inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md text-sm font-medium transition-[background-color,border-color,color,box-shadow] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--app-canvas)] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,{variants:{variant:{default:`bg-[var(--app-accent)] text-white shadow-[var(--app-shadow-accent)] hover:bg-[var(--app-accent-strong)] hover:shadow-[var(--app-shadow-lg)]`,secondary:`border border-[var(--app-border)] bg-white/[0.06] text-[var(--app-text)] hover:border-[var(--app-border-strong)] hover:bg-white/[0.1]`,destructive:`bg-[var(--app-danger)] text-white shadow-[var(--app-shadow-danger)] hover:bg-[var(--app-danger-strong)]`,ghost:`text-[var(--app-text-muted)] hover:text-[var(--app-text)] hover:bg-white/[0.06]`,outline:`border border-[var(--app-border)] bg-transparent text-[var(--app-text)] hover:border-[var(--app-border-strong)] hover:bg-white/[0.04]`,link:`text-[var(--app-accent-strong)] underline-offset-4 hover:underline`},size:{default:`px-3.5 py-1.5`,sm:`px-3 py-1.5 text-xs`,lg:`px-5 py-2.5`,icon:`h-8 w-8`}},defaultVariants:{variant:`default`,size:`default`}}),S=a.forwardRef(({className:e,variant:t,size:n,asChild:i=!1,...a},o)=>(0,l.jsx)(i?h:`button`,{className:r(x({variant:t,size:n,className:e})),ref:o,...a}));S.displayName=`Button`;export{c as i,x as n,s as r,S as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{mt as t}from"./vendor-icons-U4igmrUq.js";import{t as n}from"./vendor-react-Bp_V-Hsf.js";import{n as r}from"./dist-CgGno8kE.js";var i=e(t(),1),a=n(),o=i.forwardRef(({className:e,padding:t=!0,...n},i)=>(0,a.jsx)(`div`,{ref:i,className:r(`surface-panel rounded-xl text-[var(--app-text)]`,t&&`p-4`,e),...n}));o.displayName=`Card`;var s=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{ref:n,className:r(`mb-4 flex items-start justify-between gap-3`,e),...t}));s.displayName=`CardHeader`;var c=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`h3`,{ref:n,className:r(`text-base font-semibold text-[var(--app-text)]`,e),...t}));c.displayName=`CardTitle`;var l=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`p`,{ref:n,className:r(`text-sm leading-6 text-[var(--app-text-muted)]`,e),...t}));l.displayName=`CardDescription`;var u=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{ref:n,className:r(`space-y-3`,e),...t}));u.displayName=`CardContent`;var d=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{ref:n,className:r(`flex items-center pt-3`,e),...t}));d.displayName=`CardFooter`;export{c as a,s as i,u as n,l as r,o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{$ as t,T as n,V as r,dt as i,j as a,mt as o}from"./vendor-icons-U4igmrUq.js";import{f as s,r as c,t as l}from"./vendor-react-Bp_V-Hsf.js";import{t as u}from"./api-BkdixMz9.js";import{t as d}from"./index-C-e-qpXc.js";import{a as f,i as p,t as m}from"./Card-cy-gHU0O.js";import{t as h}from"./PageHeader-BgNbz3JV.js";import{t as g}from"./SectionHeader-CwX6m1f6.js";import{n as _}from"./format-BUYXZqDw.js";var v=e(o(),1),y=l();function b(){let{id:e}=s(),[o,l]=(0,v.useState)(null),[b,S]=(0,v.useState)([]),[C,w]=(0,v.useState)([]),[T,E]=(0,v.useState)(null);if((0,v.useEffect)(()=>{e&&((async()=>{try{l((await u(`/channels/${e}`)).channel),E(null)}catch(e){E(e instanceof Error?e.message:`Failed to load channel`)}})(),u(`/delivery-rules`).then(t=>S(t.filter(t=>t.target.type===`channel`&&t.target.channelId===e))).catch(()=>S([])),u(`/delivery-rules`).then(async t=>{let n=t.filter(t=>t.target.type===`channel`&&t.target.channelId===e),r=[];for(let e of n.slice(0,3))try{let t=await u(`/delivery-rules/${e.id}/log`);r.push(...t.log??[])}catch{}r.sort((e,t)=>t.createdAt-e.createdAt),w(r.slice(0,20))}).catch(()=>w([])))},[e]),T)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/channels`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(i,{size:14}),` Back to Channels`]}),(0,y.jsx)(m,{className:`text-center text-[var(--app-danger)]`,children:T})]});if(!o)return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(c,{to:`/channels`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(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={...o.config};for(let e of[`botToken`,`apiKey`,`secret`,`password`,`token`])e in k&&(k[e]=`********`);return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsxs)(c,{to:`/channels`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,y.jsx)(i,{size:14}),` Back to Channels`]}),(0,y.jsx)(h,{eyebrow:`Channel`,title:o.name,compact:!0,description:`Connectivity, delivery policy, and recent outbound activity.`,metrics:[{label:`Status`,value:(0,y.jsx)(d,{variant:D(o.status),children:o.status})},{label:`Platform`,value:O(o.platform)},{label:`Enabled`,value:o.enabled?`Yes`:`No`},{label:`Messages`,value:o.messageCount}]}),(0,y.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Channel ID`}),(0,y.jsx)(`p`,{className:`mt-2 truncate font-mono text-sm text-[var(--app-text)]`,children:o.id})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Linked role`}),(0,y.jsx)(`p`,{className:`mt-2 text-sm font-medium text-[var(--app-text)]`,children:o.linkedRoleId?`${o.linkedRoleId.slice(0,8)}...`:`None`})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Delivery rules`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:b.length})]}),(0,y.jsxs)(m,{className:`surface-panel-muted`,children:[(0,y.jsx)(`p`,{className:`text-section-label`,children:`Recent delivery events`}),(0,y.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:C.length})]})]}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,y.jsx)(x,{icon:t,label:`Created`,value:_(o.createdAt),mono:!0}),(0,y.jsx)(x,{icon:a,label:`Messages`,value:String(o.messageCount),mono:!0}),o.lastMessageAt&&(0,y.jsx)(x,{icon:t,label:`Last Message`,value:_(o.lastMessageAt),mono:!0}),o.linkedRoleId&&(0,y.jsx)(x,{icon:n,label:`Linked Role`,value:o.linkedRoleId.slice(0,8)+`...`,mono:!0})]}),(0,y.jsx)(g,{title:`Configuration`,compact:!0,description:`Raw config stays available below, but status and traffic stay first.`}),(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(f,{children:`Configuration`})}),Object.keys(k).length>0&&(0,y.jsx)(`div`,{className:`mb-4 grid gap-2 sm:grid-cols-2 lg:grid-cols-3`,children:Object.entries(k).slice(0,6).map(([e,t])=>(0,y.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,y.jsx)(`p`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:e}),(0,y.jsx)(`p`,{className:`mt-1 truncate text-sm text-[var(--app-text)]`,children:String(t)})]},e))}),(0,y.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap rounded-md bg-[var(--app-panel-elevated)] p-3 font-mono text-xs text-[var(--app-text)]`,children:JSON.stringify(k,null,2)})]}),(0,y.jsx)(g,{title:`Delivery Activity`,compact:!0,description:`Rules and log entries stay grouped as one operational block.`}),b.length>0&&(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,y.jsx)(r,{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)(a,{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};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{E as t,O as n,S as r,T as i,c as a,j as o,mt as s,n as c,w as l}from"./vendor-icons-U4igmrUq.js";import{t as u}from"./vendor-react-Bp_V-Hsf.js";import{t as d}from"./Button-fLMsJd5o.js";import{t as f}from"./api-BkdixMz9.js";import{t as p}from"./index-C-e-qpXc.js";import{a as m,i as h,t as g}from"./Card-cy-gHU0O.js";import{t as _}from"./PageHeader-BgNbz3JV.js";import{t as v}from"./SectionHeader-CwX6m1f6.js";import{t as y}from"./EmptyState-C5kVDHc7.js";import{t as b}from"./ui-CerQw0jA.js";var x=e(s(),1),S=u(),C=[`telegram`,`slack`,`discord`,`openclaw`,`wechat`,`whatsapp`,`email`],w={telegram:`{
|
|
2
|
+
"botToken": ""
|
|
3
|
+
}`,slack:`{
|
|
4
|
+
"botToken": "",
|
|
5
|
+
"signingSecret": ""
|
|
6
|
+
}`,discord:`{
|
|
7
|
+
"botToken": ""
|
|
8
|
+
}`,openclaw:`{
|
|
9
|
+
"gatewayUrl": "ws://127.0.0.1:18789"
|
|
10
|
+
}`,wechat:`{
|
|
11
|
+
"baseUrl": "https://ilinkai.weixin.qq.com"
|
|
12
|
+
}`,whatsapp:`{}`,email:`{
|
|
13
|
+
"address": "test1@test.com"
|
|
14
|
+
}`},T=e=>{switch(e){case`connected`:return`success`;case`connecting`:return`warning`;case`degraded`:return`warning`;case`error`:return`destructive`;default:return`secondary`}};function E({initial:e,onSubmit:t,onCancel:n}){let[r,i]=(0,x.useState)(e?.name??``),[a,o]=(0,x.useState)(e?.platform??`telegram`),[s,l]=(0,x.useState)(e?.config?JSON.stringify(e.config,null,2):w[e?.platform??`telegram`]??`{}`),[u,f]=(0,x.useState)(e?.enabled??!0),[p,h]=(0,x.useState)(``);function _(e){if(e.preventDefault(),!r.trim()){h(`Name is required`);return}let n;try{n=JSON.parse(s)}catch{h(`Invalid JSON in config`);return}h(``),t({name:r.trim(),platform:a,config:n,enabled:u})}return(0,S.jsx)(g,{children:(0,S.jsxs)(`form`,{onSubmit:_,className:`space-y-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsx)(m,{className:`text-[var(--app-text)]`,children:e?`Edit Channel`:`New Channel`}),(0,S.jsx)(d,{variant:`ghost`,size:`icon`,type:`button`,onClick:n,children:(0,S.jsx)(c,{size:14})})]}),p&&(0,S.jsx)(`div`,{className:`text-xs text-[var(--app-danger)]`,children:p}),(0,S.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Name`}),(0,S.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`My Telegram Bot`,className:`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`})]}),(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`label`,{htmlFor:`channel-platform`,className:`text-xs text-[var(--app-text-muted)]`,children:`Platform`}),(0,S.jsx)(`select`,{id:`channel-platform`,value:a,onChange:t=>{o(t.target.value),e||l(w[t.target.value]??`{}`)},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`,children:C.map(e=>(0,S.jsx)(`option`,{value:e,children:e},e))})]})]}),(0,S.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,S.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Config (JSON)`}),(0,S.jsx)(`textarea`,{value:s,onChange:e=>l(e.target.value),rows:4,className:`resize-none rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 font-mono text-xs text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`input`,{type:`checkbox`,id:`ch-enabled`,checked:u,onChange:e=>f(e.target.checked),className:`rounded border-[var(--app-border)] bg-[var(--app-panel-elevated)]`}),(0,S.jsx)(`label`,{htmlFor:`ch-enabled`,className:`text-xs text-[var(--app-text-muted)]`,children:`Enabled`})]}),!e&&a===`wechat`&&(0,S.jsx)(`div`,{className:`rounded bg-[var(--app-accent-soft-bg)] border border-[var(--app-accent-soft-border)] px-3 py-2 text-xs text-[var(--app-accent)]`,children:`Creating a WeChat channel will start a QR code scan. Have your WeChat app ready.`}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(d,{type:`submit`,size:`sm`,children:e?`Save`:a===`wechat`&&!e?`Create & Connect`:`Create`}),(0,S.jsx)(d,{type:`button`,variant:`ghost`,size:`sm`,onClick:n,children:`Cancel`})]})]})})}function D({channelId:e,onClose:t}){let[n,r]=(0,x.useState)([]),[i,a]=(0,x.useState)(!0);return(0,x.useEffect)(()=>{(async()=>{try{r((await f(`/channels/${e}/messages`)).messages)}catch{}a(!1)})()},[e]),(0,S.jsxs)(g,{children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,S.jsx)(m,{children:`Channel Messages`}),(0,S.jsx)(d,{variant:`ghost`,size:`icon`,onClick:t,children:(0,S.jsx)(c,{size:14})})]}),i?(0,S.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Loading...`}):n.length===0?(0,S.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`No messages yet`}):(0,S.jsx)(`div`,{className:`max-h-64 overflow-y-auto space-y-2`,children:n.map(e=>(0,S.jsxs)(`div`,{className:`rounded bg-[var(--app-panel-elevated)]/50 px-3 py-2 text-xs`,children:[(0,S.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,S.jsx)(`span`,{className:e.role===`user`?`text-[var(--app-accent)]`:`text-[var(--app-success)]`,children:e.role}),(0,S.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:new Date(e.createdAt).toLocaleTimeString()})]}),(0,S.jsx)(`div`,{className:`mt-1 text-[var(--app-text)]`,children:e.content})]},e.id))})]})}function O(e,t){return e instanceof Error&&e.message.trim().length>0?e.message:t}function k(){let[e,s]=(0,x.useState)([]),[c,u]=(0,x.useState)(!0),[C,w]=(0,x.useState)(null),[k,A]=(0,x.useState)(!1),[j,M]=(0,x.useState)(null),[N,P]=(0,x.useState)(null),[F,I]=(0,x.useState)(null),[L,R]=(0,x.useState)(!1);(0,x.useEffect)(()=>{z()},[]);async function z(){try{s((await f(`/channels`)).channels)}catch{}u(!1)}async function B(e){try{let t=await f(`/channels`,{method:`POST`,body:JSON.stringify(e)});w(null),A(!1),z(),e.platform===`wechat`&&t.channel?.id&&H(t.channel.id)}catch(e){w({type:`error`,text:O(e,`Failed to create channel`)})}}async function V(e){if(j)try{await f(`/channels/${j.id}`,{method:`PATCH`,body:JSON.stringify(e)}),w(null),M(null),z()}catch(e){w({type:`error`,text:O(e,`Failed to update channel`)})}}async function H(t){if(w(null),e.find(e=>e.id===t)?.platform===`wechat`)try{let e=await f(`/channels/${t}/wechat/qr-start`,{method:`POST`});if(e.qrcodeUrl&&e.sessionKey){I({channelId:t,qrcodeUrl:e.qrcodeUrl,sessionKey:e.sessionKey}),R(!0);try{(await f(`/channels/${t}/wechat/qr-wait`,{method:`POST`,body:JSON.stringify({sessionKey:e.sessionKey,timeoutMs:12e4})})).connected&&z()}catch(e){w({type:`error`,text:O(e,`WeChat connection timed out`)})}I(null),R(!1)}}catch(e){w({type:`error`,text:O(e,`Failed to start WeChat login`)})}else try{await f(`/channels/${t}/connect`,{method:`POST`}),z()}catch(e){w({type:`error`,text:O(e,`Failed to connect channel`)})}}async function U(e){try{await f(`/channels/${e}/disconnect`,{method:`POST`}),z()}catch{}}async function W(e){try{await f(`/channels/${e}`,{method:`DELETE`}),s(t=>t.filter(t=>t.id!==e))}catch{}}return c?(0,S.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,S.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):(0,S.jsxs)(`div`,{className:`space-y-6`,children:[(0,S.jsx)(_,{eyebrow:`Delivery`,title:`Channels`,description:`Connection status, volume, and edit access for every delivery endpoint.`,metrics:[{label:`Connected`,value:e.filter(e=>e.status===`connected`).length},{label:`Enabled`,value:e.filter(e=>e.enabled).length},{label:`Messages`,value:e.reduce((e,t)=>e+t.messageCount,0)}],compact:!0,actions:(0,S.jsxs)(d,{size:`sm`,onClick:()=>{A(!0),M(null)},children:[(0,S.jsx)(l,{size:14}),`Add Channel`]})}),C&&(0,S.jsx)(`div`,{className:`rounded-md border px-3 py-2 text-sm ${C.type===`error`?`border-[var(--app-danger-soft-border)] bg-[var(--app-danger-soft-bg)] text-[var(--app-danger-soft-text)]`:`border-[var(--app-success-soft-border)] bg-[var(--app-success-soft-bg)] text-[var(--app-success-soft-text)]`}`,children:C.text}),(0,S.jsx)(v,{title:`Endpoints`,description:`Connect, disconnect, edit, inspect messages, or add a new endpoint.`,compact:!0,action:(0,S.jsxs)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[e.length,` channel`,e.length===1?``:`s`]})}),k&&!j&&(0,S.jsx)(E,{onSubmit:B,onCancel:()=>A(!1)}),j&&(0,S.jsx)(E,{initial:j,onSubmit:V,onCancel:()=>M(null)}),N&&(0,S.jsx)(D,{channelId:N,onClose:()=>P(null)}),F&&(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,S.jsxs)(g,{className:`max-w-sm text-center`,children:[(0,S.jsx)(m,{className:`mb-3 text-[var(--app-text)]`,children:`Scan QR Code with WeChat`}),(0,S.jsx)(`img`,{src:`https://api.qrserver.com/v1/create-qr-code/?size=256x256&data=${encodeURIComponent(F.qrcodeUrl)}`,alt:`WeChat QR Code`,className:`mx-auto h-64 w-64 rounded bg-white p-2`}),(0,S.jsx)(`p`,{className:`mt-3 text-xs text-[var(--app-text-muted)]`,children:L?`Waiting for scan...`:`Open WeChat and scan the QR code`}),(0,S.jsx)(`a`,{href:F.qrcodeUrl,target:`_blank`,rel:`noopener noreferrer`,className:`mt-1 block text-[10px] text-[var(--app-accent)] hover:text-[var(--app-accent)] truncate max-w-[280px] mx-auto`,children:F.qrcodeUrl}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,className:`mt-3`,onClick:()=>{I(null),R(!1)},children:`Cancel`})]})}),e.length===0&&!k?(0,S.jsx)(g,{children:(0,S.jsx)(y,{icon:(0,S.jsx)(r,{size:b.hero}),title:`No channels`,description:`Add a channel to connect Adam to messaging platforms like Telegram, Slack, or Discord.`})}):(0,S.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 lg:grid-cols-3`,children:e.map(e=>(0,S.jsxs)(g,{children:[(0,S.jsxs)(h,{children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(r,{size:16,className:`text-[var(--app-text-muted)]`}),(0,S.jsx)(m,{className:`text-[var(--app-text)]`,children:e.name})]}),(0,S.jsx)(p,{variant:T(e.status),children:e.status})]}),(0,S.jsxs)(`div`,{className:`space-y-2 text-xs text-[var(--app-text-muted)]`,children:[(0,S.jsxs)(`div`,{className:`flex justify-between`,children:[(0,S.jsx)(`span`,{children:`Platform`}),(0,S.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.platform})]}),(0,S.jsxs)(`div`,{className:`flex justify-between`,children:[(0,S.jsx)(`span`,{children:`Messages`}),(0,S.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.messageCount})]}),(0,S.jsxs)(`div`,{className:`flex justify-between`,children:[(0,S.jsx)(`span`,{children:`Enabled`}),(0,S.jsx)(`span`,{className:e.enabled?`text-[var(--app-success)]`:`text-[var(--app-text-subtle)]`,children:e.enabled?`Yes`:`No`})]})]}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 border-t border-[var(--app-border)] pt-3`,children:[e.status===`connected`?(0,S.jsxs)(d,{variant:`secondary`,size:`sm`,onClick:()=>void U(e.id),children:[(0,S.jsx)(t,{size:12}),` Disconnect`]}):(0,S.jsxs)(d,{variant:`secondary`,size:`sm`,onClick:()=>void H(e.id),children:[(0,S.jsx)(i,{size:12}),` Connect`]}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>{M(e),A(!1)},children:(0,S.jsx)(n,{size:12})}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>P(e.id),children:(0,S.jsx)(o,{size:12})}),(0,S.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>void W(e.id),children:(0,S.jsx)(a,{size:12})})]})]},e.id))})]})}export{k as Channels};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/api-BkdixMz9.js","assets/rolldown-runtime-Dw2cE7zH.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{B as t,M as n,N as r,Q as i,W as a,_ as o,at as s,b as c,c as l,et as u,ft as d,it as f,m as p,mt as m,n as h,ot as g,p as _,st as v,w as y}from"./vendor-icons-U4igmrUq.js";import{p as b,t as x}from"./vendor-react-Bp_V-Hsf.js";import{r as S}from"./dist-CgGno8kE.js";import{t as C}from"./Button-fLMsJd5o.js";import{n as w}from"./vendor-state-Zjl_6-V3.js";import{t as T}from"./api-BkdixMz9.js";import{t as E}from"./PageHeader-BgNbz3JV.js";import{a as D}from"./format-BUYXZqDw.js";import{t as O}from"./EmptyState-C5kVDHc7.js";import{t as k}from"./ui-CerQw0jA.js";import{t as A}from"./useIsMobileLayout-Blj4Mk4K.js";var j=e(m(),1),M=w((e,t)=>({sessions:[],activeSessionId:null,messages:[],loading:!1,sending:!1,_chatWs:null,_chatWsReconnectDelay:1e3,fetchSessions:async()=>{try{e({sessions:(await T(`/chat/sessions`)).sessions})}catch{}},fetchMessages:async t=>{e({loading:!0});try{e({messages:(await T(`/chat/sessions/${t}`)).messages,loading:!1})}catch{e({messages:[],loading:!1})}},sendMessage:async n=>{if(t().sending)return null;e({sending:!0});try{let r=await T(`/chat/messages`,{method:`POST`,body:JSON.stringify({content:n,source:{type:`web`},sessionId:t().activeSessionId??void 0})});return e({activeSessionId:r.sessionId,sending:!1}),t().fetchSessions(),r}catch{return e({sending:!1}),null}},sendApprovalResponse:async(n,r)=>{if(t().sending)return null;e({sending:!0});try{let i=await T(`/chat/messages`,{method:`POST`,body:JSON.stringify({content:r,source:{type:`web`},sessionId:t().activeSessionId??void 0,buttonPayload:{promptId:n,value:r}})});return e({activeSessionId:i.sessionId,sending:!1}),t().fetchSessions(),i}catch{return e({sending:!1}),null}},createSession:async()=>{try{let t=await T(`/chat/sessions`,{method:`POST`,body:JSON.stringify({source:{type:`web`}})});return e(e=>({sessions:[t.session,...e.sessions],activeSessionId:t.session.id,messages:[]})),t.session}catch{return null}},archiveSession:async t=>{try{await T(`/chat/sessions/${t}/archive`,{method:`POST`}),e(e=>({sessions:e.sessions.map(e=>e.id===t?{...e,status:`archived`}:e),activeSessionId:e.activeSessionId===t?null:e.activeSessionId,messages:e.activeSessionId===t?[]:e.messages}))}catch{}},restoreSession:async t=>{try{await T(`/chat/sessions/${t}/restore`,{method:`POST`}),e(e=>({sessions:e.sessions.map(e=>e.id===t?{...e,status:`active`}:e)}))}catch{}},deleteSession:async t=>{try{await T(`/chat/sessions/${t}`,{method:`DELETE`}),e(e=>({sessions:e.sessions.filter(e=>e.id!==t),activeSessionId:e.activeSessionId===t?null:e.activeSessionId,messages:e.activeSessionId===t?[]:e.messages}))}catch{}},setActiveSession:n=>{e({activeSessionId:n,messages:[]}),n&&t().fetchMessages(n)},connectChatStream:()=>{let n=t()._chatWs;if(n&&n.readyState<=1)return;let r=window.location.protocol===`https:`?`wss:`:`ws:`,i=localStorage.getItem(`adam_api_key`),a=new URL(`${r}//${window.location.host}/chat/stream`);i&&a.searchParams.set(`api_key`,i);let o=new WebSocket(a.toString()),s=!1;o.onopen=()=>{s=!0,e({_chatWs:o,_chatWsReconnectDelay:1e3})},o.onclose=async()=>{if(!s&&i){let{verifyApiKey:e,clearStoredApiKey:t,redirectToLogin:n}=await b(async()=>{let{verifyApiKey:e,clearStoredApiKey:t,redirectToLogin:n}=await import(`./api-BkdixMz9.js`).then(e=>e.n);return{verifyApiKey:e,clearStoredApiKey:t,redirectToLogin:n}},__vite__mapDeps([0,1]));if(!await e(i).catch(()=>!0)){t(),n();return}}let n=t()._chatWsReconnectDelay;e({_chatWs:null,_chatWsReconnectDelay:Math.min(n*2,1e4)}),setTimeout(()=>{t().connectChatStream()},n)},o.onerror=()=>{o.close()},o.onmessage=n=>{try{let r=JSON.parse(n.data);if(r.type===`chat_message`&&r.message){let n=r.message,{activeSessionId:i,messages:a}=t();if(n.sessionId!==i||a.some(e=>e.id===n.id))return;e(e=>({messages:[...e.messages,n]}))}else r.type===`session_created`&&t().fetchSessions()}catch{}},e({_chatWs:o})},disconnectChatStream:()=>{let n=t()._chatWs;n&&(n.onclose=null,n.onerror=null,n.onmessage=null,n.close(),e({_chatWs:null}))}})),N=x();function P({message:e}){return(0,N.jsxs)(`div`,{className:`chat-status-report flex items-center gap-2 px-3 py-1 text-xs text-[var(--app-text-subtle)] opacity-60`,"data-testid":`status-report-line`,children:[(0,N.jsx)(`span`,{className:`select-none`,children:`›`}),(0,N.jsx)(`span`,{className:`flex-1 truncate`,children:e.content}),(0,N.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:D(typeof e.createdAt==`number`?e.createdAt:new Date(e.createdAt).getTime())})]})}function F({messages:e}){let[t,n]=(0,j.useState)(!1),r=e.length;return(0,N.jsxs)(`div`,{className:`chat-status-report-group`,"data-testid":`status-report-group`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:S(`flex w-full items-center gap-2 rounded border border-[var(--app-border)] bg-white/[0.02] px-3 py-1.5 text-xs text-[var(--app-text-muted)] transition-colors hover:border-[var(--app-border-strong)]`),"aria-expanded":t,children:[(0,N.jsx)(s,{size:12,className:S(`transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),(0,N.jsxs)(`span`,{children:[r,` 步进展`]})]}),t?(0,N.jsx)(`div`,{className:`mt-1 space-y-0.5 border-l border-[var(--app-border)] pl-3`,children:e.map(e=>(0,N.jsx)(P,{message:e},e.id))}):null]})}var I={report:a,media:t,data:i,scratch:l,archive:d};function L(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function R({attachment:e,onPreview:t}){let n=e.purpose?I[e.purpose]:a;return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>t?.(e),className:S(`inline-flex items-center gap-2 rounded-md border border-[var(--app-border)] bg-white/[0.04] px-3 py-1.5 text-xs text-[var(--app-text-muted)] transition-colors hover:border-[var(--app-border-strong)] hover:text-[var(--app-text)]`),title:`${e.filename} · ${L(e.size)} · ${e.mimeType}${e.purpose?` · purpose=${e.purpose}`:``}`,"data-testid":`attachment-chip`,"data-purpose":e.purpose??`unknown`,children:[(0,N.jsx)(n,{size:14,"aria-hidden":`true`}),(0,N.jsx)(`span`,{className:`font-medium text-[var(--app-text)]`,children:e.filename}),(0,N.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`· `,L(e.size)]})]})}var z=[`var(--app-log-adam)`,`var(--app-log-manager)`,`var(--app-log-scheduler)`,`var(--app-log-ws)`,`var(--app-log-store)`,`var(--app-log-embedding)`];function B(e){if(!e)return`var(--app-text-subtle)`;let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return z[Math.abs(t)%z.length]}function V(e){return e?`T-${e.replace(/-/g,``).slice(0,8).toUpperCase()}`:``}function ee(e,t=3){let n=[],r=[],i=()=>{if(r.length!==0){if(r.length>=t)n.push({type:`status-group`,messages:r});else for(let e of r)n.push({type:`single`,message:e});r=[]}};for(let t of e)t.kind===`status_report`?r.push(t):(i(),n.push({type:`single`,message:t}));return i(),n}function te(e){let t=[],n=new Map,r=[];for(let i of e){if(!i.threadRoot){t.push(i);continue}n.has(i.threadRoot)||(n.set(i.threadRoot,[]),r.push(i.threadRoot)),n.get(i.threadRoot).push(i)}let i=[{threadRoot:null,messages:t}];for(let e of r)i.push({threadRoot:e,messages:n.get(e)});return i}function H({message:e}){let t=B(e.roleId),n=V(e.taskId),r=e.mirroredToTargets&&e.mirroredToTargets.length>0;return(0,N.jsxs)(`div`,{className:S(`chat-result-delivery surface-panel-elevated rounded-xl px-4 py-3 text-sm leading-7`),"data-testid":`result-delivery-card`,"data-task-short-id":n,children:[(0,N.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-[11px] uppercase tracking-[0.16em]`,children:[(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-[10px] font-semibold`,style:{borderColor:t,color:t},"data-testid":`role-pill`,children:[(0,N.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full`,style:{background:t},"aria-hidden":`true`}),n||`Adam`]}),(0,N.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:D(typeof e.createdAt==`number`?e.createdAt:new Date(e.createdAt).getTime())})]}),(0,N.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-[var(--app-text)]`,children:e.content}),e.attachments&&e.attachments.length>0?(0,N.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2 border-t border-[var(--app-border)] pt-3`,children:e.attachments.map(e=>(0,N.jsx)(R,{attachment:e},e.artifactId))}):null,r?(0,N.jsxs)(`div`,{className:`chat-mirror-suffix mt-2 text-[11px] italic text-[var(--app-text-subtle)]`,"data-testid":`mirror-suffix`,children:[`(also delivered to:`,` `,e.mirroredToTargets.map(e=>e.channelId??e.sessionId??`unknown`).join(`, `),` `,`@`,` `,new Date(typeof e.createdAt==`number`?e.createdAt:new Date(e.createdAt).getTime()).toLocaleTimeString([],{hour12:!1,hour:`2-digit`,minute:`2-digit`}),`)`]}):null]})}function U({message:e}){let t=M(e=>e.sendApprovalResponse),n=M(e=>e.messages),[r,i]=(0,j.useState)(`pending`),[a,s]=(0,j.useState)(``),[c,l]=(0,j.useState)(null),[u,d]=(0,j.useState)(``),[p,m]=(0,j.useState)(``),g=e.approvalShape??`yes_no`,_=e.promptId??``;(0,j.useEffect)(()=>{if(r!==`submitted`||!_||c===null)return;let e=n.find(e=>e.kind!==`system_note`||e.createdAt<c||!e.content.includes(`#${_}`)?!1:/过期|已处理|未找到/.test(e.content));e&&(i(`stale`),d(e.content))},[r,n,_,c]);let y=async e=>{if(!_||r!==`pending`)return;let n=Date.now();await t(_,e)&&(i(`submitted`),s(e),l(n))};if(r===`stale`)return(0,N.jsxs)(`div`,{className:`chat-approval-card chat-approval-stale surface-panel rounded-xl px-4 py-3 text-sm opacity-70`,"data-testid":`approval-card`,"data-state":`stale`,children:[(0,N.jsxs)(`div`,{className:`mb-1 text-[11px] uppercase tracking-[0.16em] text-[var(--app-kicker)]`,children:[`approval · #`,_]}),(0,N.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e.content}),(0,N.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-md bg-[var(--app-warning-soft-bg)] px-2 py-1 text-xs font-medium text-[var(--app-warning-soft-text)]`,children:[(0,N.jsx)(f,{size:12,"aria-hidden":`true`}),u]})]});if(r===`submitted`){let t=c?new Date(c).toLocaleTimeString([],{hour12:!1,hour:`2-digit`,minute:`2-digit`}):``;return(0,N.jsxs)(`div`,{className:`chat-approval-card chat-approval-resolved surface-panel rounded-xl px-4 py-3 text-sm opacity-60`,"data-testid":`approval-card`,"data-state":`submitted`,children:[(0,N.jsxs)(`div`,{className:`mb-1 text-[11px] uppercase tracking-[0.16em] text-[var(--app-kicker)]`,children:[`approval · #`,_]}),(0,N.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e.content}),(0,N.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-md bg-[var(--app-success-soft-bg)] px-2 py-1 text-xs font-medium text-[var(--app-success-soft-text)]`,children:[(0,N.jsx)(v,{size:12,"aria-hidden":`true`}),`已提交「`,a,`」 `,t]})]})}return(0,N.jsxs)(`div`,{className:S(`chat-approval-card surface-panel-elevated rounded-xl px-4 py-3 text-sm`),"data-testid":`approval-card`,"data-state":`pending`,"data-shape":g,children:[(0,N.jsxs)(`div`,{className:`mb-1 text-[11px] uppercase tracking-[0.16em] text-[var(--app-kicker)]`,children:[`approval · #`,_]}),(0,N.jsx)(`div`,{className:`mb-3 text-[var(--app-text)]`,children:e.content}),g===`yes_no`?(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsxs)(C,{size:`sm`,onClick:()=>void y(`批准`),"aria-label":`Approve`,"data-testid":`approve-button`,children:[(0,N.jsx)(v,{size:14,"aria-hidden":`true`}),`批准`]}),(0,N.jsxs)(C,{size:`sm`,variant:`secondary`,onClick:()=>void y(`拒绝`),"aria-label":`Reject`,"data-testid":`reject-button`,children:[(0,N.jsx)(h,{size:14,"aria-hidden":`true`}),`拒绝`]})]}):null,g===`choose_one`?(0,N.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,N.jsx)(C,{size:`sm`,onClick:()=>void y(`批准`),"data-testid":`approve-button`,children:`批准`}),(0,N.jsx)(C,{size:`sm`,variant:`secondary`,onClick:()=>void y(`拒绝`),"data-testid":`reject-button`,children:`拒绝`})]}):null,g===`free_input`?(0,N.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,N.jsx)(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),className:`flex-1 rounded-lg border border-[var(--app-border)] bg-white/[0.04] px-3 py-2 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-border-strong)] focus:outline-none focus:ring-1 focus:ring-[var(--app-accent)]`,placeholder:`输入回复...`,"data-testid":`free-input`}),(0,N.jsxs)(C,{size:`sm`,onClick:()=>void y(p.trim()),disabled:!p.trim(),"data-testid":`submit-button`,children:[(0,N.jsx)(o,{size:14,"aria-hidden":`true`}),`提交`]})]}):null,(0,N.jsxs)(`div`,{className:`mt-2 text-[11px] text-[var(--app-text-subtle)]`,children:[`看不到按钮?回 #`,_,` 表态。`]})]})}function W({message:e}){return(0,N.jsxs)(`div`,{className:`chat-system-note flex items-center gap-2 rounded border-l-2 border-[var(--app-text-subtle)] bg-white/[0.02] px-3 py-1.5 text-xs italic text-[var(--app-text-subtle)]`,"data-testid":`system-note`,role:`note`,children:[(0,N.jsx)(`span`,{className:`select-none`,children:`●`}),(0,N.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:e.content})]})}function G({message:e}){switch(e.kind??(e.role===`user`?`user_message`:`assistant_text`)){case`status_report`:return(0,N.jsx)(P,{message:e});case`result_delivery`:return(0,N.jsx)(H,{message:e});case`approval_prompt`:return(0,N.jsx)(U,{message:e});case`system_note`:return(0,N.jsx)(W,{message:e});default:return(0,N.jsx)(K,{message:e})}}function K({message:e}){let t=e.role===`user`,n=t?`You`:e.taskId?`Adam · execution`:`Adam`;return(0,N.jsx)(`div`,{className:S(`flex`,t?`justify-end`:`justify-start`),children:(0,N.jsxs)(`div`,{className:S(`max-w-[85%] rounded-lg px-4 py-3 text-sm leading-7 shadow-[var(--app-shadow-md)]`,t?`surface-accent text-white`:`surface-panel text-[var(--app-text)]`),children:[(0,N.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-[11px] uppercase tracking-[0.16em]`,children:[(0,N.jsx)(`span`,{className:t?`text-white/70`:`text-[var(--app-kicker)]`,children:n}),(0,N.jsx)(`span`,{className:t?`text-white/45`:`text-[var(--app-text-subtle)]`,children:D(typeof e.createdAt==`number`?e.createdAt:new Date(e.createdAt).getTime())})]}),(0,N.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:e.content})]})})}function q({onSend:e,disabled:t,placeholder:n=`Type a message...`,starterActions:r=[],showStarterActions:i=!0,compact:a=!1}){let[s,c]=(0,j.useState)(``),l=(0,j.useRef)(null),u=()=>{let n=s.trim();!n||t||(e(n),c(``),l.current&&(l.current.style.height=`auto`))},d=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),u())},f=()=>{let e=l.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,120)}px`)};return(0,N.jsxs)(`div`,{className:a?`rounded-xl border border-[var(--app-border)] bg-white/[0.03] p-3`:`surface-panel-elevated rounded-xl p-3`,children:[i&&r.length>0?(0,N.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-2`,children:r.map(e=>(0,N.jsx)(`button`,{type:`button`,onClick:()=>{c(e.value),requestAnimationFrame(()=>l.current?.focus())},className:`rounded-full border border-[var(--app-border)] bg-white/[0.04] px-3 py-1.5 text-xs font-medium text-[var(--app-text-muted)] transition-colors hover:border-[var(--app-border-strong)] hover:text-[var(--app-text)]`,children:e.label},e.label))}):null,(0,N.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,N.jsx)(`textarea`,{ref:l,value:s,onChange:e=>{c(e.target.value),f()},onKeyDown:d,placeholder:n,disabled:t,rows:1,className:`min-h-12 flex-1 resize-none rounded-lg border border-[var(--app-border)] bg-white/[0.04] px-4 py-3 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-border-strong)] focus:outline-none focus:ring-1 focus:ring-[var(--app-accent)] disabled:opacity-50`}),(0,N.jsxs)(C,{onClick:u,disabled:t||!s.trim(),size:`default`,"aria-label":`Send message`,children:[(0,N.jsx)(o,{size:16}),`Send`]})]}),(0,N.jsx)(`div`,{className:`mt-2 text-xs text-[var(--app-text-subtle)]`,children:`Enter to send; Shift+Enter for a new line.`})]})}function J({session:e,isActive:t,onSelect:n,onArchive:r,onRestore:i,onDelete:a}){let o=e.status===`archived`,s=(e,t)=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),t())};return(0,N.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},className:S(`group flex w-full flex-col gap-1 rounded-lg border px-3 py-3 text-left transition-colors`,t?`border-[var(--app-border-strong)] bg-white/[0.08] text-[var(--app-text)]`:`border-transparent text-[var(--app-text-muted)] hover:border-[var(--app-border)] hover:bg-white/[0.04] hover:text-[var(--app-text)]`,o&&`opacity-60`),"aria-label":e.title??e.id.slice(0,8),children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.title??e.id.slice(0,8)}),(0,N.jsxs)(`div`,{className:S(`flex gap-0.5 transition-opacity`,t?`opacity-100`:`opacity-100 lg:opacity-0 lg:group-hover:opacity-100 lg:group-focus-within:opacity-100`),children:[o?(0,N.jsx)(C,{variant:`ghost`,size:`icon`,className:`h-6 w-6 text-[var(--app-text-subtle)] hover:text-[var(--app-success)]`,onClick:e=>{e.stopPropagation(),i()},onKeyDown:e=>s(e,i),title:`Restore session`,"aria-label":`Restore session`,children:(0,N.jsx)(c,{size:k.xs})}):(0,N.jsx)(C,{variant:`ghost`,size:`icon`,className:`h-6 w-6 text-[var(--app-text-subtle)] hover:text-[var(--app-warning)]`,onClick:e=>{e.stopPropagation(),r()},onKeyDown:e=>s(e,r),title:`Archive session`,"aria-label":`Archive session`,children:(0,N.jsx)(d,{size:k.xs})}),(0,N.jsx)(C,{variant:`ghost`,size:`icon`,className:`h-6 w-6 text-[var(--app-text-subtle)] hover:text-[var(--app-danger)]`,onClick:e=>{e.stopPropagation(),a()},onKeyDown:e=>s(e,a),title:`Delete session`,"aria-label":`Delete session`,children:(0,N.jsx)(l,{size:k.xs})})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-[var(--app-text-subtle)]`,children:[(0,N.jsxs)(`span`,{children:[e.messageCount,` turns`]}),(0,N.jsx)(`span`,{children:D(e.lastActiveAt)}),o&&(0,N.jsx)(`span`,{className:`rounded-full border border-[var(--app-border)] bg-white/[0.04] px-1.5 py-0.5 text-[9px] uppercase tracking-[0.16em]`,children:`archived`})]})]})}function Y({sessions:e,activeSessionId:t,onSelectSession:n,onNewSession:r,onArchiveSession:i,onRestoreSession:a,onDeleteSession:o,onClose:s}){let{recentSessions:c,earlierSessions:l,archivedSessions:u,activeSessions:d}=(0,j.useMemo)(()=>{let t=Date.now(),n=1440*60*1e3,r=e.filter(e=>e.status===`active`);return{recentSessions:r.filter(e=>t-e.lastActiveAt<n),earlierSessions:r.filter(e=>t-e.lastActiveAt>=n),archivedSessions:e.filter(e=>e.status===`archived`),activeSessions:r}},[e]);return(0,N.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--app-border)] px-4 py-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`span`,{className:`text-section-label`,children:`Sessions`}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-subtle)]`,children:`Switch context or reopen archived work.`})]}),(0,N.jsxs)(C,{variant:`ghost`,size:`sm`,onClick:r,"aria-label":`New session`,children:[(0,N.jsx)(y,{size:14}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`New`})]})]}),(0,N.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-2 py-2`,children:[d.length===0&&u.length===0&&(0,N.jsx)(`div`,{className:`px-2 py-6 text-center text-xs text-[var(--app-text-subtle)]`,children:`No sessions yet`}),c.length>0&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{className:`mb-2 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-[var(--app-text-subtle)]`,children:`Today`}),(0,N.jsx)(`div`,{className:`space-y-1`,children:c.map(e=>(0,N.jsx)(J,{session:e,isActive:e.id===t,onSelect:()=>{n(e.id),s?.()},onArchive:()=>i(e.id),onRestore:()=>a(e.id),onDelete:()=>o(e.id)},e.id))})]}),l.length>0&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{className:`mb-2 mt-4 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-[var(--app-text-subtle)]`,children:`Earlier`}),(0,N.jsx)(`div`,{className:`space-y-1`,children:l.map(e=>(0,N.jsx)(J,{session:e,isActive:e.id===t,onSelect:()=>{n(e.id),s?.()},onArchive:()=>i(e.id),onRestore:()=>a(e.id),onDelete:()=>o(e.id)},e.id))})]}),u.length>0&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{className:`mb-2 mt-4 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-[var(--app-text-subtle)]`,children:`Archived`}),(0,N.jsx)(`div`,{className:`space-y-1`,children:u.map(e=>(0,N.jsx)(J,{session:e,isActive:e.id===t,onSelect:()=>{n(e.id),s?.()},onArchive:()=>i(e.id),onRestore:()=>a(e.id),onDelete:()=>o(e.id)},e.id))})]})]})]})}var X=(e,t)=>`chat:thread-fold:${e}:${t}`;function Z(e){let t=e.some(e=>e.kind===`result_delivery`),n=e.some(e=>e.kind===`approval_prompt`);return!t||n}function ne({sessionId:e,threadRoot:t,messages:n,children:r}){let i=Z(n),a=X(e,t),[o,s]=(0,j.useState)(()=>{if(typeof window>`u`)return!i;let e=window.localStorage.getItem(a);return e===`1`?!0:e===`0`?!1:!i});(0,j.useEffect)(()=>{try{window.localStorage.setItem(a,o?`1`:`0`)}catch{}},[o,a]);let c=n.find(e=>e.kind===`user_message`)??n[0],l=n.find(e=>e.taskId)?.taskId,u=n.find(e=>e.roleId)?.roleId,d=B(u),f=V(l),p=(c?.content??``).slice(0,30)+((c?.content?.length??0)>30?`...`:``);return(0,N.jsxs)(`div`,{className:S(`chat-thread-container relative rounded-xl border border-[var(--app-border)] bg-white/[0.015] pl-3`),"data-testid":`thread-container`,"data-thread-root":t,"data-collapsed":o?`1`:`0`,children:[(0,N.jsx)(`div`,{className:`absolute left-0 top-0 h-full w-1 rounded-l-xl`,style:{background:d},"aria-hidden":`true`}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>s(!o),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-xs uppercase tracking-[0.16em] text-[var(--app-text-muted)] transition-colors hover:text-[var(--app-text)]`,"aria-expanded":!o,"data-testid":`thread-toggle`,children:[(0,N.jsx)(g,{size:12,className:S(`transition-transform`,o&&`-rotate-90`),"aria-hidden":`true`}),(0,N.jsx)(`span`,{style:{color:d},children:f||`Thread`}),(0,N.jsx)(`span`,{className:`text-[var(--app-text-subtle)] normal-case tracking-normal`,children:p})]}),o?null:(0,N.jsx)(`div`,{className:`space-y-2 px-3 pb-3`,children:r})]})}var Q=[{label:`Debug a failure`,value:`Review the most recent failed task and explain the next fix.`},{label:`Summarize status`,value:`Summarize the current system status, blockers, and active work.`},{label:`Plan a task`,value:`Break down the next implementation task into a concrete execution plan.`}];function re(){let e=M(e=>e.sessions),t=M(e=>e.activeSessionId),i=M(e=>e.messages),a=M(e=>e.sending),o=M(e=>e.fetchSessions),s=M(e=>e.sendMessage),c=M(e=>e.createSession),l=M(e=>e.archiveSession),d=M(e=>e.restoreSession),f=M(e=>e.deleteSession),m=M(e=>e.setActiveSession),g=M(e=>e.connectChatStream),v=M(e=>e.disconnectChatStream),b=(0,j.useRef)(null),[x,S]=(0,j.useState)(!1),w=A(1024),T=e.filter(e=>e.status===`active`),D=e.filter(e=>e.status===`archived`),P=e.length>0,I=i.length>0,L=e.find(e=>e.id===t)??null;(0,j.useEffect)(()=>{o()},[o]),(0,j.useEffect)(()=>(g(),()=>v()),[g,v]),(0,j.useEffect)(()=>{b.current?.scrollIntoView?.({behavior:`smooth`})},[i]),(0,j.useEffect)(()=>{w||S(!1)},[w]),(0,j.useEffect)(()=>{if(t||e.length===0)return;let n=[...e].filter(e=>e.status===`active`).sort((e,t)=>t.lastActiveAt-e.lastActiveAt)[0]??[...e].sort((e,t)=>t.lastActiveAt-e.lastActiveAt)[0];n&&m(n.id)},[t,e,m]);let R=async e=>{await s(e)};return(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-5`,children:[(0,N.jsx)(E,{title:`Chat`,description:P?`Resume the latest session, inspect context, and keep the composer in view.`:`Start the first session and use Adam as the working surface for review, debugging, and planning.`,compact:!0,className:`px-4 py-3 lg:px-4 lg:py-3`,actions:(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsxs)(C,{variant:`secondary`,size:`sm`,onClick:()=>void c(),children:[(0,N.jsx)(y,{size:14}),`New Session`]}),(0,N.jsxs)(C,{variant:`secondary`,size:`sm`,className:`lg:hidden`,onClick:()=>S(!0),"aria-label":`Manage sessions`,children:[(0,N.jsx)(r,{size:16}),`Sessions`]})]})}),x?(0,N.jsxs)(`div`,{className:`fixed inset-0 z-40 lg:hidden`,role:`dialog`,"aria-modal":`true`,"aria-label":`Session manager`,children:[(0,N.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:()=>S(!1)}),(0,N.jsxs)(`div`,{className:`relative z-50 h-full w-full max-w-sm border-r border-[var(--app-border)] bg-[var(--app-canvas)] shadow-[var(--app-shadow-lg)]`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--app-border)] px-4 py-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{className:`text-section-label`,children:`Sessions`}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-subtle)]`,children:`Switch, archive, restore, or start a new conversation.`})]}),(0,N.jsx)(C,{variant:`ghost`,size:`icon`,onClick:()=>S(!1),"aria-label":`Close session manager`,children:(0,N.jsx)(h,{size:16})})]}),(0,N.jsx)(Y,{sessions:e,activeSessionId:t,onSelectSession:m,onNewSession:()=>{c(),S(!1)},onArchiveSession:e=>void l(e),onRestoreSession:e=>void d(e),onDeleteSession:e=>void f(e),onClose:()=>S(!1)})]})]}):null,(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden rounded-xl border border-[var(--app-border)] bg-[color-mix(in_oklch,var(--app-canvas)_88%,transparent)] shadow-[var(--app-shadow-lg)]`,children:[(0,N.jsx)(`div`,{className:`hidden w-72 flex-shrink-0 border-r border-[var(--app-border)] bg-[color-mix(in_oklch,var(--app-canvas)_90%,transparent)] lg:block`,children:(0,N.jsx)(Y,{sessions:e,activeSessionId:t,onSelectSession:m,onNewSession:()=>void c(),onArchiveSession:e=>void l(e),onRestoreSession:e=>void d(e),onDeleteSession:e=>void f(e)})}),(0,N.jsxs)(`div`,{className:`flex flex-1 flex-col`,children:[(0,N.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 py-4 lg:px-6`,children:I?(0,N.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-3`,children:[te(i).map(e=>{if(e.threadRoot===null)return e.messages.map(e=>(0,N.jsx)(G,{message:e},e.id));let n=ee(e.messages);return(0,N.jsx)(ne,{sessionId:t??``,threadRoot:e.threadRoot,messages:e.messages,children:n.map((e,t)=>e.type===`single`?(0,N.jsx)(G,{message:e.message},e.message.id):(0,N.jsx)(F,{messages:e.messages},`status-group-${t}-${e.messages[0]?.id??``}`))},e.threadRoot)}),(0,N.jsx)(`div`,{ref:b})]}):P?(0,N.jsx)(`div`,{className:`mx-auto flex h-full w-full max-w-4xl items-start`,children:(0,N.jsxs)(`div`,{className:`surface-panel-muted flex w-full flex-col gap-4 rounded-xl p-5`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,N.jsxs)(`div`,{className:`space-y-1`,children:[(0,N.jsx)(`p`,{className:`text-kicker`,children:`Working Surface`}),(0,N.jsx)(`h2`,{className:`text-xl font-semibold text-[var(--app-text)]`,children:L?`Session ${L.title??L.id.slice(0,8)}`:`Pick a session to continue`}),(0,N.jsx)(`p`,{className:`max-w-2xl text-sm leading-6 text-[var(--app-text-muted)]`,children:L?`This session has no loaded transcript yet. Continue here or start a new thread without leaving the page.`:`Archived history exists, but no session is active. Select one from the rail or start a new conversation.`})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-[var(--app-text-subtle)]`,children:[(0,N.jsxs)(`span`,{children:[T.length,` active`]}),(0,N.jsxs)(`span`,{children:[D.length,` archived`]})]})]}),(0,N.jsx)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:Q.map(e=>(0,N.jsxs)(`button`,{type:`button`,onClick:()=>void R(e.value),className:`rounded-xl border border-[var(--app-border)] bg-white/[0.03] p-4 text-left transition-colors hover:border-[var(--app-border-strong)] hover:bg-white/[0.05]`,children:[(0,N.jsx)(`div`,{className:`text-sm font-semibold text-[var(--app-text)]`,children:e.label}),(0,N.jsx)(`div`,{className:`mt-1 text-sm leading-6 text-[var(--app-text-muted)]`,children:e.value})]},e.label))})]})}):(0,N.jsx)(O,{icon:(0,N.jsx)(n,{size:k.hero}),title:`Start a conversation with Adam`,description:`Use the starter prompts below to inspect recent work, diagnose failures, or create an execution plan.`,className:`h-full min-h-[24rem]`,action:(0,N.jsxs)(`div`,{className:`grid gap-3 text-left sm:grid-cols-3`,children:[(0,N.jsx)($,{icon:p,title:`Inspect live status`,description:`Summarize active work, risk, and recent changes.`}),(0,N.jsx)($,{icon:_,title:`Dig into a task`,description:`Review recent execution output and the next concrete step.`}),(0,N.jsx)($,{icon:u,title:`Recover context`,description:`Continue from the latest session without losing history.`})]})})}),(0,N.jsx)(`div`,{className:`mx-auto w-full max-w-4xl px-4 pb-4 lg:px-6`,children:(0,N.jsx)(q,{onSend:R,disabled:a,starterActions:Q,showStarterActions:!P&&!I,compact:P})})]})]})]})}function $({icon:e,title:t,description:n}){return(0,N.jsxs)(`div`,{className:`surface-panel-muted rounded-lg p-4`,children:[(0,N.jsx)(`div`,{className:`mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-white/[0.05] text-[var(--app-kicker)]`,children:(0,N.jsx)(e,{size:k.lg})}),(0,N.jsx)(`div`,{className:`text-sm font-semibold text-[var(--app-text)]`,children:t}),(0,N.jsx)(`div`,{className:`mt-1 text-sm leading-6 text-[var(--app-text-muted)]`,children:n})]})}export{re as Chat};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{I as t,it as n,mt as r,pt as i,rt as a,tt as o}from"./vendor-icons-U4igmrUq.js";import{r as s,t as c}from"./vendor-react-Bp_V-Hsf.js";import{t as l}from"./vendor-state-Zjl_6-V3.js";import{f as u,n as d,t as f}from"./index-C-e-qpXc.js";import{a as p,i as m,r as h,t as g}from"./Card-cy-gHU0O.js";import{t as _}from"./PageHeader-BgNbz3JV.js";import{t as v}from"./SectionHeader-CwX6m1f6.js";import{a as y,o as b,t as x}from"./format-BUYXZqDw.js";var S=e(r(),1),C=c();function w(){let{tasks:e,goals:r,roles:c,stats:w,readiness:D,executionPool:O}=u(l(e=>({tasks:e.tasks,goals:e.goals,roles:e.roles,stats:e.stats,readiness:e.readiness,executionPool:e.executionPool}))),k=u(e=>e.fetchTasks),A=u(e=>e.fetchGoals),j=u(e=>e.fetchRoles),M=u(e=>e.fetchExecutionPool);(0,S.useEffect)(()=>{k(),A(),j(),M();let e=setInterval(()=>{k(),M()},5e3);return()=>clearInterval(e)},[k,A,j,M]);let N=e.filter(e=>e.status===`running`).length,P=e.filter(e=>e.status===`queued`||e.status===`pending`).length,F=e.filter(e=>e.status===`failed`).length,I=(0,S.useMemo)(()=>[...e].sort((e,t)=>t.createdAt-e.createdAt),[e]),L=(0,S.useMemo)(()=>I.slice(0,4),[I]),R=(0,S.useMemo)(()=>I.find(e=>e.status===`failed`)||I.find(e=>e.status===`running`)||I[0],[I]),z=(0,S.useMemo)(()=>D?Object.entries(D.checks):[],[D]),B=(0,S.useMemo)(()=>z.filter(([,e])=>e).length,[z]),V=R?.roleId?c.find(e=>e.id===R.roleId)?.name??R.roleId.slice(0,8):`Unassigned`,H=R?`/tasks/${R.id}`:`/work`,U=R?`Open task`:`Open work`,W=R?R.status===`failed`?`Review the failed task before queueing more work.`:R.status===`running`?`Track this active run and its next result.`:`Use the latest completed run as the starting point for follow-up work.`:`Queue work, review recent runs, or launch an automation.`,G=R?R.status===`failed`?`surface-critical`:R.status===`running`?`surface-accent`:`surface-panel-elevated`:`surface-panel-muted`,K=G===`surface-critical`?`critical`:G===`surface-accent`?`accent`:`neutral`,q=K===`accent`||K===`critical`,J=q?`text-white`:`text-[var(--app-text)]`,Y=q?`text-white/70`:`text-[var(--app-text-subtle)]`,X=q?`text-white/76`:`text-[var(--app-text-muted)]`;return(0,C.jsxs)(`div`,{className:`space-y-6`,children:[(0,C.jsx)(_,{title:`Dashboard`,description:`Queue health, execution readiness, and the next task that needs attention.`,metrics:[{label:`Server`,value:D?.status===`ready`?`Ready`:`Attention`},{label:`Running`,value:w.activeTasks||N},{label:`Queued`,value:w.queuedTasks||P},{label:`Goals`,value:r.length},{label:`Execution Pool`,value:`${O.active}/${O.max} | ${O.queued} queued`}],compact:!0,className:`px-4 py-3 lg:px-4 lg:py-3`,actions:D?(0,C.jsx)(`span`,{role:`status`,"aria-live":`polite`,children:(0,C.jsx)(f,{variant:D.status===`ready`?`success`:`destructive`,children:D.status===`ready`?`Server Ready`:`Not Ready`})}):null}),(0,C.jsxs)(`div`,{className:`grid items-start gap-4 xl:grid-cols-2`,children:[(0,C.jsxs)(g,{className:`${G} self-start ${q?`text-white`:``}`,children:[(0,C.jsxs)(m,{className:`mb-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`p`,{className:`text-kicker ${Y}`,children:`Current Focus`}),(0,C.jsx)(p,{className:`mt-2 ${J}`,children:R?b(R.prompt,92):`No active blockers`})]}),R?(0,C.jsx)(f,{variant:d(R.status),children:R.status}):null]}),(0,C.jsx)(h,{className:X,children:W}),(0,C.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-[repeat(3,minmax(0,1fr))_auto]`,children:[(0,C.jsx)(E,{tone:K,label:`Created`,value:R?y(R.createdAt):`Idle`}),(0,C.jsx)(E,{tone:K,label:`Cost`,value:R?.costUsd==null?`No cost`:x(R.costUsd)}),(0,C.jsx)(E,{tone:K,label:`Role`,value:V}),(0,C.jsx)(s,{to:H,className:`inline-flex items-center justify-center rounded-lg border px-3 py-2 text-sm font-medium transition-colors ${q?`border-white/20 bg-white/10 text-white hover:bg-white/14`:`border-[var(--app-border)] bg-white/[0.05] text-[var(--app-text)] hover:border-[var(--app-border-strong)]`}`,children:U})]})]}),(0,C.jsxs)(g,{className:`surface-panel-elevated self-start`,children:[(0,C.jsx)(v,{title:`System Checks`,description:`${B}/${z.length||0} checks passing`,compact:!0}),D?(0,C.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:Object.entries(D.checks).map(([e,t])=>(0,C.jsxs)(`div`,{className:`surface-panel-muted flex items-center justify-between rounded-lg px-3 py-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(o,{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,a=[n>0?`${n} probation`:``,r>0?`${r} retired`:``].filter(Boolean).join(` · `);return(0,C.jsx)(T,{icon:i,label:`Role Health`,value:a?`${e}/${t} | ${a}`:`${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:a,label:`Cost Today`,value:x(w.totalCostToday),color:`text-[var(--app-accent-strong)]`})]}),(0,C.jsxs)(g,{padding:!1,children:[(0,C.jsx)(`div`,{className:`px-4 pt-4`,children:(0,C.jsx)(v,{title:`Recent Tasks`,description:`Latest executions across the control plane.`,action:(0,C.jsx)(s,{to:`/work`,className:`text-sm font-medium text-[var(--app-accent-strong)] hover:underline`,children:`View all`})})}),(0,C.jsx)(`div`,{className:`mt-4 space-y-3 px-4 pb-4`,children:L.length===0?(0,C.jsx)(`div`,{className:`surface-panel-muted rounded-lg px-4 py-6 text-sm text-[var(--app-text-subtle)]`,children:`No tasks yet`}):L.map(e=>(0,C.jsxs)(s,{to:`/tasks/${e.id}`,className:`surface-panel-muted flex flex-col gap-3 rounded-lg px-4 py-4 transition-colors hover:border-[var(--app-border-strong)] hover:bg-white/[0.05] lg:flex-row lg:items-start lg:justify-between`,children:[(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(f,{variant:d(e.status),children:e.status}),(0,C.jsx)(`span`,{className:`font-mono text-xs text-[var(--app-text-subtle)]`,children:e.id.slice(0,8)}),e.roleId?(0,C.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`role `,e.roleId.slice(0,12)]}):null]}),(0,C.jsx)(`div`,{className:`text-sm font-medium text-[var(--app-text)]`,children:b(e.prompt,128)})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 text-xs text-[var(--app-text-subtle)]`,children:[(0,C.jsx)(`span`,{children:y(e.createdAt)}),(0,C.jsx)(`span`,{children:e.costUsd==null?`no cost`:x(e.costUsd)})]})]},e.id))})]})]})}function T({icon:e,label:t,value:n,color:r}){return(0,C.jsxs)(g,{className:`surface-panel-muted flex items-center gap-3`,children:[(0,C.jsx)(`div`,{className:`rounded-lg bg-white/[0.05] p-3 ${r}`,children:(0,C.jsx)(e,{size:16})}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-xl font-semibold text-[var(--app-text)]`,children:n}),(0,C.jsx)(`div`,{className:`text-xs uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:t})]})]})}function E({label:e,value:t,tone:n=`accent`}){let r=n===`accent`||n===`critical`;return(0,C.jsxs)(`div`,{className:r?`rounded-lg border border-white/12 bg-black/10 px-3 py-3`:`surface-focus-metric rounded-lg px-3 py-3`,children:[(0,C.jsx)(`div`,{className:r?`text-[10px] uppercase tracking-[0.16em] text-white/62`:`text-[10px] uppercase tracking-[0.16em] text-[var(--app-text-subtle)]`,children:e}),(0,C.jsx)(`div`,{className:r?`mt-1 text-lg font-semibold text-white`:`mt-1 text-lg font-semibold text-[var(--app-text)]`,children:t})]})}export{w as Dashboard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./vendor-react-
|
|
1
|
+
import{t as e}from"./vendor-react-Bp_V-Hsf.js";import{n as t}from"./dist-CgGno8kE.js";var n=e();function r({icon:e,title:r,description:i,action:a,compact:o=!1,className:s}){return(0,n.jsxs)(`div`,{className:t(`surface-panel-muted flex flex-col items-center justify-center rounded-xl text-center`,o?`px-5 py-6`:`px-6 py-10`,s),children:[e&&(0,n.jsx)(`div`,{className:t(`text-[var(--app-text-subtle)]`,o?`mb-3`:`mb-4`),children:e}),(0,n.jsx)(`h3`,{className:`text-base font-semibold text-[var(--app-text)]`,children:r}),i&&(0,n.jsx)(`p`,{className:t(`max-w-md text-sm text-[var(--app-text-muted)]`,o?`mt-1.5 leading-5`:`mt-2 leading-6`),children:i}),a&&(0,n.jsx)(`div`,{className:t(o?`mt-3`:`mt-4`),children:a})]})}export{r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{K as t,c as n,mt as r,q as i,s as a,w as o}from"./vendor-icons-U4igmrUq.js";import{t as s}from"./vendor-react-Bp_V-Hsf.js";import{n as c}from"./dist-CgGno8kE.js";import{t as l}from"./Button-fLMsJd5o.js";import{t as u}from"./api-BkdixMz9.js";import{p as d}from"./index-C-e-qpXc.js";import{a as f,i as p,t as m}from"./Card-cy-gHU0O.js";import{t as h}from"./ui-CerQw0jA.js";var g=e(r(),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:r,mode:s,roleId:c,title:x=`Environment Variables`}){let[S,C]=(0,g.useState)([]),[w,T]=(0,g.useState)(!1),[E,D]=(0,g.useState)(new Set),[O,k]=(0,g.useState)([]),[A,j]=(0,g.useState)(!1);(0,g.useEffect)(()=>{C(Object.entries(e??{}).map(([e,t])=>({key:e,value:t,isNew:!1})))},[e]);let M=(0,g.useCallback)(async()=>{try{let e=await u(s===`global`?`/config/env-diff`:`/roles/${c}/env-diff`);k(s===`global`?e.diffs.filter(e=>e.configPath?.startsWith(`defaults.env.`)):e.diffs),j(e.envFileExists)}catch{}},[s,c]);(0,g.useEffect)(()=>{M()},[M]);let N=()=>{let t=Object.fromEntries(S.filter(e=>e.key.trim()).map(e=>[e.key,e.value]));return JSON.stringify(t)!==JSON.stringify(e)},P=()=>{C(e=>[...e,{key:``,value:``,isNew:!0}])},F=e=>{C(t=>t.filter((t,n)=>n!==e))},I=(e,t,n)=>{C(r=>r.map((r,i)=>i===e?{...r,[t]:n}:r))},L=e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},R=()=>{let e=new Set;for(let t of S){let n=t.key.trim();if(n){if(!y.test(n))return`Invalid key format: "${n}"`;if(n.startsWith(`ANTHROPIC_`))return`ANTHROPIC_* keys are managed in the Anthropic section`;if(e.has(n))return`Duplicate key: "${n}"`;e.add(n)}}return e.size>100?`Maximum 100 environment variables`:null},z=async()=>{let e=R();if(e){d.error(e);return}T(!0);try{let e={};for(let t of S){let n=t.key.trim();n&&(e[n]=t.value)}s===`global`?await u(`/config/env`,{method:`PUT`,body:JSON.stringify(e)}):await u(`/roles/${c}`,{method:`PATCH`,body:JSON.stringify({envVars:e})}),d.success(`Environment variables saved`),r(),M()}catch(e){d.error(e instanceof Error?e.message:`Failed to save`)}finally{T(!1)}},B=async()=>{try{await u(s===`global`?`/config/sync-to-env`:`/roles/${c}/sync-to-env`,{method:`POST`}),d.success(`Synced DB to .env`),M()}catch(e){d.error(e instanceof Error?e.message:`Sync failed`)}},V=async()=>{try{await u(s===`global`?`/config/load-from-env`:`/roles/${c}/load-from-env`,{method:`POST`}),d.success(`Loaded .env to DB`),r(),M()}catch(e){d.error(e instanceof Error?e.message:`Load failed`)}};return(0,_.jsxs)(m,{children:[(0,_.jsxs)(p,{children:[(0,_.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,_.jsx)(f,{className:`text-sm`,children:x}),(0,_.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,_.jsxs)(l,{variant:`ghost`,size:`sm`,onClick:P,children:[(0,_.jsx)(o,{size:h.sm}),`Add`]}),N()&&(0,_.jsx)(l,{size:`sm`,onClick:()=>void z(),disabled:w,children:w?`Saving...`:`Save`})]})]}),s===`global`&&(0,_.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] mt-1`,children:`ANTHROPIC_* variables are managed in the Anthropic section above.`})]}),O.length>0&&A&&(0,_.jsx)(`div`,{className:`mx-4 mb-3 rounded border border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg)] p-3`,children:(0,_.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,_.jsx)(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)(l,{variant:`ghost`,size:`sm`,className:`text-xs`,onClick:()=>void B(),children:`DB → .env`}),(0,_.jsx)(l,{variant:`ghost`,size:`sm`,className:`text-xs`,onClick:()=>void V(),children:`.env → DB`})]})]})}),(0,_.jsxs)(`div`,{className:`px-4 pb-4 space-y-2`,children:[S.length===0&&(0,_.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] py-2`,children:`No environment variables configured.`}),S.map((e,r)=>{let a=b.test(e.key),o=E.has(e.key)||e.isNew;return(0,_.jsxs)(`div`,{className:`flex flex-col gap-2 md:flex-row md:items-center`,children:[(0,_.jsx)(v,{className:`w-full font-mono text-xs md:w-48`,placeholder:`KEY_NAME`,value:e.key,onChange:e=>I(r,`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:a&&!o?`password`:`text`,placeholder:`value`,value:e.value,onChange:e=>I(r,`value`,e.target.value)}),a&&(0,_.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,onClick:()=>L(e.key),children:o?(0,_.jsx)(i,{size:12}):(0,_.jsx)(t,{size:12})})]}),(0,_.jsx)(l,{variant:`ghost`,size:`sm`,className:`self-end text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)] md:self-auto`,onClick:()=>F(r),children:(0,_.jsx)(n,{size:14})})]},r)})]})]})}export{x as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{dt as t,mt as n,x as r}from"./vendor-icons-U4igmrUq.js";import{d as i,f as a,t as o}from"./vendor-react-Bp_V-Hsf.js";import{t as s}from"./Button-fLMsJd5o.js";import{t as c}from"./api-BkdixMz9.js";import{p as l,t as u}from"./index-C-e-qpXc.js";import{t as d}from"./Card-cy-gHU0O.js";import{t as f}from"./SectionHeader-CwX6m1f6.js";import{t as p}from"./EmptyState-C5kVDHc7.js";import{a as m,i as h,n as g,o as _,r as v,t as y}from"./Table-BrERwl-F.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 c(`/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 c(`/event-defs/${e}/firings?${new URLSearchParams({limit:`20`,...n?{since:n}:{}})}`);O(t===0?r:e=>[...e,...r]),P(r.length===20),M(t)}catch{l.error(`Failed to load firings`)}finally{A(!1)}}},[e]);(0,b.useEffect)(()=>{G()},[G]),(0,b.useEffect)(()=>{U===`firings`&&D.length===0&&K(0)},[U,K,D.length]);let q=(0,b.useCallback)(async(t=0)=>{if(e){R(!0);try{let n=await c(`/event-defs/${e}/dispatches?${new URLSearchParams({limit:`20`,offset:String(t*20)})}`);I(t===0?n:e=>[...e,...n]),H(n.length===20),B(t)}catch{l.error(`Failed to load dispatches`)}finally{R(!1)}}},[e]);return(0,b.useEffect)(()=>{U===`dispatches`&&F.length===0&&q(0)},[U,q,F.length]),T?(0,x.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,x.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):o?(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>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)(s,{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)(s,{size:`sm`,variant:`ghost`,onClick:()=>{if(!o)return;let e=`${window.location.origin}/webhooks/events/${o.id}`;navigator.clipboard.writeText(e),l.success(`Webhook URL copied to clipboard`)},children:`Copy`})]}),(0,x.jsxs)(`p`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`Send a POST request with JSON body: `,(0,x.jsx)(`code`,{className:`rounded bg-[var(--app-panel)] px-1`,children:`{ "type": "event.name", "payload": {...} }`})]})]}),(()=>{let e=o.sourceConfig?.cron;return e?(0,x.jsxs)(d,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Schedule`}),(0,x.jsx)(`code`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-1.5 font-mono text-sm text-[var(--app-text)]`,children:e})]}):null})(),(()=>{let e=o.sourceConfig?.path;return e?(0,x.jsxs)(d,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Watch Directory`}),(0,x.jsx)(`code`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-1.5 font-mono text-sm text-[var(--app-text)] break-all`,children:e})]}):null})(),(0,x.jsxs)(`div`,{className:`flex gap-1 border-b border-[var(--app-border)]`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>W(`config`),className:`px-4 py-2 text-sm transition-colors ${U===`config`?`border-b-2 border-[var(--app-accent)] text-[var(--app-text)]`:`text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:`Configuration`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>W(`firings`),className:`px-4 py-2 text-sm transition-colors ${U===`firings`?`border-b-2 border-[var(--app-accent)] text-[var(--app-text)]`:`text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:`Firings`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>W(`dispatches`),className:`px-4 py-2 text-sm transition-colors ${U===`dispatches`?`border-b-2 border-[var(--app-accent)] text-[var(--app-text)]`:`text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:`Dispatches`})]}),U===`firings`&&(0,x.jsx)(d,{padding:!1,children:k&&D.length===0?(0,x.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,x.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):D.length===0?(0,x.jsx)(p,{icon:(0,x.jsx)(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)(s,{variant:`ghost`,size:`sm`,onClick:()=>void K(j+1),disabled:k,children:k?`Loading...`:`Load more`})})]})}),U===`dispatches`&&(0,x.jsx)(d,{padding:!1,children:L&&F.length===0?(0,x.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,x.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):F.length===0?(0,x.jsx)(p,{icon:(0,x.jsx)(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)(s,{variant:`ghost`,size:`sm`,onClick:()=>void q(z+1),disabled:L,children:L?`Loading...`:`Load more`})})]})})]}):null}export{w as EventDefDetail};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,O as ee,c as te,mt as n,t as ne,w as re,x as ie}from"./vendor-icons-U4igmrUq.js";import{d as ae,t as r}from"./vendor-react-Bp_V-Hsf.js";import"./es2015-JqLIWAgH.js";import{t as i}from"./Button-fLMsJd5o.js";import{t as a}from"./api-BkdixMz9.js";import{a as o,c as s,i as c,l,o as u,p as d,r as oe,s as se,t as ce,u as f}from"./index-C-e-qpXc.js";import{t as p}from"./Card-cy-gHU0O.js";import{t as le}from"./SectionHeader-CwX6m1f6.js";import{a as ue}from"./format-BUYXZqDw.js";import{t as de}from"./EmptyState-C5kVDHc7.js";import{a as fe,i as m,n as pe,o as h,r as g,t as me}from"./Table-BrERwl-F.js";import{t as he}from"./Switch-PNpjNoGn.js";var _=e(n(),1),v=r(),ge={webhook:`info`,directory_watch:`warning`,cron:`success`,manual:`muted`};function y(e){let t=e.trim().split(/\s+/);return t.length===5?t.every(e=>/^(\*|(\*\/)?\d+(-\d+)?(,\d+(-\d+)?)*)$/.test(e)):!1}function b(){let e=ae(),[n,r]=(0,_.useState)([]),[b,x]=(0,_.useState)(!0),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(``),[E,_e]=(0,_.useState)(`webhook`),[D,O]=(0,_.useState)(``),[k,A]=(0,_.useState)(``),[j,M]=(0,_.useState)(``),[N,P]=(0,_.useState)(``),[F,I]=(0,_.useState)(!1),[L,R]=(0,_.useState)(null),[z,ve]=(0,_.useState)(``),[B,V]=(0,_.useState)(``),[H,ye]=(0,_.useState)(`webhook`),[U,W]=(0,_.useState)(``),[G,K]=(0,_.useState)(``),[be,q]=(0,_.useState)(``),[xe,Se]=(0,_.useState)(!1),[J,Y]=(0,_.useState)(null),[X,Z]=(0,_.useState)(null),[Q,Ce]=(0,_.useState)(``),[we,Te]=(0,_.useState)(!1),$=(0,_.useCallback)(async()=>{x(!0);try{r(await a(`/event-defs`))}catch{d.error(`Failed to load events`)}finally{x(!1)}},[]);(0,_.useEffect)(()=>{$()},[$]);let Ee=async()=>{if(w.trim()){if(E===`cron`&&!y(j)){P(`Invalid cron expression (expected 5 fields: minute hour day month weekday)`);return}I(!0);try{let e={name:w.trim(),sourceType:E,description:D.trim()||void 0,enabled:!0};E===`directory_watch`&&k.trim()?e.sourceConfig={path:k.trim(),stability_delay_ms:5e3}:E===`cron`&&j.trim()&&(e.sourceConfig={cron:j.trim()}),await a(`/event-defs`,{method:`POST`,body:JSON.stringify(e)}),T(``),O(``),A(``),M(``),P(``),C(!1),$(),d.success(`Event created`)}catch(e){let t=e instanceof Error?e.message:`Failed to create event`;d.error(t)}finally{I(!1)}}},De=e=>{R(e.id),ve(e.name),V(e.description??``),ye(e.sourceType),W(e.sourceConfig?.path??``),K(e.sourceConfig?.cron??``),q(``)},Oe=async()=>{if(!(!L||!z.trim())){if(H===`cron`&&!y(G)){q(`Invalid cron expression`);return}Se(!0);try{let e={name:z.trim(),description:B.trim()||void 0};H===`directory_watch`?e.sourceConfig={path:U.trim(),stability_delay_ms:5e3}:H===`cron`&&(e.sourceConfig={cron:G.trim()}),await a(`/event-defs/${L}`,{method:`PATCH`,body:JSON.stringify(e)}),R(null),$(),d.success(`Event updated`)}catch(e){let t=e instanceof Error?e.message:`Failed to update event`;d.error(t)}finally{Se(!1)}}},ke=async e=>{try{await 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`;d.error(t)}},Ae=async e=>{try{await a(`/event-defs/${e}`,{method:`DELETE`}),Y(null),$(),d.success(`Event deleted`)}catch(e){let t=e instanceof Error?e.message:`Failed to delete`;d.error(t)}},je=async e=>{Te(!0);try{let t={};if(Q.trim())try{t.payload=JSON.parse(Q)}catch{t.payload={raw:Q}}await a(`/event-defs/${e}/fire`,{method:`POST`,body:JSON.stringify(t)}),Z(null),Ce(``),d.success(`Event fired`)}catch(e){let t=e instanceof Error?e.message:`Failed to fire event`;d.error(t)}finally{Te(!1)}},Me=n.find(e=>e.id===J);return(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsx)(le,{title:`Events`,description:`Event definitions that trigger automations. Configure webhooks, schedules, or file watchers.`,compact:!0,action:(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(i,{variant:`ghost`,size:`sm`,onClick:()=>void $(),children:(0,v.jsx)(ie,{size:14})}),(0,v.jsxs)(i,{size:`sm`,onClick:()=>C(!S),children:[(0,v.jsx)(re,{size:14}),`New Event`]})]})}),S&&(0,v.jsxs)(p,{className:`space-y-3`,children:[(0,v.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`New Event`}),(0,v.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Event name`,value:w,onChange:e=>T(e.target.value)}),(0,v.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Description (optional)`,value:D,onChange:e=>O(e.target.value)}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Source:`}),(0,v.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:E,onChange:e=>_e(e.target.value),children:[(0,v.jsx)(`option`,{value:`webhook`,children:`Webhook (HTTP)`}),(0,v.jsx)(`option`,{value:`cron`,children:`Schedule (Cron)`}),(0,v.jsx)(`option`,{value:`directory_watch`,children:`File Watcher`}),(0,v.jsx)(`option`,{value:`manual`,children:`Manual`})]})]}),E===`directory_watch`&&(0,v.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Watch directory path (absolute)`,value:k,onChange:e=>A(e.target.value)}),E===`cron`&&(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Cron expression (minute hour day month weekday)`,value:j,onChange:e=>{M(e.target.value),P(``)}}),N&&(0,v.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:N})]}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(i,{onClick:()=>void Ee(),disabled:F||!w.trim()||E===`directory_watch`&&!k.trim(),children:F?`Creating...`:`Create`}),(0,v.jsx)(i,{variant:`ghost`,onClick:()=>C(!1),children:`Cancel`})]})]}),L!==null&&(n.find(e=>e.id===L)?(0,v.jsxs)(p,{className:`space-y-3`,children:[(0,v.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Edit Event`}),(0,v.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Event name`,value:z,onChange:e=>ve(e.target.value)}),(0,v.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)]`,placeholder:`Description (optional)`,value:B,onChange:e=>V(e.target.value)}),H===`directory_watch`&&(0,v.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)]`,placeholder:`Watch directory path`,value:U,onChange:e=>W(e.target.value)}),H===`cron`&&(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)]`,placeholder:`Cron expression`,value:G,onChange:e=>{K(e.target.value),q(``)}}),be&&(0,v.jsx)(`p`,{className:`text-xs text-[var(--app-danger)]`,children:be})]}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(i,{onClick:()=>void Oe(),disabled:xe||!z.trim(),children:xe?`Saving...`:`Save`}),(0,v.jsx)(i,{variant:`ghost`,onClick:()=>R(null),children:`Cancel`})]})]}):null),(0,v.jsx)(p,{padding:!1,children:b?(0,v.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,v.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):n.length===0?(0,v.jsx)(de,{icon:(0,v.jsx)(ne,{size:32}),title:`No events`,description:`Events are triggered by webhooks, schedules, or file changes and can start automations.`}):(0,v.jsxs)(me,{children:[(0,v.jsx)(fe,{children:(0,v.jsxs)(h,{children:[(0,v.jsx)(m,{children:`Name`}),(0,v.jsx)(m,{children:`Source`}),(0,v.jsx)(m,{children:`Enabled`}),(0,v.jsx)(m,{children:`Last Fired`}),(0,v.jsx)(m,{children:`Actions`})]})}),(0,v.jsx)(pe,{children:n.map(n=>(0,v.jsxs)(h,{children:[(0,v.jsxs)(g,{children:[(0,v.jsx)(`button`,{type:`button`,onClick:()=>e(`/events/${n.id}`),className:`font-medium text-[var(--app-text)] hover:text-[var(--app-accent)] transition-colors text-left`,children:n.name}),n.description&&(0,v.jsx)(`div`,{className:`text-xs text-[var(--app-text-muted)] truncate max-w-[200px]`,children:n.description})]}),(0,v.jsx)(g,{children:(0,v.jsx)(ce,{variant:ge[n.sourceType],children:n.sourceType===`directory_watch`?`file watcher`:n.sourceType})}),(0,v.jsx)(g,{children:(0,v.jsx)(he,{checked:n.enabled,onCheckedChange:()=>void ke(n),"aria-label":`Toggle ${n.name}`})}),(0,v.jsx)(g,{className:`text-xs text-[var(--app-text-muted)]`,children:n.lastFiredAt?ue(n.lastFiredAt):`—`}),(0,v.jsx)(g,{children:(0,v.jsxs)(`div`,{className:`flex gap-1`,children:[(0,v.jsx)(i,{variant:`ghost`,size:`sm`,onClick:()=>De(n),title:`Edit`,children:(0,v.jsx)(ee,{size:12})}),n.sourceType===`manual`&&n.enabled&&(0,v.jsx)(i,{variant:`ghost`,size:`sm`,onClick:()=>Z(n.id),title:`Fire now`,children:(0,v.jsx)(t,{size:12})}),(0,v.jsx)(i,{variant:`ghost`,size:`sm`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,onClick:()=>Y(n.id),title:`Delete`,children:(0,v.jsx)(te,{size:12})})]})})]},n.id))})]})}),(0,v.jsx)(oe,{open:X!==null,onOpenChange:e=>{e||Z(null)},children:(0,v.jsxs)(u,{children:[(0,v.jsxs)(l,{children:[(0,v.jsx)(f,{children:`Fire Event`}),(0,v.jsx)(se,{children:`Fire the manual event immediately. Optionally provide a JSON payload.`})]}),(0,v.jsx)(`textarea`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder='{}' focus:border-[var(--app-accent)] focus:outline-none font-mono`,rows:4,placeholder:`{"key": "value"}`,value:Q,onChange:e=>Ce(e.target.value)}),(0,v.jsxs)(s,{children:[(0,v.jsx)(o,{children:`Cancel`}),(0,v.jsx)(c,{onClick:()=>{X&&je(X),Z(null)},disabled:we,children:we?`Firing...`:`Fire Event`})]})]})}),(0,v.jsx)(oe,{open:J!==null,onOpenChange:e=>{e||Y(null)},children:(0,v.jsxs)(u,{children:[(0,v.jsxs)(l,{children:[(0,v.jsx)(f,{children:`Delete Event`}),(0,v.jsxs)(se,{children:[`Delete “`,Me?.name,`”? This action cannot be undone.`]})]}),(0,v.jsxs)(s,{children:[(0,v.jsx)(o,{children:`Cancel`}),(0,v.jsx)(c,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger)]`,onClick:()=>{J&&Ae(J)},children:`Delete`})]})]})})]})}export{b as Events};
|