agentix-cli 0.192.0 → 0.193.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/README.md +2 -2
  2. package/dist/{App-N6WWCFBO.js → App-6TNGC3UR.js} +2 -2
  3. package/dist/{ChatApp-JMSINKZP.js → ChatApp-FUDLZ6HZ.js} +2 -2
  4. package/dist/{absorb-eval-4LJ4R7GN.js → absorb-eval-YSWPPGQF.js} +2 -2
  5. package/dist/{adapter-2Y3PQ5IZ.js → adapter-EEBNOFDS.js} +2 -2
  6. package/dist/{agent-RSOKWOZ2.js → agent-QX2POUEM.js} +2 -2
  7. package/dist/{board-dashboard-M3HOVCLM.js → board-dashboard-VVFHNABJ.js} +880 -429
  8. package/dist/board-dashboard-VVFHNABJ.js.map +1 -0
  9. package/dist/{chunk-E3UQEMNV.js → chunk-22WO5X4L.js} +103 -102
  10. package/dist/chunk-22WO5X4L.js.map +1 -0
  11. package/dist/{chunk-4IHQSNE3.js → chunk-2O72AHK5.js} +2 -2
  12. package/dist/{chunk-JW3ZHQ7U.js → chunk-2VQ3VKBR.js} +2 -2
  13. package/dist/{chunk-BZ2HOV4M.js → chunk-462FRP7L.js} +294 -292
  14. package/dist/chunk-462FRP7L.js.map +1 -0
  15. package/dist/{chunk-6FHKA62Y.js → chunk-52NME3AU.js} +2 -2
  16. package/dist/{chunk-54LKUDJZ.js → chunk-6FUWODBV.js} +2 -2
  17. package/dist/{chunk-CXAKD7XW.js → chunk-6ZAQ3IT5.js} +32 -30
  18. package/dist/chunk-6ZAQ3IT5.js.map +1 -0
  19. package/dist/{chunk-5XGQE2SN.js → chunk-AAL5WIXB.js} +2 -2
  20. package/dist/{chunk-JNJVRSOL.js → chunk-BKTKJNCR.js} +2 -2
  21. package/dist/{chunk-2HPVL6UM.js → chunk-DACZSUCN.js} +2 -2
  22. package/dist/{chunk-Y7HU4GHT.js → chunk-DS2ZIVIH.js} +2 -2
  23. package/dist/{chunk-WWFMIAYZ.js → chunk-EH7Y2W77.js} +2 -2
  24. package/dist/{chunk-UUQ2AHUL.js → chunk-EI3TZ52P.js} +2 -2
  25. package/dist/{chunk-VG3NUHJX.js → chunk-FEXG2PKQ.js} +2 -2
  26. package/dist/{chunk-7NXFW4LM.js → chunk-GLYBXXO7.js} +3 -3
  27. package/dist/{chunk-RZPQML3W.js → chunk-H5XBQWAI.js} +2 -2
  28. package/dist/{chunk-RZS4BHCW.js → chunk-HNA4BW47.js} +2 -2
  29. package/dist/chunk-HPRLRD4P.js +6 -0
  30. package/dist/chunk-HPRLRD4P.js.map +1 -0
  31. package/dist/{chunk-QQTSGXFB.js → chunk-JGZ6CA5L.js} +2 -2
  32. package/dist/{chunk-PNWXXDTE.js → chunk-KHKG7H6Q.js} +2 -2
  33. package/dist/chunk-MQRAQJSS.js +2 -0
  34. package/dist/chunk-MQRAQJSS.js.map +1 -0
  35. package/dist/{chunk-FFPF7SAD.js → chunk-MQV3IU6F.js} +2 -2
  36. package/dist/{chunk-6DGMUN2Q.js → chunk-N56EHPTR.js} +2 -2
  37. package/dist/{chunk-OPBPH7IB.js → chunk-OYXB6KZX.js} +2 -2
  38. package/dist/{chunk-2FCYIEKT.js → chunk-PSP3NAFU.js} +56 -56
  39. package/dist/{chunk-2FCYIEKT.js.map → chunk-PSP3NAFU.js.map} +1 -1
  40. package/dist/{chunk-VGQDLAX3.js → chunk-Q7ZPW55P.js} +2 -2
  41. package/dist/chunk-QTBFMRJ2.js +2 -0
  42. package/dist/chunk-QTBFMRJ2.js.map +1 -0
  43. package/dist/{chunk-ORBEL4I4.js → chunk-RDENYWNG.js} +90 -80
  44. package/dist/chunk-RDENYWNG.js.map +1 -0
  45. package/dist/{chunk-HNTWVZMH.js → chunk-TDZDIDFG.js} +2 -2
  46. package/dist/{chunk-KZPZ2O2F.js → chunk-VK2TW3RL.js} +36 -36
  47. package/dist/chunk-VK2TW3RL.js.map +1 -0
  48. package/dist/{chunk-BSMT7MK4.js → chunk-Z2NYUCTE.js} +2 -2
  49. package/dist/cli.js +1 -1
  50. package/dist/{client-CFS5VY26.js → client-5USANRIL.js} +2 -2
  51. package/dist/{config-4R6DCRCN.js → config-N7DHUZMH.js} +2 -2
  52. package/dist/{config-mutate-EG5PS7KW.js → config-mutate-OVUXNS5X.js} +2 -2
  53. package/dist/config-mutator-OK7CDCHW.js +2 -0
  54. package/dist/{contributions-G4FZ2PKZ.js → contributions-LTDE6UOQ.js} +2 -2
  55. package/dist/{doctor-4VQ5RFWH.js → doctor-C3DTKR7C.js} +2 -2
  56. package/dist/{follow-up-tool-JJSFOO5D.js → follow-up-tool-NCFOTJ5Y.js} +2 -2
  57. package/dist/{hub-Z3KDKP7M.js → hub-F3X7NL4B.js} +2 -2
  58. package/dist/index.d.ts +81 -1
  59. package/dist/index.js +1 -1
  60. package/dist/index.js.map +1 -1
  61. package/dist/{program-6UF4K6CK.js → program-6HWZZ2D3.js} +233 -233
  62. package/dist/program-6HWZZ2D3.js.map +1 -0
  63. package/dist/{promote-WJ5HXGJG.js → promote-FSOPSHJ4.js} +2 -2
  64. package/dist/{query-7JPB2UBE.js → query-UDRKDTSB.js} +2 -2
  65. package/dist/query-runs-AENEZOM6.js +2 -0
  66. package/dist/{query-settings-O53GJRCB.js → query-settings-DJGEGG62.js} +2 -2
  67. package/dist/registry-AVGT5KPR.js +2 -0
  68. package/dist/{request-planner-25WOUCP7.js → request-planner-SAQX26AR.js} +2 -2
  69. package/dist/{review-candidates-KU3B6T5E.js → review-candidates-67MPNU42.js} +2 -2
  70. package/dist/{routing-SJQB4SJM.js → routing-7DUO5PI7.js} +2 -2
  71. package/dist/schedule-tool-LZOW5SVQ.js +2 -0
  72. package/dist/{scheduler-W3TMCBUH.js → scheduler-3IADVHIN.js} +2 -2
  73. package/dist/{seat-NDZLFK4N.js → seat-YWSYQBCW.js} +2 -2
  74. package/dist/{select-3D3GZOBS.js → select-PA7AHZ3W.js} +2 -2
  75. package/dist/self-KACQLLDA.js +2 -0
  76. package/dist/{set-enabled-ZUTWWK5S.js → set-enabled-DD6L2ZQ6.js} +2 -2
  77. package/dist/{sprint-tool-CAARUDXM.js → sprint-tool-PKJA6LYF.js} +2 -2
  78. package/dist/{tool-GKPYCNZ3.js → tool-KOGZBOCR.js} +2 -2
  79. package/dist/{tool-HK7VOPB3.js → tool-PJSLWK45.js} +2 -2
  80. package/dist/{tool-3UIRQJZF.js → tool-WJ72TBMV.js} +2 -2
  81. package/dist/{wiki-F4YT226F.js → wiki-HQBMWH23.js} +2 -2
  82. package/dist/wiki-enrich-7RPM5DQF.js +2 -0
  83. package/dist/wiki-enrich-7RPM5DQF.js.map +1 -0
  84. package/package.json +1 -1
  85. package/dist/board-dashboard-M3HOVCLM.js.map +0 -1
  86. package/dist/chunk-BZ2HOV4M.js.map +0 -1
  87. package/dist/chunk-CXAKD7XW.js.map +0 -1
  88. package/dist/chunk-CZMVJP7O.js +0 -2
  89. package/dist/chunk-CZMVJP7O.js.map +0 -1
  90. package/dist/chunk-E3UQEMNV.js.map +0 -1
  91. package/dist/chunk-KZPZ2O2F.js.map +0 -1
  92. package/dist/chunk-ORBEL4I4.js.map +0 -1
  93. package/dist/config-mutator-YDVTCBQZ.js +0 -2
  94. package/dist/program-6UF4K6CK.js.map +0 -1
  95. package/dist/query-runs-VXS572PQ.js +0 -6
  96. package/dist/query-runs-VXS572PQ.js.map +0 -1
  97. package/dist/registry-WNKSI445.js +0 -2
  98. package/dist/schedule-tool-T6FHG77E.js +0 -2
  99. package/dist/self-SO6GCVYD.js +0 -2
  100. package/dist/wiki-enrich-E6YYAI2T.js +0 -2
  101. /package/dist/{App-N6WWCFBO.js.map → App-6TNGC3UR.js.map} +0 -0
  102. /package/dist/{ChatApp-JMSINKZP.js.map → ChatApp-FUDLZ6HZ.js.map} +0 -0
  103. /package/dist/{absorb-eval-4LJ4R7GN.js.map → absorb-eval-YSWPPGQF.js.map} +0 -0
  104. /package/dist/{adapter-2Y3PQ5IZ.js.map → adapter-EEBNOFDS.js.map} +0 -0
  105. /package/dist/{agent-RSOKWOZ2.js.map → agent-QX2POUEM.js.map} +0 -0
  106. /package/dist/{chunk-4IHQSNE3.js.map → chunk-2O72AHK5.js.map} +0 -0
  107. /package/dist/{chunk-JW3ZHQ7U.js.map → chunk-2VQ3VKBR.js.map} +0 -0
  108. /package/dist/{chunk-6FHKA62Y.js.map → chunk-52NME3AU.js.map} +0 -0
  109. /package/dist/{chunk-54LKUDJZ.js.map → chunk-6FUWODBV.js.map} +0 -0
  110. /package/dist/{chunk-5XGQE2SN.js.map → chunk-AAL5WIXB.js.map} +0 -0
  111. /package/dist/{chunk-JNJVRSOL.js.map → chunk-BKTKJNCR.js.map} +0 -0
  112. /package/dist/{chunk-2HPVL6UM.js.map → chunk-DACZSUCN.js.map} +0 -0
  113. /package/dist/{chunk-Y7HU4GHT.js.map → chunk-DS2ZIVIH.js.map} +0 -0
  114. /package/dist/{chunk-WWFMIAYZ.js.map → chunk-EH7Y2W77.js.map} +0 -0
  115. /package/dist/{chunk-UUQ2AHUL.js.map → chunk-EI3TZ52P.js.map} +0 -0
  116. /package/dist/{chunk-VG3NUHJX.js.map → chunk-FEXG2PKQ.js.map} +0 -0
  117. /package/dist/{chunk-7NXFW4LM.js.map → chunk-GLYBXXO7.js.map} +0 -0
  118. /package/dist/{chunk-RZPQML3W.js.map → chunk-H5XBQWAI.js.map} +0 -0
  119. /package/dist/{chunk-RZS4BHCW.js.map → chunk-HNA4BW47.js.map} +0 -0
  120. /package/dist/{chunk-QQTSGXFB.js.map → chunk-JGZ6CA5L.js.map} +0 -0
  121. /package/dist/{chunk-PNWXXDTE.js.map → chunk-KHKG7H6Q.js.map} +0 -0
  122. /package/dist/{chunk-FFPF7SAD.js.map → chunk-MQV3IU6F.js.map} +0 -0
  123. /package/dist/{chunk-6DGMUN2Q.js.map → chunk-N56EHPTR.js.map} +0 -0
  124. /package/dist/{chunk-OPBPH7IB.js.map → chunk-OYXB6KZX.js.map} +0 -0
  125. /package/dist/{chunk-VGQDLAX3.js.map → chunk-Q7ZPW55P.js.map} +0 -0
  126. /package/dist/{chunk-HNTWVZMH.js.map → chunk-TDZDIDFG.js.map} +0 -0
  127. /package/dist/{chunk-BSMT7MK4.js.map → chunk-Z2NYUCTE.js.map} +0 -0
  128. /package/dist/{client-CFS5VY26.js.map → client-5USANRIL.js.map} +0 -0
  129. /package/dist/{config-4R6DCRCN.js.map → config-N7DHUZMH.js.map} +0 -0
  130. /package/dist/{config-mutate-EG5PS7KW.js.map → config-mutate-OVUXNS5X.js.map} +0 -0
  131. /package/dist/{config-mutator-YDVTCBQZ.js.map → config-mutator-OK7CDCHW.js.map} +0 -0
  132. /package/dist/{contributions-G4FZ2PKZ.js.map → contributions-LTDE6UOQ.js.map} +0 -0
  133. /package/dist/{doctor-4VQ5RFWH.js.map → doctor-C3DTKR7C.js.map} +0 -0
  134. /package/dist/{follow-up-tool-JJSFOO5D.js.map → follow-up-tool-NCFOTJ5Y.js.map} +0 -0
  135. /package/dist/{hub-Z3KDKP7M.js.map → hub-F3X7NL4B.js.map} +0 -0
  136. /package/dist/{promote-WJ5HXGJG.js.map → promote-FSOPSHJ4.js.map} +0 -0
  137. /package/dist/{query-7JPB2UBE.js.map → query-UDRKDTSB.js.map} +0 -0
  138. /package/dist/{registry-WNKSI445.js.map → query-runs-AENEZOM6.js.map} +0 -0
  139. /package/dist/{query-settings-O53GJRCB.js.map → query-settings-DJGEGG62.js.map} +0 -0
  140. /package/dist/{routing-SJQB4SJM.js.map → registry-AVGT5KPR.js.map} +0 -0
  141. /package/dist/{request-planner-25WOUCP7.js.map → request-planner-SAQX26AR.js.map} +0 -0
  142. /package/dist/{review-candidates-KU3B6T5E.js.map → review-candidates-67MPNU42.js.map} +0 -0
  143. /package/dist/{schedule-tool-T6FHG77E.js.map → routing-7DUO5PI7.js.map} +0 -0
  144. /package/dist/{scheduler-W3TMCBUH.js.map → schedule-tool-LZOW5SVQ.js.map} +0 -0
  145. /package/dist/{seat-NDZLFK4N.js.map → scheduler-3IADVHIN.js.map} +0 -0
  146. /package/dist/{self-SO6GCVYD.js.map → seat-YWSYQBCW.js.map} +0 -0
  147. /package/dist/{select-3D3GZOBS.js.map → select-PA7AHZ3W.js.map} +0 -0
  148. /package/dist/{wiki-F4YT226F.js.map → self-KACQLLDA.js.map} +0 -0
  149. /package/dist/{set-enabled-ZUTWWK5S.js.map → set-enabled-DD6L2ZQ6.js.map} +0 -0
  150. /package/dist/{sprint-tool-CAARUDXM.js.map → sprint-tool-PKJA6LYF.js.map} +0 -0
  151. /package/dist/{tool-GKPYCNZ3.js.map → tool-KOGZBOCR.js.map} +0 -0
  152. /package/dist/{tool-HK7VOPB3.js.map → tool-PJSLWK45.js.map} +0 -0
  153. /package/dist/{tool-3UIRQJZF.js.map → tool-WJ72TBMV.js.map} +0 -0
  154. /package/dist/{wiki-enrich-E6YYAI2T.js.map → wiki-HQBMWH23.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as Ge,b as k,c as D,d as Xe,e as ge,f as ue,g as j,h as me,i as N,j as L,n as Ve,o as Qe,p as Ze,q as ea}from"./chunk-EFGAPAYZ.js";import{e as Ye,i as Je}from"./chunk-QAWKN2N4.js";import{b as xe}from"./chunk-DODL5POT.js";import{a as Q,b as Ke}from"./chunk-6DGMUN2Q.js";import{Ia as We,Ja as Be,Ka as Ue,Ma as Fe,ja as _,oa as Le,wb as qe}from"./chunk-ORBEL4I4.js";import{a as X}from"./chunk-IMLAPB7G.js";import{b as V}from"./chunk-2VDO2HEK.js";import{c as Me,e as He}from"./chunk-LQE73AZR.js";import{b as Ne}from"./chunk-MRIVENBY.js";import{q as pe,s as je}from"./chunk-XPZSEDE3.js";import{ga as G}from"./chunk-KZPZ2O2F.js";import{a as q,b as J}from"./chunk-2HPVL6UM.js";import{a as De}from"./chunk-UUQ2AHUL.js";import{c as Ee,d as Re}from"./chunk-OWNQ2FD4.js";import{a as Oe}from"./chunk-ROLSSYXE.js";import{a as Pe}from"./chunk-QUFIUXMQ.js";import{Gb as ce,Ta as Ie,_a as Va,ea as de,fa as Te,pa as Xa,tb as le,wb as F,xb as ze}from"./chunk-CXAKD7XW.js";import{existsSync as K,readFileSync as da,writeFileSync as la,appendFileSync as lt,mkdirSync as ct}from"fs";import{dirname as pt,resolve as M}from"path";import{fileURLToPath as xt}from"url";import{hostname as gt}from"os";import{spawn as ut}from"child_process";var fe=`:root {
1
+ import{a as Xe,b as k,c as D,d as Ve,e as ue,f as me,g as j,h as fe,i as N,j as L,n as Qe,o as Ze,p as ea,q as aa}from"./chunk-EFGAPAYZ.js";import{e as Je,i as Ge}from"./chunk-QAWKN2N4.js";import{b as ge}from"./chunk-DODL5POT.js";import{a as Q,b as Ye}from"./chunk-N56EHPTR.js";import{Ia as Be,Ja as Ue,Ka as Fe,Ma as qe,ja as _,oa as We,wb as Ke}from"./chunk-RDENYWNG.js";import{a as X}from"./chunk-IMLAPB7G.js";import{b as V}from"./chunk-2VDO2HEK.js";import{c as He,e as je}from"./chunk-LQE73AZR.js";import{b as Le}from"./chunk-MRIVENBY.js";import{q as xe,s as Ne}from"./chunk-XPZSEDE3.js";import{ga as G}from"./chunk-VK2TW3RL.js";import{b as pe}from"./chunk-MQRAQJSS.js";import{a as q,b as J}from"./chunk-DACZSUCN.js";import{a as Me}from"./chunk-EI3TZ52P.js";import{c as Re,d as Oe}from"./chunk-OWNQ2FD4.js";import{a as De}from"./chunk-ROLSSYXE.js";import{a as Ee}from"./chunk-QUFIUXMQ.js";import{$a as Qa,Hb as ce,Ua as ze,ea as de,fa as Ie,pa as Va,ub as le,xb as F,yb as Pe}from"./chunk-6ZAQ3IT5.js";import{existsSync as K,readFileSync as la,writeFileSync as ca,appendFileSync as ct,mkdirSync as pt}from"fs";import{dirname as xt,resolve as M}from"path";import{fileURLToPath as gt}from"url";import{hostname as ut}from"os";import{spawn as mt}from"child_process";var he=`:root {
2
2
  /* --- Brand (agentina) --------------------------------------------- */
3
3
  --ax-blue: #2979FF;
4
4
  --ax-blue-d: #1B5FD9;
@@ -140,7 +140,7 @@ pre, code, .ax-mono {
140
140
  a { color: var(--ax-accent); text-decoration: none; font-weight: 600; }
141
141
  a:hover { color: var(--ax-accent-2); text-decoration: underline; }
142
142
  .ax-muted { color: var(--ax-muted); }
143
- .ax-accent { color: var(--ax-accent); }`;var he=`
143
+ .ax-accent { color: var(--ax-accent); }`;var be=`
144
144
  /* --- Dots --- */
145
145
  .ax-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ax-muted); }
146
146
  .ax-dot--ok, .ax-dot--live { background: var(--ax-accent); }
@@ -1608,7 +1608,7 @@ textarea.ax-builder__inp { min-height: 80px; line-height: 1.5; resize: vertical;
1608
1608
  .ax-log-head, .ax-log-row { grid-template-columns: 8px 80px 1fr auto; }
1609
1609
  .ax-log-head span:nth-child(3), .ax-log-row .ax-who { display: none; }
1610
1610
  .ax-grid-2, .ax-grid-3 { grid-template-columns: 1fr; }
1611
- }`;var aa=`
1611
+ }`;var ta=`
1612
1612
  .ax-as-dock{position:fixed;bottom:0;left:50%;transform:translateX(-50%);z-index:59;
1613
1613
  display:flex;flex-direction:column;align-items:center;
1614
1614
  width:min(620px,calc(100vw - 36px));transition:transform 160ms ease}
@@ -1720,7 +1720,7 @@ body.ax-as-open{padding-right:var(--ax-as-w)}
1720
1720
  .ax-as__foot textarea{flex:1;resize:none;font:inherit;font-size:13px;padding:8px 10px;
1721
1721
  min-height:38px;max-height:140px;border-radius:var(--ax-radius-sm);
1722
1722
  border:var(--ax-border-w) solid var(--ax-border-2);background:var(--ax-bg);color:var(--ax-text)}
1723
- `,ta=`
1723
+ `,ra=`
1724
1724
  <div class="ax-as-dock" id="ax-as-dock">
1725
1725
  <button class="ax-as-dock__grip" id="ax-as-bar-toggle" type="button"
1726
1726
  aria-expanded="true" aria-controls="ax-as-bar" title="Hide the composer"></button>
@@ -1751,7 +1751,7 @@ body.ax-as-open{padding-right:var(--ax-as-w)}
1751
1751
  <div class="ax-as__log" id="ax-as-log">
1752
1752
  <p class="ax-as__empty">Ask about what is on this page. What you are looking at &mdash; the page, its filters and the rows in view &mdash; goes with the question.</p>
1753
1753
  </div>
1754
- </aside>`,ra=String.raw`
1754
+ </aside>`,na=String.raw`
1755
1755
  (function(){
1756
1756
  const $=id=>document.getElementById(id);
1757
1757
  const panel=$('ax-as'), handle=$('ax-as-handle');
@@ -1966,56 +1966,56 @@ if(threadId&&!userHid()&&$('ax-as-log').querySelector('.ax-as__pending'))open(tr
1966
1966
  });
1967
1967
  loadHistory();
1968
1968
  })();
1969
- `;function na(e){return"globalThis.__axBind=globalThis.__axBind||((n,f)=>{globalThis[f.name]=f;globalThis[n]=f;return f});"+Object.entries(e).map(([t,r])=>`const ${t}=globalThis.__axBind(${JSON.stringify(t)},${r.toString()});`).join("")}function be(e){let a=`${fe}
1970
- ${he}
1971
- ${Be}
1972
- ${aa}${e.css?`
1973
- `+e.css:""}`,t=e.customHeader??(e.activeTab==="custom"?"":Fe({activeTab:e.activeTab,subtitle:e.subtitle,subheader:e.subheader,peers:e.peers,currentPeerId:e.currentPeerId})),r=e.noMain?e.body:`<main>${e.body}</main>`;return`<!DOCTYPE html>
1969
+ `;function oa(e){return"globalThis.__axBind=globalThis.__axBind||((n,f)=>{globalThis[f.name]=f;globalThis[n]=f;return f});"+Object.entries(e).map(([t,r])=>`const ${t}=globalThis.__axBind(${JSON.stringify(t)},${r.toString()});`).join("")}function ve(e){let a=`${he}
1970
+ ${be}
1971
+ ${Ue}
1972
+ ${ta}${e.css?`
1973
+ `+e.css:""}`,t=e.customHeader??(e.activeTab==="custom"?"":qe({activeTab:e.activeTab,subtitle:e.subtitle,subheader:e.subheader,peers:e.peers,currentPeerId:e.currentPeerId})),r=e.noMain?e.body:`<main>${e.body}</main>`;return`<!DOCTYPE html>
1974
1974
  <html lang="en">
