agentix-cli 0.88.0 → 0.90.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-BSGDYHRD.js → App-LC34QQPN.js} +2 -2
- package/dist/{ChatApp-K57DBCDT.js → ChatApp-FB72AK7M.js} +2 -2
- package/dist/{agent-6MTUM5DR.js → agent-OZ4XFAD4.js} +2 -2
- package/dist/{board-dashboard-MHMXII6V.js → board-dashboard-YBWSJ7J2.js} +338 -217
- package/dist/board-dashboard-YBWSJ7J2.js.map +1 -0
- package/dist/{chunk-ECCPLASB.js → chunk-26UFDYRZ.js} +2 -2
- package/dist/{chunk-HQWMWSSE.js → chunk-3GN255MT.js} +2 -2
- package/dist/{chunk-7QDAGGOD.js → chunk-3SEFVZA7.js} +2 -2
- package/dist/{chunk-DWZYVYZS.js → chunk-3SZ4CU6G.js} +57 -15
- package/dist/chunk-3SZ4CU6G.js.map +1 -0
- package/dist/{chunk-XVDASTUX.js → chunk-64UK5VG4.js} +2 -2
- package/dist/{chunk-N4HFUAPN.js → chunk-A5DFX47N.js} +2 -2
- package/dist/{chunk-HOXHUFZB.js → chunk-BEJCSZOQ.js} +2 -2
- package/dist/{chunk-BFY4D4RH.js → chunk-BTTQZWYB.js} +2 -2
- package/dist/{chunk-I6HCIQCQ.js → chunk-ISIJAZGO.js} +2 -2
- package/dist/{chunk-C3VCIEZS.js → chunk-JF5UGNMG.js} +2 -2
- package/dist/{chunk-2FLVU2QW.js → chunk-JLCYQZRT.js} +2 -2
- package/dist/{chunk-L6BO76GK.js → chunk-JVQXD35E.js} +195 -194
- package/dist/chunk-JVQXD35E.js.map +1 -0
- package/dist/{chunk-MZQ5PCLA.js → chunk-LCWE2GHC.js} +2 -2
- package/dist/{chunk-7K5SJJUI.js → chunk-LS6KXRXY.js} +2 -2
- package/dist/{chunk-KIXDJEGA.js → chunk-MBVRADNG.js} +2 -2
- package/dist/{chunk-BUELCBBV.js → chunk-MU4S6LQA.js} +8 -8
- package/dist/{chunk-BUELCBBV.js.map → chunk-MU4S6LQA.js.map} +1 -1
- package/dist/{chunk-X2F3AVGR.js → chunk-N2OMSKIQ.js} +2 -2
- package/dist/{chunk-EUXF2GJY.js → chunk-QYFF2WJ2.js} +2 -2
- package/dist/{chunk-PN6XHTG5.js → chunk-RJ7DASOU.js} +4 -4
- package/dist/{chunk-PN6XHTG5.js.map → chunk-RJ7DASOU.js.map} +1 -1
- package/dist/{chunk-TNR7AI4H.js → chunk-RLXEF2X6.js} +67 -67
- package/dist/chunk-RLXEF2X6.js.map +1 -0
- package/dist/{chunk-BOENB3IK.js → chunk-TA2BYYNZ.js} +2 -2
- package/dist/{chunk-OAA7TNB6.js → chunk-TGN7K7VG.js} +2 -2
- package/dist/{chunk-7ADEEHZQ.js → chunk-TS7JDPOY.js} +2 -2
- package/dist/{chunk-BYD5B3P3.js → chunk-UVMCAZL7.js} +2 -2
- package/dist/{chunk-7OEFPYQJ.js → chunk-UWH7NTGV.js} +2 -2
- package/dist/{chunk-54VYZE7A.js → chunk-XSVGD64O.js} +3 -3
- package/dist/{chunk-54VYZE7A.js.map → chunk-XSVGD64O.js.map} +1 -1
- package/dist/cli.js +1 -1
- package/dist/{client-UKLOVDZB.js → client-IPZRCNE7.js} +2 -2
- package/dist/{config-WUDWHRT6.js → config-HZTKLB6A.js} +2 -2
- package/dist/config-mutator-6S4X6WMU.js +2 -0
- package/dist/{doctor-COAIIKLV.js → doctor-BTHIQN7F.js} +2 -2
- package/dist/index.d.ts +14 -13
- package/dist/index.js +1 -1
- package/dist/processes-MMAVAZAC.js +2 -0
- package/dist/{program-VX4XZAE6.js → program-PURSFZBM.js} +170 -170
- package/dist/program-PURSFZBM.js.map +1 -0
- package/dist/{promote-B7FGHUFA.js → promote-RDXNGZKX.js} +2 -2
- package/dist/{query-ZSVAGGSM.js → query-OGMNU45Y.js} +2 -2
- package/dist/{registry-4DWWYWDR.js → registry-LKIOKDIG.js} +2 -2
- package/dist/{request-planner-DSXXT75B.js → request-planner-EP6QJAK5.js} +2 -2
- package/dist/{review-candidates-34S6R3DJ.js → review-candidates-BJPY54JI.js} +2 -2
- package/dist/{routing-HWGNYIF3.js → routing-PZNFU3OV.js} +2 -2
- package/dist/schedule-tool-C3CE6GJG.js +2 -0
- package/dist/scheduler-PJMGEJMR.js +2 -0
- package/dist/{seat-OQZY3CW7.js → seat-4OONQEDH.js} +2 -2
- package/dist/{select-BBTWL7FN.js → select-BR3NBXW7.js} +2 -2
- package/dist/{set-enabled-OC3YT4D4.js → set-enabled-Z3NKON2M.js} +2 -2
- package/dist/{surface-usage-O5L4KLGS.js → surface-usage-CH3SHO77.js} +2 -2
- package/dist/{tool-R36FDI6E.js → tool-DWMZ5OWI.js} +2 -2
- package/dist/{tool-P4AHNZ5O.js → tool-SV55IZS3.js} +2 -2
- package/dist/wiki-EWEJOKP7.js +2 -0
- package/package.json +1 -1
- package/dist/board-dashboard-MHMXII6V.js.map +0 -1
- package/dist/chunk-DWZYVYZS.js.map +0 -1
- package/dist/chunk-L6BO76GK.js.map +0 -1
- package/dist/chunk-TNR7AI4H.js.map +0 -1
- package/dist/config-mutator-UPLM7KGO.js +0 -2
- package/dist/processes-TXEWMXXJ.js +0 -2
- package/dist/program-VX4XZAE6.js.map +0 -1
- package/dist/schedule-tool-JLIS2GQU.js +0 -2
- package/dist/scheduler-F6NRVZ7W.js +0 -2
- package/dist/wiki-5E4AGLKY.js +0 -2
- /package/dist/{App-BSGDYHRD.js.map → App-LC34QQPN.js.map} +0 -0
- /package/dist/{ChatApp-K57DBCDT.js.map → ChatApp-FB72AK7M.js.map} +0 -0
- /package/dist/{agent-6MTUM5DR.js.map → agent-OZ4XFAD4.js.map} +0 -0
- /package/dist/{chunk-ECCPLASB.js.map → chunk-26UFDYRZ.js.map} +0 -0
- /package/dist/{chunk-HQWMWSSE.js.map → chunk-3GN255MT.js.map} +0 -0
- /package/dist/{chunk-7QDAGGOD.js.map → chunk-3SEFVZA7.js.map} +0 -0
- /package/dist/{chunk-XVDASTUX.js.map → chunk-64UK5VG4.js.map} +0 -0
- /package/dist/{chunk-N4HFUAPN.js.map → chunk-A5DFX47N.js.map} +0 -0
- /package/dist/{chunk-HOXHUFZB.js.map → chunk-BEJCSZOQ.js.map} +0 -0
- /package/dist/{chunk-BFY4D4RH.js.map → chunk-BTTQZWYB.js.map} +0 -0
- /package/dist/{chunk-I6HCIQCQ.js.map → chunk-ISIJAZGO.js.map} +0 -0
- /package/dist/{chunk-C3VCIEZS.js.map → chunk-JF5UGNMG.js.map} +0 -0
- /package/dist/{chunk-2FLVU2QW.js.map → chunk-JLCYQZRT.js.map} +0 -0
- /package/dist/{chunk-MZQ5PCLA.js.map → chunk-LCWE2GHC.js.map} +0 -0
- /package/dist/{chunk-7K5SJJUI.js.map → chunk-LS6KXRXY.js.map} +0 -0
- /package/dist/{chunk-KIXDJEGA.js.map → chunk-MBVRADNG.js.map} +0 -0
- /package/dist/{chunk-X2F3AVGR.js.map → chunk-N2OMSKIQ.js.map} +0 -0
- /package/dist/{chunk-EUXF2GJY.js.map → chunk-QYFF2WJ2.js.map} +0 -0
- /package/dist/{chunk-BOENB3IK.js.map → chunk-TA2BYYNZ.js.map} +0 -0
- /package/dist/{chunk-OAA7TNB6.js.map → chunk-TGN7K7VG.js.map} +0 -0
- /package/dist/{chunk-7ADEEHZQ.js.map → chunk-TS7JDPOY.js.map} +0 -0
- /package/dist/{chunk-BYD5B3P3.js.map → chunk-UVMCAZL7.js.map} +0 -0
- /package/dist/{chunk-7OEFPYQJ.js.map → chunk-UWH7NTGV.js.map} +0 -0
- /package/dist/{client-UKLOVDZB.js.map → client-IPZRCNE7.js.map} +0 -0
- /package/dist/{config-WUDWHRT6.js.map → config-HZTKLB6A.js.map} +0 -0
- /package/dist/{config-mutator-UPLM7KGO.js.map → config-mutator-6S4X6WMU.js.map} +0 -0
- /package/dist/{doctor-COAIIKLV.js.map → doctor-BTHIQN7F.js.map} +0 -0
- /package/dist/{processes-TXEWMXXJ.js.map → processes-MMAVAZAC.js.map} +0 -0
- /package/dist/{promote-B7FGHUFA.js.map → promote-RDXNGZKX.js.map} +0 -0
- /package/dist/{query-ZSVAGGSM.js.map → query-OGMNU45Y.js.map} +0 -0
- /package/dist/{registry-4DWWYWDR.js.map → registry-LKIOKDIG.js.map} +0 -0
- /package/dist/{request-planner-DSXXT75B.js.map → request-planner-EP6QJAK5.js.map} +0 -0
- /package/dist/{review-candidates-34S6R3DJ.js.map → review-candidates-BJPY54JI.js.map} +0 -0
- /package/dist/{routing-HWGNYIF3.js.map → routing-PZNFU3OV.js.map} +0 -0
- /package/dist/{schedule-tool-JLIS2GQU.js.map → schedule-tool-C3CE6GJG.js.map} +0 -0
- /package/dist/{scheduler-F6NRVZ7W.js.map → scheduler-PJMGEJMR.js.map} +0 -0
- /package/dist/{seat-OQZY3CW7.js.map → seat-4OONQEDH.js.map} +0 -0
- /package/dist/{select-BBTWL7FN.js.map → select-BR3NBXW7.js.map} +0 -0
- /package/dist/{set-enabled-OC3YT4D4.js.map → set-enabled-Z3NKON2M.js.map} +0 -0
- /package/dist/{surface-usage-O5L4KLGS.js.map → surface-usage-CH3SHO77.js.map} +0 -0
- /package/dist/{tool-R36FDI6E.js.map → tool-DWMZ5OWI.js.map} +0 -0
- /package/dist/{tool-P4AHNZ5O.js.map → tool-SV55IZS3.js.map} +0 -0
- /package/dist/{wiki-5E4AGLKY.js.map → wiki-EWEJOKP7.js.map} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{a as D,b as _}from"./chunk-RKPAVWXF.js";import{a as q,b as O,c as R,d as B,f as b,g as S,h as E,i as w,j as y}from"./chunk-
|
|
1
|
+
import{a as D,b as _}from"./chunk-RKPAVWXF.js";import{a as q,b as O,c as R,d as B,f as b,g as S,h as E,i as w,j as y}from"./chunk-TA2BYYNZ.js";import{a as T,b as C,c as I,d as x,e as P}from"./chunk-ISIJAZGO.js";import{existsSync as X,readFileSync as F}from"fs";var J=new Set(["cron","heartbeat","api","a2a","mesh"]),M=160;function s(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function A(n,e=M){let t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function V(n){let e=T(n);if(!X(e))throw new Error(`config not found at ${e}`);return JSON.parse(F(e,"utf-8"))}function W(n,e){return n?.agents?.[e]?.admin===!0}function Y(n,e,t){return W(n,t.agentId)||e?.createdBy===t.agentId}function Z(n,e){let t=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${t}. Agents manage only schedules they created (unless configured admin).`}function K(n,e){let t=s(n.notify);if(t!=="none"){if(t&&t!=="here"){let r=t.split(":");return r.length<2||!r[0]||!r[1]?"invalid":{channel:r[0],chatId:r.slice(1).join(":")}}if(e.channel&&e.chatId&&!J.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function Q(n,e,t){let r=e.timezone||"UTC",u=e.enabled&&!y(e)?w(E(e.schedule,r,t),r):"\u2014",h=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",p=[`- ${n} [${h}] ${e.schedule} \u2014 ${S(e.schedule)} (${r})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${u}`];return e.notify&&p.push(` notify: ${e.notify.channel} ${e.notify.chatId}`),e.command?p.push(` command: ${A(String(e.command))}`):e.prompt&&p.push(` prompt: ${A(String(e.prompt))}`),p.join(`
|
|
2
2
|
`)}async function k(n,e,t){let r=n?.notifications?.destination;if(!r?.channel||!r?.chatId)return"No operator notification destination is configured (notifications.destination); the operator must check `agentx schedule list`.";if(!e.notifyOperator)return"Operator notification is unavailable in this context.";try{return await e.notifyOperator({channel:r.channel,chatId:r.chatId,accountId:r.accountId},t),"The operator has been notified."}catch(u){return`Could not notify the operator (${u?.message??u}); the request is still recorded.`}}async function re(n,e,t={}){let r=(s(n.action)||"list").toLowerCase(),u=t.now?t.now():new Date,h;try{h=V(t.configPath)}catch(a){return`Error: ${a.message}`}let p=h.crons||{};if(r==="list"){let a=n.mine===!0,l=Object.entries(p).filter(([,i])=>!a||e&&i?.createdBy===e.agentId);return l.length?l.map(([i,f])=>Q(i,f,u)).join(`
|
|
3
3
|
`):a?"You have no schedules.":"No schedules."}if(!e?.agentId)return"Error: caller agent is unknown (AGENTX_AGENT_ID not set). Pass callerAgentId.";if(!h.agents?.[e.agentId])return`Error: caller "${e.agentId}" is not an agent on this node.`;let o=s(n.id),m=a=>C(a,{configPath:t.configPath,reload:t.reload});if(r==="create"){let a=s(n.when),l=s(n.prompt);if(!a||!l)return"Error: create needs `when` (plain English) and `prompt`.";let i=D(a);if(!i)return`Error: couldn't parse "${a}". ${O}.`;let f=s(n.agent)||e.agentId;if(!h.agents?.[f])return`Error: agent "${f}" not found on this node.`;let g=s(n.timezone)||q;if(!B(g))return`Error: unknown timezone "${g}".`;let d=o||_(i.matched,f);if(!R(d))return`Error: invalid id "${d}" (letters, digits, "-" and "_" only).`;if(p[d])return`Error: a schedule "${d}" already exists. Pick another \`id\`.`;let $=K(n,e);if($==="invalid")return'Error: `notify` must be "here", "none", or "channel:chatId".';let z={action:"create",requestedBy:e.agentId,requestedAt:u.toISOString()},L=b({parsed:i,agent:f,prompt:l,timezone:g,notify:$,enabled:!1,createdBy:e.agentId,approval:z}),v=await m(U=>I(U,`crons.${d}`,L));if(!v.success)return`Error: ${v.error}`;let N=w(E(i.cron,g,u),g),G=[`Schedule approval requested by ${e.agentId}`,`Create: ${d}`,`When: ${i.human} \u2014 cron \`${i.cron}\` (${g})`,`Next fire: ${N}`,`Agent: ${f}`,$?`Notify: ${$.channel} ${$.chatId}`:"Notify: none",`Prompt: ${A(l,400)}`,"",`Approve: agentx schedule approve ${d}`,`Reject: agentx schedule reject ${d}`].join(`
|
|
4
4
|
`),H=await k(h,t,G);return[`Requested schedule "${d}": ${i.human} (cron ${i.cron}, ${g}); next fire would be ${N}.`,"It is saved DISABLED and will not run until the operator approves it.",H].join(`
|
|
5
5
|
`)}if(!o)return`Error: ${r} needs \`id\`.`;let c=p[o];if(!c)return`Error: schedule "${o}" not found.`;if(!Y(h,c,e))return Z(o,c);if(r==="pause"||r==="resume"){let a=r==="resume";if(a&&y(c))return`"${o}" is still awaiting operator approval; it can't be resumed until approved.`;if(c.enabled===a)return`"${o}" is already ${a?"active":"paused"}.`;let l=await m(i=>I(i,`crons.${o}.enabled`,a));return l.success?`"${o}" ${a?"resumed":"paused"}.`:`Error: ${l.error}`}if(r==="delete"){if(y(c)&&c.approval.requestedBy===e.agentId){let d=await m($=>P($,`crons.${o}`));return d.success?`Withdrew the pending request "${o}".`:`Error: ${d.error}`}if(y(c))return`"${o}" is a creation request still awaiting approval; only its requester or the operator (\`agentx schedule reject ${o}\`) can drop it.`;if(c.approval?.action==="delete")return`Deletion of "${o}" is already awaiting approval.`;let a={action:"delete",requestedBy:e.agentId,requestedAt:u.toISOString()},l=await m(d=>{if(!x(d,`crons.${o}`))throw new Error(`schedule "${o}" not found`);I(d,`crons.${o}.approval`,a)});if(!l.success)return`Error: ${l.error}`;let i=c.timezone||"UTC",f=[`Schedule approval requested by ${e.agentId}`,`Delete: ${o}`,`When: ${S(c.schedule)} \u2014 cron \`${c.schedule}\` (${i})`,`Next fire: ${c.enabled?w(E(c.schedule,i,u),i):"\u2014 (paused)"}`,`Agent: ${c.agent}`,"",`Approve: agentx schedule approve ${o}`,`Reject: agentx schedule reject ${o}`].join(`
|
|
6
6
|
`),g=await k(h,t,f);return[`Deletion of "${o}" requested. It keeps its current state until the operator approves.`,g].join(`
|
|
7
7
|
`)}return`Error: unknown action "${r}". Use list, create, pause, resume or delete.`}function oe(n,e=process.env){let t=s(e.AGENTX_AGENT_ID)||s(n.callerAgentId);if(!t)return null;let r=!!(s(e.AGENTX_CHANNEL)&&s(e.AGENTX_CHAT_ID)),u=s(r?e.AGENTX_CHANNEL:n.channel),h=s(r?e.AGENTX_CHAT_ID:n.chatId),p=s(n.accountId);return{agentId:t,channel:u,chatId:h,...p?{accountId:p}:{}}}export{re as a,oe as b};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-LCWE2GHC.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{da as m,ga as b}from"./chunk-
|
|
1
|
+
import{da as m,ga as b}from"./chunk-XSVGD64O.js";b();function w(t){let e=typeof t.node=="string"?t.node:"",n=typeof t.token=="string"?t.token:"";if(!e||!n)try{let o=m(t.config);e||(e=o.dashboard?.daemonUrl||""),n||(n=o.dashboard?.token||"")}catch{}return e||(e="http://localhost:18800"),{baseUrl:e.replace(/\/+$/,""),token:n}}async function d(t,e,n){let o={Accept:"application/json"};t.token&&(o.Authorization=`Bearer ${t.token}`);let r=await fetch(`${t.baseUrl}${e}`,{headers:o,signal:n});if(!r.ok)throw new Error(`GET ${e} \u2192 HTTP ${r.status}`);return await r.json()}function R(t,e){return d(t,"/agents",e)}async function S(t,e){return(await d(t,"/api/processes",e)).processes??[]}function P(t,e){return d(t,"/crons",e)}async function h(t,e,n,o){let r={Accept:"application/json","Content-Type":"application/json"};t.token&&(r.Authorization=`Bearer ${t.token}`);let s=await fetch(`${t.baseUrl}${e}`,{method:"POST",headers:r,body:JSON.stringify(n),signal:o}),a=await s.text(),i;try{i=a?JSON.parse(a):{}}catch{i={raw:a}}if(!s.ok)throw new Error(i?.error||`POST ${e} \u2192 HTTP ${s.status}`);return i}function A(t,e,n="tui"){return h(t,"/api/processes/kill",{...e,reason:n})}function C(t,e,n,o){return h(t,"/task",{agent:e,message:n,context:o??{channel:"tui",chatId:"tui:operator"}})}async function $(t,e,n,o={}){let r={Accept:"text/event-stream","Content-Type":"application/json"};t.token&&(r.Authorization=`Bearer ${t.token}`);let s=await fetch(`${t.baseUrl}/task`,{method:"POST",headers:r,body:JSON.stringify({agent:e,message:n,stream:!0,context:{channel:o.channel??"chat-cli",chatId:o.chatId??"chat-cli:operator"}}),signal:o.signal});if(!s.ok||!s.body){let g=await s.text().catch(()=>"");throw new Error(`POST /task (stream) \u2192 HTTP ${s.status}${g?`: ${g.slice(0,200)}`:""}`)}let a=s.body.getReader(),i=new TextDecoder,u={content:""},c="";try{for(;;){let{done:g,value:p}=await a.read();if(g)break;c+=i.decode(p,{stream:!0});let l;for(;(l=c.indexOf(`
|
|
2
2
|
|
|
3
3
|
`))>=0;){let k=c.slice(0,l);c=c.slice(l+2);let f=x(k);f&&T(f,o,u)}}}finally{try{a.releaseLock()}catch{}}return u}function T(t,e,n){let{event:o,data:r}=t;switch(o){case"text":r?.text&&(n.content+=r.text,e.onText?.(r.text));break;case"thinking":r?.text&&e.onThinking?.(r.text);break;case"tool":e.onTool?.(r);break;case"done":typeof r?.content=="string"&&(n.content=r.content),n.usage=r?.usage,n.duration=r?.duration;break;case"error":n.error=r?.error,n.errorKind=r?.errorKind;break}}function x(t){let e="message",n="";for(let r of t.split(`
|
|
4
4
|
`))r.startsWith("event: ")?e=r.slice(7).trim():r.startsWith("data: ")&&(n=r.slice(6));if(!n)return null;let o;try{o=JSON.parse(n)}catch{o=n}return{event:e,data:o}}export{w as a,R as b,S as c,P as d,A as e,C as f,$ as g};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-LS6KXRXY.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as tt,c as nt}from"./chunk-GLQLCBJS.js";import{c as Ze}from"./chunk-SZDACK6O.js";import{b as ce}from"./chunk-AFRHKA7B.js";import{b as qe,e as Ye,f as Ge,i as Qe,k as Xe,l as et,q as rt}from"./chunk-
|
|
1
|
+
import{b as tt,c as nt}from"./chunk-GLQLCBJS.js";import{c as Ze}from"./chunk-SZDACK6O.js";import{b as ce}from"./chunk-AFRHKA7B.js";import{b as qe,e as Ye,f as Ge,i as Qe,k as Xe,l as et,q as rt}from"./chunk-3GN255MT.js";import{c as Ke,e as ze,f as Je}from"./chunk-KA2UIZXG.js";import{e as He,g as Ue,h as Be,i as de}from"./chunk-GQ76J72O.js";import{a as Ve}from"./chunk-GV7S5BAX.js";import{a as _e,b as oe,c as se,d as Le,e as ae}from"./chunk-QD6IICK7.js";import{v as Ce,w as hn}from"./chunk-26UFDYRZ.js";import{b as Me,f as mn}from"./chunk-72SZI2UW.js";import{c as We,d as je}from"./chunk-QOYAX2FT.js";import{a as ie,i as gn}from"./chunk-RJ7DASOU.js";import{existsSync as yn,mkdirSync as it,readFileSync as wn,writeFileSync as kn,renameSync as bn}from"fs";import{resolve as ot,dirname as vn}from"path";var st=class{filePath;log;constructor(e={}){let t=e.baseDir??ot(process.cwd(),".agentx");this.filePath=ot(t,"handover.json"),this.log=e.log??console.error.bind(console,"[handover]"),it(t,{recursive:!0})}key(e,t,n){return`${e}::${t}::${n||"-"}`}load(){if(!yn(this.filePath))return{version:1,overrides:{}};try{let e=wn(this.filePath,"utf-8"),t=JSON.parse(e);return!t||typeof t!="object"?{version:1,overrides:{}}:(t.overrides||(t.overrides={}),t)}catch(e){return this.log(`load failed, starting empty: ${e?.message||e}`),{version:1,overrides:{}}}}save(e){it(vn(this.filePath),{recursive:!0});let t=`${this.filePath}.tmp-${process.pid}`;kn(t,JSON.stringify(e,null,2)),bn(t,this.filePath)}get(e,t,n){let o=this.load().overrides[this.key(e,t,n)];if(o&&!(o.expiresAt&&Date.parse(o.expiresAt)<Date.now()))return o}set(e){if(!e.channel||!e.chatId||!e.toAgent)throw new Error("channel, chatId and toAgent are required");let t=this.load(),n={...e,createdAt:e.createdAt??new Date().toISOString()};return t.overrides[this.key(n.channel,n.chatId,n.accountId)]=n,this.save(t),n}remove(e,t,n){let i=this.load(),o=this.key(e,t,n);return o in i.overrides?(delete i.overrides[o],this.save(i),!0):!1}consumeSummary(e,t,n){let i=this.load(),o=i.overrides[this.key(e,t,n)];if(!o||!o.summary||o.summaryConsumedAt)return;let s=o.summary;return o.summaryConsumedAt=new Date().toISOString(),this.save(i),s}listActive(){let e=this.load(),t=Date.now();return Object.values(e.overrides).filter(n=>!n.expiresAt||Date.parse(n.expiresAt)>=t)}listByAgent(e){let t=this.listActive();return{incoming:t.filter(n=>n.toAgent===e),outgoing:t.filter(n=>n.fromAgent===e)}}};import{readFileSync as ut,writeFileSync as le,appendFileSync as Rn,mkdirSync as $n,existsSync as pt,statSync as xn}from"fs";import{resolve as U}from"path";var at="[Agent Memory \u2014 persistent facts from past conversations]",Sn=2400;function dt(r,e){return r?`UNVERIFIED (${e===null?"age unknown":`${e}d old`}) `:""}function In(r,e=Date.now()){let t=ze(r,e),n=r.undated?"UNVERIFIED (never checked) ":dt(t,He(r.verifiedAt,e));return{line:`- [wiki ${r.id}] ${n}${r.subject} \xB7 ${r.attribute}: ${r.value} (${r.source}, checked ${r.verifiedAt.slice(0,10)} by ${r.verifiedBy})`,unverified:t}}function An(r,e){let n=!r.source.chatId.startsWith("-")&&/^\d+$/.test(r.source.chatId)?"DM":r.source.chatId,i=Be(r,e);return{line:`- [${r.category}] ${dt(i,Ue(r,e))}${r.content} (${n}, ${r.source.date})`,unverified:i}}function ct(r,e=[],t=Date.now()){let n=[],i=new Set,o=at.length,s=!1;for(let a of r){let d=e.length>0?Je(a.content,e):null,c,u,p=d&&Date.parse(a.createdAt)>Date.parse(d.verifiedAt)&&!a.content.toLowerCase().includes(d.value.toLowerCase());if(d&&!p){if(i.has(d.id))continue;i.add(d.id),c=In(d,t),u=d.id}else c=An(a,t),d&&(c.line+=` [differs from wiki ${d.id}]`);let f=c.unverified&&!s?de.length:0;if(o+f+c.line.length>Sn)break;n.push({fact:a,...c,...u?{wikiRef:u}:{}}),o+=f+c.line.length,f&&(s=!0)}return n}function lt(r){if(r.length===0)return"";let e=r.some(t=>t.unverified)?[de]:[];return[at,...e,...r.map(t=>t.line),"[End Memory]"].join(`
|
|
2
2
|
`)}var ft=200,Pn=7,gt=class{memoryDir;ledger;constructor(e=process.cwd()){this.memoryDir=U(e,".agentx/memory"),this.ledger=new Ke(U(e,".agentx/wiki")),pt(this.memoryDir)||$n(this.memoryDir,{recursive:!0})}filePath(e){return U(this.memoryDir,`${e}.jsonl`)}addMemory(e,t){if(t.category==="secret"||oe(t.content))return!1;let n=t.source.trust??_e(t.source.channel),i=t.review??Le(n),o={...t,source:{...t.source,trust:n},...i?{review:i}:{},id:`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,createdAt:new Date().toISOString()};return Rn(this.filePath(e),JSON.stringify(o)+`
|
|
3
3
|
`),!0}parsedCache=new Map;getAll(e){let t=this.filePath(e);if(!pt(t))return[];try{let{mtimeMs:n,size:i}=xn(t),o=this.parsedCache.get(t);if(o&&o.mtimeMs===n&&o.size===i)return o.facts.slice();let a=ut(t,"utf-8").split(`
|
|
4
4
|
`).filter(d=>d.trim()).map(d=>{try{return JSON.parse(d)}catch{return null}}).filter(d=>d!==null);return this.parsedCache.set(t,{mtimeMs:n,size:i,facts:a}),a.slice()}catch{return[]}}findRelevant(e,t,n=8){let i=this.getAll(t).filter(ae);if(i.length===0)return[];let o=i.map(g=>`${g.keywords.join(" ")} ${g.content}`),s=U(this.memoryDir,`${t}_bm25_cache.json`),a=je(o,s),d=We(e,a),c=new Map(d.map(g=>[g.docIndex,g.score])),p=i.map((g,h)=>{let m=c.get(h)??0;return g.category==="commitment"&&(m+=1),{memory:g,score:m}}).filter(g=>g.score>0);if(p.length===0)return i.slice(-n);let f=p.sort((g,h)=>h.score-g.score).slice(0,n).map(g=>g.memory);if(f.length>0)try{this.recordAccess(t,f.map(g=>g.id))}catch{}return f}buildContext(e){return lt(this.contextLines(e))}contextFacts(e){return this.contextLines(e).map(t=>t.fact)}contextLines(e){let t=[];try{t=this.ledger.list()}catch{}return ct(e,t)}recordAccess(e,t){if(t.length===0)return;let n=this.getAll(e),i=new Set(t),o=!1;for(let s of n)if(i.has(s.id)){s.accessCount=(s.accessCount||0)+1,s.lastAccessed=new Date().toISOString();let a=s.intervalDays||1;s.intervalDays=Math.min(a*2,30),s.nextReview=new Date(Date.now()+s.intervalDays*864e5).toISOString(),o=!0}o&&le(this.filePath(e),n.map(s=>JSON.stringify(s)).join(`
|
|
@@ -25,4 +25,4 @@ import{b as tt,c as nt}from"./chunk-GLQLCBJS.js";import{c as Ze}from"./chunk-SZD
|
|
|
25
25
|
`).filter(Boolean),i=[];for(let o=n.length-1;o>=0&&i.length<t;o--)try{let s=JSON.parse(n[o]);(!e||s.person===e)&&i.push(s)}catch{}return i}load(){if(Oe(this.file))try{let e=JSON.parse(Ne(this.file,"utf-8"));if(e&&Array.isArray(e.devices))return e}catch{}return{devices:[]}}save(e){Gt(Qt(this.file),{recursive:!0});let t=`${this.file}.${process.pid}.${en(4).toString("hex")}.tmp`;Zt(t,JSON.stringify(e,null,2)+`
|
|
26
26
|
`,{encoding:"utf-8",mode:384}),Vt(t,this.file)}};import{extname as ui}from"path";var nn=/<agentx-artifact>([\s\S]*?)<\/agentx-artifact>/gi,rn=/<agentx-artifact>[\s\S]*$/i;function Ps(r,e=1/0,t=!1){let n=[],i=String(r??"");if(!/<agentx-artifact>/i.test(i))return{text:i,artifacts:n};let o=i.replace(nn,(s,a)=>{try{let d=JSON.parse(a.trim());if(d&&typeof d.filename=="string"&&typeof d.mime=="string"&&n.length<e){let c=d.mime,u=c.startsWith("image/")?"image":c==="application/pdf"?"pdf":c.startsWith("text/")?"text":"file";n.push({type:u,filename:d.filename,mime:c})}}catch{}return""});return{text:(t?o.replace(rn,""):o).trim(),artifacts:n}}function Ts(r,e=!1){let t=String(r??""),n=t;if(/<agentx-artifact>/i.test(t)){let i=t.replace(nn,(o,s)=>{try{let a=JSON.parse(s.trim());return a&&typeof a.filename=="string"?a.filename:""}catch{return""}});n=(e?i.replace(rn,""):i).trim()}return n.replace(/```[\s\S]*?```|`[^`\n]*`|!\[([^\]\n]*)\]\(([^)\s]+)\)/g,(i,o,s)=>o===void 0||s===void 0?i:`[${o||s}](${s})`)}var pi={".png":{mime:"image/png",kind:"image"},".jpg":{mime:"image/jpeg",kind:"image"},".jpeg":{mime:"image/jpeg",kind:"image"},".gif":{mime:"image/gif",kind:"image"},".webp":{mime:"image/webp",kind:"image"},".svg":{mime:"image/svg+xml",kind:"file"},".pdf":{mime:"application/pdf",kind:"file"},".txt":{mime:"text/plain; charset=utf-8",kind:"file"},".md":{mime:"text/markdown; charset=utf-8",kind:"file"},".csv":{mime:"text/csv; charset=utf-8",kind:"file"},".json":{mime:"application/json",kind:"file"},".mp3":{mime:"audio/mpeg",kind:"audio"},".m4a":{mime:"audio/mp4",kind:"audio"},".wav":{mime:"audio/wav",kind:"audio"},".mp4":{mime:"video/mp4",kind:"video"},".webm":{mime:"video/webm",kind:"video"}},Os={bytes:20*1024*1024,perMessage:20,pathChars:512};function Ns(r){return pi[ui(r).toLowerCase()]??null}var fi=["[Phone app: showing files]","To show the owner a file you created (a chart, a screenshot, a PDF, a recording), save or copy it into .agentx/outbox/ in your workspace and end your reply with one line per file:",'<agentx-artifact>{"filename":".agentx/outbox/<name.ext>","mime":"<mime/type>"}</agentx-artifact>',"Files outside your workspace (/tmp, your home folder) are refused. Outbox files are removed after 7 days.","The line is removed from the text. Images show in the reply, audio and video get a player, other files an Open link. Allowed: png, jpg, gif, webp, svg, pdf, txt, md, csv, json, mp3, m4a, wav, mp4, webm; up to 20 MB and 20 files per reply.","A picture already on the web can go inline as ."].join(`
|
|
27
27
|
`);function Ds(r,e,t){return r==="app"&&e&&t!==!1?fi:void 0}import{lstatSync as Ee,mkdirSync as gi,readdirSync as mi,realpathSync as De,unlinkSync as hi}from"fs";import{join as ne,resolve as on}from"path";var sn=".agentx/outbox",yi=7*24*60*60*1e3;function wi(r,e){try{let t=De(on(e,r)),n=ne(t,sn);return De(n)===n&&Ee(n).isDirectory()?n:null}catch{return null}}function js(r,e={}){let t=e.cwd??process.cwd();if(e.create!==!1)try{let i=De(on(t,r));Ee(ne(i,".agentx"),{throwIfNoEntry:!1})?.isSymbolicLink()||gi(ne(i,sn),{recursive:!0})}catch{return 0}let n=wi(r,t);return n?an(n,(e.now??Date.now())-(e.maxAgeMs??yi)):0}function an(r,e){let t=0;for(let n of mi(r)){let i=ne(r,n);try{let o=Ee(i);o.isDirectory()?t+=an(i,e):Math.max(o.mtimeMs,o.ctimeMs)<e&&(hi(i),t++)}catch{}}return t}export{st as a,gt as b,mt as c,Fi as d,Nn as e,Wi as f,$ as g,pe as h,v as i,B as j,Bn as k,he as l,we as m,be as n,xe as o,Hr as p,qr as q,Te as r,ar as s,ai as t,tn as u,Ps as v,Ts as w,Os as x,Ns as y,Ds as z,sn as A,js as B};
|
|
28
|
-
//# sourceMappingURL=chunk-
|
|
28
|
+
//# sourceMappingURL=chunk-MBVRADNG.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as de,d as le,e as K,f as E,g as Y,h as
|
|
2
|
-
`,l=n+".tmp";G(l,s,"utf-8");try{JSON.parse(ce(l,"utf-8"))}catch(p){throw new Error(`config did not round-trip cleanly: ${p.message}`)}let i;return t.skipBackup||(i=`${n}.bak.${Date.now()}`,
|
|
3
|
-
`,"utf-8"),{file:n}}async function
|
|
1
|
+
import{c as de,d as le,e as K,f as E,g as Y,h as _}from"./chunk-TGN7K7VG.js";import{a as se}from"./chunk-3SZ4CU6G.js";import{e as j,g as oe,n as ie,p as J}from"./chunk-XIYWXCNU.js";import{a as ae,b as re}from"./chunk-ISIJAZGO.js";import{a as ne}from"./chunk-A5DFX47N.js";import{L as ee,S as ze,aa as q,ca as te,da as U,ga as F,s as L,t as Z,w as Pe}from"./chunk-XSVGD64O.js";import{existsSync as M,readFileSync as he,writeFileSync as ve,appendFileSync as Ue,mkdirSync as We}from"fs";import{dirname as Oe,resolve as P}from"path";import{fileURLToPath as Be}from"url";import{hostname as He}from"os";import{spawn as Le}from"child_process";F();import{existsSync as pe,readFileSync as ce,writeFileSync as G,copyFileSync as De}from"fs";import{resolve as ge}from"path";function W(e,t={}){let n=t.configPath||ge(process.cwd(),"agentx.json");if(!pe(n))throw new Error(`agentx.json not found at ${n}`);let a=JSON.parse(ce(n,"utf-8")),r=e(a),o=typeof r=="string"?{summary:r}:r,s=JSON.stringify(a,null,2)+`
|
|
2
|
+
`,l=n+".tmp";G(l,s,"utf-8");try{JSON.parse(ce(l,"utf-8"))}catch(p){throw new Error(`config did not round-trip cleanly: ${p.message}`)}let i;return t.skipBackup||(i=`${n}.bak.${Date.now()}`,De(n,i)),G(n,s,"utf-8"),t.skipReload||_e().catch(()=>{}),{summary:o.summary,payload:o.payload,backupPath:i}}function me(e,t={}){let n=t.configPath||ge(process.cwd(),"agentx.json");if(pe(n)&&!t.overwrite)throw new Error(`agentx.json already exists at ${n}. Pass overwrite=true to replace it.`);return G(n,JSON.stringify(e,null,2)+`
|
|
3
|
+
`,"utf-8"),{file:n}}async function _e(){try{let t=U().dashboard.daemonUrl?.replace(/\/+$/,"")||"http://127.0.0.1:18800";await fetch(`${t}/reload`,{method:"POST"}).catch(()=>null)}catch{}}function ue(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">
|
|
4
4
|
<div class="ax-topbar__left">
|
|
5
5
|
<div class="ax-brand">
|
|
6
6
|
<span class="ax-brand__mark">AX</span>
|
|
@@ -16,14 +16,14 @@ import{c as de,d as le,e as K,f as E,g as Y,h as D}from"./chunk-OAA7TNB6.js";imp
|
|
|
16
16
|
<button data-theme-opt="light">Light</button>
|
|
17
17
|
</div>
|
|
18
18
|
</div>
|
|
19
|
-
</header>`,r=
|
|
19
|
+
</header>`,r=_(1,"Team basics",E({name:"nodeName",label:"Team name",hint:"(what you'd call this AgentX install)",value:t,placeholder:"My Team",required:!0})),o=_(2,"First agent",Y([E({name:"agentName",label:"Agent name",value:"Assistant",placeholder:"Support Bot",required:!0}),E({name:"agentId",label:"Agent id",hint:"(lowercase, no spaces)",value:"assistant",pattern:"[a-z0-9][a-z0-9_-]*",required:!0})])+E({name:"triggerWords",label:"Trigger words",hint:"(comma or space separated \u2014 e.g. <code>@support, support</code>)",value:"@assistant, assistant",required:!0})+Y([E({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)"}]}),E({name:"model",label:"Model",hint:"(optional)",value:"claude-sonnet-4-6",placeholder:"claude-sonnet-4-6"})])+E({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."})),s=_(3,"First channel",`
|
|
20
20
|
<label class="ax-toggle"><input type="checkbox" id="enableTelegram" /> Connect Telegram now</label>
|
|
21
21
|
<div class="ax-optional" id="telegramFields">
|
|
22
22
|
${E({name:"telegramAccountId",label:"Account id",hint:"(a label you choose \u2014 e.g. <code>support</code>)",value:"default"})}
|
|
23
23
|
${E({name:"telegramBotToken",label:"Bot token",hint:'(from <a href="https://t.me/BotFather" target="_blank">@BotFather</a>)',placeholder:"123456:ABCdef..."})}
|
|
24
24
|
${E({name:"telegramBotUsername",label:"Bot username",hint:"(optional \u2014 e.g. <code>my_support_bot</code>)",placeholder:"my_support_bot"})}
|
|
25
25
|
</div>
|
|
26
|
-
`),l=
|
|
26
|
+
`),l=_(4,"Anthropic API key",E({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">
|
|
27
27
|
The key is stored in <code>.env</code> as <code>ANTHROPIC_API_KEY</code> and used to authenticate requests to Anthropic. Keep it private.
|
|
28
28
|
</div>`),i=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>`:"",p=`<div class="ax-wizard">
|
|
29
29
|
<h1 class="ax-wizard__h1">${se(n)}</h1>
|
|
@@ -735,10 +735,10 @@ tr:hover td { background: var(--bg-hover); }
|
|
|
735
735
|
</div>`}o+=i.length}}return o===0&&(r+=`<p style="color:var(--muted);margin-top:24px">No articles tagged <code>${c(t)}</code>.</p>`),$(`Tag: ${t}`,C(a),r)}function it(e,t,n,a){let r=a||e.summary(),o;try{o=e.getAgentWiki(t)}catch{return $(`Tag: ${n}`,C(r),`<h1>Agent not found: ${c(t)}</h1>`)}let s=o.findByTags([n],void 0,100),l=`/agent/${encodeURIComponent(t)}`,i=`<nav class="breadcrumb"><a href="/">Hub</a> <span class="sep">/</span> <a href="${l}">${c(t)}</a> <span class="sep">/</span> <span class="current">${c(n)}</span></nav>`;i+=`<div class="page-head"><div><h1>${c(n)}</h1><p class="page-sub">${s.length} article${s.length===1?"":"s"} tagged <code>${c(n)}</code> in <b>${c(t)}</b>.</p></div></div>`;for(let p of s)i+=`<div class="entry-card">
|
|
736
736
|
<div class="meta-line">${z((p.meta.tags||[]).slice(0,6),t)}</div>
|
|
737
737
|
<h3><a href="${l}/article/${encodeURIComponent(p.path)}">${c(p.meta.title)}</a></h3>
|
|
738
|
-
</div>`;return $(`${t} \xB7 ${n}`,C(r),i)}function
|
|
738
|
+
</div>`;return $(`${t} \xB7 ${n}`,C(r),i)}function D(e,t,n){let a=e.rebuildIndex(),r=X(a.articles.map(s=>({title:s.title,path:s.path,tags:s.tags}))),o='<div class="nav-section">';o+=`<div class="nav-section-title">${c(t)}</div>`,o+=`<a class="nav-item${n?"":" active"}" href="/">Home</a>`,o+='<a class="nav-item" href="/lint">Health check</a>',o+="</div>";for(let[s,l]of r){o+='<div class="nav-section">',o+=`<div class="nav-section-title">${V(s)}</div>`;for(let i of l){let p=i.path===n;o+=`<a class="nav-item${p?" active":""}" href="/article/${encodeURIComponent(i.path)}">${c(i.title)}</a>`}o+="</div>"}return o}function st(e){let{wikiDir:t,agentFilter:n,peerUrls:a=[],mode:r="graph",pathPrefix:o=""}=e,s=o.replace(/\/+$/,""),l=new ne(t,void 0,r),i=a.length>0?new O(a):null;return async(p,g)=>{let f=new URL(p.url||"/","http://localhost"),d=decodeURIComponent(f.pathname),h=s&&d.startsWith(s)?d.slice(s.length)||"/":d,u=null,A=200;try{if(h.startsWith("/remote/")&&i){let x=h.slice(8).split("/article/");if(x.length===2){let[y,v]=x,m=y.indexOf("/"),k=decodeURIComponent(y.slice(0,m)),b=y.slice(m+1),w=await i.getRemoteArticle(k,b,v);if(w){let R=await i.getRemoteAgents(),N=[...l.summary(),...R.map(I=>({...I,agentId:`${I.agentId} @${I.nodeId}`}))],S=`<div class="breadcrumb"><a href="/">Hub</a> / <span class="tag">remote</span> ${c(b)} @ ${c(k)}</div>`;S+=`<h1>${c(w.meta.title)}</h1>`,S+='<dl class="meta">',S+=`<dt>Tags</dt><dd>${(w.meta.tags||[]).map(I=>`<span class="tag">${I}</span>`).join(" ")}</dd>`,S+=`<dt>Owner</dt><dd>${c(w.meta.owner)}</dd>`,S+=`<dt>Source</dt><dd><span class="tag">remote</span> ${c(k)}</dd>`,S+=`<dt>Updated</dt><dd>${w.meta.lastUpdated}</dd>`,S+="</dl>";let T=new Map;S+=B(w.content,T),u=$(w.meta.title,C(N),S)}}}if(!u&&n){let x=l.getAgentWiki(n);if(h==="/"||h===""){let y=x.rebuildIndex(),v=l.getAgentEntries(n),m=`<h1>${c(n)}</h1>`;if(m+='<div class="stats">',m+=`<div class="stat-card"><div class="number">${y.articles.length}</div><div class="label">Articles</div></div>`,m+=`<div class="stat-card"><div class="number">${v.length}</div><div class="label">Entries</div></div>`,m+="</div>",y.articles.length>0){m+="<h2>Articles</h2><table><tr><th>Title</th><th>Type</th><th>Updated</th></tr>";for(let k of y.articles)m+=`<tr><td><a href="/article/${encodeURIComponent(k.path)}">${c(k.title)}</a></td><td><span class="tag">${(k.tags||[]).slice(0,3).join(", ")}</span></td><td>${k.lastUpdated||""}</td></tr>`;m+="</table>"}u=$(n,D(x,n),m)}else if(h.startsWith("/article/")){let y=h.slice(9),v=x.readArticle(y);if(v){let m=x.rebuildIndex(),k=new Map;for(let w of m.articles)k.set(w.title,w.path);let b=`<h1>${c(v.meta.title)}</h1>`;b+='<dl class="meta">',b+=`<dt>Tags</dt><dd>${(v.meta.tags||[]).map(w=>`<span class="tag">${w}</span>`).join(" ")}</dd>`,b+=`<dt>Updated</dt><dd>${v.meta.lastUpdated}</dd>`,v.meta.sources?.length&&(b+=`<dt>Sources</dt><dd>${v.meta.sources.length} entries</dd>`),b+="</dl>",b+=B(v.content,k),u=$(v.meta.title,D(x,n,y),b)}}else if(h==="/lint"){let y=x.lint(),v="<h1>Health Check</h1>";if(y.length===0)v+='<p style="color:green;">No issues.</p>';else{v+="<table><tr><th>Type</th><th>Article</th><th>Issue</th></tr>";for(let m of y)v+=`<tr><td><span class="tag">${m.type}</span></td><td>${c(m.article)}</td><td>${c(m.message)}</td></tr>`;v+="</table>"}u=$("Health Check",D(x,n),v)}else if(h==="/search"){let y=f.searchParams.get("q")||"",v=await x.findRelevantReranked(y,void 0,20),m=`<h1>Search: "${c(y)}"</h1>`;for(let k of v)m+=`<div class="entry-card"><h3><a href="/article/${encodeURIComponent(k.path)}">${c(k.meta.title)}</a></h3><p>${c(k.content.slice(0,200))}...</p></div>`;v.length===0&&(m+="<p>No results.</p>"),u=$(`Search: ${y}`,D(x,n),m)}else if(h.startsWith("/tag/")){let y=decodeURIComponent(h.slice(5)),v=x.findByTags([y],void 0,100),m=`<h1>Tag: <a class="tag" href="#">${c(y)}</a></h1>`;m+=`<p>${v.length} article${v.length===1?"":"s"} tagged <code>${c(y)}</code></p>`;for(let k of v)m+=`<div class="entry-card"><h3><a href="/article/${encodeURIComponent(k.path)}">${c(k.meta.title)}</a></h3><div class="meta-line">${z((k.meta.tags||[]).slice(0,6))}</div></div>`;v.length===0&&(m+="<p>No articles with this tag.</p>"),u=$(`Tag: ${y}`,D(x,n),m)}}else{let x=i?await i.getRemoteAgents():[],y=l.summary(),v=new Map(y.map(b=>[b.agentId,b])),m=[],k=new Set;for(let b of y){let w=x.find(R=>R.agentId===b.agentId);w&&w.totalArticles>b.totalArticles?m.push({...w,totalEntries:Math.max(b.totalEntries,w.totalEntries),unabsorbed:Math.max(b.unabsorbed,w.unabsorbed)}):m.push(b),k.add(b.agentId)}for(let b of x)k.has(b.agentId)||(m.push(b),k.add(b.agentId));if(h==="/"||h==="")u=et(l,m,x);else if(h==="/entries")u=at(l,m);else if(h==="/search")u=rt(l,f.searchParams.get("q")||"",m);else if(h.startsWith("/tag/"))u=ot(l,decodeURIComponent(h.slice(5)),m);else if(h.match(/^\/agent\/[^/]+\/tag\/.+/)){let b=h.match(/^\/agent\/([^/]+)\/tag\/(.+)$/);u=it(l,decodeURIComponent(b[1]),decodeURIComponent(b[2]),m)}else if(h.startsWith("/agent/")){let b=h.slice(7),w=b.indexOf("/article/");if(w===-1)u=tt(l,b,m);else{let R=b.slice(0,w),N=b.slice(w+9);if(u=nt(l,R,N,m),!u&&i){let S=x.find(T=>T.agentId===R);if(S){let T=await i.getRemoteArticle(S.peerUrl,R,N);if(T){let I=`<div class="breadcrumb"><a href="/">Hub</a> / <span class="tag">remote @ ${c(S.nodeId)}</span> / ${c(R)}</div>`;I+=`<h1>${c(T.meta.title)}</h1>`,I+='<dl class="meta">',I+=`<dt>Tags</dt><dd>${(T.meta.tags||[]).map(Re=>`<span class="tag">${Re}</span>`).join(" ")}</dd>`,I+=`<dt>Source</dt><dd><span class="tag">remote</span> ${c(S.nodeId)}</dd>`,I+=`<dt>Updated</dt><dd>${T.meta.lastUpdated}</dd>`,I+="</dl>",I+=B(T.content,new Map),u=$(T.meta.title,C(m),I)}}}}}}if(!u){A=404;let x=n?D(l.getAgentWiki(n),n):C(l.summary());u=$("Not Found",x,"<h1>Page not found</h1>")}}catch(x){A=500,u=$("Error","",`<h1>Error</h1><pre>${c(x.message)}</pre>`)}g.writeHead(A,{"Content-Type":"text/html; charset=utf-8"}),g.end(s?dt(u,s):u)}}function dt(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 nn(e,t=4200,n,a=[],r="graph"){let o=st({wikiDir:e,agentFilter:n,peerUrls:a,mode:r});Ge((l,i)=>{o(l,i)}).listen(t)}Pe();function on(e,t,n=20){return e.prepare(`SELECT task_id, agent_id, channel, chat_id, status, started_at, message_preview
|
|
739
739
|
FROM task_traces
|
|
740
740
|
WHERE person = ? AND (channel IS NULL OR channel != 'a2a')
|
|
741
|
-
ORDER BY started_at DESC LIMIT ?`).all(t,Math.max(1,Math.min(n,500))).map(r=>({taskId:r.task_id,agentId:r.agent_id,channel:r.channel,chatId:r.chat_id,status:r.status,startedAt:r.started_at,messagePreview:r.message_preview}))}function lt(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 $e(e,t,n,a,...r){return lt(e)?e.prepare(`SELECT id, state, channel, agent_id, text, created_at FROM requests
|
|
741
|
+
ORDER BY started_at DESC, rowid DESC LIMIT ?`).all(t,Math.max(1,Math.min(n,500))).map(r=>({taskId:r.task_id,agentId:r.agent_id,channel:r.channel,chatId:r.chat_id,status:r.status,startedAt:r.started_at,messagePreview:r.message_preview}))}function lt(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 $e(e,t,n,a,...r){return lt(e)?e.prepare(`SELECT id, state, channel, agent_id, text, created_at FROM requests
|
|
742
742
|
WHERE person = ? AND state IN (${n.map(()=>"?").join(",")})
|
|
743
743
|
${a}`).all(t,...n,...r).map(s=>({id:s.id,state:s.state,channel:s.channel,agentId:s.agent_id,text:s.text,createdAt:s.created_at})):[]}function sn(e,t){return $e(e,t,L,"ORDER BY created_at")}function dn(e,t,n=50){return $e(e,t,[...L,...Z],"ORDER BY created_at DESC, rowid DESC LIMIT ?",Math.max(1,Math.min(n,500)))}ze();var Q="member:",ct=90,pt="members",gt="tailscale-user-login",mt=400,ut=60*60*1e3;function ft(e){let t=e.scopes.find(n=>n.startsWith(Q));return t?t.slice(Q.length):null}function Ae(e,t){if(!e)return null;let n=t.verify(e),a=n?ft(n):null;return n&&a?{rec:n,personId:a}:null}function un(e,t){let n=e.people().find(l=>l.id===t);if(!n)return{ok:!1,error:`No person "${t}". Add them first: agentx people add ${t} --name "\u2026"`};let{token:a,record:r}=e.tokens.create({name:`${n.name} (machine not paired yet)`,scopes:[`${Q}${n.id}`],expiresInDays:ct}),{code:o,expiresAt:s}=e.codes.create({token:a,tokenId:r.id,name:n.id});return e.members.log({person:n.id,device:r.id,event:"invited"}),{ok:!0,code:o,expiresAt:s,tokenId:r.id,person:n}}var ht="The private network says someone else is connecting from this machine. Ask the owner for a new code.",vt="Too many machines are waiting for the owner's answer. Try again later.",Se=(e,t)=>{let n=e.headers[t];return(Array.isArray(n)?n[0]:n||"").trim()};function Ie(e){let t=e.socket?.remoteAddress||"";return t==="127.0.0.1"||t==="::1"||t==="::ffff:127.0.0.1"}function bt(e){if(!Ie(e))return null;let t=Se(e,gt).toLowerCase();return t?t.slice(0,80):null}function xt(e){let t=e.socket?.remoteAddress||"unknown";if(!Ie(e))return t;let n=Se(e,"x-forwarded-for").split(",").pop().trim();return/^[0-9a-fA-F:.]{2,45}$/.test(n)?n:t}function yt(e){return typeof e=="string"?e.replace(/[^\p{L}\p{N} ._'()-]/gu," ").replace(/\s+/g," ").trim().slice(0,60):""}function kt(e){return e.identities.map(ee).filter(t=>!!t&&t.channel==="tailscale").map(t=>t.value)}async function fn(e,t){let n=Date.now(),a=t.now??Date.now,r=t.log??(m=>console.log(m)),o=xt(e),s=t.limiter.retryAfter(o);if(s>0)return r(`[member] pair-code refused from ${o}: locked out for ${s}s more`),{status:429,body:{error:"too many attempts",retryAfter:s},retryAfter:s};let l=null,i="";try{let m=await ie(e,2048);l=m.code,i=yt(m.machine)}catch{}let p=t.codes.redeem(l),g=p?Ae(p.token,t.tokens):null;if(await $t(n,t.minMs??mt),!p||!g)return t.limiter.fail(o),r(`[member] pair-code failed from ${o}`),{status:401,body:{error:J}};t.limiter.succeed(o);let{rec:f,personId:d}=g,h=t.people().find(m=>m.id===d);if(!h)return t.tokens.revoke(f.id),t.members.log({person:d,device:f.id,event:"refused",address:o,detail:"person no longer listed"}),r(`[member] pair-code for ${d} refused from ${o}: person no longer listed`),{status:403,body:{error:J}};let u=bt(e),A=kt(h);if(A.length&&(!u||!A.includes(u)))return t.tokens.revoke(f.id),t.members.log({person:d,device:f.id,event:"refused",address:o,detail:`network login ${u??"missing"}; expected ${A.join(" or ")}`}),r(`[member] ${d}: pairing from ${o} refused: the network says "${u??"nobody"}", expected ${A.join(" or ")}`),{status:403,body:{error:ht}};let x=i||"Unnamed machine",y=h.name.slice(0,40),v=oe(t.root,{title:`New machine for ${y}`,ask:`From ${o}, ${u?`network login ${u}`:"no network login reported"}. Machine name, as typed there: "${x}". Let it see ${y}'s own work?`,recommend:`Yes if ${y} told you they just paired this machine. No if you did not expect it.`,if_silent:"discard",raised_by:pt},{now:a()});return v.ok?(t.members.add({tokenId:f.id,personId:d,name:x,state:"pending",cardId:v.card.id,address:o,...u?{network:u}:{},createdAt:new Date(a()).toISOString()}),t.members.log({person:d,device:f.id,event:"paired",address:o,detail:x}),r(`[member] ${d} paired "${x}" from ${o}; waiting for the owner (card ${v.card.id})`),{status:200,body:{person:d,name:x,state:"pending"},token:p.token}):(t.tokens.revoke(f.id),t.members.log({person:d,device:f.id,event:"refused",address:o,detail:v.error}),r(`[member] ${d}: pairing from ${o} refused: ${v.error}`),{status:503,body:{error:vt}})}var H="this machine is not paired",wt="waiting for the owner to approve this machine";function Ee(e){return e?e.status==="decided"?e.verdict??null:e.status==="expired"?"no":null:null}function hn(e,t){return t.state==="pending"&&t.cardId?Ee(j(e,t.cardId)):null}function vn(e,t,n){let a=t.now??Date.now,r=t.log??(g=>console.log(g)),o=Ae(e,t.tokens);if(!o)return{ok:!1,status:401,error:H};let{rec:s,personId:l}=o,i=t.members.byToken(s.id);if(!i||i.state==="removed"||i.personId!==l)return{ok:!1,status:401,error:H};if(t.people&&!t.people().some(g=>g.id===l))return Ce(t,s.id,"person no longer listed"),r(`[member] ${l}: "${i.name}" ended: person no longer listed`),{ok:!1,status:401,error:H};if(i.state==="pending"){let g=i.cardId?j(t.root,i.cardId):null,f=Ee(g);if(f==="yes")i=t.members.update(s.id,{state:"active",approvedAt:new Date(a()).toISOString()})??i,t.members.log({person:l,device:s.id,event:"approved",detail:g?.decided_by}),r(`[member] ${l}: "${i.name}" approved`);else if(f==="no"){let d=g?.status==="expired"?"the owner did not answer in time":"the owner said no";return t.tokens.revoke(s.id),t.members.update(s.id,{state:"removed",removedAt:new Date(a()).toISOString(),removedReason:d}),t.members.log({person:l,device:s.id,event:"refused",detail:d}),r(`[member] ${l}: "${i.name}" refused: ${d}`),{ok:!1,status:401,error:H}}else return{ok:!1,status:403,error:wt,waiting:!0}}let p=i.lastSeenAt?Date.parse(i.lastSeenAt):0;return n&&(a()-p>=ut||i.lastAddress!==n)&&(i=t.members.update(s.id,{lastSeenAt:new Date(a()).toISOString(),lastAddress:n})??i,t.members.log({person:l,device:s.id,event:"signed-in",address:n})),{ok:!0,device:i,personId:l,rec:s}}function Ce(e,t,n="removed by the owner"){let a=e.members.byToken(t);if(!a)return null;e.tokens.revoke(t);let r=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}),r}function bn(e,t){return e.members.devices(t).filter(n=>n.state!=="removed").map(n=>Ce(e,n.tokenId,"person removed by the owner")).filter(n=>!!n)}async function $t(e,t){let n=e+t-Date.now();n>0&&await new Promise(a=>setTimeout(a,n))}var Te=["gitlab","github"];function At(e,t,n){let a=String(t||"").trim().toLowerCase();if(!Te.includes(a))throw new Error(`Request status works on ${Te.join(" and ")}, not on "${t}".`);e.requestStatus=e.requestStatus&&typeof e.requestStatus=="object"?e.requestStatus:{};let r=Array.isArray(e.requestStatus.channels)?e.requestStatus.channels.map(o=>String(o).toLowerCase()):[];return e.requestStatus.channels=n?[...new Set([...r,a])]:r.filter(o=>o!==a),`request status on ${a} is ${n?"on":"off"}`}function kn(e){return Array.isArray(e?.requestStatus?.channels)?e.requestStatus.channels.map(t=>String(t).toLowerCase()):[]}function wn(e){let{summary:t}=W(n=>At(n,e?.channel,!!e?.enabled));return{summary:t}}var St="https://ntfy.sh";function An(e){return{enabled:!!e?.enabled,server:e?.server||St,topicSet:!!e?.topic,tokenSet:!!e?.token}}function Sn(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{W as a,be as b,Bt as c,Ht as d,Lt as e,Kt as f,Yt as g,Gt as h,on as i,sn as j,dn as k,ct as l,un as m,xt as n,fn as o,hn as p,vn as q,Ce as r,bn as s,Te as t,At as u,kn as v,wn as w,An as x,Sn as y,st as z,nn as A};
|
|
744
|
-
//# sourceMappingURL=chunk-
|
|
744
|
+
//# sourceMappingURL=chunk-MU4S6LQA.js.map
|