agentix-cli 0.132.0 → 0.134.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{App-VPYWOTTH.js → App-4UVAI5C5.js} +2 -2
- package/dist/{ChatApp-SNED4KJB.js → ChatApp-COO67WIR.js} +2 -2
- package/dist/absorb-eval-WU7JR3BT.js +2 -0
- package/dist/{agent-HXQYYLWZ.js → agent-2GPJGHHG.js} +2 -2
- package/dist/{board-dashboard-44JPXA7J.js → board-dashboard-PUQPL4AX.js} +376 -257
- package/dist/board-dashboard-PUQPL4AX.js.map +1 -0
- package/dist/{chunk-RYGVTAP4.js → chunk-3XVST5XX.js} +2 -2
- package/dist/{note-reader-LPPIYYLT.js → chunk-4LWFJ4MZ.js} +3 -3
- package/dist/{note-reader-LPPIYYLT.js.map → chunk-4LWFJ4MZ.js.map} +1 -1
- package/dist/{chunk-724IBN5Y.js → chunk-4XMALK7X.js} +2 -2
- package/dist/{chunk-3WYLK3SX.js → chunk-AHO4CQRK.js} +2 -2
- package/dist/chunk-DDEDSYLF.js +105 -0
- package/dist/chunk-DDEDSYLF.js.map +1 -0
- package/dist/chunk-DYGQF3MI.js +54 -0
- package/dist/chunk-DYGQF3MI.js.map +1 -0
- package/dist/{chunk-ZG4G6BFP.js → chunk-ERULJ2ZL.js} +2 -2
- package/dist/chunk-FEEXOWK5.js +41 -0
- package/dist/chunk-FEEXOWK5.js.map +1 -0
- package/dist/{chunk-QNKSRROH.js → chunk-FWDRBUMS.js} +2 -2
- package/dist/chunk-G4HDRJVN.js +87 -0
- package/dist/chunk-G4HDRJVN.js.map +1 -0
- package/dist/{chunk-KQH4LPYC.js → chunk-K445URSN.js} +2 -2
- package/dist/{chunk-KDQI5S7F.js → chunk-LUYN6RAC.js} +2 -2
- package/dist/{chunk-JRVJXAVC.js → chunk-MM3F74K4.js} +31 -31
- package/dist/chunk-MM3F74K4.js.map +1 -0
- package/dist/{chunk-3K35L73A.js → chunk-NXRSIWQA.js} +3 -3
- package/dist/chunk-NXRSIWQA.js.map +1 -0
- package/dist/chunk-NZQBS7GN.js +2 -0
- package/dist/{chunk-KBJNJGBP.js.map → chunk-NZQBS7GN.js.map} +1 -1
- package/dist/{chunk-Z7RJ3K3J.js → chunk-P3I7AATX.js} +2 -2
- package/dist/{chunk-A6QJ4VFT.js → chunk-RDEFA6Y6.js} +2 -2
- package/dist/{chunk-VCQVF44A.js → chunk-RJOA7QBB.js} +2 -2
- package/dist/{chunk-JNKATLF7.js → chunk-RRGITX5B.js} +2 -2
- package/dist/chunk-SFVDQNTY.js +156 -0
- package/dist/chunk-SFVDQNTY.js.map +1 -0
- package/dist/{chunk-KKQPV6SO.js → chunk-SMAI7U6H.js} +2 -2
- package/dist/{chunk-MDGYSHO5.js → chunk-SSQMFHSM.js} +2 -2
- package/dist/{chunk-CM74OUXW.js → chunk-TDGDH4RA.js} +2 -2
- package/dist/chunk-URN74FTP.js +55 -0
- package/dist/chunk-URN74FTP.js.map +1 -0
- package/dist/{chunk-XWVBLISN.js → chunk-VQYVL72V.js} +2 -2
- package/dist/{chunk-UDMI4TYM.js → chunk-XOUO4XNA.js} +2 -2
- package/dist/{chunk-WWNZL7XB.js → chunk-XWO6ALJQ.js} +2 -2
- package/dist/{chunk-62NXS7PT.js → chunk-YSXE65O7.js} +246 -246
- package/dist/chunk-YSXE65O7.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/{client-TXZF32NO.js → client-NFPBE6L4.js} +2 -2
- package/dist/config-GHMRBRDL.js +2 -0
- package/dist/{config-mutate-KDBXIN7R.js → config-mutate-2XV27EFV.js} +2 -2
- package/dist/config-mutator-6ITNU5DT.js +2 -0
- package/dist/{contributions-FBVULRR4.js → contributions-74M6YOCZ.js} +2 -2
- package/dist/{contributions-FBVULRR4.js.map → contributions-74M6YOCZ.js.map} +1 -1
- package/dist/{doctor-NBWYG743.js → doctor-UBXVMGJG.js} +2 -2
- package/dist/follow-up-tool-EARVITTS.js +7 -0
- package/dist/follow-up-tool-EARVITTS.js.map +1 -0
- package/dist/{hub-3QTJ7E3O.js → hub-VTDFUAEH.js} +2 -2
- package/dist/index.d.ts +1534 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/note-reader-IDE6RI34.js +2 -0
- package/dist/notes-settings-VPXI5IIS.js +2 -0
- package/dist/{program-SA5O6IQ3.js → program-3URNCVEZ.js} +253 -253
- package/dist/program-3URNCVEZ.js.map +1 -0
- package/dist/{promote-4XHYWHLA.js → promote-B2BADAEP.js} +2 -2
- package/dist/push-bridge-325SXDGN.js +1 -1
- package/dist/query-2VIIGGDS.js +2 -0
- package/dist/query-settings-VJ3POZS3.js +3 -0
- package/dist/query-settings-VJ3POZS3.js.map +1 -0
- package/dist/registry-PRCISYBO.js +2 -0
- package/dist/{request-planner-4BAAOUBH.js → request-planner-MFAIVLUQ.js} +2 -2
- package/dist/{review-candidates-TM53WR7G.js → review-candidates-6WMDVVIZ.js} +2 -2
- package/dist/{routing-QLS6UMLM.js → routing-OPCLHIYW.js} +2 -2
- package/dist/schedule-tool-KPVTMYL3.js +2 -0
- package/dist/{scheduler-PVXLF2VJ.js → scheduler-G3WWYETY.js} +2 -2
- package/dist/{seat-OUUN3F45.js → seat-3HM4J7IX.js} +2 -2
- package/dist/{select-D7UUSODY.js → select-VEFE2ESF.js} +2 -2
- package/dist/{set-enabled-FDNS6KW6.js → set-enabled-US5BYKFZ.js} +2 -2
- package/dist/{tool-J5FM3OPM.js → tool-HUSCHORN.js} +2 -2
- package/dist/{tool-SCBQYDI3.js → tool-XLWLXGB5.js} +2 -2
- package/dist/wiki-SXWJ5NJQ.js +2 -0
- package/dist/wiki-SXWJ5NJQ.js.map +1 -0
- package/package.json +2 -1
- package/dist/absorb-eval-WGO4JWTO.js +0 -2
- package/dist/board-dashboard-44JPXA7J.js.map +0 -1
- package/dist/chunk-2ZDV3DCT.js +0 -52
- package/dist/chunk-2ZDV3DCT.js.map +0 -1
- package/dist/chunk-3K35L73A.js.map +0 -1
- package/dist/chunk-62NXS7PT.js.map +0 -1
- package/dist/chunk-74LPAKQY.js +0 -105
- package/dist/chunk-74LPAKQY.js.map +0 -1
- package/dist/chunk-7D3RJSN4.js +0 -156
- package/dist/chunk-7D3RJSN4.js.map +0 -1
- package/dist/chunk-EQ33PFXP.js +0 -55
- package/dist/chunk-EQ33PFXP.js.map +0 -1
- package/dist/chunk-JRVJXAVC.js.map +0 -1
- package/dist/chunk-KBJNJGBP.js +0 -2
- package/dist/chunk-RH3J4LCP.js +0 -37
- package/dist/chunk-RH3J4LCP.js.map +0 -1
- package/dist/chunk-S2RRPTS3.js +0 -54
- package/dist/chunk-S2RRPTS3.js.map +0 -1
- package/dist/config-ZIXIH23X.js +0 -2
- package/dist/config-mutator-HKFGPJMG.js +0 -2
- package/dist/follow-up-tool-E5XKSPKA.js +0 -6
- package/dist/follow-up-tool-E5XKSPKA.js.map +0 -1
- package/dist/notes-settings-WMOH2V75.js +0 -2
- package/dist/program-SA5O6IQ3.js.map +0 -1
- package/dist/query-ZGD32CE2.js +0 -2
- package/dist/query-settings-BSDXFS3V.js +0 -3
- package/dist/query-settings-BSDXFS3V.js.map +0 -1
- package/dist/registry-LM35AE2P.js +0 -2
- package/dist/schedule-tool-TTCWBAQ4.js +0 -2
- package/dist/wiki-IGRRQL6H.js +0 -2
- /package/dist/{App-VPYWOTTH.js.map → App-4UVAI5C5.js.map} +0 -0
- /package/dist/{ChatApp-SNED4KJB.js.map → ChatApp-COO67WIR.js.map} +0 -0
- /package/dist/{absorb-eval-WGO4JWTO.js.map → absorb-eval-WU7JR3BT.js.map} +0 -0
- /package/dist/{agent-HXQYYLWZ.js.map → agent-2GPJGHHG.js.map} +0 -0
- /package/dist/{chunk-RYGVTAP4.js.map → chunk-3XVST5XX.js.map} +0 -0
- /package/dist/{chunk-724IBN5Y.js.map → chunk-4XMALK7X.js.map} +0 -0
- /package/dist/{chunk-3WYLK3SX.js.map → chunk-AHO4CQRK.js.map} +0 -0
- /package/dist/{chunk-ZG4G6BFP.js.map → chunk-ERULJ2ZL.js.map} +0 -0
- /package/dist/{chunk-QNKSRROH.js.map → chunk-FWDRBUMS.js.map} +0 -0
- /package/dist/{chunk-KQH4LPYC.js.map → chunk-K445URSN.js.map} +0 -0
- /package/dist/{chunk-KDQI5S7F.js.map → chunk-LUYN6RAC.js.map} +0 -0
- /package/dist/{chunk-Z7RJ3K3J.js.map → chunk-P3I7AATX.js.map} +0 -0
- /package/dist/{chunk-A6QJ4VFT.js.map → chunk-RDEFA6Y6.js.map} +0 -0
- /package/dist/{chunk-VCQVF44A.js.map → chunk-RJOA7QBB.js.map} +0 -0
- /package/dist/{chunk-JNKATLF7.js.map → chunk-RRGITX5B.js.map} +0 -0
- /package/dist/{chunk-KKQPV6SO.js.map → chunk-SMAI7U6H.js.map} +0 -0
- /package/dist/{chunk-MDGYSHO5.js.map → chunk-SSQMFHSM.js.map} +0 -0
- /package/dist/{chunk-CM74OUXW.js.map → chunk-TDGDH4RA.js.map} +0 -0
- /package/dist/{chunk-XWVBLISN.js.map → chunk-VQYVL72V.js.map} +0 -0
- /package/dist/{chunk-UDMI4TYM.js.map → chunk-XOUO4XNA.js.map} +0 -0
- /package/dist/{chunk-WWNZL7XB.js.map → chunk-XWO6ALJQ.js.map} +0 -0
- /package/dist/{client-TXZF32NO.js.map → client-NFPBE6L4.js.map} +0 -0
- /package/dist/{config-ZIXIH23X.js.map → config-GHMRBRDL.js.map} +0 -0
- /package/dist/{config-mutate-KDBXIN7R.js.map → config-mutate-2XV27EFV.js.map} +0 -0
- /package/dist/{config-mutator-HKFGPJMG.js.map → config-mutator-6ITNU5DT.js.map} +0 -0
- /package/dist/{doctor-NBWYG743.js.map → doctor-UBXVMGJG.js.map} +0 -0
- /package/dist/{hub-3QTJ7E3O.js.map → hub-VTDFUAEH.js.map} +0 -0
- /package/dist/{notes-settings-WMOH2V75.js.map → note-reader-IDE6RI34.js.map} +0 -0
- /package/dist/{promote-4XHYWHLA.js.map → notes-settings-VPXI5IIS.js.map} +0 -0
- /package/dist/{query-ZGD32CE2.js.map → promote-B2BADAEP.js.map} +0 -0
- /package/dist/{registry-LM35AE2P.js.map → query-2VIIGGDS.js.map} +0 -0
- /package/dist/{routing-QLS6UMLM.js.map → registry-PRCISYBO.js.map} +0 -0
- /package/dist/{request-planner-4BAAOUBH.js.map → request-planner-MFAIVLUQ.js.map} +0 -0
- /package/dist/{review-candidates-TM53WR7G.js.map → review-candidates-6WMDVVIZ.js.map} +0 -0
- /package/dist/{schedule-tool-TTCWBAQ4.js.map → routing-OPCLHIYW.js.map} +0 -0
- /package/dist/{scheduler-PVXLF2VJ.js.map → schedule-tool-KPVTMYL3.js.map} +0 -0
- /package/dist/{seat-OUUN3F45.js.map → scheduler-G3WWYETY.js.map} +0 -0
- /package/dist/{wiki-IGRRQL6H.js.map → seat-3HM4J7IX.js.map} +0 -0
- /package/dist/{select-D7UUSODY.js.map → select-VEFE2ESF.js.map} +0 -0
- /package/dist/{set-enabled-FDNS6KW6.js.map → set-enabled-US5BYKFZ.js.map} +0 -0
- /package/dist/{tool-J5FM3OPM.js.map → tool-HUSCHORN.js.map} +0 -0
- /package/dist/{tool-SCBQYDI3.js.map → tool-XLWLXGB5.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as Re,b as w,c as z,d as Pe,e as ie,f as se,g as M,h as le,i as N,j as O,n as De,o as ze,p as _e,q as We}from"./chunk-MCBTVNPX.js";import{e as Ee,i as Te}from"./chunk-KFIJDLQ5.js";import{b as oe}from"./chunk-5BI2T3WD.js";import{a as G,b as Ce}from"./chunk-SMAI7U6H.js";import{c as Ie,d as ae,e as T,f as re,g as B}from"./chunk-B2QYMUTD.js";import{a as Se}from"./chunk-7LN4VKDU.js";import{a as Ae}from"./chunk-IMLAPB7G.js";import{b as xe}from"./chunk-WCXXXAHV.js";import{c as ye,e as we}from"./chunk-LQE73AZR.js";import{b as $e}from"./chunk-MRIVENBY.js";import{i as ne,k as ke}from"./chunk-AKLZ4YO2.js";import{G as K}from"./chunk-FEEXOWK5.js";import{a as L,b as F}from"./chunk-LUYN6RAC.js";import{a as ve}from"./chunk-RJOA7QBB.js";import{a as be}from"./chunk-JP5OAMWQ.js";import{B as dt,S as fe,Z as ct,ma as ee,oa as H,pa as he,w as Z,x as me,xa as te}from"./chunk-DYGQF3MI.js";import{existsSync as j,readFileSync as Oe,writeFileSync as Ue,appendFileSync as ut,mkdirSync as mt}from"fs";import{dirname as ft,resolve as _}from"path";import{fileURLToPath as ht}from"url";import{hostname as bt}from"os";import{spawn as vt}from"child_process";function Me(e,t){let n=e.configExists?e.agentCount===0?"Add your first agent":"Add another agent":"Set up your team",a=`<header class="ax-topbar">
|
|
2
2
|
<div class="ax-topbar__left">
|
|
3
3
|
<div class="ax-brand">
|
|
4
4
|
<span class="ax-brand__mark">AX</span>
|
|
@@ -14,7 +14,7 @@ import{a as Te,b as w,c as D,d as Pe,e as te,f as ne,g as M,h as ae,i as N,j as
|
|
|
14
14
|
<button data-theme-opt="light">Light</button>
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
|
17
|
-
</header>`,o=B(1,"Team basics",T({name:"nodeName",label:"Team name",hint:"(what you'd call this AgentX install)",value:t,placeholder:"My Team",required:!0})),r=B(2,"First agent",
|
|
17
|
+
</header>`,o=B(1,"Team basics",T({name:"nodeName",label:"Team name",hint:"(what you'd call this AgentX install)",value:t,placeholder:"My Team",required:!0})),r=B(2,"First agent",re([T({name:"agentName",label:"Agent name",value:"Assistant",placeholder:"Support Bot",required:!0}),T({name:"agentId",label:"Agent id",hint:"(lowercase, no spaces)",value:"assistant",pattern:"[a-z0-9][a-z0-9_-]*",required:!0})])+T({name:"triggerWords",label:"Trigger words",hint:"(comma or space separated \u2014 e.g. <code>@support, support</code>)",value:"@assistant, assistant",required:!0})+re([T({name:"tier",label:"AI engine",type:"select",options:[{value:"claude-code",label:"Claude Code (recommended)",selected:!0},{value:"codex-cli",label:"Codex CLI"},{value:"opencode",label:"OpenCode CLI"},{value:"sdk",label:"Anthropic API (BYO key)"},{value:"orchestrator",label:"Orchestrator (any provider)"}]}),T({name:"model",label:"Model",hint:"(optional)",value:"claude-sonnet-4-6",placeholder:"claude-sonnet-4-6"})])+T({name:"personality",label:"Personality / instructions",hint:"(optional \u2014 what this agent does, in plain English)",type:"textarea",placeholder:"You are a support agent for Acme Co. Answer customer questions about our product, be friendly, keep replies short."})),i=B(3,"First channel",`
|
|
18
18
|
<label class="ax-toggle"><input type="checkbox" id="enableTelegram" /> Connect Telegram now</label>
|
|
19
19
|
<div class="ax-optional" id="telegramFields">
|
|
20
20
|
${T({name:"telegramAccountId",label:"Account id",hint:"(a label you choose \u2014 e.g. <code>support</code>)",value:"default"})}
|
|
@@ -24,7 +24,7 @@ import{a as Te,b as w,c as D,d as Pe,e as te,f as ne,g as M,h as ae,i as N,j as
|
|
|
24
24
|
`),s=B(4,"Anthropic API key",T({name:"anthropicApiKey",label:"API key",hint:"(optional \u2014 skip if you're using Claude Code)",type:"password",placeholder:"sk-ant-\u2026",extraAttrs:'autocomplete="off"'})+`<div class="ax-hint-block">
|
|
25
25
|
The key is stored in <code>.env</code> as <code>ANTHROPIC_API_KEY</code> and used to authenticate requests to Anthropic. Keep it private.
|
|
26
26
|
</div>`),l=e.configExists?`<div class="ax-banner">Existing install: <b>${e.agentCount}</b> agent(s), <b>${e.channelCount}</b> channel(s) already configured. This wizard will add to it.</div>`:"",c=`<div class="ax-wizard">
|
|
27
|
-
<h1 class="ax-wizard__h1">${
|
|
27
|
+
<h1 class="ax-wizard__h1">${Se(n)}</h1>
|
|
28
28
|
<p class="ax-wizard__lead">Fill in the basics below. We'll write <code>agentx.json</code>, set up a folder for your first agent, and point you at the next step.</p>
|
|
29
29
|
|
|
30
30
|
${l}
|
|
@@ -37,11 +37,11 @@ import{a as Te,b as w,c as D,d as Pe,e as te,f as ne,g as M,h as ae,i as N,j as
|
|
|
37
37
|
${i}
|
|
38
38
|
${s}
|
|
39
39
|
<footer class="ax-actions">
|
|
40
|
-
${
|
|
41
|
-
${
|
|
40
|
+
${ae("Save and continue",{type:"submit",primary:!0,id:"submitBtn"})}
|
|
41
|
+
${ae("Skip, I'll do it later",{onclick:"window.location.href='/live'"})}
|
|
42
42
|
</footer>
|
|
43
43
|
</form>
|
|
44
|
-
</div>`;return
|
|
44
|
+
</div>`;return Ie({title:"AgentX \u2014 Setup",activeTab:"custom",subtitle:"Setup",customHeader:a,noMain:!0,body:c,css:pt,scripts:gt})}var pt=`
|
|
45
45
|
/* Pre-dashboard topbar variant \u2014 no tab nav, the pills are the only chrome. */
|
|
46
46
|
.ax-topbar__right a.ax-skip {
|
|
47
47
|
padding: 4px 10px; border: 1px solid var(--ax-border-2); border-radius: 4px;
|
|
@@ -98,7 +98,7 @@ import{a as Te,b as w,c as D,d as Pe,e as te,f as ne,g as M,h as ae,i as N,j as
|
|
|
98
98
|
.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); }
|
|
99
99
|
.ax-startd { margin-top: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
|
|
100
100
|
.ax-startd__status { color: var(--ax-text-2); font-size: var(--ax-fs-sm); }
|
|
101
|
-
.ax-startd__status a { color: var(--ax-accent); }`,
|
|
101
|
+
.ax-startd__status a { color: var(--ax-accent); }`,gt=`<script>
|
|
102
102
|
document.getElementById('enableTelegram').addEventListener('change', (e) => {
|
|
103
103
|
document.getElementById('telegramFields').classList.toggle('is-show', e.target.checked);
|
|
104
104
|
});
|
|
@@ -172,15 +172,15 @@ document.getElementById('wizard').addEventListener('submit', async (e) => {
|
|
|
172
172
|
btn.disabled = false; btn.textContent = 'Save and continue';
|
|
173
173
|
}
|
|
174
174
|
});
|
|
175
|
-
</script>`;
|
|
175
|
+
</script>`;te();function Be(e=process.cwd()){let t=_(e,"agentx.json");if(!j(t))return{configExists:!1,agentCount:0,channelCount:0};try{let n=JSON.parse(Oe(t,"utf-8")),a=n.agents?Object.keys(n.agents).length:0,o=n.channels?Object.values(n.channels).filter(r=>r&&r.enabled).length:0;return{configExists:!0,agentCount:a,channelCount:o,nodeName:n.node?.name}}catch{return{configExists:!1,agentCount:0,channelCount:0}}}function xt(e,t=process.cwd()){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 n=yt(e.agent.triggerWords);if(n.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 a=_(t,"agentx.json"),o=_(t,".env"),r=_(t,"agents",e.agent.id),i=Be(t);mt(r,{recursive:!0});let s=_(r,"CLAUDE.md");if(!j(s)){let m=e.agent.personality?.trim()||`You are ${e.agent.name}, an assistant on the ${e.nodeName} team.`;Ue(s,`# ${e.agent.name}
|
|
176
176
|
|
|
177
177
|
${m}
|
|
178
|
-
`)}let l=e.telegram?`TG_${e.agent.id.toUpperCase()}_BOT_TOKEN`:void 0,c;if(i.configExists)c=
|
|
178
|
+
`)}let l=e.telegram?`TG_${e.agent.id.toUpperCase()}_BOT_TOKEN`:void 0,c;if(i.configExists)c=G(p=>{if(p.node=p.node||{},p.node.name||(p.node.name=e.nodeName),p.node.id||(p.node.id=je(e.nodeName)||"team"),p.node.bind||(p.node.bind="127.0.0.1:18800"),p.node.defaultAgent=p.node.defaultAgent||e.agent.id,p.providers=p.providers||{},p.providers.claude||(p.providers.claude={apiKey:"${ANTHROPIC_API_KEY}"}),p.agents=p.agents||{},p.agents[e.agent.id])throw new Error(`Agent "${e.agent.id}" already exists.`);return p.agents[e.agent.id]=qe(e,r,n),e.telegram&&(p.channels=p.channels||{},p.channels.telegram=p.channels.telegram||{enabled:!0,accounts:{},policy:{dm:"pair",group:"mention-required"}},p.channels.telegram.enabled=!0,p.channels.telegram.accounts=p.channels.telegram.accounts||{},p.channels.telegram.accounts[e.telegram.accountId]=He(e,l)),{summary:`added agent "${e.agent.id}"`+(e.telegram?" + telegram account":"")}},{configPath:a}).backupPath;else{let m=wt(e,r,n,l);Ce(m,{configPath:a})}kt(o,e,l);let d=[];return(e.anthropicApiKey||!j(_(t,".env")))&&d.push("Double-check the API keys in .env"),e.agent.tier==="claude-code"&&d.push("Run claude --version to confirm Claude Code is installed (needed for the claude-code engine)"),e.agent.tier==="codex-cli"&&d.push("Run codex --version to confirm Codex CLI is installed (needed for the codex-cli engine)"),e.agent.tier==="opencode"&&d.push("Run opencode --version to confirm OpenCode is installed and authenticated"),d.push("Start the daemon: agentx daemon start"),d.push("Open the dashboard: http://127.0.0.1:4202"),{summary:i.configExists?`Added agent "${e.agent.id}" to your team.`:`Initialized your team with first agent "${e.agent.id}".`,nextSteps:d,backupPath:c}}function yt(e){return(e||"").split(/[,\s]+/).map(t=>t.trim()).filter(Boolean).filter((t,n,a)=>a.indexOf(t)===n)}function je(e){return(e||"").toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"")}function wt(e,t,n,a){let r={node:{id:je(e.nodeName)||"team",name:e.nodeName,bind:"127.0.0.1:18800",defaultAgent:e.agent.id},providers:{claude:{apiKey:"${ANTHROPIC_API_KEY}"}},agents:{[e.agent.id]:qe(e,t,n)},channels:{},crons:{},mesh:{enabled:!1,peers:[],discovery:"static",healthCheck:{interval:60,timeout:10}},dashboard:{enabled:!0,port:4202,bind:"127.0.0.1",daemonUrl:"http://localhost:18800"},boards:[]};return e.telegram&&a?r.channels.telegram={enabled:!0,accounts:{[e.telegram.accountId]:He(e,a)},policy:{dm:"pair",group:"mention-required"}}:r.channels.telegram={enabled:!1,accounts:{},policy:{dm:"pair",group:"mention-required"}},r}function qe(e,t,n){let a={name:e.agent.name,workspace:t,tier:e.agent.tier,mentions:n,maxConcurrent:2,permissionMode:"default"};return e.agent.model&&(a.model=e.agent.model),e.agent.personality?.trim()&&(a.systemPrompt=e.agent.personality.trim().slice(0,400)),a}function He(e,t){return e.telegram?.botUsername,{token:"${"+t+"}",agentBinding:e.agent.id}}function kt(e,t,n){let a=j(e)?Oe(e,"utf-8"):"",o=[];if(t.anthropicApiKey&&!a.includes("ANTHROPIC_API_KEY=")&&o.push(`ANTHROPIC_API_KEY=${t.anthropicApiKey}`),t.telegram&&n&&!a.includes(`${n}=`)&&o.push(`${n}=${t.telegram.botToken}`),!j(e)){Ue(e,[...["# AgentX environment variables","# (Never commit this file \u2014 it contains secrets.)",""],...o,""].join(`
|
|
179
179
|
`));return}if(o.length>0){let r=a.endsWith(`
|
|
180
180
|
`)?"":`
|
|
181
|
-
`;
|
|
181
|
+
`;ut(e,r+o.join(`
|
|
182
182
|
`)+`
|
|
183
|
-
`)}}function wn(e,t){let n=Ue(),a=n.nodeName||ht().replace(/\.local$/,""),o=We(n,a);t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end(o)}async function kn(e,t){let n="";await new Promise(o=>{e.on("data",r=>{n+=r}),e.on("end",()=>o())});let a;try{a=JSON.parse(n)}catch{t.writeHead(400,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:"Invalid JSON"}));return}try{let o=bt(a);t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify(o))}catch(o){t.writeHead(400,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:o.message||"wizard failed"}))}}async function $n(e,t){t.setHeader("Content-Type","application/json");let n;try{n=ge().node?.bind||"127.0.0.1:18800"}catch(i){t.writeHead(400),t.end(JSON.stringify({ok:!1,error:`Config validation failed: ${i.message}`}));return}let a=`http://${n.replace(/^0\.0\.0\.0/,"127.0.0.1")}`;if(await Me(a)){t.writeHead(200),t.end(JSON.stringify({ok:!0,url:a,alreadyRunning:!0}));return}let o=process.argv[1]||_(mt(ft(import.meta.url)),"cli.js");try{vt(process.execPath,[o,"daemon","start"],{detached:!0,stdio:"ignore",cwd:process.cwd()}).unref()}catch(i){t.writeHead(500),t.end(JSON.stringify({ok:!1,error:`Failed to spawn daemon: ${i.message}`,manualUrl:a}));return}let r=Date.now()+12e3;for(;Date.now()<r;)if(await new Promise(i=>setTimeout(i,400)),await Me(a)){t.writeHead(200),t.end(JSON.stringify({ok:!0,url:a,alreadyRunning:!1}));return}t.writeHead(504),t.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:a}))}async function Me(e){try{let t=await fetch(e,{method:"GET",signal:AbortSignal.timeout(800)});return t.status>0&&t.status<600}catch{return!1}}import{existsSync as kt,readFileSync as $t}from"fs";ue();function En(e){let t=he(e),n={};if(kt(t))try{n=pe(JSON.parse($t(t,"utf-8")))}catch{n={}}let a=X.safeParse(n?.approvals);return a.success?a.data:X.parse(void 0)}function Tn(e){let t=e.indexOf(":");return t<=0||t===e.length-1?null:{channel:e.slice(0,t).trim(),chatId:e.slice(t+1).trim()}}async function Pn(e,t={}){return ve(n=>{let a=n.approvals??={};if(e.defaultExpiryDays!==void 0&&(a.defaultExpiryDays=e.defaultExpiryDays),e.maxExpiryDays!==void 0&&(a.maxExpiryDays=e.maxExpiryDays),e.laterHours!==void 0&&(a.laterHours=e.laterHours),e.notifyAgent!==void 0&&(a.notifyAgent=e.notifyAgent),e.forwardTo===null)delete a.forwardTo;else if(e.forwardTo!==void 0){let c=Array.isArray(n.mesh?.peers)?n.mesh.peers:[];if(!c.some(d=>d.name===e.forwardTo))throw new Error(`"${e.forwardTo}" is not in mesh.peers${c.length?` (known: ${c.map(d=>d.name).join(", ")})`:""}; pair the machines first`);a.forwardTo=e.forwardTo}let o=a.digest??={};e.digestEnabled!==void 0&&(o.enabled=e.digestEnabled),e.digestTime!==void 0&&(o.time=e.digestTime),e.digestTimezone===null?delete o.timezone:e.digestTimezone!==void 0&&(o.timezone=e.digestTimezone),e.destination===null?delete o.destination:e.destination!==void 0&&(o.destination=e.destination);let r=a.popup??={};e.popupEnabled!==void 0&&(r.enabled=e.popupEnabled),e.popupSpeak!==void 0&&(r.speak=e.popupSpeak),e.popupVoice===null?delete r.voice:e.popupVoice!==void 0&&(r.voice=e.popupVoice),e.popupSound!==void 0&&(r.sound=e.popupSound),e.popupTimeoutSeconds!==void 0&&(r.timeoutSeconds=e.popupTimeoutSeconds),e.popupStyle!==void 0&&(r.style=e.popupStyle),e.popupTheme!==void 0&&(r.theme=e.popupTheme);let i=a.checkin??={};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);let s=a.defaultExpiryDays??3,l=a.maxExpiryDays??30;if(s>l)throw new Error(`defaultExpiryDays (${s}) can't be more than maxExpiryDays (${l})`)},{configPath:t.configPath,reload:t.reload})}import{createServer as Pt}from"http";var q=class{peers;cache=new Map;ttl=3e4;constructor(t){this.peers=t.map(n=>({...n,url:n.url.replace(/\/$/,"")}))}async getRemoteAgents(){let t=[];return await Promise.all(this.peers.map(async n=>{try{let a=await this.fetchJson(`${n.url}/wiki/agents`);n.nodeId=a.nodeId;for(let o of a.agents||[])(o.totalEntries>0||o.totalArticles>0)&&t.push({...o,nodeId:a.nodeId,peerUrl:n.url})}catch{}})),t}async getRemoteArticles(t,n){try{return(await this.fetchJson(`${t}/wiki/articles?agent=${encodeURIComponent(n)}`)).articles||[]}catch{return[]}}async getRemoteArticle(t,n,a){try{let o=await this.fetchJson(`${t}/wiki/article?agent=${encodeURIComponent(n)}&path=${encodeURIComponent(a)}`);return{meta:{title:o.title,tags:o.tags||[],owner:o.owner,access:"public",created:o.created,lastUpdated:o.lastUpdated,sources:o.sources||[]},content:o.content,path:o.path}}catch{return null}}async fetchJson(t){let n=this.cache.get(t);if(n&&Date.now()-n.ts<this.ttl)return n.data;let a=this.peers.find(i=>t.startsWith(`${i.url}/`))?.token,o=await fetch(t,{headers:a?{Authorization:`Bearer ${a}`}:{},signal:AbortSignal.timeout(5e3)});if(!o.ok)throw new Error(`HTTP ${o.status}`);let r=await o.json();return this.cache.set(t,{data:r,ts:Date.now()}),r}};var Le=864e5;function re(e){let t=new Map;for(let n of e.entities.values()){let a=t.get(n.type)??[];a.push(n),t.set(n.type,a)}return t}function oe(e,t){if(t.type==="event")return t.date||t.updated;let n=Te(e,t,new Set(["event"]))[0],a=t.updated||t.date;return n&&n.date>a?n.date:a}function qe(e,t,n=Date.now()){let a=[],o=new Date(n+14*Le).toISOString().slice(0,10),r=new Date(n).toISOString().slice(0,10);for(let s of t){let l=s.statements.find(d=>d.property==="due"&&/^\d{4}-\d{2}-\d{2}/.test(d.value)),c=s.statements.some(d=>d.property==="fulfilled_by")||s.statements.some(d=>d.property==="status"&&/^(fulfilled|done|paid|filed)$/i.test(d.value));s.statements.some(d=>d.property==="status"&&/^late$/i.test(d.value))?a.push({e:s,chip:"late",why:"marked late"}):l&&!c&&l.value<r?a.push({e:s,chip:"late",why:`was due ${l.value}`}):l&&!c&&l.value<=o?a.push({e:s,chip:"due",why:`due ${l.value}`}):s.statements.some(d=>d.status==="proposed")?a.push({e:s,chip:"proposed",why:"statements wait for confirmation"}):s.type==="event"&&s.importance==="major"&&s.date&&n-Date.parse(s.date)<=30*Le&&a.push({e:s,chip:"major",why:`major event ${s.date}`})}let i={late:0,due:1,major:2,proposed:3};return a.sort((s,l)=>i[s.chip]-i[l.chip])}function F(e,t,n="",a){return`<div class="ox-row"><span class="ox-ic">${Pe(e.ontology,t.type)}</span><div class="t"><a href="${ne(t.id)}">${w(t.title)}</a><div class="ox-sub">${w(a??`${te(e.ontology,t.type).toLowerCase()} \xB7 ${oe(e,t)}`)}</div></div><div class="r">${n}</div></div>`}function Fe(e,t){let n=t.slice(0,6).map(a=>F(e,a.e,`<span class="ox-st ${a.chip}">${a.chip}</span>`,a.why)).join("");return`<section class="ox-card"><div class="ox-card-h"><h2>Needs attention</h2><span class="note">${t.length}</span></div>${n||'<div class="ox-empty">Nothing waits on a person.</div>'}</section>`}function At(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 Ke(e,t){let n=re(e),a=`<div class="ox-bar">${M([])}</div>`;a+=`<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>`,a+=At(t),a+='<div class="ox-grid3">';for(let r of e.ontology.pillars){let i=e.ontology.types.filter(c=>c.pillar===r.id),s=i.reduce((c,d)=>c+(n.get(d.id)?.length??0),0),l=i.filter(c=>n.get(c.id)?.length).map(c=>`${c.plural??c.label} ${n.get(c.id).length}`).join(" \xB7 ");a+=`<a class="ox-card" href="/p/${encodeURIComponent(r.id)}" style="color:inherit"><div class="ox-card-h"><span class="ox-ic">${D(r.icon)}</span><h2>${w(r.label)}</h2><span class="zin">${s}</span></div><div class="ox-sub" style="white-space:normal">${w(r.description??"")}</div><div class="ox-sub" style="margin-top:6px;white-space:normal">${w(l||"nothing yet")}</div></a>`}a+='</div><div class="ox-grid2">';let o=(n.get("event")??[]).filter(r=>r.importance!=="minor").sort((r,i)=>i.date.localeCompare(r.date)).slice(0,8);return a+='<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>'+(o.map(r=>`<div class="ox-ev"><span class="d">${w(r.date)}</span><span class="ox-st ${r.importance}">${r.importance}</span><a href="${ne(r.id)}">${w(r.title)}</a></div>`).join("")||'<div class="ox-empty">No events yet.</div>')+"</section>",a+=Fe(e,qe(e,[...e.entities.values()])),a+="</div>",O("Wiki",N(e,{home:!0}),a)}function Ge(e,t,n){let a=e.ontology.pillars.find(d=>d.id===t);if(!a)return null;let o=re(e),r=e.ontology.types.filter(d=>d.pillar===a.id),i=r.find(d=>d.id===n)??r.find(d=>o.get(d.id)?.length)??r[0],s=`<div class="ox-bar">${M([{label:a.label}])}${ae(1)}</div>`;s+=`<div class="ox-head"><div class="ox-avatar">${D(a.icon)}</div><div><h1>${w(a.label)}</h1><p>${w(a.description??"")}</p></div></div>`,s+=`<nav class="ox-tabs">${r.map(d=>`<a class="${d.id===i?.id?"on":""}" href="/p/${encodeURIComponent(a.id)}?kind=${encodeURIComponent(d.id)}">${w(d.plural??d.label)}<small>${o.get(d.id)?.length??0}</small></a>`).join("")}</nav>`;let l=i?(o.get(i.id)??[]).map(d=>({e:d,at:oe(e,d)})).sort((d,m)=>m.at.localeCompare(d.at)):[];s+='<div class="ox-grid2">',s+=`<section class="ox-card"><div class="ox-card-h"><h2>${w(i?.plural??i?.label??"")}</h2><span class="note">${l.length} \xB7 most active first</span>`+(i?`<a class="zin" href="/p/${encodeURIComponent(a.id)}/${encodeURIComponent(i.id)}">open list (Z3) \u2192</a>`:"")+"</div>"+(l.slice(0,5).map(({e:d,at:m})=>F(e,d,d.type==="event"?`<span class="ox-st ${d.importance}">${d.importance}</span>`:"",`${Re(d,90)||te(e.ontology,d.type).toLowerCase()} \xB7 ${m}`)).join("")||`<div class="ox-empty">No ${w((i?.plural??"pages").toLowerCase())} yet.</div>`)+"</section>";let c=r.flatMap(d=>o.get(d.id)??[]);return s+=Fe(e,qe(e,c)),s+="</div>",O(a.label,N(e,{pillar:a.id}),s)}function Je(e,t,n,a,o){let r=o&&me.includes(o)?o:null,i=e.ontology.pillars.find(u=>u.id===t),s=e.ontology.types.find(u=>u.id===n&&u.pillar===t);if(!i||!s)return null;let l=[...e.entities.values()].filter(u=>u.type===s.id);r&&(l=l.filter(u=>u.importance===r));let c=l.map(u=>({e:u,at:oe(e,u)})).sort((u,f)=>f.at.localeCompare(u.at)),d=50,m=Math.max(1,Math.ceil(c.length/d)),p=`/p/${encodeURIComponent(i.id)}/${encodeURIComponent(s.id)}`,k=`<div class="ox-bar">${M([{label:i.label,href:`/p/${encodeURIComponent(i.id)}`},{label:s.plural??s.label}])}${ae(3)}</div>`;if(k+=`<div class="ox-head"><div class="ox-avatar">${D(s.icon)}</div><div><h1>${w(s.plural??s.label)}</h1><p>${c.length} page${c.length===1?"":"s"}${r?` \xB7 ${w(r)} only`:""}</p></div></div>`,s.id==="event"&&(k+=`<nav class="ox-tabs">${["","major","normal","minor"].map(u=>`<a class="${(r??"")===u?"on":""}" href="${p}${u?`?importance=${u}`:""}">${u||"all"}</a>`).join("")}</nav>`),k+='<section class="ox-card" style="margin-top:16px">'+(c.slice((a-1)*d,a*d).map(({e:u,at:f})=>F(e,u,u.type==="event"?`<span class="ox-st ${u.importance}">${u.importance}</span>`:"",`${f} \xB7 ${u.pages.map(I=>I.agentId).filter((I,x,b)=>b.indexOf(I)===x).join(", ")}`)).join("")||'<div class="ox-empty">None.</div>')+"</section>",m>1){let u=r?`importance=${r}&`:"";k+=`<div class="ox-pager">${a>1?`<a href="${p}?${u}page=${a-1}">\u2190 previous</a>`:""}<span>page ${a} of ${m}</span>${a<m?`<a href="${p}?${u}page=${a+1}">next \u2192</a>`:""}</div>`}return O(s.plural??s.label,N(e,{pillar:i.id}),k)}function Ye(e,t){let n=t.trim().toLowerCase(),a=[];if(n)for(let r of e.entities.values()){let i=r.title.toLowerCase(),s=i===n?100:i.startsWith(n)?60:i.includes(n)?40:0;!s&&r.pages.some(l=>l.article.content.toLowerCase().includes(n))&&(s=10),s&&a.push({e:r,s})}a.sort((r,i)=>i.s-r.s||i.e.updated.localeCompare(r.e.updated));let o=`<div class="ox-bar">${M([{label:"Search"}])}</div>`;return o+=`<div class="ox-head"><div class="ox-avatar">${D("search")}</div><div><h1>${n?`\u201C${w(t)}\u201D`:"Search"}</h1><p>${a.length} match${a.length===1?"":"es"}</p></div></div>`,o+=`<section class="ox-card">${a.slice(0,60).map(({e:r})=>F(e,r)).join("")||'<div class="ox-empty">No page matches.</div>'}</section>`,O(`Search: ${t}`,N(e,{}),o,"",t)}function Xe(e,t,n){let a=e.ontology,o=re(e),r=`<div class="ox-bar">${M([{label:"Ontology"}])}</div>`;r+=`<div class="ox-head"><div class="ox-avatar">${D("steps")}</div><div><h1>Ontology</h1><p>${n?`Read from ${w(n)}`:"Built-in defaults. Run <code>agentx wiki ontology init</code> to write an ontology.yaml you can edit."}</p></div></div>`,t.length&&(r+=`<div class="ox-err"><b>Problems</b><ul>${t.map(i=>`<li>${w(i)}</li>`).join("")}</ul></div>`),r+=`<section class="ox-card"><div class="ox-card-h"><h2>Types</h2><span class="note">${a.types.length}</span></div>`;for(let i of a.types){let s=a.pillars.find(l=>l.id===i.pillar);r+=`<div class="ox-row"><span class="ox-ic">${D(i.icon)}</span><div class="t"><span class="l">${w(i.label)} <span class="ox-sub">${w(i.id)}</span></span><div class="ox-sub">${w(s?.label??i.pillar)} \xB7 lens: ${w((i.lens??[]).map(l=>l.title??l.panel).join(" \u2192 "))}</div></div><div class="r"><span class="ox-chip">${o.get(i.id)?.length??0}</span></div></div>`}r+=`</section><section class="ox-card" style="margin-top:16px"><div class="ox-card-h"><h2>Relations</h2><span class="note">${a.properties.length}</span></div>`;for(let i of a.properties)r+=`<div class="ox-kv"><span class="k">${w(i.id)}</span><span>${w(i.label)}${i.inverse?` \xB7 inverse: ${w(i.inverse)}`:""}${i.wikidata?` <span class="ox-sub">${w(i.wikidata)}</span>`:""}</span></div>`;return r+=`</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>${w(a.importance.default)}</span></div><div class="ox-kv"><span class="k">major set by</span><span>${w(a.importance.major_set_by)}</span></div><div class="ox-kv"><span class="k">roll-up</span><span>${a.importance.rollup.min} minor events in ${a.importance.rollup.days} days</span></div></section>`,O("Ontology",N(e,{}),r)}var K=class{constructor(t,n){this.hub=t;this.wikiDir=n}cache=new Ee;pageAt(t){if(!t.startsWith("/e/"))return null;let{ontology:n}=ee(this.wikiDir),o=this.cache.get(this.hub,n).entities.get(t.split("/").filter(Boolean)[1]??"")?.pages[0];return o?{agentId:o.agentId,path:o.article.path,title:o.article.meta.title}:null}handle(t,n){if(!(t==="/"||t===""||t.startsWith("/p/")||t.startsWith("/e/")||t==="/find"||t==="/ontology"))return null;let{ontology:a,errors:o,file:r}=ee(this.wikiDir),i=Ce(this.wikiDir,this.hub.listAgents([]),a.agent_names),s=this.cache.get(this.hub,a,i),l=Math.max(1,Number(n.get("page"))||1);if(t==="/"||t==="")return Ke(s,o);if(t==="/find")return Ye(s,n.get("q")??"");if(t==="/ontology")return Xe(s,o,r);let c=t.split("/").filter(Boolean);if(c[0]==="p")return c.length===2?Ge(s,c[1],n.get("kind")):c.length===3?Je(s,c[1],c[2],l,n.get("importance")):null;let d=s.entities.get(c[1]??"");if(!d)return null;let m={g:s,readEntries:p=>this.hub.getSharedStore().readEntries(p),versions:(p,k)=>this.hub.getAgentWiki(p).getVersions(k)};return c.length===2?ze(m,d):c.length===3?De(m,d,c[2],l):c.length===4&&c[2]==="s"?_e(m,d,Number(c[3])):null}};var St=`
|
|
183
|
+
`)}}function An(e,t){let n=Be(),a=n.nodeName||bt().replace(/\.local$/,""),o=Me(n,a);t.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),t.end(o)}async function Sn(e,t){let n="";await new Promise(o=>{e.on("data",r=>{n+=r}),e.on("end",()=>o())});let a;try{a=JSON.parse(n)}catch{t.writeHead(400,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:"Invalid JSON"}));return}try{let o=xt(a);t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify(o))}catch(o){t.writeHead(400,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:o.message||"wizard failed"}))}}async function In(e,t){t.setHeader("Content-Type","application/json");let n;try{n=he().node?.bind||"127.0.0.1:18800"}catch(i){t.writeHead(400),t.end(JSON.stringify({ok:!1,error:`Config validation failed: ${i.message}`}));return}let a=`http://${n.replace(/^0\.0\.0\.0/,"127.0.0.1")}`;if(await Ne(a)){t.writeHead(200),t.end(JSON.stringify({ok:!0,url:a,alreadyRunning:!0}));return}let o=process.argv[1]||_(ft(ht(import.meta.url)),"cli.js");try{vt(process.execPath,[o,"daemon","start"],{detached:!0,stdio:"ignore",cwd:process.cwd()}).unref()}catch(i){t.writeHead(500),t.end(JSON.stringify({ok:!1,error:`Failed to spawn daemon: ${i.message}`,manualUrl:a}));return}let r=Date.now()+12e3;for(;Date.now()<r;)if(await new Promise(i=>setTimeout(i,400)),await Ne(a)){t.writeHead(200),t.end(JSON.stringify({ok:!0,url:a,alreadyRunning:!1}));return}t.writeHead(504),t.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:a}))}async function Ne(e){try{let t=await fetch(e,{method:"GET",signal:AbortSignal.timeout(800)});return t.status>0&&t.status<600}catch{return!1}}import{existsSync as $t,readFileSync as At}from"fs";te();function Pn(e){let t=L(e),n={};if($t(t))try{n=H(JSON.parse(At(t,"utf-8")))}catch{n={}}let a=ee.safeParse(n?.approvals);return a.success?a.data:ee.parse(void 0)}function Dn(e){let t=e.indexOf(":");return t<=0||t===e.length-1?null:{channel:e.slice(0,t).trim(),chatId:e.slice(t+1).trim()}}async function zn(e,t={}){return F(n=>{let a=n.approvals??={};if(e.defaultExpiryDays!==void 0&&(a.defaultExpiryDays=e.defaultExpiryDays),e.maxExpiryDays!==void 0&&(a.maxExpiryDays=e.maxExpiryDays),e.laterHours!==void 0&&(a.laterHours=e.laterHours),e.notifyAgent!==void 0&&(a.notifyAgent=e.notifyAgent),e.forwardTo===null)delete a.forwardTo;else if(e.forwardTo!==void 0){let c=Array.isArray(n.mesh?.peers)?n.mesh.peers:[];if(!c.some(d=>d.name===e.forwardTo))throw new Error(`"${e.forwardTo}" is not in mesh.peers${c.length?` (known: ${c.map(d=>d.name).join(", ")})`:""}; pair the machines first`);a.forwardTo=e.forwardTo}let o=a.digest??={};e.digestEnabled!==void 0&&(o.enabled=e.digestEnabled),e.digestTime!==void 0&&(o.time=e.digestTime),e.digestTimezone===null?delete o.timezone:e.digestTimezone!==void 0&&(o.timezone=e.digestTimezone),e.destination===null?delete o.destination:e.destination!==void 0&&(o.destination=e.destination);let r=a.popup??={};e.popupEnabled!==void 0&&(r.enabled=e.popupEnabled),e.popupSpeak!==void 0&&(r.speak=e.popupSpeak),e.popupVoice===null?delete r.voice:e.popupVoice!==void 0&&(r.voice=e.popupVoice),e.popupSound!==void 0&&(r.sound=e.popupSound),e.popupTimeoutSeconds!==void 0&&(r.timeoutSeconds=e.popupTimeoutSeconds),e.popupStyle!==void 0&&(r.style=e.popupStyle),e.popupTheme!==void 0&&(r.theme=e.popupTheme);let i=a.checkin??={};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);let s=a.defaultExpiryDays??3,l=a.maxExpiryDays??30;if(s>l)throw new Error(`defaultExpiryDays (${s}) can't be more than maxExpiryDays (${l})`)},{configPath:t.configPath,reload:t.reload})}import{createServer as Pt}from"http";var J=class{peers;cache=new Map;ttl=3e4;constructor(t){this.peers=t.map(n=>({...n,url:n.url.replace(/\/$/,"")}))}async getRemoteAgents(){let t=[];return await Promise.all(this.peers.map(async n=>{try{let a=await this.fetchJson(`${n.url}/wiki/agents`);n.nodeId=a.nodeId;for(let o of a.agents||[])(o.totalEntries>0||o.totalArticles>0)&&t.push({...o,nodeId:a.nodeId,peerUrl:n.url})}catch{}})),t}async getRemoteArticles(t,n){try{return(await this.fetchJson(`${t}/wiki/articles?agent=${encodeURIComponent(n)}`)).articles||[]}catch{return[]}}async getRemoteArticle(t,n,a){try{let o=await this.fetchJson(`${t}/wiki/article?agent=${encodeURIComponent(n)}&path=${encodeURIComponent(a)}`);return{meta:{title:o.title,tags:o.tags||[],owner:o.owner,access:"public",created:o.created,lastUpdated:o.lastUpdated,sources:o.sources||[]},content:o.content,path:o.path}}catch{return null}}async fetchJson(t){let n=this.cache.get(t);if(n&&Date.now()-n.ts<this.ttl)return n.data;let a=this.peers.find(i=>t.startsWith(`${i.url}/`))?.token,o=await fetch(t,{headers:a?{Authorization:`Bearer ${a}`}:{},signal:AbortSignal.timeout(5e3)});if(!o.ok)throw new Error(`HTTP ${o.status}`);let r=await o.json();return this.cache.set(t,{data:r,ts:Date.now()}),r}};var Le=864e5;function de(e){let t=new Map;for(let n of e.entities.values()){let a=t.get(n.type)??[];a.push(n),t.set(n.type,a)}return t}function ce(e,t){if(t.type==="event")return t.date||t.updated;let n=Re(e,t,new Set(["event"]))[0],a=t.updated||t.date;return n&&n.date>a?n.date:a}function Fe(e,t,n=Date.now()){let a=[],o=new Date(n+14*Le).toISOString().slice(0,10),r=new Date(n).toISOString().slice(0,10);for(let s of t){let l=s.statements.find(d=>d.property==="due"&&/^\d{4}-\d{2}-\d{2}/.test(d.value)),c=s.statements.some(d=>d.property==="fulfilled_by")||s.statements.some(d=>d.property==="status"&&/^(fulfilled|done|paid|filed)$/i.test(d.value));s.statements.some(d=>d.property==="status"&&/^late$/i.test(d.value))?a.push({e:s,chip:"late",why:"marked late"}):l&&!c&&l.value<r?a.push({e:s,chip:"late",why:`was due ${l.value}`}):l&&!c&&l.value<=o?a.push({e:s,chip:"due",why:`due ${l.value}`}):s.statements.some(d=>d.status==="proposed")?a.push({e:s,chip:"proposed",why:"statements wait for confirmation"}):s.type==="event"&&s.importance==="major"&&s.date&&n-Date.parse(s.date)<=30*Le&&a.push({e:s,chip:"major",why:`major event ${s.date}`})}let i={late:0,due:1,major:2,proposed:3};return a.sort((s,l)=>i[s.chip]-i[l.chip])}function Y(e,t,n="",a){return`<div class="ox-row"><span class="ox-ic">${Pe(e.ontology,t.type)}</span><div class="t"><a href="${se(t.id)}">${w(t.title)}</a><div class="ox-sub">${w(a??`${ie(e.ontology,t.type).toLowerCase()} \xB7 ${ce(e,t)}`)}</div></div><div class="r">${n}</div></div>`}function Ke(e,t){let n=t.slice(0,6).map(a=>Y(e,a.e,`<span class="ox-st ${a.chip}">${a.chip}</span>`,a.why)).join("");return`<section class="ox-card"><div class="ox-card-h"><h2>Needs attention</h2><span class="note">${t.length}</span></div>${n||'<div class="ox-empty">Nothing waits on a person.</div>'}</section>`}function St(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 Ge(e,t){let n=de(e),a=`<div class="ox-bar">${M([])}</div>`;a+=`<div class="ox-head"><div class="ox-avatar">${z("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>`,a+=St(t),a+='<div class="ox-grid3">';for(let r of e.ontology.pillars){let i=e.ontology.types.filter(c=>c.pillar===r.id),s=i.reduce((c,d)=>c+(n.get(d.id)?.length??0),0),l=i.filter(c=>n.get(c.id)?.length).map(c=>`${c.plural??c.label} ${n.get(c.id).length}`).join(" \xB7 ");a+=`<a class="ox-card" href="/p/${encodeURIComponent(r.id)}" style="color:inherit"><div class="ox-card-h"><span class="ox-ic">${z(r.icon)}</span><h2>${w(r.label)}</h2><span class="zin">${s}</span></div><div class="ox-sub" style="white-space:normal">${w(r.description??"")}</div><div class="ox-sub" style="margin-top:6px;white-space:normal">${w(l||"nothing yet")}</div></a>`}a+='</div><div class="ox-grid2">';let o=(n.get("event")??[]).filter(r=>r.importance!=="minor").sort((r,i)=>i.date.localeCompare(r.date)).slice(0,8);return a+='<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>'+(o.map(r=>`<div class="ox-ev"><span class="d">${w(r.date)}</span><span class="ox-st ${r.importance}">${r.importance}</span><a href="${se(r.id)}">${w(r.title)}</a></div>`).join("")||'<div class="ox-empty">No events yet.</div>')+"</section>",a+=Ke(e,Fe(e,[...e.entities.values()])),a+="</div>",O("Wiki",N(e,{home:!0}),a)}function Je(e,t,n){let a=e.ontology.pillars.find(d=>d.id===t);if(!a)return null;let o=de(e),r=e.ontology.types.filter(d=>d.pillar===a.id),i=r.find(d=>d.id===n)??r.find(d=>o.get(d.id)?.length)??r[0],s=`<div class="ox-bar">${M([{label:a.label}])}${le(1)}</div>`;s+=`<div class="ox-head"><div class="ox-avatar">${z(a.icon)}</div><div><h1>${w(a.label)}</h1><p>${w(a.description??"")}</p></div></div>`,s+=`<nav class="ox-tabs">${r.map(d=>`<a class="${d.id===i?.id?"on":""}" href="/p/${encodeURIComponent(a.id)}?kind=${encodeURIComponent(d.id)}">${w(d.plural??d.label)}<small>${o.get(d.id)?.length??0}</small></a>`).join("")}</nav>`;let l=i?(o.get(i.id)??[]).map(d=>({e:d,at:ce(e,d)})).sort((d,m)=>m.at.localeCompare(d.at)):[];s+='<div class="ox-grid2">',s+=`<section class="ox-card"><div class="ox-card-h"><h2>${w(i?.plural??i?.label??"")}</h2><span class="note">${l.length} \xB7 most active first</span>`+(i?`<a class="zin" href="/p/${encodeURIComponent(a.id)}/${encodeURIComponent(i.id)}">open list (Z3) \u2192</a>`:"")+"</div>"+(l.slice(0,5).map(({e:d,at:m})=>Y(e,d,d.type==="event"?`<span class="ox-st ${d.importance}">${d.importance}</span>`:"",`${De(d,90)||ie(e.ontology,d.type).toLowerCase()} \xB7 ${m}`)).join("")||`<div class="ox-empty">No ${w((i?.plural??"pages").toLowerCase())} yet.</div>`)+"</section>";let c=r.flatMap(d=>o.get(d.id)??[]);return s+=Ke(e,Fe(e,c)),s+="</div>",O(a.label,N(e,{pillar:a.id}),s)}function Ye(e,t,n,a,o){let r=o&&be.includes(o)?o:null,i=e.ontology.pillars.find(u=>u.id===t),s=e.ontology.types.find(u=>u.id===n&&u.pillar===t);if(!i||!s)return null;let l=[...e.entities.values()].filter(u=>u.type===s.id);r&&(l=l.filter(u=>u.importance===r));let c=l.map(u=>({e:u,at:ce(e,u)})).sort((u,f)=>f.at.localeCompare(u.at)),d=50,m=Math.max(1,Math.ceil(c.length/d)),p=`/p/${encodeURIComponent(i.id)}/${encodeURIComponent(s.id)}`,k=`<div class="ox-bar">${M([{label:i.label,href:`/p/${encodeURIComponent(i.id)}`},{label:s.plural??s.label}])}${le(3)}</div>`;if(k+=`<div class="ox-head"><div class="ox-avatar">${z(s.icon)}</div><div><h1>${w(s.plural??s.label)}</h1><p>${c.length} page${c.length===1?"":"s"}${r?` \xB7 ${w(r)} only`:""}</p></div></div>`,s.id==="event"&&(k+=`<nav class="ox-tabs">${["","major","normal","minor"].map(u=>`<a class="${(r??"")===u?"on":""}" href="${p}${u?`?importance=${u}`:""}">${u||"all"}</a>`).join("")}</nav>`),k+='<section class="ox-card" style="margin-top:16px">'+(c.slice((a-1)*d,a*d).map(({e:u,at:f})=>Y(e,u,u.type==="event"?`<span class="ox-st ${u.importance}">${u.importance}</span>`:"",`${f} \xB7 ${u.pages.map(I=>I.agentId).filter((I,x,v)=>v.indexOf(I)===x).join(", ")}`)).join("")||'<div class="ox-empty">None.</div>')+"</section>",m>1){let u=r?`importance=${r}&`:"";k+=`<div class="ox-pager">${a>1?`<a href="${p}?${u}page=${a-1}">\u2190 previous</a>`:""}<span>page ${a} of ${m}</span>${a<m?`<a href="${p}?${u}page=${a+1}">next \u2192</a>`:""}</div>`}return O(s.plural??s.label,N(e,{pillar:i.id}),k)}function Ve(e,t){let n=t.trim().toLowerCase(),a=[];if(n)for(let r of e.entities.values()){let i=r.title.toLowerCase(),s=i===n?100:i.startsWith(n)?60:i.includes(n)?40:0;!s&&r.pages.some(l=>l.article.content.toLowerCase().includes(n))&&(s=10),s&&a.push({e:r,s})}a.sort((r,i)=>i.s-r.s||i.e.updated.localeCompare(r.e.updated));let o=`<div class="ox-bar">${M([{label:"Search"}])}</div>`;return o+=`<div class="ox-head"><div class="ox-avatar">${z("search")}</div><div><h1>${n?`\u201C${w(t)}\u201D`:"Search"}</h1><p>${a.length} match${a.length===1?"":"es"}</p></div></div>`,o+=`<section class="ox-card">${a.slice(0,60).map(({e:r})=>Y(e,r)).join("")||'<div class="ox-empty">No page matches.</div>'}</section>`,O(`Search: ${t}`,N(e,{}),o,"",t)}function Xe(e,t,n){let a=e.ontology,o=de(e),r=`<div class="ox-bar">${M([{label:"Ontology"}])}</div>`;r+=`<div class="ox-head"><div class="ox-avatar">${z("steps")}</div><div><h1>Ontology</h1><p>${n?`Read from ${w(n)}`:"Built-in defaults. Run <code>agentx wiki ontology init</code> to write an ontology.yaml you can edit."}</p></div></div>`,t.length&&(r+=`<div class="ox-err"><b>Problems</b><ul>${t.map(i=>`<li>${w(i)}</li>`).join("")}</ul></div>`),r+=`<section class="ox-card"><div class="ox-card-h"><h2>Types</h2><span class="note">${a.types.length}</span></div>`;for(let i of a.types){let s=a.pillars.find(l=>l.id===i.pillar);r+=`<div class="ox-row"><span class="ox-ic">${z(i.icon)}</span><div class="t"><span class="l">${w(i.label)} <span class="ox-sub">${w(i.id)}</span></span><div class="ox-sub">${w(s?.label??i.pillar)} \xB7 lens: ${w((i.lens??[]).map(l=>l.title??l.panel).join(" \u2192 "))}</div></div><div class="r"><span class="ox-chip">${o.get(i.id)?.length??0}</span></div></div>`}r+=`</section><section class="ox-card" style="margin-top:16px"><div class="ox-card-h"><h2>Relations</h2><span class="note">${a.properties.length}</span></div>`;for(let i of a.properties)r+=`<div class="ox-kv"><span class="k">${w(i.id)}</span><span>${w(i.label)}${i.inverse?` \xB7 inverse: ${w(i.inverse)}`:""}${i.wikidata?` <span class="ox-sub">${w(i.wikidata)}</span>`:""}</span></div>`;return r+=`</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>${w(a.importance.default)}</span></div><div class="ox-kv"><span class="k">major set by</span><span>${w(a.importance.major_set_by)}</span></div><div class="ox-kv"><span class="k">roll-up</span><span>${a.importance.rollup.min} minor events in ${a.importance.rollup.days} days</span></div></section>`,O("Ontology",N(e,{}),r)}var V=class{constructor(t,n){this.hub=t;this.wikiDir=n}cache=new Te;pageAt(t){if(!t.startsWith("/e/"))return null;let{ontology:n}=oe(this.wikiDir),o=this.cache.get(this.hub,n).entities.get(t.split("/").filter(Boolean)[1]??"")?.pages[0];return o?{agentId:o.agentId,path:o.article.path,title:o.article.meta.title}:null}handle(t,n){if(!(t==="/"||t===""||t.startsWith("/p/")||t.startsWith("/e/")||t==="/find"||t==="/ontology"))return null;let{ontology:a,errors:o,file:r}=oe(this.wikiDir),i=Ee(this.wikiDir,this.hub.listAgents([]),a.agent_names),s=this.cache.get(this.hub,a,i),l=Math.max(1,Number(n.get("page"))||1);if(t==="/"||t==="")return Ge(s,o);if(t==="/find")return Ve(s,n.get("q")??"");if(t==="/ontology")return Xe(s,o,r);let c=t.split("/").filter(Boolean);if(c[0]==="p")return c.length===2?Je(s,c[1],n.get("kind")):c.length===3?Ye(s,c[1],c[2],l,n.get("importance")):null;let d=s.entities.get(c[1]??"");if(!d)return null;let m={g:s,readEntries:p=>this.hub.getSharedStore().readEntries(p),versions:(p,k)=>this.hub.getAgentWiki(p).getVersions(k)};return c.length===2?ze(m,d):c.length===3?_e(m,d,c[2],l):c.length===4&&c[2]==="s"?We(m,d,Number(c[3])):null}};var It=`
|
|
184
184
|
.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;
|
|
185
185
|
font:14px/1.45 'IBM Plex Sans',system-ui,-apple-system,sans-serif;color:var(--wc-ink)}
|
|
186
186
|
[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}
|
|
@@ -219,7 +219,7 @@ ${m}
|
|
|
219
219
|
@keyframes wc-blink{0%{content:''}25%{content:'.'}50%{content:'..'}75%{content:'\u2026'}}
|
|
220
220
|
@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}}
|
|
221
221
|
@media (prefers-reduced-motion:reduce){.wc-dots::after{animation:none;content:'\u2026'}}
|
|
222
|
-
`,
|
|
222
|
+
`,Ct=`
|
|
223
223
|
(function(){
|
|
224
224
|
var root=document.getElementById('wc-root'); if(!root) return;
|
|
225
225
|
var cfg=JSON.parse(document.getElementById('wc-data').textContent);
|
|
@@ -287,20 +287,20 @@ ${m}
|
|
|
287
287
|
api('GET',q()).then(function(state){if(state.enabled===false)return;fab.hidden=false;
|
|
288
288
|
try{if(sessionStorage.getItem(openKey))setOpen(true)}catch(e){}}).catch(function(){});
|
|
289
289
|
})();
|
|
290
|
-
`,
|
|
290
|
+
`,Et='<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 Tt(e){return e.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}function Rt(e,t="/api/wiki/curate",n){let a=JSON.stringify({agent:e.agentId,path:e.path,title:e.title,endpoint:t,...n?{token:n}:{}}).replace(/</g,"\\u003c");return`<style>${It}</style>
|
|
291
291
|
<div class="wc-root" id="wc-root">
|
|
292
|
-
<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">${
|
|
292
|
+
<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">${Et}</button>
|
|
293
293
|
<section class="wc-panel" id="wc-panel" role="dialog" aria-label="Curate this page" hidden>
|
|
294
|
-
<div class="wc-head"><div><h2>Curate this page</h2><p class="wc-sub">${
|
|
294
|
+
<div class="wc-head"><div><h2>Curate this page</h2><p class="wc-sub">${Tt(e.title)}</p></div><button class="wc-x" type="button" aria-label="Close">\xD7</button></div>
|
|
295
295
|
<div class="wc-log" aria-live="polite"></div>
|
|
296
296
|
<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>
|
|
297
297
|
</section>
|
|
298
298
|
</div>
|
|
299
299
|
<script type="application/json" id="wc-data">${a}</script>
|
|
300
|
-
<script>${
|
|
301
|
-
</body>`):e+o}function g(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function
|
|
300
|
+
<script>${Ct}</script>`}function Qe(e,t,n,a){let o=Rt(t,n,a);return e.includes("</body>")?e.replace(/<\/body>(?![\s\S]*<\/body>)/,()=>`${o}
|
|
301
|
+
</body>`):e+o}function g(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Dt(e){return e.replace(/<!--\s*tags?:[^>]*-->\s*\n?/gi,"")}function Ze(e,t){return`<a href="${t?`/agent/${encodeURIComponent(t)}/tag/${encodeURIComponent(e)}`:`/tag/${encodeURIComponent(e)}`}" class="tag">${g(e)}</a>`}function W(e,t){return(e||[]).map(n=>Ze(n,t)).join(" ")}function zt(e,t){if(!e)return;let n=t.get(e);if(n)return n;let a=new Set(t.values());if(a.has(e))return e;let o=e.endsWith(".md")?e:`${e}.md`;if(a.has(o))return o;let r=e.toLowerCase();for(let[i,s]of t)if(i.toLowerCase()===r)return s}function X(e,t,n=""){return Ae(Dt(e),{wikilink:(a,o)=>{let r=zt(a,t);return r?`<a href="${n}/article/${encodeURIComponent(r)}" class="wikilink">${o}</a>`:`<a href="${n}/search?q=${encodeURIComponent(a)}" class="wikilink broken" title="Not found \u2014 click to search">${o}</a>`}})}var _t=`<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
302
302
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
303
|
-
<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">`,
|
|
303
|
+
<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">`,Wt=`
|
|
304
304
|
:root {
|
|
305
305
|
--bg: #FAF8F3;
|
|
306
306
|
--bg-raised: #FFFFFF;
|
|
@@ -773,8 +773,8 @@ tr:hover td { background: var(--bg-hover); }
|
|
|
773
773
|
<meta charset="utf-8">
|
|
774
774
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
775
775
|
<title>${g(e)} \u2014 AgentX Wiki</title>
|
|
776
|
-
${
|
|
777
|
-
<style>${
|
|
776
|
+
${_t}
|
|
777
|
+
<style>${Wt}</style>
|
|
778
778
|
<script>(function(){try{var t=localStorage.getItem('wiki-theme');if(t)document.documentElement.setAttribute('data-theme',t)}catch(e){}})();</script>
|
|
779
779
|
</head>
|
|
780
780
|
<body>
|
|
@@ -819,7 +819,7 @@ tr:hover td { background: var(--bg-hover); }
|
|
|
819
819
|
})();
|
|
820
820
|
</script>
|
|
821
821
|
</body>
|
|
822
|
-
</html>`}function
|
|
822
|
+
</html>`}function pe(e){let t=new Map;for(let n of e){let a=n.path.includes("/")?n.path.split("/").slice(0,-1).join("/"):"/",o=t.get(a)||[];o.push(n),t.set(a,o)}return new Map([...t].sort((n,a)=>n[0].localeCompare(a[0])))}function ge(e){return e==="/"?"Root":e.split("/").pop().replace(/-/g," ")}function R(e,t){let n='<div class="nav-section">';n+=`<a class="nav-item${t?"":" active"}" href="/">Home</a>`,n+='<a class="nav-item" href="/entries">All entries</a>',n+="</div>";for(let a of e){let o=`/agent/${encodeURIComponent(a.agentId)}`;n+='<div class="nav-section">',n+=`<a class="nav-agent-header" href="${o}">`,n+=`<span class="name">${g(a.agentId)}</span>`,n+=`<span class="badge">${a.totalArticles}</span>`,n+="</a>",n+='<div class="nav-agent-children">';let r=pe(a.articles);for(let[i,s]of r){n+=`<div class="nav-agent-type-label">${ge(i)}</div>`;for(let l of s){let d=`${a.agentId}/${l.path}`===t;n+=`<a class="nav-item${d?" active":""}" href="${o}/article/${encodeURIComponent(l.path)}">${g(l.title)}</a>`}}n+="</div>",n+="</div>"}return n}function Mt(e,t,n){let a=t||e.summary(),r=e.getSharedStore().listEntries().length,i=a.reduce((d,m)=>d+m.totalArticles,0),s=a.reduce((d,m)=>d+m.unabsorbed,0),l=new Set((n||[]).map(d=>d.agentId)),c=`<div class="page-head">
|
|
823
823
|
<div>
|
|
824
824
|
<h1>AgentX Wiki</h1>
|
|
825
825
|
<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>
|
|
@@ -828,34 +828,34 @@ tr:hover td { background: var(--bg-hover); }
|
|
|
828
828
|
<span><strong>${d.totalArticles}</strong> articles</span>
|
|
829
829
|
<span><strong>${d.totalEntries}</strong> entries</span>
|
|
830
830
|
${m}
|
|
831
|
-
</div>`,d.articles.length>0){c+='<div class="article-list">';for(let u of d.articles.slice(0,6)){let f=W((u.tags||[]).slice(0,2),d.agentId);c+=`<div class="article-row">${f} <a class="article-title" href="/agent/${encodeURIComponent(d.agentId)}/article/${encodeURIComponent(u.path)}">${g(u.title)}</a></div>`}d.articles.length>6&&(c+=`<div class="article-row"><a class="article-title" style="color:var(--muted)" href="/agent/${encodeURIComponent(d.agentId)}">+ ${d.articles.length-6} more \u2192</a></div>`),c+="</div>"}c+="</div>"}return c+="</div>",S("Hub",
|
|
831
|
+
</div>`,d.articles.length>0){c+='<div class="article-list">';for(let u of d.articles.slice(0,6)){let f=W((u.tags||[]).slice(0,2),d.agentId);c+=`<div class="article-row">${f} <a class="article-title" href="/agent/${encodeURIComponent(d.agentId)}/article/${encodeURIComponent(u.path)}">${g(u.title)}</a></div>`}d.articles.length>6&&(c+=`<div class="article-row"><a class="article-title" style="color:var(--muted)" href="/agent/${encodeURIComponent(d.agentId)}">+ ${d.articles.length-6} more \u2192</a></div>`),c+="</div>"}c+="</div>"}return c+="</div>",S("Hub",R(a),c)}function Nt(e,t,n){let a=n||e.summary(),o=a.find(p=>p.agentId===t);if(!o)return S("Not Found",R(a),"<h1>Agent not found</h1>");let r=o.peerUrl!==void 0,i=e.getAgentEntries(t),s=o.articles||[],l=`<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <span class="current">${g(t)}</span></nav>`;if(l+=`<div class="page-head"><div><h1>${g(t)}</h1>`,r&&(l+=`<p class="page-sub"><span class="tag" style="color:var(--cool);background:var(--cool-soft)">remote @ ${g(o.nodeId)}</span></p>`),l+="</div></div>",l+='<div class="stat-strip">',l+=`<div class="stat-cell"><div class="label">Articles</div><div class="number">${o.totalArticles}</div></div>`,l+=`<div class="stat-cell"><div class="label">Entries</div><div class="number">${o.totalEntries}</div></div>`,l+=`<div class="stat-cell"><div class="label">Unabsorbed</div><div class="number">${o.unabsorbed}</div></div>`,l+="</div>",s.length>0){l+='<div class="section-head"><h2>Articles</h2><span class="mono" style="font-size:12px;color:var(--muted)">'+s.length+" total</span></div>";let p=pe(s);for(let[k,u]of p){l+=`<h3 class="display" style="font-size:17px;color:var(--muted);font-weight:500;margin:20px 0 8px">${ge(k)}</h3>`,l+='<div class="agent-card" style="padding:4px 14px"><div class="article-list">';for(let f of u)l+=`<div class="article-row">${W((f.tags||[]).slice(0,3),t)} <a class="article-title" href="/agent/${encodeURIComponent(t)}/article/${encodeURIComponent(f.path)}">${g(f.title)}</a></div>`;l+="</div></div>"}}let c=i.slice(-5).reverse();if(c.length>0){l+='<div class="section-head"><h2>Recent entries</h2><a class="btn ghost" href="/entries">See all \u2192</a></div>';for(let p of c)l+=`<div class="entry-card">
|
|
832
832
|
<div class="meta-line">${p.date} \xB7 via ${g(p.source)} \xB7 <code>${g(p.id)}</code></div>
|
|
833
833
|
<p>${g(p.content.slice(0,300))}${p.content.length>300?"\u2026":""}</p>
|
|
834
834
|
</div>`}let m=e.getAgentWiki(t).lint();if(m.length>0){l+=`<div class="section-head"><h2>Health issues</h2><span class="mono" style="font-size:12px;color:var(--warn)">${m.length}</span></div>`,l+='<div class="health-list">';for(let p of m)l+=`<div class="health-row">
|
|
835
835
|
<span class="kind">${g(p.type)}</span>
|
|
836
836
|
<span class="article">${g(p.article)}</span>
|
|
837
837
|
<span class="msg">${g(p.message)}</span>
|
|
838
|
-
</div>`;l+="</div>"}return S(t,
|
|
838
|
+
</div>`;l+="</div>"}return S(t,R(a,t),l)}function Ot(e,t,n,a){let o=e.getAgentWiki(t),r=o.readArticle(n);if(!r)return null;let i=a||e.summary(),s=o.rebuildIndex(),l=new Map;for(let k of s.articles)l.set(k.title,k.path);let c=`/agent/${encodeURIComponent(t)}`,m=o.buildBacklinks()[r.meta.title]||[],p=`<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <a href="${c}">${g(t)}</a> <span class="sep">/</span> <span class="current">${g(r.meta.title)}</span></nav>`;if(p+=`<article class="prose"><h1>${g(r.meta.title)}</h1>`,p+='<dl class="meta">',r.meta.type&&(p+=`<dt>Type</dt><dd>${Ze(r.meta.type,t)}</dd>`),r.meta.tags?.length&&(p+=`<dt>Tags</dt><dd>${W(r.meta.tags,t)}</dd>`),r.meta.owner&&(p+=`<dt>Owner</dt><dd>${g(r.meta.owner)}</dd>`),p+=`<dt>Created</dt><dd>${g(r.meta.created||"\u2014")}</dd>`,p+=`<dt>Updated</dt><dd>${g(r.meta.lastUpdated||"\u2014")}</dd>`,r.meta.sources?.length&&(p+=`<dt>Sources</dt><dd>${r.meta.sources.length} entries</dd>`),p+="</dl>",p+=X(r.content,l,c),m.length>0){p+='<div class="backlinks"><h4>Pages that link here</h4><ul>';for(let k of m){let u=o.readArticle(k);p+=`<li><a href="${c}/article/${encodeURIComponent(k)}">${g(u?.meta.title||k)}</a></li>`}p+="</ul></div>"}return p+="</article>",S(r.meta.title,R(i,`${t}/${n}`),p)}function Ut(e,t){let n=t||e.summary(),o=e.getSharedStore().listEntries(),r='<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <span class="current">Entries</span></nav>';r+='<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 o){let l=i.get(s.date)||[];l.push(s),i.set(s.date,l)}for(let[s,l]of[...i].reverse()){r+=`<div class="section-head"><h2>${s}</h2><span class="mono" style="font-size:12px;color:var(--muted)">${l.length} entries</span></div>`;for(let c of l)r+=`<div class="entry-card">
|
|
839
839
|
<div class="meta-line">
|
|
840
840
|
<a href="/agent/${encodeURIComponent(c.agentId)}">${g(c.agentId)}</a>
|
|
841
841
|
\xB7 via ${g(c.source)} \xB7 <code>${g(c.id)}</code>
|
|
842
842
|
</div>
|
|
843
843
|
<p>${g(c.content.slice(0,400))}${c.content.length>400?"\u2026":""}</p>
|
|
844
|
-
</div>`}return S("All Entries",
|
|
844
|
+
</div>`}return S("All Entries",R(n),r)}function Bt(e,t,n){let a=n||e.summary(),o='<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <span class="current">Search</span></nav>';o+=`<div class="page-head"><div><h1>\u201C${g(t)}\u201D</h1><p class="page-sub">Full-text search across every agent's wiki.</p></div></div>`;let r=0,i=[];for(let s of a){let c=e.getAgentWiki(s.agentId).findRelevant(t,void 0,10);if(c.length>0){i.push(`<div class="section-head"><h2>${g(s.agentId)}</h2><span class="mono" style="font-size:12px;color:var(--muted)">${c.length} match${c.length===1?"":"es"}</span></div>`);for(let d of c){let m=`/agent/${encodeURIComponent(s.agentId)}`;i.push(`<div class="entry-card">
|
|
845
845
|
<div class="meta-line">${W((d.meta.tags||[]).slice(0,3),s.agentId)}</div>
|
|
846
846
|
<h3><a href="${m}/article/${encodeURIComponent(d.path)}">${g(d.meta.title)}</a></h3>
|
|
847
847
|
<p>${g(d.content.slice(0,240))}\u2026</p>
|
|
848
|
-
</div>`)}r+=c.length}}return o+=i.join(""),r===0&&(o+='<p style="color:var(--muted);margin-top:24px">No matching articles found.</p>'),S(`Search: ${t}`,
|
|
848
|
+
</div>`)}r+=c.length}}return o+=i.join(""),r===0&&(o+='<p style="color:var(--muted);margin-top:24px">No matching articles found.</p>'),S(`Search: ${t}`,R(a),o,t)}function jt(e,t,n){let a=n||e.summary(),o='<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <span class="current">Tag</span></nav>';o+=`<div class="page-head"><div><h1>${g(t)}</h1><p class="page-sub">All articles tagged <span class="tag">${g(t)}</span>, across every agent.</p></div></div>`;let r=0;for(let i of a){let s;try{s=e.getAgentWiki(i.agentId)}catch{continue}let l=s.findByTags([t],void 0,100);if(l.length!==0){o+=`<div class="section-head"><h2>${g(i.agentId)}</h2><span class="mono" style="font-size:12px;color:var(--muted)">${l.length}</span></div>`;for(let c of l){let d=`/agent/${encodeURIComponent(i.agentId)}`;o+=`<div class="entry-card">
|
|
849
849
|
<div class="meta-line">${W((c.meta.tags||[]).slice(0,6),i.agentId)}</div>
|
|
850
850
|
<h3><a href="${d}/article/${encodeURIComponent(c.path)}">${g(c.meta.title)}</a></h3>
|
|
851
|
-
</div>`}r+=l.length}}return r===0&&(o+=`<p style="color:var(--muted);margin-top:24px">No articles tagged <code>${g(t)}</code>.</p>`),S(`Tag: ${t}`,
|
|
851
|
+
</div>`}r+=l.length}}return r===0&&(o+=`<p style="color:var(--muted);margin-top:24px">No articles tagged <code>${g(t)}</code>.</p>`),S(`Tag: ${t}`,R(a),o)}function qt(e,t,n,a){let o=a||e.summary(),r;try{r=e.getAgentWiki(t)}catch{return S(`Tag: ${n}`,R(o),`<h1>Agent not found: ${g(t)}</h1>`)}let i=r.findByTags([n],void 0,100),s=`/agent/${encodeURIComponent(t)}`,l=`<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <a href="${s}">${g(t)}</a> <span class="sep">/</span> <span class="current">${g(n)}</span></nav>`;l+=`<div class="page-head"><div><h1>${g(n)}</h1><p class="page-sub">${i.length} article${i.length===1?"":"s"} tagged <code>${g(n)}</code> in <b>${g(t)}</b>.</p></div></div>`;for(let c of i)l+=`<div class="entry-card">
|
|
852
852
|
<div class="meta-line">${W((c.meta.tags||[]).slice(0,6),t)}</div>
|
|
853
853
|
<h3><a href="${s}/article/${encodeURIComponent(c.path)}">${g(c.meta.title)}</a></h3>
|
|
854
|
-
</div>`;return S(`${t} \xB7 ${n}`,
|
|
854
|
+
</div>`;return S(`${t} \xB7 ${n}`,R(o),l)}function U(e,t,n){let a=e.rebuildIndex(),o=pe(a.articles.map(i=>({title:i.title,path:i.path,tags:i.tags}))),r='<div class="nav-section">';r+=`<div class="nav-section-title">${g(t)}</div>`,r+=`<a class="nav-item${n?"":" active"}" href="/">Home</a>`,r+='<a class="nav-item" href="/lint">Health check</a>',r+="</div>";for(let[i,s]of o){r+='<div class="nav-section">',r+=`<div class="nav-section-title">${ge(i)}</div>`;for(let l of s){let c=l.path===n;r+=`<a class="nav-item${c?" active":""}" href="/article/${encodeURIComponent(l.path)}">${g(l.title)}</a>`}r+="</div>"}return r}function Ht(e){let{wikiDir:t,agentFilter:n,peers:a=[],mode:o="graph",pathPrefix:r=""}=e,i=r.replace(/\/+$/,""),s=new ve(t,void 0,o),l=new V(s,t),c=a.length>0?new J(a):null;return async(d,m)=>{let p=new URL(d.url||"/","http://localhost"),k=decodeURIComponent(p.pathname),u=i&&k.startsWith(i)?k.slice(i.length)||"/":k,f=null,I=200;try{if(u.startsWith("/remote/")&&c){let x=u.slice(8).split("/article/");if(x.length===2){let[v,b]=x,h=v.indexOf("/"),$=decodeURIComponent(v.slice(0,h)),y=v.slice(h+1),A=await c.getRemoteArticle($,y,b);if(A){let D=await c.getRemoteAgents(),q=[...s.summary(),...D.map(E=>({...E,agentId:`${E.agentId} @${E.nodeId}`}))],C=`<div class="breadcrumb"><a href="/">Hub</a> / <span class="tag">remote</span> ${g(y)} @ ${g($)}</div>`;C+=`<h1>${g(A.meta.title)}</h1>`,C+='<dl class="meta">',C+=`<dt>Tags</dt><dd>${(A.meta.tags||[]).map(E=>`<span class="tag">${E}</span>`).join(" ")}</dd>`,C+=`<dt>Owner</dt><dd>${g(A.meta.owner)}</dd>`,C+=`<dt>Source</dt><dd><span class="tag">remote</span> ${g($)}</dd>`,C+=`<dt>Updated</dt><dd>${A.meta.lastUpdated}</dd>`,C+="</dl>";let P=new Map;C+=X(A.content,P),f=S(A.meta.title,R(q),C)}}}if(!f&&n){let x=s.getAgentWiki(n);if(u==="/"||u===""){let v=x.rebuildIndex(),b=s.getAgentEntries(n),h=`<h1>${g(n)}</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)}">${g($.title)}</a></td><td><span class="tag">${($.tags||[]).slice(0,3).join(", ")}</span></td><td>${$.lastUpdated||""}</td></tr>`;h+="</table>"}f=S(n,U(x,n),h)}else if(u.startsWith("/article/")){let v=u.slice(9),b=x.readArticle(v);if(b){let h=x.rebuildIndex(),$=new Map;for(let A of h.articles)$.set(A.title,A.path);let y=`<h1>${g(b.meta.title)}</h1>`;y+='<dl class="meta">',y+=`<dt>Tags</dt><dd>${(b.meta.tags||[]).map(A=>`<span class="tag">${A}</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+=X(b.content,$),f=S(b.meta.title,U(x,n,v),y)}}else if(u==="/lint"){let v=x.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>${g(h.article)}</td><td>${g(h.message)}</td></tr>`;b+="</table>"}f=S("Health Check",U(x,n),b)}else if(u==="/search"){let v=p.searchParams.get("q")||"",b=await x.findRelevantReranked(v,void 0,20),h=`<h1>Search: "${g(v)}"</h1>`;for(let $ of b)h+=`<div class="entry-card"><h3><a href="/article/${encodeURIComponent($.path)}">${g($.meta.title)}</a></h3><p>${g($.content.slice(0,200))}...</p></div>`;b.length===0&&(h+="<p>No results.</p>"),f=S(`Search: ${v}`,U(x,n),h)}else if(u.startsWith("/tag/")){let v=decodeURIComponent(u.slice(5)),b=x.findByTags([v],void 0,100),h=`<h1>Tag: <a class="tag" href="#">${g(v)}</a></h1>`;h+=`<p>${b.length} article${b.length===1?"":"s"} tagged <code>${g(v)}</code></p>`;for(let $ of b)h+=`<div class="entry-card"><h3><a href="/article/${encodeURIComponent($.path)}">${g($.meta.title)}</a></h3><div class="meta-line">${W(($.meta.tags||[]).slice(0,6))}</div></div>`;b.length===0&&(h+="<p>No articles with this tag.</p>"),f=S(`Tag: ${v}`,U(x,n),h)}}else if(!f&&(f=l.handle(u,p.searchParams))===null){let x=c?await c.getRemoteAgents():[],v=s.summary(),b=new Map(v.map(y=>[y.agentId,y])),h=[],$=new Set;for(let y of v){let A=x.find(D=>D.agentId===y.agentId);A&&A.totalArticles>y.totalArticles?h.push({...A,totalEntries:Math.max(y.totalEntries,A.totalEntries),unabsorbed:Math.max(y.unabsorbed,A.unabsorbed)}):h.push(y),$.add(y.agentId)}for(let y of x)$.has(y.agentId)||(h.push(y),$.add(y.agentId));if(u==="/agents")f=Mt(s,h,x);else if(u==="/entries")f=Ut(s,h);else if(u==="/search")f=Bt(s,p.searchParams.get("q")||"",h);else if(u.startsWith("/tag/"))f=jt(s,decodeURIComponent(u.slice(5)),h);else if(u.match(/^\/agent\/[^/]+\/tag\/.+/)){let y=u.match(/^\/agent\/([^/]+)\/tag\/(.+)$/);f=qt(s,decodeURIComponent(y[1]),decodeURIComponent(y[2]),h)}else if(u.startsWith("/agent/")){let y=u.slice(7),A=y.indexOf("/article/");if(A===-1)f=Nt(s,y,h);else{let D=y.slice(0,A),q=y.slice(A+9);if(f=Ot(s,D,q,h),!f&&c){let C=x.find(P=>P.agentId===D);if(C){let P=await c.getRemoteArticle(C.peerUrl,D,q);if(P){let E=`<div class="breadcrumb"><a href="/">Hub</a> / <span class="tag">remote @ ${g(C.nodeId)}</span> / ${g(D)}</div>`;E+=`<h1>${g(P.meta.title)}</h1>`,E+='<dl class="meta">',E+=`<dt>Tags</dt><dd>${(P.meta.tags||[]).map(lt=>`<span class="tag">${lt}</span>`).join(" ")}</dd>`,E+=`<dt>Source</dt><dd><span class="tag">remote</span> ${g(C.nodeId)}</dd>`,E+=`<dt>Updated</dt><dd>${P.meta.lastUpdated}</dd>`,E+="</dl>",E+=X(P.content,new Map),f=S(P.meta.title,R(h),E)}}}}}}if(!f){I=404;let x=n?U(s.getAgentWiki(n),n):R(s.summary());f=S("Not Found",x,"<h1>Page not found</h1>")}}catch(x){I=500,f=S("Error","",`<h1>Error</h1><pre>${g(x.message)}</pre>`)}if(I===200&&e.curator){let x=Lt(s,l,u,n);x&&(f=Qe(f,x,e.curatorEndpoint,e.curatorToken?.()))}m.writeHead(I,{"Content-Type":"text/html; charset=utf-8"}),m.end(i?Ft(f,i):f)}}function Lt(e,t,n,a){let o,r;if(a&&n.startsWith("/article/"))o=a,r=n.slice(9);else if(!a&&n.startsWith("/agent/")){let l=n.match(/^\/agent\/([^/]+)\/article\/(.+)$/);l&&(o=l[1],r=l[2])}else if(!a)return t.pageAt(n);if(!o||!r||!e.listAgents([]).includes(o))return null;let i=e.getAgentWiki(o);if(!$e(i.baseDir,r))return null;let s=i.readArticle(r);return s?{agentId:o,path:r,title:s.meta.title}:null}function Ft(e,t){e=e.replace(/(\s(?:href|action)=")\/(?!\/)/g,`$1${t}/`),e=e.replace(new RegExp(`(${t})${t}/`,"g"),`${t}/`);let n=`<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>${n}`),e}function ta(e,t=4200,n,a=[],o="graph"){let r=Ht({wikiDir:e,agentFilter:n,peers:a,mode:o});Pt((s,l)=>{r(s,l)}).listen(t)}import{existsSync as Kt,readFileSync as Gt}from"fs";te();function sa(e){let t=L(e),n={};if(Kt(t))try{n=H(JSON.parse(Gt(t,"utf-8")))}catch{n={}}let a=n?.workflows?.required??{},o={};for(let[r,i]of Object.entries(a.agents??{}))typeof i=="boolean"&&(o[r]=i);return{enabled:typeof a.enabled=="boolean"?a.enabled:K.enabled,agents:o,exemptQuestions:typeof a.exemptQuestions=="boolean"?a.exemptQuestions:K.exemptQuestions,retentionDays:Number.isInteger(a.retentionDays)&&a.retentionDays>=0?a.retentionDays:K.retentionDays,engine:n?.workflows?.enabled===!0}}async function la(e,t={}){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`}:F(n=>{let a=n.workflows??={},o=a.required??={};if(e.enabled!==void 0&&(o.enabled=e.enabled),e.exemptQuestions!==void 0&&(o.exemptQuestions=e.exemptQuestions),e.retentionDays!==void 0&&(o.retentionDays=e.retentionDays),e.agent){let r=o.agents??={};e.agent.value===null?delete r[e.agent.id]:r[e.agent.id]=e.agent.value}(e.enabled===!0||e.agent?.value===!0)&&(a.enabled=!0)},{configPath:t.configPath,reload:t.reload})}dt();function pa(e,t,n=20){return e.prepare(`SELECT task_id, agent_id, channel, chat_id, status, started_at, finished_at, message_preview
|
|
855
855
|
FROM task_traces
|
|
856
856
|
WHERE person = ? AND (channel IS NULL OR channel != 'a2a')
|
|
857
|
-
ORDER BY started_at DESC, rowid DESC LIMIT ?`).all(t,Math.max(1,Math.min(n,500))).map(o=>({taskId:o.task_id,agentId:o.agent_id,channel:o.channel,chatId:o.chat_id,status:o.status,startedAt:o.started_at,finishedAt:o.finished_at??null,messagePreview:o.message_preview}))}function
|
|
857
|
+
ORDER BY started_at DESC, rowid DESC LIMIT ?`).all(t,Math.max(1,Math.min(n,500))).map(o=>({taskId:o.task_id,agentId:o.agent_id,channel:o.channel,chatId:o.chat_id,status:o.status,startedAt:o.started_at,finishedAt:o.finished_at??null,messagePreview:o.message_preview}))}function Jt(e){return e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'requests'").get()?e.prepare("PRAGMA table_info(requests)").all().some(a=>a.name==="person"):!1}function et(e,t,n,a,...o){return Jt(e)?e.prepare(`SELECT id, state, channel, agent_id, text, created_at FROM requests
|
|
858
858
|
WHERE person = ? AND state IN (${n.map(()=>"?").join(",")})
|
|
859
|
-
${a}`).all(t,...n,...o).map(i=>({id:i.id,state:i.state,channel:i.channel,agentId:i.agent_id,text:i.text,createdAt:i.created_at})):[]}function
|
|
860
|
-
`)}var
|
|
861
|
-
//# sourceMappingURL=chunk-
|
|
859
|
+
${a}`).all(t,...n,...o).map(i=>({id:i.id,state:i.state,channel:i.channel,agentId:i.agent_id,text:i.text,createdAt:i.created_at})):[]}function ga(e,t){return et(e,t,Z,"ORDER BY created_at")}function ua(e,t,n=50){return et(e,t,[...Z,...me],"ORDER BY created_at DESC, rowid DESC LIMIT ?",Math.max(1,Math.min(n,500)))}ct();var ue="member:",Yt=90,Vt="members",Xt="tailscale-user-login",Qt=400,Zt=60*60*1e3;function en(e){let t=e.scopes.find(n=>n.startsWith(ue));return t?t.slice(ue.length):null}function nt(e,t){if(!e)return null;let n=t.verify(e),a=n?en(n):null;return n&&a?{rec:n,personId:a}:null}function ya(e,t){let n=e.people().find(s=>s.id===t);if(!n)return{ok:!1,error:`No person "${t}". Add them first: agentx people add ${t} --name "\u2026"`};let{token:a,record:o}=e.tokens.create({name:`${n.name} (machine not paired yet)`,scopes:[`${ue}${n.id}`],expiresInDays:Yt}),{code:r,expiresAt:i}=e.codes.create({token:a,tokenId:o.id,name:n.id});return e.members.log({person:n.id,device:o.id,event:"invited"}),{ok:!0,code:r,expiresAt:i,tokenId:o.id,person:n}}var tn=Math.round(ye/6e4);function nn(e){return e==="client"?"Your project":"My work"}function wa(e){let t=nn(e.person.role),n=e.person.role==="client"?`I use AgentX to keep track of the work I do for you. It has a page for you, "${t}": what you asked us for, and where each request stands.`:`I use AgentX to give our AI agents their jobs. It has a page for you, "${t}": what you asked the agents for, and where each request stands.`;return[`Hi ${e.person.name},`,"",n,"","To open it:","1. Accept the Tailscale share I sent you. Tailscale is a small program that connects your computer to mine, privately.",`2. Open ${e.origin.replace(/\/+$/,"")}/member in Edge or Chrome, give your computer a name and type this code: ${we(e.code)}`,` The code works once, for ${tn} minutes. If it has stopped working, tell me and I will send you a new one.`,"","I then approve your machine, and the page opens by itself."].join(`
|
|
860
|
+
`)}var an="The private network says someone else is connecting from this machine. Ask the person who invited you for a new code.",rn="Too many machines are waiting for the owner's answer. Try again later.",tt="That code didn't work. Check it, or ask the person who invited you for a new one.",at=(e,t)=>{let n=e.headers[t];return(Array.isArray(n)?n[0]:n||"").trim()};function rt(e){let t=e.socket?.remoteAddress||"";return t==="127.0.0.1"||t==="::1"||t==="::ffff:127.0.0.1"}function on(e){if(!rt(e))return null;let t=at(e,Xt).toLowerCase();return t?t.slice(0,80):null}function sn(e){let t=e.socket?.remoteAddress||"unknown";if(!rt(e))return t;let n=at(e,"x-forwarded-for").split(",").pop().trim();return/^[0-9a-fA-F:.]{2,45}$/.test(n)?n:t}function ln(e){return typeof e=="string"?e.replace(/[^\p{L}\p{N} ._'()-]/gu," ").replace(/\s+/g," ").trim().slice(0,60):""}function dn(e){return e.identities.map(fe).filter(t=>!!t&&t.channel==="tailscale").map(t=>t.value)}async function ka(e,t){let n=Date.now(),a=t.now??Date.now,o=t.log??(b=>console.log(b)),r=sn(e),i=t.limiter.retryAfter(r);if(i>0)return o(`[member] pair-code refused from ${r}: locked out for ${i}s more`),{status:429,body:{error:"too many attempts",retryAfter:i},retryAfter:i};let s=null,l="";try{let b=await xe(e,2048);s=b.code,l=ln(b.machine)}catch{}let c=t.codes.redeem(s),d=c?nt(c.token,t.tokens):null;if(await pn(n,t.minMs??Qt),!c||!d)return t.limiter.fail(r),o(`[member] pair-code failed from ${r}`),{status:401,body:{error:tt}};t.limiter.succeed(r);let{rec:m,personId:p}=d,k=t.people().find(b=>b.id===p);if(!k)return t.tokens.revoke(m.id),t.members.log({person:p,device:m.id,event:"refused",address:r,detail:"person no longer listed"}),o(`[member] pair-code for ${p} refused from ${r}: person no longer listed`),{status:403,body:{error:tt}};let u=on(e),f=dn(k);if(f.length&&(!u||!f.includes(u)))return t.tokens.revoke(m.id),t.members.log({person:p,device:m.id,event:"refused",address:r,detail:`network login ${u??"missing"}; expected ${f.join(" or ")}`}),o(`[member] ${p}: pairing from ${r} refused: the network says "${u??"nobody"}", expected ${f.join(" or ")}`),{status:403,body:{error:an}};let I=l||"Unnamed machine",x=k.name.slice(0,40),v=ke(t.root,{title:`New machine for ${x}`,ask:`From ${r}, ${u?`network login ${u}`:"no network login reported"}. Machine name, as typed there: "${I}". Let it see ${x}'s own work?`,recommend:`Yes if ${x} told you they just paired this machine. No if you did not expect it.`,if_silent:"discard",raised_by:Vt},{now:a()});return v.ok?(t.members.add({tokenId:m.id,personId:p,name:I,state:"pending",cardId:v.card.id,address:r,...u?{network:u}:{},createdAt:new Date(a()).toISOString()}),t.members.log({person:p,device:m.id,event:"paired",address:r,detail:I}),o(`[member] ${p} paired "${I}" from ${r}; waiting for the owner (card ${v.card.id})`),{status:200,body:{person:p,name:I,state:"pending"},token:c.token}):(t.tokens.revoke(m.id),t.members.log({person:p,device:m.id,event:"refused",address:r,detail:v.error}),o(`[member] ${p}: pairing from ${r} refused: ${v.error}`),{status:503,body:{error:rn}})}var Q="this machine is not paired",cn="waiting for the owner to approve this machine";function ot(e){return e?e.status==="decided"?e.verdict??null:e.status==="expired"?"no":null:null}function $a(e,t){return t.state==="pending"&&t.cardId?ot(ne(e,t.cardId)):null}function Aa(e,t,n){let a=t.now??Date.now,o=t.log??(d=>console.log(d)),r=nt(e,t.tokens);if(!r)return{ok:!1,status:401,error:Q};let{rec:i,personId:s}=r,l=t.members.byToken(i.id);if(!l||l.state==="removed"||l.personId!==s)return{ok:!1,status:401,error:Q};if(t.people&&!t.people().some(d=>d.id===s))return it(t,i.id,"person no longer listed"),o(`[member] ${s}: "${l.name}" ended: person no longer listed`),{ok:!1,status:401,error:Q};if(l.state==="pending"){let d=l.cardId?ne(t.root,l.cardId):null,m=ot(d);if(m==="yes")l=t.members.update(i.id,{state:"active",approvedAt:new Date(a()).toISOString()})??l,t.members.log({person:s,device:i.id,event:"approved",detail:d?.decided_by}),o(`[member] ${s}: "${l.name}" approved`);else if(m==="no"){let p=d?.status==="expired"?"the owner did not answer in time":"the owner said no";return t.tokens.revoke(i.id),t.members.update(i.id,{state:"removed",removedAt:new Date(a()).toISOString(),removedReason:p}),t.members.log({person:s,device:i.id,event:"refused",detail:p}),o(`[member] ${s}: "${l.name}" refused: ${p}`),{ok:!1,status:401,error:Q}}else return{ok:!1,status:403,error:cn,waiting:!0}}let c=l.lastSeenAt?Date.parse(l.lastSeenAt):0;return n&&(a()-c>=Zt||l.lastAddress!==n)&&(l=t.members.update(i.id,{lastSeenAt:new Date(a()).toISOString(),lastAddress:n})??l,t.members.log({person:s,device:i.id,event:"signed-in",address:n})),{ok:!0,device:l,personId:s,rec:i}}function it(e,t,n="removed by the owner"){let a=e.members.byToken(t);if(!a)return null;e.tokens.revoke(t);let o=e.members.update(t,{state:"removed",removedAt:new Date((e.now??Date.now)()).toISOString(),removedReason:n});return e.members.log({person:a.personId,device:t,event:"removed",detail:n}),o}function Sa(e,t){return e.members.devices(t).filter(n=>n.state!=="removed").map(n=>it(e,n.tokenId,"person removed by the owner")).filter(n=>!!n)}async function pn(e,t){let n=e+t-Date.now();n>0&&await new Promise(a=>setTimeout(a,n))}var st=["gitlab","github"];function gn(e,t,n){let a=String(t||"").trim().toLowerCase();if(!st.includes(a))throw new Error(`Request status works on ${st.join(" and ")}, not on "${t}".`);e.requestStatus=e.requestStatus&&typeof e.requestStatus=="object"?e.requestStatus:{};let o=Array.isArray(e.requestStatus.channels)?e.requestStatus.channels.map(r=>String(r).toLowerCase()):[];return e.requestStatus.channels=n?[...new Set([...o,a])]:o.filter(r=>r!==a),`request status on ${a} is ${n?"on":"off"}`}function Ea(e){return Array.isArray(e?.requestStatus?.channels)?e.requestStatus.channels.map(t=>String(t).toLowerCase()):[]}function Ta(e){let{summary:t}=G(n=>gn(n,e?.channel,!!e?.enabled));return{summary:t}}function Pa(e){return new Set(Object.entries(e).filter(([,t])=>t?.wiki?.absorb?.enabled===!1).map(([t])=>t))}function Da(e,t){return t.only?{agents:[t.only],skipped:[]}:{agents:e.filter(n=>!t.off.has(n)),skipped:e.filter(n=>t.off.has(n))}}function za(e,t){return`absorb is off for this agent (agents.${e}.wiki.absorb.enabled); skipped.${e===t?" It reads the wiki notes inbox, so the inbox was not read.":""} Use --agent ${e} to run it anyway.`}function _a(e,t){if(t){if(!e.wiki?.absorb)return;delete e.wiki.absorb.enabled,Object.keys(e.wiki.absorb).length===0&&delete e.wiki.absorb,Object.keys(e.wiki).length===0&&delete e.wiki;return}e.wiki??={},e.wiki.absorb??={},e.wiki.absorb.enabled=!1}var un="https://ntfy.sh";function Ma(e){return{enabled:!!e?.enabled,server:e?.server||un,topicSet:!!e?.topic,tokenSet:!!e?.token}}function Na(e,t){let n={...e??{}};if("enabled"in t&&(n.enabled=!!t.enabled),"server"in t){let a=String(t.server).trim().replace(/\/+$/,"");if(!/^https?:\/\/\S+$/.test(a))throw new Error("ntfy server must be an http(s) URL");n.server=a}if("topic"in t){let a=String(t.topic).trim();if(!a)throw new Error("ntfy topic cannot be empty");n.topic=a}if("token"in t){let a=String(t.token??"").trim();a?n.token=a:delete n.token}if(n.enabled&&!n.topic)throw new Error("set a topic before enabling ntfy");return n}export{Be as a,An as b,Sn as c,In as d,Pn as e,Dn as f,zn as g,pa as h,ga as i,ua as j,Yt as k,ya as l,tn as m,nn as n,wa as o,sn as p,ka as q,$a as r,Aa as s,it as t,Sa as u,st as v,gn as w,Ea as x,Ta as y,Pa as z,Da as A,za as B,_a as C,Ma as D,Na as E,Ht as F,ta as G,sa as H,la as I};
|
|
861
|
+
//# sourceMappingURL=chunk-MM3F74K4.js.map
|