agentix-cli 0.135.0 → 0.135.1

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 (98) hide show
  1. package/dist/{absorb-eval-WY3YMLS4.js → absorb-eval-YT5TOTC7.js} +2 -2
  2. package/dist/{agent-3R5NY7I3.js → agent-DRUIMWF5.js} +2 -2
  3. package/dist/{board-dashboard-U3ZSCO62.js → board-dashboard-2524GN5N.js} +2 -2
  4. package/dist/chunk-32LIPTHM.js +55 -0
  5. package/dist/chunk-32LIPTHM.js.map +1 -0
  6. package/dist/{chunk-5NT44FKL.js → chunk-3D5XUOBL.js} +2 -2
  7. package/dist/{chunk-EEBK4F6E.js → chunk-3F4GPRGQ.js} +2 -2
  8. package/dist/{chunk-BQIWMQNU.js → chunk-H4NSB54D.js} +2 -2
  9. package/dist/chunk-MTX4UPNB.js +3 -0
  10. package/dist/chunk-MTX4UPNB.js.map +1 -0
  11. package/dist/{chunk-NY7NHGVT.js → chunk-MUVE3UAS.js} +2 -2
  12. package/dist/chunk-MWNCS57L.js +2 -0
  13. package/dist/chunk-MWNCS57L.js.map +1 -0
  14. package/dist/{chunk-GSKJ57XY.js → chunk-NG72DYJR.js} +80 -80
  15. package/dist/chunk-NG72DYJR.js.map +1 -0
  16. package/dist/{chunk-ZGVVYJIK.js → chunk-R6ECKZLE.js} +2 -2
  17. package/dist/{chunk-MI7WOGH6.js → chunk-R6KLH34H.js} +2 -2
  18. package/dist/{chunk-RGZARSHV.js → chunk-ROLSSYXE.js} +1 -1
  19. package/dist/{chunk-RGZARSHV.js.map → chunk-ROLSSYXE.js.map} +1 -1
  20. package/dist/{chunk-YA3P77LV.js → chunk-SKSYII3K.js} +2 -2
  21. package/dist/{chunk-6WF56ME6.js → chunk-SN7YH4E4.js} +2 -2
  22. package/dist/{chunk-RVEMX5MJ.js → chunk-TTG3ZW3W.js} +2 -2
  23. package/dist/{chunk-ZFRXFUP7.js → chunk-UTW56K5I.js} +2 -2
  24. package/dist/{chunk-H6VWU2HN.js → chunk-UXOGNBGL.js} +2 -2
  25. package/dist/{chunk-L5UGH4T4.js → chunk-WYEWNN76.js} +3 -3
  26. package/dist/{chunk-LU7GDHGD.js → chunk-ZEAT2B5B.js} +2 -2
  27. package/dist/cli.js +1 -1
  28. package/dist/{contributions-KLRJ4ZXV.js → contributions-ZD6ZGTJR.js} +2 -2
  29. package/dist/enrich-EFIPWA3P.js +16 -0
  30. package/dist/{enrich-ZB5I7KHN.js.map → enrich-EFIPWA3P.js.map} +1 -1
  31. package/dist/event-levels-7CY7AJLY.js +3 -0
  32. package/dist/event-levels-7CY7AJLY.js.map +1 -0
  33. package/dist/{hub-TILTOOSS.js → hub-MVX3U6A2.js} +2 -2
  34. package/dist/index.js +1 -1
  35. package/dist/load-LQ2I2PQI.js +2 -0
  36. package/dist/model-call-J7JATTMW.js +2 -0
  37. package/dist/{program-U3HJY7E5.js → program-WOQXOAYQ.js} +194 -194
  38. package/dist/program-WOQXOAYQ.js.map +1 -0
  39. package/dist/{promote-RHVZB2QZ.js → promote-X2XQEEQP.js} +2 -2
  40. package/dist/push-bridge-325SXDGN.js +1 -1
  41. package/dist/query-RRHYPXOM.js +2 -0
  42. package/dist/query-runs-WYRNBLLC.js +6 -0
  43. package/dist/query-runs-WYRNBLLC.js.map +1 -0
  44. package/dist/{query-settings-2MGUS6AY.js → query-settings-WKVLQEVZ.js} +2 -2
  45. package/dist/{registry-LZLIPP7N.js → registry-VXK36CCL.js} +2 -2
  46. package/dist/score-LNJ46A67.js +3 -0
  47. package/dist/score-LNJ46A67.js.map +1 -0
  48. package/dist/types-YZX46RES.js +2 -0
  49. package/dist/{wiki-GCRRINW3.js → wiki-QZ7XNAMJ.js} +2 -2
  50. package/dist/wiki-enrich-PMG4T6PP.js +2 -0
  51. package/package.json +1 -1
  52. package/dist/chunk-GSKJ57XY.js.map +0 -1
  53. package/dist/chunk-JRS5QRZG.js +0 -2
  54. package/dist/chunk-JRS5QRZG.js.map +0 -1
  55. package/dist/chunk-JTDUTCUE.js +0 -3
  56. package/dist/chunk-JTDUTCUE.js.map +0 -1
  57. package/dist/chunk-WWDYDLY2.js +0 -55
  58. package/dist/chunk-WWDYDLY2.js.map +0 -1
  59. package/dist/enrich-ZB5I7KHN.js +0 -16
  60. package/dist/event-levels-CQWHSLMT.js +0 -3
  61. package/dist/event-levels-CQWHSLMT.js.map +0 -1
  62. package/dist/load-EOZUZK7U.js +0 -2
  63. package/dist/model-call-PKV5UAQ7.js +0 -2
  64. package/dist/program-U3HJY7E5.js.map +0 -1
  65. package/dist/query-OZXZVLO7.js +0 -2
  66. package/dist/query-runs-7VX3YAC3.js +0 -4
  67. package/dist/query-runs-7VX3YAC3.js.map +0 -1
  68. package/dist/score-DZGPLHCL.js +0 -3
  69. package/dist/score-DZGPLHCL.js.map +0 -1
  70. package/dist/types-LJZ2YY5W.js +0 -2
  71. package/dist/wiki-enrich-P5TNWACZ.js +0 -2
  72. /package/dist/{absorb-eval-WY3YMLS4.js.map → absorb-eval-YT5TOTC7.js.map} +0 -0
  73. /package/dist/{agent-3R5NY7I3.js.map → agent-DRUIMWF5.js.map} +0 -0
  74. /package/dist/{board-dashboard-U3ZSCO62.js.map → board-dashboard-2524GN5N.js.map} +0 -0
  75. /package/dist/{chunk-5NT44FKL.js.map → chunk-3D5XUOBL.js.map} +0 -0
  76. /package/dist/{chunk-EEBK4F6E.js.map → chunk-3F4GPRGQ.js.map} +0 -0
  77. /package/dist/{chunk-BQIWMQNU.js.map → chunk-H4NSB54D.js.map} +0 -0
  78. /package/dist/{chunk-NY7NHGVT.js.map → chunk-MUVE3UAS.js.map} +0 -0
  79. /package/dist/{chunk-ZGVVYJIK.js.map → chunk-R6ECKZLE.js.map} +0 -0
  80. /package/dist/{chunk-MI7WOGH6.js.map → chunk-R6KLH34H.js.map} +0 -0
  81. /package/dist/{chunk-YA3P77LV.js.map → chunk-SKSYII3K.js.map} +0 -0
  82. /package/dist/{chunk-6WF56ME6.js.map → chunk-SN7YH4E4.js.map} +0 -0
  83. /package/dist/{chunk-RVEMX5MJ.js.map → chunk-TTG3ZW3W.js.map} +0 -0
  84. /package/dist/{chunk-ZFRXFUP7.js.map → chunk-UTW56K5I.js.map} +0 -0
  85. /package/dist/{chunk-H6VWU2HN.js.map → chunk-UXOGNBGL.js.map} +0 -0
  86. /package/dist/{chunk-L5UGH4T4.js.map → chunk-WYEWNN76.js.map} +0 -0
  87. /package/dist/{chunk-LU7GDHGD.js.map → chunk-ZEAT2B5B.js.map} +0 -0
  88. /package/dist/{contributions-KLRJ4ZXV.js.map → contributions-ZD6ZGTJR.js.map} +0 -0
  89. /package/dist/{hub-TILTOOSS.js.map → hub-MVX3U6A2.js.map} +0 -0
  90. /package/dist/{load-EOZUZK7U.js.map → load-LQ2I2PQI.js.map} +0 -0
  91. /package/dist/{model-call-PKV5UAQ7.js.map → model-call-J7JATTMW.js.map} +0 -0
  92. /package/dist/{promote-RHVZB2QZ.js.map → promote-X2XQEEQP.js.map} +0 -0
  93. /package/dist/{query-OZXZVLO7.js.map → query-RRHYPXOM.js.map} +0 -0
  94. /package/dist/{query-settings-2MGUS6AY.js.map → query-settings-WKVLQEVZ.js.map} +0 -0
  95. /package/dist/{registry-LZLIPP7N.js.map → registry-VXK36CCL.js.map} +0 -0
  96. /package/dist/{types-LJZ2YY5W.js.map → types-YZX46RES.js.map} +0 -0
  97. /package/dist/{wiki-GCRRINW3.js.map → wiki-QZ7XNAMJ.js.map} +0 -0
  98. /package/dist/{wiki-enrich-P5TNWACZ.js.map → wiki-enrich-PMG4T6PP.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-RVEMX5MJ.js";import"./chunk-ZFRXFUP7.js";import"./chunk-WWDYDLY2.js";import"./chunk-YA3P77LV.js";import"./chunk-ERULJ2ZL.js";import"./chunk-WPNRDEHW.js";import"./chunk-JRS5QRZG.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-4XMALK7X.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"./chunk-DYGQF3MI.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{i as JUDGE_ENTRY_CHARS,e as WEAK_CITATION,j as buildJudgePrompt,l as buildScorecard,f as checkArticle,n as envelopeUsage,h as findDuplicates,k as parseJudgeReply,b as pickSample,m as renderScorecard,a as seededRandom,o as summariseRuns,d as termOverlap,c as terms,g as uncitedWithFacts};
2
- //# sourceMappingURL=absorb-eval-WY3YMLS4.js.map
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-TTG3ZW3W.js";import"./chunk-UTW56K5I.js";import"./chunk-32LIPTHM.js";import"./chunk-SKSYII3K.js";import"./chunk-ERULJ2ZL.js";import"./chunk-WPNRDEHW.js";import"./chunk-MWNCS57L.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-4XMALK7X.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"./chunk-DYGQF3MI.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{i as JUDGE_ENTRY_CHARS,e as WEAK_CITATION,j as buildJudgePrompt,l as buildScorecard,f as checkArticle,n as envelopeUsage,h as findDuplicates,k as parseJudgeReply,b as pickSample,m as renderScorecard,a as seededRandom,o as summariseRuns,d as termOverlap,c as terms,g as uncitedWithFacts};
2
+ //# sourceMappingURL=absorb-eval-YT5TOTC7.js.map
@@ -1,2 +1,2 @@
1
- import{A as a,B as b,C as c}from"./chunk-H6VWU2HN.js";import"./chunk-SFQUP3BP.js";import"./chunk-QOYAX2FT.js";import"./chunk-2PJKGZWP.js";import"./chunk-7I7IEX4S.js";import"./chunk-JHCI6XCJ.js";import"./chunk-DSYKYZMT.js";import"./chunk-QIJLFPWE.js";export{a as createAgentContext,b as generate,c as generateStream};
2
- //# sourceMappingURL=agent-3R5NY7I3.js.map
1
+ import{A as a,B as b,C as c}from"./chunk-UXOGNBGL.js";import"./chunk-SFQUP3BP.js";import"./chunk-QOYAX2FT.js";import"./chunk-2PJKGZWP.js";import"./chunk-7I7IEX4S.js";import"./chunk-JHCI6XCJ.js";import"./chunk-DSYKYZMT.js";import"./chunk-QIJLFPWE.js";export{a as createAgentContext,b as generate,c as generateStream};
2
+ //# sourceMappingURL=agent-DRUIMWF5.js.map
@@ -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-EEBK4F6E.js";import"./chunk-BQIWMQNU.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"./chunk-JTDUTCUE.js";import{a as C}from"./chunk-SMAI7U6H.js";import{a as Or}from"./chunk-LNY6N73E.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 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-ZGVVYJIK.js";import"./chunk-GTJIKXDB.js";import{h as Qn,i as Zn}from"./chunk-XOUO4XNA.js";import{p as nr,t as rr}from"./chunk-S2GAEH2F.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{a as ir,b as yt,d as lr,e as dr,f as wt}from"./chunk-WCXXXAHV.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-AKLZ4YO2.js";import"./chunk-5NT44FKL.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{b as sr}from"./chunk-JWDJMFU6.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-QDWEM4DG.js";import"./chunk-QSKG754X.js";import"./chunk-MEFPXHQJ.js";import"./chunk-Y4CYQV7G.js";import"./chunk-SHEUCITK.js";import"./chunk-FWDRBUMS.js";import"./chunk-SZDACK6O.js";import"./chunk-AFRHKA7B.js";import"./chunk-SSQMFHSM.js";import{a as Kn}from"./chunk-LUYN6RAC.js";import"./chunk-3UOTLMXD.js";import"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-6WF56ME6.js";import"./chunk-NY7NHGVT.js";import"./chunk-KEXBEUSU.js";import"./chunk-RGZARSHV.js";import{g as zn}from"./chunk-ERULJ2ZL.js";import"./chunk-WPNRDEHW.js";import"./chunk-4XMALK7X.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{B as nc,I as Nn,L as va,O as Dn,Q as mt,R as Hn,T as Bn,V as qn,Z as ya,a as Mn,b as Ln,c as ec,pa as X,u as ct,v as tc,w as xa,x as ba,xa as ft}from"./chunk-DYGQF3MI.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-3F4GPRGQ.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-SMAI7U6H.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-R6ECKZLE.js";import"./chunk-GTJIKXDB.js";import{h as Qn,i as Zn}from"./chunk-XOUO4XNA.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-AKLZ4YO2.js";import"./chunk-3D5XUOBL.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-QDWEM4DG.js";import"./chunk-QSKG754X.js";import"./chunk-MEFPXHQJ.js";import"./chunk-Y4CYQV7G.js";import"./chunk-SHEUCITK.js";import"./chunk-FWDRBUMS.js";import"./chunk-SZDACK6O.js";import"./chunk-AFRHKA7B.js";import"./chunk-SSQMFHSM.js";import{a as Kn}from"./chunk-LUYN6RAC.js";import"./chunk-3UOTLMXD.js";import"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-SN7YH4E4.js";import"./chunk-MUVE3UAS.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import{g as zn}from"./chunk-ERULJ2ZL.js";import"./chunk-WPNRDEHW.js";import"./chunk-4XMALK7X.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{B as nc,I as Nn,L as va,O as Dn,Q as mt,R as Hn,T as Bn,V as qn,Z as ya,a as Mn,b as Ln,c as ec,pa as X,u as ct,v as tc,w as xa,x as ba,xa as ft}from"./chunk-DYGQF3MI.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-U3ZSCO62.js.map
20923
+ //# sourceMappingURL=board-dashboard-2524GN5N.js.map
@@ -0,0 +1,55 @@
1
+ import{a as _,b as F,c as K,d as z,e as J}from"./chunk-SKSYII3K.js";import{a as j,b as I,c as Y,d as V,e as B,j as G}from"./chunk-ERULJ2ZL.js";import{a as H}from"./chunk-MWNCS57L.js";import{y as N,z as ot}from"./chunk-4XMALK7X.js";import{g as Q}from"./chunk-6TURWSMN.js";import{b as E,c as L}from"./chunk-QOYAX2FT.js";import{readFileSync as lt,existsSync as X}from"fs";ot();import{resolve as R}from"path";import{execSync as ct}from"child_process";var ht="haiku",dt="sonnet",pt=.8;function mt(e,r,o,t){if(t.size===0)return 0;let c=e.listArticles(r||"").map(l=>l.path).filter(l=>!l.includes("/_versions/"));return c.length===0&&(c=o.sharedPool.map(l=>l.path)),c.length===0?0:c.filter(l=>t.has(l)).length/c.length}async function _t(e,r,o,t={}){let c=t.selectorModel??ht,l=t.synthModel??dt,m=t.maxCandidates??3,g=t.maxHops??2,d=t.maxArticles??8,i=t.timeoutMs??6e4,s=t.log??console.error.bind(console,"[wiki-query]"),h=t.messagePath?.length?t.messagePath:void 0,n=t.graphWeight??W,a=R(r.baseDir,"_index.md"),p=tt(r,o,t.shared),b=t.method??"catalog";if(b!=="catalog"){let u=z(r,t.shared);if(b==="summaries"||mt(r,o,p,u)>=pt){let f=t.summaries??K,P=t.notes&&o&&t.notes.owner===o?F(t.notes):void 0,y=await J(e,P?gt(p,P):p,P?new Map([...u,...P.summaries]):u,{...f,navigatorModel:t.selectorModel??f.navigatorModel,answerModel:t.synthModel??f.answerModel},{call:t.call??H,fetch:t.fetch,timeoutMs:i,log:s}),$=y.picked.map(w=>({title:w.meta.title,path:w.path,type:_(w.path)?"note":w.meta.type,hop:w.hop}));return{answer:y.answer,citations:y.status==="ok"?$.map(({hop:w,...v})=>v):[],candidates:$.filter(w=>w.hop===0).map(({title:w,path:v})=>({title:w,path:v})),walked:$,status:y.status,method:"summaries",basis:y.basis,live:y.live,liveAsked:y.liveAsked,trace:y.trace,...y.error?{error:y.error}:{}}}}if(!X(a)&&p.sharedPool.length===0)return M("no-catalog",e,"No _index.md found \u2014 run `agentx wiki status` to rebuild.");let it=(X(a)?lt(a,"utf-8"):"")+yt(e,p.sharedPool,h,n),T=Date.now(),A=[],S="";try{let u=await nt(e,p.pool,o,m,h,n);u?(A=u,S=`[wiki-rerank seat] ${u.map(f=>f.title).join(" | ")}`):(S=await Z(wt(e,it,m,h),c,i),A=bt(S))}catch(u){return s("selector failed:",u?.message),{...M("error",e,`Selector: ${u?.message||"unknown"}`),trace:{selectorMs:Date.now()-T,synthesisMs:0,selectorOutput:S}}}let x=Date.now()-T;if(A.length===0)return{...M("no-candidates",e,"Selector returned no candidates."),trace:{selectorMs:x,synthesisMs:0,selectorOutput:S}};let C=rt(A,p,g,d);if(C.length===0)return{...M("no-candidates",e,"Candidates did not resolve to readable articles."),candidates:A,trace:{selectorMs:x,synthesisMs:0,selectorOutput:S}};let D=Date.now(),U="";try{U=await Z(kt(e,C),l,i*2)}catch(u){return s("synthesis failed:",u?.message),{...M("error",e,`Synthesis: ${u?.message||"unknown"}`),candidates:A,walked:C.map(f=>({title:f.meta.title,path:f.path,type:f.meta.type,hop:f.hop??0})),trace:{selectorMs:x,synthesisMs:Date.now()-D,selectorOutput:S}}}let st=Date.now()-D;return{answer:U.trim(),citations:C.map(u=>({title:u.meta.title,path:u.path,type:u.meta.type})),candidates:A,walked:C.map(u=>({title:u.meta.title,path:u.path,type:u.meta.type,hop:u.hop??0})),status:"ok",trace:{selectorMs:x,synthesisMs:st,selectorOutput:S}}}async function Rt(e,r,o,t={}){let c=t.maxCandidates??3,l=t.graphWeight??W,m=t.messagePath?.length?t.messagePath:void 0,g=t.pool??q(r);if(g.length===0||!e.trim())return[];let d=await nt(e,g,o,c,m,l,t.stage??"retrieve");if(!d){let i=new Set(L(e,E(g.map(at))).map(s=>s.docIndex));d=O(e,g,m,l).filter(s=>i.has(s)).slice(0,c).map(s=>({title:g[s].title,path:g[s].path}))}return d.length===0?[]:rt(d,tt(r,o),t.maxHops??1,t.maxArticles??6)}function q(e){try{return(e.rebuildIndex().articles??[]).filter(r=>r.path&&!r.path.includes("/_versions/"))}catch{return[]}}function M(e,r,o){return{answer:"",citations:[],candidates:[],walked:[],status:e,error:o}}function tt(e,r,o=[]){let t=new Map,c=[];for(let i of e.listArticles(r||""))t.set(i.meta.title.toLowerCase(),i.path),c.push({path:i.path,related:i.meta.related??[],lastUpdated:i.meta.lastUpdated??""});let l=[],m=new Map;for(let i of o)if(i.store.baseDir!==e.baseDir){m.set(i.id,i);for(let s of i.store.listArticles(r||"")){if(s.path.includes("/_versions/")||i.skip?.(s.path))continue;let h=`@${i.id}/${s.path}`;l.push(ut(s,h)),c.push({path:h,related:s.meta.related??[],lastUpdated:s.meta.lastUpdated??""});let n=s.meta.title.toLowerCase();t.has(n)||t.set(n,h)}}let g=new Map;if(m.size>0)for(let i of[...c].sort((s,h)=>h.lastUpdated.localeCompare(s.lastUpdated)))for(let s of i.related){let h=s.toLowerCase(),n=g.get(h)??[];n.includes(i.path)||n.push(i.path),g.set(h,n)}let d;return{backlinks:g,readable:new Set(c.map(i=>i.path)),get pool(){return d??=[...q(e),...l]},sharedPool:l,titleIndex:t,read(i){let s=i.match(/^@([^/]+)\/(.+)$/),h=s?m.get(s[1]):void 0;if(s&&!h)return null;let n=h?.store??e,a=s?s[2]:i,p=r?n.readArticleAs(a,r):n.readArticle(a);return p?{...p,path:i}:null},links(i){let s=(i.meta.related??[]).map(a=>t.get(a.toLowerCase())).filter(a=>!!a),h=[i.meta.title,...i.meta.aliases??[]].map(a=>a.toLowerCase()),n=[...new Set(h.flatMap(a=>g.get(a)??[]))].filter(a=>a!==i.path).slice(0,et);return[...new Set([...s,...n])].filter(a=>a!==i.path)}}}function gt(e,r){return{...e,pool:[...e.pool,...r.pool],readable:new Set([...e.readable,...r.pool.map(o=>o.path)]),read:o=>_(o)?r.read(o):e.read(o)}}function ut(e,r){return{path:r,title:e.meta.title,type:e.meta.type,related:e.meta.related,tags:e.meta.tags||[],owner:e.meta.owner,access:e.meta.access,sharedWith:e.meta.sharedWith,aliases:[e.meta.title.toLowerCase(),...(e.meta.aliases??[]).map(o=>o.toLowerCase())],backlinks:0,sources:e.meta.sources,lastUpdated:e.meta.lastUpdated,graphPath:e.meta.graphPath}}var ft=150;function yt(e,r,o,t){return r.length===0?"":`
2
+
3
+ ## Shared wiki (other agents' articles)
4
+
5
+ ${O(e,r,o,t).slice(0,ft).map(l=>`- ${r[l].title}${r[l].type?` [${r[l].type}]`:""} (${r[l].path})`).join(`
6
+ `)}
7
+ `}var et=3;function rt(e,r,o,t){let c=r.titleIndex,l=n=>n.startsWith("@"),m=[...e.filter(n=>!l(n.path)),...e.filter(n=>l(n.path))],g=m.length>0&&!l(m[0].path)?Math.floor(t/2):t,d=new Map,i=0,s=m.map(n=>({path:n.path,hop:0})),h=[];for(;d.size<t;){if(!s.length){if(!h.length||g>=t)break;g=t,s=h.splice(0)}let n=s.shift();if(d.has(n.path)||n.hop>o)continue;if(l(n.path)&&i>=g){h.push(n);continue}let a=r.read(n.path);if(a&&(d.set(n.path,{...a,hop:n.hop}),l(n.path)&&i++,!(n.hop>=o))){if(n.hop===0){let p=[a.meta.title,...a.meta.aliases??[]].map(k=>k.toLowerCase()),b=[...new Set(p.flatMap(k=>r.backlinks.get(k)??[]))].filter(k=>k!==n.path&&!d.has(k)).slice(0,et);for(let k of b)s.push({path:k,hop:1})}for(let p of a.meta.related||[]){let b=c.get(p.toLowerCase());b&&!d.has(b)&&s.push({path:b,hop:n.hop+1})}}}return Array.from(d.values())}async function nt(e,r,o,t,c,l=W,m="catalog-selector"){try{if(r.length<2)return null;let d=O(e,r,c,l).slice(0,I).map(n=>({id:`k${n}`,title:r[n].title||r[n].path,tags:r[n].tags,excerpt:[r[n].type?`type: ${r[n].type}`:"",(r[n].related??[]).length?`related: ${(r[n].related??[]).join(", ")}`:"",(r[n].graphPath??[]).length?`graph: ${(r[n].graphPath??[]).join(" \u203A ")}`:""].filter(Boolean).join(" \xB7 ")})),i=await N(j,Y({query:e,candidates:d,excerptChars:300}),V(d),{features:{agent:o??"unknown",stage:m}});if(!i||i.mode!=="active")return null;let h=B(i.answers,d).ranked.slice(0,t).map(n=>r[Number(n.slice(1))]).filter(Boolean).map(n=>({title:n.title,path:n.path}));return h.length>0?h:null}catch{return null}}var W=.6;function O(e,r,o,t=W){let c=L(e,E(r.map(at))),l=c.reduce((a,p)=>Math.max(a,p.score),0),m=new Map(c.map(a=>[a.docIndex,l>0?a.score/l:0])),g=!!o?.length,d=a=>g&&a.graphPath?.length?G(o,a.graphPath):0,i=(a,p)=>p.score-a.score||a.i-p.i,s=r.map((a,p)=>({i:p,score:(m.get(p)??0)*(1+t*d(a))})).filter(a=>m.has(a.i)).sort(i),h=r.map((a,p)=>({i:p,score:d(a)})).filter(a=>!m.has(a.i)&&a.score>0).sort(i),n=[...s,...h].map(a=>a.i);for(let a=0;a<r.length;a++)n.includes(a)||n.push(a);return n}function at(e){return[e.title,(e.tags??[]).join(" "),(e.related??[]).join(" ")].join(" ")}function wt(e,r,o,t){let c=t?.length?`
8
+ ## Intent
9
+
10
+ The request was classified under the intent-graph path "${t.join(" \u203A ")}". Prefer articles filed under the same branch when their titles are equally plausible.
11
+ `:"";return`You are picking candidate articles from a wiki catalog to answer a question. You do NOT answer the question. You pick which articles the answer is likely to come from.
12
+
13
+ ## Question
14
+
15
+ ${e}
16
+ ${c}
17
+ ## Catalog (_index.md \u2014 articles grouped by type, with wikilink previews)
18
+
19
+ ${r}
20
+
21
+ ## Your task
22
+
23
+ Pick up to ${o} articles from the catalog that are most likely to answer the question. Prefer:
24
+ - Articles whose title directly names a subject in the question.
25
+ - Articles of the right type (e.g. a "who owns X" question \u2192 person or project; a "what happened on DATE" \u2192 event).
26
+ - Articles whose wikilinks suggest they sit at the center of a relevant subgraph.
27
+
28
+ Return ONLY valid JSON, no markdown fencing, no prose:
29
+
30
+ [
31
+ {"title": "Exact Article Title", "path": "path/from/catalog.md"},
32
+ ...
33
+ ]
34
+
35
+ If none of the articles match, return [].`}function kt(e,r){let o=r.map(t=>{let c=[t.meta.owner?`owner: ${t.meta.owner}`:"",t.meta.lastUpdated?`updated: ${t.meta.lastUpdated}`:""].filter(Boolean).join(", "),l=`### ${t.meta.title} \u2014 ${t.meta.type||"untyped"} (${t.path}) [hop ${t.hop}]${c?` {${c}}`:""}`,m=t.meta.related?.length?`Related: ${t.meta.related.join(", ")}`:"";return[l,m,"",t.content].filter(Boolean).join(`
36
+ `)}).join(`
37
+
38
+ ---
39
+
40
+ `);return`You are answering a question using a small subgraph of wiki articles. The articles were walked from the catalog; trust them over your prior knowledge.
41
+
42
+ ## Question
43
+
44
+ ${e}
45
+
46
+ ## Articles (${r.length} walked from the catalog)
47
+
48
+ ${o}
49
+
50
+ ## Your task
51
+
52
+ Answer the question in 2\u20136 sentences. Cite articles by their title in square brackets like [Article Title]. When two articles disagree, prefer the one updated more recently, and say which agent's page and date the answer comes from. If the articles do not answer the question, say so plainly (do not invent). Prefer concrete facts over hedging.
53
+
54
+ Output ONLY the answer \u2014 no preamble, no "here is my answer:", no markdown fencing.`}function bt(e){let r=e.match(/\[[\s\S]*?\]/);if(!r)return[];try{let o=JSON.parse(r[0]);return Array.isArray(o)?o.filter(t=>t&&typeof t.title=="string"&&typeof t.path=="string").map(t=>({title:t.title,path:t.path})):[]}catch{return[]}}async function Z(e,r,o){let{writeFileSync:t,mkdirSync:c,rmSync:l}=await import("fs"),{tmpdir:m}=await import("os"),g=R(m(),`agentx-wiki-query-${process.pid}`);c(g,{recursive:!0});let d=R(g,`prompt-${Date.now()}.txt`);t(d,e);try{let i=`cat '${d}' | claude -p - --output-format json --max-turns 1 --model ${r} --disallowedTools "Bash Read Write Edit Glob Grep Agent WebSearch WebFetch NotebookEdit"`,s=ct(i,{env:Q(),encoding:"utf-8",timeout:o,maxBuffer:4*1024*1024});try{let h=JSON.parse(s);return String(h.result||h.content||"")}catch{return s}}finally{try{l(d,{force:!0})}catch{}}}async function Ot(e){try{let{loadDaemonConfig:r}=await import("./config-GHMRBRDL.js");return r(e).wiki.query.shared}catch{return!0}}export{ht as a,dt as b,pt as c,_t as d,Rt as e,q as f,ft as g,W as h,O as i,Ot as j};
55
+ //# sourceMappingURL=chunk-32LIPTHM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/wiki/query.ts"],"sourcesContent":["import { readFileSync, existsSync } from \"fs\"\nimport { buildIndex, scoreAll } from \"@/memory/bm25\"\nimport { askSeat } from \"@/decisions/seat\"\nimport { ancestryScore } from \"@/graph\"\nimport {\n DEFAULT_SHORTLIST,\n WIKI_RERANK_SEAT,\n rerankQuestions,\n rerankState,\n toRanking,\n type RerankCandidate,\n} from \"@/decisions/seats/wiki-rerank\"\nimport { claudeCliEnv } from \"@/utils/workspace-env\"\nimport { resolve } from \"path\"\nimport { execSync } from \"child_process\"\nimport type { WikiArticle, WikiIndex } from \"./types\"\nimport type { WikiStore } from \"./store\"\nimport { claudeModelCall, type ModelCall } from \"./model-call\"\nimport type { FetchLike, LiveLine } from \"./live-read\"\nimport { DEFAULT_SUMMARIES_QUERY, collectSummaries, summariesQuery, type PageView, type SummariesQuerySettings } from \"./query-summaries\"\nimport { isNotePath, notePool, type NoteSource } from \"./query-notes\"\nimport type { QueryMethod } from \"./query-settings\"\n\n/**\n * Agentic wiki query — the \"Farzapedia-faithful\" retrieval path.\n *\n * Two LLM calls + a deterministic graph walk:\n * 1. Selector (cheap): read `_index.md` + question → pick up to `maxCandidates`\n * candidate articles by title + type.\n * 2. Walk (pure code): starting from candidates, follow `related` wikilinks\n * up to `maxHops`, capped at `maxArticles` total.\n * 3. Synthesis (main): answer the question from the walked subgraph.\n *\n * Returns an answer with citations and a trace of which articles were walked,\n * so callers can audit the retrieval path.\n */\n\n/** Models of the catalog method when no `selectorModel` / `synthModel` is given. */\nexport const CATALOG_SELECTOR_MODEL = \"haiku\"\nexport const CATALOG_SYNTH_MODEL = \"sonnet\"\n\nexport interface AgenticQueryOptions {\n /** Candidate-selection model (cheap). Defaults to \"haiku\". */\n selectorModel?: string\n /** Synthesis model (main). Defaults to \"sonnet\". */\n synthModel?: string\n /** Number of candidates the selector is asked to return. Default 3. */\n maxCandidates?: number\n /** Wikilink hops from candidates. Default 2. */\n maxHops?: number\n /** Hard cap on total articles walked. Default 8. */\n maxArticles?: number\n /** Timeout per LLM call, ms. Default 60_000. */\n timeoutMs?: number\n /** Logger — defaults to console.error. */\n log?: (...args: unknown[]) => void\n /** Intent-graph path the question's request was classified under.\n * Articles on the same branch rank higher in candidate selection. */\n messagePath?: string[]\n /** Weight of the branch match against the text match, 0–1. Default 0.6\n * (`graph.retrievalWeights.graph`). */\n graphWeight?: number\n /** Other wikis to search besides `store`: the shared wiki (#824). Only\n * articles the requester may read are offered. Their paths come back\n * as `@<id>/<path>`. */\n shared?: SharedWikiStore[]\n /** How pages are picked (#855). `summaries`: from the one-line page\n * summaries, then a live read (query-summaries.ts). `auto`: that, once\n * most of the requester's own pages have a summary\n * (AUTO_SUMMARY_COVERAGE). Default \"catalog\". */\n method?: QueryMethod\n /** Settings of the summaries method. An explicit `selectorModel` or\n * `synthModel` overrides its models. */\n summaries?: SummariesQuerySettings\n /** The requester's own notes, searched beside its pages by the\n * summaries method (#862). A note is private to the agent that wrote\n * it: notes of any other agent are ignored. */\n notes?: NoteSource\n /** Model call and HTTP GET of the summaries method; tests pass their own. */\n call?: ModelCall\n fetch?: FetchLike\n}\n\n/** Share of the requester's own pages that must have a summary before\n * `auto` picks pages from summaries. Below it, an unsummarised page\n * would be ranked on its title and tags alone, so the catalog walk is\n * kept: one `wiki summarize --agent <id>` or `--limit` run must not\n * switch every agent that can read that store. */\nexport const AUTO_SUMMARY_COVERAGE = 0.8\n\n/** Share of the pages in reach that have a summary: the requester's own\n * pages, or the shared pages when the requester has none. */\nfunction summaryCoverage(store: WikiStore, requesterId: string | undefined, view: ScopeView, summaries: Map<string, string>): number {\n if (summaries.size === 0) return 0\n let paths = store.listArticles(requesterId || \"\").map((a) => a.path).filter((p) => !p.includes(\"/_versions/\"))\n if (paths.length === 0) paths = view.sharedPool.map((e) => e.path)\n if (paths.length === 0) return 0\n return paths.filter((p) => summaries.has(p)).length / paths.length\n}\n\n/** A wiki searched alongside the requester's own. */\nexport interface SharedWikiStore {\n /** Shown in citations as `@<id>/<path>`: an agent id, or \"shared\". */\n id: string\n store: WikiStore\n /** Paths to leave out, e.g. the agents/ tree under the root store. */\n skip?: (path: string) => boolean\n}\n\nexport interface AgenticQueryResult {\n answer: string\n citations: Array<{ title: string; path: string; type?: string }>\n /** Titles/paths the selector picked. */\n candidates: Array<{ title: string; path: string }>\n /** Full article subgraph the walk produced. */\n walked: Array<{ title: string; path: string; type?: string; hop: number }>\n /** \"no-catalog\" | \"no-candidates\" | \"ok\" */\n status: \"ok\" | \"no-catalog\" | \"no-candidates\" | \"error\"\n /** How the pages were picked. */\n method?: \"summaries\" | \"catalog\"\n /** Lines read at the source for this answer (summaries method). */\n live?: LiveLine[]\n /** Live reads the model named and the config allowed. */\n liveAsked?: number\n /** \"search\": no wiki page was used; the answer comes from a search at\n * the source (#861). */\n basis?: \"pages\" | \"search\"\n /** For operator debugging only. */\n trace?: {\n selectorMs: number\n synthesisMs: number\n selectorOutput?: string\n planMs?: number\n liveMs?: number\n }\n error?: string\n}\n\n/**\n * Run an agentic query against a specific agent's WikiStore.\n *\n * `requesterId` is used for permission checks — only articles the requester\n * can read will be included in the synthesis input.\n */\nexport async function agenticQuery(\n question: string,\n store: WikiStore,\n requesterId: string | undefined,\n opts: AgenticQueryOptions = {},\n): Promise<AgenticQueryResult> {\n const selectorModel = opts.selectorModel ?? CATALOG_SELECTOR_MODEL\n const synthModel = opts.synthModel ?? CATALOG_SYNTH_MODEL\n const maxCandidates = opts.maxCandidates ?? 3\n const maxHops = opts.maxHops ?? 2\n const maxArticles = opts.maxArticles ?? 8\n const timeoutMs = opts.timeoutMs ?? 60_000\n const log = opts.log ?? console.error.bind(console, \"[wiki-query]\")\n const messagePath = opts.messagePath?.length ? opts.messagePath : undefined\n const graphWeight = opts.graphWeight ?? DEFAULT_GRAPH_WEIGHT\n\n // --- Step 1: Load the catalog ---\n const catalogPath = resolve(store.baseDir, \"_index.md\")\n const view = scopeView(store, requesterId, opts.shared)\n\n const method = opts.method ?? \"catalog\"\n if (method !== \"catalog\") {\n const summaries = collectSummaries(store, opts.shared)\n if (method === \"summaries\" || summaryCoverage(store, requesterId, view, summaries) >= AUTO_SUMMARY_COVERAGE) {\n const base = opts.summaries ?? DEFAULT_SUMMARIES_QUERY\n const notes = opts.notes && requesterId && opts.notes.owner === requesterId ? notePool(opts.notes) : undefined\n const out = await summariesQuery(question, notes ? withNotes(view, notes) : view, notes ? new Map([...summaries, ...notes.summaries]) : summaries, {\n ...base,\n navigatorModel: opts.selectorModel ?? base.navigatorModel,\n answerModel: opts.synthModel ?? base.answerModel,\n }, { call: opts.call ?? claudeModelCall, fetch: opts.fetch, timeoutMs, log })\n const pages = out.picked.map((a) => ({ title: a.meta.title, path: a.path, type: isNotePath(a.path) ? \"note\" : a.meta.type, hop: a.hop }))\n return {\n answer: out.answer,\n citations: out.status === \"ok\" ? pages.map(({ hop: _, ...p }) => p) : [],\n candidates: pages.filter((p) => p.hop === 0).map(({ title, path }) => ({ title, path })),\n walked: pages,\n status: out.status,\n method: \"summaries\",\n basis: out.basis,\n live: out.live,\n liveAsked: out.liveAsked,\n trace: out.trace,\n ...(out.error ? { error: out.error } : {}),\n }\n }\n }\n\n if (!existsSync(catalogPath) && view.sharedPool.length === 0) {\n return emptyResult(\"no-catalog\", question, \"No _index.md found — run `agentx wiki status` to rebuild.\")\n }\n const ownCatalog = existsSync(catalogPath) ? readFileSync(catalogPath, \"utf-8\") : \"\"\n const catalog = ownCatalog + renderSharedCatalog(question, view.sharedPool, messagePath, graphWeight)\n\n // --- Step 2: Selector — pick candidates ---\n const selectorStart = Date.now()\n let candidates: Array<{ title: string; path: string }> = []\n let selectorOutput = \"\"\n try {\n const viaSeat = await selectCandidatesViaSeat(question, view.pool, requesterId, maxCandidates, messagePath, graphWeight)\n if (viaSeat) {\n candidates = viaSeat\n selectorOutput = `[wiki-rerank seat] ${viaSeat.map((c) => c.title).join(\" | \")}`\n } else {\n selectorOutput = await runClaude(\n buildSelectorPrompt(question, catalog, maxCandidates, messagePath),\n selectorModel,\n timeoutMs,\n )\n candidates = parseCandidates(selectorOutput)\n }\n } catch (e: any) {\n log(\"selector failed:\", e?.message)\n return { ...emptyResult(\"error\", question, `Selector: ${e?.message || \"unknown\"}`), trace: { selectorMs: Date.now() - selectorStart, synthesisMs: 0, selectorOutput } }\n }\n const selectorMs = Date.now() - selectorStart\n\n if (candidates.length === 0) {\n return { ...emptyResult(\"no-candidates\", question, \"Selector returned no candidates.\"), trace: { selectorMs, synthesisMs: 0, selectorOutput } }\n }\n\n // --- Step 3: Walk the subgraph via `related` wikilinks ---\n const walked = walkSubgraph(candidates, view, maxHops, maxArticles)\n\n if (walked.length === 0) {\n return { ...emptyResult(\"no-candidates\", question, \"Candidates did not resolve to readable articles.\"), candidates, trace: { selectorMs, synthesisMs: 0, selectorOutput } }\n }\n\n // --- Step 4: Synthesize the answer ---\n const synthStart = Date.now()\n let answer = \"\"\n try {\n answer = await runClaude(\n buildSynthesisPrompt(question, walked),\n synthModel,\n timeoutMs * 2,\n )\n } catch (e: any) {\n log(\"synthesis failed:\", e?.message)\n return { ...emptyResult(\"error\", question, `Synthesis: ${e?.message || \"unknown\"}`), candidates, walked: walked.map(w => ({ title: w.meta.title, path: w.path, type: w.meta.type, hop: (w as any).hop ?? 0 })), trace: { selectorMs, synthesisMs: Date.now() - synthStart, selectorOutput } }\n }\n const synthesisMs = Date.now() - synthStart\n\n return {\n answer: answer.trim(),\n citations: walked.map(a => ({ title: a.meta.title, path: a.path, type: a.meta.type })),\n candidates,\n walked: walked.map(w => ({ title: w.meta.title, path: w.path, type: w.meta.type, hop: (w as any).hop ?? 0 })),\n status: \"ok\",\n trace: { selectorMs, synthesisMs, selectorOutput },\n }\n}\n\nexport interface RetrieveOptions {\n /** Articles picked before the walk. Default 3. */\n maxCandidates?: number\n /** Wikilink hops from the picked articles. Default 1. */\n maxHops?: number\n /** Hard cap on articles returned. Default 6. */\n maxArticles?: number\n messagePath?: string[]\n graphWeight?: number\n /** The catalog to pick from. Pass it when retrieving many times in a row,\n * so the index is not rebuilt for every call. */\n pool?: CatalogEntry[]\n /** Seat telemetry label. */\n stage?: string\n}\n\n/**\n * The retrieval half of agenticQuery, without the synthesis call: BM25\n * shortlist, rerank seat, then the `related` wikilink walk. Returns the\n * walked articles, hop 0 first.\n *\n * When the seat is off or fails, the BM25 order decides on its own, and\n * only articles the text matched are picked: an article chosen for\n * nothing but its catalog position is noise here, not a candidate. There\n * is no CLI fallback, so this never spends an LLM call.\n */\nexport async function retrieveArticles(\n question: string,\n store: WikiStore,\n requesterId: string | undefined,\n opts: RetrieveOptions = {},\n): Promise<Array<WikiArticle & { hop: number }>> {\n const maxCandidates = opts.maxCandidates ?? 3\n const graphWeight = opts.graphWeight ?? DEFAULT_GRAPH_WEIGHT\n const messagePath = opts.messagePath?.length ? opts.messagePath : undefined\n const pool = opts.pool ?? catalogPool(store)\n if (pool.length === 0 || !question.trim()) return []\n\n let candidates = await selectCandidatesViaSeat(\n question, pool, requesterId, maxCandidates, messagePath, graphWeight, opts.stage ?? \"retrieve\",\n )\n if (!candidates) {\n const matched = new Set(scoreAll(question, buildIndex(pool.map(catalogDoc))).map((r) => r.docIndex))\n candidates = rankCatalogPool(question, pool, messagePath, graphWeight)\n .filter((i) => matched.has(i))\n .slice(0, maxCandidates)\n .map((i) => ({ title: pool[i].title, path: pool[i].path }))\n }\n if (candidates.length === 0) return []\n return walkSubgraph(candidates, scopeView(store, requesterId), opts.maxHops ?? 1, opts.maxArticles ?? 6)\n}\n\nexport type CatalogEntry = WikiIndex[\"articles\"][number]\n\n/** The catalog retrieval picks from: every indexed article but old versions. */\nexport function catalogPool(store: WikiStore): CatalogEntry[] {\n try {\n return (store.rebuildIndex().articles ?? []).filter((a) => a.path && !a.path.includes(\"/_versions/\"))\n } catch {\n return []\n }\n}\n\n// --- Helpers ---\n\nfunction emptyResult(\n status: AgenticQueryResult[\"status\"],\n _question: string,\n error?: string,\n): AgenticQueryResult {\n return {\n answer: \"\",\n citations: [],\n candidates: [],\n walked: [],\n status,\n error,\n }\n}\n\n/**\n * The articles a query may open: the requester's own wiki first, then\n * each shared one. Shared paths carry an `@<id>/` prefix so the walk\n * knows which store to read; a title the own wiki has resolves there.\n */\ninterface ScopeView {\n /** Own catalog, then the shared articles. */\n pool: CatalogEntry[]\n sharedPool: CatalogEntry[]\n titleIndex: Map<string, string>\n /** Title (lowercased) → pages whose `related` names it, newest first.\n * Built only when shared wikis are searched. */\n backlinks: Map<string, string[]>\n /** Paths the requester may read, own and shared. */\n readable: Set<string>\n read(path: string): WikiArticle | null\n /** Pages `article` names in `related`, then the newest that name it. */\n links(article: WikiArticle): string[]\n}\n\nfunction scopeView(store: WikiStore, requesterId: string | undefined, shared: SharedWikiStore[] = []): ScopeView {\n const titleIndex = new Map<string, string>()\n const linking: Array<{ path: string; related: string[]; lastUpdated: string }> = []\n for (const article of store.listArticles(requesterId || \"\")) {\n titleIndex.set(article.meta.title.toLowerCase(), article.path)\n linking.push({ path: article.path, related: article.meta.related ?? [], lastUpdated: article.meta.lastUpdated ?? \"\" })\n }\n const sharedPool: CatalogEntry[] = []\n const byId = new Map<string, SharedWikiStore>()\n for (const s of shared) {\n if (s.store.baseDir === store.baseDir) continue\n byId.set(s.id, s)\n // listArticles is cached and already drops what the requester can't\n // read; rebuilding every agent's index per query would not be.\n for (const a of s.store.listArticles(requesterId || \"\")) {\n if (a.path.includes(\"/_versions/\") || s.skip?.(a.path)) continue\n const path = `@${s.id}/${a.path}`\n sharedPool.push(catalogEntry(a, path))\n linking.push({ path, related: a.meta.related ?? [], lastUpdated: a.meta.lastUpdated ?? \"\" })\n const key = a.meta.title.toLowerCase()\n if (!titleIndex.has(key)) titleIndex.set(key, path)\n }\n }\n // In a fleet's shared pool the page that answers a question often links\n // TO the page the selector picked (a decision about a person), and the\n // forward walk never reaches it (#824 review: ranked 103rd of ~5,700).\n const backlinks = new Map<string, string[]>()\n if (byId.size > 0) {\n for (const l of [...linking].sort((a, b) => b.lastUpdated.localeCompare(a.lastUpdated))) {\n for (const t of l.related) {\n const key = t.toLowerCase()\n const list = backlinks.get(key) ?? []\n if (!list.includes(l.path)) list.push(l.path)\n backlinks.set(key, list)\n }\n }\n }\n let pool: CatalogEntry[] | undefined\n return {\n backlinks,\n readable: new Set(linking.map((l) => l.path)),\n // Lazy: retrieveArticles brings its own pool, and building this one\n // rebuilds the index.\n get pool() { return (pool ??= [...catalogPool(store), ...sharedPool]) },\n sharedPool,\n titleIndex,\n read(path) {\n const m = path.match(/^@([^/]+)\\/(.+)$/)\n const target = m ? byId.get(m[1]) : undefined\n if (m && !target) return null\n const s = target?.store ?? store\n const rel = m ? m[2] : path\n const article = requesterId ? s.readArticleAs(rel, requesterId) : s.readArticle(rel)\n return article ? { ...article, path } : null\n },\n links(article) {\n const forward = (article.meta.related ?? []).map((t) => titleIndex.get(t.toLowerCase())).filter((p): p is string => !!p)\n const names = [article.meta.title, ...(article.meta.aliases ?? [])].map((n) => n.toLowerCase())\n const back = [...new Set(names.flatMap((n) => backlinks.get(n) ?? []))].filter((p) => p !== article.path).slice(0, BACKLINKS_PER_PICK)\n return [...new Set([...forward, ...back])].filter((p) => p !== article.path)\n },\n }\n}\n\n/** The view with the requester's notes added: in the pool, readable,\n * and opened from the notes folder. Everything else the view carries\n * (such as the title index linked pages follow) is kept. */\nfunction withNotes(view: ScopeView, notes: ReturnType<typeof notePool>): PageView {\n return {\n ...view,\n pool: [...view.pool, ...notes.pool],\n readable: new Set([...view.readable, ...notes.pool.map((n) => n.path)]),\n read: (path) => (isNotePath(path) ? notes.read(path) : view.read(path)),\n }\n}\n\nfunction catalogEntry(a: WikiArticle, path: string): CatalogEntry {\n return {\n path,\n title: a.meta.title,\n type: a.meta.type,\n related: a.meta.related,\n tags: a.meta.tags || [],\n owner: a.meta.owner,\n access: a.meta.access,\n sharedWith: a.meta.sharedWith,\n aliases: [a.meta.title.toLowerCase(), ...(a.meta.aliases ?? []).map((x) => x.toLowerCase())],\n backlinks: 0,\n sources: a.meta.sources,\n lastUpdated: a.meta.lastUpdated,\n graphPath: a.meta.graphPath,\n }\n}\n\n/** Shared articles most related to the question, for the CLI selector.\n * Capped: a fleet's shared catalog would not fit one prompt. */\nexport const SHARED_CATALOG_LINES = 150\n\nfunction renderSharedCatalog(question: string, pool: CatalogEntry[], messagePath: string[] | undefined, graphWeight: number): string {\n if (pool.length === 0) return \"\"\n const lines = rankCatalogPool(question, pool, messagePath, graphWeight)\n .slice(0, SHARED_CATALOG_LINES)\n .map((i) => `- ${pool[i].title}${pool[i].type ? ` [${pool[i].type}]` : \"\"} (${pool[i].path})`)\n return `\\n\\n## Shared wiki (other agents' articles)\\n\\n${lines.join(\"\\n\")}\\n`\n}\n\n/** Pages that link to a picked page, opened per picked page. */\nconst BACKLINKS_PER_PICK = 3\n\nfunction walkSubgraph(\n candidates: Array<{ title: string; path: string }>,\n view: ScopeView,\n maxHops: number,\n maxArticles: number,\n): Array<WikiArticle & { hop: number }> {\n const titleIndex = view.titleIndex\n const isShared = (path: string) => path.startsWith(\"@\")\n\n // The agent's own pages come first, and shared pages may take at most\n // half the walk when it has any: in the #824 trial shared pages took\n // the slots of the agent's own correct pages and its score dropped.\n const ordered = [...candidates.filter((c) => !isShared(c.path)), ...candidates.filter((c) => isShared(c.path))]\n let sharedCap = ordered.length > 0 && !isShared(ordered[0].path) ? Math.floor(maxArticles / 2) : maxArticles\n\n const opened = new Map<string, WikiArticle & { hop: number }>()\n let sharedOpened = 0\n let frontier: Array<{ path: string; hop: number }> = ordered.map((c) => ({ path: c.path, hop: 0 }))\n // Shared pages turned away by the cap, in walk order. When the agent's\n // own pages run out first they get the slots left: an own pick with no\n // own neighbours must not leave the walk short of shared pages that answer.\n const deferred: Array<{ path: string; hop: number }> = []\n\n while (opened.size < maxArticles) {\n if (!frontier.length) {\n if (!deferred.length || sharedCap >= maxArticles) break\n sharedCap = maxArticles\n frontier = deferred.splice(0)\n }\n const next = frontier.shift()!\n if (opened.has(next.path)) continue\n if (next.hop > maxHops) continue\n if (isShared(next.path) && sharedOpened >= sharedCap) { deferred.push(next); continue }\n\n const article = view.read(next.path)\n if (!article) continue\n\n opened.set(next.path, { ...article, hop: next.hop })\n if (isShared(next.path)) sharedOpened++\n if (next.hop >= maxHops) continue\n\n if (next.hop === 0) {\n // Pages link to a subject by any of its names; skip what is already\n // open before taking the newest few, or an opened page uses a slot.\n const names = [article.meta.title, ...(article.meta.aliases ?? [])].map((n) => n.toLowerCase())\n const linking = [...new Set(names.flatMap((n) => view.backlinks.get(n) ?? []))]\n .filter((path) => path !== next.path && !opened.has(path))\n .slice(0, BACKLINKS_PER_PICK)\n for (const path of linking) frontier.push({ path, hop: 1 })\n }\n for (const target of article.meta.related || []) {\n const path = titleIndex.get(target.toLowerCase())\n if (path && !opened.has(path)) {\n frontier.push({ path, hop: next.hop + 1 })\n }\n }\n }\n\n return Array.from(opened.values())\n}\n\n// --- Prompts ---\n\n/**\n * Pick candidates with the wiki-rerank seat instead of a Claude CLI call.\n *\n * The selector is 56% of a wiki query — 14.1s of a 25s total, measured —\n * and its whole job is \"pick 3 articles from this catalog\", which is a\n * Choice with per-option probabilities. Jev answers that in about a\n * second. Synthesis stays on Sonnet; it writes prose, which Jev cannot.\n *\n * BM25 shortlists first because the shared catalog carries 971 entries,\n * past the 255-option cap. Same two-stage shape as findRelevantReranked,\n * and it reuses that seat rather than introducing a second one.\n *\n * Returns null whenever the seat is off, errors, or has nothing to rank,\n * and the caller falls back to the CLI selector — so this is strictly an\n * accelerator, never a new way to fail.\n */\nasync function selectCandidatesViaSeat(\n question: string,\n pool: CatalogEntry[],\n requesterId: string | undefined,\n maxCandidates: number,\n messagePath?: string[],\n graphWeight: number = DEFAULT_GRAPH_WEIGHT,\n stage = \"catalog-selector\",\n): Promise<Array<{ title: string; path: string }> | null> {\n try {\n if (pool.length < 2) return null\n\n const shortlist = rankCatalogPool(question, pool, messagePath, graphWeight).slice(0, DEFAULT_SHORTLIST)\n\n const candidates: RerankCandidate[] = shortlist.map((i) => ({\n id: `k${i}`,\n title: pool[i].title || pool[i].path,\n tags: pool[i].tags,\n // The catalog has no body — a title, its type, its wikilinks and its\n // branch of the intent graph are what the selector chooses on.\n excerpt: [\n pool[i].type ? `type: ${pool[i].type}` : \"\",\n (pool[i].related ?? []).length ? `related: ${(pool[i].related ?? []).join(\", \")}` : \"\",\n (pool[i].graphPath ?? []).length ? `graph: ${(pool[i].graphPath ?? []).join(\" › \")}` : \"\",\n ].filter(Boolean).join(\" · \"),\n }))\n\n const result = await askSeat(\n WIKI_RERANK_SEAT,\n rerankState({ query: question, candidates, excerptChars: 300 }),\n rerankQuestions(candidates),\n { features: { agent: requesterId ?? \"unknown\", stage } },\n )\n if (!result || result.mode !== \"active\") return null\n\n const ranking = toRanking(result.answers as never, candidates)\n const picked = ranking.ranked\n .slice(0, maxCandidates)\n .map((id) => pool[Number(id.slice(1))])\n .filter(Boolean)\n .map((a) => ({ title: a.title, path: a.path }))\n return picked.length > 0 ? picked : null\n } catch {\n return null\n }\n}\n\n/** Weight of the intent-graph branch match against the text match when\n * shortlisting catalog candidates. Mirrors `graph.retrievalWeights.graph`. */\nexport const DEFAULT_GRAPH_WEIGHT = 0.6\n\n/**\n * Order the catalog pool for a question. Three bands, never mixed:\n *\n * 1. articles the text match scored, ordered by `text * (1 + w * branch)`\n * when the request was classified: the branch reorders text matches\n * but cannot lift an unrelated article above one;\n * 2. articles on the request's branch that the text never matched, by\n * how much of the path they share;\n * 3. the rest, in catalog order.\n *\n * Band 1 comes first in full because the shortlist the reranker sees is\n * finite (DEFAULT_SHORTLIST): a busy category holds more same-branch\n * articles than that, and a blended score let them push the article that\n * actually answers the question out of the list.\n *\n * Exported for tests; the seat and the CLI selector both consume the order.\n */\nexport function rankCatalogPool(\n question: string,\n pool: Array<{ title: string; tags?: string[]; related?: string[]; graphPath?: string[] }>,\n messagePath?: string[],\n graphWeight: number = DEFAULT_GRAPH_WEIGHT,\n): number[] {\n const bm25 = scoreAll(question, buildIndex(pool.map(catalogDoc)))\n const maxBm25 = bm25.reduce((m, r) => Math.max(m, r.score), 0)\n const text = new Map(bm25.map((r) => [r.docIndex, maxBm25 > 0 ? r.score / maxBm25 : 0]))\n const useGraph = !!messagePath?.length\n const branch = (a: { graphPath?: string[] }) =>\n useGraph && a.graphPath?.length ? ancestryScore(messagePath!, a.graphPath) : 0\n\n const byScore = (x: { i: number; score: number }, y: { i: number; score: number }) => y.score - x.score || x.i - y.i\n const matched = pool\n .map((a, i) => ({ i, score: (text.get(i) ?? 0) * (1 + graphWeight * branch(a)) }))\n .filter((c) => text.has(c.i))\n .sort(byScore)\n const branchOnly = pool\n .map((a, i) => ({ i, score: branch(a) }))\n .filter((c) => !text.has(c.i) && c.score > 0)\n .sort(byScore)\n const ranked = [...matched, ...branchOnly].map((c) => c.i)\n for (let i = 0; i < pool.length; i++) if (!ranked.includes(i)) ranked.push(i)\n return ranked\n}\n\n/** What BM25 sees of a catalog entry: the catalog carries no body. */\nfunction catalogDoc(a: { title: string; tags?: string[]; related?: string[] }): string {\n return [a.title, (a.tags ?? []).join(\" \"), (a.related ?? []).join(\" \")].join(\" \")\n}\n\nfunction buildSelectorPrompt(question: string, catalog: string, maxCandidates: number, messagePath?: string[]): string {\n const branch = messagePath?.length\n ? `\\n## Intent\\n\\nThe request was classified under the intent-graph path \"${messagePath.join(\" › \")}\". Prefer articles filed under the same branch when their titles are equally plausible.\\n`\n : \"\"\n return `You are picking candidate articles from a wiki catalog to answer a question. You do NOT answer the question. You pick which articles the answer is likely to come from.\n\n## Question\n\n${question}\n${branch}\n## Catalog (_index.md — articles grouped by type, with wikilink previews)\n\n${catalog}\n\n## Your task\n\nPick up to ${maxCandidates} articles from the catalog that are most likely to answer the question. Prefer:\n- Articles whose title directly names a subject in the question.\n- Articles of the right type (e.g. a \"who owns X\" question → person or project; a \"what happened on DATE\" → event).\n- Articles whose wikilinks suggest they sit at the center of a relevant subgraph.\n\nReturn ONLY valid JSON, no markdown fencing, no prose:\n\n[\n {\"title\": \"Exact Article Title\", \"path\": \"path/from/catalog.md\"},\n ...\n]\n\nIf none of the articles match, return [].`\n}\n\nfunction buildSynthesisPrompt(\n question: string,\n articles: Array<WikiArticle & { hop: number }>,\n): string {\n const articlesBlock = articles\n .map(a => {\n // Owner and date let the answer say where a fact came from and pick\n // the newer page when two disagree (#824).\n const from = [a.meta.owner ? `owner: ${a.meta.owner}` : \"\", a.meta.lastUpdated ? `updated: ${a.meta.lastUpdated}` : \"\"].filter(Boolean).join(\", \")\n const header = `### ${a.meta.title} — ${a.meta.type || \"untyped\"} (${a.path}) [hop ${a.hop}]${from ? ` {${from}}` : \"\"}`\n const related = a.meta.related?.length ? `Related: ${a.meta.related.join(\", \")}` : \"\"\n return [header, related, \"\", a.content].filter(Boolean).join(\"\\n\")\n })\n .join(\"\\n\\n---\\n\\n\")\n\n return `You are answering a question using a small subgraph of wiki articles. The articles were walked from the catalog; trust them over your prior knowledge.\n\n## Question\n\n${question}\n\n## Articles (${articles.length} walked from the catalog)\n\n${articlesBlock}\n\n## Your task\n\nAnswer the question in 2–6 sentences. Cite articles by their title in square brackets like [Article Title]. When two articles disagree, prefer the one updated more recently, and say which agent's page and date the answer comes from. If the articles do not answer the question, say so plainly (do not invent). Prefer concrete facts over hedging.\n\nOutput ONLY the answer — no preamble, no \"here is my answer:\", no markdown fencing.`\n}\n\nfunction parseCandidates(raw: string): Array<{ title: string; path: string }> {\n const match = raw.match(/\\[[\\s\\S]*?\\]/)\n if (!match) return []\n try {\n const parsed = JSON.parse(match[0])\n if (!Array.isArray(parsed)) return []\n return parsed\n .filter((x: any) => x && typeof x.title === \"string\" && typeof x.path === \"string\")\n .map((x: any) => ({ title: x.title, path: x.path }))\n } catch {\n return []\n }\n}\n\nasync function runClaude(prompt: string, model: string, timeoutMs: number): Promise<string> {\n // Use stdin via a temp-file pipe to avoid shell-escaping a huge prompt.\n // Prompts can exceed the `-E` arg buffer on macOS, so we always pipe.\n const { writeFileSync, mkdirSync, rmSync } = await import(\"fs\")\n const { tmpdir } = await import(\"os\")\n const dir = resolve(tmpdir(), `agentx-wiki-query-${process.pid}`)\n mkdirSync(dir, { recursive: true })\n const promptPath = resolve(dir, `prompt-${Date.now()}.txt`)\n writeFileSync(promptPath, prompt)\n try {\n const cmd = `cat '${promptPath}' | claude -p - --output-format json --max-turns 1 --model ${model} --disallowedTools \"Bash Read Write Edit Glob Grep Agent WebSearch WebFetch NotebookEdit\"`\n const raw = execSync(cmd, { env: claudeCliEnv(), encoding: \"utf-8\", timeout: timeoutMs, maxBuffer: 4 * 1024 * 1024 })\n try {\n const envelope = JSON.parse(raw)\n return String(envelope.result || envelope.content || \"\")\n } catch {\n return raw\n }\n } finally {\n try { rmSync(promptPath, { force: true }) } catch {}\n }\n}\n\n/** `wiki.query.shared` from agentx.json: whether a query also searches the\n * shared wiki. On when there is no config to read. The CLI and the\n * `agentx_wiki_query` tool both ask here, so the switch reaches both. */\nexport async function sharedQueryEnabled(configPath?: string): Promise<boolean> {\n try {\n const { loadDaemonConfig } = await import(\"@/daemon/config\")\n return loadDaemonConfig(configPath).wiki.query.shared\n } catch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,KAAO,IAAK,CAAC,EACpH,GAAI,CACF,IAAMiI,EAAW,KAAK,MAAMd,CAAG,EAC/B,OAAO,OAAOc,EAAS,QAAUA,EAAS,SAAW,EAAE,CACzD,MAAE,CACA,OAAOd,CACT,CACF,QAAE,CACA,GAAI,CAAEO,EAAOG,EAAY,CAAE,MAAO,EAAK,CAAC,CAAE,MAAE,CAAO,CACrD,CACF,CAKA,eAAsBK,GAAmBC,EAAuC,CAC9E,GAAI,CACF,GAAM,CAAE,iBAAAC,CAAiB,EAAI,KAAM,QAAO,sBAAiB,EAC3D,OAAOA,EAAiBD,CAAU,EAAE,KAAK,MAAM,MACjD,MAAE,CACA,MAAO,EACT,CACF","names":["readFileSync","existsSync","init_seat","resolve","execSync","CATALOG_SELECTOR_MODEL","CATALOG_SYNTH_MODEL","AUTO_SUMMARY_COVERAGE","summaryCoverage","store","requesterId","view","summaries","paths","a","p","e","agenticQuery","question","opts","selectorModel","synthModel","maxCandidates","maxHops","maxArticles","timeoutMs","log","messagePath","graphWeight","DEFAULT_GRAPH_WEIGHT","catalogPath","resolve","scopeView","method","collectSummaries","base","DEFAULT_SUMMARIES_QUERY","notes","notePool","out","summariesQuery","withNotes","claudeModelCall","pages","isNotePath","_","title","path","existsSync","emptyResult","catalog","readFileSync","renderSharedCatalog","selectorStart","candidates","selectorOutput","viaSeat","selectCandidatesViaSeat","c","runClaude","buildSelectorPrompt","parseCandidates","selectorMs","walked","walkSubgraph","synthStart","answer","buildSynthesisPrompt","w","synthesisMs","retrieveArticles","pool","catalogPool","matched","scoreAll","buildIndex","catalogDoc","r","rankCatalogPool","i","status","_question","error","shared","titleIndex","linking","article","sharedPool","byId","s","catalogEntry","key","backlinks","l","b","t","list","m","target","rel","forward","names","n","back","BACKLINKS_PER_PICK","x","SHARED_CATALOG_LINES","isShared","ordered","sharedCap","opened","sharedOpened","frontier","deferred","next","stage","DEFAULT_SHORTLIST","result","askSeat","WIKI_RERANK_SEAT","rerankState","rerankQuestions","picked","toRanking","id","bm25","maxBm25","text","useGraph","branch","ancestryScore","byScore","y","branchOnly","ranked","articles","articlesBlock","from","header","related","raw","match","parsed","prompt","model","writeFileSync","mkdirSync","rmSync","tmpdir","dir","promptPath","cmd","execSync","claudeCliEnv","envelope","sharedQueryEnabled","configPath","loadDaemonConfig"]}
@@ -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-NY7NHGVT.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?`
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-MUVE3UAS.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-5NT44FKL.js.map
252
+ //# sourceMappingURL=chunk-3D5XUOBL.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-BQIWMQNU.js";import{e as Ee,i as Te}from"./chunk-QAWKN2N4.js";import{b as oe}from"./chunk-JTDUTCUE.js";import{a as G,b as Ce}from"./chunk-SMAI7U6H.js";import{c as Ie,d as ae,e as T,f as re,g as B}from"./chunk-B2QYMUTD.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-AKLZ4YO2.js";import{G as K}from"./chunk-QDWEM4DG.js";import{a as L,b as F}from"./chunk-LUYN6RAC.js";import{a as ve}from"./chunk-6WF56ME6.js";import{a as be}from"./chunk-RGZARSHV.js";import{B as dt,S as fe,Z as ct,ma as ee,oa as H,pa as he,w as Z,x as me,xa as te}from"./chunk-DYGQF3MI.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-SMAI7U6H.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-AKLZ4YO2.js";import{G as K}from"./chunk-QDWEM4DG.js";import{a as L,b as F}from"./chunk-LUYN6RAC.js";import{a as ve}from"./chunk-SN7YH4E4.js";import{a as be}from"./chunk-ROLSSYXE.js";import{B as dt,S as fe,Z as ct,ma as ee,oa as H,pa as he,w as Z,x as me,xa as te}from"./chunk-DYGQF3MI.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-EEBK4F6E.js.map
861
+ //# sourceMappingURL=chunk-3F4GPRGQ.js.map
@@ -1,4 +1,4 @@
1
- import{f as h}from"./chunk-QAWKN2N4.js";import{f as j,g}from"./chunk-JTDUTCUE.js";import{a as z}from"./chunk-IMLAPB7G.js";function E(o,t){return o.ontology.types.find(e=>e.id===t)?.lens??[{panel:"notes",source:"notes",show:1}]}function v(o,t,e){let a=o.ontology.properties.find(n=>n.id===t);return a?e?a.inverse??a.label:a.label:t.replace(/_/g," ")}function G(o,t){let e=o.until??o.date??o.since??"",a=t.until??t.date??t.since??"";return e!==a?a.localeCompare(e):o.label.localeCompare(t.label)}function R(o,t,e,a,n){let r=a?n:e.target?o.entities.get(e.target):void 0,i=[v(o,e.property,a)];return e.role&&i.unshift(e.role.length>40?`${e.role.slice(0,39)}\u2026`:e.role),{label:r?.title??e.value,entityId:r?.id,type:r?.type,chips:i,since:e.since,until:e.until,status:e.status,private:e.access==="private",statement:a?void 0:t.statements.indexOf(e),sub:e.note}}function H(o,t,e){let a=new Set(j(e)),n=e.types?new Set(e.types):null,r=[],i=new Set,s=x=>!n||!!x&&n.has(x.type);for(let x of t.statements){if(!a.has(x.property))continue;let d=x.target?o.entities.get(x.target):void 0;s(d)&&(r.push(R(o,t,x,!1)),d&&i.add(d.id))}for(let x of o.incoming.get(t.id)??[]){if(!a.has(x.property))continue;let d=o.entities.get(x.from);!d||!s(d)||(x.statement?r.push(R(o,t,x.statement,!0,d)):i.has(d.id)||r.push({label:d.title,entityId:d.id,type:d.type,chips:[v(o,"related",!0)],date:d.updated}),i.add(d.id))}if(a.has("related"))for(let x of o.outgoing.get(t.id)??[]){if(x.property!=="related"||i.has(x.to))continue;let d=o.entities.get(x.to);!d||!s(d)||(r.push({label:d.title,entityId:d.id,type:d.type,chips:[v(o,"related",!1)],date:d.updated}),i.add(d.id))}let c=r.filter(x=>!x.chips.includes(v(o,"related",!1))),p=r.filter(x=>x.chips.includes(v(o,"related",!1)));return[...c.sort(G),...p.sort(G)]}function I(o,t,e){let a=new Set;for(let r of o.outgoing.get(t.id)??[])a.add(r.to);for(let r of o.incoming.get(t.id)??[])a.add(r.from);let n=[];for(let r of a){let i=o.entities.get(r);i&&(!e||e.has(i.type))&&n.push(i)}return n.sort((r,i)=>(i.date||i.updated).localeCompare(r.date||r.updated))}function M(o){return{label:o.title,entityId:o.id,type:o.type,chips:[],date:o.date,importance:o.importance}}function T(o,t,e){let a=I(o,t,new Set(["event"])).map(M),n=new Set(e.importance??["major","normal","minor"]),r=a.filter(p=>n.has(p.importance??o.ontology.importance.default)),i=e.fold?a.filter(p=>p.importance===e.fold):[],s=[],c=e.rollup??o.ontology.importance.rollup;if(i.length>=c.min&&i[0].date){let p=Date.parse(i[0].date),x=i.filter(d=>d.date&&p-Date.parse(d.date)<=c.days*864e5);x.length>=c.min&&s.push(`${x.length} minor events in ${c.days} days up to ${i[0].date}`)}return{shown:r,folded:i,rollups:s}}function V(o,t){let e=o.statements.map((r,i)=>({st:r,i})).filter(({st:r})=>r.property==="reading"||!!r.metric).sort((r,i)=>(i.st.at??"").localeCompare(r.st.at??"")),a=new Set,n=[];for(let{st:r,i}of e){let s=r.metric??"reading";t&&a.has(s)||(a.add(s),n.push({label:`${s.replace(/_/g," ")}: ${r.value}`,chips:[],date:r.at,statement:i,private:r.access==="private"}))}return n}function B(o,t){return t(o.sources).sort((e,a)=>a.date.localeCompare(e.date)).map(e=>{let a=e.content.split(`
1
+ import{f as j,g}from"./chunk-MTX4UPNB.js";import{f as h}from"./chunk-QAWKN2N4.js";import{a as z}from"./chunk-IMLAPB7G.js";function E(o,t){return o.ontology.types.find(e=>e.id===t)?.lens??[{panel:"notes",source:"notes",show:1}]}function v(o,t,e){let a=o.ontology.properties.find(n=>n.id===t);return a?e?a.inverse??a.label:a.label:t.replace(/_/g," ")}function G(o,t){let e=o.until??o.date??o.since??"",a=t.until??t.date??t.since??"";return e!==a?a.localeCompare(e):o.label.localeCompare(t.label)}function R(o,t,e,a,n){let r=a?n:e.target?o.entities.get(e.target):void 0,i=[v(o,e.property,a)];return e.role&&i.unshift(e.role.length>40?`${e.role.slice(0,39)}\u2026`:e.role),{label:r?.title??e.value,entityId:r?.id,type:r?.type,chips:i,since:e.since,until:e.until,status:e.status,private:e.access==="private",statement:a?void 0:t.statements.indexOf(e),sub:e.note}}function H(o,t,e){let a=new Set(j(e)),n=e.types?new Set(e.types):null,r=[],i=new Set,s=x=>!n||!!x&&n.has(x.type);for(let x of t.statements){if(!a.has(x.property))continue;let d=x.target?o.entities.get(x.target):void 0;s(d)&&(r.push(R(o,t,x,!1)),d&&i.add(d.id))}for(let x of o.incoming.get(t.id)??[]){if(!a.has(x.property))continue;let d=o.entities.get(x.from);!d||!s(d)||(x.statement?r.push(R(o,t,x.statement,!0,d)):i.has(d.id)||r.push({label:d.title,entityId:d.id,type:d.type,chips:[v(o,"related",!0)],date:d.updated}),i.add(d.id))}if(a.has("related"))for(let x of o.outgoing.get(t.id)??[]){if(x.property!=="related"||i.has(x.to))continue;let d=o.entities.get(x.to);!d||!s(d)||(r.push({label:d.title,entityId:d.id,type:d.type,chips:[v(o,"related",!1)],date:d.updated}),i.add(d.id))}let c=r.filter(x=>!x.chips.includes(v(o,"related",!1))),p=r.filter(x=>x.chips.includes(v(o,"related",!1)));return[...c.sort(G),...p.sort(G)]}function I(o,t,e){let a=new Set;for(let r of o.outgoing.get(t.id)??[])a.add(r.to);for(let r of o.incoming.get(t.id)??[])a.add(r.from);let n=[];for(let r of a){let i=o.entities.get(r);i&&(!e||e.has(i.type))&&n.push(i)}return n.sort((r,i)=>(i.date||i.updated).localeCompare(r.date||r.updated))}function M(o){return{label:o.title,entityId:o.id,type:o.type,chips:[],date:o.date,importance:o.importance}}function T(o,t,e){let a=I(o,t,new Set(["event"])).map(M),n=new Set(e.importance??["major","normal","minor"]),r=a.filter(p=>n.has(p.importance??o.ontology.importance.default)),i=e.fold?a.filter(p=>p.importance===e.fold):[],s=[],c=e.rollup??o.ontology.importance.rollup;if(i.length>=c.min&&i[0].date){let p=Date.parse(i[0].date),x=i.filter(d=>d.date&&p-Date.parse(d.date)<=c.days*864e5);x.length>=c.min&&s.push(`${x.length} minor events in ${c.days} days up to ${i[0].date}`)}return{shown:r,folded:i,rollups:s}}function V(o,t){let e=o.statements.map((r,i)=>({st:r,i})).filter(({st:r})=>r.property==="reading"||!!r.metric).sort((r,i)=>(i.st.at??"").localeCompare(r.st.at??"")),a=new Set,n=[];for(let{st:r,i}of e){let s=r.metric??"reading";t&&a.has(s)||(a.add(s),n.push({label:`${s.replace(/_/g," ")}: ${r.value}`,chips:[],date:r.at,statement:i,private:r.access==="private"}))}return n}function B(o,t){return t(o.sources).sort((e,a)=>a.date.localeCompare(e.date)).map(e=>{let a=e.content.split(`
2
2
  `).map(n=>n.trim()).find(Boolean)??"";return{label:a.length>120?`${a.slice(0,117)}\u2026`:a,chips:[],date:e.date,sub:`${e.date} \xB7 ${e.agentId} \xB7 ${e.source}`}})}function P(o,t,e,a){let n=g(e),r=[],i=[],s=[];if(n==="statements")r=H(o,t,e);else if(n==="linked")r=I(o,t,e.types?new Set(e.types):null).map(M);else if(n==="readings")r=V(t,!a.full&&e.latest!==!1);else if(n==="discussed")r=B(t,a.readEntries);else if(n==="history"){let p=T(o,t,e);r=a.full?I(o,t,new Set(["event"])).map(M):p.shown,i=a.full?[]:p.folded,s=p.rollups}let c=r.length;if(a.full){let p=a.pageSize??50,x=Math.max(1,a.page??1);r=r.slice((x-1)*p,x*p)}else r=r.slice(0,e.show??5);return{def:e,title:e.title??e.panel.replace(/_/g," "),items:r,total:c,folded:i,rollups:s,ownerOnly:e.access==="owner"}}function l(o){return String(o??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}var O={home:'<rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/>',person:'<circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 4-6 8-6s8 2 8 6"/>',org:'<rect x="4" y="3" width="16" height="18" rx="2"/><path d="M9 7h2M13 7h2M9 11h2M13 11h2M9 15h2M13 15h2"/>',pin:'<path d="M12 21s-7-6.2-7-11a7 7 0 0 1 14 0c0 4.8-7 11-7 11z"/><circle cx="12" cy="10" r="2.5"/>',server:'<rect x="3" y="4" width="18" height="7" rx="2"/><rect x="3" y="13" width="18" height="7" rx="2"/><path d="M7 7.5h.01M7 16.5h.01"/>',device:'<rect x="4" y="5" width="16" height="11" rx="1.5"/><path d="M2 19h20"/>',app:'<rect x="4" y="4" width="16" height="16" rx="3"/><path d="M9 12h6M12 9v6"/>',globe:'<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c3 3.5 3 14.5 0 18M12 3c-3 3.5-3 14.5 0 18"/>',key:'<circle cx="8" cy="15" r="4"/><path d="M11 12l9-9M17 6l3 3"/>',agent:'<rect x="5" y="8" width="14" height="11" rx="3"/><path d="M12 4v4M9 13h.01M15 13h.01"/>',project:'<path d="M12 3l8 4.5v9L12 21l-8-4.5v-9z"/><path d="M4 7.5l8 4.5 8-4.5M12 12v9"/>',contract:'<path d="M7 3h7l5 5v13H7z"/><path d="M14 3v5h5M10 13h6M10 17h4"/>',law:'<path d="M12 3v18M5 21h14M6 7h12M6 7l-3 7a3 3 0 0 0 6 0zM18 7l-3 7a3 3 0 0 0 6 0z"/>',calendar:'<rect x="3" y="5" width="18" height="16" rx="2"/><path d="M3 10h18M8 3v4M16 3v4"/>',decision:'<path d="M12 3v18M12 8H6l-2 2 2 2h6M12 12h6l2 2-2 2h-6"/>',steps:'<path d="M9 6h11M9 12h11M9 18h11M4 6l1 1 2-2M4 12l1 1 2-2M4 18l1 1 2-2"/>',topic:'<path d="M4 7h16M4 12h10M4 17h7"/>',chat:'<path d="M4 5h16v11H9l-5 4z"/>',lock:'<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>',arrow:'<path d="M5 12h14M13 6l6 6-6 6"/>',search:'<circle cx="11" cy="11" r="7"/><path d="M21 21l-4.3-4.3"/>',merge:'<circle cx="6" cy="6" r="2"/><circle cx="6" cy="18" r="2"/><circle cx="18" cy="12" r="2"/><path d="M6 8v8M8 6c6 0 8 2 8 6"/>'};function m(o){return`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${O[o??""]??O.topic}</svg>`}function u(o,t){return m(o.types.find(e=>e.id===t)?.icon)}function b(o,t){return o.types.find(e=>e.id===t)?.label??t??""}function f(o){return`/e/${encodeURIComponent(o)}`}function L(o){return`<nav class="ox-crumbs" aria-label="Breadcrumb">${[{label:"Wiki",href:"/"},...o].map((e,a,n)=>a===n.length-1||!e.href?`<b>${l(e.label)}</b>`:`<a href="${e.href}">${l(e.label)}</a>`).join('<span aria-hidden="true">/</span>')}</nav>`}function y(o){let t=["","Pillar","Overview","Panel","Statement"];return`<div class="ox-zoom" title="Zoom level">${[1,2,3,4].map(a=>`<span class="${a===o?"on":""}">Z${a}${a===o?` ${t[a]}`:""}</span>`).join("")}</div>`}function w(o,t){let e=o.ontology,a=`<a class="ox-nav${t.home?" on":""}" href="/">${m("home")}<span>Home</span></a>`,n=e.sidebar.pins.slice(0,e.sidebar.pins_max);if(n.length){a+='<div class="ox-side-h">Pinned</div>';for(let r of n){let i=o.names.get(h(r)),s=i?o.entities.get(i):void 0;s&&(a+=`<a class="ox-nav pin${t.entity===s.id?" on":""}" href="${f(s.id)}">${u(e,s.type)}<span>${l(s.title)}</span></a>`)}}a+='<div class="ox-side-h">Pillars</div>';for(let r of e.pillars)r.sidebar!==!1&&(a+=`<a class="ox-nav${t.pillar===r.id?" on":""}" href="/p/${encodeURIComponent(r.id)}">${m(r.icon)}<span>${l(r.label)}</span></a>`);return a+='<div class="ox-side-foot">Types, topics and agent wikis are one level down, on Home and the pillar pages.</div>',a}function $(o,t,e,a="",n=""){return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
@@ -149,4 +149,4 @@ body>a[href="/admin"]+.ox-app .ox-top{padding-right:130px}
149
149
  `;var F=()=>new Date().toISOString().slice(0,10);function q(o){return o?`<span class="ox-st ${l(o)}">${l(o)}</span>`:""}function K(o){return o.private?`<span class="l"><span class="ox-mask">\u2022\u2022\u2022\u2022</span> ${m("lock")}</span>`:o.entityId?`<a href="${f(o.entityId)}">${l(o.label)}</a>`:`<span class="l">${l(o.label)}</span>`}function J(o,t){if(t.sub)return t.sub;let e=[];return t.type&&e.push(b(o.ontology,t.type).toLowerCase()),t.since||t.until?e.push(`${t.since??"\u2026"} \u2192 ${t.until??"now"}`):t.date&&e.push(t.date),e.join(" \xB7 ")}function Y(o,t,e){let a=J(o,e),n=e.chips.map(i=>`<span class="ox-chip">${l(i)}</span>`).join(""),r=e.statement!==void 0&&e.statement>=0?`<a class="ox-sub" href="${f(t.id)}/s/${e.statement}" title="Where this comes from (Z4)">Z4</a>`:"";return`<div class="ox-row"><span class="ox-ic">${e.type?u(o.ontology,e.type):m(e.private?"lock":"topic")}</span><div class="t">${K(e)}${a?`<div class="ox-sub">${l(a)}</div>`:""}</div><div class="r">${n}${q(e.status)}${r}</div></div>`}function U(o){let t=o.importance??"normal";return`<div class="ox-ev"><span class="d">${l(o.date??"")}</span><span class="ox-st ${t}">${t}</span><span>${o.entityId?`<a href="${f(o.entityId)}">${l(o.label)}</a>`:l(o.label)}</span></div>`}function Q(o){let t=o.flatMap(s=>[s.since,s.until]).filter(s=>!!s).map(s=>Number(s.slice(0,4))).filter(Boolean),e=Number(F().slice(0,4)),a=Math.min(...t,e-1),n=Math.max(1,e+1-a),r=(s,c)=>{if(!s)return c?100:0;let[p,x]=[Number(s.slice(0,4)),Number(s.slice(5,7))||(c?12:1)];return Math.min(100,Math.max(0,(p-a+(x-1)/12)/n*100))},i=`<div class="ox-tl-axis"><span></span><span class="yrs"><span>${a}</span><span>${e}</span></span></div>`;for(let s of o){let c=r(s.since,!1),p=r(s.until,!0),x=`${s.since??"\u2026"} \u2192 ${s.until??"now"}`;i+=`<div class="ox-tl-row"><div class="who">${s.chips.map(l).join(", ")}<small>${s.entityId?`<a href="${f(s.entityId)}">${l(s.label)}</a>`:l(s.label)}</small></div><div class="ox-track"><i class="${s.until?"past":""}" style="left:${c.toFixed(1)}%;width:${Math.max(4,p-c).toFixed(1)}%" title="${l(x)}">${l(x)}</i></div></div>`}return i}function S(o,t,e,a,n=""){let r=!a&&(e.total>e.items.length||e.def.source==="notes"||e.folded.length)?`<a class="zin" href="${f(t.id)}/${encodeURIComponent(e.def.panel)}">all ${e.total||""} (Z3) \u2192</a>`:"",s=e.def.source==="notes"||e.def.panel==="notes"?`${t.pages.length} page${t.pages.length===1?"":"s"}`:`${e.total} ${e.total===1?"item":"items"}`,c=`<span class="note">${e.ownerOnly?`${m("lock")} private to the owner \xB7 `:""}${s}</span>`,p="";e.def.source==="notes"||e.def.panel==="notes"?p=n||'<div class="ox-empty">No notes.</div>':e.items.length===0?p='<div class="ox-empty">Nothing recorded yet.</div>':e.def.display==="timeline"&&e.items.some(d=>d.since)?p=Q(e.items):e.def.source==="history"||e.items.every(d=>d.type==="event")?p=e.items.map(U).join(""):p=e.items.map(d=>Y(o,t,d)).join("");for(let d of e.rollups)p+=`<div class="ox-fold">\u21BB Recurring: ${l(d)}</div>`;return e.folded.length&&(p+=`<details class="ox-fold"><summary>+ ${e.folded.length} minor event${e.folded.length===1?"":"s"}</summary>${e.folded.slice(0,20).map(U).join("")}</details>`),`<section class="ox-card${e.def.display==="timeline"||e.def.source==="notes"||e.def.panel==="notes"?" wide":""}"><div class="ox-card-h"><h2>${l(e.title)}</h2>${c}${r}</div>${p}</section>`}function C(o,t){return z(t.replace(/<!--\s*tags?:[^>]*-->\s*\n?/gi,"").replace(/<!-- \/overview -->\s*\n?/g,""),{wikilink:(e,a)=>{let n=o.names.get(h(e));return n?`<a href="${f(n)}" class="wikilink">${a}</a>`:`<a href="/find?q=${encodeURIComponent(e)}" class="wikilink broken" title="No page yet">${a}</a>`}})}function k(o){return o.replace(/^---\n[\s\S]*?\n---\n?/,"").trim()}var X=/^##[ \t]+Overview[ \t]*$/im,N="<!-- /overview -->";function D(o){let t=X.exec(o);if(!t)return;let e=t.index+t[0].length,a=o.slice(e),n=a.indexOf(N),r=a.search(/^#{1,2}[ \t]/m),i=[n,r].filter(p=>p>=0),s=e+(i.length?Math.min(...i):a.length),c=n>=0&&e+n===s?s+N.length:s;return{start:t.index,textStart:e,end:s,after:c}}function ee(o){let t=k(o),e=D(t);return(e?t.slice(e.textStart,e.end).trim():"")||void 0}function te(o){let t=[...o.pages].sort((e,a)=>(a.article.meta.lastUpdated||"").localeCompare(e.article.meta.lastUpdated||""));for(let e of t){let a=ee(e.article.content);if(a)return a}}function oe(o,t){if(o.length<=t)return o;let e=o.slice(0,t),a=Math.max(...[". ","! ","? ","\u061F ","\u3002"].map(n=>e.lastIndexOf(n)));return a>t/3?e.slice(0,a+1):`${e.replace(/\s+\S*$/,"")}\u2026`}function ne(o,t=360){let n=(k(o.pages[0]?.article.content??"").split(/\n\s*\n/).map(r=>r.trim()).find(r=>r&&!r.startsWith("#")&&!r.startsWith("|")&&!r.startsWith("```"))??"").replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g,(r,i,s)=>s??i).replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/^[-*]\s+/gm,"").replace(/[*_`]/g,"").replace(/\s+/g," ").trim();return oe(n,t)}function ae(o,t){return o.ontology.pillars.find(e=>e.id===t.pillar)}function W(o,t,e=[]){let a=ae(o,t);return L([{label:a?.label??t.pillar,href:`/p/${encodeURIComponent(t.pillar)}`},{label:b(o.ontology,t.type),href:`/p/${encodeURIComponent(t.pillar)}?kind=${encodeURIComponent(t.type)}`},{label:t.title,href:e.length?f(t.id):void 0},...e])}function _(o,t,e){if(!e){let a=t.pages[0];if(!a)return"";let n=k(a.article.content),r=D(n),i=(r?n.slice(0,r.start)+n.slice(r.after):n).trim(),s=i.length>1600?`${i.slice(0,1600).replace(/\n[^\n]*$/,"")}
150
150
 
151
151
  \u2026`:i;return`<div class="ox-prose">${C(o,s)}</div>`}return t.pages.map(a=>`<div class="ox-sub">from ${l(a.agentId)} \xB7 ${l(a.article.path)} \xB7 updated ${l(a.article.meta.lastUpdated||"\u2014")}</div><div class="ox-prose">${C(o,k(a.article.content))}</div>`).join('<hr style="border:0;border-top:1px solid var(--edge);margin:16px 0">')}function re(o,t,e){let a=o.ontology.types.find(i=>i.id===t.type),n=`<span class="ox-lbl">Lens for this type</span><div class="ox-annot"><b>${l(a?.label??t.type)}</b> opens with:<ol>`;n+=e.map(i=>`<li>${l(i.title??i.panel)}</li>`).join(""),n+=`</ol><span class="ox-sub">from ontology.yaml \xB7 types.${l(t.type)}.lens</span></div>`,n+='<span class="ox-lbl" style="margin-top:20px">Zoom in</span>';for(let i of e)n+=`<div class="ox-row"><span class="ox-ic">${m(g(i)==="history"?"calendar":g(i)==="discussed"?"chat":"arrow")}</span><div class="t"><a href="${f(t.id)}/${encodeURIComponent(i.panel)}">${l(i.title??i.panel)}</a><div class="ox-sub">Z3 \xB7 in full</div></div></div>`;n+='<span class="ox-lbl" style="margin-top:20px">Provenance</span>';let r=new Map;for(let i of t.pages)r.set(i.agentId,(r.get(i.agentId)??0)+1);for(let[i,s]of r){let c=t.pages.find(p=>p.agentId===i);n+=`<div class="ox-row"><span class="ox-ic">${m("agent")}</span><div class="t"><a href="/agent/${encodeURIComponent(i)}/article/${encodeURIComponent(c.article.path)}">${l(i)}</a><div class="ox-sub">${s} page${s===1?"":"s"} \xB7 ${t.statements.filter(p=>p.page.agentId===i).length} statements</div></div></div>`}return t.pages.length>1&&(n+=`<div class="ox-row"><span class="ox-ic">${m("merge")}</span><div class="t"><span class="l">${t.pages.length} pages merged</span><div class="ox-sub">same name, one entity</div></div></div>`),n}function ve(o,t){let{g:e}=o,a=E(e,t.type),n=e.ontology.types.find(p=>p.id===t.type),r=e.ontology.sidebar.pins.some(p=>e.names.get(h(p))===t.id),i=`<div class="ox-bar">${W(e,t)}${y(2)}</div>`;i+=`<div class="ox-head"><div class="ox-avatar">${u(e.ontology,t.type)}</div><div><h1>${l(t.title)}</h1><div class="ox-chips">`,i+=`<span class="ox-chip type">${u(e.ontology,t.type)}${l(n?.label??t.type)}</span>`,n?.schema&&(i+=`<span class="ox-chip mono">${l(n.schema.includes(" ")||n.schema.includes(":")?n.schema:`schema.org/${n.schema}`)}</span>`),t.type==="event"&&(i+=`<span class="ox-st ${t.importance}">${t.importance}</span>`),r&&(i+='<span class="ox-chip">pinned</span>'),t.pages.length>1&&(i+=`<span class="ox-chip">${m("merge")}merged from ${t.pages.length} pages</span>`),i+="</div></div></div>",t.review&&(i+=`<div class="ox-card ox-sub" style="border-color:var(--warn,#d97706)">Check the type: ${l(t.review)}</div>`);let s=te(t),c=s?"":ne(t);if((s||c)&&a[0]?.panel!=="notes"){let p=s?`<div class="ox-summary ox-prose">${C(e,s)}</div>`:`<p class="ox-summary">${l(c)}</p>`;i+=`<section class="ox-card">${p}<div class="ox-meta"><span>updated ${l(t.updated||"\u2014")}</span><span>sources: ${t.sources.length}</span><span>${t.statements.length} statements</span></div></section>`}i+='<div class="ox-grid2">';for(let p of a){let x=P(e,t,p,{full:!1,readEntries:o.readEntries}),d=g(p)==="notes";i+=S(e,t,x,!1,d?_(e,t,!1):"")}return i+="</div>",$(t.title,w(e,{pillar:t.pillar,entity:t.id}),i,re(e,t,a))}function be(o,t,e,a){let{g:n}=o,r=E(n,t.type).find(d=>d.panel===e);if(!r)return null;let i=P(n,t,r,{full:!0,page:a,pageSize:50,readEntries:o.readEntries}),s=r.title??r.panel,c=`<div class="ox-bar">${W(n,t,[{label:s}])}${y(3)}</div>`;c+=`<div class="ox-head"><div class="ox-avatar">${u(n.ontology,t.type)}</div><div><h1>${l(s)}</h1><p>${l(t.title)} \xB7 ${i.total} item${i.total===1?"":"s"}</p></div></div>`;let p=g(r)==="notes";c+=S(n,t,i,!0,p?_(n,t,!0):"");let x=Math.ceil(i.total/50);if(x>1){let d=`${f(t.id)}/${encodeURIComponent(e)}`;c+=`<div class="ox-pager">${a>1?`<a href="${d}?page=${a-1}">\u2190 newer</a>`:""}<span>page ${a} of ${x}</span>${a<x?`<a href="${d}?page=${a+1}">older \u2192</a>`:""}</div>`}return $(`${s} \xB7 ${t.title}`,w(n,{pillar:t.pillar,entity:t.id}),c)}function ye(o,t,e){let{g:a}=o,n=t.statements[e];if(!n)return null;let r=a.ontology.properties.find(d=>d.id===n.property),i=n.target?a.entities.get(n.target):void 0,s=n.page.article.meta,c=[["Subject",`<a href="${f(t.id)}">${l(t.title)}</a>`],["Property",`${l(r?.label??n.property)}${r?.wikidata?` <span class="ox-sub">wikidata ${l(r.wikidata)}</span>`:""}`],["Value",i?`<a href="${f(i.id)}">${l(i.title)}</a>`:l(n.value)]];n.role&&c.push(["Role",l(n.role)]),n.metric&&c.push(["Metric",l(n.metric)]),(n.since||n.until)&&c.push(["True",`${l(n.since??"\u2026")} \u2192 ${l(n.until??"now")}`]),n.at&&c.push(["Measured",l(n.at)]),c.push(["Recorded",l(s.lastUpdated||s.created||"\u2014")]),c.push(["Source",l(n.source??(s.sources.length?`${s.sources.length} conversation entries`:"not given"))]),c.push(["Written by",`${l(n.page.agentId)} \xB7 <a href="/agent/${encodeURIComponent(n.page.agentId)}/article/${encodeURIComponent(n.page.article.path)}">${l(n.page.article.path)}</a>`]),c.push(["Status",n.status?`<span class="ox-st ${l(n.status)}">${l(n.status)}</span>`:"not set"]),n.confirmed_by&&c.push(["Confirmed by",l(n.confirmed_by)]),n.checked_at&&c.push(["Checked",l(n.checked_at)]),c.push(["Access",l(n.access??s.access)]),n.note&&c.push(["Note",l(n.note)]);let p=o.versions(n.page.agentId,n.page.article.path);c.push(["Past versions",p.length?p.slice(0,8).map(d=>l(d.timestamp)).join("<br>"):"none saved"]);let x=`<div class="ox-bar">${W(a,t,[{label:r?.label??n.property}])}${y(4)}</div>`;return x+=`<div class="ox-head"><div class="ox-avatar">${m("key")}</div><div><h1>${l(r?.label??n.property)}</h1><p>${l(t.title)} \u2192 ${l(i?.title??n.value)}</p></div></div>`,x+=`<section class="ox-card">${c.map(([d,A])=>`<div class="ox-kv"><span class="k">${d}</span><span>${A}</span></div>`).join("")}</section>`,$(`${r?.label??n.property} \xB7 ${t.title}`,w(a,{pillar:t.pillar,entity:t.id}),x)}export{I as a,l as b,m as c,u as d,b as e,f,L as g,y as h,w as i,$ as j,k,N as l,D as m,ne as n,ve as o,be as p,ye as q};
152
- //# sourceMappingURL=chunk-BQIWMQNU.js.map
152
+ //# sourceMappingURL=chunk-H4NSB54D.js.map
@@ -0,0 +1,3 @@
1
+ import{a as d}from"./chunk-ROLSSYXE.js";import{existsSync as g,readFileSync as P,statSync as O,writeFileSync as A}from"fs";import{resolve as h}from"path";import w from"js-yaml";var l=(t=5)=>({panel:"history",title:"History",source:"history",show:t,importance:["major","normal"],fold:"minor",rollup:{min:5,days:30}}),c={panel:"discussed",title:"Discussed",source:"discussed",show:3,access:"owner"},s=(t=1)=>({panel:"notes",title:"Notes",source:"notes",show:t}),v=["device","server","app","domain","account","agent"],m="\\b(down|outage|offline|unreachable|fail(ed|ing|ure)?|crash(ed|es|ing)?|broke|broken|lost|loss|corrupt(ed)?|data|production|prod|customers?|clients?|incident|breach|after|loop|again)\\b",k=[{id:"person",label:"Person",plural:"People",pillar:"parties",schema:"Person",icon:"person",lens:[{panel:"roles",title:"Roles over time",from:["role_at","member_of","founded"],show:6,display:"timeline"},{panel:"relations",title:"Relations",from:["works_with","reports_to","client_of","works_on","related"],types:["person","organization","project"],show:5,group_by:"role"},{panel:"belongings",title:"Belongings",from:["owns","uses","related"],types:v.filter(t=>t!=="agent"),show:5},{panel:"obligations",title:"Obligations they carry",from:["subject_to"],show:3},l(),c,s()]},{id:"organization",label:"Organization",plural:"Organizations",pillar:"parties",schema:"Organization",icon:"org",lens:[{panel:"people",title:"People and roles",from:["role_at","member_of","founded"],show:6,group_by:"role"},{panel:"facts",title:"Key facts",from:["registered_with","located_in","identifier","legal_form"],show:6},{panel:"obligations",title:"Obligations and next due dates",from:["subject_to"],show:4},{panel:"agreements",title:"Agreements",source:"linked",types:["contract"],show:4},{panel:"decisions",title:"Decisions",source:"linked",types:["decision","policy"],show:4},l(),c,s()]},{id:"place",label:"Place",plural:"Places",pillar:"places",schema:"Place",icon:"pin",lens:[{panel:"here",title:"What is here",from:["located_in","related"],show:6},{panel:"laws",title:"Laws that apply here",from:["applies_in"],show:5},l(),s()]},{id:"jurisdiction",label:"Jurisdiction",plural:"Jurisdictions",pillar:"places",schema:"AdministrativeArea",icon:"pin",lens:[{panel:"laws",title:"Laws in force",from:["applies_in"],show:6},{panel:"authorities",title:"Authorities with reach",from:["jurisdiction_of"],show:5},{panel:"here",title:"What is here",from:["located_in"],show:5},s()]},{id:"device",label:"Device",plural:"Devices",pillar:"assets",schema:"Product",icon:"device",lens:[{panel:"state",title:"State now",source:"readings",latest:!0,show:6},l(),{panel:"apps",title:"Installed apps",from:["installed_on"],show:5},c,{panel:"parties",title:"Owner, user, location",from:["owns","uses","located_in","related"],types:["person","organization","place"],show:5},s()]},{id:"server",label:"Server",plural:"Servers",pillar:"assets",schema:"Product",icon:"server",lens:[{panel:"state",title:"State now",source:"readings",latest:!0,show:6},l(),{panel:"hosts",title:"Hosted services",from:["installed_on","runs_on"],show:6},c,{panel:"parties",title:"Owner and location",from:["owns","uses","located_in"],show:4},s()]},{id:"app",label:"App or system",plural:"Apps",pillar:"assets",schema:"SoftwareApplication",icon:"app",lens:[{panel:"installs",title:"Where it runs",from:["installed_on","runs_on"],show:5},{panel:"licence",title:"Licence or subscription",from:["party_to","licensed_by"],show:3},l(),c,s()]},{id:"domain",label:"Domain",plural:"Domains",pillar:"assets",schema:"WebSite",icon:"globe",lens:[{panel:"holder",title:"Holder",from:["owns","registrar"],show:3},{panel:"dues",title:"Renewal and due dates",source:"linked",types:["due_date"],show:4},{panel:"services",title:"Linked services",from:["related"],show:5},l(),s()]},{id:"account",label:"Account",plural:"Accounts",pillar:"assets",schema:"Service",icon:"key",lens:[{panel:"holder",title:"Holder",from:["owns","uses"],show:3},{panel:"dues",title:"Renewal and due dates",source:"linked",types:["due_date"],show:4},l(),s()]},{id:"agent",label:"Agent",plural:"Agents",pillar:"assets",schema:"SoftwareApplication",icon:"agent",lens:[{panel:"runs",title:"Where it runs",from:["runs_on","installed_on","related"],types:["server","device"],show:4},{panel:"works",title:"Works for",from:["works_for","uses","related"],types:["person","organization","project"],show:5},l(),c,s()]},{id:"project",label:"Project",plural:"Projects",pillar:"offerings",schema:"Project",icon:"project",lens:[{panel:"people",title:"Client and people",from:["client","client_of","works_on","related"],types:["person","organization","agent"],show:6,group_by:"role"},{panel:"agreements",title:"Agreements",source:"linked",types:["contract"],show:3},{panel:"decisions",title:"Decisions",source:"linked",types:["decision","policy"],show:4},l(6),c,s()]},{id:"offering",label:"Offering",plural:"Offerings",pillar:"offerings",schema:"Offer",icon:"project",lens:[{panel:"clients",title:"Clients",from:["client_of","related"],types:["organization","person"],show:5},l(),s()]},{id:"contract",label:"Agreement",plural:"Agreements",pillar:"agreements",schema:"Contract",icon:"contract",lens:[{panel:"parties",title:"Parties and roles",from:["party_to"],show:5,group_by:"role"},{panel:"terms",title:"Key terms and dates",from:["starts","renews","notice","amount"],show:6},{panel:"obligations",title:"Obligations it creates",from:["creates"],show:5},{panel:"amendments",title:"Amendments",from:["amends"],show:4},l(),s()]},{id:"legal_source",label:"Legal source",plural:"Legal sources",pillar:"law",schema:"Legislation",icon:"law",lens:[{panel:"reference",title:"Gazette reference and dates",from:["identifier","published_in","in_force_from","legal_force","issued_by"],show:6},{panel:"creates",title:"Obligations, penalties and reliefs it creates",from:["creates","created_by"],show:6},{panel:"amends",title:"Amends and amended by",from:["amends","repeals","implements"],show:5},{panel:"applies",title:"Where it applies",from:["applies_in"],show:3},s()]},{id:"obligation",label:"Obligation",plural:"Obligations",pillar:"law",schema:"LegalRuleML Obligation",icon:"law",lens:[{panel:"rule",title:"Who must do what, by when",from:["action","bearer","due_rule","amount_rule","authority","status"],show:6},{panel:"dues",title:"Next due dates",source:"linked",types:["due_date"],show:4},{panel:"sources",title:"Source articles",from:["created_by","changed_by"],show:4},{panel:"penalties",title:"Penalties and reliefs",from:["penalty_for","relieves"],show:4},{panel:"procedure",title:"Procedure",from:["procedure"],show:2},{panel:"bearers",title:"Who carries it",from:["subject_to"],show:5},l(4),s()]},{id:"penalty",label:"Penalty",plural:"Penalties",pillar:"law",schema:"LegalRuleML Penalty",icon:"law",lens:[{panel:"rule",title:"For which failure, how much",from:["penalty_for","kind","amount_rule","created_by"],show:6},s()]},{id:"relief",label:"Relief",plural:"Reliefs",pillar:"law",schema:"LegalRuleML Permission",icon:"law",lens:[{panel:"rule",title:"What it relieves, for whom, until when",from:["relieves","bearer","condition","created_by"],show:6},s()]},{id:"due_date",label:"Due date",plural:"Due dates",pillar:"law",schema:"Event",icon:"calendar",lens:[{panel:"due",title:"Due",from:["due_for","bearer","due","status","fulfilled_by"],show:6},s()]},{id:"event",label:"Event",plural:"Events",pillar:"events",schema:"Event",icon:"calendar",lens:[s(1),{panel:"involved",title:"Who and what was involved",from:["involves","affects","related"],show:8},{panel:"followed",title:"What followed",source:"linked",types:["event","decision"],show:4},c]},{id:"decision",label:"Decision",plural:"Decisions",pillar:"decisions",schema:"ChooseAction",icon:"decision",lens:[s(1),{panel:"affects",title:"What it affects",from:["affects","creates","related"],show:6},{panel:"replaced",title:"Replaced by",from:["replaced_by"],show:2},c]},{id:"policy",label:"Policy",plural:"Policies",pillar:"decisions",schema:"LegalRuleML Obligation",icon:"decision",lens:[{panel:"rule",title:"Rule",from:["action","bearer","creates","created_by"],show:6},{panel:"affects",title:"What it affects",from:["affects","related"],show:6},s()]},{id:"procedure",label:"Procedure",plural:"Procedures",pillar:"procedures",schema:"HowTo",icon:"steps",lens:[s(1),{panel:"triggers",title:"What triggers it",from:["procedure","triggered_by","related"],show:5},{panel:"runs",title:"Last runs",source:"linked",types:["event"],show:4}]},{id:"topic",label:"Topic",plural:"Topics",pillar:"topics",schema:"skos:Concept",icon:"topic",lens:[s(1),{panel:"related",title:"Related",from:["related"],show:8},l(4)]}],u={version:1,pillars:[{id:"parties",label:"Parties",description:"People and organisations, and the roles between them",icon:"person"},{id:"places",label:"Places & Jurisdictions",description:"Where things are, and whose rules apply there",icon:"pin"},{id:"assets",label:"Assets",description:"What is owned or run: devices, servers, apps, domains, accounts, agents",icon:"server"},{id:"offerings",label:"Offerings & Projects",description:"What is sold, built or delivered",icon:"project"},{id:"agreements",label:"Agreements",description:"Contracts, subscriptions and their terms",icon:"contract"},{id:"law",label:"Law & Obligations",description:"Legal sources, the obligations they create, penalties, reliefs and due dates",icon:"law"},{id:"events",label:"Events",description:"What happened, by importance",icon:"calendar"},{id:"decisions",label:"Decisions & Policies",description:"Why things are the way they are",icon:"decision"},{id:"procedures",label:"Procedures",description:"How things are done",icon:"steps"},{id:"topics",label:"Topics",description:"Pages no type fits yet. A growing count means a type is missing.",icon:"topic",sidebar:!1}],types:k,properties:[{id:"related",label:"related to",inverse:"related to"},{id:"role_at",label:"role at",inverse:"people",wikidata:"P108",range:["organization"],domain:["person"]},{id:"member_of",label:"member of",inverse:"members",wikidata:"P463",range:["organization"],domain:["person","organization"]},{id:"founded",label:"founded",inverse:"founded by",wikidata:"P112",domain:["person","organization"]},{id:"works_with",label:"works with",inverse:"works with",domain:["person","organization"]},{id:"reports_to",label:"reports to",inverse:"manages",domain:["person"]},{id:"client_of",label:"client of",inverse:"clients",wikidata:"P1972",domain:["person","organization"]},{id:"client",label:"is for client",inverse:"projects",range:["organization","person"],domain:["project","offering","contract"]},{id:"works_on",label:"works on",inverse:"people",range:["project"],domain:["person","organization","agent"]},{id:"works_for",label:"works for",inverse:"agents",wikidata:"P108",domain:["agent","person"]},{id:"owns",label:"owns",inverse:"owned by",wikidata:"P1830"},{id:"uses",label:"uses",inverse:"used by",wikidata:"P2283"},{id:"located_in",label:"located in",inverse:"here",wikidata:"P276"},{id:"installed_on",label:"installed on",inverse:"installed apps",range:["device","server"]},{id:"runs_on",label:"runs on",inverse:"hosts"},{id:"registered_with",label:"registered with",inverse:"registered"},{id:"identifier",label:"identifier",wikidata:"P1448"},{id:"legal_form",label:"legal form",wikidata:"P1454"},{id:"registrar",label:"registrar"},{id:"licensed_by",label:"licensed by",inverse:"licences"},{id:"party_to",label:"party to",inverse:"parties"},{id:"starts",label:"starts"},{id:"renews",label:"renews"},{id:"notice",label:"notice period"},{id:"amount",label:"amount"},{id:"creates",label:"creates",inverse:"created by"},{id:"created_by",label:"created by",inverse:"creates"},{id:"changed_by",label:"changed by",inverse:"changes"},{id:"amends",label:"amends",inverse:"amended by",wikidata:"P144"},{id:"repeals",label:"repeals",inverse:"repealed by"},{id:"implements",label:"implements",inverse:"implemented by"},{id:"issued_by",label:"issued by",inverse:"issues"},{id:"published_in",label:"published in",wikidata:"P1433"},{id:"in_force_from",label:"in force from",wikidata:"P7588"},{id:"legal_force",label:"legal force"},{id:"applies_in",label:"applies in",inverse:"laws that apply",wikidata:"P1001"},{id:"jurisdiction_of",label:"authority in",inverse:"authorities"},{id:"subject_to",label:"subject to",inverse:"carried by"},{id:"action",label:"action"},{id:"bearer",label:"bearer"},{id:"due_rule",label:"due"},{id:"amount_rule",label:"amount"},{id:"authority",label:"authority",inverse:"collects"},{id:"status",label:"status"},{id:"penalty_for",label:"penalty for",inverse:"penalties"},{id:"relieves",label:"relieves",inverse:"reliefs"},{id:"condition",label:"condition"},{id:"kind",label:"kind"},{id:"procedure",label:"procedure",inverse:"carries out"},{id:"due_for",label:"due for",inverse:"due dates"},{id:"due",label:"due on"},{id:"fulfilled_by",label:"fulfilled by",inverse:"fulfils"},{id:"involves",label:"involves",inverse:"events",wikidata:"P710"},{id:"affects",label:"affects",inverse:"affected by"},{id:"replaced_by",label:"replaced by",inverse:"replaces",wikidata:"P1366"},{id:"triggered_by",label:"triggered by",inverse:"triggers"},{id:"mentions",label:"mentions",inverse:"discussed in"},{id:"reading",label:"reading"},{id:"importance_set",label:"importance set"}],importance:{default:"normal",major_set_by:"owner",rollup:{min:5,days:30},rules:[{level:"minor",title:"\\b(disk|storage) (is |was |almost |nearly )?(full|pressure|cleanup|clean-up|usage|space)\\b",unless:m},{level:"minor",title:"\\b(cache|logs?|temp files?) (was |were )?(cleared|cleaned|purged|rotated|pruned)\\b",unless:m},{level:"minor",title:"\\b(restart(ed)?|reboot(ed)?|health ?check|heartbeat)\\b",unless:m}]},sidebar:{pins_max:5,pins:[]},classify:[{type:"agent",legacy:["person","concept","project"],title:"\\bagents?\\b|\\bbot\\b"},{type:"server",legacy:["place","concept"],title:"\\b(server|vps|host|node)\\b"},{type:"device",legacy:["place","concept"],title:"\\b(laptop|macbook|desktop|phone|tablet|printer|router)\\b"},{type:"person",legacy:["person"]},{type:"event",legacy:["event"]},{type:"decision",legacy:["decision"]},{type:"procedure",legacy:["pattern"]},{type:"place",legacy:["place"]},{type:"project",legacy:["project"]},{type:"organization",path:["clients","customers","vendors","suppliers","organizations","orgs","companies"]},{type:"organization",tags:["organization","company","client","vendor","supplier","agency","bank"]},{type:"server",path:["servers","hosts","infrastructure"]},{type:"server",tags:["server","vps","host"]},{type:"device",path:["devices"]},{type:"device",tags:["device","laptop","phone","printer"]},{type:"agent",tags:["agent"],title:"\\bagent\\b"},{type:"app",path:["apps","systems","services"]},{type:"domain",tags:["domain","dns"]},{type:"contract",path:["contracts","agreements"]},{type:"contract",tags:["contract","agreement","subscription"]},{type:"legal_source",path:["laws","legislation"]},{type:"legal_source",tags:["law","legislation","decree"]},{type:"obligation",path:["obligations","compliance"]},{type:"obligation",tags:["obligation","compliance"]},{type:"policy",path:["policies"]},{type:"policy",tags:["policy"]},{type:"procedure",path:["runbooks","procedures"]},{type:"procedure",tags:["runbook","procedure","how-to"]}],fallback_type:"topic"};var y="ontology.yaml",b=new Map;function T(t){let i=h(t,y);if(!g(i))return{ontology:u,errors:[],file:null};let r=O(i).mtimeMs,a=b.get(i);if(a&&a.mtimeMs===r)return a.loaded;let n,e=[];try{n=w.load(P(i,"utf-8"))}catch(_){e.push(`${y} is not valid YAML: ${_.message}`),n={}}let o=L(u,f(n)?n:{},e);e.push(...$(o));let p={ontology:o,errors:e,file:i};return b.set(i,{mtimeMs:r,loaded:p}),p}function M(t){let i=h(t,y);if(g(i))throw new Error(`${i} already exists`);let r=["# Wiki ontology: pillars, types, typed relations, event importance and lenses.","# Edit any section; what you leave out falls back to the built-in defaults.","# Check it with: agentx wiki ontology check",""].join(`
2
+ `);return A(i,r+w.dump(u,{lineWidth:120,noRefs:!0})),i}function L(t,i,r=[]){let a=structuredClone(t);typeof i.version=="number"&&(a.version=i.version);for(let n of["pillars","types","properties"]){let e=i[n];if(e!==void 0){if(!Array.isArray(e)){r.push(`${n} must be a list`);continue}a[n]=j(a[n],e,n,r)}}return f(i.importance)&&(a.importance={...a.importance,...i.importance}),f(i.sidebar)&&(a.sidebar={...a.sidebar,...i.sidebar}),i.classify!==void 0&&(Array.isArray(i.classify)?a.classify=i.classify:r.push("classify must be a list")),typeof i.fallback_type=="string"&&(a.fallback_type=i.fallback_type),i.agent_names!==void 0&&(Array.isArray(i.agent_names)?a.agent_names=i.agent_names.filter(n=>typeof n=="string"&&!!n.trim()):r.push("agent_names must be a list")),a}function j(t,i,r,a){let n=t.map(e=>({...e}));for(let e of i){if(!f(e)||typeof e.id!="string"){a.push(`every item in ${r} needs an id`);continue}let o=n.findIndex(p=>p.id===e.id);o===-1?n.push(e):n[o]={...n[o],...e}}return n}function $(t){let i=[],r=new Set(t.pillars.map(e=>e.id)),a=new Set(t.types.map(e=>e.id)),n=new Set(t.properties.map(e=>e.id));for(let e of t.types){r.has(e.pillar)||i.push(`type ${e.id}: unknown pillar "${e.pillar}"`);for(let o of e.lens??[]){for(let p of S(o))n.has(p)||i.push(`type ${e.id}, panel ${o.panel}: unknown property "${p}"`);for(let p of o.types??[])a.has(p)||i.push(`type ${e.id}, panel ${o.panel}: unknown type "${p}"`);for(let p of o.importance??[])d.includes(p)||i.push(`type ${e.id}, panel ${o.panel}: unknown importance "${p}"`)}}for(let e of t.classify)if(a.has(e.type)||i.push(`classify: unknown type "${e.type}"`),e.title)try{new RegExp(e.title,"i")}catch{i.push(`classify: bad title pattern "${e.title}"`)}a.has(t.fallback_type)||i.push(`fallback_type: unknown type "${t.fallback_type}"`),d.includes(t.importance.default)||i.push(`importance.default: unknown level "${t.importance.default}"`);for(let e of t.importance.rules??[]){if(d.includes(e.level)||i.push(`importance.rules: unknown level "${e.level}"`),!e.title&&!e.tags?.length&&i.push(`importance.rules: a rule for "${e.level}" needs a title or tags`),e.title)try{new RegExp(e.title,"i")}catch{i.push(`importance.rules: bad title pattern "${e.title}"`)}if(e.unless)try{new RegExp(e.unless,"i")}catch{i.push(`importance.rules: bad unless pattern "${e.unless}"`)}}return t.sidebar.pins.length>t.sidebar.pins_max&&i.push(`sidebar.pins: ${t.sidebar.pins.length} pins, only the first ${t.sidebar.pins_max} are shown`),i}function S(t){return t.from?Array.isArray(t.from)?t.from:[t.from]:[]}function C(t){return t.source?t.source:t.panel==="history"||t.panel==="discussed"||t.panel==="notes"?t.panel:t.latest?"readings":t.from?"statements":"linked"}function f(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}export{y as a,T as b,M as c,L as d,$ as e,S as f,C as g};
3
+ //# sourceMappingURL=chunk-MTX4UPNB.js.map