agentix-cli 0.137.1 → 0.137.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/{board-dashboard-VXQYQY22.js → board-dashboard-2A6VSQ7V.js} +2 -2
  2. package/dist/{chunk-Z5OD225A.js → chunk-DIE6XXJF.js} +2 -2
  3. package/dist/chunk-GFKLKPPY.js +4 -0
  4. package/dist/chunk-GFKLKPPY.js.map +1 -0
  5. package/dist/chunk-PBP3D2BM.js +2 -0
  6. package/dist/chunk-PBP3D2BM.js.map +1 -0
  7. package/dist/{chunk-LK4YO2FE.js → chunk-PNITKKDR.js} +2 -2
  8. package/dist/{chunk-BWXRAPTX.js → chunk-Q72TK3DO.js} +2 -2
  9. package/dist/{chunk-K6UV4A2T.js → chunk-QY5YUHGW.js} +2 -2
  10. package/dist/{chunk-ADQUFEPJ.js → chunk-RTKSSFX2.js} +67 -67
  11. package/dist/chunk-RTKSSFX2.js.map +1 -0
  12. package/dist/{chunk-36HFRKIH.js → chunk-VDG6Y5L3.js} +1 -1
  13. package/dist/cli.js +1 -1
  14. package/dist/cli.js.map +1 -1
  15. package/dist/index.js +1 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/net-family-OFHIZDHS.js +2 -0
  18. package/dist/ntfy-W56TUC5C.js +2 -0
  19. package/dist/{program-MJ6S6X6T.js → program-AMQ7JGHO.js} +5 -5
  20. package/dist/{program-MJ6S6X6T.js.map → program-AMQ7JGHO.js.map} +1 -1
  21. package/dist/push-B2GNI3VQ.js +2 -0
  22. package/dist/push-bridge-F4PCXWJF.js +2 -0
  23. package/dist/wiki-enrich-6776OMUB.js +2 -0
  24. package/dist/wiki-enrich-6776OMUB.js.map +1 -0
  25. package/package.json +1 -1
  26. package/dist/chunk-ADQUFEPJ.js.map +0 -1
  27. package/dist/chunk-KQ7KWFZY.js +0 -4
  28. package/dist/chunk-KQ7KWFZY.js.map +0 -1
  29. package/dist/ntfy-ZDNBUEIX.js +0 -2
  30. package/dist/push-HVGOC4VN.js +0 -2
  31. package/dist/push-bridge-NAQ7WQJX.js +0 -2
  32. package/dist/wiki-enrich-6CSUPULH.js +0 -2
  33. /package/dist/{board-dashboard-VXQYQY22.js.map → board-dashboard-2A6VSQ7V.js.map} +0 -0
  34. /package/dist/{chunk-Z5OD225A.js.map → chunk-DIE6XXJF.js.map} +0 -0
  35. /package/dist/{chunk-LK4YO2FE.js.map → chunk-PNITKKDR.js.map} +0 -0
  36. /package/dist/{chunk-BWXRAPTX.js.map → chunk-Q72TK3DO.js.map} +0 -0
  37. /package/dist/{chunk-K6UV4A2T.js.map → chunk-QY5YUHGW.js.map} +0 -0
  38. /package/dist/{chunk-36HFRKIH.js.map → chunk-VDG6Y5L3.js.map} +0 -0
  39. /package/dist/{ntfy-ZDNBUEIX.js.map → net-family-OFHIZDHS.js.map} +0 -0
  40. /package/dist/{push-HVGOC4VN.js.map → ntfy-W56TUC5C.js.map} +0 -0
  41. /package/dist/{push-bridge-NAQ7WQJX.js.map → push-B2GNI3VQ.js.map} +0 -0
  42. /package/dist/{wiki-enrich-6CSUPULH.js.map → push-bridge-F4PCXWJF.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{C as Ot,D as ro,E as oo,F as so,H as io,I as lo,a as qr,b as zr,c as Fr,d as Ur,e as Ae,f as Wr,g as Gr,h as jt,j as Xr,p as Kr,q as Jr,r as Vr,s as Yr,t as Qr,x as Zr,y as eo}from"./chunk-K6UV4A2T.js";import"./chunk-H4NSB54D.js";import"./chunk-MTX4UPNB.js";import{a as to}from"./chunk-5NTWGUSJ.js";import{a as ao,b as no}from"./chunk-NZQBS7GN.js";import"./chunk-QAWKN2N4.js";import{a as Br}from"./chunk-BKHIR2YJ.js";import{a as qe,b as z,c as I,h as pe,i as Pt,j as se,k as K,l as $t,m as Nr,n as Dr,o as Hr}from"./chunk-B2QYMUTD.js";import{a as C}from"./chunk-GIQKQD2B.js";import{a as Or}from"./chunk-LNY6N73E.js";import{$a as Pr,A as ur,B as St,Ba as Tr,C as mr,Ca as Ar,D as Et,Da as Cr,E as Tt,F as At,G as fr,H as gr,K as xr,L as br,La as Ir,M as vr,Na as Te,Sa as Mr,T as U,U as yr,Ua as Be,V as wr,Va as Ct,Wa as It,Xa as Mt,Ya as Lt,Za as Lr,_a as Rr,a as er,ab as Rt,c as bt,cb as $r,d as _a,e as tr,fb as jr,i as vt,l as Ze,n as ar,z as _t,za as Er}from"./chunk-LK4YO2FE.js";import{h as Qn,i as Zn}from"./chunk-Z2QOQBUS.js";import"./chunk-GTJIKXDB.js";import{a as H,b as kr,c as _r,g as Sr}from"./chunk-7LN4VKDU.js";import{a as hr}from"./chunk-IMLAPB7G.js";import{p as nr,t as rr}from"./chunk-S2GAEH2F.js";import{a as ir,b as yt,d as lr,e as dr,f as wt}from"./chunk-WCXXXAHV.js";import{b as sr}from"./chunk-JWDJMFU6.js";import{g as kt}from"./chunk-LQE73AZR.js";import{b as cr,c as pr}from"./chunk-2D3RYIDU.js";import"./chunk-MRIVENBY.js";import"./chunk-AKWBDCMU.js";import"./chunk-635B6SXI.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import{b as G,c as Ee,d as or,e as Sa}from"./chunk-EMGB23H5.js";import{F as Vn,W as ht,X as gt,Y as xt,Z as ce,_ as Yn,a as Fn,f as Un,g as wa,h as ka,l as Wn,n as Gn,o as Xn,z as Jn}from"./chunk-3K3LRLZX.js";import"./chunk-QSKG754X.js";import"./chunk-MEFPXHQJ.js";import"./chunk-Y4CYQV7G.js";import"./chunk-SHEUCITK.js";import"./chunk-5RHCM3L7.js";import"./chunk-SZDACK6O.js";import"./chunk-AFRHKA7B.js";import"./chunk-23LWLYOK.js";import{a as Kn}from"./chunk-BXXP6DTB.js";import"./chunk-3UOTLMXD.js";import"./chunk-PE5V2LI7.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-RWMDDMYX.js";import"./chunk-MXDWLBIA.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import{g as zn}from"./chunk-E3AEOQMK.js";import"./chunk-WPNRDEHW.js";import"./chunk-SQ37I2MD.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-6TURWSMN.js";import"./chunk-QD6IICK7.js";import"./chunk-QOYAX2FT.js";import"./chunk-2PJKGZWP.js";import"./chunk-7I7IEX4S.js";import{A as ba,Aa as ft,E as nc,L as Nn,O as va,R as Dn,T as mt,U as Hn,W as Bn,Y as qn,a as Mn,aa as ya,b as Ln,c as ec,sa as X,x as ct,y as tc,z as xa}from"./chunk-KHYF6KTY.js";import{a as Rn,b as pt,c as ga,d as Pn,h as $n}from"./chunk-BRK6M6LA.js";import{d as jn,e as ac,f as ut,n as On}from"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";function Ea(t,e,a=Date.now()){let n=Math.max(0,a-(t.updatedAt||a)),r=t.clientId?e[t.clientId]:void 0;if(!r)return{score:n/864e5,ageMs:n,rising:!1,overdue:!1};let o=n/(r*6e4);return{score:1e3+o,ageMs:n,rising:!0,overdue:o>=1}}function co(t,e,a=Date.now()){return t.map((n,r)=>({i:r,s:Ea(n,e,a).score})).sort((n,r)=>r.s-n.s||n.i-r.i).map(n=>n.i)}var ie={refresh:'<path d="M21 2v6h-6"/><path d="M3 12a9 9 0 0 1 15-6.7L21 8"/><path d="M3 22v-6h6"/><path d="M21 12a9 9 0 0 1-15 6.7L3 16"/>',clock:'<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>',alert:'<path d="M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z"/><path d="M12 9v4"/><path d="M12 17h.01"/>',gavel:'<path d="M12 3 6 9"/><path d="m9 6 6 6"/><path d="M15 9 9 15"/><path d="m12 12 6 6"/><path d="M4 21h10"/>',loop:'<path d="M17 2l4 4-4 4"/><path d="M3 11V9a4 4 0 0 1 4-4h14"/><path d="M7 22l-4-4 4-4"/><path d="M21 13v2a4 4 0 0 1-4 4H3"/>',broom:'<path d="M3 21h18"/><path d="M12 3v9"/><path d="m7 12 5-3 5 3-1.5 6h-7Z"/>',server:'<rect x="2" y="3" width="20" height="7" rx="2"/><rect x="2" y="14" width="20" height="7" rx="2"/><path d="M6 6.5h.01"/><path d="M6 17.5h.01"/>',inbox:'<path d="M21 12h-6l-2 3h-2l-2-3H3"/><path d="M5 5h14l2 7v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5Z"/>',cross:'<circle cx="12" cy="12" r="9"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/>',file:'<path d="M14 2H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7Z"/><path d="M14 2v5h5"/>',search:'<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',chev:'<path d="m6 9 6 6 6-6"/>',chevr:'<path d="m9 6 6 6-6 6"/>',ext:'<path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>',pulse:'<path d="M3 12h4l3-8 4 16 3-8h4"/>',plug:'<path d="M9 2v6"/><path d="M15 2v6"/><path d="M6 8h12v3a6 6 0 0 1-12 0Z"/><path d="M12 17v5"/>',check:'<path d="M20 6 9 17l-5-5"/>',route:'<circle cx="6" cy="19" r="3"/><circle cx="18" cy="5" r="3"/><path d="M9 19h6a4 4 0 0 0 0-8H9a4 4 0 0 1 0-8h6"/>',branch:'<circle cx="6" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="8" r="3"/><path d="M18 11v1a3 3 0 0 1-3 3H9"/><path d="M6 9v6"/>',send:'<path d="M22 2 11 13"/><path d="M22 2l-7 20-4-9-9-4Z"/>',msg:'<path d="M21 11.5a8.4 8.4 0 0 1-12.9 7.5L3 21l2-5.1A8.4 8.4 0 1 1 21 11.5Z"/>',code:'<path d="m9 18-6-6 6-6"/><path d="m15 6 6 6-6 6"/>',hash:'<path d="M4 9h16"/><path d="M4 15h16"/><path d="M10 3 8 21"/><path d="M16 3l-2 18"/>',x:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',trace:'<path d="M4 4v16h16"/><path d="m7 15 4-4 3 3 5-6"/>'},Ce=(t,e=14)=>'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="'+e+'" height="'+e+'" aria-hidden="true">'+t+"</svg>",Nt=(t,e,a,n="")=>'<div class="ax-sec-label"><h3>'+Ce(t,13)+e+(a?'<span class="ax-sec-label__n" id="'+a+'"></span>':"")+"</h3>"+n+"</div>";function po(t={}){return I({title:"AgentX \xB7 Monitor",activeTab:"monitor",subtitle:"Monitor",peers:t.peers,body:`<div class="bf">
1
+ import{C as Ot,D as ro,E as oo,F as so,H as io,I as lo,a as qr,b as zr,c as Fr,d as Ur,e as Ae,f as Wr,g as Gr,h as jt,j as Xr,p as Kr,q as Jr,r as Vr,s as Yr,t as Qr,x as Zr,y as eo}from"./chunk-QY5YUHGW.js";import"./chunk-H4NSB54D.js";import"./chunk-MTX4UPNB.js";import{a as to}from"./chunk-5NTWGUSJ.js";import{a as ao,b as no}from"./chunk-NZQBS7GN.js";import"./chunk-QAWKN2N4.js";import{a as Br}from"./chunk-BKHIR2YJ.js";import{a as qe,b as z,c as I,h as pe,i as Pt,j as se,k as K,l as $t,m as Nr,n as Dr,o as Hr}from"./chunk-B2QYMUTD.js";import{a as C}from"./chunk-GIQKQD2B.js";import{a as Or}from"./chunk-LNY6N73E.js";import{$a as Pr,A as ur,B as St,Ba as Tr,C as mr,Ca as Ar,D as Et,Da as Cr,E as Tt,F as At,G as fr,H as gr,K as xr,L as br,La as Ir,M as vr,Na as Te,Sa as Mr,T as U,U as yr,Ua as Be,V as wr,Va as Ct,Wa as It,Xa as Mt,Ya as Lt,Za as Lr,_a as Rr,a as er,ab as Rt,c as bt,cb as $r,d as _a,e as tr,fb as jr,i as vt,l as Ze,n as ar,z as _t,za as Er}from"./chunk-PNITKKDR.js";import"./chunk-GTJIKXDB.js";import{h as Qn,i as Zn}from"./chunk-Z2QOQBUS.js";import{a as H,b as kr,c as _r,g as Sr}from"./chunk-7LN4VKDU.js";import{a as hr}from"./chunk-IMLAPB7G.js";import{p as nr,t as rr}from"./chunk-S2GAEH2F.js";import"./chunk-AKWBDCMU.js";import{b as G,c as Ee,d as or,e as Sa}from"./chunk-EMGB23H5.js";import{a as ir,b as yt,d as lr,e as dr,f as wt}from"./chunk-WCXXXAHV.js";import{b as sr}from"./chunk-JWDJMFU6.js";import{g as kt}from"./chunk-LQE73AZR.js";import{b as cr,c as pr}from"./chunk-2D3RYIDU.js";import"./chunk-MRIVENBY.js";import"./chunk-635B6SXI.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import{F as Vn,W as ht,X as gt,Y as xt,Z as ce,_ as Yn,a as Fn,f as Un,g as wa,h as ka,l as Wn,n as Gn,o as Xn,z as Jn}from"./chunk-3K3LRLZX.js";import"./chunk-QSKG754X.js";import"./chunk-MEFPXHQJ.js";import"./chunk-Y4CYQV7G.js";import"./chunk-SHEUCITK.js";import"./chunk-5RHCM3L7.js";import"./chunk-SZDACK6O.js";import"./chunk-AFRHKA7B.js";import"./chunk-23LWLYOK.js";import{a as Kn}from"./chunk-BXXP6DTB.js";import"./chunk-3UOTLMXD.js";import"./chunk-PE5V2LI7.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-RWMDDMYX.js";import"./chunk-MXDWLBIA.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import{g as zn}from"./chunk-E3AEOQMK.js";import"./chunk-WPNRDEHW.js";import"./chunk-SQ37I2MD.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-6TURWSMN.js";import"./chunk-QD6IICK7.js";import"./chunk-QOYAX2FT.js";import"./chunk-2PJKGZWP.js";import"./chunk-7I7IEX4S.js";import{A as ba,Aa as ft,E as nc,L as Nn,O as va,R as Dn,T as mt,U as Hn,W as Bn,Y as qn,a as Mn,aa as ya,b as Ln,c as ec,sa as X,x as ct,y as tc,z as xa}from"./chunk-KHYF6KTY.js";import{a as Rn,b as pt,c as ga,d as Pn,h as $n}from"./chunk-BRK6M6LA.js";import{d as jn,e as ac,f as ut,n as On}from"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";function Ea(t,e,a=Date.now()){let n=Math.max(0,a-(t.updatedAt||a)),r=t.clientId?e[t.clientId]:void 0;if(!r)return{score:n/864e5,ageMs:n,rising:!1,overdue:!1};let o=n/(r*6e4);return{score:1e3+o,ageMs:n,rising:!0,overdue:o>=1}}function co(t,e,a=Date.now()){return t.map((n,r)=>({i:r,s:Ea(n,e,a).score})).sort((n,r)=>r.s-n.s||n.i-r.i).map(n=>n.i)}var ie={refresh:'<path d="M21 2v6h-6"/><path d="M3 12a9 9 0 0 1 15-6.7L21 8"/><path d="M3 22v-6h6"/><path d="M21 12a9 9 0 0 1-15 6.7L3 16"/>',clock:'<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>',alert:'<path d="M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z"/><path d="M12 9v4"/><path d="M12 17h.01"/>',gavel:'<path d="M12 3 6 9"/><path d="m9 6 6 6"/><path d="M15 9 9 15"/><path d="m12 12 6 6"/><path d="M4 21h10"/>',loop:'<path d="M17 2l4 4-4 4"/><path d="M3 11V9a4 4 0 0 1 4-4h14"/><path d="M7 22l-4-4 4-4"/><path d="M21 13v2a4 4 0 0 1-4 4H3"/>',broom:'<path d="M3 21h18"/><path d="M12 3v9"/><path d="m7 12 5-3 5 3-1.5 6h-7Z"/>',server:'<rect x="2" y="3" width="20" height="7" rx="2"/><rect x="2" y="14" width="20" height="7" rx="2"/><path d="M6 6.5h.01"/><path d="M6 17.5h.01"/>',inbox:'<path d="M21 12h-6l-2 3h-2l-2-3H3"/><path d="M5 5h14l2 7v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5Z"/>',cross:'<circle cx="12" cy="12" r="9"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/>',file:'<path d="M14 2H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7Z"/><path d="M14 2v5h5"/>',search:'<circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/>',chev:'<path d="m6 9 6 6 6-6"/>',chevr:'<path d="m9 6 6 6-6 6"/>',ext:'<path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>',pulse:'<path d="M3 12h4l3-8 4 16 3-8h4"/>',plug:'<path d="M9 2v6"/><path d="M15 2v6"/><path d="M6 8h12v3a6 6 0 0 1-12 0Z"/><path d="M12 17v5"/>',check:'<path d="M20 6 9 17l-5-5"/>',route:'<circle cx="6" cy="19" r="3"/><circle cx="18" cy="5" r="3"/><path d="M9 19h6a4 4 0 0 0 0-8H9a4 4 0 0 1 0-8h6"/>',branch:'<circle cx="6" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="8" r="3"/><path d="M18 11v1a3 3 0 0 1-3 3H9"/><path d="M6 9v6"/>',send:'<path d="M22 2 11 13"/><path d="M22 2l-7 20-4-9-9-4Z"/>',msg:'<path d="M21 11.5a8.4 8.4 0 0 1-12.9 7.5L3 21l2-5.1A8.4 8.4 0 1 1 21 11.5Z"/>',code:'<path d="m9 18-6-6 6-6"/><path d="m15 6 6 6-6 6"/>',hash:'<path d="M4 9h16"/><path d="M4 15h16"/><path d="M10 3 8 21"/><path d="M16 3l-2 18"/>',x:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',trace:'<path d="M4 4v16h16"/><path d="m7 15 4-4 3 3 5-6"/>'},Ce=(t,e=14)=>'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="'+e+'" height="'+e+'" aria-hidden="true">'+t+"</svg>",Nt=(t,e,a,n="")=>'<div class="ax-sec-label"><h3>'+Ce(t,13)+e+(a?'<span class="ax-sec-label__n" id="'+a+'"></span>':"")+"</h3>"+n+"</div>";function po(t={}){return I({title:"AgentX \xB7 Monitor",activeTab:"monitor",subtitle:"Monitor",peers:t.peers,body:`<div class="bf">
2
2
 
3
3
  <div class="bf-head">
4
4
  <div>
@@ -20920,4 +20920,4 @@ data: ${g.replace(/\n/g," ")}
20920
20920
  `)}catch{}}};s.stdout?.on("data",l),s.stderr?.on("data",l);let d=setInterval(()=>{try{e.write(`: hb
20921
20921
 
20922
20922
  `)}catch{}},15e3),c=()=>{clearInterval(d);try{s.kill()}catch{}try{e.end()}catch{}};t.on("close",c),s.on("exit",c),s.on("error",c)}async function Ud(t,e,a,n){let r=a.url+n,o=(t.method||"GET").toUpperCase(),i=o!=="GET"&&o!=="HEAD"?await new Promise((p,m)=>{let g=[];t.on("data",_=>g.push(_)),t.on("end",()=>p(Buffer.concat(g))),t.on("error",m)}):void 0,l={},d=t.headers["content-type"];d&&(l["Content-Type"]=Array.isArray(d)?d[0]:d);let c=t.headers["x-requested-with"];c&&(l["X-Requested-With"]=Array.isArray(c)?c[0]:c),a.token&&(l.Authorization=`Bearer ${a.token}`),l["X-Agentx-Peer"]="primary";try{let p=await fetch(r,{method:o,headers:l,body:i&&i.length>0?i:void 0}),m=Buffer.from(await p.arrayBuffer());e.writeHead(p.status,{"Content-Type":p.headers.get("content-type")||"application/json","Cache-Control":"no-store"}),e.end(m)}catch(p){w(e,502,{error:`proxy to peer failed: ${p?.message||p}`,target:r})}}function lt(t,e){let a=t.replace(/\/+$/,""),n=(e.dashboard?.daemons||[]).find(r=>r.url.replace(/\/+$/,"")===a);return n?{url:Jd(n),token:n.dashboardToken||n.token}:null}export{Gh as applyAttachSessions,Hh as fetchDaemonAgents,Ph as handleBoardRequest,W0 as resetLiveCaches,Se as resolveNodeTargets,U0 as startBoardDashboard,Wh as withLastGood};
20923
- //# sourceMappingURL=board-dashboard-VXQYQY22.js.map
20923
+ //# sourceMappingURL=board-dashboard-2A6VSQ7V.js.map
@@ -1,2 +1,2 @@
1
- import{c as d,g}from"./chunk-WCXXXAHV.js";import{a as f}from"./chunk-BWXRAPTX.js";var k=/^[A-Za-z0-9._-]{1,64}$/,m=/^[A-Za-z0-9_-]{1,64}$/,A=100,w=1e3,E=6e4,P=15*6e4;function p(r){return(r.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"node").slice(0,64)}function _(r,t,n){let i=/^bearer /i.test(r)?r.slice(7).trim():"",e="Phones paired with another computer need that computer's own peer token: give it a token in mesh.peers on both computers.";if(!i||n&&i===n)return{error:e};let a=new Set(t.filter(s=>s.token===i).map(s=>p(s.name)));if(a.size===0)return{error:e};if(a.size>1)return{error:`Several mesh.peers entries share this token (${[...a].join(", ")}). Give each computer its own token.`};let[o]=a,u=t.filter(s=>s.token!==i&&p(s.name)===o).map(s=>s.name);return u.length?{error:`mesh.peers names ${u.map(s=>`"${s}"`).join(", ")} too close to this computer's name: rename one so they differ in letters or digits.`}:{origin:o}}function C(r,t){let n=r.indexOf(":");return n<0?{ok:!0}:"error"in t?{error:t.error}:r.slice(0,n)!==t.origin?{error:`${r} is a phone paired with another computer; only that computer can send to it.`}:{ok:!0}}function x(r,t,n){let i=r.toLowerCase(),e=t.find(a=>a.name.toLowerCase()===i);return e?e.token?n&&e.token===n?`mesh.peers "${e.name}" uses the shared MESH_TOKEN, so phones paired here can't turn notifications on. Give this pair a token of its own on both computers.`:null:`mesh.peers "${e.name}" has no token, so phones paired here can't turn notifications on. Give it a token of its own on both computers.`:null}function O(r){return new Set(r.map(t=>p(t.name)))}function j(r,t,n,i){let e=r&&typeof r=="object"?r:{};if("error"in t)return{status:403,body:{error:t.error}};let a=t.origin;if(!k.test(a))return{status:403,body:{error:"this peer's name can't be used as a notification origin"}};if(!n)return{status:503,body:{error:i??"Notifications are not set up on the computer that sends them."}};if(e.op==="roster"){if(!Array.isArray(e.active)||e.active.length>w||!e.active.every(l=>typeof l=="string"&&m.test(l)))return{status:400,body:{error:"active must be a list of device ids"}};let h=n.store();return h?{status:200,body:{ok:!0,removed:h.pruneOrigin(a,e.active)}}:{status:503,body:{error:n.reason??"the database is unavailable"}}}if(e.op!=="app")return{status:400,body:{error:"op must be app or roster"}};let o=e.call&&typeof e.call=="object"?e.call:{},u=o.device&&typeof o.device=="object"?o.device:{},s=typeof o.path=="string"?o.path:"",c=o.method==="GET"||o.method==="POST"?o.method:"";if(!d(s)||!c)return{status:404,body:{error:"not found"}};if(typeof u.id!="string"||!m.test(u.id))return{status:400,body:{error:"device.id is required"}};let b=typeof u.name=="string"&&u.name.trim()?u.name.trim():u.id,v=o.body&&typeof o.body=="object"&&!Array.isArray(o.body)?o.body:{};return g({path:s,method:c,body:v,device:{id:f(a,u.id),name:S(`${b} (${a})`,A)}},n)}var y=class{constructor(t){this.deps=t}lastKey=null;lastSentAt=0;failing=!1;async tick(){let t=(this.deps.now??Date.now)(),n;try{n=[...new Set(this.deps.active())].sort()}catch(e){return this.deps.log?.(`push: phone list not read, not sent this time: ${e?.message??e}`),!1}let i=n.join(",");if(i===this.lastKey&&t-this.lastSentAt<P)return!1;try{let e=await this.deps.send(n);if(e&&typeof e=="object"&&typeof e.status=="number"&&e.status!==200)throw new Error(`${e.status} ${typeof e.body?.error=="string"?e.body.error:"refused"}`);return this.lastKey=i,this.lastSentAt=t,this.failing&&this.deps.log?.("push: phone list sent to the push host again"),this.failing=!1,!0}catch(e){return this.failing||this.deps.log?.(`push: phone list not sent to the push host, retrying every minute: ${e?.message??e}`),this.failing=!0,!1}}};function S(r,t){let n=[...r];return n.length>t?n.slice(0,t-1).join("")+"\u2026":r}export{E as a,P as b,p as c,_ as d,C as e,x as f,O as g,j as h,y as i};
2
- //# sourceMappingURL=chunk-Z5OD225A.js.map
1
+ import{c as d,g}from"./chunk-WCXXXAHV.js";import{a as f}from"./chunk-Q72TK3DO.js";var k=/^[A-Za-z0-9._-]{1,64}$/,m=/^[A-Za-z0-9_-]{1,64}$/,A=100,w=1e3,E=6e4,P=15*6e4;function p(r){return(r.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"node").slice(0,64)}function _(r,t,n){let i=/^bearer /i.test(r)?r.slice(7).trim():"",e="Phones paired with another computer need that computer's own peer token: give it a token in mesh.peers on both computers.";if(!i||n&&i===n)return{error:e};let a=new Set(t.filter(s=>s.token===i).map(s=>p(s.name)));if(a.size===0)return{error:e};if(a.size>1)return{error:`Several mesh.peers entries share this token (${[...a].join(", ")}). Give each computer its own token.`};let[o]=a,u=t.filter(s=>s.token!==i&&p(s.name)===o).map(s=>s.name);return u.length?{error:`mesh.peers names ${u.map(s=>`"${s}"`).join(", ")} too close to this computer's name: rename one so they differ in letters or digits.`}:{origin:o}}function C(r,t){let n=r.indexOf(":");return n<0?{ok:!0}:"error"in t?{error:t.error}:r.slice(0,n)!==t.origin?{error:`${r} is a phone paired with another computer; only that computer can send to it.`}:{ok:!0}}function x(r,t,n){let i=r.toLowerCase(),e=t.find(a=>a.name.toLowerCase()===i);return e?e.token?n&&e.token===n?`mesh.peers "${e.name}" uses the shared MESH_TOKEN, so phones paired here can't turn notifications on. Give this pair a token of its own on both computers.`:null:`mesh.peers "${e.name}" has no token, so phones paired here can't turn notifications on. Give it a token of its own on both computers.`:null}function O(r){return new Set(r.map(t=>p(t.name)))}function j(r,t,n,i){let e=r&&typeof r=="object"?r:{};if("error"in t)return{status:403,body:{error:t.error}};let a=t.origin;if(!k.test(a))return{status:403,body:{error:"this peer's name can't be used as a notification origin"}};if(!n)return{status:503,body:{error:i??"Notifications are not set up on the computer that sends them."}};if(e.op==="roster"){if(!Array.isArray(e.active)||e.active.length>w||!e.active.every(l=>typeof l=="string"&&m.test(l)))return{status:400,body:{error:"active must be a list of device ids"}};let h=n.store();return h?{status:200,body:{ok:!0,removed:h.pruneOrigin(a,e.active)}}:{status:503,body:{error:n.reason??"the database is unavailable"}}}if(e.op!=="app")return{status:400,body:{error:"op must be app or roster"}};let o=e.call&&typeof e.call=="object"?e.call:{},u=o.device&&typeof o.device=="object"?o.device:{},s=typeof o.path=="string"?o.path:"",c=o.method==="GET"||o.method==="POST"?o.method:"";if(!d(s)||!c)return{status:404,body:{error:"not found"}};if(typeof u.id!="string"||!m.test(u.id))return{status:400,body:{error:"device.id is required"}};let b=typeof u.name=="string"&&u.name.trim()?u.name.trim():u.id,v=o.body&&typeof o.body=="object"&&!Array.isArray(o.body)?o.body:{};return g({path:s,method:c,body:v,device:{id:f(a,u.id),name:S(`${b} (${a})`,A)}},n)}var y=class{constructor(t){this.deps=t}lastKey=null;lastSentAt=0;failing=!1;async tick(){let t=(this.deps.now??Date.now)(),n;try{n=[...new Set(this.deps.active())].sort()}catch(e){return this.deps.log?.(`push: phone list not read, not sent this time: ${e?.message??e}`),!1}let i=n.join(",");if(i===this.lastKey&&t-this.lastSentAt<P)return!1;try{let e=await this.deps.send(n);if(e&&typeof e=="object"&&typeof e.status=="number"&&e.status!==200)throw new Error(`${e.status} ${typeof e.body?.error=="string"?e.body.error:"refused"}`);return this.lastKey=i,this.lastSentAt=t,this.failing&&this.deps.log?.("push: phone list sent to the push host again"),this.failing=!1,!0}catch(e){return this.failing||this.deps.log?.(`push: phone list not sent to the push host, retrying every minute: ${e?.message??e}`),this.failing=!0,!1}}};function S(r,t){let n=[...r];return n.length>t?n.slice(0,t-1).join("")+"\u2026":r}export{E as a,P as b,p as c,_ as d,C as e,x as f,O as g,j as h,y as i};
2
+ //# sourceMappingURL=chunk-DIE6XXJF.js.map
@@ -0,0 +1,4 @@
1
+ var $=[1e3,3e3,8e3],w=2e4;function b(e){let t=e,n=t?.message??String(e),s=t?.cause;return s?.code?`${n} code=${s.code}`:s?.message&&s.message!==n?`${n} (${s.message})`:n}var A=new Set(["ECONNREFUSED","ETIMEDOUT","ENETUNREACH","EHOSTUNREACH","EADDRNOTAVAIL","ENOTFOUND","EAI_AGAIN","UND_ERR_CONNECT_TIMEOUT"]);function M(e){let t=e?.cause?.code;return!!t&&A.has(t)}function N(e){return e===429||e===503}function m(e){return/^[\x20-\x7E]*$/.test(e)?e:`=?UTF-8?B?${Buffer.from(e,"utf8").toString("base64")}?=`}function D(e){let t=e.split(`
2
+ `),n=(t[0]??"").trim(),s=t.slice(1).join(`
3
+ `).trim();return s?n.length===0||n.length>80?{body:e.trim()}:{title:n,body:s}:{body:e.trim()}}var y=class{name="ntfy";config;log;constructor(t,n=console.error.bind(console,"[ntfy]")){this.config=t,this.log=n}async start(){this.log(`ntfy: ready (${this.serverUrl()}/${this.config.topic})`)}async stop(){}onMessage(t){}serverUrl(){return(this.config.server||"https://ntfy.sh").replace(/\/+$/,"")}async send(t){let n=(t.chatId||"").trim(),s=n&&n!=="default"?n:this.config.topic;if(!s)throw new Error("ntfy: no topic (pass chatId, or set channels.ntfy.topic)");let f=D(t.text||""),p=f.title||this.config.defaultTitle||"AgentX",c={"Content-Type":"text/plain; charset=utf-8",Title:m(p),Priority:String(this.config.defaultPriority??3)};if(this.config.token&&(c.Authorization=`Bearer ${this.config.token}`),t.parseMode==="markdown"&&(c.Markdown="yes"),t.buttons?.length){let i=t.buttons.slice(0,3).map(r=>`view, ${r.label.replace(/[,;]/g," ")}, ${r.url}`).join("; ");c.Actions=m(i)}let E=`${this.serverUrl()}/${encodeURIComponent(s)}`,T=f.body||t.text||"",d=this.config.retryDelaysMs??$,u=d.length+1,h=Date.now()+(this.config.sendTimeoutMs??w);for(let i=1;;i++){let r,a,l=!1;try{let o=AbortSignal.timeout(Math.max(1,h-Date.now()));r=await fetch(E,{method:"POST",headers:c,body:T,signal:o})}catch(o){a=new Error(`ntfy: ${b(o)}`,{cause:o}),l=M(o)}if(r){if(r.ok)return(await r.json().catch(()=>null))?.id;let o=await r.text().catch(()=>"");a=new Error(`ntfy: ${r.status} ${o.slice(0,200)}`),l=N(r.status)}let g=d[i-1];if(!l||i>=u||Date.now()+g>=h)throw this.log(`ntfy: send failed after ${i} attempt(s): ${a.message}`),a;this.log(`ntfy: attempt ${i}/${u} failed (${a.message}); retrying in ${g} ms`),await new Promise(o=>setTimeout(o,g))}}};export{b as a,D as b,y as c};
4
+ //# sourceMappingURL=chunk-GFKLKPPY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/channels/ntfy.ts"],"sourcesContent":["import type { ChannelAdapter, IncomingMessage, OutgoingMessage } from \"./types\"\n\n// --- ntfy channel — push notifications to the operator's phone ---\n//\n// Outbound only. ntfy has an inbound side (SSE subscribe), but nothing here\n// wants it: a push notification is a one-way tap on the shoulder, and replies\n// come back through the channels that already carry conversation (Telegram,\n// WhatsApp) or through POST /ask when Siri asks a follow-up.\n//\n// Registering it as a ChannelAdapter rather than a bespoke notifier is what\n// makes it free everywhere: notifications.destination, POST /send, cron\n// failure pings, and the agent-facing `channel` action all funnel through\n// router.sendOutbound() and already know how to address a channel + chatId.\n//\n// Addressing: `chatId` is the ntfy topic. The literal `\"default\"` (and an\n// empty string) resolve to the configured topic instead. That indirection\n// exists so agents never have to carry the topic in their prompts — on the\n// public ntfy.sh the topic IS the credential, and every caller that funnels\n// through the router (POST /send, channel.reply) requires a non-empty chatId.\n\nexport interface NtfyConfig {\n /** Base URL of the ntfy server. Default is the public ntfy.sh. */\n server?: string\n /** Default topic when an OutgoingMessage carries no chatId. */\n topic: string\n /** Access token for protected topics (ntfy `Authorization: Bearer`). */\n token?: string\n /** 1 (min) .. 5 (max). ntfy's default is 3. */\n defaultPriority?: number\n /** Notification title. Per-message titles override it. */\n defaultTitle?: string\n /** Test hook, not in the config schema: waits between attempts when a\n * publish is safe to repeat. One attempt more than there are entries. */\n retryDelaysMs?: number[]\n /** Test hook, not in the config schema: time limit for one send, all\n * attempts and waits included. */\n sendTimeoutMs?: number\n}\n\nconst DEFAULT_RETRY_DELAYS_MS = [1000, 3000, 8000]\nconst DEFAULT_SEND_TIMEOUT_MS = 20_000\n\n/** `fetch failed` hides the reason in `cause`; surface its code so a log\n * line says ETIMEDOUT or ECONNREFUSED rather than nothing useful (#930). */\nexport function describeFetchError(e: unknown): string {\n const err = e as { message?: string; cause?: { code?: string; message?: string } }\n const message = err?.message ?? String(e)\n const cause = err?.cause\n if (cause?.code) return `${message} code=${cause.code}`\n if (cause?.message && cause.message !== message) return `${message} (${cause.message})`\n return message\n}\n\n// A publish is retried only when the server cannot have stored it: ntfy has\n// no key to drop a repeat, so re-posting after a 500 or a reset mid-response\n// could put the same notification on the phone twice.\n\n/** The connection never opened, so the request never reached the server. */\nconst CONNECT_FAILURE_CODES = new Set([\n \"ECONNREFUSED\", \"ETIMEDOUT\", \"ENETUNREACH\", \"EHOSTUNREACH\", \"EADDRNOTAVAIL\",\n \"ENOTFOUND\", \"EAI_AGAIN\", \"UND_ERR_CONNECT_TIMEOUT\",\n])\n\nfunction isRetryableFetchError(e: unknown): boolean {\n const code = (e as { cause?: { code?: string } })?.cause?.code\n return !!code && CONNECT_FAILURE_CODES.has(code)\n}\n\n/** 429 and 503 say the server turned the request away without handling it. */\nfunction isRetryableStatus(status: number): boolean {\n return status === 429 || status === 503\n}\n\n/**\n * ntfy requires header values to be ASCII. Titles and tags routinely aren't\n * (French accents, Arabic), so non-ASCII values go out as RFC 2047 encoded\n * words, which ntfy decodes. Pure-ASCII values are passed through untouched\n * so the common case stays readable in logs.\n */\nfunction encodeHeader(value: string): string {\n // eslint-disable-next-line no-control-regex\n if (/^[\\x20-\\x7E]*$/.test(value)) return value\n return `=?UTF-8?B?${Buffer.from(value, \"utf8\").toString(\"base64\")}?=`\n}\n\n/** First line of the body, when it reads like a title (short, no trailing\n * punctuation that implies a sentence continues). Lets an agent write a\n * single blob and still get a well-formed notification. */\nexport function splitTitle(text: string): { title?: string; body: string } {\n const lines = text.split(\"\\n\")\n const first = (lines[0] ?? \"\").trim()\n const rest = lines.slice(1).join(\"\\n\").trim()\n if (!rest) return { body: text.trim() }\n if (first.length === 0 || first.length > 80) return { body: text.trim() }\n return { title: first, body: rest }\n}\n\nexport class NtfyAdapter implements ChannelAdapter {\n readonly name = \"ntfy\"\n private config: NtfyConfig\n private log: (...args: unknown[]) => void\n\n constructor(config: NtfyConfig, log: (...args: unknown[]) => void = console.error.bind(console, \"[ntfy]\")) {\n this.config = config\n this.log = log\n }\n\n async start(): Promise<void> {\n this.log(`ntfy: ready (${this.serverUrl()}/${this.config.topic})`)\n }\n\n async stop(): Promise<void> {}\n\n /** No inbound side — the handler is accepted and never invoked, which\n * satisfies router.addChannel() without pretending to poll. */\n onMessage(_handler: (msg: IncomingMessage) => Promise<void>): void {}\n\n private serverUrl(): string {\n return (this.config.server || \"https://ntfy.sh\").replace(/\\/+$/, \"\")\n }\n\n async send(msg: OutgoingMessage): Promise<string | void> {\n const requested = (msg.chatId || \"\").trim()\n const topic = requested && requested !== \"default\" ? requested : this.config.topic\n if (!topic) throw new Error(\"ntfy: no topic (pass chatId, or set channels.ntfy.topic)\")\n\n const split = splitTitle(msg.text || \"\")\n const title = split.title || this.config.defaultTitle || \"AgentX\"\n\n const headers: Record<string, string> = {\n \"Content-Type\": \"text/plain; charset=utf-8\",\n \"Title\": encodeHeader(title),\n \"Priority\": String(this.config.defaultPriority ?? 3),\n }\n if (this.config.token) headers[\"Authorization\"] = `Bearer ${this.config.token}`\n if (msg.parseMode === \"markdown\") headers[\"Markdown\"] = \"yes\"\n\n // URL buttons map onto ntfy's view actions, so an alert can carry\n // \"open the MR\" without the operator hunting for it.\n if (msg.buttons?.length) {\n const actions = msg.buttons\n .slice(0, 3) // ntfy caps at 3\n .map(b => `view, ${b.label.replace(/[,;]/g, \" \")}, ${b.url}`)\n .join(\"; \")\n headers[\"Actions\"] = encodeHeader(actions)\n }\n\n const url = `${this.serverUrl()}/${encodeURIComponent(topic)}`\n const body = split.body || msg.text || \"\"\n const delays = this.config.retryDelaysMs ?? DEFAULT_RETRY_DELAYS_MS\n const attempts = delays.length + 1\n // Each try can spend several seconds per address on a dead link, so the\n // whole send gets one time limit and callers never wait much past it.\n const deadline = Date.now() + (this.config.sendTimeoutMs ?? DEFAULT_SEND_TIMEOUT_MS)\n\n // A slow or flapping link loses pushes that a few seconds later would\n // go through. Retry only what cannot have been stored (see above).\n for (let attempt = 1; ; attempt++) {\n let res: Response | undefined\n let failure!: Error\n let retryable = false\n try {\n const signal = AbortSignal.timeout(Math.max(1, deadline - Date.now()))\n res = await fetch(url, { method: \"POST\", headers, body, signal })\n } catch (e) {\n failure = new Error(`ntfy: ${describeFetchError(e)}`, { cause: e })\n retryable = isRetryableFetchError(e)\n }\n if (res) {\n if (res.ok) {\n const json = await res.json().catch(() => null) as { id?: string } | null\n return json?.id\n }\n const detail = await res.text().catch(() => \"\")\n failure = new Error(`ntfy: ${res.status} ${detail.slice(0, 200)}`)\n retryable = isRetryableStatus(res.status)\n }\n const wait = delays[attempt - 1]\n if (!retryable || attempt >= attempts || Date.now() + wait >= deadline) {\n this.log(`ntfy: send failed after ${attempt} attempt(s): ${failure.message}`)\n throw failure\n }\n this.log(`ntfy: attempt ${attempt}/${attempts} failed (${failure.message}); retrying in ${wait} ms`)\n await new Promise(r => setTimeout(r, wait))\n }\n }\n}\n"],"mappings":"AAuCA,IAAMA,EAA0B,CAAC,IAAM,IAAM,GAAI,EAC3CC,EAA0B,IAIzB,SAASC,EAAmB,EAAoB,CACrD,IAAMC,EAAM,EACNC,EAAUD,GAAK,SAAW,OAAO,CAAC,EAClCE,EAAQF,GAAK,MACnB,OAAIE,GAAO,KAAa,GAAGD,UAAgBC,EAAM,OAC7CA,GAAO,SAAWA,EAAM,UAAYD,EAAgB,GAAGA,MAAYC,EAAM,WACtED,CACT,CAOA,IAAME,EAAwB,IAAI,IAAI,CACpC,eAAgB,YAAa,cAAe,eAAgB,gBAC5D,YAAa,YAAa,yBAC5B,CAAC,EAED,SAASC,EAAsB,EAAqB,CAClD,IAAMC,EAAQ,GAAqC,OAAO,KAC1D,MAAO,CAAC,CAACA,GAAQF,EAAsB,IAAIE,CAAI,CACjD,CAGA,SAASC,EAAkBC,EAAyB,CAClD,OAAOA,IAAW,KAAOA,IAAW,GACtC,CAQA,SAASC,EAAaC,EAAuB,CAE3C,MAAI,iBAAiB,KAAKA,CAAK,EAAUA,EAClC,aAAa,OAAO,KAAKA,EAAO,MAAM,EAAE,SAAS,QAAQ,KAClE,CAKO,SAASC,EAAWC,EAAgD,CACzE,IAAMC,EAAQD,EAAK,MAAM;AAAA,CAAI,EACvBE,GAASD,EAAM,CAAC,GAAK,IAAI,KAAK,EAC9BE,EAAOF,EAAM,MAAM,CAAC,EAAE,KAAK;AAAA,CAAI,EAAE,KAAK,EAC5C,OAAKE,EACDD,EAAM,SAAW,GAAKA,EAAM,OAAS,GAAW,CAAE,KAAMF,EAAK,KAAK,CAAE,EACjE,CAAE,MAAOE,EAAO,KAAMC,CAAK,EAFhB,CAAE,KAAMH,EAAK,KAAK,CAAE,CAGxC,CAEO,IAAMI,EAAN,KAA4C,CACxC,KAAO,OACR,OACA,IAER,YAAYC,EAAoBC,EAAoC,QAAQ,MAAM,KAAK,QAAS,QAAQ,EAAG,CACzG,KAAK,OAASD,EACd,KAAK,IAAMC,CACb,CAEA,MAAM,OAAuB,CAC3B,KAAK,IAAI,gBAAgB,KAAK,UAAU,KAAK,KAAK,OAAO,QAAQ,CACnE,CAEA,MAAM,MAAsB,CAAC,CAI7B,UAAUC,EAAyD,CAAC,CAE5D,WAAoB,CAC1B,OAAQ,KAAK,OAAO,QAAU,mBAAmB,QAAQ,OAAQ,EAAE,CACrE,CAEA,MAAM,KAAKC,EAA8C,CACvD,IAAMC,GAAaD,EAAI,QAAU,IAAI,KAAK,EACpCE,EAAQD,GAAaA,IAAc,UAAYA,EAAY,KAAK,OAAO,MAC7E,GAAI,CAACC,EAAO,MAAM,IAAI,MAAM,0DAA0D,EAEtF,IAAMC,EAAQZ,EAAWS,EAAI,MAAQ,EAAE,EACjCI,EAAQD,EAAM,OAAS,KAAK,OAAO,cAAgB,SAEnDE,EAAkC,CACtC,eAAgB,4BAChB,MAAShB,EAAae,CAAK,EAC3B,SAAY,OAAO,KAAK,OAAO,iBAAmB,CAAC,CACrD,EAMA,GALI,KAAK,OAAO,QAAOC,EAAQ,cAAmB,UAAU,KAAK,OAAO,SACpEL,EAAI,YAAc,aAAYK,EAAQ,SAAc,OAIpDL,EAAI,SAAS,OAAQ,CACvB,IAAMM,EAAUN,EAAI,QACjB,MAAM,EAAG,CAAC,EACV,IAAIO,GAAK,SAASA,EAAE,MAAM,QAAQ,QAAS,GAAG,MAAMA,EAAE,KAAK,EAC3D,KAAK,IAAI,EACZF,EAAQ,QAAahB,EAAaiB,CAAO,EAG3C,IAAME,EAAM,GAAG,KAAK,UAAU,KAAK,mBAAmBN,CAAK,IACrDO,EAAON,EAAM,MAAQH,EAAI,MAAQ,GACjCU,EAAS,KAAK,OAAO,eAAiBhC,EACtCiC,EAAWD,EAAO,OAAS,EAG3BE,EAAW,KAAK,IAAI,GAAK,KAAK,OAAO,eAAiBjC,GAI5D,QAASkC,EAAU,GAAKA,IAAW,CACjC,IAAIC,EACAC,EACAC,EAAY,GAChB,GAAI,CACF,IAAMC,EAAS,YAAY,QAAQ,KAAK,IAAI,EAAGL,EAAW,KAAK,IAAI,CAAC,CAAC,EACrEE,EAAM,MAAM,MAAMN,EAAK,CAAE,OAAQ,OAAQ,QAAAH,EAAS,KAAAI,EAAM,OAAAQ,CAAO,CAAC,CAClE,OAASC,EAAP,CACAH,EAAU,IAAI,MAAM,SAASnC,EAAmBsC,CAAC,IAAK,CAAE,MAAOA,CAAE,CAAC,EAClEF,EAAY/B,EAAsBiC,CAAC,CACrC,CACA,GAAIJ,EAAK,CACP,GAAIA,EAAI,GAEN,OADa,MAAMA,EAAI,KAAK,EAAE,MAAM,IAAM,IAAI,IACjC,GAEf,IAAMK,EAAS,MAAML,EAAI,KAAK,EAAE,MAAM,IAAM,EAAE,EAC9CC,EAAU,IAAI,MAAM,SAASD,EAAI,UAAUK,EAAO,MAAM,EAAG,GAAG,GAAG,EACjEH,EAAY7B,EAAkB2B,EAAI,MAAM,EAE1C,IAAMM,EAAOV,EAAOG,EAAU,CAAC,EAC/B,GAAI,CAACG,GAAaH,GAAWF,GAAY,KAAK,IAAI,EAAIS,GAAQR,EAC5D,WAAK,IAAI,2BAA2BC,iBAAuBE,EAAQ,SAAS,EACtEA,EAER,KAAK,IAAI,iBAAiBF,KAAWF,aAAoBI,EAAQ,yBAAyBK,MAAS,EACnG,MAAM,IAAI,QAAQC,GAAK,WAAWA,EAAGD,CAAI,CAAC,EAE9C,CACF","names":["DEFAULT_RETRY_DELAYS_MS","DEFAULT_SEND_TIMEOUT_MS","describeFetchError","err","message","cause","CONNECT_FAILURE_CODES","isRetryableFetchError","code","isRetryableStatus","status","encodeHeader","value","splitTitle","text","lines","first","rest","NtfyAdapter","config","log","_handler","msg","requested","topic","split","title","headers","actions","b","url","body","delays","attempts","deadline","attempt","res","failure","retryable","signal","e","detail","wait","r"]}
@@ -0,0 +1,2 @@
1
+ import o from"node:net";import{existsSync as i,readFileSync as c}from"node:fs";import{resolve as r}from"node:path";function p(n){let e=o.getDefaultAutoSelectFamilyAttemptTimeout,t=o.setDefaultAutoSelectFamilyAttemptTimeout;if(typeof e!="function"||typeof t!="function")return;let u=e();return n>u&&t(n),e()}var f=5e3;function d(n=process.cwd()){for(let e of[r(n,"agentx.json"),r(n,".agentx/config.json")])if(i(e)){try{let t=JSON.parse(c(e,"utf-8"))?.node?.connectAttemptTimeoutMs;if(Number.isInteger(t)&&t>=250&&t<=6e4)return t}catch{}break}return f}export{p as a,f as b,d as c};
2
+ //# sourceMappingURL=chunk-PBP3D2BM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/daemon/net-family.ts"],"sourcesContent":["import net from \"node:net\"\nimport { existsSync, readFileSync } from \"node:fs\"\nimport { resolve } from \"node:path\"\n\n// --- Connect attempt timeout for dual-stack hosts (#930) ---\n//\n// Node 20+ turns on `autoSelectFamily` (happy eyeballs) for every outbound\n// connection, fetch included, and gives each address only 250 ms to connect\n// before moving to the next. On a host that resolves both A and AAAA but has\n// no IPv6 route, the IPv6 attempt fails at once and the IPv4 attempt is then\n// abandoned after 250 ms. A slow uplink whose TCP connect takes longer fails\n// every request with ETIMEDOUT about 300 ms in, while curl from the same\n// host succeeds. Raising the per-attempt timeout keeps happy eyeballs and\n// lets a slow but working link connect.\n\n/**\n * Raise Node's per-address connect attempt timeout to `ms`. Never lowers a\n * larger value already set (for example with\n * `--network-family-autoselection-attempt-timeout`). Returns the value in\n * effect afterwards, or undefined when this Node has no such setting.\n */\nexport function applyConnectAttemptTimeout(ms: number): number | undefined {\n const get = (net as any).getDefaultAutoSelectFamilyAttemptTimeout as (() => number) | undefined\n const set = (net as any).setDefaultAutoSelectFamilyAttemptTimeout as ((v: number) => void) | undefined\n if (typeof get !== \"function\" || typeof set !== \"function\") return undefined\n const current = get()\n if (ms > current) set(ms)\n return get()\n}\n\nexport const DEFAULT_CONNECT_ATTEMPT_TIMEOUT_MS = 5000\n\n/**\n * `node.connectAttemptTimeoutMs` read straight from the config file, for CLI\n * commands that call out on their own and never load the full daemon config.\n * Falls back to the default when there is no file or no valid value.\n */\nexport function readConnectAttemptTimeout(cwd: string = process.cwd()): number {\n for (const p of [resolve(cwd, \"agentx.json\"), resolve(cwd, \".agentx/config.json\")]) {\n if (!existsSync(p)) continue\n try {\n const v = JSON.parse(readFileSync(p, \"utf-8\"))?.node?.connectAttemptTimeoutMs\n if (Number.isInteger(v) && v >= 250 && v <= 60_000) return v\n } catch { /* an invalid file is reported by whatever loads it in full */ }\n break\n }\n return DEFAULT_CONNECT_ATTEMPT_TIMEOUT_MS\n}\n"],"mappings":"AAAA,OAAOA,MAAS,WAChB,OAAS,cAAAC,EAAY,gBAAAC,MAAoB,UACzC,OAAS,WAAAC,MAAe,YAmBjB,SAASC,EAA2BC,EAAgC,CACzE,IAAMC,EAAON,EAAY,yCACnBO,EAAOP,EAAY,yCACzB,GAAI,OAAOM,GAAQ,YAAc,OAAOC,GAAQ,WAAY,OAC5D,IAAMC,EAAUF,EAAI,EACpB,OAAID,EAAKG,GAASD,EAAIF,CAAE,EACjBC,EAAI,CACb,CAEO,IAAMG,EAAqC,IAO3C,SAASC,EAA0BC,EAAc,QAAQ,IAAI,EAAW,CAC7E,QAAWC,IAAK,CAACT,EAAQQ,EAAK,aAAa,EAAGR,EAAQQ,EAAK,qBAAqB,CAAC,EAC/E,GAAKV,EAAWW,CAAC,EACjB,IAAI,CACF,IAAMC,EAAI,KAAK,MAAMX,EAAaU,EAAG,OAAO,CAAC,GAAG,MAAM,wBACtD,GAAI,OAAO,UAAUC,CAAC,GAAKA,GAAK,KAAOA,GAAK,IAAQ,OAAOA,CAC7D,MAAE,CAAuE,CACzE,MAEF,OAAOJ,CACT","names":["net","existsSync","readFileSync","resolve","applyConnectAttemptTimeout","ms","get","set","current","DEFAULT_CONNECT_ATTEMPT_TIMEOUT_MS","readConnectAttemptTimeout","cwd","p","v"]}
@@ -1,4 +1,4 @@
1
- import{a as Re}from"./chunk-GTJIKXDB.js";import{a as w}from"./chunk-7LN4VKDU.js";import{a as ne}from"./chunk-IMLAPB7G.js";import{q as Kt}from"./chunk-S2GAEH2F.js";import{b as Jt}from"./chunk-WCXXXAHV.js";import{f as Yt,g as Ae,i as V,j as q,l as Zt}from"./chunk-AKWBDCMU.js";import{t as Xt,u as Gt}from"./chunk-635B6SXI.js";import{d as Ht,e as zt}from"./chunk-AQASR6KR.js";import{X as Nt,Z as te,_ as ve,aa as $e,b as Se}from"./chunk-3K3LRLZX.js";import{a as Vt,b as qt,d as Bt}from"./chunk-Y4CYQV7G.js";import{a as Lt,b as Ot}from"./chunk-SHEUCITK.js";import{g as Mt,h as jt,i as Wt,k as Ft,l as Ut}from"./chunk-5RHCM3L7.js";import{q as Pt}from"./chunk-23LWLYOK.js";import{a as Ct,b as Dt}from"./chunk-BXXP6DTB.js";import{Aa as Tt,B as $t,C as At,D as Rt,E as _t,ka as xe,n as ee,o as St,p as vt,q as Jr,ra as It,sa as Et}from"./chunk-KHYF6KTY.js";import{a as we,h as Yr}from"./chunk-BRK6M6LA.js";import{f as ke,n as Zr}from"./chunk-UIBUZ2N3.js";import{existsSync as Qr,readdirSync as ei,readFileSync as ti,statSync as ni}from"fs";import{resolve as ri}from"path";function Qt(t,e,n=Date.now(),i=7){let r=i*864e5,s=new Map;for(let o of e){let a=s.get(o.workflowId);a?a.push(o):s.set(o.workflowId,[o])}return t.map(o=>{let a=s.get(o.id)??[],l=a.filter(f=>n-f.at<=r),c=a.filter(f=>n-f.at>r&&n-f.at<=r*2),u=l.filter(f=>f.status==="failed").length,d=a.filter(f=>f.status==="paused").length,p=a.length?Math.max(...a.map(f=>f.at)):null,g=a.length?c.length>0&&l.length===0?"dormant":l.length>0&&u*2>=l.length?"failing":l.length>0?"active":"quiet":"never";return{id:o.id,name:o.name||o.id,state:g,lastRunAt:p,recent:l.length,prior:c.length,failed:u,paused:d}}).sort((o,a)=>{let l={dormant:0,failing:1,active:2,quiet:3,never:4};return l[o.state]-l[a.state]||(a.lastRunAt??0)-(o.lastRunAt??0)})}var re=new Map;function Ea(t,e=1e3){if(!Qr(t))return[];let n=ei(t).filter(s=>s.endsWith(".jsonl")).map(s=>{let o=ri(t,s);return{path:o,mtime:ni(o).mtimeMs}}).sort((s,o)=>o.mtime-s.mtime).slice(0,e),i=new Set(n.map(s=>s.path));for(let s of re.keys())i.has(s)||re.delete(s);let r=[];for(let{path:s,mtime:o}of n){let a=re.get(s);if(a&&a.mtime===o){a.summary&&r.push(a.summary);continue}let l=ii(s,o);re.set(s,{mtime:o,summary:l}),l&&r.push(l)}return r}function ii(t,e){try{let n=ti(t,"utf-8").split(`
1
+ import{a as Re}from"./chunk-GTJIKXDB.js";import{a as w}from"./chunk-7LN4VKDU.js";import{a as ne}from"./chunk-IMLAPB7G.js";import{q as Kt}from"./chunk-S2GAEH2F.js";import{f as Yt,g as Ae,i as V,j as q,l as Zt}from"./chunk-AKWBDCMU.js";import{b as Jt}from"./chunk-WCXXXAHV.js";import{t as Xt,u as Gt}from"./chunk-635B6SXI.js";import{d as Ht,e as zt}from"./chunk-AQASR6KR.js";import{X as Nt,Z as te,_ as ve,aa as $e,b as Se}from"./chunk-3K3LRLZX.js";import{a as Vt,b as qt,d as Bt}from"./chunk-Y4CYQV7G.js";import{a as Lt,b as Ot}from"./chunk-SHEUCITK.js";import{g as Mt,h as jt,i as Wt,k as Ft,l as Ut}from"./chunk-5RHCM3L7.js";import{q as Pt}from"./chunk-23LWLYOK.js";import{a as Ct,b as Dt}from"./chunk-BXXP6DTB.js";import{Aa as Tt,B as $t,C as At,D as Rt,E as _t,ka as xe,n as ee,o as St,p as vt,q as Jr,ra as It,sa as Et}from"./chunk-KHYF6KTY.js";import{a as we,h as Yr}from"./chunk-BRK6M6LA.js";import{f as ke,n as Zr}from"./chunk-UIBUZ2N3.js";import{existsSync as Qr,readdirSync as ei,readFileSync as ti,statSync as ni}from"fs";import{resolve as ri}from"path";function Qt(t,e,n=Date.now(),i=7){let r=i*864e5,s=new Map;for(let o of e){let a=s.get(o.workflowId);a?a.push(o):s.set(o.workflowId,[o])}return t.map(o=>{let a=s.get(o.id)??[],l=a.filter(f=>n-f.at<=r),c=a.filter(f=>n-f.at>r&&n-f.at<=r*2),u=l.filter(f=>f.status==="failed").length,d=a.filter(f=>f.status==="paused").length,p=a.length?Math.max(...a.map(f=>f.at)):null,g=a.length?c.length>0&&l.length===0?"dormant":l.length>0&&u*2>=l.length?"failing":l.length>0?"active":"quiet":"never";return{id:o.id,name:o.name||o.id,state:g,lastRunAt:p,recent:l.length,prior:c.length,failed:u,paused:d}}).sort((o,a)=>{let l={dormant:0,failing:1,active:2,quiet:3,never:4};return l[o.state]-l[a.state]||(a.lastRunAt??0)-(o.lastRunAt??0)})}var re=new Map;function Ea(t,e=1e3){if(!Qr(t))return[];let n=ei(t).filter(s=>s.endsWith(".jsonl")).map(s=>{let o=ri(t,s);return{path:o,mtime:ni(o).mtimeMs}}).sort((s,o)=>o.mtime-s.mtime).slice(0,e),i=new Set(n.map(s=>s.path));for(let s of re.keys())i.has(s)||re.delete(s);let r=[];for(let{path:s,mtime:o}of n){let a=re.get(s);if(a&&a.mtime===o){a.summary&&r.push(a.summary);continue}let l=ii(s,o);re.set(s,{mtime:o,summary:l}),l&&r.push(l)}return r}function ii(t,e){try{let n=ti(t,"utf-8").split(`
2
2
  `).filter(Boolean);if(!n.length)return null;let i=JSON.parse(n[0]),r=i.run?.workflowId;if(!r)return null;let s=i.run?.status??"unknown";for(let o=n.length-1;o>=0;o--){let a=JSON.parse(n[o]),l=a.status??a.run?.status;if(l){s=l;break}}return{workflowId:r,status:s,at:e}}catch{return null}}var si={failStreak:3,disabledDays:30,missedFires:2,graceMs:15*6e4},k={routines:200,summary:160,filters:6,filterValue:60,text:120},oi=(t,e,n)=>{try{return Pt(t,e,n)}catch{return null}},en=864e5;function Pa(t){let e=t.now??Date.now(),n={...si,...t.thresholds},i=t.nextFire??oi,r=[];for(let a of t.crons){let l=t.cronRuns.get(a.id)??[],c=a.timezone||"UTC",u=l.map(g=>({at:Date.parse(g.startedAt),status:g.status})),d=l[0],p={id:`cron:${a.id}`,source:"cron",kind:"schedule",name:$(a.id,k.text),trigger:{schedule:$(a.schedule,k.text),timezone:c},agent:a.agent||null,enabled:a.enabled,state:a.enabled?"enabled":"disabled",nextRunAt:a.enabled?_e(a.nextRun)??_e(i(a.schedule,new Date(e),c)):null,lastRun:d?{at:d.startedAt,status:d.status,summary:pi(d.status==="success"?void 0:d.errorSummary,k.summary)}:null,lastSuccessAt:l.find(g=>g.status==="success")?.startedAt??null,consecutiveFailures:tn(u),sampledRuns:l.length,flags:[],attention:null};p.flags=nn(p,u,a.schedule,c,null,e,n,i),r.push(rn(p))}let s=new Map(Qt(t.workflows.map(a=>({id:a.id,name:a.title})),t.workflowRuns,e).map(a=>[a.id,a])),o=new Map;for(let a of t.workflowRuns){let l=o.get(a.workflowId);l?l.push(a):o.set(a.workflowId,[a])}for(let a of t.workflows){let l=a.nodes.find(I=>I.type.startsWith("trigger."));if(!l||l.type!=="trigger.cron"&&l.type!=="trigger.hook")continue;let c=l.config??{},u=a.state||"active",d=u==="active",p=(o.get(a.id)??[]).slice().sort((I,ye)=>ye.at-I.at),g=p.map(I=>({at:I.at,status:ci(I.status)})),f=g[0],h=l.type==="trigger.cron",b=typeof c.spec=="string"?c.spec:"",C=typeof c.timezone=="string"?c.timezone:"UTC",M={id:`workflow:${a.id}`,source:"workflow",kind:h?"schedule":"event",name:$(a.title||a.id,k.text),trigger:h?{schedule:$(b,k.text),timezone:C}:{event:$(typeof c.event=="string"?c.event:"",k.text),filters:di(c.filter,a)},agent:ui(a),enabled:d,state:u,nextRunAt:h&&d&&b?_e(i(b,new Date(e),C)):null,lastRun:f?{at:new Date(f.at).toISOString(),status:f.status}:null,lastSuccessAt:(()=>{let I=g.find(ye=>ye.status==="success");return I?new Date(I.at).toISOString():null})(),consecutiveFailures:tn(g),sampledRuns:p.length,flags:[],attention:null},Q=Date.parse(a.updated||a.created||"");M.flags=h?nn(M,g,b,C,Number.isFinite(Q)?Q:null,e,n,i):ai(M,s.get(a.id)?.state==="dormant",Number.isFinite(Q)?Q:null,e,n),r.push(rn(M))}return r.sort(li).slice(0,k.routines)}function tn(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 nn(t,e,n,i,r,s,o,a){let l=[],c=e.length?e[0].at:null;if(!t.enabled){let p=on(c,r,s,o);return p&&l.push(p),l}if(t.consecutiveFailures>=o.failStreak&&l.push({reason:"failing",detail:`${t.consecutiveFailures} failed attempts in a row`}),c===null)return l.push({reason:"never-ran",detail:"No persisted attempt"}),l;let u=new Date(c),d=null;for(let p=0;p<o.missedFires&&(d=a(n,u,i),!!d);p++)u=d;return d&&s>d.getTime()+o.graceMs&&l.push({reason:"overdue",detail:`No attempt since ${new Date(c).toISOString()}; ${o.missedFires} scheduled fires missed`}),l}function ai(t,e,n,i,r){let s=[],o=t.lastRun?Date.parse(t.lastRun.at):null;if(!t.enabled){let a=on(o,n,i,r);return a&&s.push(a),s}return t.consecutiveFailures>=r.failStreak&&s.push({reason:"failing",detail:`${t.consecutiveFailures} failed runs in a row`}),o===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 on(t,e,n,i){let r=Math.max(t??0,e??0);return r&&n-r<i.disabledDays*en?null:{reason:"disabled-long",detail:r?`Disabled; no activity for ${Math.floor((n-r)/en)} days`:"Disabled and never ran"}}function rn(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 sn={critical:0,warning:1,info:2};function li(t,e){let n=t.attention?sn[t.attention]:3,i=e.attention?sn[e.attention]:3;return n-i||Number(e.enabled)-Number(t.enabled)||t.name.localeCompare(e.name)}function ci(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 ui(t){if(t.ownerAgent)return $(t.ownerAgent,k.text);let e=t.nodes.find(n=>n.type==="agent"&&typeof n.config?.agentId=="string"&&n.config.agentId);return e?$(String(e.config.agentId),k.text):null}function di(t,e){let n=[],i=e?.project;if(i&&n.push($(`project=${i}`,k.filterValue)),t&&typeof t=="object"&&!Array.isArray(t))for(let[r,s]of Object.entries(t)){let o=Array.isArray(s)?s.map(String):s==null?[]:[String(s)];o.length&&n.push($(`${r}=${o.join(",")}`,k.filterValue))}return n.slice(0,k.filters)}function _e(t){if(!t)return null;let e=t instanceof Date?t:new Date(t);return Number.isFinite(e.getTime())?e.toISOString():null}function $(t,e){return t.length<=e?t:t.slice(0,e-3)+"..."}function pi(t,e){return t===void 0?void 0:$(t,e)}import{existsSync as H,readdirSync as Pi,readFileSync as Ni}from"fs";import{resolve as R}from"path";import{randomBytes as cn}from"crypto";import{existsSync as fi,mkdirSync as mi,readdirSync as hi,readFileSync as bi,renameSync as un,unlinkSync as yi,writeFileSync as wi}from"fs";import{resolve as dn}from"path";function an(t){return[...t.account?["--account",t.account]:[],...t.store?["--store",t.store]:[]]}var gi=t=>t.trim().split(`
3
3
  `).pop()?.slice(0,300)||"no output";async function ln(t,e,n,i=Re){let r=await i(t.bin,[...an(t),"send","text","--to",e,"--message",n,"--no-preview"],{timeoutMs:6e4});return r.code===0?{ok:!0}:{ok:!1,error:`wacli send failed: ${gi(r.stderr||r.stdout)}`}}async function Oa(t,e,n,i,r=Re){return(await r(t.bin,[...an(t),"--read-only","media","download","--chat",e,"--id",n,"--output",i],{timeoutMs:12e4})).code===0}var ki=2e3,xi=t=>ln(t.wacli,t.to,t.text);function Ie(t){return dn(t,".agentx","whatsapp-triage","drafts")}var Si=t=>/^[a-z0-9-]{8,64}$/.test(t),ie=(t,e)=>dn(Ie(t),`${e}.json`);function pn(t,e){mi(Ie(t),{recursive:!0});let n=ie(t,e.id),i=`${n}.${process.pid}.tmp`;wi(i,JSON.stringify(e,null,2)+`
4
4
  `,{mode:384}),un(i,n)}function Va(t,e,n=Date.now()){let i=e.text.trim().slice(0,ki);if(!i)throw new Error("empty draft");let r={...e,text:i,id:`${n.toString(36)}-${cn(4).toString("hex")}`,status:"pending",created_at:new Date(n).toISOString()};return pn(t,r),r}function se(t,e){if(!Si(e))return null;try{return JSON.parse(bi(ie(t,e),"utf-8"))}catch{return null}}function gn(t,e){let n=Ie(t);return fi(n)?hi(n).filter(i=>i.endsWith(".json")).map(i=>se(t,i.slice(0,-5))).filter(i=>!!i&&(!e||i.status===e)).sort((i,r)=>i.created_at.localeCompare(r.created_at)):[]}async function fn(t,e,n,i={}){let r=se(t,e);if(!r||r.status!=="pending")return{ok:!1,error:`no reply draft "${e}" is waiting`};let s=`${ie(t,e)}.${process.pid}.${cn(3).toString("hex")}.claim`;try{un(ie(t,e),s)}catch{return{ok:!1,error:`reply draft "${e}" is already being decided`}}let o={...r,decided_by:i.by??"operator",decided_at:new Date(i.now??Date.now()).toISOString()};if(n==="no")o.status="rejected";else{let a=await(i.send??xi)(r).catch(l=>({ok:!1,error:String(l?.message??l)}));a.ok?o.status="sent":(o.status="failed",o.error=a.error)}pn(t,o);try{yi(s)}catch{}return o.status==="failed"?{ok:!1,error:o.error??"send failed"}:{ok:!0,draft:o}}import{mkdirSync as vi,readFileSync as $i,renameSync as Ai,writeFileSync as Ri}from"fs";import{resolve as _i}from"path";function mn(t){return _i(Ae(t),"_state.json")}function A(t){try{let e=JSON.parse($i(mn(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 B(t,e){vi(Ae(t),{recursive:!0});let n=mn(t),i=`${n}.${process.pid}.tmp`;Ri(i,JSON.stringify(e,null,2)+`
@@ -529,4 +529,4 @@ Document the arguments, commands, or files the skill expects. Example:
529
529
  claude-code ${xt(t)} --arg value
530
530
  \`\`\`
531
531
  `}Tt();var zr={maxPixels:12e5,timeoutMs:5e3,intervalMs:100,changeThreshold:.015,stableMs:400,regions:{},buffer:{enabled:!1,seconds:10,fps:2,region:"screen",maxPixels:3e5}};function Xr(t){return{...zr,...t??{},regions:{...t?.regions??{}},buffer:{...zr.buffer,...t?.buffer??{}}}}function td(t){try{return Xr(Et(t).screen)}catch{return Xr(void 0)}}var Ra=/^[a-z][\w-]*$/,Gr=["window","screen","menubar","notifications"];function Z(t,e,n,i){let r=Number(t);if(t===""||t===null||!Number.isFinite(r)||!n(r))throw new Error(`${e} must be ${i}`);return r}var be=(t,e)=>Z(t,e,n=>Number.isInteger(n)&&n>0,"a whole number above 0");function Kr(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 nd(t,e){let n={...t??{}};if("maxPixels"in e&&(n.maxPixels=be(e.maxPixels,"maxPixels")),"timeoutMs"in e&&(n.timeoutMs=be(e.timeoutMs,"timeoutMs")),"intervalMs"in e&&(n.intervalMs=be(e.intervalMs,"intervalMs")),"stableMs"in e&&(n.stableMs=Z(e.stableMs,"stableMs",r=>Number.isInteger(r)&&r>=0,"a whole number, 0 or more")),"changeThreshold"in e&&(n.changeThreshold=Z(e.changeThreshold,"changeThreshold",r=>r>=0&&r<=1,"between 0 and 1")),e.regions&&typeof e.regions=="object"){let r={...n.regions??{}};for(let[s,o]of Object.entries(e.regions)){if(!Ra.test(s))throw new Error(`region name "${s}" must be lowercase letters, digits, - or _`);o===null?delete r[s]:r[s]=Kr(o)}n.regions=r}if(e.buffer&&typeof e.buffer=="object"){let r=e.buffer,s={...n.buffer??{}};"enabled"in r&&(s.enabled=!!r.enabled),"seconds"in r&&(s.seconds=Z(r.seconds,"buffer.seconds",o=>o>0&&o<=120,"above 0 and at most 120")),"fps"in r&&(s.fps=Z(r.fps,"buffer.fps",o=>o>0&&o<=10,"above 0 and at most 10")),"maxPixels"in r&&(s.maxPixels=be(r.maxPixels,"buffer.maxPixels")),"region"in r&&(s.region=String(r.region).trim()),n.buffer=s}let i=n.buffer?.region;if(i!==void 0&&!Gr.includes(i)&&!n.regions?.[i])try{Kr(i)}catch{throw new Error(`buffer.region "${i}" is not a region \u2014 use ${[...Gr,...Object.keys(n.regions??{})].join(", ")}, or x,y,w,h`)}return n}export{Qt as a,Ea as b,tt as c,Ks as d,Js as e,mc as f,hc as g,bc as h,ar as i,wc as j,xc as k,D as l,lr as m,k as n,Pa as o,Oa as p,xi as q,Va as r,fn as s,A as t,Xa as u,Ga as v,Ya as w,oe as x,Za as y,xn as z,il as A,z as B,wl as C,kl as D,_n as E,cr as F,$c as G,_c as H,vr as I,eu as J,tu as K,au as L,qo as M,lu as N,Sl as O,vl as P,$l as Q,Al as R,Rl as S,_l as T,El as U,Tl as V,Wl as W,Me as X,Fl as Y,Ul as Z,X as _,G as $,Ko as aa,bu as ba,yu as ca,wu as da,ku as ea,ct as fa,xu as ga,Fe as ha,Ue as ia,pe as ja,ms as ka,bs as la,zl as ma,qe as na,Be as oa,ys as pa,ws as qa,Xn as ra,Yn as sa,Xl as ta,Ss as ua,Gl as va,Ts as wa,Ps as xa,He as ya,Ls as za,Zn as Aa,P as Ba,Lr as Ca,Or as Da,Mr as Ea,_u as Fa,ia as Ga,Wr as Ha,Fr as Ia,ju as Ja,Wu as Ka,ka as La,Fu as Ma,Vr as Na,ge as Oa,oc as Pa,ir as Qa,ze as Ra,Qe as Sa,gc as Ta,Bu as Ua,Hu as Va,zu as Wa,Xu as Xa,Gu as Ya,Ku as Za,Ju as _a,Yu as $a,Zu as ab,zr as bb,Xr as cb,td as db,Gr as eb,nd as fb};
532
- //# sourceMappingURL=chunk-LK4YO2FE.js.map
532
+ //# sourceMappingURL=chunk-PNITKKDR.js.map
@@ -1,2 +1,2 @@
1
- import{b as c}from"./chunk-KQ7KWFZY.js";function f(n,e){return`${n}:${e}`}function m(n){return n.includes(":")}var P="/app#alerts",h=3e3,x=2,w=40,A=120,k=1e3;function M(n,e="AgentX"){let o=c(n.text||""),r=(n.buttons??[]).filter(t=>t.url&&t.url.length<=k).slice(0,x).map((t,d)=>({action:`b${d}`,title:g(t.label,w),url:t.url})),s={title:g(o.title||e,A),body:o.body,url:r[0]?.url??P,actions:r},a=()=>Buffer.byteLength(JSON.stringify(s),"utf8");if(a()>h){let t=[...s.body],d=a()-h;for(t=t.slice(0,Math.max(0,t.length-d-1)),s.body=t.join("")+"\u2026";a()>h&&t.length>0;)t=t.slice(0,Math.max(0,t.length-32)),s.body=t.join("")+"\u2026"}return s}function g(n,e){let o=[...n];return o.length>e?o.slice(0,e-1).join("")+"\u2026":n}var y=class{constructor(e){this.deps=e;this.log=e.log??console.error.bind(console,"[push]")}name="push";log;async start(){let e=this.deps.store.list().length;this.log(`push: ready (${e} subscribed phone${e===1?"":"s"})${this.deps.keys()?"":" \u2014 no keys yet, run: agentx app push-keys"}`)}async stop(){}onMessage(e){}async send(e){let o=this.deps.keys();if(!o)throw new Error("push: no keys \u2014 run `agentx app push-keys` on this node");let r=(e.chatId||"").trim(),s=r&&r!=="default"?r:void 0;s&&e.origin&&!m(s)&&(s=f(e.origin,s));let a=[];for(let i of this.deps.store.list(s))this.deps.deviceActive(i.deviceId)&&i.publicKey===o.publicKey?a.push(i):this.deps.store.unsubscribe(i.endpoint);if(a.length===0)throw new Error(s?`push: phone ${s} has not turned on notifications`:"push: no phone has turned on notifications \u2014 open Alerts in the phone app");let t=M(e),d=JSON.stringify(t),v={vapidDetails:{subject:this.deps.subject,publicKey:o.publicKey,privateKey:o.privateKey},TTL:this.deps.ttlSeconds},u=0,l=[];if(await Promise.all(a.map(async i=>{try{await this.deps.sender({endpoint:i.endpoint,keys:{p256dh:i.p256dh,auth:i.auth}},d,v),u++}catch(p){p?.statusCode===404||p?.statusCode===410?(this.deps.store.unsubscribe(i.endpoint),this.log(`push: removed expired subscription for ${i.deviceName}`)):l.push(`${i.deviceName}: ${p?.statusCode?`HTTP ${p.statusCode} `:""}${p?.body||p?.message||p}`.slice(0,200))}})),u===0)throw new Error(`push: not delivered \u2014 ${l.join("; ")||"every subscription had expired"}`);return l.length&&this.log(`push: ${l.length} phone(s) failed: ${l.join("; ")}`),this.deps.store.log({title:t.title,body:t.body,url:t.url,delivered:u,deviceId:s??null},this.deps.keepRecent),String(u)}},b=class{constructor(e,o,r=console.error.bind(console,"[push]"),s){this.peer=e;this.forward=o;this.log=r;this.origin=s}name="push";async start(){this.log(`push: relaying to ${this.peer}`)}async stop(){}onMessage(e){}async send(e){if(e.relayed)throw new Error(`push: this node relays too (channels.push.relayTo = ${this.peer}); set relayTo only on nodes that don't host the phone app`);return this.forward(this.peer,{channel:"push",chatId:e.chatId||"default",text:e.text,...e.buttons?.length?{buttons:e.buttons}:{},relayed:!0,...this.origin?{origin:this.origin}:{}})}};export{f as a,m as b,P as c,h as d,M as e,y as f,b as g};
2
- //# sourceMappingURL=chunk-BWXRAPTX.js.map
1
+ import{b as c}from"./chunk-GFKLKPPY.js";function f(n,e){return`${n}:${e}`}function m(n){return n.includes(":")}var P="/app#alerts",h=3e3,x=2,w=40,A=120,k=1e3;function M(n,e="AgentX"){let o=c(n.text||""),r=(n.buttons??[]).filter(t=>t.url&&t.url.length<=k).slice(0,x).map((t,d)=>({action:`b${d}`,title:g(t.label,w),url:t.url})),s={title:g(o.title||e,A),body:o.body,url:r[0]?.url??P,actions:r},a=()=>Buffer.byteLength(JSON.stringify(s),"utf8");if(a()>h){let t=[...s.body],d=a()-h;for(t=t.slice(0,Math.max(0,t.length-d-1)),s.body=t.join("")+"\u2026";a()>h&&t.length>0;)t=t.slice(0,Math.max(0,t.length-32)),s.body=t.join("")+"\u2026"}return s}function g(n,e){let o=[...n];return o.length>e?o.slice(0,e-1).join("")+"\u2026":n}var y=class{constructor(e){this.deps=e;this.log=e.log??console.error.bind(console,"[push]")}name="push";log;async start(){let e=this.deps.store.list().length;this.log(`push: ready (${e} subscribed phone${e===1?"":"s"})${this.deps.keys()?"":" \u2014 no keys yet, run: agentx app push-keys"}`)}async stop(){}onMessage(e){}async send(e){let o=this.deps.keys();if(!o)throw new Error("push: no keys \u2014 run `agentx app push-keys` on this node");let r=(e.chatId||"").trim(),s=r&&r!=="default"?r:void 0;s&&e.origin&&!m(s)&&(s=f(e.origin,s));let a=[];for(let i of this.deps.store.list(s))this.deps.deviceActive(i.deviceId)&&i.publicKey===o.publicKey?a.push(i):this.deps.store.unsubscribe(i.endpoint);if(a.length===0)throw new Error(s?`push: phone ${s} has not turned on notifications`:"push: no phone has turned on notifications \u2014 open Alerts in the phone app");let t=M(e),d=JSON.stringify(t),v={vapidDetails:{subject:this.deps.subject,publicKey:o.publicKey,privateKey:o.privateKey},TTL:this.deps.ttlSeconds},u=0,l=[];if(await Promise.all(a.map(async i=>{try{await this.deps.sender({endpoint:i.endpoint,keys:{p256dh:i.p256dh,auth:i.auth}},d,v),u++}catch(p){p?.statusCode===404||p?.statusCode===410?(this.deps.store.unsubscribe(i.endpoint),this.log(`push: removed expired subscription for ${i.deviceName}`)):l.push(`${i.deviceName}: ${p?.statusCode?`HTTP ${p.statusCode} `:""}${p?.body||p?.message||p}`.slice(0,200))}})),u===0)throw new Error(`push: not delivered \u2014 ${l.join("; ")||"every subscription had expired"}`);return l.length&&this.log(`push: ${l.length} phone(s) failed: ${l.join("; ")}`),this.deps.store.log({title:t.title,body:t.body,url:t.url,delivered:u,deviceId:s??null},this.deps.keepRecent),String(u)}},b=class{constructor(e,o,r=console.error.bind(console,"[push]"),s){this.peer=e;this.forward=o;this.log=r;this.origin=s}name="push";async start(){this.log(`push: relaying to ${this.peer}`)}async stop(){}onMessage(e){}async send(e){if(e.relayed)throw new Error(`push: this node relays too (channels.push.relayTo = ${this.peer}); set relayTo only on nodes that don't host the phone app`);return this.forward(this.peer,{channel:"push",chatId:e.chatId||"default",text:e.text,...e.buttons?.length?{buttons:e.buttons}:{},relayed:!0,...this.origin?{origin:this.origin}:{}})}};export{f as a,m as b,P as c,h as d,M as e,y as f,b as g};
2
+ //# sourceMappingURL=chunk-Q72TK3DO.js.map
@@ -1,4 +1,4 @@
1
- import{a as Re,b as w,c as z,d as Pe,e as ie,f as se,g as M,h as le,i as N,j as O,n as De,o as ze,p as _e,q as We}from"./chunk-H4NSB54D.js";import{b as oe}from"./chunk-MTX4UPNB.js";import{e as Ee,i as Te}from"./chunk-QAWKN2N4.js";import{c as Ie,d as ae,e as T,f as re,g as B}from"./chunk-B2QYMUTD.js";import{a as G,b as Ce}from"./chunk-GIQKQD2B.js";import{a as Se}from"./chunk-7LN4VKDU.js";import{a as Ae}from"./chunk-IMLAPB7G.js";import{b as xe}from"./chunk-WCXXXAHV.js";import{c as ye,e as we}from"./chunk-LQE73AZR.js";import{b as $e}from"./chunk-MRIVENBY.js";import{i as ne,k as ke}from"./chunk-AKWBDCMU.js";import{G as K}from"./chunk-3K3LRLZX.js";import{a as L,b as F}from"./chunk-BXXP6DTB.js";import{a as ve}from"./chunk-RWMDDMYX.js";import{a as be}from"./chunk-ROLSSYXE.js";import{A as me,Aa as te,E as dt,V as fe,aa as ct,pa as ee,ra as H,sa as he,z as Z}from"./chunk-KHYF6KTY.js";import{existsSync as j,readFileSync as Oe,writeFileSync as Ue,appendFileSync as ut,mkdirSync as mt}from"fs";import{dirname as ft,resolve as _}from"path";import{fileURLToPath as ht}from"url";import{hostname as bt}from"os";import{spawn as vt}from"child_process";function Me(e,t){let n=e.configExists?e.agentCount===0?"Add your first agent":"Add another agent":"Set up your team",a=`<header class="ax-topbar">
1
+ import{a as Re,b as w,c as z,d as Pe,e as ie,f as se,g as M,h as le,i as N,j as O,n as De,o as ze,p as _e,q as We}from"./chunk-H4NSB54D.js";import{b as oe}from"./chunk-MTX4UPNB.js";import{e as Ee,i as Te}from"./chunk-QAWKN2N4.js";import{c as Ie,d as ae,e as T,f as re,g as B}from"./chunk-B2QYMUTD.js";import{a as G,b as Ce}from"./chunk-GIQKQD2B.js";import{a as Se}from"./chunk-7LN4VKDU.js";import{a as Ae}from"./chunk-IMLAPB7G.js";import{i as ne,k as ke}from"./chunk-AKWBDCMU.js";import{b as xe}from"./chunk-WCXXXAHV.js";import{c as ye,e as we}from"./chunk-LQE73AZR.js";import{b as $e}from"./chunk-MRIVENBY.js";import{G as K}from"./chunk-3K3LRLZX.js";import{a as L,b as F}from"./chunk-BXXP6DTB.js";import{a as ve}from"./chunk-RWMDDMYX.js";import{a as be}from"./chunk-ROLSSYXE.js";import{A as me,Aa as te,E as dt,V as fe,aa as ct,pa as ee,ra as H,sa as he,z as Z}from"./chunk-KHYF6KTY.js";import{existsSync as j,readFileSync as Oe,writeFileSync as Ue,appendFileSync as ut,mkdirSync as mt}from"fs";import{dirname as ft,resolve as _}from"path";import{fileURLToPath as ht}from"url";import{hostname as bt}from"os";import{spawn as vt}from"child_process";function Me(e,t){let n=e.configExists?e.agentCount===0?"Add your first agent":"Add another agent":"Set up your team",a=`<header class="ax-topbar">
2
2
  <div class="ax-topbar__left">
3
3
  <div class="ax-brand">
4
4
  <span class="ax-brand__mark">AX</span>
@@ -858,4 +858,4 @@ tr:hover td { background: var(--bg-hover); }
858
858
  WHERE person = ? AND state IN (${n.map(()=>"?").join(",")})
859
859
  ${a}`).all(t,...n,...o).map(i=>({id:i.id,state:i.state,channel:i.channel,agentId:i.agent_id,text:i.text,createdAt:i.created_at})):[]}function ga(e,t){return et(e,t,Z,"ORDER BY created_at")}function ua(e,t,n=50){return et(e,t,[...Z,...me],"ORDER BY created_at DESC, rowid DESC LIMIT ?",Math.max(1,Math.min(n,500)))}ct();var ue="member:",Yt=90,Vt="members",Xt="tailscale-user-login",Qt=400,Zt=60*60*1e3;function en(e){let t=e.scopes.find(n=>n.startsWith(ue));return t?t.slice(ue.length):null}function nt(e,t){if(!e)return null;let n=t.verify(e),a=n?en(n):null;return n&&a?{rec:n,personId:a}:null}function ya(e,t){let n=e.people().find(s=>s.id===t);if(!n)return{ok:!1,error:`No person "${t}". Add them first: agentx people add ${t} --name "\u2026"`};let{token:a,record:o}=e.tokens.create({name:`${n.name} (machine not paired yet)`,scopes:[`${ue}${n.id}`],expiresInDays:Yt}),{code:r,expiresAt:i}=e.codes.create({token:a,tokenId:o.id,name:n.id});return e.members.log({person:n.id,device:o.id,event:"invited"}),{ok:!0,code:r,expiresAt:i,tokenId:o.id,person:n}}var tn=Math.round(ye/6e4);function nn(e){return e==="client"?"Your project":"My work"}function wa(e){let t=nn(e.person.role),n=e.person.role==="client"?`I use AgentX to keep track of the work I do for you. It has a page for you, "${t}": 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, "${t}": what you asked the agents for, and where each request stands.`;return[`Hi ${e.person.name},`,"",n,"","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 ${tn} 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(`
860
860
  `)}var an="The private network says someone else is connecting from this machine. Ask the person who invited you for a new code.",rn="Too many machines are waiting for the owner's answer. Try again later.",tt="That code didn't work. Check it, or ask the person who invited you for a new one.",at=(e,t)=>{let n=e.headers[t];return(Array.isArray(n)?n[0]:n||"").trim()};function rt(e){let t=e.socket?.remoteAddress||"";return t==="127.0.0.1"||t==="::1"||t==="::ffff:127.0.0.1"}function on(e){if(!rt(e))return null;let t=at(e,Xt).toLowerCase();return t?t.slice(0,80):null}function sn(e){let t=e.socket?.remoteAddress||"unknown";if(!rt(e))return t;let n=at(e,"x-forwarded-for").split(",").pop().trim();return/^[0-9a-fA-F:.]{2,45}$/.test(n)?n:t}function ln(e){return typeof e=="string"?e.replace(/[^\p{L}\p{N} ._'()-]/gu," ").replace(/\s+/g," ").trim().slice(0,60):""}function dn(e){return e.identities.map(fe).filter(t=>!!t&&t.channel==="tailscale").map(t=>t.value)}async function ka(e,t){let n=Date.now(),a=t.now??Date.now,o=t.log??(b=>console.log(b)),r=sn(e),i=t.limiter.retryAfter(r);if(i>0)return o(`[member] pair-code refused from ${r}: locked out for ${i}s more`),{status:429,body:{error:"too many attempts",retryAfter:i},retryAfter:i};let s=null,l="";try{let b=await xe(e,2048);s=b.code,l=ln(b.machine)}catch{}let c=t.codes.redeem(s),d=c?nt(c.token,t.tokens):null;if(await pn(n,t.minMs??Qt),!c||!d)return t.limiter.fail(r),o(`[member] pair-code failed from ${r}`),{status:401,body:{error:tt}};t.limiter.succeed(r);let{rec:m,personId:p}=d,k=t.people().find(b=>b.id===p);if(!k)return t.tokens.revoke(m.id),t.members.log({person:p,device:m.id,event:"refused",address:r,detail:"person no longer listed"}),o(`[member] pair-code for ${p} refused from ${r}: person no longer listed`),{status:403,body:{error:tt}};let u=on(e),f=dn(k);if(f.length&&(!u||!f.includes(u)))return t.tokens.revoke(m.id),t.members.log({person:p,device:m.id,event:"refused",address:r,detail:`network login ${u??"missing"}; expected ${f.join(" or ")}`}),o(`[member] ${p}: pairing from ${r} refused: the network says "${u??"nobody"}", expected ${f.join(" or ")}`),{status:403,body:{error:an}};let I=l||"Unnamed machine",x=k.name.slice(0,40),v=ke(t.root,{title:`New machine for ${x}`,ask:`From ${r}, ${u?`network login ${u}`:"no network login reported"}. Machine name, as typed there: "${I}". Let it see ${x}'s own work?`,recommend:`Yes if ${x} told you they just paired this machine. No if you did not expect it.`,if_silent:"discard",raised_by:Vt},{now:a()});return v.ok?(t.members.add({tokenId:m.id,personId:p,name:I,state:"pending",cardId:v.card.id,address:r,...u?{network:u}:{},createdAt:new Date(a()).toISOString()}),t.members.log({person:p,device:m.id,event:"paired",address:r,detail:I}),o(`[member] ${p} paired "${I}" from ${r}; waiting for the owner (card ${v.card.id})`),{status:200,body:{person:p,name:I,state:"pending"},token:c.token}):(t.tokens.revoke(m.id),t.members.log({person:p,device:m.id,event:"refused",address:r,detail:v.error}),o(`[member] ${p}: pairing from ${r} refused: ${v.error}`),{status:503,body:{error:rn}})}var Q="this machine is not paired",cn="waiting for the owner to approve this machine";function ot(e){return e?e.status==="decided"?e.verdict??null:e.status==="expired"?"no":null:null}function $a(e,t){return t.state==="pending"&&t.cardId?ot(ne(e,t.cardId)):null}function Aa(e,t,n){let a=t.now??Date.now,o=t.log??(d=>console.log(d)),r=nt(e,t.tokens);if(!r)return{ok:!1,status:401,error:Q};let{rec:i,personId:s}=r,l=t.members.byToken(i.id);if(!l||l.state==="removed"||l.personId!==s)return{ok:!1,status:401,error:Q};if(t.people&&!t.people().some(d=>d.id===s))return it(t,i.id,"person no longer listed"),o(`[member] ${s}: "${l.name}" ended: person no longer listed`),{ok:!1,status:401,error:Q};if(l.state==="pending"){let d=l.cardId?ne(t.root,l.cardId):null,m=ot(d);if(m==="yes")l=t.members.update(i.id,{state:"active",approvedAt:new Date(a()).toISOString()})??l,t.members.log({person:s,device:i.id,event:"approved",detail:d?.decided_by}),o(`[member] ${s}: "${l.name}" approved`);else if(m==="no"){let p=d?.status==="expired"?"the owner did not answer in time":"the owner said no";return t.tokens.revoke(i.id),t.members.update(i.id,{state:"removed",removedAt:new Date(a()).toISOString(),removedReason:p}),t.members.log({person:s,device:i.id,event:"refused",detail:p}),o(`[member] ${s}: "${l.name}" refused: ${p}`),{ok:!1,status:401,error:Q}}else return{ok:!1,status:403,error:cn,waiting:!0}}let c=l.lastSeenAt?Date.parse(l.lastSeenAt):0;return n&&(a()-c>=Zt||l.lastAddress!==n)&&(l=t.members.update(i.id,{lastSeenAt:new Date(a()).toISOString(),lastAddress:n})??l,t.members.log({person:s,device:i.id,event:"signed-in",address:n})),{ok:!0,device:l,personId:s,rec:i}}function it(e,t,n="removed by the owner"){let a=e.members.byToken(t);if(!a)return null;e.tokens.revoke(t);let o=e.members.update(t,{state:"removed",removedAt:new Date((e.now??Date.now)()).toISOString(),removedReason:n});return e.members.log({person:a.personId,device:t,event:"removed",detail:n}),o}function Sa(e,t){return e.members.devices(t).filter(n=>n.state!=="removed").map(n=>it(e,n.tokenId,"person removed by the owner")).filter(n=>!!n)}async function pn(e,t){let n=e+t-Date.now();n>0&&await new Promise(a=>setTimeout(a,n))}var st=["gitlab","github"];function gn(e,t,n){let a=String(t||"").trim().toLowerCase();if(!st.includes(a))throw new Error(`Request status works on ${st.join(" and ")}, not on "${t}".`);e.requestStatus=e.requestStatus&&typeof e.requestStatus=="object"?e.requestStatus:{};let o=Array.isArray(e.requestStatus.channels)?e.requestStatus.channels.map(r=>String(r).toLowerCase()):[];return e.requestStatus.channels=n?[...new Set([...o,a])]:o.filter(r=>r!==a),`request status on ${a} is ${n?"on":"off"}`}function Ea(e){return Array.isArray(e?.requestStatus?.channels)?e.requestStatus.channels.map(t=>String(t).toLowerCase()):[]}function Ta(e){let{summary:t}=G(n=>gn(n,e?.channel,!!e?.enabled));return{summary:t}}function Pa(e){return new Set(Object.entries(e).filter(([,t])=>t?.wiki?.absorb?.enabled===!1).map(([t])=>t))}function Da(e,t){return t.only?{agents:[t.only],skipped:[]}:{agents:e.filter(n=>!t.off.has(n)),skipped:e.filter(n=>t.off.has(n))}}function za(e,t){return`absorb is off for this agent (agents.${e}.wiki.absorb.enabled); skipped.${e===t?" It reads the wiki notes inbox, so the inbox was not read.":""} Use --agent ${e} to run it anyway.`}function _a(e,t){if(t){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 un="https://ntfy.sh";function Ma(e){return{enabled:!!e?.enabled,server:e?.server||un,topicSet:!!e?.topic,tokenSet:!!e?.token}}function Na(e,t){let n={...e??{}};if("enabled"in t&&(n.enabled=!!t.enabled),"server"in t){let a=String(t.server).trim().replace(/\/+$/,"");if(!/^https?:\/\/\S+$/.test(a))throw new Error("ntfy server must be an http(s) URL");n.server=a}if("topic"in t){let a=String(t.topic).trim();if(!a)throw new Error("ntfy topic cannot be empty");n.topic=a}if("token"in t){let a=String(t.token??"").trim();a?n.token=a:delete n.token}if(n.enabled&&!n.topic)throw new Error("set a topic before enabling ntfy");return n}export{Be as a,An as b,Sn as c,In as d,Pn as e,Dn as f,zn as g,pa as h,ga as i,ua as j,Yt as k,ya as l,tn as m,nn as n,wa as o,sn as p,ka as q,$a as r,Aa as s,it as t,Sa as u,st as v,gn as w,Ea as x,Ta as y,Pa as z,Da as A,za as B,_a as C,Ma as D,Na as E,Ht as F,ta as G,sa as H,la as I};
861
- //# sourceMappingURL=chunk-K6UV4A2T.js.map
861
+ //# sourceMappingURL=chunk-QY5YUHGW.js.map