1975
1975
  <head>
1976
1976
  <meta charset="utf-8">
1977
1977
  <meta name="viewport" content="width=device-width, initial-scale=1">
1978
- <title>${Qa(e.title)}</title>
1979
- ${We}
1978
+ <title>${Za(e.title)}</title>
1979
+ ${Be}
1980
1980
  ${e.headExtras||""}
1981
1981
  <style>${a}</style>
1982
1982
  </head>
1983
1983
  <body>
1984
1984
  ${t}
1985
1985
  ${r}
1986
- ${e.noAssistant?"":ta}
1987
- ${Ue}
1986
+ ${e.noAssistant?"":ra}
1987
+ ${Fe}
1988
1988
  ${e.scripts||""}
1989
- ${e.noAssistant?"":`<script>${na({markdownToHtml:X})}${ra}</script>`}
1989
+ ${e.noAssistant?"":`<script>${oa({markdownToHtml:X})}${na}</script>`}
1990
1990
  </body>
1991
- </html>`}function Qa(e){return String(e||"").replace(/[<>&]/g,a=>({"<":"&lt;",">":"&gt;","&":"&amp;"})[a])}function Z(e,a={}){let t=["ax-btn",a.primary?"ax-btn--primary":"",a.ghost?"ax-btn--ghost":"",a.danger?"ax-btn--danger":"",a.extraClass||""].filter(Boolean).join(" ");return`<button ${[`type="${a.type||"button"}"`,`class="${t}"`,a.id?`id="${_(a.id)}"`:"",a.disabled?"disabled":"",a.onclick?`onclick="${_(a.onclick)}"`:""].filter(Boolean).join(" ")}>${_(e)}</button>`}function z(e){let a=`<label>${_(e.label)}${e.hint?` <span class="ax-hint">${e.hint}</span>`:""}</label>`,t="",r=[`name="${_(e.name)}"`,e.required?"required":"",e.readonly?"readonly":"",e.placeholder?`placeholder="${_(e.placeholder)}"`:"",e.extraAttrs||""].filter(Boolean).join(" ");if(e.type==="textarea")t=`<textarea ${r} rows="${e.rows||3}">${_(e.value||"")}</textarea>`;else if(e.type==="select"&&e.options){let n=e.options.map(o=>`<option value="${_(o.value)}"${o.selected?" selected":""}>${_(o.label)}</option>`).join("");t=`<select ${r}>${n}</select>`}else t=`<input type="${e.type||"text"}" ${r}`+(e.value!==void 0?` value="${_(e.value)}"`:"")+(e.pattern?` pattern="${_(e.pattern)}"`:"")+" />";return`<div class="ax-field">${a}${t}</div>`}function ee(e){return`<div class="ax-row">${e.join("")}</div>`}function W(e,a,t){return`<section class="ax-step">
1991
+ </html>`}function Za(e){return String(e||"").replace(/[<>&]/g,a=>({"<":"&lt;",">":"&gt;","&":"&amp;"})[a])}function Z(e,a={}){let t=["ax-btn",a.primary?"ax-btn--primary":"",a.ghost?"ax-btn--ghost":"",a.danger?"ax-btn--danger":"",a.extraClass||""].filter(Boolean).join(" ");return`<button ${[`type="${a.type||"button"}"`,`class="${t}"`,a.id?`id="${_(a.id)}"`:"",a.disabled?"disabled":"",a.onclick?`onclick="${_(a.onclick)}"`:""].filter(Boolean).join(" ")}>${_(e)}</button>`}function z(e){let a=`<label>${_(e.label)}${e.hint?` <span class="ax-hint">${e.hint}</span>`:""}</label>`,t="",r=[`name="${_(e.name)}"`,e.required?"required":"",e.readonly?"readonly":"",e.placeholder?`placeholder="${_(e.placeholder)}"`:"",e.extraAttrs||""].filter(Boolean).join(" ");if(e.type==="textarea")t=`<textarea ${r} rows="${e.rows||3}">${_(e.value||"")}</textarea>`;else if(e.type==="select"&&e.options){let n=e.options.map(o=>`<option value="${_(o.value)}"${o.selected?" selected":""}>${_(o.label)}</option>`).join("");t=`<select ${r}>${n}</select>`}else t=`<input type="${e.type||"text"}" ${r}`+(e.value!==void 0?` value="${_(e.value)}"`:"")+(e.pattern?` pattern="${_(e.pattern)}"`:"")+" />";return`<div class="ax-field">${a}${t}</div>`}function ee(e){return`<div class="ax-row">${e.join("")}</div>`}function W(e,a,t){return`<section class="ax-step">
1992
1992
  <div class="ax-step__head"><span class="ax-step__num">${_(String(e))}</span>${_(a)}</div>
1993
1993
  ${t}
1994
- </section>`}function Za(e){return`<div class="ax-page-head">
1994
+ </section>`}function et(e){return`<div class="ax-page-head">
1995
1995
  ${e.kicker?`<div class="ax-kicker">${_(e.kicker)}</div>`:""}
1996
1996
  <h1>${_(e.title)}</h1>
1997
1997
  ${e.lead?`<p class="ax-lead">${e.lead}</p>`:""}
1998
- </div>`}function oa(e){return`<div class="ax-health-card">
1998
+ </div>`}function ia(e){return`<div class="ax-health-card">
1999
1999
  <div class="ax-hc-dot ax-hc-dot--${e.kind||"off"}"></div>
2000
2000
  <div class="ax-hc-txt">
2001
2001
  <div class="ax-hc-num">${_(e.num)}</div>
2002
2002
  <div class="ax-hc-lbl">${_(e.label)}</div>
2003
2003
  </div>
2004
- </div>`}function et(e){return`<div class="ax-health-strip">${e.map(oa).join("")}</div>`}function at(e){return`<div class="ax-wit"${e.persistKey?` data-wit="${_(e.persistKey)}"`:""}>
2004
+ </div>`}function at(e){return`<div class="ax-health-strip">${e.map(ia).join("")}</div>`}function tt(e){return`<div class="ax-wit"${e.persistKey?` data-wit="${_(e.persistKey)}"`:""}>
2005
2005
  <span class="ax-wit__icon">${_(e.icon||"?")}</span>
2006
2006
  <div>${e.bodyHtml}</div>
2007
2007
  <button class="ax-wit__dismiss" onclick="this.parentElement.style.display='none'">\xD7</button>
2008
- </div>`}function tt(e){return`<div class="ax-section-head">
2008
+ </div>`}function rt(e){return`<div class="ax-section-head">
2009
2009
  <div class="ax-section-head__icon">${e.icon}</div>
2010
2010
  <div class="ax-section-head__text">
2011
2011
  <h2>${_(e.title)}</h2>
2012
2012
  ${e.lead?`<p class="ax-lead">${_(e.lead)}</p>`:""}
2013
2013
  </div>
2014
2014
  ${e.actionHtml||""}
2015
- </div>`}function rt(e){return`<div class="ax-sec-label"><h3>${_(e.label)}</h3>${e.rightHtml||""}</div>`}var nt=`<div class="ax-toast" id="ax-toast">
2015
+ </div>`}function nt(e){return`<div class="ax-sec-label"><h3>${_(e.label)}</h3>${e.rightHtml||""}</div>`}var ot=`<div class="ax-toast" id="ax-toast">
2016
2016
  <svg class="ax-toast__icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20 6L9 17l-5-5"/></svg>
2017
2017
  <span id="ax-toast-msg">Copied</span>
2018
- </div>`,ot=`
2018
+ </div>`,it=`
2019
2019
  let __axToastTimer;
2020
2020
  window.showToast = function(msg) {
2021
2021
  const el = document.getElementById('ax-toast');
@@ -2029,11 +2029,11 @@ ${e.noAssistant?"":`<script>${na({markdownToHtml:X})}${ra}</script>`}
2029
2029
  window.copyText = function(_btn, text) {
2030
2030
  try { navigator.clipboard.writeText(text); } catch (e) {}
2031
2031
  window.showToast('Copied to clipboard');
2032
- };`,it=`
2032
+ };`,st=`
2033
2033
  window.toggleCard = function(btn) {
2034
2034
  const card = btn.closest('.ax-row-card');
2035
2035
  if (card) card.classList.toggle('is-open');
2036
- };`;function ia(e,a){let t=e.configExists?e.agentCount===0?"Add your first agent":"Add another agent":"Set up your team",r=`<header class="ax-topbar">
2036
+ };`;function sa(e,a){let t=e.configExists?e.agentCount===0?"Add your first agent":"Add another agent":"Set up your team",r=`<header class="ax-topbar">
2037
2037
  <div class="ax-topbar__left">
2038
2038
  <div class="ax-brand">
2039
2039
  <span class="ax-brand__mark">AX</span>
@@ -2042,7 +2042,7 @@ ${e.noAssistant?"":`<script>${na({markdownToHtml:X})}${ra}</script>`}
2042
2042
  </div>
2043
2043
  </div>
2044
2044
  <div class="ax-topbar__right">
2045
- <a href="/wall#page=live" class="ax-skip">Skip \u2014 open dashboard</a>
2045
+ <a href="${pe}#page=live" class="ax-skip">Skip \u2014 open dashboard</a>
2046
2046
  <div class="ax-theme-switch" role="tablist" aria-label="Theme">
2047
2047
  <button data-theme-opt="dark">Dark</button>
2048
2048
  <button data-theme-opt="light">Light</button>
@@ -2072,10 +2072,10 @@ ${e.noAssistant?"":`<script>${na({markdownToHtml:X})}${ra}</script>`}
2072
2072
  ${s}
2073
2073
  <footer class="ax-actions">
2074
2074
  ${Z("Save and continue",{type:"submit",primary:!0,id:"submitBtn"})}
2075
- ${Z("Skip, I'll do it later",{onclick:"window.location.href='/wall#page=live'"})}
2075
+ ${Z("Skip, I'll do it later",{onclick:`window.location.href='${pe}#page=live'`})}
2076
2076
  </footer>
2077
2077
  </form>
2078
- </div>`;return be({title:"AgentX \u2014 Setup",activeTab:"custom",subtitle:"Setup",customHeader:r,noMain:!0,body:l,css:st,scripts:dt})}var st=`
2078
+ </div>`;return ve({title:"AgentX \u2014 Setup",activeTab:"custom",subtitle:"Setup",customHeader:r,noMain:!0,body:l,css:dt,scripts:lt})}var dt=`
2079
2079
  /* Pre-dashboard topbar variant \u2014 no tab nav, the pills are the only chrome. */
