agentix-cli 0.217.0 → 0.219.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 +87 -207
- package/dist/{App-IXJCCCGN.js → App-ET75JEWK.js} +2 -2
- package/dist/{ChatApp-4YCCRL5M.js → ChatApp-F2NT5M2O.js} +2 -2
- package/dist/{absorb-eval-YE57HA6N.js → absorb-eval-EA5ESP4Y.js} +2 -2
- package/dist/{adapter-CRVWPQBN.js → adapter-7PKOKXO5.js} +2 -2
- package/dist/{agent-CTZN3P2K.js → agent-SDNU6MUI.js} +2 -2
- package/dist/{board-dashboard-2WE2HBEW.js → board-dashboard-PI22IXZN.js} +5 -5
- package/dist/{board-dashboard-2WE2HBEW.js.map → board-dashboard-PI22IXZN.js.map} +1 -1
- package/dist/{chunk-MFZNBE65.js → chunk-34TEBXFP.js} +2 -2
- package/dist/{chunk-WHAMZPEG.js → chunk-3XUAIA7U.js} +2 -2
- package/dist/{chunk-KBSQRQPF.js → chunk-5OEW46QP.js} +2 -2
- package/dist/{chunk-YXGZSVPY.js → chunk-6HCCMU57.js} +2 -2
- package/dist/{chunk-AOPNASCE.js → chunk-6X7SABYJ.js} +2 -2
- package/dist/{chunk-QGRIW7SE.js → chunk-7ATCEK7R.js} +2 -2
- package/dist/{chunk-IP67DTXX.js → chunk-CR37IINZ.js} +2 -2
- package/dist/{chunk-RKKAP4EY.js → chunk-DGCYSQAZ.js} +2 -2
- package/dist/{chunk-O2YDS2P3.js → chunk-EPOQUX4G.js} +2 -2
- package/dist/{chunk-FFLMSNTN.js → chunk-EWXY73XA.js} +2 -2
- package/dist/{chunk-PZ2F6J2E.js → chunk-EZDHAX4Z.js} +31 -30
- package/dist/chunk-EZDHAX4Z.js.map +1 -0
- package/dist/{chunk-I4FXWN7I.js → chunk-GPX4LDAX.js} +2 -2
- package/dist/{chunk-X2GBLX3E.js → chunk-HHSPOS7O.js} +2 -2
- package/dist/{chunk-SJJ7QEFE.js → chunk-IIJB3OPV.js} +2 -2
- package/dist/{chunk-OJ4RUZZY.js → chunk-IKOJM4GM.js} +2 -2
- package/dist/{chunk-Z5HYCMDF.js → chunk-IQNKEUEL.js} +2 -2
- package/dist/{chunk-LSFLSB7C.js → chunk-KCS737RC.js} +2 -2
- package/dist/{chunk-56UTQ4FU.js → chunk-MELXJ5AR.js} +2 -2
- package/dist/{chunk-GEKEILPL.js → chunk-MUCWUVOW.js} +5 -5
- package/dist/{chunk-QEOGWSRR.js → chunk-PTVDVI2U.js} +2 -2
- package/dist/{chunk-LLNLDZNA.js → chunk-SQJ3IHNL.js} +2 -2
- package/dist/{chunk-3C6UDZDX.js → chunk-TCBIAKGS.js} +2 -2
- package/dist/chunk-U4AUJ6XI.js +39 -0
- package/dist/chunk-U4AUJ6XI.js.map +1 -0
- package/dist/{chunk-5FFNFW4C.js → chunk-UYDC2YMH.js} +2 -2
- package/dist/{chunk-2MAKXLK2.js → chunk-V75JESS5.js} +3 -3
- package/dist/{chunk-M42GMRZF.js → chunk-W2KIJ5LL.js} +2 -2
- package/dist/{chunk-NFUHYIYG.js → chunk-XTXFA5EJ.js} +2 -2
- package/dist/{chunk-3B7RH3IK.js → chunk-Y3TXTZYG.js} +2 -2
- package/dist/{chunk-64IVC2G6.js → chunk-YMMGY7GR.js} +2 -2
- package/dist/{chunk-ELC3M5WS.js → chunk-Z3FJRBTG.js} +337 -336
- package/dist/chunk-Z3FJRBTG.js.map +1 -0
- package/dist/{chunk-Q432O462.js → chunk-ZT4FCL5B.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{client-UPXDV3SM.js → client-7PLIDORM.js} +2 -2
- package/dist/{config-LAM4HUTA.js → config-3R4EGNUG.js} +2 -2
- package/dist/{config-mutate-P4QLFUVH.js → config-mutate-3PGEBKJ6.js} +2 -2
- package/dist/{config-mutator-RIPSMYAO.js → config-mutator-LQQOOUZR.js} +2 -2
- package/dist/{contributions-SHSEI3TX.js → contributions-D4O76KGX.js} +2 -2
- package/dist/{doctor-TLDBNHYM.js → doctor-QM4KUMQJ.js} +2 -2
- package/dist/{follow-up-tool-VM4ZDRC5.js → follow-up-tool-X3YPYSP2.js} +2 -2
- package/dist/{hub-7Y6ZUVJV.js → hub-PBJHXL2G.js} +2 -2
- package/dist/index.d.ts +52 -2
- package/dist/index.js +1 -1
- package/dist/{org-tool-TOHI7MBS.js → org-tool-37GNUUAD.js} +2 -2
- package/dist/{program-QZKK3Y2W.js → program-243AGBJJ.js} +26 -26
- package/dist/program-243AGBJJ.js.map +1 -0
- package/dist/{promote-OBTQ3ZUN.js → promote-CFI4HJDJ.js} +2 -2
- package/dist/{query-K6NR3GQE.js → query-J6S3GWPY.js} +2 -2
- package/dist/{query-settings-NIZBB73K.js → query-settings-2NKI7UFN.js} +2 -2
- package/dist/{registry-B7X6YGS7.js → registry-R2QIR6GI.js} +2 -2
- package/dist/{request-planner-YDIX4BQW.js → request-planner-NKGUSV4N.js} +2 -2
- package/dist/{review-candidates-3QCCHXWM.js → review-candidates-43HXKXWD.js} +2 -2
- package/dist/{routing-BGMIY5JY.js → routing-72F2DJTV.js} +2 -2
- package/dist/{schedule-tool-P6XM6W3S.js → schedule-tool-V3KMSJHK.js} +2 -2
- package/dist/{scheduler-PUKN5YSL.js → scheduler-ZBTMOE3T.js} +2 -2
- package/dist/{seat-OTAJJ5BP.js → seat-GYYH2IW5.js} +2 -2
- package/dist/{select-KKMXIVVL.js → select-JNVP4P5N.js} +2 -2
- package/dist/{set-enabled-BNF427ZN.js → set-enabled-U26A4RMI.js} +2 -2
- package/dist/{sprint-tool-Y72HTX5X.js → sprint-tool-YCDVAF2Y.js} +2 -2
- package/dist/{tool-F4ZVMX4J.js → tool-CF7OTKDV.js} +2 -2
- package/dist/tool-GHQ2FM4T.js +10 -0
- package/dist/tool-GHQ2FM4T.js.map +1 -0
- package/dist/{tool-DW6MYEG2.js → tool-JEHJS2SA.js} +2 -2
- package/dist/tool-K3RAEZKE.js +2 -0
- package/dist/{tool-QDAD4ACK.js → tool-MB3IYEP7.js} +2 -2
- package/dist/{wiki-J6MSHSVD.js → wiki-6UFGH2OO.js} +2 -2
- package/dist/wiki-enrich-7LMT3CFV.js +2 -0
- package/package.json +2 -2
- package/dist/chunk-2F7KQ4DJ.js +0 -38
- package/dist/chunk-2F7KQ4DJ.js.map +0 -1
- package/dist/chunk-ELC3M5WS.js.map +0 -1
- package/dist/chunk-PZ2F6J2E.js.map +0 -1
- package/dist/program-QZKK3Y2W.js.map +0 -1
- package/dist/tool-EA4FWTH6.js +0 -2
- package/dist/tool-HUOT3I42.js +0 -10
- package/dist/tool-HUOT3I42.js.map +0 -1
- package/dist/wiki-enrich-3Y3TZ6ZK.js +0 -2
- /package/dist/{App-IXJCCCGN.js.map → App-ET75JEWK.js.map} +0 -0
- /package/dist/{ChatApp-4YCCRL5M.js.map → ChatApp-F2NT5M2O.js.map} +0 -0
- /package/dist/{absorb-eval-YE57HA6N.js.map → absorb-eval-EA5ESP4Y.js.map} +0 -0
- /package/dist/{adapter-CRVWPQBN.js.map → adapter-7PKOKXO5.js.map} +0 -0
- /package/dist/{agent-CTZN3P2K.js.map → agent-SDNU6MUI.js.map} +0 -0
- /package/dist/{chunk-MFZNBE65.js.map → chunk-34TEBXFP.js.map} +0 -0
- /package/dist/{chunk-WHAMZPEG.js.map → chunk-3XUAIA7U.js.map} +0 -0
- /package/dist/{chunk-KBSQRQPF.js.map → chunk-5OEW46QP.js.map} +0 -0
- /package/dist/{chunk-YXGZSVPY.js.map → chunk-6HCCMU57.js.map} +0 -0
- /package/dist/{chunk-AOPNASCE.js.map → chunk-6X7SABYJ.js.map} +0 -0
- /package/dist/{chunk-QGRIW7SE.js.map → chunk-7ATCEK7R.js.map} +0 -0
- /package/dist/{chunk-IP67DTXX.js.map → chunk-CR37IINZ.js.map} +0 -0
- /package/dist/{chunk-RKKAP4EY.js.map → chunk-DGCYSQAZ.js.map} +0 -0
- /package/dist/{chunk-O2YDS2P3.js.map → chunk-EPOQUX4G.js.map} +0 -0
- /package/dist/{chunk-FFLMSNTN.js.map → chunk-EWXY73XA.js.map} +0 -0
- /package/dist/{chunk-I4FXWN7I.js.map → chunk-GPX4LDAX.js.map} +0 -0
- /package/dist/{chunk-X2GBLX3E.js.map → chunk-HHSPOS7O.js.map} +0 -0
- /package/dist/{chunk-SJJ7QEFE.js.map → chunk-IIJB3OPV.js.map} +0 -0
- /package/dist/{chunk-OJ4RUZZY.js.map → chunk-IKOJM4GM.js.map} +0 -0
- /package/dist/{chunk-Z5HYCMDF.js.map → chunk-IQNKEUEL.js.map} +0 -0
- /package/dist/{chunk-LSFLSB7C.js.map → chunk-KCS737RC.js.map} +0 -0
- /package/dist/{chunk-56UTQ4FU.js.map → chunk-MELXJ5AR.js.map} +0 -0
- /package/dist/{chunk-GEKEILPL.js.map → chunk-MUCWUVOW.js.map} +0 -0
- /package/dist/{chunk-QEOGWSRR.js.map → chunk-PTVDVI2U.js.map} +0 -0
- /package/dist/{chunk-LLNLDZNA.js.map → chunk-SQJ3IHNL.js.map} +0 -0
- /package/dist/{chunk-3C6UDZDX.js.map → chunk-TCBIAKGS.js.map} +0 -0
- /package/dist/{chunk-5FFNFW4C.js.map → chunk-UYDC2YMH.js.map} +0 -0
- /package/dist/{chunk-2MAKXLK2.js.map → chunk-V75JESS5.js.map} +0 -0
- /package/dist/{chunk-M42GMRZF.js.map → chunk-W2KIJ5LL.js.map} +0 -0
- /package/dist/{chunk-NFUHYIYG.js.map → chunk-XTXFA5EJ.js.map} +0 -0
- /package/dist/{chunk-3B7RH3IK.js.map → chunk-Y3TXTZYG.js.map} +0 -0
- /package/dist/{chunk-64IVC2G6.js.map → chunk-YMMGY7GR.js.map} +0 -0
- /package/dist/{chunk-Q432O462.js.map → chunk-ZT4FCL5B.js.map} +0 -0
- /package/dist/{client-UPXDV3SM.js.map → client-7PLIDORM.js.map} +0 -0
- /package/dist/{config-LAM4HUTA.js.map → config-3R4EGNUG.js.map} +0 -0
- /package/dist/{config-mutate-P4QLFUVH.js.map → config-mutate-3PGEBKJ6.js.map} +0 -0
- /package/dist/{config-mutator-RIPSMYAO.js.map → config-mutator-LQQOOUZR.js.map} +0 -0
- /package/dist/{contributions-SHSEI3TX.js.map → contributions-D4O76KGX.js.map} +0 -0
- /package/dist/{doctor-TLDBNHYM.js.map → doctor-QM4KUMQJ.js.map} +0 -0
- /package/dist/{follow-up-tool-VM4ZDRC5.js.map → follow-up-tool-X3YPYSP2.js.map} +0 -0
- /package/dist/{hub-7Y6ZUVJV.js.map → hub-PBJHXL2G.js.map} +0 -0
- /package/dist/{org-tool-TOHI7MBS.js.map → org-tool-37GNUUAD.js.map} +0 -0
- /package/dist/{promote-OBTQ3ZUN.js.map → promote-CFI4HJDJ.js.map} +0 -0
- /package/dist/{query-K6NR3GQE.js.map → query-J6S3GWPY.js.map} +0 -0
- /package/dist/{query-settings-NIZBB73K.js.map → query-settings-2NKI7UFN.js.map} +0 -0
- /package/dist/{registry-B7X6YGS7.js.map → registry-R2QIR6GI.js.map} +0 -0
- /package/dist/{request-planner-YDIX4BQW.js.map → request-planner-NKGUSV4N.js.map} +0 -0
- /package/dist/{review-candidates-3QCCHXWM.js.map → review-candidates-43HXKXWD.js.map} +0 -0
- /package/dist/{routing-BGMIY5JY.js.map → routing-72F2DJTV.js.map} +0 -0
- /package/dist/{schedule-tool-P6XM6W3S.js.map → schedule-tool-V3KMSJHK.js.map} +0 -0
- /package/dist/{scheduler-PUKN5YSL.js.map → scheduler-ZBTMOE3T.js.map} +0 -0
- /package/dist/{seat-OTAJJ5BP.js.map → seat-GYYH2IW5.js.map} +0 -0
- /package/dist/{select-KKMXIVVL.js.map → select-JNVP4P5N.js.map} +0 -0
- /package/dist/{set-enabled-BNF427ZN.js.map → set-enabled-U26A4RMI.js.map} +0 -0
- /package/dist/{sprint-tool-Y72HTX5X.js.map → sprint-tool-YCDVAF2Y.js.map} +0 -0
- /package/dist/{tool-F4ZVMX4J.js.map → tool-CF7OTKDV.js.map} +0 -0
- /package/dist/{tool-DW6MYEG2.js.map → tool-JEHJS2SA.js.map} +0 -0
- /package/dist/{tool-EA4FWTH6.js.map → tool-K3RAEZKE.js.map} +0 -0
- /package/dist/{tool-QDAD4ACK.js.map → tool-MB3IYEP7.js.map} +0 -0
- /package/dist/{wiki-J6MSHSVD.js.map → wiki-6UFGH2OO.js.map} +0 -0
- /package/dist/{wiki-enrich-3Y3TZ6ZK.js.map → wiki-enrich-7LMT3CFV.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{y as l,z as T}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{y as l,z as T}from"./chunk-YMMGY7GR.js";import{a,f as w}from"./chunk-72SZI2UW.js";T();w();var d="task-tier";function u(e){return{task:b(e.message,2e3),agent:e.agent,channel:e.channel??null,continuesExistingSession:e.isFollowUp??!1,...e.toolsAvailable?{toolsAvailable:e.toolsAvailable}:{}}}var c={needsFlagship:a("This task needs the strongest available model to be done correctly.",{true:"Doing it well takes real reasoning: writing or reviewing code, diagnosing a failure, planning work across several steps, weighing a judgement, handling money, touching production or anything irreversible, following a long or ambiguous instruction, or work where being subtly wrong would not be noticed. Anything where a weaker model would produce something that LOOKS right belongs here.",false:"It is mechanical and its result is obvious on sight: acknowledging or confirming a message, restating or formatting something already written, a greeting, a status echo, reading one file and reporting what it says, a lookup with one right answer, a scheduled heartbeat with nothing to decide."})};function g(e){return e.needsFlagship.noul}function b(e,n){return e.length>n?`${e.slice(0,n)}\u2026`:e}var h=.2;function p(e){return e==="voice"||e==="desktop"||e==="opencode"}var f=60*60*1e3;function M(e,n){if(e==="claude-code"){let t=n?.cheapModels?.[e]??n?.cheapModel;return t&&/^(claude-|haiku$|sonnet$|opus$)/.test(t)?t:void 0}if(e==="codex-cli"){let t=n?.cheapModels?.[e];return t&&/^(gpt-|o\d)/.test(t)?t:void 0}}async function v(e){let n=(s,r=null)=>({downgraded:!1,needsFlagship:r,reason:s});if(p(e.channel))return n(`${e.channel} requests retain the configured model`);if(!e.cheapModel)return n("no cheaper model configured");if(e.isFollowUp){let s=e.sessionIdleMs??0,r=e.cacheTtlMs??f;if(s<r)return n(`follow-up on a warm cache (idle ${Math.round(s/1e3)}s) \u2014 swapping would cost more than it saves`)}let t;try{t=await l(d,u(e),c,{incumbent:{needsFlagship:1},features:{agent:e.agent,channel:e.channel??"unknown"},timeoutMs:1500})}catch{return n("routing seat threw \u2014 keeping the flagship")}if(!t)return n("routing seat unavailable \u2014 keeping the flagship");let o=g(t.answers);if(t.mode!=="active")return n(`shadow \u2014 would ${o<(e.threshold??h)?"downgrade":"keep"} (${o.toFixed(2)})`,o);let i=e.threshold??h;return o>=i?n(`needs the flagship (${o.toFixed(2)})`,o):{model:e.cheapModel,downgraded:!0,needsFlagship:o,reason:`mechanical task (${o.toFixed(2)} below ${i}) \u2192 ${e.cheapModel}`}}var A=["labeled","unlabeled","closed"];function y(e){let n=r=>({downgraded:!1,needsFlagship:null,reason:r});if(p(e.channel))return n(`${e.channel} requests retain the configured model`);let t=e.eventActions??[];if(!t.length)return n("not started by a platform event");let o=e.triage?.actions??A,i=t.find(r=>!o.includes(r));if(i)return n(`"${i}" is not a triage action`);let s=M(e.tier,{cheapModels:e.triage?.models});if(!s)return n(`no triage model set for ${e.tier}`);if(e.isFollowUp){let r=e.sessionIdleMs??0,m=e.cacheTtlMs??f;if(r<m)return n(`follow-up on a warm cache (idle ${Math.round(r/1e3)}s) \u2014 keeping the session's model`)}return{model:s,downgraded:!0,needsFlagship:null,reason:`triage event (${t.join(", ")}) \u2192 ${s}`}}export{h as a,p as b,M as c,v as d,A as e,y as f};
|
|
2
|
+
//# sourceMappingURL=chunk-34TEBXFP.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as xt}from"./chunk-GTJIKXDB.js";import{
|
|
1
|
+
import{a as xt}from"./chunk-GTJIKXDB.js";import{P as Wr,W as Xr,s as Y}from"./chunk-U4AUJ6XI.js";import{f as Br,g as Hr,h as Vr,l as qr}from"./chunk-EWXY73XA.js";import{b as jr}from"./chunk-2VDO2HEK.js";import{t as Fr,u as Ur}from"./chunk-DGCYSQAZ.js";import{d as Pr,e as Mr}from"./chunk-AQASR6KR.js";import{h as he,j as Er,l as $r,m as _r,n as Ar}from"./chunk-RX5O5637.js";import{a as Rr,c as Tr,e as Ir,f as ht,h as Dr,j as Cr,k as Nr,l as bt,m as yt,n as wt}from"./chunk-5ELIX7BQ.js";import{c as Or,d as Lr}from"./chunk-CR37IINZ.js";import{a as br,c as yr}from"./chunk-KP7KDLZ2.js";import{Aa as mr,Ba as W,Ca as fe,Ea as ft,b as pt,f as cr,s as gt,u as mt,za as Oe}from"./chunk-Y3TXTZYG.js";import{a as Ce,b as me,e as dr}from"./chunk-7AB3QUGH.js";import{h as wr,i as xr,j as kr,l as vr,m as Sr}from"./chunk-MELXJ5AR.js";import{s as gr}from"./chunk-ZT4FCL5B.js";import{a as ur,b as Ne,e as pr}from"./chunk-KCS737RC.js";import{c as Le,d as fr,e as hr}from"./chunk-XVV7ZZ77.js";import{b as ne}from"./chunk-5ONH4ITT.js";import{a as lr,c as ut}from"./chunk-ILEC3IAV.js";import{a as er,j as sr,m as ir,o as ct,p as dt,s as ge,t as te,v as ar}from"./chunk-BXK5S2KK.js";import{a as tr,b as nr,d as rr,e as or}from"./chunk-4NZ4T3TQ.js";import{a as Zn}from"./chunk-7IW25T4K.js";import{a as Qn}from"./chunk-QUFIUXMQ.js";import{Cc as Jn,Fa as De,Ha as qn,I as ot,J as C,L as Te,M as $,N as pe,O as jn,R as Bn,S as st,Xa as Xn,b as In,c as Dn,d as Cn,db as zn,e as Nn,f as On,fa as Ie,fb as Kn,g as Ln,ga as Hn,gb as Xi,gc as lt,h as G,ha as Vn,i as Pn,ia as Hi,j as Mn,k as Fn,l as rt,rc as Gn,s as Un,sc as Yn,w as ji,x as Wn,y as Bi}from"./chunk-EZDHAX4Z.js";import{a as it,h as Vi}from"./chunk-KEUW6YLL.js";import{j as at,r as qi}from"./chunk-N47Y5ADQ.js";import{existsSync as zi,readdirSync as Ki,readFileSync as Gi,statSync as Yi}from"fs";import{resolve as Ji}from"path";function zr(t,e,n=Date.now(),r=7){let o=r*864e5,s=new Map;for(let i of e){let a=s.get(i.workflowId);a?a.push(i):s.set(i.workflowId,[i])}return t.map(i=>{let a=s.get(i.id)??[],d=a.filter(m=>n-m.at<=o),l=a.filter(m=>n-m.at>o&&n-m.at<=o*2),c=d.filter(m=>m.status==="failed").length,p=a.filter(m=>m.status==="paused").length,u=a.length?Math.max(...a.map(m=>m.at)):null,g=a.length?l.length>0&&d.length===0?"dormant":d.length>0&&c*2>=d.length?"failing":d.length>0?"active":"quiet":"never";return{id:i.id,name:i.name||i.id,state:g,lastRunAt:u,recent:d.length,prior:l.length,failed:c,paused:p}}).sort((i,a)=>{let d={dormant:0,failing:1,active:2,quiet:3,never:4};return d[i.state]-d[a.state]||(a.lastRunAt??0)-(i.lastRunAt??0)})}var Pe=new Map;function np(t,e=1e3){if(!zi(t))return[];let n=Ki(t).filter(s=>s.endsWith(".jsonl")).map(s=>{let i=Ji(t,s);return{path:i,mtime:Yi(i).mtimeMs}}).sort((s,i)=>i.mtime-s.mtime).slice(0,e),r=new Set(n.map(s=>s.path));for(let s of Pe.keys())r.has(s)||Pe.delete(s);let o=[];for(let{path:s,mtime:i}of n){let a=Pe.get(s);if(a&&a.mtime===i){a.summary&&o.push(a.summary);continue}let d=Qi(s,i);Pe.set(s,{mtime:i,summary:d}),d&&o.push(d)}return o}function Qi(t,e){try{let n=Gi(t,"utf-8").split(`
|
|
2
2
|
`).filter(Boolean);if(!n.length)return null;let r=JSON.parse(n[0]),o=r.run?.workflowId;if(!o)return null;let s=r.run?.status??"unknown";for(let i=n.length-1;i>=0;i--){let a=JSON.parse(n[i]),d=a.status??a.run?.status;if(d){s=d;break}}return{workflowId:o,status:s,at:e}}catch{return null}}var Kr=7,Zi={failStreak:3,disabledDays:30,missedFires:2,graceMs:15*6e4},T={routines:200,summary:160,filters:6,filterValue:60,text:120},ea=(t,e,n)=>{try{return gr(t,e,n)}catch{return null}},Gr=864e5;function ip(t){let e=t.now??Date.now(),n={...Zi,...t.thresholds},r=t.nextFire??ea,o=[];for(let a of t.crons){let d=t.cronRuns.get(a.id)??[],l=a.timezone||"UTC",c=d.map(g=>({at:Date.parse(g.startedAt),status:g.status})),p=d[0],u={id:`cron:${a.id}`,source:"cron",kind:"schedule",name:F(a.id,T.text),trigger:{schedule:F(a.schedule,T.text),timezone:l},agent:a.agent||null,enabled:a.enabled,state:a.enabled?"enabled":"disabled",nextRunAt:a.enabled?kt(a.nextRun)??kt(r(a.schedule,new Date(e),l)):null,lastRun:p?{at:p.startedAt,status:p.status,summary:ia(p.status==="success"?void 0:p.errorSummary,T.summary)}:null,lastSuccessAt:d.find(g=>g.status==="success")?.startedAt??null,consecutiveFailures:Yr(c),sampledRuns:d.length,flags:[],attention:null,recent:d.slice(0,Kr).map(g=>({at:g.startedAt,status:g.status}))};u.flags=Jr(u,c,a.schedule,l,null,e,n,r),o.push(Qr(u))}let s=new Map(zr(t.workflows.map(a=>({id:a.id,name:a.title})),t.workflowRuns,e).map(a=>[a.id,a])),i=new Map;for(let a of t.workflowRuns){let d=i.get(a.workflowId);d?d.push(a):i.set(a.workflowId,[a])}for(let a of t.workflows){let d=a.nodes.find(k=>k.type.startsWith("trigger."));if(!d||d.type!=="trigger.cron"&&d.type!=="trigger.hook")continue;let l=d.config??{},c=a.state||"active",p=c==="active",u=(i.get(a.id)??[]).slice().sort((k,S)=>S.at-k.at),g=u.map(k=>({at:k.at,status:ra(k.status)})),m=g[0],f=d.type==="trigger.cron",w=typeof l.spec=="string"?l.spec:"",x=typeof l.timezone=="string"?l.timezone:"UTC",b={id:`workflow:${a.id}`,source:"workflow",kind:f?"schedule":"event",name:F(a.title||a.id,T.text),trigger:f?{schedule:F(w,T.text),timezone:x}:{event:F(typeof l.event=="string"?l.event:"",T.text),filters:sa(l.filter,a)},agent:oa(a),enabled:p,state:c,nextRunAt:f&&p&&w?kt(r(w,new Date(e),x)):null,lastRun:m?{at:new Date(m.at).toISOString(),status:m.status}:null,lastSuccessAt:(()=>{let k=g.find(S=>S.status==="success");return k?new Date(k.at).toISOString():null})(),consecutiveFailures:Yr(g),sampledRuns:u.length,flags:[],attention:null,recent:g.slice(0,Kr).map(k=>({at:new Date(k.at).toISOString(),status:k.status}))},y=Date.parse(a.updated||a.created||"");b.flags=f?Jr(b,g,w,x,Number.isFinite(y)?y:null,e,n,r):ta(b,s.get(a.id)?.state==="dormant",Number.isFinite(y)?y:null,e,n),o.push(Qr(b))}return o.sort(na).slice(0,T.routines)}function Yr(t){let e=0;for(let n of t)if(!(n.status==="running"||n.status==="paused"||n.status==="unknown"))if(n.status==="failed"||n.status==="timeout")e++;else break;return e}function Jr(t,e,n,r,o,s,i,a){let d=[],l=e.length?e[0].at:null;if(!t.enabled){let u=eo(l,o,s,i);return u&&d.push(u),d}if(t.consecutiveFailures>=i.failStreak&&d.push({reason:"failing",detail:`${t.consecutiveFailures} failed attempts in a row`}),l===null)return d.push({reason:"never-ran",detail:"No persisted attempt"}),d;let c=new Date(l),p=null;for(let u=0;u<i.missedFires&&(p=a(n,c,r),!!p);u++)c=p;return p&&s>p.getTime()+i.graceMs&&d.push({reason:"overdue",detail:`No attempt since ${new Date(l).toISOString()}; ${i.missedFires} scheduled fires missed`}),d}function ta(t,e,n,r,o){let s=[],i=t.lastRun?Date.parse(t.lastRun.at):null;if(!t.enabled){let a=eo(i,n,r,o);return a&&s.push(a),s}return t.consecutiveFailures>=o.failStreak&&s.push({reason:"failing",detail:`${t.consecutiveFailures} failed runs in a row`}),i===null?s.push({reason:"never-ran",detail:"No run recorded for this trigger"}):e&&s.push({reason:"dormant",detail:"Fired in the prior week, silent in the last one"}),s}function eo(t,e,n,r){let o=Math.max(t??0,e??0);return o&&n-o<r.disabledDays*Gr?null:{reason:"disabled-long",detail:o?`Disabled; no activity for ${Math.floor((n-o)/Gr)} days`:"Disabled and never ran"}}function Qr(t){let e=new Set(t.flags.map(n=>n.reason));return t.attention=e.has("failing")?"critical":e.has("overdue")||e.has("dormant")||e.has("never-ran")?"warning":e.has("disabled-long")?"info":null,t}var Zr={critical:0,warning:1,info:2};function na(t,e){let n=t.attention?Zr[t.attention]:3,r=e.attention?Zr[e.attention]:3;return n-r||Number(e.enabled)-Number(t.enabled)||t.name.localeCompare(e.name)}function ra(t){switch(t){case"completed":case"ok":return"success";case"failed":return"failed";case"timeout":return"timeout";case"canceled":return"canceled";case"running":return"running";case"paused":return"paused";default:return"unknown"}}function oa(t){if(t.ownerAgent)return F(t.ownerAgent,T.text);let e=t.nodes.find(n=>n.type==="agent"&&typeof n.config?.agentId=="string"&&n.config.agentId);return e?F(String(e.config.agentId),T.text):null}function sa(t,e){let n=[],r=e?.project;if(r&&n.push(F(`project=${r}`,T.filterValue)),t&&typeof t=="object"&&!Array.isArray(t))for(let[o,s]of Object.entries(t)){let i=Array.isArray(s)?s.map(String):s==null?[]:[String(s)];i.length&&n.push(F(`${o}=${i.join(",")}`,T.filterValue))}return n.slice(0,T.filters)}function kt(t){if(!t)return null;let e=t instanceof Date?t:new Date(t);return Number.isFinite(e.getTime())?e.toISOString():null}function F(t,e){return t.length<=e?t:t.slice(0,e-3)+"..."}function ia(t,e){return t===void 0?void 0:F(t,e)}import{mkdirSync as aa,readFileSync as la,renameSync as ca,writeFileSync as da}from"fs";import{resolve as ua}from"path";function to(t){return ua(dt(t),"_state.json")}function N(t){try{let e=JSON.parse(la(to(t),"utf-8"));return{snoozed:e&&typeof e.snoozed=="object"&&e.snoozed?e.snoozed:{},...typeof e?.lastDigest=="string"?{lastDigest:e.lastDigest}:{},...e?.popped&&typeof e.popped=="object"?{popped:e.popped}:{},...typeof e?.passAt=="string"?{passAt:e.passAt}:{},...Array.isArray(e?.wanted)?{wanted:e.wanted.filter(n=>typeof n=="string")}:{}}}catch{return{snoozed:{}}}}function be(t,e){aa(dt(t),{recursive:!0});let n=to(t),r=`${n}.${process.pid}.tmp`;da(r,JSON.stringify(e,null,2)+`
|
|
3
3
|
`),ca(r,n)}function no(t,e,n,r=Date.now()){let o=N(t),s={};for(let[i,a]of Object.entries(o.snoozed))Date.parse(a)>r&&(s[i]=a);s[e]=n.toISOString(),be(t,{...o,snoozed:s})}function up(t,e){be(t,{...N(t),lastDigest:e})}function vt(t,e,n,r=Date.now()){let o=N(t),s=new Set(n),i={};for(let[d,l]of Object.entries(o.popped??{}))s.has(d)&&(i[d]=l);i[e]=new Date(r).toISOString();let a=(o.wanted??[]).filter(d=>d!==e&&s.has(d));be(t,{...o,popped:i,wanted:a})}function ro(t,e){let n=N(t);be(t,{...n,wanted:[...(n.wanted??[]).filter(r=>r!==e),e]})}function pp(t,e=Date.now()){be(t,{...N(t),popped:{},passAt:new Date(e).toISOString()})}import{existsSync as pa,readFileSync as ga}from"fs";Jn();Vi();function oo(t){let e=ur(t),n={};if(pa(e))try{n=Gn(JSON.parse(ga(e,"utf-8")))}catch{n={}}let r=lt.safeParse(n?.requests);return r.success?r.data:lt.parse(void 0)}async function yp(t,e={}){let n=(t.channels??[]).filter(r=>!it.has(r.toLowerCase().split("@")[0]));return n.length?{success:!1,error:`unknown channel ${n.map(r=>`"${r}"`).join(", ")}: use ${[...it].join(", ")}`}:Ne(r=>{let o=r.requests??={};for(let s of["enabled","channels","from","staleAfterHours","retentionDays","settleHandedBack","homeCloses","releaseOnOwnerTurn"])t[s]!==void 0&&(o[s]=t[s]);if(t.plans){let s=o.plans??={};for(let i of["enabled","stallMinutes","maxNudges","approveKinds","disabledAgents","requireForWork","requireOverMinutes"])t.plans[i]!==void 0&&(s[i]=t.plans[i])}if(t.headlines?.enabled!==void 0&&((o.headlines??={}).enabled=t.headlines.enabled),t.catchPromises){let s=o.catchPromises??={};for(let i of["enabled","dailyCap"])t.catchPromises[i]!==void 0&&(s[i]=t.catchPromises[i])}if(t.autoResend){let s=o.autoResend??={};for(let i of["enabled","afterMinutes","holdMaxHours"])t.autoResend[i]!==void 0&&(s[i]=t.autoResend[i])}if(t.flow){let s=o.flow??={};for(let i of["timeZone","days"])t.flow[i]!==void 0&&(s[i]=t.flow[i])}if(t.checkers){let s=o.checkers??={};for(let i of["enabled","checkEveryMinutes"])t.checkers[i]!==void 0&&(s[i]=t.checkers[i])}},{configPath:e.configPath,reload:e.reload})}import{existsSync as V,readdirSync as Da,readFileSync as $t,statSync as Ca}from"fs";import{dirname as So,resolve as R}from"path";import{randomBytes as ao}from"crypto";import{existsSync as fa,mkdirSync as ha,readdirSync as ba,readFileSync as ya,renameSync as lo,unlinkSync as wa,writeFileSync as xa}from"fs";import{resolve as co}from"path";function so(t){return[...t.account?["--account",t.account]:[],...t.store?["--store",t.store]:[]]}var ma=t=>t.trim().split(`
|
|
4
4
|
`).pop()?.slice(0,300)||"no output";async function io(t,e,n,r=xt){let o=await r(t.bin,[...so(t),"send","text","--to",e,"--message",n,"--no-preview"],{timeoutMs:6e4});return o.code===0?{ok:!0}:{ok:!1,error:`wacli send failed: ${ma(o.stderr||o.stdout)}`}}async function kp(t,e,n,r,o=xt){return(await o(t.bin,[...so(t),"--read-only","media","download","--chat",e,"--id",n,"--output",r],{timeoutMs:12e4})).code===0}var ka=2e3,va=t=>io(t.wacli,t.to,t.text);function St(t){return co(t,".agentx","whatsapp-triage","drafts")}var Sa=t=>/^[a-z0-9-]{8,64}$/.test(t),Me=(t,e)=>co(St(t),`${e}.json`);function uo(t,e){ha(St(t),{recursive:!0});let n=Me(t,e.id),r=`${n}.${process.pid}.tmp`;xa(r,JSON.stringify(e,null,2)+`
|
|
@@ -960,4 +960,4 @@ Document the arguments, commands, or files the skill expects. Example:
|
|
|
960
960
|
claude-code ${Tn(t)} --arg value
|
|
961
961
|
\`\`\`
|
|
962
962
|
`}Jn();var Mi={maxPixels:12e5,timeoutMs:5e3,intervalMs:100,changeThreshold:.015,stableMs:400,regions:{},buffer:{enabled:!1,seconds:10,fps:2,region:"screen",maxPixels:3e5}};function Fi(t){return{...Mi,...t??{},regions:{...t?.regions??{}},buffer:{...Mi.buffer,...t?.buffer??{}}}}function kb(t){try{return Fi(Yn(t).screen)}catch{return Fi(void 0)}}var Zu=/^[a-z][\w-]*$/,Ui=["window","screen","menubar","notifications"];function _e(t,e,n,r){let o=Number(t);if(t===""||t===null||!Number.isFinite(o)||!n(o))throw new Error(`${e} must be ${r}`);return o}var tt=(t,e)=>_e(t,e,n=>Number.isInteger(n)&&n>0,"a whole number above 0");function Wi(t){let e=typeof t=="string"?t.split(",").map(Number):[t?.x,t?.y,t?.width,t?.height].map(Number);if(e.length!==4||!e.every(Number.isFinite)||e[2]<=0||e[3]<=0)throw new Error("a region is x,y,width,height in screen points, with width and height above 0");return{x:e[0],y:e[1],width:e[2],height:e[3]}}function vb(t,e){let n={...t??{}};if("maxPixels"in e&&(n.maxPixels=tt(e.maxPixels,"maxPixels")),"timeoutMs"in e&&(n.timeoutMs=tt(e.timeoutMs,"timeoutMs")),"intervalMs"in e&&(n.intervalMs=tt(e.intervalMs,"intervalMs")),"stableMs"in e&&(n.stableMs=_e(e.stableMs,"stableMs",o=>Number.isInteger(o)&&o>=0,"a whole number, 0 or more")),"changeThreshold"in e&&(n.changeThreshold=_e(e.changeThreshold,"changeThreshold",o=>o>=0&&o<=1,"between 0 and 1")),e.regions&&typeof e.regions=="object"){let o={...n.regions??{}};for(let[s,i]of Object.entries(e.regions)){if(!Zu.test(s))throw new Error(`region name "${s}" must be lowercase letters, digits, - or _`);i===null?delete o[s]:o[s]=Wi(i)}n.regions=o}if(e.buffer&&typeof e.buffer=="object"){let o=e.buffer,s={...n.buffer??{}};"enabled"in o&&(s.enabled=!!o.enabled),"seconds"in o&&(s.seconds=_e(o.seconds,"buffer.seconds",i=>i>0&&i<=120,"above 0 and at most 120")),"fps"in o&&(s.fps=_e(o.fps,"buffer.fps",i=>i>0&&i<=10,"above 0 and at most 10")),"maxPixels"in o&&(s.maxPixels=tt(o.maxPixels,"buffer.maxPixels")),"region"in o&&(s.region=String(o.region).trim()),n.buffer=s}let r=n.buffer?.region;if(r!==void 0&&!Ui.includes(r)&&!n.regions?.[r])try{Wi(r)}catch{throw new Error(`buffer.region "${r}" is not a region \u2014 use ${[...Ui,...Object.keys(n.regions??{})].join(", ")}, or x,y,w,h`)}return n}export{zr as a,np as b,en as c,$c as d,_c as e,Nm as f,Om as g,Lm as h,Fm as i,Um as j,Wm as k,vs as l,Ss as m,jm as n,Hm as o,X as p,Es as q,T as r,ip as s,As as t,Gm as u,Qm as v,Ts as w,Zm as x,Is as y,ef as z,xe as A,Yc as B,tf as C,nf as D,Cs as E,kp as F,va as G,Ap as H,go as I,N as J,up as K,pp as L,oo as M,yp as N,J as O,ig as P,To as Q,Co as R,ed as S,of as T,td as U,sf as V,af as W,nn as X,Os as Y,df as Z,on as _,od as $,sd as aa,mf as ba,nl as ca,rl as da,cg as ea,dg as fa,dl as ga,mg as ha,Vs as ia,Xs as ja,xf as ka,ce as la,$f as ma,zs as na,Rf as oa,bg as pa,yg as qa,ys as ra,qt as sa,yc as ta,I as ua,ii as va,ih as wa,ah as xa,Yd as ya,uh as za,pi as Aa,ph as Ba,gh as Ca,wh as Da,su as Ea,au as Fa,xh as Ga,xg as Ha,kg as Ia,vg as Ja,Sg as Ka,Eg as La,$g as Ma,_g as Na,Ag as Oa,Tg as Pa,Ig as Qa,Ng as Ra,Og as Sa,Lg as Ta,Fg as Ua,Ug as Va,Wg as Wa,jg as Xa,Bg as Ya,Hg as Za,Vg as _a,Zg as $a,Lt as ab,em as bb,tm as cb,ye as db,we as eb,gu as fb,Th as gb,Ih as hb,Dh as ib,Ch as jb,bn as kb,Nh as lb,Ft as mb,Ut as nb,ze as ob,Wl as pb,Bl as qb,im as rb,jt as sb,Bt as tb,Hl as ub,Vl as vb,rs as wb,as as xb,am as yb,zl as zb,lm as Ab,tc as Bb,oc as Cb,Ht as Db,ic as Eb,ls as Fb,z as Gb,Si as Hb,Ei as Ib,$i as Jb,wn as Kb,Uh as Lb,vu as Mb,Ai as Nb,Ri as Ob,Yh as Pb,Jh as Qb,Fu as Rb,Qh as Sb,Ii as Tb,ps as Ub,rb as Vb,Vu as Wb,sb as Xb,ib as Yb,Ke as Zb,Sm as _b,Qt as $b,Im as ac,db as bc,ub as cc,pb as dc,gb as ec,mb as fc,fb as gc,hb as hc,bb as ic,yb as jc,Mi as kc,Fi as lc,kb as mc,Ui as nc,vb as oc};
|
|
963
|
-
//# sourceMappingURL=chunk-
|
|
963
|
+
//# sourceMappingURL=chunk-3XUAIA7U.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as N}from"./chunk-
|
|
1
|
+
import{d as N}from"./chunk-EPOQUX4G.js";import{b as A}from"./chunk-IFUAP7UD.js";import{d as w,f as y,i as b,j as v,l as R,t as S,w as j}from"./chunk-EZDHAX4Z.js";R();j();var g=e=>typeof e=="string"?e.trim():"";function l(e){let r=e.latest?`${b(e.latest.value,e.unit)} for ${w({start:e.latest.periodStart,end:e.latest.periodEnd})}${e.latest.value===null&&e.latest.error?` (${e.latest.error})`:""}`:"no reading yet",c=[e.ownerAgent?`owner ${e.ownerAgent}`:null,e.rhythm,e.target?`target ${v(e.target,e.unit)}`:null,e.tags.length?`tags ${e.tags.join(", ")}`:null,S(e.source)].filter(Boolean);return`- ${e.id} "${e.name}" [${y[e.status]}]: ${r}. ${c.join("; ")}.${e.archivedAt?" Archived.":""}`}function k(e){let r=new Date(e.raisedAt).toISOString().slice(0,10);return e.cardId?`Missed-twice card ${e.cardId}, raised ${r} for ${e.raisedFor}${e.reviewer?`, reviewer ${e.reviewer}`:""}.`:`Missed-twice card not raised (${r}): ${e.error??"unknown reason"}.`}function E(e){return(e.readings??[]).map(r=>` ${w({start:r.periodStart,end:r.periodEnd})}: ${b(r.value,e.unit)}${r.value===null&&r.error?` (${r.error})`:""}, by ${r.by}${r.note?` (${r.note})`:""}`)}async function M(e,r){let c=r.fetch??fetch,m=r.daemonUrl.replace(/\/$/,""),s=(g(e.action)||"list").toLowerCase();try{if(s==="list"){let t=Array.isArray(e.tags)?e.tags.join(","):g(e.tags),i=new URLSearchParams({...t?{tags:t}:{},...e.archived?{archived:"1"}:{}}),n=await c(`${m}/numbers${i.size?`?${i}`:""}`,{signal:AbortSignal.timeout(1e4)}),o=await n.json().catch(()=>({}));if(!n.ok)return`Error: ${o?.error||`HTTP ${n.status}`}`;let a=o.numbers??[];return a.length?`${a.length} number${a.length===1?"":"s"}:
|
|
2
2
|
${a.map(l).join(`
|
|
3
3
|
`)}`:"No numbers are tracked on this node."}if(s==="review"){let t=Array.isArray(e.tags)?e.tags.join(","):g(e.tags),i=new URLSearchParams({review:"1",...t?{tags:t}:{}}),n=await c(`${m}/numbers?${i}`,{signal:AbortSignal.timeout(1e4)}),o=await n.json().catch(()=>({}));if(!n.ok)return`Error: ${o?.error||`HTTP ${n.status}`}`;let a=o.numbers??[];return a.length?`${a.length} number${a.length===1?"":"s"} to review, worst first:
|
|
4
4
|
${a.map(h=>[l(h),...h.card?[` ${k(h.card)}`]:[]].join(`
|
|
@@ -7,4 +7,4 @@ ${a.map(h=>[l(h),...h.card?[` ${k(h.card)}`]:[]].join(`
|
|
|
7
7
|
`)}if(!["create","record","archive"].includes(s))return`Error: unknown action "${s}": use list, review, show, create, record or archive.`;let d=r.env??process.env,f=N(e,d);if(!f)return"Error: couldn't tell which agent you are. Pass callerAgentId.";let{callerAgentId:P,...T}=e,$=await c(`${m}/numbers`,{method:"POST",headers:{"Content-Type":"application/json",...A(d)},body:JSON.stringify({...T,action:s,agentId:f.agentId}),signal:AbortSignal.timeout(1e4)}),p=await $.json().catch(()=>({}));if(!$.ok)return`Error: ${p?.error||`HTTP ${$.status}`}`;let u=p.number;if(s==="create"){let t=u.source.kind==="manual"?` Record each reading with {action:"record", id:"${u.id}", value:<n>, from:"YYYY-MM-DD", to:"YYYY-MM-DD"}.`:" The daemon reads it once per period.";return`Number ${$.status===201?"made":"updated"}:
|
|
8
8
|
${l(u)}${t}`}return s==="archive"?`Number ${u.id} is no longer tracked. Its readings stay.`:`Reading kept:
|
|
9
9
|
${l(u)}`}catch(d){return`Error: couldn't reach the daemon (${d?.message??d}).`}}export{l as a,k as b,E as c,M as d};
|
|
10
|
-
//# sourceMappingURL=chunk-
|
|
10
|
+
//# sourceMappingURL=chunk-5OEW46QP.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ze,b as k,c as D,d as ea,e as fe,f as he,g as H,h as be,i as L,j as N,n as aa,o as ta,p as ra,q as na}from"./chunk-EFGAPAYZ.js";import{e as Ve,i as Qe}from"./chunk-QAWKN2N4.js";import{b as me}from"./chunk-DODL5POT.js";import{Kb as Ge,Wa as Ke,Xa as Ye,Ya as Je,_a as Xe,c as Le,ua as _,za as qe}from"./chunk-
|
|
1
|
+
import{a as Ze,b as k,c as D,d as ea,e as fe,f as he,g as H,h as be,i as L,j as N,n as aa,o as ta,p as ra,q as na}from"./chunk-EFGAPAYZ.js";import{e as Ve,i as Qe}from"./chunk-QAWKN2N4.js";import{b as me}from"./chunk-DODL5POT.js";import{Kb as Ge,Wa as Ke,Xa as Ye,Ya as Je,_a as Xe,c as Le,ua as _,za as qe}from"./chunk-3XUAIA7U.js";import{a as V}from"./chunk-IMLAPB7G.js";import{k as Be}from"./chunk-EWXY73XA.js";import{b as Q}from"./chunk-2VDO2HEK.js";import{c as Ne,e as We}from"./chunk-LQE73AZR.js";import{a as Z,b as Ue}from"./chunk-TCBIAKGS.js";import{b as Fe}from"./chunk-MRIVENBY.js";import{ia as G}from"./chunk-Y3TXTZYG.js";import{b as ue}from"./chunk-7AB3QUGH.js";import{a as K,b as X}from"./chunk-KCS737RC.js";import{s as ge,u as Oe}from"./chunk-BXK5S2KK.js";import{b as He}from"./chunk-SQJ3IHNL.js";import{c as De,d as Me}from"./chunk-OWNQ2FD4.js";import{a as je}from"./chunk-ROLSSYXE.js";import{Cc as xe,J as le,Lb as Ee,M as F,S as Za,Sb as at,Va as ce,Wa as Pe,gb as et,nc as pe,rc as q,sc as Re}from"./chunk-EZDHAX4Z.js";import{existsSync as Y,readFileSync as xa,writeFileSync as ga,appendFileSync as lt,mkdirSync as ct}from"fs";import{dirname as pt,resolve as M}from"path";import{fileURLToPath as xt}from"url";import{hostname as gt}from"os";import{spawn as ut}from"child_process";var ve=`:root {
|
|
2
2
|
/* --- Brand (agentina) --------------------------------------------- */
|
|
3
3
|
--ax-blue: #2979FF;
|
|
4
4
|
--ax-blue-d: #1B5FD9;
|
|
@@ -2903,4 +2903,4 @@ tr:hover td { background: var(--bg-hover); }
|
|
|
2903
2903
|
${r}`).all(a,...t,...n).map(i=>({id:i.id,state:i.state,channel:i.channel,agentId:i.agent_id,text:i.text,createdAt:i.created_at})):[]}function Qo(e,a){return Ua(e,a,ce,"ORDER BY created_at")}function Zo(e,a,t=50){return Ua(e,a,[...ce,...Pe],"ORDER BY created_at DESC, rowid DESC LIMIT ?",Math.max(1,Math.min(t,500)))}at();var ze="member:",pr=90,xr="members",gr="tailscale-user-login",ur=400,mr=60*60*1e3;function fr(e){let a=e.scopes.find(t=>t.startsWith(ze));return a?a.slice(ze.length):null}function qa(e,a){if(!e)return null;let t=a.verify(e),r=t?fr(t):null;return t&&r?{rec:t,personId:r}:null}function ii(e,a){let t=e.people().find(s=>s.id===a);if(!t)return{ok:!1,error:`No person "${a}". Add them first: agentx people add ${a} --name "\u2026"`};let{token:r,record:n}=e.tokens.create({name:`${t.name} (machine not paired yet)`,scopes:[`${ze}${t.id}`],expiresInDays:pr}),{code:o,expiresAt:i}=e.codes.create({token:r,tokenId:n.id,name:t.id});return e.members.log({person:t.id,device:n.id,event:"invited"}),{ok:!0,code:o,expiresAt:i,tokenId:n.id,person:t}}var hr=Math.round(Ne/6e4);function br(e){return e==="client"?"Your project":"My work"}function si(e){let a=br(e.person.role),t=e.person.role==="client"?`I use AgentX to keep track of the work I do for you. It has a page for you, "${a}": what you asked us for, and where each request stands.`:`I use AgentX to give our AI agents their jobs. It has a page for you, "${a}": what you asked the agents for, and where each request stands.`;return[`Hi ${e.person.name},`,"",t,"","To open it:","1. Accept the Tailscale share I sent you. Tailscale is a small program that connects your computer to mine, privately.",`2. Open ${e.origin.replace(/\/+$/,"")}/member in Edge or Chrome, give your computer a name and type this code: ${We(e.code)}`,` The code works once, for ${hr} minutes. If it has stopped working, tell me and I will send you a new one.`,"","I then approve your machine, and the page opens by itself."].join(`
|
|
2904
2904
|
`)}var vr="The private network says someone else is connecting from this machine. Ask the person who invited you for a new code.",wr="Too many machines are waiting for the owner's answer. Try again later.",Fa="That code didn't work. Check it, or ask the person who invited you for a new one.",Ka=(e,a)=>{let t=e.headers[a];return(Array.isArray(t)?t[0]:t||"").trim()};function Ya(e){let a=e.socket?.remoteAddress||"";return a==="127.0.0.1"||a==="::1"||a==="::ffff:127.0.0.1"}function yr(e){if(!Ya(e))return null;let a=Ka(e,gr).toLowerCase();return a?a.slice(0,80):null}function kr(e){let a=e.socket?.remoteAddress||"unknown";if(!Ya(e))return a;let t=Ka(e,"x-forwarded-for").split(",").pop().trim();return/^[0-9a-fA-F:.]{2,45}$/.test(t)?t:a}function $r(e){return typeof e=="string"?e.replace(/[^\p{L}\p{N} ._'()-]/gu," ").replace(/\s+/g," ").trim().slice(0,60):""}function _r(e){return e.identities.map(Ee).filter(a=>!!a&&a.channel==="tailscale").map(a=>a.value)}async function di(e,a){let t=Date.now(),r=a.now??Date.now,n=a.log??(b=>console.log(b)),o=kr(e),i=a.limiter.retryAfter(o);if(i>0)return n(`[member] pair-code refused from ${o}: locked out for ${i}s more`),{status:429,body:{error:"too many attempts",retryAfter:i},retryAfter:i};let s=null,d="";try{let b=await Q(e,2048);s=b.code,d=$r(b.machine)}catch{}let l=a.codes.redeem(s),c=l?qa(l.token,a.tokens):null;if(await Cr(t,a.minMs??ur),!l||!c)return a.limiter.fail(o),n(`[member] pair-code failed from ${o}`),{status:401,body:{error:Fa}};a.limiter.succeed(o);let{rec:m,personId:g}=c,u=a.people().find(b=>b.id===g);if(!u)return a.tokens.revoke(m.id),a.members.log({person:g,device:m.id,event:"refused",address:o,detail:"person no longer listed"}),n(`[member] pair-code for ${g} refused from ${o}: person no longer listed`),{status:403,body:{error:Fa}};let x=yr(e),f=_r(u);if(f.length&&(!x||!f.includes(x)))return a.tokens.revoke(m.id),a.members.log({person:g,device:m.id,event:"refused",address:o,detail:`network login ${x??"missing"}; expected ${f.join(" or ")}`}),n(`[member] ${g}: pairing from ${o} refused: the network says "${x??"nobody"}", expected ${f.join(" or ")}`),{status:403,body:{error:vr}};let A=d||"Unnamed machine",y=u.name.slice(0,40),v=Oe(a.root,{title:`New machine for ${y}`,ask:`From ${o}, ${x?`network login ${x}`:"no network login reported"}. Machine name, as typed there: "${A}". Let it see their own work?`,recommend:`Yes if ${y} told you they just paired this machine. No if you did not expect it.`,if_silent:"discard",raised_by:xr},{now:r()});return v.ok?(a.members.add({tokenId:m.id,personId:g,name:A,state:"pending",cardId:v.card.id,address:o,...x?{network:x}:{},createdAt:new Date(r()).toISOString()}),a.members.log({person:g,device:m.id,event:"paired",address:o,detail:A}),n(`[member] ${g} paired "${A}" from ${o}; waiting for the owner (card ${v.card.id})`),{status:200,body:{person:g,name:A,state:"pending"},token:l.token}):(a.tokens.revoke(m.id),a.members.log({person:g,device:m.id,event:"refused",address:o,detail:v.error}),n(`[member] ${g}: pairing from ${o} refused: ${v.error}`),{status:503,body:{error:wr}})}var de="this machine is not paired",Sr="waiting for the owner to approve this machine";function Ja(e){return e?e.status==="decided"?e.verdict??null:e.status==="expired"?"no":null:null}function li(e,a){return a.state==="pending"&&a.cardId?Ja(ge(e,a.cardId)):null}function ci(e,a,t){let r=a.now??Date.now,n=a.log??(c=>console.log(c)),o=qa(e,a.tokens);if(!o)return{ok:!1,status:401,error:de};let{rec:i,personId:s}=o,d=a.members.byToken(i.id);if(!d||d.state==="removed"||d.personId!==s)return{ok:!1,status:401,error:de};if(a.people&&!a.people().some(c=>c.id===s))return Xa(a,i.id,"person no longer listed"),n(`[member] ${s}: "${d.name}" ended: person no longer listed`),{ok:!1,status:401,error:de};if(d.state==="pending"){let c=d.cardId?ge(a.root,d.cardId):null,m=Ja(c);if(m==="yes")d=a.members.update(i.id,{state:"active",approvedAt:new Date(r()).toISOString()})??d,a.members.log({person:s,device:i.id,event:"approved",detail:c?.decided_by}),n(`[member] ${s}: "${d.name}" approved`);else if(m==="no"){let g=c?.status==="expired"?"the owner did not answer in time":"the owner said no";return a.tokens.revoke(i.id),a.members.update(i.id,{state:"removed",removedAt:new Date(r()).toISOString(),removedReason:g}),a.members.log({person:s,device:i.id,event:"refused",detail:g}),n(`[member] ${s}: "${d.name}" refused: ${g}`),{ok:!1,status:401,error:de}}else return{ok:!1,status:403,error:Sr,waiting:!0}}let l=d.lastSeenAt?Date.parse(d.lastSeenAt):0;return t&&(r()-l>=mr||d.lastAddress!==t)&&(d=a.members.update(i.id,{lastSeenAt:new Date(r()).toISOString(),lastAddress:t})??d,a.members.log({person:s,device:i.id,event:"signed-in",address:t})),{ok:!0,device:d,personId:s,rec:i}}function Xa(e,a,t="removed by the owner"){let r=e.members.byToken(a);if(!r)return null;e.tokens.revoke(a);let n=e.members.update(a,{state:"removed",removedAt:new Date((e.now??Date.now)()).toISOString(),removedReason:t});return e.members.log({person:r.personId,device:a,event:"removed",detail:t}),n}function pi(e,a){return e.members.devices(a).filter(t=>t.state!=="removed").map(t=>Xa(e,t.tokenId,"person removed by the owner")).filter(t=>!!t)}async function Cr(e,a){let t=e+a-Date.now();t>0&&await new Promise(r=>setTimeout(r,t))}var Ga=["gitlab","github"];function Ar(e,a,t){let r=String(a||"").trim().toLowerCase();if(!Ga.includes(r))throw new Error(`Request status works on ${Ga.join(" and ")}, not on "${a}".`);e.requestStatus=e.requestStatus&&typeof e.requestStatus=="object"?e.requestStatus:{};let n=Array.isArray(e.requestStatus.channels)?e.requestStatus.channels.map(o=>String(o).toLowerCase()):[];return e.requestStatus.channels=t?[...new Set([...n,r])]:n.filter(o=>o!==r),`request status on ${r} is ${t?"on":"off"}`}function ui(e){return Array.isArray(e?.requestStatus?.channels)?e.requestStatus.channels.map(a=>String(a).toLowerCase()):[]}function mi(e){let{summary:a}=Z(t=>Ar(t,e?.channel,!!e?.enabled));return{summary:a}}var hi="https://myaccount.google.com/apppasswords";function bi(e){let a=e.split("@")[1]?.toLowerCase()??"";if(a==="gmail.com"||a==="googlemail.com")return{imapHost:"imap.gmail.com",imapPort:993,smtpHost:"smtp.gmail.com",smtpPort:465}}function vi(e){let a=e.user&&e.user!==e.address?{user:e.user}:{};return{agent:e.agent,address:e.address,imap:{host:e.imapHost,port:e.imapPort,secure:e.imapPort===993,...a,password:`\${${e.passwordEnv}}`},smtp:{host:e.smtpHost,port:e.smtpPort,secure:e.smtpPort===465},allowFrom:e.allowFrom,send:e.send}}function wi(e){return`EMAIL_${e.toUpperCase().replace(/[^A-Z0-9]/g,"_")}_PASSWORD`}function $i(e){return`${e.name} <${e.from}> via ${e.host}:${e.port}`}async function _i(e,a){return Be({host:e.host,port:e.port,secure:e.secure,user:e.user,password:e.password},{name:e.name,address:e.from},a,{"Auto-Submitted":"auto-generated"})}function Si(e,a){return{to:e,subject:`${a.name}: test mail`,text:[`This is a test mail from ${a.name}.`,"","If it reached you, AgentX can send mail through this sender.","You can ignore it."].join(`
|
|
2905
2905
|
`)}}function Ai(e){return new Set(Object.entries(e).filter(([,a])=>a?.wiki?.absorb?.enabled===!1).map(([a])=>a))}function Ti(e,a){return a.only?{agents:[a.only],skipped:[]}:{agents:e.filter(t=>!a.off.has(t)),skipped:e.filter(t=>a.off.has(t))}}function Ii(e,a){return`absorb is off for this agent (agents.${e}.wiki.absorb.enabled); skipped.${e===a?" It reads the wiki notes inbox, so the inbox was not read.":""} Use --agent ${e} to run it anyway.`}function zi(e,a){if(a){if(!e.wiki?.absorb)return;delete e.wiki.absorb.enabled,Object.keys(e.wiki.absorb).length===0&&delete e.wiki.absorb,Object.keys(e.wiki).length===0&&delete e.wiki;return}e.wiki??={},e.wiki.absorb??={},e.wiki.absorb.enabled=!1}var Tr="https://ntfy.sh";function Ei(e){return{enabled:!!e?.enabled,server:e?.server||Tr,topicSet:!!e?.topic,tokenSet:!!e?.token}}function Ri(e,a){let t={...e??{}};if("enabled"in a&&(t.enabled=!!a.enabled),"server"in a){let r=String(a.server).trim().replace(/\/+$/,"");if(!/^https?:\/\/\S+$/.test(r))throw new Error("ntfy server must be an http(s) URL");t.server=r}if("topic"in a){let r=String(a.topic).trim();if(!r)throw new Error("ntfy topic cannot be empty");t.topic=r}if("token"in a){let r=String(a.token??"").trim();r?t.token=r:delete t.token}if(t.enabled&&!t.topic)throw new Error("set a topic before enabling ntfy");return t}Za();function Va(e){return/^(agent|person):/.test(e)?F(e):`person:${e}`}function ji(e){let a=(e?.projects??[]).filter(t=>t?.id);return a.map(t=>({id:t.id,name:t.name?.trim()||t.id,client:Le(t.id,a),...t.pm?{pm:F(t.pm)}:{},...t.lead?{lead:Va(t.lead)}:{},team:[...new Set((t.team??[]).filter(Boolean).map(F))]})).sort((t,r)=>t.client.localeCompare(r.client)||t.name.localeCompare(r.name)||t.id.localeCompare(r.id))}function Hi(e,a,t){if(!t.lead&&!t.team?.length)return;let r=new Set(Object.keys(e.business?.orgChart||{})),n=new Set((e.people||[]).map(i=>String(i.id))),o={id:a,name:a,client:"",...t.lead?{lead:Va(t.lead)}:{},team:(t.team??[]).map(F)};return Ir([o],r,n)}function Ir(e,a,t){let r=n=>{let o=le(n);return o.kind==="agent"?a.has(o.id)?void 0:`"${o.id}", which is not an agent in business.orgChart`:t.has(o.id)?void 0:`"${o.id}", which is not a person in people`};for(let n of e){if(n.lead){if(le(n.lead).kind!=="person")return`Project ${n.name} is led by "${n.lead}"; a lead is a person (person:<id>), the PM is the agent`;let o=r(n.lead);if(o)return`Project ${n.name} is led by ${o}`}for(let o of n.team){let i=r(o);if(i)return`Project ${n.name} has ${i} in its team`}}}export{ve as a,da as b,ye as c,nt as d,ot as e,it as f,ua as g,mt as h,_n as i,Sn as j,Cn as k,ko as l,Co as m,Ba as n,Yo as o,Jo as p,Rn as q,On as r,It as s,Et as t,ke as u,Dn as v,Mn as w,Rt as x,Bn as y,Un as z,Fn as A,Vo as B,Qo as C,Zo as D,pr as E,xr as F,ii as G,hr as H,br as I,si as J,vr as K,wr as L,yr as M,kr as N,$r as O,_r as P,di as Q,Ja as R,li as S,ci as T,Xa as U,pi as V,Ga as W,Ar as X,ui as Y,mi as Z,hi as _,bi as $,vi as aa,wi as ba,$i as ca,_i as da,Si as ea,Ai as fa,Ti as ga,Ii as ha,zi as ia,Ei as ja,Ri as ka,Va as la,ji as ma,Hi as na,Ir as oa,Qt as pa,go as qa,vo as ra,wo as sa};
|
|
2906
|
-
//# sourceMappingURL=chunk-
|
|
2906
|
+
//# sourceMappingURL=chunk-6HCCMU57.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as g}from"./chunk-
|
|
1
|
+
import{e as g}from"./chunk-V75JESS5.js";async function $(e,i,r,n,o={}){let a=o.retrieve??g,c=o.perEntry??2,s=o.maxArticles??8,f=o.queryChars??1500,h=new Map;for(let t of e){let l=[];try{l=await a(t.content.slice(0,f),i,r,{pool:n,maxCandidates:c,maxHops:1,maxArticles:c*2,stage:"absorb-covering"})}catch{}for(let u of l){let p=h.get(u.path);p?(p.hop=Math.min(p.hop,u.hop),p.entries.includes(t.id)||p.entries.push(t.id)):h.set(u.path,{...u,entries:[t.id]})}}return[...h.values()].sort((t,l)=>t.hop-l.hop||l.entries.length-t.entries.length||t.path.localeCompare(l.path)).slice(0,s)}function x(e){if(e.length===0)return"";let i=e.map(r=>{let n=`### ${r.meta.title} \u2014 ${r.meta.type||"untyped"} (${r.path})`,o=`Found for entries: ${r.entries.join(", ")}${r.hop>0?" (linked from a match)":""}`,a=r.meta.related?.length?`Related: ${r.meta.related.join(", ")}`:"";return[n,o,a,"",r.content].filter(c=>c!=="").join(`
|
|
2
2
|
`)}).join(`
|
|
3
3
|
|
|
4
4
|
---
|
|
@@ -14,4 +14,4 @@ These ${e.length} articles were found by searching the wiki for each entry below
|
|
|
14
14
|
|
|
15
15
|
${i}
|
|
16
16
|
`}var d=/\bhttps?:\/\/[^\s<>"'`)\]]+/gi,y=/\[\[([^\]|]+)(?:\|[^\]]*)?\]\]/g,w=/(?<![\w-])(?=[0-9a-f]*[0-9])(?=[0-9a-f]*[a-f])[0-9a-f]{7,40}(?![\w-])/gi,k=/(?<![\w.,:/-])\d+(?:[.,:\-/]\d+)*(?![\w])/g,C=/^\s*\d+[.)]\s/gm;function A(e){let i=[...e.matchAll(d)].map(s=>s[0].replace(/[.,;:!?'"]+$/,"")),r=[...e.matchAll(y)].map(s=>s[1].trim()),n=e.replace(d," ").replace(y," ").replace(C," "),o=[...n.matchAll(w)].map(s=>s[0].toLowerCase()),c=[...n.replace(w," ").matchAll(k)].map(s=>v(s[0]));return{commits:m(o),urls:m(i),wikilinks:m(r),numbers:m(c)}}function R(e,i){let r=A(e),n=A(i),o=i.toLowerCase(),a=[];for(let t of r.commits)!o.includes(t)&&!n.commits.some(l=>l.startsWith(t)||t.startsWith(l))&&a.push(`commit ${t}`);let c=t=>t.toLowerCase().replace(/\/+$/,""),s=new Set(n.urls.map(c));for(let t of r.urls)s.has(c(t))||a.push(`link ${t}`);let f=new Set(n.wikilinks.map(t=>t.toLowerCase()));for(let t of r.wikilinks)f.has(t.toLowerCase())||a.push(`link [[${t}]]`);let h=new Set(n.numbers);for(let t of r.numbers)h.has(t)||a.push(`number ${t}`);return a}function v(e){return/^\d{1,3}(,\d{3})+$/.test(e)?e.replace(/,/g,""):e}function m(e){return[...new Set(e)]}function L(e,i){if(i.some(n=>n.path===e.path))return e.path;let r=b(e.title);return r?i.find(n=>b(n.title)===r)?.path??e.path:e.path}function b(e){return(e||"").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim()}export{$ as a,x as b,A as c,R as d,L as e};
|
|
17
|
-
//# sourceMappingURL=chunk-
|
|
17
|
+
//# sourceMappingURL=chunk-6X7SABYJ.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Cc as b,sc as m}from"./chunk-EZDHAX4Z.js";b();function w(t){let e=typeof t.node=="string"?t.node:"",n=typeof t.token=="string"?t.token:"";if(!e||!n)try{let o=m(t.config);e||(e=o.dashboard?.daemonUrl||""),n||(n=o.dashboard?.token||"")}catch{}return e||(e="http://localhost:18800"),{baseUrl:e.replace(/\/+$/,""),token:n}}async function d(t,e,n){let o={Accept:"application/json"};t.token&&(o.Authorization=`Bearer ${t.token}`);let r=await fetch(`${t.baseUrl}${e}`,{headers:o,signal:n});if(!r.ok)throw new Error(`GET ${e} \u2192 HTTP ${r.status}`);return await r.json()}function R(t,e){return d(t,"/agents",e)}async function S(t,e){return(await d(t,"/api/processes",e)).processes??[]}function P(t,e){return d(t,"/crons",e)}async function h(t,e,n,o){let r={Accept:"application/json","Content-Type":"application/json"};t.token&&(r.Authorization=`Bearer ${t.token}`);let s=await fetch(`${t.baseUrl}${e}`,{method:"POST",headers:r,body:JSON.stringify(n),signal:o}),a=await s.text(),i;try{i=a?JSON.parse(a):{}}catch{i={raw:a}}if(!s.ok)throw new Error(i?.error||`POST ${e} \u2192 HTTP ${s.status}`);return i}function A(t,e,n="tui"){return h(t,"/api/processes/kill",{...e,reason:n})}function C(t,e,n,o){return h(t,"/task",{agent:e,message:n,context:o??{channel:"tui",chatId:"tui:operator"}})}async function $(t,e,n,o={}){let r={Accept:"text/event-stream","Content-Type":"application/json"};t.token&&(r.Authorization=`Bearer ${t.token}`);let s=await fetch(`${t.baseUrl}/task`,{method:"POST",headers:r,body:JSON.stringify({agent:e,message:n,stream:!0,context:{channel:o.channel??"chat-cli",chatId:o.chatId??"chat-cli:operator"}}),signal:o.signal});if(!s.ok||!s.body){let g=await s.text().catch(()=>"");throw new Error(`POST /task (stream) \u2192 HTTP ${s.status}${g?`: ${g.slice(0,200)}`:""}`)}let a=s.body.getReader(),i=new TextDecoder,u={content:""},c="";try{for(;;){let{done:g,value:p}=await a.read();if(g)break;c+=i.decode(p,{stream:!0});let l;for(;(l=c.indexOf(`
|
|
2
2
|
|
|
3
3
|
`))>=0;){let k=c.slice(0,l);c=c.slice(l+2);let f=x(k);f&&T(f,o,u)}}}finally{try{a.releaseLock()}catch{}}return u}function T(t,e,n){let{event:o,data:r}=t;switch(o){case"text":r?.text&&(n.content+=r.text,e.onText?.(r.text));break;case"thinking":r?.text&&e.onThinking?.(r.text);break;case"tool":e.onTool?.(r);break;case"done":typeof r?.content=="string"&&(n.content=r.content),n.usage=r?.usage,n.duration=r?.duration;break;case"error":n.error=r?.error,n.errorKind=r?.errorKind;break}}function x(t){let e="message",n="";for(let r of t.split(`
|
|
4
4
|
`))r.startsWith("event: ")?e=r.slice(7).trim():r.startsWith("data: ")&&(n=r.slice(6));if(!n)return null;let o;try{o=JSON.parse(n)}catch{o=n}return{event:e,data:o}}export{w as a,R as b,S as c,P as d,A as e,C as f,$ as g};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-7ATCEK7R.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{cb as p,gb as g}from"./chunk-EZDHAX4Z.js";import{q as d,r as N}from"./chunk-N47Y5ADQ.js";g();N();var m=["done","skipped"];function I(t,e=Date.now()){return t.state==="active"&&typeof t.waitUntil=="number"&&t.waitUntil>e?` waits until ${new Date(t.waitUntil).toISOString().slice(0,16).replace("T"," ")}Z`:""}var A=1e3;function h(t){t.exec(`
|
|
2
2
|
CREATE TABLE IF NOT EXISTS request_plans (
|
|
3
3
|
request_id TEXT PRIMARY KEY,
|
|
4
4
|
created_by TEXT NOT NULL,
|
|
@@ -59,4 +59,4 @@ import{bb as p,fb as g}from"./chunk-PZ2F6J2E.js";import{q as d,r as N}from"./chu
|
|
|
59
59
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);this.db.transaction(()=>{i.run(e,a,l),n.forEach((s,u)=>{let E=u===0,T=E&&s.agentId===a&&s.kind!=="message";r.run(e,u+1,s.name,s.kind,s.agentId,s.doneWhen,E?"active":"pending",s.needsApproval?1:0,s.message??null,s.toChannel??null,s.toChat??null,s.toAccount??null,s.checkUrl??null,s.checkContains??null,s.stallMinutes??null,T?l:null,l,s.checkCount??null)}),this.event(e,null,"created",`${n.length} steps, written by ${a}`,l)})()}get(e){let a=this.db.prepare("SELECT * FROM request_plans WHERE request_id = ?").get(e);return a?o(a):null}steps(e){return this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? ORDER BY idx").all(e).map(c)}step(e,a){let n=this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? AND idx = ?").get(e,a);return n?c(n):null}listActive(){return this.db.prepare("SELECT * FROM request_plans WHERE state = 'active' ORDER BY created_at, rowid").all().map(o)}updateStep(e,a,n){let l=[],i=[];for(let[r,s]of Object.entries(n)){let u=R[r];!u||s===void 0||(l.push(`${u} = ?`),i.push(typeof s=="boolean"?s?1:0:s))}l.length&&this.db.prepare(`UPDATE request_plan_steps SET ${l.join(", ")} WHERE request_id = ? AND idx = ?`).run(...i,e,a)}finish(e,a,n){return this.db.prepare("UPDATE request_plans SET state = ?, finished_at = ? WHERE request_id = ? AND state = 'active'").run(a,n,e).changes>0}markNotified(e,a){this.db.prepare("UPDATE request_plans SET notified_at = ? WHERE request_id = ?").run(a,e)}awaitingSummary(){return this.db.prepare("SELECT * FROM request_plans WHERE state = 'done' AND notified_at IS NULL ORDER BY finished_at").all().map(o)}event(e,a,n,l,i){this.db.prepare("INSERT INTO request_plan_events (request_id, step, at, kind, detail) VALUES (?, ?, ?, ?, ?)").run(e,a,i,n,l.replace(/\s+/g," ").trim().slice(0,A))}continues(e,a){let n=this.db.prepare("SELECT turns, cost_usd, told_at FROM request_plan_continues WHERE goal_key = ? AND day = ?").get(e,a);return n?{turns:n.turns,costUsd:n.cost_usd,toldAt:n.told_at??null}:{turns:0,costUsd:0,toldAt:null}}addContinue(e,a,n){this.db.prepare(`INSERT INTO request_plan_continues (goal_key, day, turns, cost_usd, told_at) VALUES (?, ?, ?, ?, ?)
|
|
60
60
|
ON CONFLICT(goal_key, day) DO UPDATE SET turns = turns + excluded.turns, cost_usd = cost_usd + excluded.cost_usd,
|
|
61
61
|
told_at = COALESCE(excluded.told_at, told_at)`).run(e,a,n.turns??0,n.costUsd??0,n.toldAt??null)}events(e,a=200){return this.db.prepare("SELECT request_id, step, at, kind, detail FROM request_plan_events WHERE request_id = ? ORDER BY at DESC, rowid DESC LIMIT ?").all(e,a).reverse().map(n=>({requestId:n.request_id,step:n.step??null,at:n.at,kind:n.kind,detail:n.detail}))}stepEvents(e,a,n,l=200){return this.db.prepare("SELECT request_id, step, at, kind, detail FROM request_plan_events WHERE request_id = ? AND step = ? AND kind = ? ORDER BY at DESC, rowid DESC LIMIT ?").all(e,a,n,l).reverse().map(i=>({requestId:i.request_id,step:i.step??null,at:i.at,kind:i.kind,detail:i.detail}))}},q=p;export{m as a,I as b,b as c,_ as d,q as e};
|
|
62
|
-
//# sourceMappingURL=chunk-
|
|
62
|
+
//# sourceMappingURL=chunk-CR37IINZ.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{q as _,r as W}from"./chunk-2AXFYDWF.js";import{b as Y,c as I,d as O}from"./chunk-AQASR6KR.js";import{b as F}from"./chunk-MEFPXHQJ.js";import{a as E}from"./chunk-
|
|
1
|
+
import{q as _,r as W}from"./chunk-2AXFYDWF.js";import{b as Y,c as I,d as O}from"./chunk-AQASR6KR.js";import{b as F}from"./chunk-MEFPXHQJ.js";import{a as E}from"./chunk-IQNKEUEL.js";import{b as L}from"./chunk-KEXBEUSU.js";import{createHash as ee}from"crypto";import{existsSync as H,readdirSync as te,readFileSync as re,writeFileSync as ne}from"fs";import{resolve as P}from"path";function be(n,r,s,t,o,i,c="",p="",m=""){return Z(r,s,t,o,i,c,p,m)}function Z(n,r,s,t,o,i="",c="",p=""){let m=r?`
|
|
2
2
|
## Worldview
|
|
3
3
|
|
|
4
4
|
${r}
|
|
@@ -249,4 +249,4 @@ ${u}`}var x="memory-promoter",oe=["project","reference","feedback"],K="_memory-p
|
|
|
249
249
|
Re-emit the FULL corrected JSON object \u2014 same structure, fixed issues, valid JSON only.`:n,y=await t(`${a}/task`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:r.viaAgent,message:h,freshSession:s===null,context:{channel:"api",chatId:r.chatId??"memory-promote"}}),signal:i.signal});if(!y.ok){let f=await y.text().catch(()=>"");throw new Error(`agent /task ${y.status}: ${f.slice(0,500)}`)}let w=await y.json();if(w.error)throw new Error(`agent reported error: ${w.error}`);let b=String(w.content??"").trim();if(!b)throw new Error("agent returned empty content");return b}if(!r.model)throw new Error("callPromotionLlm: viaAgent or model is required");let p=process.env.ANTHROPIC_API_KEY;if(!p)throw new Error("ANTHROPIC_API_KEY not set; use --via <agentId> instead");let m=[{role:"user",content:n}];s&&(m.push({role:"assistant",content:"(previous attempt; will retry with corrections)"}),m.push({role:"user",content:`Your previous response failed validation: ${s}
|
|
250
250
|
Re-emit the FULL corrected JSON object.`}));let u=await t(me,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":p,"anthropic-version":ge},body:JSON.stringify({model:r.model,max_tokens:8e3,messages:m}),signal:i.signal});if(!u.ok){let a=await u.text().catch(()=>"");throw new Error(`anthropic API ${u.status}: ${a.slice(0,500)}`)}let d=await u.json(),e=(Array.isArray(d.content)?d.content:[]).filter(a=>a?.type==="text").map(a=>a.text).join(`
|
|
251
251
|
`).trim();if(!e)throw new Error("anthropic API returned no text content");return e}finally{clearTimeout(c)}}async function Se(n={}){let r=n.wikiDir??P(process.cwd(),".agentx","wiki"),s=n.memoryRoot??P(process.cwd(),".agentx"),t=n.log??(()=>{}),o=n.now??Date.now(),i={candidates:[],clusters:[],proposed:[],skipped:[],gaps:[],warnings:[],errors:[],dryRun:!n.commit},c=new E(r,(...l)=>t(l.map(String).join(" "))),p=c.rebuildIndex(),m=z(r),u=[...ce(s),...n.extraCandidates??[]];if(i.candidates=de(u,p,m,{types:n.types,sinceMs:n.sinceMs,agentFilter:n.agentFilter,now:o,max:n.max}),i.candidates.length===0)return t("no unpromoted memories in window"),i;if(i.clusters=le(i.candidates),i.dryRun)return i;let d=p.articles.map(l=>({title:l.title,path:l.path,type:l.type})),g=c.getWorldview()??"",e=n.budgetTokens??ue,a=i.clusters,h=D(x,a,d,g);for(;R(h)>e&&a.length>1;)a=a.slice(0,-1),h=D(x,a,d,g);if(R(h)>e)return i.errors.push(`judge prompt (~${R(h)} tokens) exceeds the ${e}-token budget even with one cluster`),i;a.length<i.clusters.length&&i.warnings.push(`token budget: judged ${a.length} of ${i.clusters.length} clusters; the rest wait for the next run`);let y=a.flatMap(l=>l.candidates),w=new Set(y.map(l=>l.stamp)),b=n.chatId??`memory-promote-${new Date(o).toISOString().slice(0,10)}`,f=B(await G(h,{...n,chatId:b}),w);if("error"in f&&(t(`parse failed (${f.error}) \u2014 retrying with feedback`),f=B(await G(h,{...n,chatId:b},f.error),w)),"error"in f)return i.errors.push(`LLM response unusable after retry: ${f.error}`),i;i.warnings.push(...f.warnings),i.gaps=f.gaps;let v=new Date(o).toISOString(),k=[],T=new Map(y.map(l=>[l.stamp,l]));for(let l of f.articles){let A=c.readArticle(l.path);if(A&&!c.canWrite(A.meta,x)){i.errors.push(`write denied for "${l.path}" (owned by ${A.meta.owner??"?"})`);continue}let M=fe(l.promotedFrom,T),S={id:Y(o,l.path),createdAt:v,status:"pending",article:l,evidence:M,...A?{replaces:{lastUpdated:A.meta.lastUpdated,contentHash:V(A.content)}}:{}};I(r,S),i.proposed.push({id:S.id,path:l.path,title:l.title,type:l.type,stamps:l.promotedFrom,agents:M.agents,occurrences:M.occurrences});for(let X of l.promotedFrom)k.push({stamp:X,decision:"proposed",article:l.path,proposal:S.id,at:v})}for(let l of f.skipped)k.push({stamp:l.stamp,decision:"skipped",reason:l.reason,at:v}),i.skipped.push(l);return k.length&&C(r,k),i}var ue=6e4;function R(n){return Math.ceil(n.length/4)}function V(n){return ee("sha256").update(n).digest("hex").slice(0,16)}var he=600;function ye(n){return n.startsWith("review:")?"review":n.startsWith(j)?"failure":"memory"}function fe(n,r){let s=[];for(let t of n){let o=r.get(t);o&&s.push({stamp:t,kind:ye(t),agentId:o.agentId,type:o.memory.type,name:o.memory.name,description:o.memory.description,...o.occurrences?{occurrences:o.occurrences}:{},...o.sessions?.length?{sessions:o.sessions}:{},...o.tasks?.length?{tasks:o.tasks}:{},...o.failure?{failure:o.failure}:{},...o.memory.author?{author:o.memory.author}:{},...o.memory.taskId?{taskId:o.memory.taskId}:{},updatedAt:o.memory.updatedAt,excerpt:o.memory.body.slice(0,he)})}return{agents:[...new Set(s.map(t=>t.agentId))].sort(),occurrences:Math.max(1,...s.map(t=>t.occurrences??1)),sources:s}}function Ee(n,r,s={}){let t=O(n,r);if(!t)return{ok:!1,error:`no proposal "${r}"`};if(t.status!=="pending")return{ok:!1,error:`proposal "${r}" is already ${t.status}`};let o=s.log??(()=>{}),i=new E(n,(...a)=>o(a.map(String).join(" "))),{article:c}=t,p=i.readArticle(c.path);if(!s.force){if(p&&!t.replaces)return{ok:!1,error:`"${c.path}" was created after this proposal; review it, then approve with --force`};if(p&&t.replaces&&V(p.content)!==t.replaces.contentHash)return{ok:!1,error:`"${c.path}" changed since this proposal; review it, then approve with --force`}}let m=s.now??Date.now(),u=new Date(m).toISOString().slice(0,10);if(!i.writeArticle(c.path,{title:c.title,type:L(c.type)?c.type:void 0,related:c.related,tags:c.tags,owner:x,access:"public",created:p?.meta.created??u,lastUpdated:u,sources:ae(p?.meta.sources,c.promotedFrom)},c.content,x))return{ok:!1,error:`write denied for "${c.path}" (owned by ${p?.meta.owner??"?"})`};let g=new Date(m).toISOString();C(n,c.promotedFrom.map(a=>({stamp:a,decision:"promoted",article:c.path,proposal:r,at:g}))),i.rebuildIndex();let e={...t,status:"approved",decidedBy:s.by??"operator",decidedAt:g};return I(n,e),{ok:!0,proposal:e}}function Oe(n,r,s={}){let t=O(n,r);if(!t)return{ok:!1,error:`no proposal "${r}"`};if(t.status!=="pending")return{ok:!1,error:`proposal "${r}" is already ${t.status}`};let o=new Date(s.now??Date.now()).toISOString();C(n,t.article.promotedFrom.map(c=>({stamp:c,decision:"rejected",article:t.article.path,proposal:r,reason:s.reason,at:o})));let i={...t,status:"rejected",decidedBy:s.by??"operator",decidedAt:o,...s.reason?{reason:s.reason}:{}};return I(n,i),{ok:!0,proposal:i}}export{be as a,x as b,oe as c,K as d,q as e,ie as f,$ as g,ae as h,ce as i,z as j,C as k,le as l,B as m,de as n,G as o,Se as p,R as q,ye as r,fe as s,Ee as t,Oe as u};
|
|
252
|
-
//# sourceMappingURL=chunk-
|
|
252
|
+
//# sourceMappingURL=chunk-DGCYSQAZ.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{a as _,b as O,c as q,d as B,f as L,g as z,h as T,i as b,j as v,k as w}from"./chunk-
|
|
1
|
+
import{a as _,b as O,c as q,d as B,f as L,g as z,h as T,i as b,j as v,k as w}from"./chunk-MELXJ5AR.js";import{a as R,b as P,c as E,d as k,e as D}from"./chunk-KCS737RC.js";import{existsSync as K,readFileSync as Y}from"fs";import J from"cronstrue";var A={sun:0,sunday:0,mon:1,monday:1,tue:2,tuesday:2,tues:2,wed:3,wednesday:3,thu:4,thursday:4,thurs:4,fri:5,friday:5,sat:6,saturday:6},S={morning:{h:9,m:0},afternoon:{h:14,m:0},evening:{h:18,m:0},night:{h:22,m:0},noon:{h:12,m:0},midnight:{h:0,m:0}};function g(n){try{return J.toString(n,{use24HourTimeFormat:!1})}catch{return n}}function V(n){if(/\b(noon|midday)\b/.test(n))return S.noon;if(/\bmidnight\b/.test(n))return S.midnight;let e=n.match(/\b(?:at|by|@)\s*(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\b/);if(e){let r=parseInt(e[1],10),i=e[2]?parseInt(e[2],10):0,a=e[3];return a==="pm"&&r<12&&(r+=12),a==="am"&&r===12&&(r=0),r>23||i>59?null:{h:r,m:i}}return null}function H(n){let e=n.trim().toLowerCase();if(!e)return null;let r;if(r=e.match(/\bevery\s+(\d+)\s*(minutes|mins|m)\b/)){let t=parseInt(r[1],10);return t<1||t>59?null:{cron:`*/${t} * * * *`,human:g(`*/${t} * * * *`),matched:r[0]}}if(/\bevery\s+minute\b/.test(e))return{cron:"* * * * *",human:g("* * * * *"),matched:"every minute"};if(r=e.match(/\bevery\s+(\d+)\s*(hours|hrs|h)\b/)){let t=parseInt(r[1],10);return t<1||t>23?null:{cron:`0 */${t} * * *`,human:g(`0 */${t} * * *`),matched:r[0]}}if(/\b(every hour|hourly)\b/.test(e))return{cron:"0 * * * *",human:g("0 * * * *"),matched:"every hour"};let i=V(e),a=null;for(let[t,o]of Object.entries(S))if(!(t==="noon"||t==="midnight")&&new RegExp(`\\b(every\\s+)?${t}s?\\b`).test(e)){a=o;break}let d=i||a,m=e.match(/\b(first|1st|2nd|3rd|last|(\d+)(?:st|nd|rd|th)?)\s+(day\s+)?of\s+(every|each|the)\s+month\b/);if(m){let t=m[1],o=1;if(t==="last"||(/^\d+(st|nd|rd|th)?$/.test(t)?o=parseInt(t,10):t==="first"||t==="1st"?o=1:t==="2nd"?o=2:t==="3rd"&&(o=3),o<1||o>31))return null;let u=d||{h:9,m:0},p=`${u.m} ${u.h} ${o} * *`;return{cron:p,human:g(p),matched:m[0]}}let s=[],y=Object.keys(A).join("|"),l=new RegExp(`\\b(?:every|on|each|by)\\s+((?:${y})s?(?:\\s*(?:,|and|&)\\s*(?:${y})s?)*)\\b`),c=e.match(l);if(c){let t=c[1];for(let o of Object.keys(A))if(new RegExp(`\\b${o}s?\\b`).test(t)){let u=A[o];s.includes(u)||s.push(u)}}if(s.length){let t=d||{h:9,m:0};s.sort((p,h)=>p-h);let o=s.join(","),u=`${t.m} ${t.h} * * ${o}`;return{cron:u,human:g(u),matched:`on ${o}`}}if(/\b(weekday|workday|business day)s?\b/.test(e)){let t=d||{h:9,m:0},o=`${t.m} ${t.h} * * 1-5`;return{cron:o,human:g(o),matched:"weekdays"}}if(/\bweekends?\b/.test(e)){let t=d||{h:9,m:0},o=`${t.m} ${t.h} * * 0,6`;return{cron:o,human:g(o),matched:"weekends"}}if(/\b(every day|daily|each day)\b/.test(e)||a){let t=d||{h:9,m:0},o=`${t.m} ${t.h} * * *`;return{cron:o,human:g(o),matched:a&&Object.entries(S).find(([,u])=>u===a)?.[0]||"daily"}}if(i){let t=`${i.m} ${i.h} * * *`;return{cron:t,human:g(t),matched:`at ${i.h}:${String(i.m).padStart(2,"0")}`}}return null}function G(n,e){return`${n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)||"job"}-${e}`}var Z=new Set(["cron","heartbeat","api","a2a","mesh"]),Q=160;function f(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function x(n,e=Q){let r=n.replace(/\s+/g," ").trim();return r.length>e?`${r.slice(0,e-1)}\u2026`:r}function ee(n){let e=R(n);if(!K(e))throw new Error(`config not found at ${e}`);return JSON.parse(Y(e,"utf-8"))}function te(n,e){return n?.agents?.[e]?.admin===!0}function ne(n,e,r){return te(n,r.agentId)||e?.createdBy===r.agentId}function re(n,e){let r=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${r}. Agents manage only schedules they created (unless configured admin).`}function oe(n,e){let r=f(n.notify);if(r!=="none"){if(r&&r!=="here"){let i=r.split(":");return i.length<2||!i[0]||!i[1]?"invalid":{channel:i[0],chatId:i.slice(1).join(":")}}if(e.channel&&e.chatId&&!Z.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function ie(n,e,r){let i=e.timezone||"UTC",a=e.enabled&&!w(e)?v(b(e.schedule,i,r),i):"\u2014",d=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",m=[`- ${n} [${d}] ${e.schedule} \u2014 ${T(e.schedule)} (${i})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${a}`];return e.notify&&m.push(` notify: ${e.notify.channel} ${e.notify.chatId} ${z(e)}`),e.command?m.push(` command: ${x(String(e.command))}`):e.prompt&&m.push(` prompt: ${x(String(e.prompt))}`),m.join(`
|
|
2
2
|
`)}async function F(n,e,r){let i=n?.notifications?.destination;if(!i?.channel||!i?.chatId)return"No operator notification destination is configured (notifications.destination); the operator must check `agentx schedule list`.";if(!e.notifyOperator)return"Operator notification is unavailable in this context.";try{return await e.notifyOperator({channel:i.channel,chatId:i.chatId,accountId:i.accountId},r),"The operator has been notified."}catch(a){return`Could not notify the operator (${a?.message??a}); the request is still recorded.`}}async function he(n,e,r={}){let i=(f(n.action)||"list").toLowerCase(),a=r.now?r.now():new Date,d;try{d=ee(r.configPath)}catch(c){return`Error: ${c.message}`}let m=d.crons||{};if(i==="list"){let c=n.mine===!0,t=Object.entries(m).filter(([,o])=>!c||e&&o?.createdBy===e.agentId);return t.length?t.map(([o,u])=>ie(o,u,a)).join(`
|
|
3
3
|
`):c?"You have no schedules.":"No schedules."}if(!e?.agentId)return"Error: caller agent is unknown (AGENTX_AGENT_ID not set). Pass callerAgentId.";if(!d.agents?.[e.agentId])return`Error: caller "${e.agentId}" is not an agent on this node.`;let s=f(n.id),y=c=>P(c,{configPath:r.configPath,reload:r.reload});if(i==="create"){let c=f(n.when),t=f(n.prompt);if(!c||!t)return"Error: create needs `when` (plain English) and `prompt`.";let o=H(c);if(!o)return`Error: couldn't parse "${c}". ${O}.`;let u=f(n.agent)||e.agentId;if(!d.agents?.[u])return`Error: agent "${u}" not found on this node.`;let p=f(n.timezone)||_;if(!B(p))return`Error: unknown timezone "${p}".`;let h=s||G(o.matched,u);if(!q(h))return`Error: invalid id "${h}" (letters, digits, "-" and "_" only).`;if(m[h])return`Error: a schedule "${h}" already exists. Pick another \`id\`.`;let $=oe(n,e);if($==="invalid")return'Error: `notify` must be "here", "none", or "channel:chatId".';let I=f(n.report);if(I&&I!=="always"&&I!=="exceptions")return'Error: `report` must be "always" or "exceptions".';let M={action:"create",requestedBy:e.agentId,requestedAt:a.toISOString()},U=L({parsed:o,agent:u,prompt:t,timezone:p,notify:$,report:I,enabled:!1,createdBy:e.agentId,approval:M}),N=await y(j=>E(j,`crons.${h}`,U));if(!N.success)return`Error: ${N.error}`;let C=v(b(o.cron,p,a),p),W=[`Schedule approval requested by ${e.agentId}`,`Create: ${h}`,`When: ${o.human} \u2014 cron \`${o.cron}\` (${p})`,`Next fire: ${C}`,`Agent: ${u}`,$?`${I==="exceptions"?"Exceptions":"Results"} and failures go to: ${$.channel} ${$.chatId}${$.channel==="voice"?" (as a push notification)":""}`:"Results go to: run log only (no chat)",`Prompt: ${x(t,400)}`,"",`Approve: agentx schedule approve ${h}`,`Reject: agentx schedule reject ${h}`].join(`
|
|
4
4
|
`),X=await F(d,r,W);return[`Requested schedule "${h}": ${o.human} (cron ${o.cron}, ${p}); next fire would be ${C}.`,"It is saved DISABLED and will not run until the operator approves it.",X].join(`
|
|
5
5
|
`)}if(!s)return`Error: ${i} needs \`id\`.`;let l=m[s];if(!l)return`Error: schedule "${s}" not found.`;if(!ne(d,l,e))return re(s,l);if(i==="pause"||i==="resume"){let c=i==="resume";if(c&&w(l))return`"${s}" is still awaiting operator approval; it can't be resumed until approved.`;if(l.enabled===c)return`"${s}" is already ${c?"active":"paused"}.`;let t=await y(o=>E(o,`crons.${s}.enabled`,c));return t.success?`"${s}" ${c?"resumed":"paused"}.`:`Error: ${t.error}`}if(i==="delete"){if(w(l)&&l.approval.requestedBy===e.agentId){let h=await y($=>D($,`crons.${s}`));return h.success?`Withdrew the pending request "${s}".`:`Error: ${h.error}`}if(w(l))return`"${s}" is a creation request still awaiting approval; only its requester or the operator (\`agentx schedule reject ${s}\`) can drop it.`;if(l.approval?.action==="delete")return`Deletion of "${s}" is already awaiting approval.`;let c={action:"delete",requestedBy:e.agentId,requestedAt:a.toISOString()},t=await y(h=>{if(!k(h,`crons.${s}`))throw new Error(`schedule "${s}" not found`);E(h,`crons.${s}.approval`,c)});if(!t.success)return`Error: ${t.error}`;let o=l.timezone||"UTC",u=[`Schedule approval requested by ${e.agentId}`,`Delete: ${s}`,`When: ${T(l.schedule)} \u2014 cron \`${l.schedule}\` (${o})`,`Next fire: ${l.enabled?v(b(l.schedule,o,a),o):"\u2014 (paused)"}`,`Agent: ${l.agent}`,"",`Approve: agentx schedule approve ${s}`,`Reject: agentx schedule reject ${s}`].join(`
|
|
6
6
|
`),p=await F(d,r,u);return[`Deletion of "${s}" requested. It keeps its current state until the operator approves.`,p].join(`
|
|
7
7
|
`)}return`Error: unknown action "${i}". Use list, create, pause, resume or delete.`}function fe(n,e=process.env){let r=f(e.AGENTX_AGENT_ID)||f(n.callerAgentId);if(!r)return null;let i=!!(f(e.AGENTX_CHANNEL)&&f(e.AGENTX_CHAT_ID)),a=f(i?e.AGENTX_CHANNEL:n.channel),d=f(i?e.AGENTX_CHAT_ID:n.chatId),m=f(n.accountId);return{agentId:r,channel:a,chatId:d,...m?{accountId:m}:{}}}export{H as a,G as b,he as c,fe as d};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-EPOQUX4G.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Cc as $,Zb as S}from"./chunk-EZDHAX4Z.js";import{randomBytes as x}from"crypto";import{existsSync as b,mkdirSync as k,readdirSync as M,readFileSync as j,renameSync as E,unlinkSync as y,writeFileSync as C}from"fs";import{resolve as c}from"path";function m(t){return c(t,".agentx","email")}function u(t,e){k(c(t,".."),{recursive:!0});let r=`${t}.${process.pid}.tmp`;C(r,JSON.stringify(e,null,2)+`
|
|
2
2
|
`,{mode:384}),E(r,t)}function g(t){try{return JSON.parse(j(t,"utf-8"))}catch{return null}}var D=t=>c(m(t),"threads.json");function w(t){return g(D(t))??{}}function I(t,e){return w(t)[e.toLowerCase()]}function L(t,e){let r=w(t);r[e.to.toLowerCase()]=e,u(D(t),r)}var h=(t,e)=>c(m(t),"cursors",`${e}.json`);function z(t,e){return g(h(t,e))}function B(t,e,r){u(h(t,e),r)}var T=2e4,_=t=>c(m(t),"drafts"),N=t=>/^[a-z0-9-]{8,64}$/.test(t),a=(t,e)=>c(_(t),`${e}.json`);function U(t,e,r=Date.now()){let n=e.text.trim().slice(0,T);if(!n)throw new Error("empty reply");let s={...e,text:n,id:`${r.toString(36)}-${x(4).toString("hex")}`,status:"pending",created_at:new Date(r).toISOString()};return u(a(t,s.id),s),s}function v(t,e){return N(e)?g(a(t,e)):null}function V(t,e){let r=_(t);return b(r)?M(r).filter(n=>n.endsWith(".json")).map(n=>v(t,n.slice(0,-5))).filter(n=>!!n&&(!e||n.status===e)).sort((n,s)=>n.created_at.localeCompare(s.created_at)):[]}async function W(t,e,r,n){let s=v(t,e);if(!s||s.status!=="pending")return{ok:!1,error:`no email reply "${e}" is waiting`};let i=`${a(t,e)}.${process.pid}.${x(3).toString("hex")}.claim`;try{E(a(t,e),i)}catch{return{ok:!1,error:`email reply "${e}" is already being decided`}}let d=n.text!==void 0&&n.text.trim()!==""&&n.text.trim()!==s.text,o={...s,...d?{text:n.text.trim().slice(0,T),edited:!0}:{},decided_by:n.by??"operator",decided_at:new Date(n.now??Date.now()).toISOString()};if(r==="no")o.status="rejected";else{let f=await n.send(o).catch(p=>({ok:!1,error:String(p?.message??p)}));if(!f.ok){u(a(t,e),{...s,error:f.error});try{y(i)}catch{}return{ok:!1,error:`not sent: ${f.error}`}}o.status="sent",delete o.error}u(a(t,e),o);try{y(i)}catch{}return{ok:!0,draft:o}}$();function l(t,e){return(t??"").replace(/\$\{(\w+)\}/g,(r,n)=>e[n]??"")}function P(t,e=process.env){let r={host:t.imap.host,port:t.imap.port,secure:t.imap.secure,user:l(t.imap.user,e)||t.address,password:l(t.imap.password,e)},n={host:t.smtp.host,port:t.smtp.port,secure:t.smtp.secure,user:l(t.smtp.user,e)||r.user,password:l(t.smtp.password,e)||r.password};return{imap:r,smtp:n}}async function R(t,e,r,n=process.env){let{smtp:s}=P(t,n);if(!s.password)throw new Error(`no SMTP password for ${t.address}: set it in .env`);return J(s,{name:e,address:t.address},r,{"Auto-Submitted":"auto-replied"})}async function J(t,e,r,n){let{default:s}=await import("nodemailer"),i=s.createTransport({host:t.host,port:t.port,secure:t.secure,auth:{user:t.user,pass:t.password},connectionTimeout:2e4,greetingTimeout:2e4,socketTimeout:6e4});try{return(await i.sendMail({from:e,to:r.toName?{name:r.toName,address:r.to}:r.to,subject:r.subject,text:r.text,...r.inReplyTo?{inReplyTo:r.inReplyTo}:{},...r.references?{references:r.references}:{},headers:n})).messageId}finally{i.close()}}function G(t,e){return async r=>{let n=t?.channels?.email?.accounts?.[r.account];if(!n)return{ok:!1,error:`no email account "${r.account}" in agentx.json`};let s=S.safeParse(n);if(!s.success)return{ok:!1,error:`email account "${r.account}": ${s.error.issues[0]?.message}`};let i=s.data,d=i.name||t?.agents?.[r.agent]?.name||r.agent;return await R(i,d,{to:r.to,toName:r.to_name,subject:r.subject,inReplyTo:r.in_reply_to,references:r.references,text:r.text},e),{ok:!0}}}export{I as a,L as b,z as c,B as d,U as e,v as f,V as g,W as h,P as i,R as j,J as k,G as l};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-EWXY73XA.js.map
|