2080
2080
  .ax-topbar__right a.ax-skip {
2081
2081
  padding: 4px 10px; border: 1px solid var(--ax-border-2); border-radius: 4px;
@@ -2132,7 +2132,7 @@ ${e.noAssistant?"":`<script>${na({markdownToHtml:X})}${ra}</script>`}
2132
2132
  .ax-next-steps code { background: var(--ax-surface-2); padding: 1px 6px; border-radius: 3px; color: var(--ax-text); font-family: var(--ax-mono); font-size: var(--ax-fs-sm); }
2133
2133
  .ax-startd { margin-top: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
2134
2134
  .ax-startd__status { color: var(--ax-text-2); font-size: var(--ax-fs-sm); }
2135
- .ax-startd__status a { color: var(--ax-accent); }`,dt=`<script>
2135
+ .ax-startd__status a { color: var(--ax-accent); }`,lt=`<script>
2136
2136
  document.getElementById('enableTelegram').addEventListener('change', (e) => {
2137
2137
  document.getElementById('telegramFields').classList.toggle('is-show', e.target.checked);
2138
2138
  });
@@ -2206,16 +2206,16 @@ document.getElementById('wizard').addEventListener('submit', async (e) => {
2206
2206
  btn.disabled = false; btn.textContent = 'Save and continue';
2207
2207
  }
2208
2208
  });
2209
- </script>`;ce();function ca(e=process.cwd()){let a=M(e,"agentx.json");if(!K(a))return{configExists:!1,agentCount:0,channelCount:0};try{let t=JSON.parse(da(a,"utf-8")),r=t.agents?Object.keys(t.agents).length:0,n=t.channels?Object.values(t.channels).filter(o=>o&&o.enabled).length:0;return{configExists:!0,agentCount:r,channelCount:n,nodeName:t.node?.name}}catch{return{configExists:!1,agentCount:0,channelCount:0}}}function mt(e,a=process.cwd(),t={}){if(!e.nodeName?.trim())throw new Error("Team name is required.");if(!e.agent?.id?.trim())throw new Error("Agent id is required.");if(!/^[a-z0-9][a-z0-9_-]*$/.test(e.agent.id))throw new Error("Agent id must be lowercase (letters, digits, -, _) and start with a letter or digit.");if(!e.agent.name?.trim())throw new Error("Agent name is required.");let r=ft(e.agent.triggerWords);if(r.length===0)throw new Error("At least one trigger word is required.");if(e.agent.tier!=="claude-code"&&e.agent.tier!=="codex-cli"&&e.agent.tier!=="opencode"&&e.agent.tier!=="sdk"&&e.agent.tier!=="orchestrator")throw new Error("AI engine must be claude-code, codex-cli, opencode, sdk, or orchestrator.");let n=M(a,"agentx.json"),o=M(a,".env"),i=M(a,"agents",e.agent.id),s=ca(a);ct(i,{recursive:!0});let d=M(i,"CLAUDE.md");if(!K(d)){let g=e.agent.personality?.trim()||`You are ${e.agent.name}, an assistant on the ${e.nodeName} team.`;la(d,`# ${e.agent.name}
2209
+ </script>`;ce();function pa(e=process.cwd()){let a=M(e,"agentx.json");if(!K(a))return{configExists:!1,agentCount:0,channelCount:0};try{let t=JSON.parse(la(a,"utf-8")),r=t.agents?Object.keys(t.agents).length:0,n=t.channels?Object.values(t.channels).filter(o=>o&&o.enabled).length:0;return{configExists:!0,agentCount:r,channelCount:n,nodeName:t.node?.name}}catch{return{configExists:!1,agentCount:0,channelCount:0}}}function ft(e,a=process.cwd(),t={}){if(!e.nodeName?.trim())throw new Error("Team name is required.");if(!e.agent?.id?.trim())throw new Error("Agent id is required.");if(!/^[a-z0-9][a-z0-9_-]*$/.test(e.agent.id))throw new Error("Agent id must be lowercase (letters, digits, -, _) and start with a letter or digit.");if(!e.agent.name?.trim())throw new Error("Agent name is required.");let r=ht(e.agent.triggerWords);if(r.length===0)throw new Error("At least one trigger word is required.");if(e.agent.tier!=="claude-code"&&e.agent.tier!=="codex-cli"&&e.agent.tier!=="opencode"&&e.agent.tier!=="sdk"&&e.agent.tier!=="orchestrator")throw new Error("AI engine must be claude-code, codex-cli, opencode, sdk, or orchestrator.");let n=M(a,"agentx.json"),o=M(a,".env"),i=M(a,"agents",e.agent.id),s=pa(a);pt(i,{recursive:!0});let d=M(i,"CLAUDE.md");if(!K(d)){let g=e.agent.personality?.trim()||`You are ${e.agent.name}, an assistant on the ${e.nodeName} team.`;ca(d,`# ${e.agent.name}
2210
2210
 
2211
2211
  ${g}
2212
- `)}let l=e.telegram?`TG_${e.agent.id.toUpperCase()}_BOT_TOKEN`:void 0,c;if(s.configExists)c=Q(u=>{if(u.node=u.node||{},u.node.name||(u.node.name=e.nodeName),u.node.id||(u.node.id=pa(e.nodeName)||"team"),u.node.bind||(u.node.bind="127.0.0.1:18800"),u.node.defaultAgent=u.node.defaultAgent||e.agent.id,u.providers=u.providers||{},u.providers.claude||(u.providers.claude={apiKey:"${ANTHROPIC_API_KEY}"}),u.agents=u.agents||{},u.agents[e.agent.id])throw new Error(`Agent "${e.agent.id}" already exists.`);return u.agents[e.agent.id]=xa(e,i,r),e.telegram&&(u.channels=u.channels||{},u.channels.telegram=u.channels.telegram||{enabled:!0,accounts:{},policy:{dm:"pair",group:"mention-required"}},u.channels.telegram.enabled=!0,u.channels.telegram.accounts=u.channels.telegram.accounts||{},u.channels.telegram.accounts[e.telegram.accountId]=ga(e,l)),{summary:`added agent "${e.agent.id}"`+(e.telegram?" + telegram account":"")}},{configPath:n}).backupPath;else{let g=ht(e,i,r,l,t);Ke(g,{configPath:n})}bt(o,e,l);let m=[];return(e.anthropicApiKey||!K(M(a,".env")))&&m.push("Double-check the API keys in .env"),e.agent.tier==="claude-code"&&m.push("Run claude --version to confirm Claude Code is installed (needed for the claude-code engine)"),e.agent.tier==="codex-cli"&&m.push("Run codex --version to confirm Codex CLI is installed (needed for the codex-cli engine)"),e.agent.tier==="opencode"&&m.push("Run opencode --version to confirm OpenCode is installed and authenticated"),m.push("Start the daemon: agentx daemon start"),m.push("Open the dashboard: http://127.0.0.1:4202"),{summary:s.configExists?`Added agent "${e.agent.id}" to your team.`:`Initialized your team with first agent "${e.agent.id}".`,nextSteps:m,backupPath:c}}function ft(e){return(e||"").split(/[,\s]+/).map(a=>a.trim()).filter(Boolean).filter((a,t,r)=>r.indexOf(a)===t)}function pa(e){return(e||"").toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"")}function ht(e,a,t,r,n={}){let o=pa(e.nodeName)||"team",i=n.daemonPort??18800,s={node:{id:o,name:e.nodeName,bind:`127.0.0.1:${i}`,defaultAgent:e.agent.id},providers:{claude:{apiKey:"${ANTHROPIC_API_KEY}"}},agents:{[e.agent.id]:xa(e,a,t)},channels:{},crons:{},mesh:{enabled:!1,peers:[],discovery:"static",healthCheck:{interval:60,timeout:10}},dashboard:{enabled:!0,port:n.dashboardPort??4202,bind:"127.0.0.1",daemonUrl:`http://localhost:${i}`},boards:[]};return e.telegram&&r?s.channels.telegram={enabled:!0,accounts:{[e.telegram.accountId]:ga(e,r)},policy:{dm:"pair",group:"mention-required"}}:s.channels.telegram={enabled:!1,accounts:{},policy:{dm:"pair",group:"mention-required"}},s}function xa(e,a,t){let r={name:e.agent.name,workspace:a,tier:e.agent.tier,mentions:t,maxConcurrent:2,permissionMode:"default"};return e.agent.model&&(r.model=e.agent.model),e.agent.provider&&(r.provider=e.agent.provider),e.agent.personality?.trim()&&(r.systemPrompt=e.agent.personality.trim().slice(0,400)),r}function ga(e,a){return e.telegram?.botUsername,{token:"${"+a+"}",agentBinding:e.agent.id}}function bt(e,a,t){let r=K(e)?da(e,"utf-8"):"",n=[];if(a.anthropicApiKey&&!r.includes("ANTHROPIC_API_KEY=")&&n.push(`ANTHROPIC_API_KEY=${a.anthropicApiKey}`),a.telegram&&t&&!r.includes(`${t}=`)&&n.push(`${t}=${a.telegram.botToken}`),!K(e)){la(e,[...["# AgentX environment variables","# (Never commit this file \u2014 it contains secrets.)",""],...n,""].join(`
2212
+ `)}let l=e.telegram?`TG_${e.agent.id.toUpperCase()}_BOT_TOKEN`:void 0,c;if(s.configExists)c=Q(u=>{if(u.node=u.node||{},u.node.name||(u.node.name=e.nodeName),u.node.id||(u.node.id=xa(e.nodeName)||"team"),u.node.bind||(u.node.bind="127.0.0.1:18800"),u.node.defaultAgent=u.node.defaultAgent||e.agent.id,u.providers=u.providers||{},u.providers.claude||(u.providers.claude={apiKey:"${ANTHROPIC_API_KEY}"}),u.agents=u.agents||{},u.agents[e.agent.id])throw new Error(`Agent "${e.agent.id}" already exists.`);return u.agents[e.agent.id]=ga(e,i,r),e.telegram&&(u.channels=u.channels||{},u.channels.telegram=u.channels.telegram||{enabled:!0,accounts:{},policy:{dm:"pair",group:"mention-required"}},u.channels.telegram.enabled=!0,u.channels.telegram.accounts=u.channels.telegram.accounts||{},u.channels.telegram.accounts[e.telegram.accountId]=ua(e,l)),{summary:`added agent "${e.agent.id}"`+(e.telegram?" + telegram account":"")}},{configPath:n}).backupPath;else{let g=bt(e,i,r,l,t);Ye(g,{configPath:n})}vt(o,e,l);let m=[];return(e.anthropicApiKey||!K(M(a,".env")))&&m.push("Double-check the API keys in .env"),e.agent.tier==="claude-code"&&m.push("Run claude --version to confirm Claude Code is installed (needed for the claude-code engine)"),e.agent.tier==="codex-cli"&&m.push("Run codex --version to confirm Codex CLI is installed (needed for the codex-cli engine)"),e.agent.tier==="opencode"&&m.push("Run opencode --version to confirm OpenCode is installed and authenticated"),m.push("Start the daemon: agentx daemon start"),m.push("Open the dashboard: http://127.0.0.1:4202"),{summary:s.configExists?`Added agent "${e.agent.id}" to your team.`:`Initialized your team with first agent "${e.agent.id}".`,nextSteps:m,backupPath:c}}function ht(e){return(e||"").split(/[,\s]+/).map(a=>a.trim()).filter(Boolean).filter((a,t,r)=>r.indexOf(a)===t)}function xa(e){return(e||"").toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"")}function bt(e,a,t,r,n={}){let o=xa(e.nodeName)||"team",i=n.daemonPort??18800,s={node:{id:o,name:e.nodeName,bind:`127.0.0.1:${i}`,defaultAgent:e.agent.id},providers:{claude:{apiKey:"${ANTHROPIC_API_KEY}"}},agents:{[e.agent.id]:ga(e,a,t)},channels:{},crons:{},mesh:{enabled:!1,peers:[],discovery:"static",healthCheck:{interval:60,timeout:10}},dashboard:{enabled:!0,port:n.dashboardPort??4202,bind:"127.0.0.1",daemonUrl:`http://localhost:${i}`},boards:[]};return e.telegram&&r?s.channels.telegram={enabled:!0,accounts:{[e.telegram.accountId]:ua(e,r)},policy:{dm:"pair",group:"mention-required"}}:s.channels.telegram={enabled:!1,accounts:{},policy:{dm:"pair",group:"mention-required"}},s}function ga(e,a,t){let r={name:e.agent.name,workspace:a,tier:e.agent.tier,mentions:t,maxConcurrent:2,permissionMode:"default"};return e.agent.model&&(r.model=e.agent.model),e.agent.provider&&(r.provider=e.agent.provider),e.agent.personality?.trim()&&(r.systemPrompt=e.agent.personality.trim().slice(0,400)),r}function ua(e,a){return e.telegram?.botUsername,{token:"${"+a+"}",agentBinding:e.agent.id}}function vt(e,a,t){let r=K(e)?la(e,"utf-8"):"",n=[];if(a.anthropicApiKey&&!r.includes("ANTHROPIC_API_KEY=")&&n.push(`ANTHROPIC_API_KEY=${a.anthropicApiKey}`),a.telegram&&t&&!r.includes(`${t}=`)&&n.push(`${t}=${a.telegram.botToken}`),!K(e)){ca(e,[...["# AgentX environment variables","# (Never commit this file \u2014 it contains secrets.)",""],...n,""].join(`
2213
2213
  `),{mode:384});return}if(n.length>0){let o=r.endsWith(`
2214
2214
  `)?"":`
2215
- `;lt(e,o+n.join(`
2215
+ `;ct(e,o+n.join(`
2216
2216
  `)+`
2217
- `)}}function yn(e,a){let t=ca(),r=t.nodeName||gt().replace(/\.local$/,""),n=ia(t,r);a.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),a.end(n)}async function kn(e,a){let t="";await new Promise(n=>{e.on("data",o=>{t+=o}),e.on("end",()=>n())});let r;try{r=JSON.parse(t)}catch{a.writeHead(400,{"Content-Type":"application/json"}),a.end(JSON.stringify({error:"Invalid JSON"}));return}try{let n=mt(r);a.writeHead(200,{"Content-Type":"application/json"}),a.end(JSON.stringify(n))}catch(n){a.writeHead(400,{"Content-Type":"application/json"}),a.end(JSON.stringify({error:n.message||"wizard failed"}))}}async function _n(e,a){a.setHeader("Content-Type","application/json");let t;try{t=ze().node?.bind||"127.0.0.1:18800"}catch(i){a.writeHead(400),a.end(JSON.stringify({ok:!1,error:`Config validation failed: ${i.message}`}));return}let r=`http://${t.replace(/^0\.0\.0\.0/,"127.0.0.1")}`;if(await sa(r)){a.writeHead(200),a.end(JSON.stringify({ok:!0,url:r,alreadyRunning:!0}));return}let n=process.argv[1]||M(pt(xt(import.meta.url)),"cli.js");try{ut(process.execPath,[n,"daemon","start"],{detached:!0,stdio:"ignore",cwd:process.cwd()}).unref()}catch(i){a.writeHead(500),a.end(JSON.stringify({ok:!1,error:`Failed to spawn daemon: ${i.message}`,manualUrl:r}));return}let o=Date.now()+12e3;for(;Date.now()<o;)if(await new Promise(i=>setTimeout(i,400)),await sa(r)){a.writeHead(200),a.end(JSON.stringify({ok:!0,url:r,alreadyRunning:!1}));return}a.writeHead(504),a.end(JSON.stringify({ok:!1,error:"Daemon spawn succeeded but never bound the port within 12s \u2014 check `agentx daemon status` and the dotfile log for errors.",manualUrl:r}))}async function sa(e){try{let a=await fetch(e,{method:"GET",signal:AbortSignal.timeout(800)});return a.status>0&&a.status<600}catch{return!1}}import{mkdirSync as vt,readFileSync as wt,renameSync as yt,writeFileSync as kt}from"fs";import{dirname as _t,isAbsolute as $t,resolve as St}from"path";import{createHash as At,randomBytes as Ct}from"crypto";var zn=".agentx/app-pins.json",Pn=12,ua=40,ma=2e3,Tt=/^pin_[a-z0-9]{6,32}$/;function It(e,a){return $t(a)?a:St(e,a)}function ae(e){let a=typeof e=="string"?e.trim().replace(/\s+/g," "):"";return a?/[\p{Cc}\p{Cf}]/u.test(a)?{ok:!1,error:"Use only letters, numbers, spaces and punctuation in the name."}:[...a].length>ua?{ok:!1,error:`Keep the name under ${ua} characters.`}:{ok:!0,value:a}:{ok:!1,error:"Give the button a name."}}function we(e){let a=typeof e=="string"?e.trim():"";if(!a)return{ok:!1,error:"Give the page's address."};if(a.length>ma)return{ok:!1,error:`Keep the address under ${ma} characters.`};let t;try{t=new URL(a)}catch{return{ok:!1,error:"That is not a web address. It should start with https://"}}return t.protocol!=="https:"||!t.hostname?{ok:!1,error:"Only https:// pages can be pinned."}:t.username||t.password?{ok:!1,error:"Leave the user name and password out of the address."}:{ok:!0,value:t.href}}function zt(e){return`cfg_${At("sha256").update(e).digest("hex").slice(0,12)}`}function Pt(e){let a=[];for(let t of e){let r=ae(t.label),n=we(t.url);!r.ok||!n.ok||a.some(o=>o.url===n.value||o.label.toLowerCase()===r.value.toLowerCase())||a.push({id:zt(n.value),label:r.value,url:n.value,source:"config"})}return a}var fa="This button is set in agentx.json (app.pins.pages). Change or remove it there.";function Et(e){let a=ae(e.label);if(!a.ok)return a;let t=we(e.url);return t.ok?{ok:!0,value:{label:a.value,url:t.value}}:t}var ve=class{constructor(a,t=Date.now,r=[]){this.path=a;this.now=t;this.fixed=r}list(){return[...this.fixed,...this.load().pins.filter(a=>!this.shadowed(a))]}shadowed(a){return this.fixed.some(t=>t.url===a.url||t.label.toLowerCase()===a.label.toLowerCase())}isFixed(a){return this.fixed.some(t=>t.id===a)}load(){let a;try{a=wt(this.path,"utf-8")}catch(o){return{pins:[],damaged:o?.code!=="ENOENT"}}let t;try{t=JSON.parse(a)}catch{return{pins:[],damaged:!0}}let r=Array.isArray(t?.pins)?t.pins:[],n=r.filter(o=>{let i=o;return!!i&&typeof i.id=="string"&&Tt.test(i.id)&&ae(i.label).ok&&we(i.url).ok});return{pins:n,damaged:!Array.isArray(t?.pins)||n.length!==r.length}}locked(a){try{return Re(this.path,a,{what:"The pinned pages file"})}catch(t){if(t instanceof Ee)return{ok:!1,status:409,error:t.message};throw t}}editable(){let{pins:a,damaged:t}=this.load();return t?{ok:!1,status:409,error:`The pinned pages file (${this.path}) can't be read. Fix or remove it on the computer, then try again.`}:{ok:!0,pins:a}}write(a){vt(_t(this.path),{recursive:!0});let t=`${this.path}.${process.pid}.tmp`;kt(t,JSON.stringify({pins:a},null,2)+`
2218
- `,{mode:384}),yt(t,this.path)}add(a,t){return this.locked(()=>this.addUnlocked(a,t))}addUnlocked(a,t){let r=this.editable();if(!r.ok)return r;let n=r.pins;if(n.filter(i=>!this.shadowed(i)).length+this.fixed.length>=t)return{ok:!1,status:409,error:`You already have ${t} pinned pages, the most allowed (app.pins.max). Remove one first.`};if([...this.fixed,...n].some(i=>i.label.toLowerCase()===a.label.toLowerCase()))return{ok:!1,status:409,error:`You already have a button called ${a.label}.`};if(this.fixed.some(i=>i.url===a.url))return{ok:!1,status:409,error:"This page is already a button, set in agentx.json (app.pins.pages)."};let o={id:`pin_${Ct(6).toString("hex")}`,...a,createdAt:new Date(this.now()).toISOString()};return n.push(o),this.write(n),{ok:!0,pin:o}}rename(a,t){return this.locked(()=>this.renameUnlocked(a,t))}renameUnlocked(a,t){if(this.isFixed(a))return{ok:!1,status:409,error:fa};let r=this.editable();if(!r.ok)return r;let n=r.pins,o=n.find(i=>i.id===a);return o?[...this.fixed,...n].some(i=>i.id!==a&&i.label.toLowerCase()===t.toLowerCase())?{ok:!1,status:409,error:`You already have a button called ${t}.`}:(o.label=t,this.write(n),{ok:!0,pin:o}):{ok:!1,status:404,error:"No such pinned page."}}remove(a){return this.locked(()=>this.removeUnlocked(a))}removeUnlocked(a){if(this.isFixed(a))return{ok:!1,status:409,error:fa};let t=this.editable();if(!t.ok)return t;let r=t.pins.filter(n=>n.id!==a);return r.length===t.pins.length?{ok:!1,status:404,error:"No such pinned page."}:(this.write(r),{ok:!0})}};function En(e,a){let t=e.app.pins;return{store:new ve(It(a,t.file),Date.now,Pt(t.pages)),max:t.max}}async function Rn(e,a,t,r,n){if(t!=="/api/app/pins"&&!t.startsWith("/api/app/pins/"))return!1;let o=t.slice(13);if(r==="GET"&&o==="")return P(a,200,{pins:n.store.list(),max:n.max});if(r!=="POST")return P(a,404,{error:"not found"});let i;try{i=await V(e,4096)}catch(d){return P(a,400,{error:d.message})}let s=typeof i.id=="string"?i.id:"";if(o==="/add"){let d=Et(i);if(!d.ok)return P(a,400,{error:d.error});let l=n.store.add(d.value,n.max);return l.ok?P(a,200,{ok:!0,pin:l.pin}):P(a,l.status,{error:l.error})}if(o==="/rename"){let d=ae(i.label);if(!d.ok)return P(a,400,{error:d.error});let l=n.store.rename(s,d.value);return l.ok?P(a,200,{ok:!0,pin:l.pin}):P(a,l.status,{error:l.error})}if(o==="/remove"){let d=n.store.remove(s);return d.ok?P(a,200,{ok:!0}):P(a,d.status,{error:d.error})}return P(a,404,{error:"not found"})}function P(e,a,t){return e.writeHead(a,{"Content-Type":"application/json","Cache-Control":"no-store"}),e.end(JSON.stringify(t)),!0}import{existsSync as ha,readFileSync as ba}from"fs";ce();function Rt(e){let a=q(e),t={};if(ha(a))try{t=F(JSON.parse(ba(a,"utf-8")))}catch{t={}}let r=le.safeParse(t?.approvals);return r.success?r.data:le.parse(void 0)}function Nn(e){let a=q(e),t={};if(ha(a))try{t=F(JSON.parse(ba(a,"utf-8")))}catch{t={}}return Le({desk:t?.notifications?.desk,popupEnabled:!!Rt(e).popup?.enabled})}function Ln(e){let a=e.indexOf(":");return a<=0||a===e.length-1?null:{channel:e.slice(0,a).trim(),chatId:e.slice(a+1).trim()}}async function Wn(e,a={}){return J(t=>{let r=t.approvals??={};if(e.defaultExpiryDays!==void 0&&(r.defaultExpiryDays=e.defaultExpiryDays),e.maxExpiryDays!==void 0&&(r.maxExpiryDays=e.maxExpiryDays),e.laterHours!==void 0&&(r.laterHours=e.laterHours),e.notifyAgent!==void 0&&(r.notifyAgent=e.notifyAgent),e.forwardTo===null)delete r.forwardTo;else if(e.forwardTo!==void 0){let l=Array.isArray(t.mesh?.peers)?t.mesh.peers:[];if(!l.some(c=>c.name===e.forwardTo))throw new Error(`"${e.forwardTo}" is not in mesh.peers${l.length?` (known: ${l.map(c=>c.name).join(", ")})`:""}; pair the machines first`);r.forwardTo=e.forwardTo}let n=r.digest??={};e.digestEnabled!==void 0&&(n.enabled=e.digestEnabled),e.digestTime!==void 0&&(n.time=e.digestTime),e.digestTimezone===null?delete n.timezone:e.digestTimezone!==void 0&&(n.timezone=e.digestTimezone),e.destination===null?delete n.destination:e.destination!==void 0&&(n.destination=e.destination);let o=r.popup??={};e.popupEnabled!==void 0&&(o.enabled=e.popupEnabled),e.popupSpeak!==void 0&&(o.speak=e.popupSpeak),e.popupVoice===null?delete o.voice:e.popupVoice!==void 0&&(o.voice=e.popupVoice),e.popupSound!==void 0&&(o.sound=e.popupSound),e.popupTimeoutSeconds!==void 0&&(o.timeoutSeconds=e.popupTimeoutSeconds),e.popupStyle!==void 0&&(o.style=e.popupStyle),e.popupTheme!==void 0&&(o.theme=e.popupTheme);let i=r.checkin??={};if(e.checkinEnabled!==void 0&&(i.enabled=e.checkinEnabled),e.checkinTimes!==void 0&&(i.times=e.checkinTimes),e.checkinDailyAt!==void 0&&(i.dailyAt=e.checkinDailyAt),e.checkinLists!==void 0&&(i.lists=e.checkinLists),e.checkinAgent===null?delete i.agent:e.checkinAgent!==void 0&&(i.agent=e.checkinAgent),e.deskPhone!==void 0||e.deskComputer!==void 0){let l=(t.notifications??={}).desk??={};e.deskPhone!==void 0&&(l.phone=e.deskPhone),e.deskComputer!==void 0&&(l.computer=e.deskComputer)}let s=r.defaultExpiryDays??3,d=r.maxExpiryDays??30;if(s>d)throw new Error(`defaultExpiryDays (${s}) can't be more than maxExpiryDays (${d})`)},{configPath:a.configPath,reload:a.reload})}import{createServer as Lt}from"http";var te=class{peers;cache=new Map;ttl=3e4;constructor(a){this.peers=a.map(t=>({...t,url:t.url.replace(/\/$/,"")}))}async getRemoteAgents(){let a=[];return await Promise.all(this.peers.map(async t=>{try{let r=await this.fetchJson(`${t.url}/wiki/agents`);t.nodeId=r.nodeId;for(let n of r.agents||[])(n.totalEntries>0||n.totalArticles>0)&&a.push({...n,nodeId:r.nodeId,peerUrl:t.url})}catch{}})),a}async getRemoteArticles(a,t){try{return(await this.fetchJson(`${a}/wiki/articles?agent=${encodeURIComponent(t)}`)).articles||[]}catch{return[]}}async getRemoteArticle(a,t,r){try{let n=await this.fetchJson(`${a}/wiki/article?agent=${encodeURIComponent(t)}&path=${encodeURIComponent(r)}`);return{meta:{title:n.title,tags:n.tags||[],owner:n.owner,access:"public",created:n.created,lastUpdated:n.lastUpdated,sources:n.sources||[]},content:n.content,path:n.path}}catch{return null}}async fetchJson(a){let t=this.cache.get(a);if(t&&Date.now()-t.ts<this.ttl)return t.data;let r=this.peers.find(i=>a.startsWith(`${i.url}/`))?.token,n=await fetch(a,{headers:r?{Authorization:`Bearer ${r}`}:{},signal:AbortSignal.timeout(5e3)});if(!n.ok)throw new Error(`HTTP ${n.status}`);let o=await n.json();return this.cache.set(a,{data:o,ts:Date.now()}),o}};var va=864e5;function ye(e){let a=new Map;for(let t of e.entities.values()){let r=a.get(t.type)??[];r.push(t),a.set(t.type,r)}return a}function ke(e,a){if(a.type==="event")return a.date||a.updated;let t=Ge(e,a,new Set(["event"]))[0],r=a.updated||a.date;return t&&t.date>r?t.date:r}function wa(e,a,t=Date.now()){let r=[],n=new Date(t+14*va).toISOString().slice(0,10),o=new Date(t).toISOString().slice(0,10);for(let s of a){let d=s.statements.find(c=>c.property==="due"&&/^\d{4}-\d{2}-\d{2}/.test(c.value)),l=s.statements.some(c=>c.property==="fulfilled_by")||s.statements.some(c=>c.property==="status"&&/^(fulfilled|done|paid|filed)$/i.test(c.value));s.statements.some(c=>c.property==="status"&&/^late$/i.test(c.value))?r.push({e:s,chip:"late",why:"marked late"}):d&&!l&&d.value<o?r.push({e:s,chip:"late",why:`was due ${d.value}`}):d&&!l&&d.value<=n?r.push({e:s,chip:"due",why:`due ${d.value}`}):s.statements.some(c=>c.status==="proposed")?r.push({e:s,chip:"proposed",why:"statements wait for confirmation"}):s.type==="event"&&s.importanceProposed&&s.importanceProposed!==s.importance?r.push({e:s,chip:"proposed",why:`proposed as ${s.importanceProposed}; the owner decides`}):s.type==="event"&&s.importance==="major"&&s.date&&t-Date.parse(s.date)<=30*va&&r.push({e:s,chip:"major",why:`major event ${s.date}`})}let i={late:0,due:1,major:2,proposed:3};return r.sort((s,d)=>i[s.chip]-i[d.chip])}function re(e,a,t="",r){return`<div class="ox-row"><span class="ox-ic">${Xe(e.ontology,a.type)}</span><div class="t"><a href="${ue(a.id)}">${k(a.title)}</a><div class="ox-sub">${k(r??`${ge(e.ontology,a.type).toLowerCase()} \xB7 ${ke(e,a)}`)}</div></div><div class="r">${t}</div></div>`}function ya(e,a){let t=a.slice(0,6).map(r=>re(e,r.e,`<span class="ox-st ${r.chip}">${r.chip}</span>`,r.why)).join("");return`<section class="ox-card"><div class="ox-card-h"><h2>Needs attention</h2><span class="note">${a.length}</span></div>${t||'<div class="ox-empty">Nothing waits on a person.</div>'}</section>`}function Ot(e){return e.length?`<div class="ox-err"><b>ontology.yaml has ${e.length} problem${e.length===1?"":"s"}</b> \u2014 the defaults are used where they apply. <a href="/ontology">See them</a></div>`:""}function ka(e,a){let t=ye(e),r=`<div class="ox-bar">${j([])}</div>`;r+=`<div class="ox-head"><div class="ox-avatar">${D("home")}</div><div><h1>Wiki</h1><p>${e.entities.size} things, merged from every agent's pages and typed by the <a href="/ontology">ontology</a>. <a href="/agents">Agent wikis</a> \xB7 <a href="/entries">raw entries</a></p></div></div>`,r+=Ot(a),r+='<div class="ox-grid3">';for(let o of e.ontology.pillars){let i=e.ontology.types.filter(l=>l.pillar===o.id),s=i.reduce((l,c)=>l+(t.get(c.id)?.length??0),0),d=i.filter(l=>t.get(l.id)?.length).map(l=>`${l.plural??l.label} ${t.get(l.id).length}`).join(" \xB7 ");r+=`<a class="ox-card" href="/p/${encodeURIComponent(o.id)}" style="color:inherit"><div class="ox-card-h"><span class="ox-ic">${D(o.icon)}</span><h2>${k(o.label)}</h2><span class="zin">${s}</span></div><div class="ox-sub" style="white-space:normal">${k(o.description??"")}</div><div class="ox-sub" style="margin-top:6px;white-space:normal">${k(d||"nothing yet")}</div></a>`}r+='</div><div class="ox-grid2">';let n=(t.get("event")??[]).filter(o=>o.importance!=="minor").sort((o,i)=>i.date.localeCompare(o.date)).slice(0,8);return r+='<section class="ox-card"><div class="ox-card-h"><h2>Recent events</h2><span class="note">major and normal</span><a class="zin" href="/p/events">all (Z1) \u2192</a></div>'+(n.map(o=>`<div class="ox-ev"><span class="d">${k(o.date)}</span><span class="ox-st ${o.importance}">${o.importance}</span><a href="${ue(o.id)}">${k(o.title)}</a></div>`).join("")||'<div class="ox-empty">No events yet.</div>')+"</section>",r+=ya(e,wa(e,[...e.entities.values()])),r+="</div>",L("Wiki",N(e,{home:!0}),r)}function _a(e,a,t){let r=e.ontology.pillars.find(c=>c.id===a);if(!r)return null;let n=ye(e),o=e.ontology.types.filter(c=>c.pillar===r.id),i=o.find(c=>c.id===t)??o.find(c=>n.get(c.id)?.length)??o[0],s=`<div class="ox-bar">${j([{label:r.label}])}${me(1)}</div>`;s+=`<div class="ox-head"><div class="ox-avatar">${D(r.icon)}</div><div><h1>${k(r.label)}</h1><p>${k(r.description??"")}</p></div></div>`,s+=`<nav class="ox-tabs">${o.map(c=>`<a class="${c.id===i?.id?"on":""}" href="/p/${encodeURIComponent(r.id)}?kind=${encodeURIComponent(c.id)}">${k(c.plural??c.label)}<small>${n.get(c.id)?.length??0}</small></a>`).join("")}</nav>`;let d=i?(n.get(i.id)??[]).map(c=>({e:c,at:ke(e,c)})).sort((c,m)=>m.at.localeCompare(c.at)):[];s+='<div class="ox-grid2">',s+=`<section class="ox-card"><div class="ox-card-h"><h2>${k(i?.plural??i?.label??"")}</h2><span class="note">${d.length} \xB7 most active first</span>`+(i?`<a class="zin" href="/p/${encodeURIComponent(r.id)}/${encodeURIComponent(i.id)}">open list (Z3) \u2192</a>`:"")+"</div>"+(d.slice(0,5).map(({e:c,at:m})=>re(e,c,c.type==="event"?`<span class="ox-st ${c.importance}">${c.importance}</span>`:"",`${Ve(c,90)||ge(e.ontology,c.type).toLowerCase()} \xB7 ${m}`)).join("")||`<div class="ox-empty">No ${k((i?.plural??"pages").toLowerCase())} yet.</div>`)+"</section>";let l=o.flatMap(c=>n.get(c.id)??[]);return s+=ya(e,wa(e,l)),s+="</div>",L(r.label,N(e,{pillar:r.id}),s)}function $a(e,a,t,r,n){let o=n&&Oe.includes(n)?n:null,i=e.ontology.pillars.find(x=>x.id===a),s=e.ontology.types.find(x=>x.id===t&&x.pillar===a);if(!i||!s)return null;let d=[...e.entities.values()].filter(x=>x.type===s.id);o&&(d=d.filter(x=>x.importance===o));let l=d.map(x=>({e:x,at:ke(e,x)})).sort((x,f)=>f.at.localeCompare(x.at)),c=50,m=Math.max(1,Math.ceil(l.length/c)),g=`/p/${encodeURIComponent(i.id)}/${encodeURIComponent(s.id)}`,u=`<div class="ox-bar">${j([{label:i.label,href:`/p/${encodeURIComponent(i.id)}`},{label:s.plural??s.label}])}${me(3)}</div>`;if(u+=`<div class="ox-head"><div class="ox-avatar">${D(s.icon)}</div><div><h1>${k(s.plural??s.label)}</h1><p>${l.length} page${l.length===1?"":"s"}${o?` \xB7 ${k(o)} only`:""}</p></div></div>`,s.id==="event"&&(u+=`<nav class="ox-tabs">${["","major","normal","minor"].map(x=>`<a class="${(o??"")===x?"on":""}" href="${g}${x?`?importance=${x}`:""}">${x||"all"}</a>`).join("")}</nav>`),u+='<section class="ox-card" style="margin-top:16px">'+(l.slice((r-1)*c,r*c).map(({e:x,at:f})=>re(e,x,x.type==="event"?`<span class="ox-st ${x.importance}">${x.importance}</span>`:"",`${f} \xB7 ${x.pages.map(C=>C.agentId).filter((C,w,v)=>v.indexOf(C)===w).join(", ")}`)).join("")||'<div class="ox-empty">None.</div>')+"</section>",m>1){let x=o?`importance=${o}&`:"";u+=`<div class="ox-pager">${r>1?`<a href="${g}?${x}page=${r-1}">\u2190 previous</a>`:""}<span>page ${r} of ${m}</span>${r<m?`<a href="${g}?${x}page=${r+1}">next \u2192</a>`:""}</div>`}return L(s.plural??s.label,N(e,{pillar:i.id}),u)}function Sa(e,a){let t=a.trim().toLowerCase(),r=[];if(t)for(let o of e.entities.values()){let i=o.title.toLowerCase(),s=i===t?100:i.startsWith(t)?60:i.includes(t)?40:0;!s&&o.pages.some(d=>d.article.content.toLowerCase().includes(t))&&(s=10),s&&r.push({e:o,s})}r.sort((o,i)=>i.s-o.s||i.e.updated.localeCompare(o.e.updated));let n=`<div class="ox-bar">${j([{label:"Search"}])}</div>`;return n+=`<div class="ox-head"><div class="ox-avatar">${D("search")}</div><div><h1>${t?`\u201C${k(a)}\u201D`:"Search"}</h1><p>${r.length} match${r.length===1?"":"es"}</p></div></div>`,n+=`<section class="ox-card">${r.slice(0,60).map(({e:o})=>re(e,o)).join("")||'<div class="ox-empty">No page matches.</div>'}</section>`,L(`Search: ${a}`,N(e,{}),n,"",a)}function Aa(e,a,t){let r=e.ontology,n=ye(e),o=`<div class="ox-bar">${j([{label:"Ontology"}])}</div>`;o+=`<div class="ox-head"><div class="ox-avatar">${D("steps")}</div><div><h1>Ontology</h1><p>${t?`Read from ${k(t)}`:"Built-in defaults. Run <code>agentx wiki ontology init</code> to write an ontology.yaml you can edit."}</p></div></div>`,a.length&&(o+=`<div class="ox-err"><b>Problems</b><ul>${a.map(i=>`<li>${k(i)}</li>`).join("")}</ul></div>`),o+=`<section class="ox-card"><div class="ox-card-h"><h2>Types</h2><span class="note">${r.types.length}</span></div>`;for(let i of r.types){let s=r.pillars.find(d=>d.id===i.pillar);o+=`<div class="ox-row"><span class="ox-ic">${D(i.icon)}</span><div class="t"><span class="l">${k(i.label)} <span class="ox-sub">${k(i.id)}</span></span><div class="ox-sub">${k(s?.label??i.pillar)} \xB7 lens: ${k((i.lens??[]).map(d=>d.title??d.panel).join(" \u2192 "))}</div></div><div class="r"><span class="ox-chip">${n.get(i.id)?.length??0}</span></div></div>`}o+=`</section><section class="ox-card" style="margin-top:16px"><div class="ox-card-h"><h2>Relations</h2><span class="note">${r.properties.length}</span></div>`;for(let i of r.properties)o+=`<div class="ox-kv"><span class="k">${k(i.id)}</span><span>${k(i.label)}${i.inverse?` \xB7 inverse: ${k(i.inverse)}`:""}${i.wikidata?` <span class="ox-sub">${k(i.wikidata)}</span>`:""}</span></div>`;return o+=`</section><section class="ox-card" style="margin-top:16px"><div class="ox-card-h"><h2>Event importance</h2></div><div class="ox-kv"><span class="k">default</span><span>${k(r.importance.default)}</span></div><div class="ox-kv"><span class="k">major set by</span><span>${k(r.importance.major_set_by)}</span></div><div class="ox-kv"><span class="k">roll-up</span><span>${r.importance.rollup.min} minor events in ${r.importance.rollup.days} days</span></div></section>`,L("Ontology",N(e,{}),o)}var ne=class{constructor(a,t){this.hub=a;this.wikiDir=t}cache=new Je;pageAt(a){if(!a.startsWith("/e/"))return null;let{ontology:t}=xe(this.wikiDir),n=this.cache.get(this.hub,t).entities.get(a.split("/").filter(Boolean)[1]??"")?.pages[0];return n?{agentId:n.agentId,path:n.article.path,title:n.article.meta.title}:null}handle(a,t){if(!(a==="/"||a===""||a.startsWith("/p/")||a.startsWith("/e/")||a==="/find"||a==="/ontology"))return null;let{ontology:r,errors:n,file:o}=xe(this.wikiDir),i=Ye(this.wikiDir,this.hub.listAgents([]),r.agent_names),s=this.cache.get(this.hub,r,i),d=Math.max(1,Number(t.get("page"))||1);if(a==="/"||a==="")return ka(s,n);if(a==="/find")return Sa(s,t.get("q")??"");if(a==="/ontology")return Aa(s,n,o);let l=a.split("/").filter(Boolean);if(l[0]==="p")return l.length===2?_a(s,l[1],t.get("kind")):l.length===3?$a(s,l[1],l[2],d,t.get("importance")):null;let c=s.entities.get(l[1]??"");if(!c)return null;let m={g:s,readEntries:g=>this.hub.getSharedStore().readEntries(g),versions:(g,u)=>this.hub.getAgentWiki(g).getVersions(u)};return l.length===2?Qe(m,c):l.length===3?Ze(m,c,l[2],d):l.length===4&&l[2]==="s"?ea(m,c,Number(l[3])):null}};var Dt=`
2217
+ `)}}function _n(e,a){let t=pa(),r=t.nodeName||ut().replace(/\.local$/,""),n=sa(t,r);a.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),a.end(n)}async function $n(e,a){let t="";await new Promise(n=>{e.on("data",o=>{t+=o}),e.on("end",()=>n())});let r;try{r=JSON.parse(t)}catch{a.writeHead(400,{"Content-Type":"application/json"}),a.end(JSON.stringify({error:"Invalid JSON"}));return}try{let n=ft(r);a.writeHead(200,{"Content-Type":"application/json"}),a.end(JSON.stringify(n))}catch(n){a.writeHead(400,{"Content-Type":"application/json"}),a.end(JSON.stringify({error:n.message||"wizard failed"}))}}async function Sn(e,a){a.setHeader("Content-Type","application/json");let t;try{t=Pe().node?.bind||"127.0.0.1:18800"}catch(i){a.writeHead(400),a.end(JSON.stringify({ok:!1,error:`Config validation failed: ${i.message}`}));return}let r=`http://${t.replace(/^0\.0\.0\.0/,"127.0.0.1")}`;if(await da(r)){a.writeHead(200),a.end(JSON.stringify({ok:!0,url:r,alreadyRunning:!0}));return}let n=process.argv[1]||M(xt(gt(import.meta.url)),"cli.js");try{mt(process.execPath,[n,"daemon","start"],{detached:!0,stdio:"ignore",cwd:process.cwd()}).unref()}catch(i){a.writeHead(500),a.end(JSON.stringify({ok:!1,error:`Failed to spawn daemon: ${i.message}`,manualUrl:r}));return}let o=Date.now()+12e3;for(;Date.now()<o;)if(await new Promise(i=>setTimeout(i,400)),await da(r)){a.writeHead(200),a.end(JSON.stringify({ok:!0,url:r,alreadyRunning:!1}));return}a.writeHead(504),a.end(JSON.stringify({ok:!1,error:"Daemon spawn succeeded but never bound the port within 12s \u2014 check `agentx daemon status` and the dotfile log for errors.",manualUrl:r}))}async function da(e){try{let a=await fetch(e,{method:"GET",signal:AbortSignal.timeout(800)});return a.status>0&&a.status<600}catch{return!1}}import{mkdirSync as wt,readFileSync as yt,renameSync as kt,writeFileSync as _t}from"fs";import{dirname as $t,isAbsolute as St,resolve as At}from"path";import{createHash as Ct,randomBytes as Tt}from"crypto";var En=".agentx/app-pins.json",Rn=12,ma=40,fa=2e3,It=/^pin_[a-z0-9]{6,32}$/;function zt(e,a){return St(a)?a:At(e,a)}function ae(e){let a=typeof e=="string"?e.trim().replace(/\s+/g," "):"";return a?/[\p{Cc}\p{Cf}]/u.test(a)?{ok:!1,error:"Use only letters, numbers, spaces and punctuation in the name."}:[...a].length>ma?{ok:!1,error:`Keep the name under ${ma} characters.`}:{ok:!0,value:a}:{ok:!1,error:"Give the button a name."}}function ye(e){let a=typeof e=="string"?e.trim():"";if(!a)return{ok:!1,error:"Give the page's address."};if(a.length>fa)return{ok:!1,error:`Keep the address under ${fa} characters.`};let t;try{t=new URL(a)}catch{return{ok:!1,error:"That is not a web address. It should start with https://"}}return t.protocol!=="https:"||!t.hostname?{ok:!1,error:"Only https:// pages can be pinned."}:t.username||t.password?{ok:!1,error:"Leave the user name and password out of the address."}:{ok:!0,value:t.href}}function Pt(e){return`cfg_${Ct("sha256").update(e).digest("hex").slice(0,12)}`}function Et(e){let a=[];for(let t of e){let r=ae(t.label),n=ye(t.url);!r.ok||!n.ok||a.some(o=>o.url===n.value||o.label.toLowerCase()===r.value.toLowerCase())||a.push({id:Pt(n.value),label:r.value,url:n.value,source:"config"})}return a}var ha="This button is set in agentx.json (app.pins.pages). Change or remove it there.";function Rt(e){let a=ae(e.label);if(!a.ok)return a;let t=ye(e.url);return t.ok?{ok:!0,value:{label:a.value,url:t.value}}:t}var we=class{constructor(a,t=Date.now,r=[]){this.path=a;this.now=t;this.fixed=r}list(){return[...this.fixed,...this.load().pins.filter(a=>!this.shadowed(a))]}shadowed(a){return this.fixed.some(t=>t.url===a.url||t.label.toLowerCase()===a.label.toLowerCase())}isFixed(a){return this.fixed.some(t=>t.id===a)}load(){let a;try{a=yt(this.path,"utf-8")}catch(o){return{pins:[],damaged:o?.code!=="ENOENT"}}let t;try{t=JSON.parse(a)}catch{return{pins:[],damaged:!0}}let r=Array.isArray(t?.pins)?t.pins:[],n=r.filter(o=>{let i=o;return!!i&&typeof i.id=="string"&&It.test(i.id)&&ae(i.label).ok&&ye(i.url).ok});return{pins:n,damaged:!Array.isArray(t?.pins)||n.length!==r.length}}locked(a){try{return Oe(this.path,a,{what:"The pinned pages file"})}catch(t){if(t instanceof Re)return{ok:!1,status:409,error:t.message};throw t}}editable(){let{pins:a,damaged:t}=this.load();return t?{ok:!1,status:409,error:`The pinned pages file (${this.path}) can't be read. Fix or remove it on the computer, then try again.`}:{ok:!0,pins:a}}write(a){wt($t(this.path),{recursive:!0});let t=`${this.path}.${process.pid}.tmp`;_t(t,JSON.stringify({pins:a},null,2)+`
2218
+ `,{mode:384}),kt(t,this.path)}add(a,t){return this.locked(()=>this.addUnlocked(a,t))}addUnlocked(a,t){let r=this.editable();if(!r.ok)return r;let n=r.pins;if(n.filter(i=>!this.shadowed(i)).length+this.fixed.length>=t)return{ok:!1,status:409,error:`You already have ${t} pinned pages, the most allowed (app.pins.max). Remove one first.`};if([...this.fixed,...n].some(i=>i.label.toLowerCase()===a.label.toLowerCase()))return{ok:!1,status:409,error:`You already have a button called ${a.label}.`};if(this.fixed.some(i=>i.url===a.url))return{ok:!1,status:409,error:"This page is already a button, set in agentx.json (app.pins.pages)."};let o={id:`pin_${Tt(6).toString("hex")}`,...a,createdAt:new Date(this.now()).toISOString()};return n.push(o),this.write(n),{ok:!0,pin:o}}rename(a,t){return this.locked(()=>this.renameUnlocked(a,t))}renameUnlocked(a,t){if(this.isFixed(a))return{ok:!1,status:409,error:ha};let r=this.editable();if(!r.ok)return r;let n=r.pins,o=n.find(i=>i.id===a);return o?[...this.fixed,...n].some(i=>i.id!==a&&i.label.toLowerCase()===t.toLowerCase())?{ok:!1,status:409,error:`You already have a button called ${t}.`}:(o.label=t,this.write(n),{ok:!0,pin:o}):{ok:!1,status:404,error:"No such pinned page."}}remove(a){return this.locked(()=>this.removeUnlocked(a))}removeUnlocked(a){if(this.isFixed(a))return{ok:!1,status:409,error:ha};let t=this.editable();if(!t.ok)return t;let r=t.pins.filter(n=>n.id!==a);return r.length===t.pins.length?{ok:!1,status:404,error:"No such pinned page."}:(this.write(r),{ok:!0})}};function On(e,a){let t=e.app.pins;return{store:new we(zt(a,t.file),Date.now,Et(t.pages)),max:t.max}}async function Dn(e,a,t,r,n){if(t!=="/api/app/pins"&&!t.startsWith("/api/app/pins/"))return!1;let o=t.slice(13);if(r==="GET"&&o==="")return P(a,200,{pins:n.store.list(),max:n.max});if(r!=="POST")return P(a,404,{error:"not found"});let i;try{i=await V(e,4096)}catch(d){return P(a,400,{error:d.message})}let s=typeof i.id=="string"?i.id:"";if(o==="/add"){let d=Rt(i);if(!d.ok)return P(a,400,{error:d.error});let l=n.store.add(d.value,n.max);return l.ok?P(a,200,{ok:!0,pin:l.pin}):P(a,l.status,{error:l.error})}if(o==="/rename"){let d=ae(i.label);if(!d.ok)return P(a,400,{error:d.error});let l=n.store.rename(s,d.value);return l.ok?P(a,200,{ok:!0,pin:l.pin}):P(a,l.status,{error:l.error})}if(o==="/remove"){let d=n.store.remove(s);return d.ok?P(a,200,{ok:!0}):P(a,d.status,{error:d.error})}return P(a,404,{error:"not found"})}function P(e,a,t){return e.writeHead(a,{"Content-Type":"application/json","Cache-Control":"no-store"}),e.end(JSON.stringify(t)),!0}import{existsSync as ba,readFileSync as va}from"fs";ce();function Ot(e){let a=q(e),t={};if(ba(a))try{t=F(JSON.parse(va(a,"utf-8")))}catch{t={}}let r=le.safeParse(t?.approvals);return r.success?r.data:le.parse(void 0)}function Wn(e){let a=q(e),t={};if(ba(a))try{t=F(JSON.parse(va(a,"utf-8")))}catch{t={}}return We({desk:t?.notifications?.desk,popupEnabled:!!Ot(e).popup?.enabled})}function Bn(e){let a=e.indexOf(":");return a<=0||a===e.length-1?null:{channel:e.slice(0,a).trim(),chatId:e.slice(a+1).trim()}}async function Un(e,a={}){return J(t=>{let r=t.approvals??={};if(e.defaultExpiryDays!==void 0&&(r.defaultExpiryDays=e.defaultExpiryDays),e.maxExpiryDays!==void 0&&(r.maxExpiryDays=e.maxExpiryDays),e.laterHours!==void 0&&(r.laterHours=e.laterHours),e.notifyAgent!==void 0&&(r.notifyAgent=e.notifyAgent),e.forwardTo===null)delete r.forwardTo;else if(e.forwardTo!==void 0){let l=Array.isArray(t.mesh?.peers)?t.mesh.peers:[];if(!l.some(c=>c.name===e.forwardTo))throw new Error(`"${e.forwardTo}" is not in mesh.peers${l.length?` (known: ${l.map(c=>c.name).join(", ")})`:""}; pair the machines first`);r.forwardTo=e.forwardTo}let n=r.digest??={};e.digestEnabled!==void 0&&(n.enabled=e.digestEnabled),e.digestTime!==void 0&&(n.time=e.digestTime),e.digestTimezone===null?delete n.timezone:e.digestTimezone!==void 0&&(n.timezone=e.digestTimezone),e.destination===null?delete n.destination:e.destination!==void 0&&(n.destination=e.destination);let o=r.popup??={};e.popupEnabled!==void 0&&(o.enabled=e.popupEnabled),e.popupSpeak!==void 0&&(o.speak=e.popupSpeak),e.popupVoice===null?delete o.voice:e.popupVoice!==void 0&&(o.voice=e.popupVoice),e.popupSound!==void 0&&(o.sound=e.popupSound),e.popupTimeoutSeconds!==void 0&&(o.timeoutSeconds=e.popupTimeoutSeconds),e.popupStyle!==void 0&&(o.style=e.popupStyle),e.popupTheme!==void 0&&(o.theme=e.popupTheme);let i=r.checkin??={};if(e.checkinEnabled!==void 0&&(i.enabled=e.checkinEnabled),e.checkinTimes!==void 0&&(i.times=e.checkinTimes),e.checkinDailyAt!==void 0&&(i.dailyAt=e.checkinDailyAt),e.checkinLists!==void 0&&(i.lists=e.checkinLists),e.checkinAgent===null?delete i.agent:e.checkinAgent!==void 0&&(i.agent=e.checkinAgent),e.deskPhone!==void 0||e.deskComputer!==void 0){let l=(t.notifications??={}).desk??={};e.deskPhone!==void 0&&(l.phone=e.deskPhone),e.deskComputer!==void 0&&(l.computer=e.deskComputer)}let s=r.defaultExpiryDays??3,d=r.maxExpiryDays??30;if(s>d)throw new Error(`defaultExpiryDays (${s}) can't be more than maxExpiryDays (${d})`)},{configPath:a.configPath,reload:a.reload})}import{createServer as Wt}from"http";var te=class{peers;cache=new Map;ttl=3e4;constructor(a){this.peers=a.map(t=>({...t,url:t.url.replace(/\/$/,"")}))}async getRemoteAgents(){let a=[];return await Promise.all(this.peers.map(async t=>{try{let r=await this.fetchJson(`${t.url}/wiki/agents`);t.nodeId=r.nodeId;for(let n of r.agents||[])(n.totalEntries>0||n.totalArticles>0)&&a.push({...n,nodeId:r.nodeId,peerUrl:t.url})}catch{}})),a}async getRemoteArticles(a,t){try{return(await this.fetchJson(`${a}/wiki/articles?agent=${encodeURIComponent(t)}`)).articles||[]}catch{return[]}}async getRemoteArticle(a,t,r){try{let n=await this.fetchJson(`${a}/wiki/article?agent=${encodeURIComponent(t)}&path=${encodeURIComponent(r)}`);return{meta:{title:n.title,tags:n.tags||[],owner:n.owner,access:"public",created:n.created,lastUpdated:n.lastUpdated,sources:n.sources||[]},content:n.content,path:n.path}}catch{return null}}async fetchJson(a){let t=this.cache.get(a);if(t&&Date.now()-t.ts<this.ttl)return t.data;let r=this.peers.find(i=>a.startsWith(`${i.url}/`))?.token,n=await fetch(a,{headers:r?{Authorization:`Bearer ${r}`}:{},signal:AbortSignal.timeout(5e3)});if(!n.ok)throw new Error(`HTTP ${n.status}`);let o=await n.json();return this.cache.set(a,{data:o,ts:Date.now()}),o}};var wa=864e5;function ke(e){let a=new Map;for(let t of e.entities.values()){let r=a.get(t.type)??[];r.push(t),a.set(t.type,r)}return a}function _e(e,a){if(a.type==="event")return a.date||a.updated;let t=Xe(e,a,new Set(["event"]))[0],r=a.updated||a.date;return t&&t.date>r?t.date:r}function ya(e,a,t=Date.now()){let r=[],n=new Date(t+14*wa).toISOString().slice(0,10),o=new Date(t).toISOString().slice(0,10);for(let s of a){let d=s.statements.find(c=>c.property==="due"&&/^\d{4}-\d{2}-\d{2}/.test(c.value)),l=s.statements.some(c=>c.property==="fulfilled_by")||s.statements.some(c=>c.property==="status"&&/^(fulfilled|done|paid|filed)$/i.test(c.value));s.statements.some(c=>c.property==="status"&&/^late$/i.test(c.value))?r.push({e:s,chip:"late",why:"marked late"}):d&&!l&&d.value<o?r.push({e:s,chip:"late",why:`was due ${d.value}`}):d&&!l&&d.value<=n?r.push({e:s,chip:"due",why:`due ${d.value}`}):s.statements.some(c=>c.status==="proposed")?r.push({e:s,chip:"proposed",why:"statements wait for confirmation"}):s.type==="event"&&s.importanceProposed&&s.importanceProposed!==s.importance?r.push({e:s,chip:"proposed",why:`proposed as ${s.importanceProposed}; the owner decides`}):s.type==="event"&&s.importance==="major"&&s.date&&t-Date.parse(s.date)<=30*wa&&r.push({e:s,chip:"major",why:`major event ${s.date}`})}let i={late:0,due:1,major:2,proposed:3};return r.sort((s,d)=>i[s.chip]-i[d.chip])}function re(e,a,t="",r){return`<div class="ox-row"><span class="ox-ic">${Ve(e.ontology,a.type)}</span><div class="t"><a href="${me(a.id)}">${k(a.title)}</a><div class="ox-sub">${k(r??`${ue(e.ontology,a.type).toLowerCase()} \xB7 ${_e(e,a)}`)}</div></div><div class="r">${t}</div></div>`}function ka(e,a){let t=a.slice(0,6).map(r=>re(e,r.e,`<span class="ox-st ${r.chip}">${r.chip}</span>`,r.why)).join("");return`<section class="ox-card"><div class="ox-card-h"><h2>Needs attention</h2><span class="note">${a.length}</span></div>${t||'<div class="ox-empty">Nothing waits on a person.</div>'}</section>`}function Dt(e){return e.length?`<div class="ox-err"><b>ontology.yaml has ${e.length} problem${e.length===1?"":"s"}</b> \u2014 the defaults are used where they apply. <a href="/ontology">See them</a></div>`:""}function _a(e,a){let t=ke(e),r=`<div class="ox-bar">${j([])}</div>`;r+=`<div class="ox-head"><div class="ox-avatar">${D("home")}</div><div><h1>Wiki</h1><p>${e.entities.size} things, merged from every agent's pages and typed by the <a href="/ontology">ontology</a>. <a href="/agents">Agent wikis</a> \xB7 <a href="/entries">raw entries</a></p></div></div>`,r+=Dt(a),r+='<div class="ox-grid3">';for(let o of e.ontology.pillars){let i=e.ontology.types.filter(l=>l.pillar===o.id),s=i.reduce((l,c)=>l+(t.get(c.id)?.length??0),0),d=i.filter(l=>t.get(l.id)?.length).map(l=>`${l.plural??l.label} ${t.get(l.id).length}`).join(" \xB7 ");r+=`<a class="ox-card" href="/p/${encodeURIComponent(o.id)}" style="color:inherit"><div class="ox-card-h"><span class="ox-ic">${D(o.icon)}</span><h2>${k(o.label)}</h2><span class="zin">${s}</span></div><div class="ox-sub" style="white-space:normal">${k(o.description??"")}</div><div class="ox-sub" style="margin-top:6px;white-space:normal">${k(d||"nothing yet")}</div></a>`}r+='</div><div class="ox-grid2">';let n=(t.get("event")??[]).filter(o=>o.importance!=="minor").sort((o,i)=>i.date.localeCompare(o.date)).slice(0,8);return r+='<section class="ox-card"><div class="ox-card-h"><h2>Recent events</h2><span class="note">major and normal</span><a class="zin" href="/p/events">all (Z1) \u2192</a></div>'+(n.map(o=>`<div class="ox-ev"><span class="d">${k(o.date)}</span><span class="ox-st ${o.importance}">${o.importance}</span><a href="${me(o.id)}">${k(o.title)}</a></div>`).join("")||'<div class="ox-empty">No events yet.</div>')+"</section>",r+=ka(e,ya(e,[...e.entities.values()])),r+="</div>",L("Wiki",N(e,{home:!0}),r)}function $a(e,a,t){let r=e.ontology.pillars.find(c=>c.id===a);if(!r)return null;let n=ke(e),o=e.ontology.types.filter(c=>c.pillar===r.id),i=o.find(c=>c.id===t)??o.find(c=>n.get(c.id)?.length)??o[0],s=`<div class="ox-bar">${j([{label:r.label}])}${fe(1)}</div>`;s+=`<div class="ox-head"><div class="ox-avatar">${D(r.icon)}</div><div><h1>${k(r.label)}</h1><p>${k(r.description??"")}</p></div></div>`,s+=`<nav class="ox-tabs">${o.map(c=>`<a class="${c.id===i?.id?"on":""}" href="/p/${encodeURIComponent(r.id)}?kind=${encodeURIComponent(c.id)}">${k(c.plural??c.label)}<small>${n.get(c.id)?.length??0}</small></a>`).join("")}</nav>`;let d=i?(n.get(i.id)??[]).map(c=>({e:c,at:_e(e,c)})).sort((c,m)=>m.at.localeCompare(c.at)):[];s+='<div class="ox-grid2">',s+=`<section class="ox-card"><div class="ox-card-h"><h2>${k(i?.plural??i?.label??"")}</h2><span class="note">${d.length} \xB7 most active first</span>`+(i?`<a class="zin" href="/p/${encodeURIComponent(r.id)}/${encodeURIComponent(i.id)}">open list (Z3) \u2192</a>`:"")+"</div>"+(d.slice(0,5).map(({e:c,at:m})=>re(e,c,c.type==="event"?`<span class="ox-st ${c.importance}">${c.importance}</span>`:"",`${Qe(c,90)||ue(e.ontology,c.type).toLowerCase()} \xB7 ${m}`)).join("")||`<div class="ox-empty">No ${k((i?.plural??"pages").toLowerCase())} yet.</div>`)+"</section>";let l=o.flatMap(c=>n.get(c.id)??[]);return s+=ka(e,ya(e,l)),s+="</div>",L(r.label,N(e,{pillar:r.id}),s)}function Sa(e,a,t,r,n){let o=n&&De.includes(n)?n:null,i=e.ontology.pillars.find(x=>x.id===a),s=e.ontology.types.find(x=>x.id===t&&x.pillar===a);if(!i||!s)return null;let d=[...e.entities.values()].filter(x=>x.type===s.id);o&&(d=d.filter(x=>x.importance===o));let l=d.map(x=>({e:x,at:_e(e,x)})).sort((x,f)=>f.at.localeCompare(x.at)),c=50,m=Math.max(1,Math.ceil(l.length/c)),g=`/p/${encodeURIComponent(i.id)}/${encodeURIComponent(s.id)}`,u=`<div class="ox-bar">${j([{label:i.label,href:`/p/${encodeURIComponent(i.id)}`},{label:s.plural??s.label}])}${fe(3)}</div>`;if(u+=`<div class="ox-head"><div class="ox-avatar">${D(s.icon)}</div><div><h1>${k(s.plural??s.label)}</h1><p>${l.length} page${l.length===1?"":"s"}${o?` \xB7 ${k(o)} only`:""}</p></div></div>`,s.id==="event"&&(u+=`<nav class="ox-tabs">${["","major","normal","minor"].map(x=>`<a class="${(o??"")===x?"on":""}" href="${g}${x?`?importance=${x}`:""}">${x||"all"}</a>`).join("")}</nav>`),u+='<section class="ox-card" style="margin-top:16px">'+(l.slice((r-1)*c,r*c).map(({e:x,at:f})=>re(e,x,x.type==="event"?`<span class="ox-st ${x.importance}">${x.importance}</span>`:"",`${f} \xB7 ${x.pages.map(C=>C.agentId).filter((C,w,v)=>v.indexOf(C)===w).join(", ")}`)).join("")||'<div class="ox-empty">None.</div>')+"</section>",m>1){let x=o?`importance=${o}&`:"";u+=`<div class="ox-pager">${r>1?`<a href="${g}?${x}page=${r-1}">\u2190 previous</a>`:""}<span>page ${r} of ${m}</span>${r<m?`<a href="${g}?${x}page=${r+1}">next \u2192</a>`:""}</div>`}return L(s.plural??s.label,N(e,{pillar:i.id}),u)}function Aa(e,a){let t=a.trim().toLowerCase(),r=[];if(t)for(let o of e.entities.values()){let i=o.title.toLowerCase(),s=i===t?100:i.startsWith(t)?60:i.includes(t)?40:0;!s&&o.pages.some(d=>d.article.content.toLowerCase().includes(t))&&(s=10),s&&r.push({e:o,s})}r.sort((o,i)=>i.s-o.s||i.e.updated.localeCompare(o.e.updated));let n=`<div class="ox-bar">${j([{label:"Search"}])}</div>`;return n+=`<div class="ox-head"><div class="ox-avatar">${D("search")}</div><div><h1>${t?`\u201C${k(a)}\u201D`:"Search"}</h1><p>${r.length} match${r.length===1?"":"es"}</p></div></div>`,n+=`<section class="ox-card">${r.slice(0,60).map(({e:o})=>re(e,o)).join("")||'<div class="ox-empty">No page matches.</div>'}</section>`,L(`Search: ${a}`,N(e,{}),n,"",a)}function Ca(e,a,t){let r=e.ontology,n=ke(e),o=`<div class="ox-bar">${j([{label:"Ontology"}])}</div>`;o+=`<div class="ox-head"><div class="ox-avatar">${D("steps")}</div><div><h1>Ontology</h1><p>${t?`Read from ${k(t)}`:"Built-in defaults. Run <code>agentx wiki ontology init</code> to write an ontology.yaml you can edit."}</p></div></div>`,a.length&&(o+=`<div class="ox-err"><b>Problems</b><ul>${a.map(i=>`<li>${k(i)}</li>`).join("")}</ul></div>`),o+=`<section class="ox-card"><div class="ox-card-h"><h2>Types</h2><span class="note">${r.types.length}</span></div>`;for(let i of r.types){let s=r.pillars.find(d=>d.id===i.pillar);o+=`<div class="ox-row"><span class="ox-ic">${D(i.icon)}</span><div class="t"><span class="l">${k(i.label)} <span class="ox-sub">${k(i.id)}</span></span><div class="ox-sub">${k(s?.label??i.pillar)} \xB7 lens: ${k((i.lens??[]).map(d=>d.title??d.panel).join(" \u2192 "))}</div></div><div class="r"><span class="ox-chip">${n.get(i.id)?.length??0}</span></div></div>`}o+=`</section><section class="ox-card" style="margin-top:16px"><div class="ox-card-h"><h2>Relations</h2><span class="note">${r.properties.length}</span></div>`;for(let i of r.properties)o+=`<div class="ox-kv"><span class="k">${k(i.id)}</span><span>${k(i.label)}${i.inverse?` \xB7 inverse: ${k(i.inverse)}`:""}${i.wikidata?` <span class="ox-sub">${k(i.wikidata)}</span>`:""}</span></div>`;return o+=`</section><section class="ox-card" style="margin-top:16px"><div class="ox-card-h"><h2>Event importance</h2></div><div class="ox-kv"><span class="k">default</span><span>${k(r.importance.default)}</span></div><div class="ox-kv"><span class="k">major set by</span><span>${k(r.importance.major_set_by)}</span></div><div class="ox-kv"><span class="k">roll-up</span><span>${r.importance.rollup.min} minor events in ${r.importance.rollup.days} days</span></div></section>`,L("Ontology",N(e,{}),o)}var ne=class{constructor(a,t){this.hub=a;this.wikiDir=t}cache=new Ge;pageAt(a){if(!a.startsWith("/e/"))return null;let{ontology:t}=ge(this.wikiDir),n=this.cache.get(this.hub,t).entities.get(a.split("/").filter(Boolean)[1]??"")?.pages[0];return n?{agentId:n.agentId,path:n.article.path,title:n.article.meta.title}:null}handle(a,t){if(!(a==="/"||a===""||a.startsWith("/p/")||a.startsWith("/e/")||a==="/find"||a==="/ontology"))return null;let{ontology:r,errors:n,file:o}=ge(this.wikiDir),i=Je(this.wikiDir,this.hub.listAgents([]),r.agent_names),s=this.cache.get(this.hub,r,i),d=Math.max(1,Number(t.get("page"))||1);if(a==="/"||a==="")return _a(s,n);if(a==="/find")return Aa(s,t.get("q")??"");if(a==="/ontology")return Ca(s,n,o);let l=a.split("/").filter(Boolean);if(l[0]==="p")return l.length===2?$a(s,l[1],t.get("kind")):l.length===3?Sa(s,l[1],l[2],d,t.get("importance")):null;let c=s.entities.get(l[1]??"");if(!c)return null;let m={g:s,readEntries:g=>this.hub.getSharedStore().readEntries(g),versions:(g,u)=>this.hub.getAgentWiki(g).getVersions(u)};return l.length===2?Ze(m,c):l.length===3?ea(m,c,l[2],d):l.length===4&&l[2]==="s"?aa(m,c,Number(l[3])):null}};var Mt=`
2219
2219
  .wc-root{--wc-bg:#fff;--wc-ink:#1b1f1e;--wc-muted:#5d6664;--wc-edge:#d9dedc;--wc-soft:#f3f5f4;--wc-accent:#2f6fde;--wc-on-accent:#fff;--wc-add:#e6f4ea;--wc-add-ink:#1e6b34;--wc-del:#fbe9e9;--wc-del-ink:#9b2c2c;
2220
2220
  font:14px/1.45 'IBM Plex Sans',system-ui,-apple-system,sans-serif;color:var(--wc-ink)}
2221
2221
  [data-theme=dark] .wc-root{--wc-bg:#181c1b;--wc-ink:#e9eeec;--wc-muted:#a3adab;--wc-edge:#2c3331;--wc-soft:#1f2422;--wc-accent:#6b9cff;--wc-on-accent:#0b1020;--wc-add:#173823;--wc-add-ink:#9be3b0;--wc-del:#3b1d1d;--wc-del-ink:#f3a9a9}
@@ -2254,7 +2254,7 @@ ${g}
2254
2254
  @keyframes wc-blink{0%{content:''}25%{content:'.'}50%{content:'..'}75%{content:'\u2026'}}
2255
2255
  @media (max-width:600px){.wc-panel{right:8px;left:8px;bottom:80px;width:auto;max-height:calc(100vh - 100px)}.wc-fab{right:14px;bottom:14px}}
2256
2256
  @media (prefers-reduced-motion:reduce){.wc-dots::after{animation:none;content:'\u2026'}}
2257
- `,Mt=`
2257
+ `,Ht=`
2258
2258
  (function(){
2259
2259
  var root=document.getElementById('wc-root'); if(!root) return;
2260
2260
  var cfg=JSON.parse(document.getElementById('wc-data').textContent);
@@ -2322,20 +2322,20 @@ ${g}
2322
2322
  api('GET',q()).then(function(state){if(state.enabled===false)return;fab.hidden=false;
2323
2323
  try{if(sessionStorage.getItem(openKey))setOpen(true)}catch(e){}}).catch(function(){});
2324
2324
  })();
2325
- `,Ht='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z"/><path d="M12 8.5l.9 2.1 2.1.9-2.1.9-.9 2.1-.9-2.1-2.1-.9 2.1-.9z"/></svg>';function jt(e){return e.replace(/[&<>"']/g,a=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[a])}function Nt(e,a="/api/wiki/curate",t){let r=JSON.stringify({agent:e.agentId,path:e.path,title:e.title,endpoint:a,...t?{token:t}:{}}).replace(/</g,"\\u003c");return`<style>${Dt}</style>
2325
+ `,jt='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z"/><path d="M12 8.5l.9 2.1 2.1.9-2.1.9-.9 2.1-.9-2.1-2.1-.9 2.1-.9z"/></svg>';function Nt(e){return e.replace(/[&<>"']/g,a=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[a])}function Lt(e,a="/api/wiki/curate",t){let r=JSON.stringify({agent:e.agentId,path:e.path,title:e.title,endpoint:a,...t?{token:t}:{}}).replace(/</g,"\\u003c");return`<style>${Mt}</style>
2326
2326
  <div class="wc-root" id="wc-root">
2327
- <button class="wc-fab" type="button" hidden aria-label="Ask an agent to curate this page" aria-expanded="false" aria-controls="wc-panel" title="Curate this page">${Ht}</button>
2327
+ <button class="wc-fab" type="button" hidden aria-label="Ask an agent to curate this page" aria-expanded="false" aria-controls="wc-panel" title="Curate this page">${jt}</button>
2328
2328
  <section class="wc-panel" id="wc-panel" role="dialog" aria-label="Curate this page" hidden>
2329
- <div class="wc-head"><div><h2>Curate this page</h2><p class="wc-sub">${jt(e.title)}</p></div><button class="wc-x" type="button" aria-label="Close">\xD7</button></div>
2329
+ <div class="wc-head"><div><h2>Curate this page</h2><p class="wc-sub">${Nt(e.title)}</p></div><button class="wc-x" type="button" aria-label="Close">\xD7</button></div>
2330
2330
  <div class="wc-log" aria-live="polite"></div>
2331
2331
  <form class="wc-form"><textarea rows="2" aria-label="Instruction for the agent" placeholder="What should change on this page?"></textarea><button class="wc-send" type="submit">Send</button></form>
2332
2332
  </section>
2333
2333
  </div>
2334
2334
  <script type="application/json" id="wc-data">${r}</script>
2335
- <script>${Mt}</script>`}function Ca(e,a,t,r){let n=Nt(a,t,r);return e.includes("</body>")?e.replace(/<\/body>(?![\s\S]*<\/body>)/,()=>`${n}
2336
- </body>`):e+n}function p(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Wt(e){return e.replace(/<!--\s*tags?:[^>]*-->\s*\n?/gi,"")}function Ta(e,a){return`<a href="${a?`/agent/${encodeURIComponent(a)}/tag/${encodeURIComponent(e)}`:`/tag/${encodeURIComponent(e)}`}" class="tag">${p(e)}</a>`}function H(e,a){return(e||[]).map(t=>Ta(t,a)).join(" ")}function Bt(e,a){if(!e)return;let t=a.get(e);if(t)return t;let r=new Set(a.values());if(r.has(e))return e;let n=e.endsWith(".md")?e:`${e}.md`;if(r.has(n))return n;let o=e.toLowerCase();for(let[i,s]of a)if(i.toLowerCase()===o)return s}function oe(e,a,t=""){return X(Wt(e),{wikilink:(r,n)=>{let o=Bt(r,a);return o?`<a href="${t}/article/${encodeURIComponent(o)}" class="wikilink">${n}</a>`:`<a href="${t}/search?q=${encodeURIComponent(r)}" class="wikilink broken" title="Not found \u2014 click to search">${n}</a>`}})}var Ut=`<link rel="preconnect" href="https://fonts.googleapis.com">
2335
+ <script>${Ht}</script>`}function Ta(e,a,t,r){let n=Lt(a,t,r);return e.includes("</body>")?e.replace(/<\/body>(?![\s\S]*<\/body>)/,()=>`${n}
2336
+ </body>`):e+n}function p(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Bt(e){return e.replace(/<!--\s*tags?:[^>]*-->\s*\n?/gi,"")}function Ia(e,a){return`<a href="${a?`/agent/${encodeURIComponent(a)}/tag/${encodeURIComponent(e)}`:`/tag/${encodeURIComponent(e)}`}" class="tag">${p(e)}</a>`}function H(e,a){return(e||[]).map(t=>Ia(t,a)).join(" ")}function Ut(e,a){if(!e)return;let t=a.get(e);if(t)return t;let r=new Set(a.values());if(r.has(e))return e;let n=e.endsWith(".md")?e:`${e}.md`;if(r.has(n))return n;let o=e.toLowerCase();for(let[i,s]of a)if(i.toLowerCase()===o)return s}function oe(e,a,t=""){return X(Bt(e),{wikilink:(r,n)=>{let o=Ut(r,a);return o?`<a href="${t}/article/${encodeURIComponent(o)}" class="wikilink">${n}</a>`:`<a href="${t}/search?q=${encodeURIComponent(r)}" class="wikilink broken" title="Not found \u2014 click to search">${n}</a>`}})}var Ft=`<link rel="preconnect" href="https://fonts.googleapis.com">
2337
2337
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
2338
- <link href="https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,300..600;1,6..72,300..600&family=Inter+Tight:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">`,Ft=`
2338
+ <link href="https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,300..600;1,6..72,300..600&family=Inter+Tight:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">`,qt=`
2339
2339
  :root {
2340
2340
  --bg: #FAF8F3;
2341
2341
  --bg-raised: #FFFFFF;
@@ -2808,8 +2808,8 @@ tr:hover td { background: var(--bg-hover); }
2808
2808
  <meta charset="utf-8">
2809
2809
  <meta name="viewport" content="width=device-width, initial-scale=1">
2810
2810
  <title>${p(e)} \u2014 AgentX Wiki</title>
2811
- ${Ut}
2812
- <style>${Ft}</style>
2811
+ ${Ft}
2812
+ <style>${qt}</style>
2813
2813
  <script>(function(){try{var t=localStorage.getItem('wiki-theme');if(t)document.documentElement.setAttribute('data-theme',t)}catch(e){}})();</script>
2814
2814
  </head>
2815
2815
  <body>
@@ -2854,7 +2854,7 @@ tr:hover td { background: var(--bg-hover); }
2854
2854
  })();
2855
2855
  </script>
2856
2856
  </body>
2857
- </html>`}function _e(e){let a=new Map;for(let t of e){let r=t.path.includes("/")?t.path.split("/").slice(0,-1).join("/"):"/",n=a.get(r)||[];n.push(t),a.set(r,n)}return new Map([...a].sort((t,r)=>t[0].localeCompare(r[0])))}function $e(e){return e==="/"?"Root":e.split("/").pop().replace(/-/g," ")}function E(e,a){let t='<div class="nav-section">';t+=`<a class="nav-item${a?"":" active"}" href="/">Home</a>`,t+='<a class="nav-item" href="/entries">All entries</a>',t+="</div>";for(let r of e){let n=`/agent/${encodeURIComponent(r.agentId)}`;t+='<div class="nav-section">',t+=`<a class="nav-agent-header" href="${n}">`,t+=`<span class="name">${p(r.agentId)}</span>`,t+=`<span class="badge">${r.totalArticles}</span>`,t+="</a>",t+='<div class="nav-agent-children">';let o=_e(r.articles);for(let[i,s]of o){t+=`<div class="nav-agent-type-label">${$e(i)}</div>`;for(let d of s){let c=`${r.agentId}/${d.path}`===a;t+=`<a class="nav-item${c?" active":""}" href="${n}/article/${encodeURIComponent(d.path)}">${p(d.title)}</a>`}}t+="</div>",t+="</div>"}return t}function qt(e,a,t){let r=a||e.summary(),o=e.getSharedStore().listEntries().length,i=r.reduce((c,m)=>c+m.totalArticles,0),s=r.reduce((c,m)=>c+m.unabsorbed,0),d=new Set((t||[]).map(c=>c.agentId)),l=`<div class="page-head">
2857
+ </html>`}function $e(e){let a=new Map;for(let t of e){let r=t.path.includes("/")?t.path.split("/").slice(0,-1).join("/"):"/",n=a.get(r)||[];n.push(t),a.set(r,n)}return new Map([...a].sort((t,r)=>t[0].localeCompare(r[0])))}function Se(e){return e==="/"?"Root":e.split("/").pop().replace(/-/g," ")}function E(e,a){let t='<div class="nav-section">';t+=`<a class="nav-item${a?"":" active"}" href="/">Home</a>`,t+='<a class="nav-item" href="/entries">All entries</a>',t+="</div>";for(let r of e){let n=`/agent/${encodeURIComponent(r.agentId)}`;t+='<div class="nav-section">',t+=`<a class="nav-agent-header" href="${n}">`,t+=`<span class="name">${p(r.agentId)}</span>`,t+=`<span class="badge">${r.totalArticles}</span>`,t+="</a>",t+='<div class="nav-agent-children">';let o=$e(r.articles);for(let[i,s]of o){t+=`<div class="nav-agent-type-label">${Se(i)}</div>`;for(let d of s){let c=`${r.agentId}/${d.path}`===a;t+=`<a class="nav-item${c?" active":""}" href="${n}/article/${encodeURIComponent(d.path)}">${p(d.title)}</a>`}}t+="</div>",t+="</div>"}return t}function Kt(e,a,t){let r=a||e.summary(),o=e.getSharedStore().listEntries().length,i=r.reduce((c,m)=>c+m.totalArticles,0),s=r.reduce((c,m)=>c+m.unabsorbed,0),d=new Set((t||[]).map(c=>c.agentId)),l=`<div class="page-head">
2858
2858
  <div>
2859
2859
  <h1>AgentX Wiki</h1>
2860
2860
  <p class="page-sub">Agent-owned institutional knowledge, typed and cross-referenced. Everything here compiles from raw conversation entries through the nightly absorb pass.</p>
@@ -2863,41 +2863,41 @@ tr:hover td { background: var(--bg-hover); }
2863
2863
  <span><strong>${c.totalArticles}</strong> articles</span>
2864
2864
  <span><strong>${c.totalEntries}</strong> entries</span>
2865
2865
  ${m}
2866
- </div>`,c.articles.length>0){l+='<div class="article-list">';for(let x of c.articles.slice(0,6)){let f=H((x.tags||[]).slice(0,2),c.agentId);l+=`<div class="article-row">${f} <a class="article-title" href="/agent/${encodeURIComponent(c.agentId)}/article/${encodeURIComponent(x.path)}">${p(x.title)}</a></div>`}c.articles.length>6&&(l+=`<div class="article-row"><a class="article-title" style="color:var(--muted)" href="/agent/${encodeURIComponent(c.agentId)}">+ ${c.articles.length-6} more \u2192</a></div>`),l+="</div>"}l+="</div>"}return l+="</div>",A("Hub",E(r),l)}function Kt(e,a,t){let r=t||e.summary(),n=r.find(g=>g.agentId===a);if(!n)return A("Not Found",E(r),"<h1>Agent not found</h1>");let o=n.peerUrl!==void 0,i=e.getAgentEntries(a),s=n.articles||[],d=`<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <span class="current">${p(a)}</span></nav>`;if(d+=`<div class="page-head"><div><h1>${p(a)}</h1>`,o&&(d+=`<p class="page-sub"><span class="tag" style="color:var(--cool);background:var(--cool-soft)">remote @ ${p(n.nodeId)}</span></p>`),d+="</div></div>",d+='<div class="stat-strip">',d+=`<div class="stat-cell"><div class="label">Articles</div><div class="number">${n.totalArticles}</div></div>`,d+=`<div class="stat-cell"><div class="label">Entries</div><div class="number">${n.totalEntries}</div></div>`,d+=`<div class="stat-cell"><div class="label">Unabsorbed</div><div class="number">${n.unabsorbed}</div></div>`,d+="</div>",s.length>0){d+='<div class="section-head"><h2>Articles</h2><span class="mono" style="font-size:12px;color:var(--muted)">'+s.length+" total</span></div>";let g=_e(s);for(let[u,x]of g){d+=`<h3 class="display" style="font-size:17px;color:var(--muted);font-weight:500;margin:20px 0 8px">${$e(u)}</h3>`,d+='<div class="agent-card" style="padding:4px 14px"><div class="article-list">';for(let f of x)d+=`<div class="article-row">${H((f.tags||[]).slice(0,3),a)} <a class="article-title" href="/agent/${encodeURIComponent(a)}/article/${encodeURIComponent(f.path)}">${p(f.title)}</a></div>`;d+="</div></div>"}}let l=i.slice(-5).reverse();if(l.length>0){d+='<div class="section-head"><h2>Recent entries</h2><a class="btn ghost" href="/entries">See all \u2192</a></div>';for(let g of l)d+=`<div class="entry-card">
2866
+ </div>`,c.articles.length>0){l+='<div class="article-list">';for(let x of c.articles.slice(0,6)){let f=H((x.tags||[]).slice(0,2),c.agentId);l+=`<div class="article-row">${f} <a class="article-title" href="/agent/${encodeURIComponent(c.agentId)}/article/${encodeURIComponent(x.path)}">${p(x.title)}</a></div>`}c.articles.length>6&&(l+=`<div class="article-row"><a class="article-title" style="color:var(--muted)" href="/agent/${encodeURIComponent(c.agentId)}">+ ${c.articles.length-6} more \u2192</a></div>`),l+="</div>"}l+="</div>"}return l+="</div>",A("Hub",E(r),l)}function Yt(e,a,t){let r=t||e.summary(),n=r.find(g=>g.agentId===a);if(!n)return A("Not Found",E(r),"<h1>Agent not found</h1>");let o=n.peerUrl!==void 0,i=e.getAgentEntries(a),s=n.articles||[],d=`<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <span class="current">${p(a)}</span></nav>`;if(d+=`<div class="page-head"><div><h1>${p(a)}</h1>`,o&&(d+=`<p class="page-sub"><span class="tag" style="color:var(--cool);background:var(--cool-soft)">remote @ ${p(n.nodeId)}</span></p>`),d+="</div></div>",d+='<div class="stat-strip">',d+=`<div class="stat-cell"><div class="label">Articles</div><div class="number">${n.totalArticles}</div></div>`,d+=`<div class="stat-cell"><div class="label">Entries</div><div class="number">${n.totalEntries}</div></div>`,d+=`<div class="stat-cell"><div class="label">Unabsorbed</div><div class="number">${n.unabsorbed}</div></div>`,d+="</div>",s.length>0){d+='<div class="section-head"><h2>Articles</h2><span class="mono" style="font-size:12px;color:var(--muted)">'+s.length+" total</span></div>";let g=$e(s);for(let[u,x]of g){d+=`<h3 class="display" style="font-size:17px;color:var(--muted);font-weight:500;margin:20px 0 8px">${Se(u)}</h3>`,d+='<div class="agent-card" style="padding:4px 14px"><div class="article-list">';for(let f of x)d+=`<div class="article-row">${H((f.tags||[]).slice(0,3),a)} <a class="article-title" href="/agent/${encodeURIComponent(a)}/article/${encodeURIComponent(f.path)}">${p(f.title)}</a></div>`;d+="</div></div>"}}let l=i.slice(-5).reverse();if(l.length>0){d+='<div class="section-head"><h2>Recent entries</h2><a class="btn ghost" href="/entries">See all \u2192</a></div>';for(let g of l)d+=`<div class="entry-card">
2867
2867
  <div class="meta-line">${g.date} \xB7 via ${p(g.source)} \xB7 <code>${p(g.id)}</code></div>
2868
2868
  <p>${p(g.content.slice(0,300))}${g.content.length>300?"\u2026":""}</p>
2869
2869
  </div>`}let m=e.getAgentWiki(a).lint();if(m.length>0){d+=`<div class="section-head"><h2>Health issues</h2><span class="mono" style="font-size:12px;color:var(--warn)">${m.length}</span></div>`,d+='<div class="health-list">';for(let g of m)d+=`<div class="health-row">
2870
2870
  <span class="kind">${p(g.type)}</span>
2871
2871
  <span class="article">${p(g.article)}</span>
2872
2872
  <span class="msg">${p(g.message)}</span>
2873
- </div>`;d+="</div>"}return A(a,E(r,a),d)}function Yt(e,a,t,r){let n=e.getAgentWiki(a),o=n.readArticle(t);if(!o)return null;let i=r||e.summary(),s=n.rebuildIndex(),d=new Map;for(let u of s.articles)d.set(u.title,u.path);let l=`/agent/${encodeURIComponent(a)}`,m=n.buildBacklinks()[o.meta.title]||[],g=`<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <a href="${l}">${p(a)}</a> <span class="sep">/</span> <span class="current">${p(o.meta.title)}</span></nav>`;if(g+=`<article class="prose"><h1>${p(o.meta.title)}</h1>`,g+='<dl class="meta">',o.meta.type&&(g+=`<dt>Type</dt><dd>${Ta(o.meta.type,a)}</dd>`),o.meta.tags?.length&&(g+=`<dt>Tags</dt><dd>${H(o.meta.tags,a)}</dd>`),o.meta.owner&&(g+=`<dt>Owner</dt><dd>${p(o.meta.owner)}</dd>`),g+=`<dt>Created</dt><dd>${p(o.meta.created||"\u2014")}</dd>`,g+=`<dt>Updated</dt><dd>${p(o.meta.lastUpdated||"\u2014")}</dd>`,o.meta.sources?.length&&(g+=`<dt>Sources</dt><dd>${o.meta.sources.length} entries</dd>`),g+="</dl>",g+=oe(o.content,d,l),m.length>0){g+='<div class="backlinks"><h4>Pages that link here</h4><ul>';for(let u of m){let x=n.readArticle(u);g+=`<li><a href="${l}/article/${encodeURIComponent(u)}">${p(x?.meta.title||u)}</a></li>`}g+="</ul></div>"}return g+="</article>",A(o.meta.title,E(i,`${a}/${t}`),g)}function Jt(e,a){let t=a||e.summary(),n=e.getSharedStore().listEntries(),o='<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <span class="current">Entries</span></nav>';o+='<div class="page-head"><div><h1>All raw entries</h1><p class="page-sub">Every conversation line that the ingest pipeline captured. Absorb compiles these into typed articles nightly.</p></div></div>';let i=new Map;for(let s of n){let d=i.get(s.date)||[];d.push(s),i.set(s.date,d)}for(let[s,d]of[...i].reverse()){o+=`<div class="section-head"><h2>${s}</h2><span class="mono" style="font-size:12px;color:var(--muted)">${d.length} entries</span></div>`;for(let l of d)o+=`<div class="entry-card">
2873
+ </div>`;d+="</div>"}return A(a,E(r,a),d)}function Jt(e,a,t,r){let n=e.getAgentWiki(a),o=n.readArticle(t);if(!o)return null;let i=r||e.summary(),s=n.rebuildIndex(),d=new Map;for(let u of s.articles)d.set(u.title,u.path);let l=`/agent/${encodeURIComponent(a)}`,m=n.buildBacklinks()[o.meta.title]||[],g=`<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <a href="${l}">${p(a)}</a> <span class="sep">/</span> <span class="current">${p(o.meta.title)}</span></nav>`;if(g+=`<article class="prose"><h1>${p(o.meta.title)}</h1>`,g+='<dl class="meta">',o.meta.type&&(g+=`<dt>Type</dt><dd>${Ia(o.meta.type,a)}</dd>`),o.meta.tags?.length&&(g+=`<dt>Tags</dt><dd>${H(o.meta.tags,a)}</dd>`),o.meta.owner&&(g+=`<dt>Owner</dt><dd>${p(o.meta.owner)}</dd>`),g+=`<dt>Created</dt><dd>${p(o.meta.created||"\u2014")}</dd>`,g+=`<dt>Updated</dt><dd>${p(o.meta.lastUpdated||"\u2014")}</dd>`,o.meta.sources?.length&&(g+=`<dt>Sources</dt><dd>${o.meta.sources.length} entries</dd>`),g+="</dl>",g+=oe(o.content,d,l),m.length>0){g+='<div class="backlinks"><h4>Pages that link here</h4><ul>';for(let u of m){let x=n.readArticle(u);g+=`<li><a href="${l}/article/${encodeURIComponent(u)}">${p(x?.meta.title||u)}</a></li>`}g+="</ul></div>"}return g+="</article>",A(o.meta.title,E(i,`${a}/${t}`),g)}function Gt(e,a){let t=a||e.summary(),n=e.getSharedStore().listEntries(),o='<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <span class="current">Entries</span></nav>';o+='<div class="page-head"><div><h1>All raw entries</h1><p class="page-sub">Every conversation line that the ingest pipeline captured. Absorb compiles these into typed articles nightly.</p></div></div>';let i=new Map;for(let s of n){let d=i.get(s.date)||[];d.push(s),i.set(s.date,d)}for(let[s,d]of[...i].reverse()){o+=`<div class="section-head"><h2>${s}</h2><span class="mono" style="font-size:12px;color:var(--muted)">${d.length} entries</span></div>`;for(let l of d)o+=`<div class="entry-card">
2874
2874
  <div class="meta-line">
2875
2875
  <a href="/agent/${encodeURIComponent(l.agentId)}">${p(l.agentId)}</a>
2876
2876
  \xB7 via ${p(l.source)} \xB7 <code>${p(l.id)}</code>
2877
2877
  </div>
2878
2878
  <p>${p(l.content.slice(0,400))}${l.content.length>400?"\u2026":""}</p>
2879
- </div>`}return A("All Entries",E(t),o)}function Gt(e,a,t){let r=t||e.summary(),n='<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <span class="current">Search</span></nav>';n+=`<div class="page-head"><div><h1>\u201C${p(a)}\u201D</h1><p class="page-sub">Full-text search across every agent's wiki.</p></div></div>`;let o=0,i=[];for(let s of r){let l=e.getAgentWiki(s.agentId).findRelevant(a,void 0,10);if(l.length>0){i.push(`<div class="section-head"><h2>${p(s.agentId)}</h2><span class="mono" style="font-size:12px;color:var(--muted)">${l.length} match${l.length===1?"":"es"}</span></div>`);for(let c of l){let m=`/agent/${encodeURIComponent(s.agentId)}`;i.push(`<div class="entry-card">
2879
+ </div>`}return A("All Entries",E(t),o)}function Xt(e,a,t){let r=t||e.summary(),n='<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <span class="current">Search</span></nav>';n+=`<div class="page-head"><div><h1>\u201C${p(a)}\u201D</h1><p class="page-sub">Full-text search across every agent's wiki.</p></div></div>`;let o=0,i=[];for(let s of r){let l=e.getAgentWiki(s.agentId).findRelevant(a,void 0,10);if(l.length>0){i.push(`<div class="section-head"><h2>${p(s.agentId)}</h2><span class="mono" style="font-size:12px;color:var(--muted)">${l.length} match${l.length===1?"":"es"}</span></div>`);for(let c of l){let m=`/agent/${encodeURIComponent(s.agentId)}`;i.push(`<div class="entry-card">
2880
2880
  <div class="meta-line">${H((c.meta.tags||[]).slice(0,3),s.agentId)}</div>
2881
2881
  <h3><a href="${m}/article/${encodeURIComponent(c.path)}">${p(c.meta.title)}</a></h3>
2882
2882
  <p>${p(c.content.slice(0,240))}\u2026</p>
2883
- </div>`)}o+=l.length}}return n+=i.join(""),o===0&&(n+='<p style="color:var(--muted);margin-top:24px">No matching articles found.</p>'),A(`Search: ${a}`,E(r),n,a)}function Xt(e,a,t){let r=t||e.summary(),n='<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <span class="current">Tag</span></nav>';n+=`<div class="page-head"><div><h1>${p(a)}</h1><p class="page-sub">All articles tagged <span class="tag">${p(a)}</span>, across every agent.</p></div></div>`;let o=0;for(let i of r){let s;try{s=e.getAgentWiki(i.agentId)}catch{continue}let d=s.findByTags([a],void 0,100);if(d.length!==0){n+=`<div class="section-head"><h2>${p(i.agentId)}</h2><span class="mono" style="font-size:12px;color:var(--muted)">${d.length}</span></div>`;for(let l of d){let c=`/agent/${encodeURIComponent(i.agentId)}`;n+=`<div class="entry-card">
2883
+ </div>`)}o+=l.length}}return n+=i.join(""),o===0&&(n+='<p style="color:var(--muted);margin-top:24px">No matching articles found.</p>'),A(`Search: ${a}`,E(r),n,a)}function Vt(e,a,t){let r=t||e.summary(),n='<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <span class="current">Tag</span></nav>';n+=`<div class="page-head"><div><h1>${p(a)}</h1><p class="page-sub">All articles tagged <span class="tag">${p(a)}</span>, across every agent.</p></div></div>`;let o=0;for(let i of r){let s;try{s=e.getAgentWiki(i.agentId)}catch{continue}let d=s.findByTags([a],void 0,100);if(d.length!==0){n+=`<div class="section-head"><h2>${p(i.agentId)}</h2><span class="mono" style="font-size:12px;color:var(--muted)">${d.length}</span></div>`;for(let l of d){let c=`/agent/${encodeURIComponent(i.agentId)}`;n+=`<div class="entry-card">
2884
2884
  <div class="meta-line">${H((l.meta.tags||[]).slice(0,6),i.agentId)}</div>
2885
2885
  <h3><a href="${c}/article/${encodeURIComponent(l.path)}">${p(l.meta.title)}</a></h3>
2886
- </div>`}o+=d.length}}return o===0&&(n+=`<p style="color:var(--muted);margin-top:24px">No articles tagged <code>${p(a)}</code>.</p>`),A(`Tag: ${a}`,E(r),n)}function Vt(e,a,t,r){let n=r||e.summary(),o;try{o=e.getAgentWiki(a)}catch{return A(`Tag: ${t}`,E(n),`<h1>Agent not found: ${p(a)}</h1>`)}let i=o.findByTags([t],void 0,100),s=`/agent/${encodeURIComponent(a)}`,d=`<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <a href="${s}">${p(a)}</a> <span class="sep">/</span> <span class="current">${p(t)}</span></nav>`;d+=`<div class="page-head"><div><h1>${p(t)}</h1><p class="page-sub">${i.length} article${i.length===1?"":"s"} tagged <code>${p(t)}</code> in <b>${p(a)}</b>.</p></div></div>`;for(let l of i)d+=`<div class="entry-card">
2886
+ </div>`}o+=d.length}}return o===0&&(n+=`<p style="color:var(--muted);margin-top:24px">No articles tagged <code>${p(a)}</code>.</p>`),A(`Tag: ${a}`,E(r),n)}function Qt(e,a,t,r){let n=r||e.summary(),o;try{o=e.getAgentWiki(a)}catch{return A(`Tag: ${t}`,E(n),`<h1>Agent not found: ${p(a)}</h1>`)}let i=o.findByTags([t],void 0,100),s=`/agent/${encodeURIComponent(a)}`,d=`<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <a href="${s}">${p(a)}</a> <span class="sep">/</span> <span class="current">${p(t)}</span></nav>`;d+=`<div class="page-head"><div><h1>${p(t)}</h1><p class="page-sub">${i.length} article${i.length===1?"":"s"} tagged <code>${p(t)}</code> in <b>${p(a)}</b>.</p></div></div>`;for(let l of i)d+=`<div class="entry-card">
2887
2887
  <div class="meta-line">${H((l.meta.tags||[]).slice(0,6),a)}</div>
2888
2888
  <h3><a href="${s}/article/${encodeURIComponent(l.path)}">${p(l.meta.title)}</a></h3>
2889
- </div>`;return A(`${a} \xB7 ${t}`,E(n),d)}function B(e,a,t){let r=e.rebuildIndex(),n=_e(r.articles.map(i=>({title:i.title,path:i.path,tags:i.tags}))),o='<div class="nav-section">';o+=`<div class="nav-section-title">${p(a)}</div>`,o+=`<a class="nav-item${t?"":" active"}" href="/">Home</a>`,o+='<a class="nav-item" href="/lint">Health check</a>',o+="</div>";for(let[i,s]of n){o+='<div class="nav-section">',o+=`<div class="nav-section-title">${$e(i)}</div>`;for(let d of s){let l=d.path===t;o+=`<a class="nav-item${l?" active":""}" href="/article/${encodeURIComponent(d.path)}">${p(d.title)}</a>`}o+="</div>"}return o}function Qt(e){let{wikiDir:a,agentFilter:t,peers:r=[],mode:n="graph",pathPrefix:o=""}=e,i=o.replace(/\/+$/,""),s=new De(a,void 0,n),d=new ne(s,a),l=r.length>0?new te(r):null;return async(c,m)=>{let g=new URL(c.url||"/","http://localhost"),u=decodeURIComponent(g.pathname),x=i&&u.startsWith(i)?u.slice(i.length)||"/":u,f=null,C=200;try{if(x.startsWith("/remote/")&&l){let w=x.slice(8).split("/article/");if(w.length===2){let[v,b]=w,h=v.indexOf("/"),$=decodeURIComponent(v.slice(0,h)),y=v.slice(h+1),S=await l.getRemoteArticle($,y,b);if(S){let O=await l.getRemoteAgents(),Y=[...s.summary(),...O.map(I=>({...I,agentId:`${I.agentId} @${I.nodeId}`}))],T=`<div class="breadcrumb"><a href="/">Hub</a> / <span class="tag">remote</span> ${p(y)} @ ${p($)}</div>`;T+=`<h1>${p(S.meta.title)}</h1>`,T+='<dl class="meta">',T+=`<dt>Tags</dt><dd>${(S.meta.tags||[]).map(I=>`<span class="tag">${I}</span>`).join(" ")}</dd>`,T+=`<dt>Owner</dt><dd>${p(S.meta.owner)}</dd>`,T+=`<dt>Source</dt><dd><span class="tag">remote</span> ${p($)}</dd>`,T+=`<dt>Updated</dt><dd>${S.meta.lastUpdated}</dd>`,T+="</dl>";let R=new Map;T+=oe(S.content,R),f=A(S.meta.title,E(Y),T)}}}if(!f&&t){let w=s.getAgentWiki(t);if(x==="/"||x===""){let v=w.rebuildIndex(),b=s.getAgentEntries(t),h=`<h1>${p(t)}</h1>`;if(h+='<div class="stats">',h+=`<div class="stat-card"><div class="number">${v.articles.length}</div><div class="label">Articles</div></div>`,h+=`<div class="stat-card"><div class="number">${b.length}</div><div class="label">Entries</div></div>`,h+="</div>",v.articles.length>0){h+="<h2>Articles</h2><table><tr><th>Title</th><th>Type</th><th>Updated</th></tr>";for(let $ of v.articles)h+=`<tr><td><a href="/article/${encodeURIComponent($.path)}">${p($.title)}</a></td><td><span class="tag">${($.tags||[]).slice(0,3).join(", ")}</span></td><td>${$.lastUpdated||""}</td></tr>`;h+="</table>"}f=A(t,B(w,t),h)}else if(x.startsWith("/article/")){let v=x.slice(9),b=w.readArticle(v);if(b){let h=w.rebuildIndex(),$=new Map;for(let S of h.articles)$.set(S.title,S.path);let y=`<h1>${p(b.meta.title)}</h1>`;y+='<dl class="meta">',y+=`<dt>Tags</dt><dd>${(b.meta.tags||[]).map(S=>`<span class="tag">${S}</span>`).join(" ")}</dd>`,y+=`<dt>Updated</dt><dd>${b.meta.lastUpdated}</dd>`,b.meta.sources?.length&&(y+=`<dt>Sources</dt><dd>${b.meta.sources.length} entries</dd>`),y+="</dl>",y+=oe(b.content,$),f=A(b.meta.title,B(w,t,v),y)}}else if(x==="/lint"){let v=w.lint(),b="<h1>Health Check</h1>";if(v.length===0)b+='<p style="color:green;">No issues.</p>';else{b+="<table><tr><th>Type</th><th>Article</th><th>Issue</th></tr>";for(let h of v)b+=`<tr><td><span class="tag">${h.type}</span></td><td>${p(h.article)}</td><td>${p(h.message)}</td></tr>`;b+="</table>"}f=A("Health Check",B(w,t),b)}else if(x==="/search"){let v=g.searchParams.get("q")||"",b=await w.findRelevantReranked(v,void 0,20),h=`<h1>Search: "${p(v)}"</h1>`;for(let $ of b)h+=`<div class="entry-card"><h3><a href="/article/${encodeURIComponent($.path)}">${p($.meta.title)}</a></h3><p>${p($.content.slice(0,200))}...</p></div>`;b.length===0&&(h+="<p>No results.</p>"),f=A(`Search: ${v}`,B(w,t),h)}else if(x.startsWith("/tag/")){let v=decodeURIComponent(x.slice(5)),b=w.findByTags([v],void 0,100),h=`<h1>Tag: <a class="tag" href="#">${p(v)}</a></h1>`;h+=`<p>${b.length} article${b.length===1?"":"s"} tagged <code>${p(v)}</code></p>`;for(let $ of b)h+=`<div class="entry-card"><h3><a href="/article/${encodeURIComponent($.path)}">${p($.meta.title)}</a></h3><div class="meta-line">${H(($.meta.tags||[]).slice(0,6))}</div></div>`;b.length===0&&(h+="<p>No articles with this tag.</p>"),f=A(`Tag: ${v}`,B(w,t),h)}}else if(!f&&(f=d.handle(x,g.searchParams))===null){let w=l?await l.getRemoteAgents():[],v=s.summary(),b=new Map(v.map(y=>[y.agentId,y])),h=[],$=new Set;for(let y of v){let S=w.find(O=>O.agentId===y.agentId);S&&S.totalArticles>y.totalArticles?h.push({...S,totalEntries:Math.max(y.totalEntries,S.totalEntries),unabsorbed:Math.max(y.unabsorbed,S.unabsorbed)}):h.push(y),$.add(y.agentId)}for(let y of w)$.has(y.agentId)||(h.push(y),$.add(y.agentId));if(x==="/agents")f=qt(s,h,w);else if(x==="/entries")f=Jt(s,h);else if(x==="/search")f=Gt(s,g.searchParams.get("q")||"",h);else if(x.startsWith("/tag/"))f=Xt(s,decodeURIComponent(x.slice(5)),h);else if(x.match(/^\/agent\/[^/]+\/tag\/.+/)){let y=x.match(/^\/agent\/([^/]+)\/tag\/(.+)$/);f=Vt(s,decodeURIComponent(y[1]),decodeURIComponent(y[2]),h)}else if(x.startsWith("/agent/")){let y=x.slice(7),S=y.indexOf("/article/");if(S===-1)f=Kt(s,y,h);else{let O=y.slice(0,S),Y=y.slice(S+9);if(f=Yt(s,O,Y,h),!f&&l){let T=w.find(R=>R.agentId===O);if(T){let R=await l.getRemoteArticle(T.peerUrl,O,Y);if(R){let I=`<div class="breadcrumb"><a href="/">Hub</a> / <span class="tag">remote @ ${p(T.nodeId)}</span> / ${p(O)}</div>`;I+=`<h1>${p(R.meta.title)}</h1>`,I+='<dl class="meta">',I+=`<dt>Tags</dt><dd>${(R.meta.tags||[]).map(Ga=>`<span class="tag">${Ga}</span>`).join(" ")}</dd>`,I+=`<dt>Source</dt><dd><span class="tag">remote</span> ${p(T.nodeId)}</dd>`,I+=`<dt>Updated</dt><dd>${R.meta.lastUpdated}</dd>`,I+="</dl>",I+=oe(R.content,new Map),f=A(R.meta.title,E(h),I)}}}}}}if(!f){C=404;let w=t?B(s.getAgentWiki(t),t):E(s.summary());f=A("Not Found",w,"<h1>Page not found</h1>")}}catch(w){C=500,f=A("Error","",`<h1>Error</h1><pre>${p(w.message)}</pre>`)}if(C===200&&e.curator){let w=Zt(s,d,x,t);w&&(f=Ca(f,w,e.curatorEndpoint,e.curatorToken?.(c)))}m.writeHead(C,{"Content-Type":"text/html; charset=utf-8"}),m.end(i?er(f,i):f)}}function Zt(e,a,t,r){let n,o;if(r&&t.startsWith("/article/"))n=r,o=t.slice(9);else if(!r&&t.startsWith("/agent/")){let d=t.match(/^\/agent\/([^/]+)\/article\/(.+)$/);d&&(n=d[1],o=d[2])}else if(!r)return a.pageAt(t);if(!n||!o||!e.listAgents([]).includes(n))return null;let i=e.getAgentWiki(n);if(!Ne(i.baseDir,o))return null;let s=i.readArticle(o);return s?{agentId:n,path:o,title:s.meta.title}:null}function er(e,a){e=e.replace(/(\s(?:href|action)=")\/(?!\/)/g,`$1${a}/`),e=e.replace(new RegExp(`(${a})${a}/`,"g"),`${a}/`);let t=`<a href="/admin" style="position:fixed;top:10px;right:14px;z-index:9999;padding:5px 11px;background:rgba(0,0,0,0.55);color:#fff;font:12px/1.2 'IBM Plex Sans',system-ui,sans-serif;text-decoration:none;border-radius:6px;border:1px solid rgba(255,255,255,0.18);backdrop-filter:blur(6px)">\u2190 Dashboard</a>`;return e=e.replace(/<body([^>]*)>/,`<body$1>${t}`),e}function co(e,a=4200,t,r=[],n="graph"){let o=Qt({wikiDir:e,agentFilter:t,peers:r,mode:n});Lt((s,d)=>{o(s,d)}).listen(a)}import{existsSync as ar,readFileSync as tr}from"fs";ce();function fo(e){let a=q(e),t={};if(ar(a))try{t=F(JSON.parse(tr(a,"utf-8")))}catch{t={}}let r=t?.workflows?.required??{},n={};for(let[o,i]of Object.entries(r.agents??{}))typeof i=="boolean"&&(n[o]=i);return{enabled:typeof r.enabled=="boolean"?r.enabled:G.enabled,agents:n,exemptQuestions:typeof r.exemptQuestions=="boolean"?r.exemptQuestions:G.exemptQuestions,retentionDays:Number.isInteger(r.retentionDays)&&r.retentionDays>=0?r.retentionDays:G.retentionDays,engine:t?.workflows?.enabled===!0}}async function ho(e,a={}){return e.retentionDays!==void 0&&!(Number.isInteger(e.retentionDays)&&e.retentionDays>=0&&e.retentionDays<=3650)?{success:!1,error:"retentionDays is a whole number of days from 0 to 3650"}:e.agent&&!/^[A-Za-z0-9_.@-]{1,80}$/.test(e.agent.id)?{success:!1,error:`"${e.agent.id}" is not an agent id`}:J(t=>{let r=t.workflows??={},n=r.required??={};if(e.enabled!==void 0&&(n.enabled=e.enabled),e.exemptQuestions!==void 0&&(n.exemptQuestions=e.exemptQuestions),e.retentionDays!==void 0&&(n.retentionDays=e.retentionDays),e.agent){let o=n.agents??={};e.agent.value===null?delete o[e.agent.id]:o[e.agent.id]=e.agent.value}(e.enabled===!0||e.agent?.value===!0)&&(r.enabled=!0)},{configPath:a.configPath,reload:a.reload})}var rr={"claude-code":{bin:"claude",login:"Install Claude Code (https://claude.com/claude-code) and run `claude` once to log in"},"codex-cli":{bin:"codex",login:"Install Codex CLI and run `codex login`"},opencode:{bin:"opencode",login:"Install OpenCode and run `opencode auth login`"}};function nr(e){if(typeof e!="string")return null;let a=e.match(/^\$\{(\w+)\}$/);return a?a[1]:null}function vo(e){let a=e.rawConfig?.agents?.[e.agentId];if(!a)return{ready:!1,hint:`No agent "${e.agentId}" in agentx.json.`};let t=String(a.tier||""),r=rr[t];if(r)return e.hasBinary(r.bin)?e.cliLoggedIn?.(r.bin)===!1?{ready:!1,need:"cli",cli:r.bin,hint:`${r.bin} is installed but not logged in. In a terminal, run \`${r.bin}\` once and log in, then press Check again.`}:{ready:!0}:{ready:!1,need:"cli",cli:r.bin,hint:`${r.login}, then press Check again.`};if(t==="sdk"||t==="orchestrator"){let n=a.provider||(t==="sdk"?"claude":"claude-code"),o=e.rawConfig?.providers?.[n];if(t==="orchestrator"&&!(o&&"apiKey"in o))return{ready:!0};let i=o?.apiKey,s=nr(i);return s?e.env[s]||e.dotenv[s]?{ready:!0}:{ready:!1,need:"key",envVar:s,hint:`Paste an API key for "${n}". It is saved to .env as ${s} on this computer only.`}:typeof i=="string"&&i.trim()?{ready:!0}:{ready:!1,hint:`Set providers.${n}.apiKey in agentx.json.`}}return{ready:!0}}import{appendFileSync as or,chmodSync as ir,existsSync as Ia,readFileSync as za,writeFileSync as sr}from"fs";function dr(e){return Ia(e)?Object.fromEntries(Pe(za(e,"utf-8"))):{}}function _o(e,a,t){if(!/^[A-Z_][A-Z0-9_]*$/.test(a))throw new Error(`not an environment variable name: ${a}`);if(!t||/[\r\n]/.test(t))throw new Error("the value must be one non-empty line");if(dr(e)[a])return!1;if(!Ia(e))return sr(e,`# AgentX environment variables
2889
+ </div>`;return A(`${a} \xB7 ${t}`,E(n),d)}function B(e,a,t){let r=e.rebuildIndex(),n=$e(r.articles.map(i=>({title:i.title,path:i.path,tags:i.tags}))),o='<div class="nav-section">';o+=`<div class="nav-section-title">${p(a)}</div>`,o+=`<a class="nav-item${t?"":" active"}" href="/">Home</a>`,o+='<a class="nav-item" href="/lint">Health check</a>',o+="</div>";for(let[i,s]of n){o+='<div class="nav-section">',o+=`<div class="nav-section-title">${Se(i)}</div>`;for(let d of s){let l=d.path===t;o+=`<a class="nav-item${l?" active":""}" href="/article/${encodeURIComponent(d.path)}">${p(d.title)}</a>`}o+="</div>"}return o}function Zt(e){let{wikiDir:a,agentFilter:t,peers:r=[],mode:n="graph",pathPrefix:o=""}=e,i=o.replace(/\/+$/,""),s=new Me(a,void 0,n),d=new ne(s,a),l=r.length>0?new te(r):null;return async(c,m)=>{let g=new URL(c.url||"/","http://localhost"),u=decodeURIComponent(g.pathname),x=i&&u.startsWith(i)?u.slice(i.length)||"/":u,f=null,C=200;try{if(x.startsWith("/remote/")&&l){let w=x.slice(8).split("/article/");if(w.length===2){let[v,b]=w,h=v.indexOf("/"),$=decodeURIComponent(v.slice(0,h)),y=v.slice(h+1),S=await l.getRemoteArticle($,y,b);if(S){let O=await l.getRemoteAgents(),Y=[...s.summary(),...O.map(I=>({...I,agentId:`${I.agentId} @${I.nodeId}`}))],T=`<div class="breadcrumb"><a href="/">Hub</a> / <span class="tag">remote</span> ${p(y)} @ ${p($)}</div>`;T+=`<h1>${p(S.meta.title)}</h1>`,T+='<dl class="meta">',T+=`<dt>Tags</dt><dd>${(S.meta.tags||[]).map(I=>`<span class="tag">${I}</span>`).join(" ")}</dd>`,T+=`<dt>Owner</dt><dd>${p(S.meta.owner)}</dd>`,T+=`<dt>Source</dt><dd><span class="tag">remote</span> ${p($)}</dd>`,T+=`<dt>Updated</dt><dd>${S.meta.lastUpdated}</dd>`,T+="</dl>";let R=new Map;T+=oe(S.content,R),f=A(S.meta.title,E(Y),T)}}}if(!f&&t){let w=s.getAgentWiki(t);if(x==="/"||x===""){let v=w.rebuildIndex(),b=s.getAgentEntries(t),h=`<h1>${p(t)}</h1>`;if(h+='<div class="stats">',h+=`<div class="stat-card"><div class="number">${v.articles.length}</div><div class="label">Articles</div></div>`,h+=`<div class="stat-card"><div class="number">${b.length}</div><div class="label">Entries</div></div>`,h+="</div>",v.articles.length>0){h+="<h2>Articles</h2><table><tr><th>Title</th><th>Type</th><th>Updated</th></tr>";for(let $ of v.articles)h+=`<tr><td><a href="/article/${encodeURIComponent($.path)}">${p($.title)}</a></td><td><span class="tag">${($.tags||[]).slice(0,3).join(", ")}</span></td><td>${$.lastUpdated||""}</td></tr>`;h+="</table>"}f=A(t,B(w,t),h)}else if(x.startsWith("/article/")){let v=x.slice(9),b=w.readArticle(v);if(b){let h=w.rebuildIndex(),$=new Map;for(let S of h.articles)$.set(S.title,S.path);let y=`<h1>${p(b.meta.title)}</h1>`;y+='<dl class="meta">',y+=`<dt>Tags</dt><dd>${(b.meta.tags||[]).map(S=>`<span class="tag">${S}</span>`).join(" ")}</dd>`,y+=`<dt>Updated</dt><dd>${b.meta.lastUpdated}</dd>`,b.meta.sources?.length&&(y+=`<dt>Sources</dt><dd>${b.meta.sources.length} entries</dd>`),y+="</dl>",y+=oe(b.content,$),f=A(b.meta.title,B(w,t,v),y)}}else if(x==="/lint"){let v=w.lint(),b="<h1>Health Check</h1>";if(v.length===0)b+='<p style="color:green;">No issues.</p>';else{b+="<table><tr><th>Type</th><th>Article</th><th>Issue</th></tr>";for(let h of v)b+=`<tr><td><span class="tag">${h.type}</span></td><td>${p(h.article)}</td><td>${p(h.message)}</td></tr>`;b+="</table>"}f=A("Health Check",B(w,t),b)}else if(x==="/search"){let v=g.searchParams.get("q")||"",b=await w.findRelevantReranked(v,void 0,20),h=`<h1>Search: "${p(v)}"</h1>`;for(let $ of b)h+=`<div class="entry-card"><h3><a href="/article/${encodeURIComponent($.path)}">${p($.meta.title)}</a></h3><p>${p($.content.slice(0,200))}...</p></div>`;b.length===0&&(h+="<p>No results.</p>"),f=A(`Search: ${v}`,B(w,t),h)}else if(x.startsWith("/tag/")){let v=decodeURIComponent(x.slice(5)),b=w.findByTags([v],void 0,100),h=`<h1>Tag: <a class="tag" href="#">${p(v)}</a></h1>`;h+=`<p>${b.length} article${b.length===1?"":"s"} tagged <code>${p(v)}</code></p>`;for(let $ of b)h+=`<div class="entry-card"><h3><a href="/article/${encodeURIComponent($.path)}">${p($.meta.title)}</a></h3><div class="meta-line">${H(($.meta.tags||[]).slice(0,6))}</div></div>`;b.length===0&&(h+="<p>No articles with this tag.</p>"),f=A(`Tag: ${v}`,B(w,t),h)}}else if(!f&&(f=d.handle(x,g.searchParams))===null){let w=l?await l.getRemoteAgents():[],v=s.summary(),b=new Map(v.map(y=>[y.agentId,y])),h=[],$=new Set;for(let y of v){let S=w.find(O=>O.agentId===y.agentId);S&&S.totalArticles>y.totalArticles?h.push({...S,totalEntries:Math.max(y.totalEntries,S.totalEntries),unabsorbed:Math.max(y.unabsorbed,S.unabsorbed)}):h.push(y),$.add(y.agentId)}for(let y of w)$.has(y.agentId)||(h.push(y),$.add(y.agentId));if(x==="/agents")f=Kt(s,h,w);else if(x==="/entries")f=Gt(s,h);else if(x==="/search")f=Xt(s,g.searchParams.get("q")||"",h);else if(x.startsWith("/tag/"))f=Vt(s,decodeURIComponent(x.slice(5)),h);else if(x.match(/^\/agent\/[^/]+\/tag\/.+/)){let y=x.match(/^\/agent\/([^/]+)\/tag\/(.+)$/);f=Qt(s,decodeURIComponent(y[1]),decodeURIComponent(y[2]),h)}else if(x.startsWith("/agent/")){let y=x.slice(7),S=y.indexOf("/article/");if(S===-1)f=Yt(s,y,h);else{let O=y.slice(0,S),Y=y.slice(S+9);if(f=Jt(s,O,Y,h),!f&&l){let T=w.find(R=>R.agentId===O);if(T){let R=await l.getRemoteArticle(T.peerUrl,O,Y);if(R){let I=`<div class="breadcrumb"><a href="/">Hub</a> / <span class="tag">remote @ ${p(T.nodeId)}</span> / ${p(O)}</div>`;I+=`<h1>${p(R.meta.title)}</h1>`,I+='<dl class="meta">',I+=`<dt>Tags</dt><dd>${(R.meta.tags||[]).map(Xa=>`<span class="tag">${Xa}</span>`).join(" ")}</dd>`,I+=`<dt>Source</dt><dd><span class="tag">remote</span> ${p(T.nodeId)}</dd>`,I+=`<dt>Updated</dt><dd>${R.meta.lastUpdated}</dd>`,I+="</dl>",I+=oe(R.content,new Map),f=A(R.meta.title,E(h),I)}}}}}}if(!f){C=404;let w=t?B(s.getAgentWiki(t),t):E(s.summary());f=A("Not Found",w,"<h1>Page not found</h1>")}}catch(w){C=500,f=A("Error","",`<h1>Error</h1><pre>${p(w.message)}</pre>`)}if(C===200&&e.curator){let w=er(s,d,x,t);w&&(f=Ta(f,w,e.curatorEndpoint,e.curatorToken?.(c)))}m.writeHead(C,{"Content-Type":"text/html; charset=utf-8"}),m.end(i?ar(f,i):f)}}function er(e,a,t,r){let n,o;if(r&&t.startsWith("/article/"))n=r,o=t.slice(9);else if(!r&&t.startsWith("/agent/")){let d=t.match(/^\/agent\/([^/]+)\/article\/(.+)$/);d&&(n=d[1],o=d[2])}else if(!r)return a.pageAt(t);if(!n||!o||!e.listAgents([]).includes(n))return null;let i=e.getAgentWiki(n);if(!Le(i.baseDir,o))return null;let s=i.readArticle(o);return s?{agentId:n,path:o,title:s.meta.title}:null}function ar(e,a){e=e.replace(/(\s(?:href|action)=")\/(?!\/)/g,`$1${a}/`),e=e.replace(new RegExp(`(${a})${a}/`,"g"),`${a}/`);let t=`<a href="/admin" style="position:fixed;top:10px;right:14px;z-index:9999;padding:5px 11px;background:rgba(0,0,0,0.55);color:#fff;font:12px/1.2 'IBM Plex Sans',system-ui,sans-serif;text-decoration:none;border-radius:6px;border:1px solid rgba(255,255,255,0.18);backdrop-filter:blur(6px)">\u2190 Dashboard</a>`;return e=e.replace(/<body([^>]*)>/,`<body$1>${t}`),e}function xo(e,a=4200,t,r=[],n="graph"){let o=Zt({wikiDir:e,agentFilter:t,peers:r,mode:n});Wt((s,d)=>{o(s,d)}).listen(a)}import{existsSync as tr,readFileSync as rr}from"fs";ce();function bo(e){let a=q(e),t={};if(tr(a))try{t=F(JSON.parse(rr(a,"utf-8")))}catch{t={}}let r=t?.workflows?.required??{},n={};for(let[o,i]of Object.entries(r.agents??{}))typeof i=="boolean"&&(n[o]=i);return{enabled:typeof r.enabled=="boolean"?r.enabled:G.enabled,agents:n,exemptQuestions:typeof r.exemptQuestions=="boolean"?r.exemptQuestions:G.exemptQuestions,retentionDays:Number.isInteger(r.retentionDays)&&r.retentionDays>=0?r.retentionDays:G.retentionDays,engine:t?.workflows?.enabled===!0}}async function vo(e,a={}){return e.retentionDays!==void 0&&!(Number.isInteger(e.retentionDays)&&e.retentionDays>=0&&e.retentionDays<=3650)?{success:!1,error:"retentionDays is a whole number of days from 0 to 3650"}:e.agent&&!/^[A-Za-z0-9_.@-]{1,80}$/.test(e.agent.id)?{success:!1,error:`"${e.agent.id}" is not an agent id`}:J(t=>{let r=t.workflows??={},n=r.required??={};if(e.enabled!==void 0&&(n.enabled=e.enabled),e.exemptQuestions!==void 0&&(n.exemptQuestions=e.exemptQuestions),e.retentionDays!==void 0&&(n.retentionDays=e.retentionDays),e.agent){let o=n.agents??={};e.agent.value===null?delete o[e.agent.id]:o[e.agent.id]=e.agent.value}(e.enabled===!0||e.agent?.value===!0)&&(r.enabled=!0)},{configPath:a.configPath,reload:a.reload})}var nr={"claude-code":{bin:"claude",login:"Install Claude Code (https://claude.com/claude-code) and run `claude` once to log in"},"codex-cli":{bin:"codex",login:"Install Codex CLI and run `codex login`"},opencode:{bin:"opencode",login:"Install OpenCode and run `opencode auth login`"}};function or(e){if(typeof e!="string")return null;let a=e.match(/^\$\{(\w+)\}$/);return a?a[1]:null}function yo(e){let a=e.rawConfig?.agents?.[e.agentId];if(!a)return{ready:!1,hint:`No agent "${e.agentId}" in agentx.json.`};let t=String(a.tier||""),r=nr[t];if(r)return e.hasBinary(r.bin)?e.cliLoggedIn?.(r.bin)===!1?{ready:!1,need:"cli",cli:r.bin,hint:`${r.bin} is installed but not logged in. In a terminal, run \`${r.bin}\` once and log in, then press Check again.`}:{ready:!0}:{ready:!1,need:"cli",cli:r.bin,hint:`${r.login}, then press Check again.`};if(t==="sdk"||t==="orchestrator"){let n=a.provider||(t==="sdk"?"claude":"claude-code"),o=e.rawConfig?.providers?.[n];if(t==="orchestrator"&&!(o&&"apiKey"in o))return{ready:!0};let i=o?.apiKey,s=or(i);return s?e.env[s]||e.dotenv[s]?{ready:!0}:{ready:!1,need:"key",envVar:s,hint:`Paste an API key for "${n}". It is saved to .env as ${s} on this computer only.`}:typeof i=="string"&&i.trim()?{ready:!0}:{ready:!1,hint:`Set providers.${n}.apiKey in agentx.json.`}}return{ready:!0}}import{appendFileSync as ir,chmodSync as sr,existsSync as za,readFileSync as Pa,writeFileSync as dr}from"fs";function lr(e){return za(e)?Object.fromEntries(Ee(Pa(e,"utf-8"))):{}}function So(e,a,t){if(!/^[A-Z_][A-Z0-9_]*$/.test(a))throw new Error(`not an environment variable name: ${a}`);if(!t||/[\r\n]/.test(t))throw new Error("the value must be one non-empty line");if(lr(e)[a])return!1;if(!za(e))return dr(e,`# AgentX environment variables
2890
2890
  # (Never commit this file: it contains secrets.)
2891
2891
 
2892
2892
  ${a}=${t}
2893
- `,{mode:384}),!0;try{ir(e,384)}catch{}let r=za(e,"utf-8"),n=r===""||r.endsWith(`
2893
+ `,{mode:384}),!0;try{sr(e,384)}catch{}let r=Pa(e,"utf-8"),n=r===""||r.endsWith(`
2894
2894
  `)?"":`
2895
- `;return or(e,`${n}${a}=${t}
2896
- `),!0}import{execFileSync as lr}from"child_process";function Co(e){if(e!=="claude")return null;let a=qe(e);if(!a)return null;try{let t=lr(a,["auth","status"],{encoding:"utf-8",timeout:1e4,stdio:["ignore","pipe","ignore"]});return Pa(t)}catch(t){return typeof t?.stdout=="string"?Pa(t.stdout):null}}function Pa(e){try{let a=JSON.parse(e);return typeof a?.loggedIn=="boolean"?a.loggedIn:null}catch{return null}}import{existsSync as ja,readdirSync as xr}from"fs";import{join as Na}from"path";import{join as cr}from"path";function Ea(e){return/^[\w@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function U(e){return(a,t)=>`cd ${Ea(t)} && npx -y skills add ${Ea(a)} -a ${e} -y`}var ie={tier:"claude-code",skillDirs:e=>[cr(e,".claude","skills")],addSkillCommand:U("claude-code"),instructionsFile:"CLAUDE.md"};import{join as pr}from"path";var Ra={tier:"codex-cli",skillDirs:e=>[pr(e,".agents","skills")],addSkillCommand:U("codex"),instructionsFile:"AGENTS.md"};import{join as Se}from"path";var Oa={tier:"opencode",skillDirs:e=>[Se(e,".agents","skills"),Se(e,".opencode","skills"),Se(e,".claude","skills")],addSkillCommand:U("opencode"),instructionsFile:"AGENTS.md"};import{join as Ae}from"path";var Da=e=>({...ie,tier:e,skillDirs:a=>[Ae(a,".claude","skills"),Ae(a,".skills"),Ae(a,"skills")]}),Ma=Da("sdk"),Ha=Da("orchestrator");var gr={"claude-code":ie,"codex-cli":Ra,opencode:Oa,sdk:Ma,orchestrator:Ha};function La(e){return gr[e??"claude-code"]??null}function Jo(e,a){return La(e)?.skillDirs(a)[0]??null}function Go(e,a){let t=new Map;for(let r of La(e)?.skillDirs(a)??[])if(ja(r))for(let n of xr(r))n.startsWith(".")||t.has(n)||ja(Na(r,n,"SKILL.md"))&&t.set(n,Na(r,n));return[...t].map(([r,n])=>({name:r,dir:n})).sort((r,n)=>r.name.localeCompare(n.name))}Xa();function Qo(e,a,t=20){return e.prepare(`SELECT task_id, agent_id, channel, chat_id, status, started_at, finished_at, message_preview
2895
+ `;return ir(e,`${n}${a}=${t}
2896
+ `),!0}import{execFileSync as cr}from"child_process";function Io(e){if(e!=="claude")return null;let a=Ke(e);if(!a)return null;try{let t=cr(a,["auth","status"],{encoding:"utf-8",timeout:1e4,stdio:["ignore","pipe","ignore"]});return Ea(t)}catch(t){return typeof t?.stdout=="string"?Ea(t.stdout):null}}function Ea(e){try{let a=JSON.parse(e);return typeof a?.loggedIn=="boolean"?a.loggedIn:null}catch{return null}}import{existsSync as Na,readdirSync as gr}from"fs";import{join as La}from"path";import{join as pr}from"path";function Ra(e){return/^[\w@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function U(e){return(a,t)=>`cd ${Ra(t)} && npx -y skills add ${Ra(a)} -a ${e} -y`}var ie={tier:"claude-code",skillDirs:e=>[pr(e,".claude","skills")],addSkillCommand:U("claude-code"),instructionsFile:"CLAUDE.md"};import{join as xr}from"path";var Oa={tier:"codex-cli",skillDirs:e=>[xr(e,".agents","skills")],addSkillCommand:U("codex"),instructionsFile:"AGENTS.md"};import{join as Ae}from"path";var Da={tier:"opencode",skillDirs:e=>[Ae(e,".agents","skills"),Ae(e,".opencode","skills"),Ae(e,".claude","skills")],addSkillCommand:U("opencode"),instructionsFile:"AGENTS.md"};import{join as Ce}from"path";var Ma=e=>({...ie,tier:e,skillDirs:a=>[Ce(a,".claude","skills"),Ce(a,".skills"),Ce(a,"skills")]}),Ha=Ma("sdk"),ja=Ma("orchestrator");var ur={"claude-code":ie,"codex-cli":Oa,opencode:Da,sdk:Ha,orchestrator:ja};function Wa(e){return ur[e??"claude-code"]??null}function Xo(e,a){return Wa(e)?.skillDirs(a)[0]??null}function Vo(e,a){let t=new Map;for(let r of Wa(e)?.skillDirs(a)??[])if(Na(r))for(let n of gr(r))n.startsWith(".")||t.has(n)||Na(La(r,n,"SKILL.md"))&&t.set(n,La(r,n));return[...t].map(([r,n])=>({name:r,dir:n})).sort((r,n)=>r.name.localeCompare(n.name))}Va();function ei(e,a,t=20){return e.prepare(`SELECT task_id, agent_id, channel, chat_id, status, started_at, finished_at, message_preview
2897
2897
  FROM task_traces
2898
2898
  WHERE person = ? AND (channel IS NULL OR channel != 'a2a')
2899
- ORDER BY started_at DESC, rowid DESC LIMIT ?`).all(a,Math.max(1,Math.min(t,500))).map(n=>({taskId:n.task_id,agentId:n.agent_id,channel:n.channel,chatId:n.chat_id,status:n.status,startedAt:n.started_at,finishedAt:n.finished_at??null,messagePreview:n.message_preview}))}function ur(e){return e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'requests'").get()?e.prepare("PRAGMA table_info(requests)").all().some(r=>r.name==="person"):!1}function Wa(e,a,t,r,...n){return ur(e)?e.prepare(`SELECT id, state, channel, agent_id, text, created_at FROM requests
2899
+ ORDER BY started_at DESC, rowid DESC LIMIT ?`).all(a,Math.max(1,Math.min(t,500))).map(n=>({taskId:n.task_id,agentId:n.agent_id,channel:n.channel,chatId:n.chat_id,status:n.status,startedAt:n.started_at,finishedAt:n.finished_at??null,messagePreview:n.message_preview}))}function mr(e){return e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'requests'").get()?e.prepare("PRAGMA table_info(requests)").all().some(r=>r.name==="person"):!1}function Ba(e,a,t,r,...n){return mr(e)?e.prepare(`SELECT id, state, channel, agent_id, text, created_at FROM requests
2900
2900
  WHERE person = ? AND state IN (${t.map(()=>"?").join(",")})
2901
- ${r}`).all(a,...t,...n).map(i=>({id:i.id,state:i.state,channel:i.channel,agentId:i.agent_id,text:i.text,createdAt:i.created_at})):[]}function Zo(e,a){return Wa(e,a,de,"ORDER BY created_at")}function ei(e,a,t=50){return Wa(e,a,[...de,...Te],"ORDER BY created_at DESC, rowid DESC LIMIT ?",Math.max(1,Math.min(t,500)))}Va();var Ce="member:",mr=90,fr="members",hr="tailscale-user-login",br=400,vr=60*60*1e3;function wr(e){let a=e.scopes.find(t=>t.startsWith(Ce));return a?a.slice(Ce.length):null}function Ua(e,a){if(!e)return null;let t=a.verify(e),r=t?wr(t):null;return t&&r?{rec:t,personId:r}:null}function si(e,a){let t=e.people().find(s=>s.id===a);if(!t)return{ok:!1,error:`No person "${a}". Add them first: agentx people add ${a} --name "\u2026"`};let{token:r,record:n}=e.tokens.create({name:`${t.name} (machine not paired yet)`,scopes:[`${Ce}${t.id}`],expiresInDays:mr}),{code:o,expiresAt:i}=e.codes.create({token:r,tokenId:n.id,name:t.id});return e.members.log({person:t.id,device:n.id,event:"invited"}),{ok:!0,code:o,expiresAt:i,tokenId:n.id,person:t}}var yr=Math.round(Me/6e4);function kr(e){return e==="client"?"Your project":"My work"}function di(e){let a=kr(e.person.role),t=e.person.role==="client"?`I use AgentX to keep track of the work I do for you. It has a page for you, "${a}": what you asked us for, and where each request stands.`:`I use AgentX to give our AI agents their jobs. It has a page for you, "${a}": what you asked the agents for, and where each request stands.`;return[`Hi ${e.person.name},`,"",t,"","To open it:","1. Accept the Tailscale share I sent you. Tailscale is a small program that connects your computer to mine, privately.",`2. Open ${e.origin.replace(/\/+$/,"")}/member in Edge or Chrome, give your computer a name and type this code: ${He(e.code)}`,` The code works once, for ${yr} 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(`
2902
- `)}var _r="The private network says someone else is connecting from this machine. Ask the person who invited you for a new code.",$r="Too many machines are waiting for the owner's answer. Try again later.",Ba="That code didn't work. Check it, or ask the person who invited you for a new one.",Fa=(e,a)=>{let t=e.headers[a];return(Array.isArray(t)?t[0]:t||"").trim()};function qa(e){let a=e.socket?.remoteAddress||"";return a==="127.0.0.1"||a==="::1"||a==="::ffff:127.0.0.1"}function Sr(e){if(!qa(e))return null;let a=Fa(e,hr).toLowerCase();return a?a.slice(0,80):null}function Ar(e){let a=e.socket?.remoteAddress||"unknown";if(!qa(e))return a;let t=Fa(e,"x-forwarded-for").split(",").pop().trim();return/^[0-9a-fA-F:.]{2,45}$/.test(t)?t:a}function Cr(e){return typeof e=="string"?e.replace(/[^\p{L}\p{N} ._'()-]/gu," ").replace(/\s+/g," ").trim().slice(0,60):""}function Tr(e){return e.identities.map(Ie).filter(a=>!!a&&a.channel==="tailscale").map(a=>a.value)}async function li(e,a){let t=Date.now(),r=a.now??Date.now,n=a.log??(b=>console.log(b)),o=Ar(e),i=a.limiter.retryAfter(o);if(i>0)return n(`[member] pair-code refused from ${o}: locked out for ${i}s more`),{status:429,body:{error:"too many attempts",retryAfter:i},retryAfter:i};let s=null,d="";try{let b=await V(e,2048);s=b.code,d=Cr(b.machine)}catch{}let l=a.codes.redeem(s),c=l?Ua(l.token,a.tokens):null;if(await zr(t,a.minMs??br),!l||!c)return a.limiter.fail(o),n(`[member] pair-code failed from ${o}`),{status:401,body:{error:Ba}};a.limiter.succeed(o);let{rec:m,personId:g}=c,u=a.people().find(b=>b.id===g);if(!u)return a.tokens.revoke(m.id),a.members.log({person:g,device:m.id,event:"refused",address:o,detail:"person no longer listed"}),n(`[member] pair-code for ${g} refused from ${o}: person no longer listed`),{status:403,body:{error:Ba}};let x=Sr(e),f=Tr(u);if(f.length&&(!x||!f.includes(x)))return a.tokens.revoke(m.id),a.members.log({person:g,device:m.id,event:"refused",address:o,detail:`network login ${x??"missing"}; expected ${f.join(" or ")}`}),n(`[member] ${g}: pairing from ${o} refused: the network says "${x??"nobody"}", expected ${f.join(" or ")}`),{status:403,body:{error:_r}};let C=d||"Unnamed machine",w=u.name.slice(0,40),v=je(a.root,{title:`New machine for ${w}`,ask:`From ${o}, ${x?`network login ${x}`:"no network login reported"}. Machine name, as typed there: "${C}". Let it see ${w}'s own work?`,recommend:`Yes if ${w} told you they just paired this machine. No if you did not expect it.`,if_silent:"discard",raised_by:fr},{now:r()});return v.ok?(a.members.add({tokenId:m.id,personId:g,name:C,state:"pending",cardId:v.card.id,address:o,...x?{network:x}:{},createdAt:new Date(r()).toISOString()}),a.members.log({person:g,device:m.id,event:"paired",address:o,detail:C}),n(`[member] ${g} paired "${C}" from ${o}; waiting for the owner (card ${v.card.id})`),{status:200,body:{person:g,name:C,state:"pending"},token:l.token}):(a.tokens.revoke(m.id),a.members.log({person:g,device:m.id,event:"refused",address:o,detail:v.error}),n(`[member] ${g}: pairing from ${o} refused: ${v.error}`),{status:503,body:{error:$r}})}var se="this machine is not paired",Ir="waiting for the owner to approve this machine";function Ka(e){return e?e.status==="decided"?e.verdict??null:e.status==="expired"?"no":null:null}function ci(e,a){return a.state==="pending"&&a.cardId?Ka(pe(e,a.cardId)):null}function pi(e,a,t){let r=a.now??Date.now,n=a.log??(c=>console.log(c)),o=Ua(e,a.tokens);if(!o)return{ok:!1,status:401,error:se};let{rec:i,personId:s}=o,d=a.members.byToken(i.id);if(!d||d.state==="removed"||d.personId!==s)return{ok:!1,status:401,error:se};if(a.people&&!a.people().some(c=>c.id===s))return Ya(a,i.id,"person no longer listed"),n(`[member] ${s}: "${d.name}" ended: person no longer listed`),{ok:!1,status:401,error:se};if(d.state==="pending"){let c=d.cardId?pe(a.root,d.cardId):null,m=Ka(c);if(m==="yes")d=a.members.update(i.id,{state:"active",approvedAt:new Date(r()).toISOString()})??d,a.members.log({person:s,device:i.id,event:"approved",detail:c?.decided_by}),n(`[member] ${s}: "${d.name}" approved`);else if(m==="no"){let g=c?.status==="expired"?"the owner did not answer in time":"the owner said no";return a.tokens.revoke(i.id),a.members.update(i.id,{state:"removed",removedAt:new Date(r()).toISOString(),removedReason:g}),a.members.log({person:s,device:i.id,event:"refused",detail:g}),n(`[member] ${s}: "${d.name}" refused: ${g}`),{ok:!1,status:401,error:se}}else return{ok:!1,status:403,error:Ir,waiting:!0}}let l=d.lastSeenAt?Date.parse(d.lastSeenAt):0;return t&&(r()-l>=vr||d.lastAddress!==t)&&(d=a.members.update(i.id,{lastSeenAt:new Date(r()).toISOString(),lastAddress:t})??d,a.members.log({person:s,device:i.id,event:"signed-in",address:t})),{ok:!0,device:d,personId:s,rec:i}}function Ya(e,a,t="removed by the owner"){let r=e.members.byToken(a);if(!r)return null;e.tokens.revoke(a);let n=e.members.update(a,{state:"removed",removedAt:new Date((e.now??Date.now)()).toISOString(),removedReason:t});return e.members.log({person:r.personId,device:a,event:"removed",detail:t}),n}function xi(e,a){return e.members.devices(a).filter(t=>t.state!=="removed").map(t=>Ya(e,t.tokenId,"person removed by the owner")).filter(t=>!!t)}async function zr(e,a){let t=e+a-Date.now();t>0&&await new Promise(r=>setTimeout(r,t))}var Ja=["gitlab","github"];function Pr(e,a,t){let r=String(a||"").trim().toLowerCase();if(!Ja.includes(r))throw new Error(`Request status works on ${Ja.join(" and ")}, not on "${a}".`);e.requestStatus=e.requestStatus&&typeof e.requestStatus=="object"?e.requestStatus:{};let n=Array.isArray(e.requestStatus.channels)?e.requestStatus.channels.map(o=>String(o).toLowerCase()):[];return e.requestStatus.channels=t?[...new Set([...n,r])]:n.filter(o=>o!==r),`request status on ${r} is ${t?"on":"off"}`}function mi(e){return Array.isArray(e?.requestStatus?.channels)?e.requestStatus.channels.map(a=>String(a).toLowerCase()):[]}function fi(e){let{summary:a}=Q(t=>Pr(t,e?.channel,!!e?.enabled));return{summary:a}}var bi="https://myaccount.google.com/apppasswords";function vi(e){let a=e.split("@")[1]?.toLowerCase()??"";if(a==="gmail.com"||a==="googlemail.com")return{imapHost:"imap.gmail.com",imapPort:993,smtpHost:"smtp.gmail.com",smtpPort:465}}function wi(e){let a=e.user&&e.user!==e.address?{user:e.user}:{};return{agent:e.agent,address:e.address,imap:{host:e.imapHost,port:e.imapPort,secure:e.imapPort===993,...a,password:`\${${e.passwordEnv}}`},smtp:{host:e.smtpHost,port:e.smtpPort,secure:e.smtpPort===465},allowFrom:e.allowFrom,send:e.send}}function yi(e){return`EMAIL_${e.toUpperCase().replace(/[^A-Z0-9]/g,"_")}_PASSWORD`}function _i(e){return new Set(Object.entries(e).filter(([,a])=>a?.wiki?.absorb?.enabled===!1).map(([a])=>a))}function $i(e,a){return a.only?{agents:[a.only],skipped:[]}:{agents:e.filter(t=>!a.off.has(t)),skipped:e.filter(t=>a.off.has(t))}}function Si(e,a){return`absorb is off for this agent (agents.${e}.wiki.absorb.enabled); skipped.${e===a?" It reads the wiki notes inbox, so the inbox was not read.":""} Use --agent ${e} to run it anyway.`}function Ai(e,a){if(a){if(!e.wiki?.absorb)return;delete e.wiki.absorb.enabled,Object.keys(e.wiki.absorb).length===0&&delete e.wiki.absorb,Object.keys(e.wiki).length===0&&delete e.wiki;return}e.wiki??={},e.wiki.absorb??={},e.wiki.absorb.enabled=!1}var Er="https://ntfy.sh";function Ti(e){return{enabled:!!e?.enabled,server:e?.server||Er,topicSet:!!e?.topic,tokenSet:!!e?.token}}function Ii(e,a){let t={...e??{}};if("enabled"in a&&(t.enabled=!!a.enabled),"server"in a){let r=String(a.server).trim().replace(/\/+$/,"");if(!/^https?:\/\/\S+$/.test(r))throw new Error("ntfy server must be an http(s) URL");t.server=r}if("topic"in a){let r=String(a.topic).trim();if(!r)throw new Error("ntfy topic cannot be empty");t.topic=r}if("token"in a){let r=String(a.token??"").trim();r?t.token=r:delete t.token}if(t.enabled&&!t.topic)throw new Error("set a topic before enabling ntfy");return t}export{fe as a,na as b,be as c,Za as d,et as e,at as f,tt as g,rt as h,nt as i,ot as j,it as k,ca as l,mt as m,yn as n,kn as o,_n as p,vo as q,dr as r,_o as s,Co as t,La as u,Jo as v,Go as w,zn as x,Pn as y,It as z,Et as A,ve as B,En as C,Rn as D,Rt as E,Nn as F,Ln as G,Wn as H,Qo as I,Zo as J,ei as K,mr as L,si as M,yr as N,kr as O,di as P,Ar as Q,li as R,ci as S,pi as T,Ya as U,xi as V,Ja as W,Pr as X,mi as Y,fi as Z,bi as _,vi as $,wi as aa,yi as ba,_i as ca,$i as da,Si as ea,Ai as fa,Ti as ga,Ii as ha,Qt as ia,co as ja,fo as ka,ho as la};
2903
- //# sourceMappingURL=chunk-2FCYIEKT.js.map
2901
+ ${r}`).all(a,...t,...n).map(i=>({id:i.id,state:i.state,channel:i.channel,agentId:i.agent_id,text:i.text,createdAt:i.created_at})):[]}function ai(e,a){return Ba(e,a,de,"ORDER BY created_at")}function ti(e,a,t=50){return Ba(e,a,[...de,...Ie],"ORDER BY created_at DESC, rowid DESC LIMIT ?",Math.max(1,Math.min(t,500)))}Qa();var Te="member:",fr=90,hr="members",br="tailscale-user-login",vr=400,wr=60*60*1e3;function yr(e){let a=e.scopes.find(t=>t.startsWith(Te));return a?a.slice(Te.length):null}function Fa(e,a){if(!e)return null;let t=a.verify(e),r=t?yr(t):null;return t&&r?{rec:t,personId:r}:null}function li(e,a){let t=e.people().find(s=>s.id===a);if(!t)return{ok:!1,error:`No person "${a}". Add them first: agentx people add ${a} --name "\u2026"`};let{token:r,record:n}=e.tokens.create({name:`${t.name} (machine not paired yet)`,scopes:[`${Te}${t.id}`],expiresInDays:fr}),{code:o,expiresAt:i}=e.codes.create({token:r,tokenId:n.id,name:t.id});return e.members.log({person:t.id,device:n.id,event:"invited"}),{ok:!0,code:o,expiresAt:i,tokenId:n.id,person:t}}var kr=Math.round(He/6e4);function _r(e){return e==="client"?"Your project":"My work"}function ci(e){let a=_r(e.person.role),t=e.person.role==="client"?`I use AgentX to keep track of the work I do for you. It has a page for you, "${a}": what you asked us for, and where each request stands.`:`I use AgentX to give our AI agents their jobs. It has a page for you, "${a}": what you asked the agents for, and where each request stands.`;return[`Hi ${e.person.name},`,"",t,"","To open it:","1. Accept the Tailscale share I sent you. Tailscale is a small program that connects your computer to mine, privately.",`2. Open ${e.origin.replace(/\/+$/,"")}/member in Edge or Chrome, give your computer a name and type this code: ${je(e.code)}`,` The code works once, for ${kr} 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(`
2902
+ `)}var $r="The private network says someone else is connecting from this machine. Ask the person who invited you for a new code.",Sr="Too many machines are waiting for the owner's answer. Try again later.",Ua="That code didn't work. Check it, or ask the person who invited you for a new one.",qa=(e,a)=>{let t=e.headers[a];return(Array.isArray(t)?t[0]:t||"").trim()};function Ka(e){let a=e.socket?.remoteAddress||"";return a==="127.0.0.1"||a==="::1"||a==="::ffff:127.0.0.1"}function Ar(e){if(!Ka(e))return null;let a=qa(e,br).toLowerCase();return a?a.slice(0,80):null}function Cr(e){let a=e.socket?.remoteAddress||"unknown";if(!Ka(e))return a;let t=qa(e,"x-forwarded-for").split(",").pop().trim();return/^[0-9a-fA-F:.]{2,45}$/.test(t)?t:a}function Tr(e){return typeof e=="string"?e.replace(/[^\p{L}\p{N} ._'()-]/gu," ").replace(/\s+/g," ").trim().slice(0,60):""}function Ir(e){return e.identities.map(ze).filter(a=>!!a&&a.channel==="tailscale").map(a=>a.value)}async function pi(e,a){let t=Date.now(),r=a.now??Date.now,n=a.log??(b=>console.log(b)),o=Cr(e),i=a.limiter.retryAfter(o);if(i>0)return n(`[member] pair-code refused from ${o}: locked out for ${i}s more`),{status:429,body:{error:"too many attempts",retryAfter:i},retryAfter:i};let s=null,d="";try{let b=await V(e,2048);s=b.code,d=Tr(b.machine)}catch{}let l=a.codes.redeem(s),c=l?Fa(l.token,a.tokens):null;if(await Pr(t,a.minMs??vr),!l||!c)return a.limiter.fail(o),n(`[member] pair-code failed from ${o}`),{status:401,body:{error:Ua}};a.limiter.succeed(o);let{rec:m,personId:g}=c,u=a.people().find(b=>b.id===g);if(!u)return a.tokens.revoke(m.id),a.members.log({person:g,device:m.id,event:"refused",address:o,detail:"person no longer listed"}),n(`[member] pair-code for ${g} refused from ${o}: person no longer listed`),{status:403,body:{error:Ua}};let x=Ar(e),f=Ir(u);if(f.length&&(!x||!f.includes(x)))return a.tokens.revoke(m.id),a.members.log({person:g,device:m.id,event:"refused",address:o,detail:`network login ${x??"missing"}; expected ${f.join(" or ")}`}),n(`[member] ${g}: pairing from ${o} refused: the network says "${x??"nobody"}", expected ${f.join(" or ")}`),{status:403,body:{error:$r}};let C=d||"Unnamed machine",w=u.name.slice(0,40),v=Ne(a.root,{title:`New machine for ${w}`,ask:`From ${o}, ${x?`network login ${x}`:"no network login reported"}. Machine name, as typed there: "${C}". Let it see ${w}'s own work?`,recommend:`Yes if ${w} told you they just paired this machine. No if you did not expect it.`,if_silent:"discard",raised_by:hr},{now:r()});return v.ok?(a.members.add({tokenId:m.id,personId:g,name:C,state:"pending",cardId:v.card.id,address:o,...x?{network:x}:{},createdAt:new Date(r()).toISOString()}),a.members.log({person:g,device:m.id,event:"paired",address:o,detail:C}),n(`[member] ${g} paired "${C}" from ${o}; waiting for the owner (card ${v.card.id})`),{status:200,body:{person:g,name:C,state:"pending"},token:l.token}):(a.tokens.revoke(m.id),a.members.log({person:g,device:m.id,event:"refused",address:o,detail:v.error}),n(`[member] ${g}: pairing from ${o} refused: ${v.error}`),{status:503,body:{error:Sr}})}var se="this machine is not paired",zr="waiting for the owner to approve this machine";function Ya(e){return e?e.status==="decided"?e.verdict??null:e.status==="expired"?"no":null:null}function xi(e,a){return a.state==="pending"&&a.cardId?Ya(xe(e,a.cardId)):null}function gi(e,a,t){let r=a.now??Date.now,n=a.log??(c=>console.log(c)),o=Fa(e,a.tokens);if(!o)return{ok:!1,status:401,error:se};let{rec:i,personId:s}=o,d=a.members.byToken(i.id);if(!d||d.state==="removed"||d.personId!==s)return{ok:!1,status:401,error:se};if(a.people&&!a.people().some(c=>c.id===s))return Ja(a,i.id,"person no longer listed"),n(`[member] ${s}: "${d.name}" ended: person no longer listed`),{ok:!1,status:401,error:se};if(d.state==="pending"){let c=d.cardId?xe(a.root,d.cardId):null,m=Ya(c);if(m==="yes")d=a.members.update(i.id,{state:"active",approvedAt:new Date(r()).toISOString()})??d,a.members.log({person:s,device:i.id,event:"approved",detail:c?.decided_by}),n(`[member] ${s}: "${d.name}" approved`);else if(m==="no"){let g=c?.status==="expired"?"the owner did not answer in time":"the owner said no";return a.tokens.revoke(i.id),a.members.update(i.id,{state:"removed",removedAt:new Date(r()).toISOString(),removedReason:g}),a.members.log({person:s,device:i.id,event:"refused",detail:g}),n(`[member] ${s}: "${d.name}" refused: ${g}`),{ok:!1,status:401,error:se}}else return{ok:!1,status:403,error:zr,waiting:!0}}let l=d.lastSeenAt?Date.parse(d.lastSeenAt):0;return t&&(r()-l>=wr||d.lastAddress!==t)&&(d=a.members.update(i.id,{lastSeenAt:new Date(r()).toISOString(),lastAddress:t})??d,a.members.log({person:s,device:i.id,event:"signed-in",address:t})),{ok:!0,device:d,personId:s,rec:i}}function Ja(e,a,t="removed by the owner"){let r=e.members.byToken(a);if(!r)return null;e.tokens.revoke(a);let n=e.members.update(a,{state:"removed",removedAt:new Date((e.now??Date.now)()).toISOString(),removedReason:t});return e.members.log({person:r.personId,device:a,event:"removed",detail:t}),n}function ui(e,a){return e.members.devices(a).filter(t=>t.state!=="removed").map(t=>Ja(e,t.tokenId,"person removed by the owner")).filter(t=>!!t)}async function Pr(e,a){let t=e+a-Date.now();t>0&&await new Promise(r=>setTimeout(r,t))}var Ga=["gitlab","github"];function Er(e,a,t){let r=String(a||"").trim().toLowerCase();if(!Ga.includes(r))throw new Error(`Request status works on ${Ga.join(" and ")}, not on "${a}".`);e.requestStatus=e.requestStatus&&typeof e.requestStatus=="object"?e.requestStatus:{};let n=Array.isArray(e.requestStatus.channels)?e.requestStatus.channels.map(o=>String(o).toLowerCase()):[];return e.requestStatus.channels=t?[...new Set([...n,r])]:n.filter(o=>o!==r),`request status on ${r} is ${t?"on":"off"}`}function hi(e){return Array.isArray(e?.requestStatus?.channels)?e.requestStatus.channels.map(a=>String(a).toLowerCase()):[]}function bi(e){let{summary:a}=Q(t=>Er(t,e?.channel,!!e?.enabled));return{summary:a}}var wi="https://myaccount.google.com/apppasswords";function yi(e){let a=e.split("@")[1]?.toLowerCase()??"";if(a==="gmail.com"||a==="googlemail.com")return{imapHost:"imap.gmail.com",imapPort:993,smtpHost:"smtp.gmail.com",smtpPort:465}}function ki(e){let a=e.user&&e.user!==e.address?{user:e.user}:{};return{agent:e.agent,address:e.address,imap:{host:e.imapHost,port:e.imapPort,secure:e.imapPort===993,...a,password:`\${${e.passwordEnv}}`},smtp:{host:e.smtpHost,port:e.smtpPort,secure:e.smtpPort===465},allowFrom:e.allowFrom,send:e.send}}function _i(e){return`EMAIL_${e.toUpperCase().replace(/[^A-Z0-9]/g,"_")}_PASSWORD`}function Si(e){return new Set(Object.entries(e).filter(([,a])=>a?.wiki?.absorb?.enabled===!1).map(([a])=>a))}function Ai(e,a){return a.only?{agents:[a.only],skipped:[]}:{agents:e.filter(t=>!a.off.has(t)),skipped:e.filter(t=>a.off.has(t))}}function Ci(e,a){return`absorb is off for this agent (agents.${e}.wiki.absorb.enabled); skipped.${e===a?" It reads the wiki notes inbox, so the inbox was not read.":""} Use --agent ${e} to run it anyway.`}function Ti(e,a){if(a){if(!e.wiki?.absorb)return;delete e.wiki.absorb.enabled,Object.keys(e.wiki.absorb).length===0&&delete e.wiki.absorb,Object.keys(e.wiki).length===0&&delete e.wiki;return}e.wiki??={},e.wiki.absorb??={},e.wiki.absorb.enabled=!1}var Rr="https://ntfy.sh";function zi(e){return{enabled:!!e?.enabled,server:e?.server||Rr,topicSet:!!e?.topic,tokenSet:!!e?.token}}function Pi(e,a){let t={...e??{}};if("enabled"in a&&(t.enabled=!!a.enabled),"server"in a){let r=String(a.server).trim().replace(/\/+$/,"");if(!/^https?:\/\/\S+$/.test(r))throw new Error("ntfy server must be an http(s) URL");t.server=r}if("topic"in a){let r=String(a.topic).trim();if(!r)throw new Error("ntfy topic cannot be empty");t.topic=r}if("token"in a){let r=String(a.token??"").trim();r?t.token=r:delete t.token}if(t.enabled&&!t.topic)throw new Error("set a topic before enabling ntfy");return t}export{he as a,oa as b,ve as c,et as d,at as e,tt as f,rt as g,nt as h,ot as i,it as j,st as k,pa as l,ft as m,_n as n,$n as o,Sn as p,yo as q,lr as r,So as s,Io as t,Wa as u,Xo as v,Vo as w,En as x,Rn as y,zt as z,Rt as A,we as B,On as C,Dn as D,Ot as E,Wn as F,Bn as G,Un as H,ei as I,ai as J,ti as K,fr as L,li as M,kr as N,_r as O,ci as P,Cr as Q,pi as R,xi as S,gi as T,Ja as U,ui as V,Ga as W,Er as X,hi as Y,bi as Z,wi as _,yi as $,ki as aa,_i as ba,Si as ca,Ai as da,Ci as ea,Ti as fa,zi as ga,Pi as ha,Zt as ia,xo as ja,bo as ka,vo as la};
2903
+ //# sourceMappingURL=chunk-PSP3NAFU.js.map