agentix-cli 0.70.0 → 0.71.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/apps/mac-voice/Sources/AgentXVoice/CallModel.swift +55 -0
- package/apps/mac-voice/Sources/AgentXVoice/Calls.swift +172 -0
- package/apps/mac-voice/Sources/AgentXVoice/Panel.swift +28 -3
- package/apps/mac-voice/Sources/AgentXVoice/StatusMenu.swift +2 -0
- package/apps/mac-voice/Sources/AgentXVoice/main.swift +108 -4
- package/dist/{App-Z66ABY7H.js → App-PRD5JNO4.js} +2 -2
- package/dist/{ChatApp-Z2LZ7IM3.js → ChatApp-BKS6OJ3L.js} +2 -2
- package/dist/{agent-V223TG6H.js → agent-QF2JQ72Z.js} +2 -2
- package/dist/{board-dashboard-HR3PQPFW.js → board-dashboard-AROMOAKS.js} +4 -4
- package/dist/{board-dashboard-HR3PQPFW.js.map → board-dashboard-AROMOAKS.js.map} +1 -1
- package/dist/{chunk-PHDS2HIN.js → chunk-3C2SQDIH.js} +240 -229
- package/dist/chunk-3C2SQDIH.js.map +1 -0
- package/dist/{chunk-YBF2QVZ7.js → chunk-4XBYHKYG.js} +2 -2
- package/dist/{chunk-OPUPVGYP.js → chunk-5Y7QRFSL.js} +2 -2
- package/dist/{chunk-W7SEPJFH.js → chunk-6LTD7XL5.js} +2 -2
- package/dist/chunk-AAA6NGY5.js +6 -0
- package/dist/chunk-AAA6NGY5.js.map +1 -0
- package/dist/chunk-AHOGFVHA.js +15 -0
- package/dist/{chunk-DTX4I5LQ.js.map → chunk-AHOGFVHA.js.map} +1 -1
- package/dist/{chunk-OVX6NRMD.js → chunk-BO4WLXXC.js} +2 -2
- package/dist/{chunk-6QDOUOKD.js → chunk-D233M73Q.js} +2 -2
- package/dist/{chunk-BBIWAJRX.js → chunk-DJMUP6TK.js} +2 -2
- package/dist/{chunk-ML6CNRBK.js → chunk-EMRQ6W5J.js} +2 -2
- package/dist/{chunk-ML6CNRBK.js.map → chunk-EMRQ6W5J.js.map} +1 -1
- package/dist/{chunk-3RC4LO2G.js → chunk-HXW4NAWF.js} +2 -2
- package/dist/{chunk-KLHG5ZQH.js → chunk-IK2XG65P.js} +2 -2
- package/dist/{chunk-YK7GFEGO.js → chunk-JBVABB26.js} +2 -2
- package/dist/{chunk-3IY2YWXP.js → chunk-JU67IZLC.js} +3 -3
- package/dist/chunk-JU67IZLC.js.map +1 -0
- package/dist/{chunk-P2RYUODK.js → chunk-K6CHA6JJ.js} +2 -2
- package/dist/{chunk-LHLNARRW.js → chunk-MT3BD6WG.js} +186 -184
- package/dist/chunk-MT3BD6WG.js.map +1 -0
- package/dist/{chunk-FBDIJEKL.js → chunk-OTMDMGHE.js} +9 -9
- package/dist/chunk-OTMDMGHE.js.map +1 -0
- package/dist/{chunk-SN5N2FPG.js → chunk-RCKICCTT.js} +2 -2
- package/dist/{chunk-FSYA4GNU.js → chunk-SELIVR6U.js} +2 -2
- package/dist/{chunk-FUR3T3IN.js → chunk-SFWA67GQ.js} +2 -2
- package/dist/{chunk-YL223TEU.js → chunk-WLX4766Y.js} +2 -2
- package/dist/{chunk-TTVVXBCM.js → chunk-WPNRDEHW.js} +2 -2
- package/dist/chunk-XJQNIFZ4.js +49 -0
- package/dist/chunk-XJQNIFZ4.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/client-UPBQVXYM.js +2 -0
- package/dist/config-UY5K6SCL.js +2 -0
- package/dist/config-mutator-7KOSRAQF.js +2 -0
- package/dist/doctor-GFPSIJGB.js +2 -0
- package/dist/index.d.ts +106 -9
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/migrate-v2-W7RRFM24.js +4 -0
- package/dist/{migrate-v2-ZOIMGITH.js.map → migrate-v2-W7RRFM24.js.map} +1 -1
- package/dist/program-XMGZOYX3.js +2 -0
- package/dist/promote-YLKNYYIU.js +2 -0
- package/dist/query-CVRXEG43.js +2 -0
- package/dist/registry-HZL363TA.js +2 -0
- package/dist/{request-planner-NMOAOZIM.js → request-planner-76NCBYBW.js} +2 -2
- package/dist/{review-candidates-FLY6HZEN.js → review-candidates-ZUXMX6BJ.js} +2 -2
- package/dist/{routing-SMIZ77CT.js → routing-EIGWDKH7.js} +2 -2
- package/dist/schedule-tool-PSZMP7C4.js +2 -0
- package/dist/scheduler-S24PXNB6.js +2 -0
- package/dist/{seat-F3S2HG5G.js → seat-QOY6FA4N.js} +2 -2
- package/dist/{select-5GC7CTPQ.js → select-JHKHO5BO.js} +2 -2
- package/dist/{set-enabled-53ZPZ5GR.js → set-enabled-DVJIUOKX.js} +2 -2
- package/dist/{tool-FRTZS4TT.js → tool-WKSLNQ6H.js} +2 -2
- package/dist/wiki-PTXUMSIR.js +2 -0
- package/package.json +1 -1
- package/dist/chunk-3IY2YWXP.js.map +0 -1
- package/dist/chunk-DTX4I5LQ.js +0 -15
- package/dist/chunk-FBDIJEKL.js.map +0 -1
- package/dist/chunk-LHLNARRW.js.map +0 -1
- package/dist/chunk-PHDS2HIN.js.map +0 -1
- package/dist/chunk-TFVUOC2C.js +0 -2
- package/dist/chunk-TFVUOC2C.js.map +0 -1
- package/dist/chunk-TLDQWTSW.js +0 -49
- package/dist/chunk-TLDQWTSW.js.map +0 -1
- package/dist/chunk-WLMQ5JMX.js +0 -6
- package/dist/chunk-WLMQ5JMX.js.map +0 -1
- package/dist/client-GDTX6LFH.js +0 -2
- package/dist/config-FZ4D4EAV.js +0 -2
- package/dist/config-mutator-ETG5V4C5.js +0 -2
- package/dist/doctor-JBIRBRLB.js +0 -2
- package/dist/graph-FJ53FDWK.js +0 -2
- package/dist/migrate-v2-ZOIMGITH.js +0 -4
- package/dist/program-UTELWTXC.js +0 -2
- package/dist/promote-B5AOKPQR.js +0 -2
- package/dist/query-QLJNQUUP.js +0 -2
- package/dist/registry-CTZFLXGB.js +0 -2
- package/dist/schedule-tool-NJFROYKY.js +0 -2
- package/dist/scheduler-5N4FC2FQ.js +0 -2
- package/dist/wiki-X76JUHXT.js +0 -2
- package/dist/wiki-X76JUHXT.js.map +0 -1
- /package/dist/{App-Z66ABY7H.js.map → App-PRD5JNO4.js.map} +0 -0
- /package/dist/{ChatApp-Z2LZ7IM3.js.map → ChatApp-BKS6OJ3L.js.map} +0 -0
- /package/dist/{agent-V223TG6H.js.map → agent-QF2JQ72Z.js.map} +0 -0
- /package/dist/{chunk-YBF2QVZ7.js.map → chunk-4XBYHKYG.js.map} +0 -0
- /package/dist/{chunk-OPUPVGYP.js.map → chunk-5Y7QRFSL.js.map} +0 -0
- /package/dist/{chunk-W7SEPJFH.js.map → chunk-6LTD7XL5.js.map} +0 -0
- /package/dist/{chunk-OVX6NRMD.js.map → chunk-BO4WLXXC.js.map} +0 -0
- /package/dist/{chunk-6QDOUOKD.js.map → chunk-D233M73Q.js.map} +0 -0
- /package/dist/{chunk-BBIWAJRX.js.map → chunk-DJMUP6TK.js.map} +0 -0
- /package/dist/{chunk-3RC4LO2G.js.map → chunk-HXW4NAWF.js.map} +0 -0
- /package/dist/{chunk-KLHG5ZQH.js.map → chunk-IK2XG65P.js.map} +0 -0
- /package/dist/{chunk-YK7GFEGO.js.map → chunk-JBVABB26.js.map} +0 -0
- /package/dist/{chunk-P2RYUODK.js.map → chunk-K6CHA6JJ.js.map} +0 -0
- /package/dist/{chunk-SN5N2FPG.js.map → chunk-RCKICCTT.js.map} +0 -0
- /package/dist/{chunk-FSYA4GNU.js.map → chunk-SELIVR6U.js.map} +0 -0
- /package/dist/{chunk-FUR3T3IN.js.map → chunk-SFWA67GQ.js.map} +0 -0
- /package/dist/{chunk-YL223TEU.js.map → chunk-WLX4766Y.js.map} +0 -0
- /package/dist/{chunk-TTVVXBCM.js.map → chunk-WPNRDEHW.js.map} +0 -0
- /package/dist/{client-GDTX6LFH.js.map → client-UPBQVXYM.js.map} +0 -0
- /package/dist/{config-FZ4D4EAV.js.map → config-UY5K6SCL.js.map} +0 -0
- /package/dist/{config-mutator-ETG5V4C5.js.map → config-mutator-7KOSRAQF.js.map} +0 -0
- /package/dist/{doctor-JBIRBRLB.js.map → doctor-GFPSIJGB.js.map} +0 -0
- /package/dist/{graph-FJ53FDWK.js.map → program-XMGZOYX3.js.map} +0 -0
- /package/dist/{program-UTELWTXC.js.map → promote-YLKNYYIU.js.map} +0 -0
- /package/dist/{promote-B5AOKPQR.js.map → query-CVRXEG43.js.map} +0 -0
- /package/dist/{query-QLJNQUUP.js.map → registry-HZL363TA.js.map} +0 -0
- /package/dist/{request-planner-NMOAOZIM.js.map → request-planner-76NCBYBW.js.map} +0 -0
- /package/dist/{review-candidates-FLY6HZEN.js.map → review-candidates-ZUXMX6BJ.js.map} +0 -0
- /package/dist/{registry-CTZFLXGB.js.map → routing-EIGWDKH7.js.map} +0 -0
- /package/dist/{routing-SMIZ77CT.js.map → schedule-tool-PSZMP7C4.js.map} +0 -0
- /package/dist/{schedule-tool-NJFROYKY.js.map → scheduler-S24PXNB6.js.map} +0 -0
- /package/dist/{scheduler-5N4FC2FQ.js.map → seat-QOY6FA4N.js.map} +0 -0
- /package/dist/{select-5GC7CTPQ.js.map → select-JHKHO5BO.js.map} +0 -0
- /package/dist/{set-enabled-53ZPZ5GR.js.map → set-enabled-DVJIUOKX.js.map} +0 -0
- /package/dist/{tool-FRTZS4TT.js.map → tool-WKSLNQ6H.js.map} +0 -0
- /package/dist/{seat-F3S2HG5G.js.map → wiki-PTXUMSIR.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as o}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as o}from"./chunk-EMRQ6W5J.js";import{resolve as a}from"path";import{existsSync as d,readdirSync as c,mkdirSync as l}from"fs";var g=class{baseDir;agentsDir;mode;sharedStore;agentStores=new Map;log;constructor(t=a(process.cwd(),".agentx/wiki"),e=console.error.bind(console,"[wiki-hub]"),r="graph"){this.baseDir=t,this.agentsDir=a(t,"agents"),this.mode=r,this.log=e,l(this.agentsDir,{recursive:!0}),this.sharedStore=new o(t,e)}getMode(){return this.mode}getAgentWiki(t){let e=`${t}:${this.mode}`;if(this.agentStores.has(e))return this.agentStores.get(e);let r=a(this.agentsDir,t,this.mode),i=new o(r,this.log);return this.agentStores.set(e,i),i}getBaseDir(){return this.baseDir}getSharedStore(){return this.sharedStore}listAgents(){let t=new Set,e=this.sharedStore.listEntries();for(let r of e)t.add(r.agentId);if(d(this.agentsDir))for(let r of c(this.agentsDir))!r.startsWith("_")&&!r.startsWith(".")&&t.add(r);return[...t].sort()}getAgentEntries(t){return this.sharedStore.listEntries({agentId:t})}getUnabsorbedEntries(t){let e=this.getAgentWiki(t),r=this.getAgentEntries(t),i=new Set,n=e.rebuildIndex();for(let s of n.articles)if(s.sources)for(let h of s.sources)i.add(h);return r.filter(s=>!i.has(s.id))}summary(){return this.listAgents().map(e=>{let r=this.getAgentEntries(e),n=this.getAgentWiki(e).rebuildIndex(),s=this.getUnabsorbedEntries(e);return{agentId:e,totalEntries:r.length,totalArticles:n.articles.length,unabsorbed:s.length,articles:n.articles}})}};export{g as a};
|
|
2
|
+
//# sourceMappingURL=chunk-RCKICCTT.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{q as p}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{q as p}from"./chunk-5Y7QRFSL.js";import{b as i,c as u,d as l,e as c}from"./chunk-WLX4766Y.js";import d from"cronstrue";var f=Intl.DateTimeFormat().resolvedOptions().timeZone,m=600,E='Try: "every morning at 9", "weekdays at 6pm", "every 15 minutes", "every monday at 10am", "1st of every month at noon", "daily at 9:30am", "every hour"',g=/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;function w(e){return g.test(e)}function x(e){try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}}function $(e){return e?e.split(",").map(r=>r.trim().toLowerCase()).filter(r=>r==="log"||r==="notify"||r==="disable"):["log"]}function S(e){let r=[...e.onError??["log"]];e.notify&&!r.includes("notify")&&r.push("notify");let t={enabled:e.enabled??!0,schedule:e.parsed.cron,timezone:e.timezone||f,agent:e.agent,prompt:e.prompt,timeout:e.timeout??m,onError:r};return e.model&&(t.model=e.model),e.notify&&(t.notify=e.notify),e.createdBy&&(t.createdBy=e.createdBy),e.approval&&(t.approval=e.approval),t}function P(e){try{return d.toString(e,{use24HourTimeFormat:!1})}catch{return e}}function T(e,r,t=new Date){try{return p(e,t,r)}catch{return null}}function A(e,r){if(!e)return"unknown (no match within a year)";try{return`${new Intl.DateTimeFormat("en-GB",{timeZone:r,weekday:"short",day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(e)} (${r})`}catch{return e.toISOString()}}function h(e){return e?.approval?.action==="create"}async function D(e,r={}){let t="",o=await i(n=>{let a=l(n,`crons.${e}`);if(!a)throw new Error(`cron "${e}" not found`);let s=a.approval;if(!s)throw new Error(`cron "${e}" has no pending request`);s.action==="create"?(delete a.approval,a.enabled=!0,t=`${e} approved and enabled (requested by ${s.requestedBy})`):(c(n,`crons.${e}`),t=`${e} deletion approved; job removed (requested by ${s.requestedBy})`)},{configPath:r.configPath,reload:r.reload});return o.success?{success:!0,message:t,result:o}:{success:!1,message:o.error||"failed",result:o}}async function I(e,r={}){let t="",o=await i(n=>{let a=l(n,`crons.${e}`);if(!a)throw new Error(`cron "${e}" not found`);let s=a.approval;if(!s)throw new Error(`cron "${e}" has no pending request`);s.action==="create"?(c(n,`crons.${e}`),t=`${e} rejected; pending job removed`):(delete a.approval,t=`${e} deletion rejected; job kept`)},{configPath:r.configPath,reload:r.reload});return o.success?{success:!0,message:t,result:o}:{success:!1,message:o.error||"failed",result:o}}async function O(e,r,t={}){return i(o=>{let n=l(o,`crons.${e}`);if(!n)throw new Error(`cron "${e}" not found`);if(r&&h(n))throw new Error(`cron "${e}" is awaiting approval; run \`agentx schedule approve ${e}\``);u(o,`crons.${e}.enabled`,r)},{configPath:t.configPath,reload:t.reload})}export{f as a,E as b,w as c,x as d,$ as e,S as f,P as g,T as h,A as i,h as j,D as k,I as l,O as m};
|
|
2
|
+
//# sourceMappingURL=chunk-SELIVR6U.js.map
|
|
@@ -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-SELIVR6U.js";import{a as T,b as C,c as I,d as x,e as P}from"./chunk-WLX4766Y.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-SFWA67GQ.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as x,v as m,w as $}from"./chunk-AHOGFVHA.js";x();import{readFileSync as S,writeFileSync as P,existsSync as b}from"fs";import{resolve as f}from"path";function w(r){if(r)return f(r);let e=[f(process.cwd(),"agentx.json"),f(process.cwd(),".agentx/config.json")];for(let n of e)if(b(n))return n;return e[0]}function v(r){return JSON.parse(JSON.stringify(r))}async function O(r){try{let e=await fetch(`${r.replace(/\/$/,"")}/reload`,{method:"POST",signal:AbortSignal.timeout(3e3)});return e.ok?{ok:!0}:{ok:!1,reason:`HTTP ${e.status}`}}catch(e){return{ok:!1,reason:e?.cause?.code||e?.message||"unreachable"}}}async function J(r,e={}){let{validate:n=!0,dryRun:t=!1,reload:s=!0,configPath:u,daemonUrl:c}=e,o=w(u);if(!b(o))return{success:!1,path:o,error:`Config not found at ${o}. Run \`agentx init\` first.`};let d;try{d=S(o,"utf-8")}catch(a){return{success:!1,path:o,error:`Cannot read ${o}: ${a.message}`}}let g;try{g=JSON.parse(d)}catch(a){return{success:!1,path:o,error:`Invalid JSON in ${o}: ${a.message}`}}let i=v(g);try{await r(i)}catch(a){return{success:!1,path:o,error:`Mutator threw: ${a.message}`}}if(n){let a=$(i),l=m.safeParse(a);if(!l.success){let k=l.error.issues.map(y=>` ${y.path.join(".")||"<root>"}: ${y.message}`).join(`
|
|
2
2
|
`);return{success:!1,path:o,error:`Validation failed:
|
|
3
3
|
${k}`,after:i}}}if(t)return{success:!0,path:o,after:i,dryRun:!0};try{P(o,JSON.stringify(i,null,2)+`
|
|
4
4
|
`)}catch(a){return{success:!1,path:o,error:`Write failed: ${a.message}`,after:i}}let p=!1,h;if(s){let a=c||R(i),l=await O(a);l.ok?p=!0:h=l.reason}return{success:!0,path:o,after:i,reloaded:p,reloadSkipped:h}}function R(r){let e=r?.node?.bind;if(!e)return"http://127.0.0.1:18800";let[n,t]=e.split(":");return`http://${n==="0.0.0.0"||n==="::"?"127.0.0.1":n}:${t}`}function N(r,e,n){let t=e.split("."),s=r;for(let u=0;u<t.length-1;u++){let c=t[u];(s[c]===void 0||s[c]===null)&&(s[c]={}),s=s[c]}s[t[t.length-1]]=n}function j(r,e){let n=e.split("."),t=r;for(let s of n){if(t==null)return;t=t[s]}return t}function A(r,e){let n=e.split("."),t=r;for(let s=0;s<n.length-1;s++){if(t==null)return;t=t[n[s]]}t!=null&&delete t[n[n.length-1]]}export{w as a,J as b,N as c,j as d,A as e};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-WLX4766Y.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{z as e}from"zod";var i=e.enum(["enum","free","ref"]),a=e.object({name:e.string().regex(/^[a-z][a-z0-9_]*$/i,"axis name must be a simple identifier"),type:i,values:e.array(e.string()).optional(),refLevel:e.string().optional(),optional:e.boolean().optional(),description:e.string().optional()}),r=e.object({id:e.string().regex(/^[a-z][a-z0-9_-]*$/,"level id must be lowercase slug"),axes:e.array(a).min(1),description:e.string().optional()}),f=e.object({version:e.number().int().default(1),levels:e.array(r).min(1).max(5),leafInput:a.optional(),leafOutput:a.optional()}),t=e.string().regex(/^[a-z0-9][a-z0-9._-]*$/,"node id must be lowercase slug (alnum, '.', '_', '-')"),n=e.object({id:t,level:e.string(),parentId:t.nullable(),axes:e.record(e.string(),e.string()),createdAt:e.string(),createdBy:e.string().optional()}),o=e.enum(["llm","user","cache","seat"]),s=e.enum(["pending","approved","rejected"]),p=e.object({ts:e.string(),msgHash:e.string(),agentId:e.string().optional(),channel:e.string().optional(),sender:e.string().optional(),chatId:e.string().optional(),path:e.array(t),proposedAxes:e.record(e.string(),e.record(e.string(),e.string())).default({}),leaf:e.object({input:e.string().optional(),output:e.string().optional()}).partial().default({}),source:o,status:s,confidence:e.number().min(0).max(1).optional(),preview:e.string().optional()}),c=e.object({fingerprint:e.string(),path:e.array(t),leaf:p.shape.leaf,updatedAt:e.string()}),m=e.object({version:e.number().int().default(1),nodes:e.array(n).default([])}),d=e.object({version:e.number().int().default(1),entries:e.record(e.string(),c).default({})});export{
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{z as e}from"zod";var i=e.enum(["enum","free","ref"]),a=e.object({name:e.string().regex(/^[a-z][a-z0-9_]*$/i,"axis name must be a simple identifier"),type:i,values:e.array(e.string()).optional(),refLevel:e.string().optional(),optional:e.boolean().optional(),description:e.string().optional()}),r=e.object({id:e.string().regex(/^[a-z][a-z0-9_-]*$/,"level id must be lowercase slug"),axes:e.array(a).min(1),description:e.string().optional()}),f=e.object({version:e.number().int().default(1),levels:e.array(r).min(1).max(5),leafInput:a.optional(),leafOutput:a.optional()}),t=e.string().regex(/^[a-z0-9][a-z0-9._-]*$/,"node id must be lowercase slug (alnum, '.', '_', '-')"),n=e.object({id:t,level:e.string(),parentId:t.nullable(),axes:e.record(e.string(),e.string()),createdAt:e.string(),createdBy:e.string().optional()}),o=e.enum(["llm","user","cache","seat"]),s=e.enum(["pending","approved","rejected"]),p=e.object({ts:e.string(),msgHash:e.string(),agentId:e.string().optional(),channel:e.string().optional(),sender:e.string().optional(),chatId:e.string().optional(),path:e.array(t),proposedAxes:e.record(e.string(),e.record(e.string(),e.string())).default({}),leaf:e.object({input:e.string().optional(),output:e.string().optional()}).partial().default({}),source:o,status:s,confidence:e.number().min(0).max(1).optional(),preview:e.string().optional()}),c=e.object({fingerprint:e.string(),path:e.array(t),leaf:p.shape.leaf,updatedAt:e.string()}),m=e.object({version:e.number().int().default(1),nodes:e.array(n).default([])}),d=e.object({version:e.number().int().default(1),entries:e.record(e.string(),c).default({})});export{f as a,p as b,c,m as d,d as e};
|
|
2
|
+
//# sourceMappingURL=chunk-WPNRDEHW.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import{a as j,b as O,c as T,d as D,e as _,j as N}from"./chunk-AAA6NGY5.js";import{b as R}from"./chunk-2GIDVZ4H.js";import{v as C,w as I}from"./chunk-DJMUP6TK.js";import{b as v,c as W}from"./chunk-QOYAX2FT.js";import{readFileSync as Y,existsSync as B}from"fs";I();import{resolve as x}from"path";import{execSync as L}from"child_process";async function nt(n,a,o,t={}){let u=t.selectorModel??"haiku",g=t.synthModel??"sonnet",l=t.maxCandidates??3,r=t.maxHops??2,s=t.maxArticles??8,h=t.timeoutMs??6e4,p=t.log??console.error.bind(console,"[wiki-query]"),m=t.messagePath?.length?t.messagePath:void 0,w=t.graphWeight??$,i=x(a.baseDir,"_index.md");if(!B(i))return A("no-catalog",n,"No _index.md found \u2014 run `agentx wiki status` to rebuild.");let e=Y(i,"utf-8"),d=Date.now(),f=[],y="";try{let c=await G(n,a,o,l,m,w);c?(f=c,y=`[wiki-rerank seat] ${c.map(k=>k.title).join(" | ")}`):(y=await Q(q(n,e,l,m),u,h),f=K(y))}catch(c){return p("selector failed:",c?.message),{...A("error",n,`Selector: ${c?.message||"unknown"}`),trace:{selectorMs:Date.now()-d,synthesisMs:0,selectorOutput:y}}}let S=Date.now()-d;if(f.length===0)return{...A("no-candidates",n,"Selector returned no candidates."),trace:{selectorMs:S,synthesisMs:0,selectorOutput:y}};let b=F(f,a,o,r,s);if(b.length===0)return{...A("no-candidates",n,"Candidates did not resolve to readable articles."),candidates:f,trace:{selectorMs:S,synthesisMs:0,selectorOutput:y}};let M=Date.now(),P="";try{P=await Q(J(n,b),g,h*2)}catch(c){return p("synthesis failed:",c?.message),{...A("error",n,`Synthesis: ${c?.message||"unknown"}`),candidates:f,walked:b.map(k=>({title:k.meta.title,path:k.path,type:k.meta.type,hop:k.hop??0})),trace:{selectorMs:S,synthesisMs:Date.now()-M,selectorOutput:y}}}let E=Date.now()-M;return{answer:P.trim(),citations:b.map(c=>({title:c.meta.title,path:c.path,type:c.meta.type})),candidates:f,walked:b.map(c=>({title:c.meta.title,path:c.path,type:c.meta.type,hop:c.hop??0})),status:"ok",trace:{selectorMs:S,synthesisMs:E,selectorOutput:y}}}function A(n,a,o){return{answer:"",citations:[],candidates:[],walked:[],status:n,error:o}}function F(n,a,o,t,u){let g=new Map;for(let s of a.listArticles(o||""))g.set(s.meta.title.toLowerCase(),s.path);let l=new Map,r=[];for(let s of n)l.has(s.path)||r.push({path:s.path,hop:0});for(;r.length&&l.size<u;){let s=r.shift();if(l.has(s.path)||s.hop>t)continue;let h=o?a.readArticleAs(s.path,o):a.readArticle(s.path);if(h&&(l.set(s.path,{...h,hop:s.hop}),!(s.hop>=t)))for(let p of h.meta.related||[]){let m=g.get(p.toLowerCase());m&&!l.has(m)&&r.push({path:m,hop:s.hop+1})}}return Array.from(l.values())}async function G(n,a,o,t,u,g=$){try{let r=(a.rebuildIndex().articles??[]).filter(i=>i.path&&!i.path.includes("/_versions/"));if(r.length<2)return null;let h=H(n,r,u,g).slice(0,O).map(i=>({id:`k${i}`,title:r[i].title||r[i].path,tags:r[i].tags,excerpt:[r[i].type?`type: ${r[i].type}`:"",(r[i].related??[]).length?`related: ${(r[i].related??[]).join(", ")}`:"",(r[i].graphPath??[]).length?`graph: ${(r[i].graphPath??[]).join(" \u203A ")}`:""].filter(Boolean).join(" \xB7 ")})),p=await C(j,T({query:n,candidates:h,excerptChars:300}),D(h),{features:{agent:o??"unknown",stage:"catalog-selector"}});if(!p||p.mode!=="active")return null;let w=_(p.answers,h).ranked.slice(0,t).map(i=>r[Number(i.slice(1))]).filter(Boolean).map(i=>({title:i.title,path:i.path}));return w.length>0?w:null}catch{return null}}var $=.6;function H(n,a,o,t=$){let u=a.map(e=>[e.title,(e.tags??[]).join(" "),(e.related??[]).join(" ")].join(" ")),g=W(n,v(u)),l=g.reduce((e,d)=>Math.max(e,d.score),0),r=new Map(g.map(e=>[e.docIndex,l>0?e.score/l:0])),s=!!o?.length,h=e=>s&&e.graphPath?.length?N(o,e.graphPath):0,p=(e,d)=>d.score-e.score||e.i-d.i,m=a.map((e,d)=>({i:d,score:(r.get(d)??0)*(1+t*h(e))})).filter(e=>r.has(e.i)).sort(p),w=a.map((e,d)=>({i:d,score:h(e)})).filter(e=>!r.has(e.i)&&e.score>0).sort(p),i=[...m,...w].map(e=>e.i);for(let e=0;e<a.length;e++)i.includes(e)||i.push(e);return i}function q(n,a,o,t){let u=t?.length?`
|
|
2
|
+
## Intent
|
|
3
|
+
|
|
4
|
+
The request was classified under the intent-graph path "${t.join(" \u203A ")}". Prefer articles filed under the same branch when their titles are equally plausible.
|
|
5
|
+
`:"";return`You are picking candidate articles from a wiki catalog to answer a question. You do NOT answer the question. You pick which articles the answer is likely to come from.
|
|
6
|
+
|
|
7
|
+
## Question
|
|
8
|
+
|
|
9
|
+
${n}
|
|
10
|
+
${u}
|
|
11
|
+
## Catalog (_index.md \u2014 articles grouped by type, with wikilink previews)
|
|
12
|
+
|
|
13
|
+
${a}
|
|
14
|
+
|
|
15
|
+
## Your task
|
|
16
|
+
|
|
17
|
+
Pick up to ${o} articles from the catalog that are most likely to answer the question. Prefer:
|
|
18
|
+
- Articles whose title directly names a subject in the question.
|
|
19
|
+
- Articles of the right type (e.g. a "who owns X" question \u2192 person or project; a "what happened on DATE" \u2192 event).
|
|
20
|
+
- Articles whose wikilinks suggest they sit at the center of a relevant subgraph.
|
|
21
|
+
|
|
22
|
+
Return ONLY valid JSON, no markdown fencing, no prose:
|
|
23
|
+
|
|
24
|
+
[
|
|
25
|
+
{"title": "Exact Article Title", "path": "path/from/catalog.md"},
|
|
26
|
+
...
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
If none of the articles match, return [].`}function J(n,a){let o=a.map(t=>{let u=`### ${t.meta.title} \u2014 ${t.meta.type||"untyped"} (${t.path}) [hop ${t.hop}]`,g=t.meta.related?.length?`Related: ${t.meta.related.join(", ")}`:"";return[u,g,"",t.content].filter(Boolean).join(`
|
|
30
|
+
`)}).join(`
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
`);return`You are answering a question using a small subgraph of wiki articles. The articles were walked from the catalog; trust them over your prior knowledge.
|
|
35
|
+
|
|
36
|
+
## Question
|
|
37
|
+
|
|
38
|
+
${n}
|
|
39
|
+
|
|
40
|
+
## Articles (${a.length} walked from the catalog)
|
|
41
|
+
|
|
42
|
+
${o}
|
|
43
|
+
|
|
44
|
+
## Your task
|
|
45
|
+
|
|
46
|
+
Answer the question in 2\u20136 sentences. Cite articles by their title in square brackets like [Article Title]. If the articles do not answer the question, say so plainly (do not invent). Prefer concrete facts over hedging.
|
|
47
|
+
|
|
48
|
+
Output ONLY the answer \u2014 no preamble, no "here is my answer:", no markdown fencing.`}function K(n){let a=n.match(/\[[\s\S]*?\]/);if(!a)return[];try{let o=JSON.parse(a[0]);return Array.isArray(o)?o.filter(t=>t&&typeof t.title=="string"&&typeof t.path=="string").map(t=>({title:t.title,path:t.path})):[]}catch{return[]}}async function Q(n,a,o){let{writeFileSync:t,mkdirSync:u,rmSync:g}=await import("fs"),{tmpdir:l}=await import("os"),r=x(l(),`agentx-wiki-query-${process.pid}`);u(r,{recursive:!0});let s=x(r,`prompt-${Date.now()}.txt`);t(s,n);try{let h=`cat '${s}' | claude -p - --output-format json --max-turns 1 --model ${a} --disallowedTools "Bash Read Write Edit Glob Grep Agent WebSearch WebFetch NotebookEdit"`,p=L(h,{env:R({...process.env}),encoding:"utf-8",timeout:o,maxBuffer:4*1024*1024});try{let m=JSON.parse(p);return String(m.result||m.content||"")}catch{return p}}finally{try{g(s,{force:!0})}catch{}}}export{nt as a,$ as b,H as c};
|
|
49
|
+
//# sourceMappingURL=chunk-XJQNIFZ4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/wiki/query.ts"],"sourcesContent":["import { readFileSync, existsSync } from \"fs\"\nimport { buildIndex, scoreAll } from \"@/memory/bm25\"\nimport { askSeat } from \"@/decisions/seat\"\nimport { ancestryScore } from \"@/graph\"\nimport {\n DEFAULT_SHORTLIST,\n WIKI_RERANK_SEAT,\n rerankQuestions,\n rerankState,\n toRanking,\n type RerankCandidate,\n} from \"@/decisions/seats/wiki-rerank\"\nimport { stripAnthropicApiKey } from \"@/utils/workspace-env\"\nimport { resolve } from \"path\"\nimport { execSync } from \"child_process\"\nimport type { WikiArticle } from \"./types\"\nimport type { WikiStore } from \"./store\"\n\n/**\n * Agentic wiki query — the \"Farzapedia-faithful\" retrieval path.\n *\n * Two LLM calls + a deterministic graph walk:\n * 1. Selector (cheap): read `_index.md` + question → pick up to `maxCandidates`\n * candidate articles by title + type.\n * 2. Walk (pure code): starting from candidates, follow `related` wikilinks\n * up to `maxHops`, capped at `maxArticles` total.\n * 3. Synthesis (main): answer the question from the walked subgraph.\n *\n * Returns an answer with citations and a trace of which articles were walked,\n * so callers can audit the retrieval path.\n */\n\nexport interface AgenticQueryOptions {\n /** Candidate-selection model (cheap). Defaults to \"haiku\". */\n selectorModel?: string\n /** Synthesis model (main). Defaults to \"sonnet\". */\n synthModel?: string\n /** Number of candidates the selector is asked to return. Default 3. */\n maxCandidates?: number\n /** Wikilink hops from candidates. Default 2. */\n maxHops?: number\n /** Hard cap on total articles walked. Default 8. */\n maxArticles?: number\n /** Timeout per LLM call, ms. Default 60_000. */\n timeoutMs?: number\n /** Logger — defaults to console.error. */\n log?: (...args: unknown[]) => void\n /** Intent-graph path the question's request was classified under.\n * Articles on the same branch rank higher in candidate selection. */\n messagePath?: string[]\n /** Weight of the branch match against the text match, 0–1. Default 0.6\n * (`graph.retrievalWeights.graph`). */\n graphWeight?: number\n}\n\nexport interface AgenticQueryResult {\n answer: string\n citations: Array<{ title: string; path: string; type?: string }>\n /** Titles/paths the selector picked. */\n candidates: Array<{ title: string; path: string }>\n /** Full article subgraph the walk produced. */\n walked: Array<{ title: string; path: string; type?: string; hop: number }>\n /** \"no-catalog\" | \"no-candidates\" | \"ok\" */\n status: \"ok\" | \"no-catalog\" | \"no-candidates\" | \"error\"\n /** For operator debugging only. */\n trace?: {\n selectorMs: number\n synthesisMs: number\n selectorOutput?: string\n }\n error?: string\n}\n\n/**\n * Run an agentic query against a specific agent's WikiStore.\n *\n * `requesterId` is used for permission checks — only articles the requester\n * can read will be included in the synthesis input.\n */\nexport async function agenticQuery(\n question: string,\n store: WikiStore,\n requesterId: string | undefined,\n opts: AgenticQueryOptions = {},\n): Promise<AgenticQueryResult> {\n const selectorModel = opts.selectorModel ?? \"haiku\"\n const synthModel = opts.synthModel ?? \"sonnet\"\n const maxCandidates = opts.maxCandidates ?? 3\n const maxHops = opts.maxHops ?? 2\n const maxArticles = opts.maxArticles ?? 8\n const timeoutMs = opts.timeoutMs ?? 60_000\n const log = opts.log ?? console.error.bind(console, \"[wiki-query]\")\n const messagePath = opts.messagePath?.length ? opts.messagePath : undefined\n const graphWeight = opts.graphWeight ?? DEFAULT_GRAPH_WEIGHT\n\n // --- Step 1: Load the catalog ---\n const catalogPath = resolve(store.baseDir, \"_index.md\")\n if (!existsSync(catalogPath)) {\n return emptyResult(\"no-catalog\", question, \"No _index.md found — run `agentx wiki status` to rebuild.\")\n }\n const catalog = readFileSync(catalogPath, \"utf-8\")\n\n // --- Step 2: Selector — pick candidates ---\n const selectorStart = Date.now()\n let candidates: Array<{ title: string; path: string }> = []\n let selectorOutput = \"\"\n try {\n const viaSeat = await selectCandidatesViaSeat(question, store, requesterId, maxCandidates, messagePath, graphWeight)\n if (viaSeat) {\n candidates = viaSeat\n selectorOutput = `[wiki-rerank seat] ${viaSeat.map((c) => c.title).join(\" | \")}`\n } else {\n selectorOutput = await runClaude(\n buildSelectorPrompt(question, catalog, maxCandidates, messagePath),\n selectorModel,\n timeoutMs,\n )\n candidates = parseCandidates(selectorOutput)\n }\n } catch (e: any) {\n log(\"selector failed:\", e?.message)\n return { ...emptyResult(\"error\", question, `Selector: ${e?.message || \"unknown\"}`), trace: { selectorMs: Date.now() - selectorStart, synthesisMs: 0, selectorOutput } }\n }\n const selectorMs = Date.now() - selectorStart\n\n if (candidates.length === 0) {\n return { ...emptyResult(\"no-candidates\", question, \"Selector returned no candidates.\"), trace: { selectorMs, synthesisMs: 0, selectorOutput } }\n }\n\n // --- Step 3: Walk the subgraph via `related` wikilinks ---\n const walked = walkSubgraph(candidates, store, requesterId, maxHops, maxArticles)\n\n if (walked.length === 0) {\n return { ...emptyResult(\"no-candidates\", question, \"Candidates did not resolve to readable articles.\"), candidates, trace: { selectorMs, synthesisMs: 0, selectorOutput } }\n }\n\n // --- Step 4: Synthesize the answer ---\n const synthStart = Date.now()\n let answer = \"\"\n try {\n answer = await runClaude(\n buildSynthesisPrompt(question, walked),\n synthModel,\n timeoutMs * 2,\n )\n } catch (e: any) {\n log(\"synthesis failed:\", e?.message)\n return { ...emptyResult(\"error\", question, `Synthesis: ${e?.message || \"unknown\"}`), candidates, walked: walked.map(w => ({ title: w.meta.title, path: w.path, type: w.meta.type, hop: (w as any).hop ?? 0 })), trace: { selectorMs, synthesisMs: Date.now() - synthStart, selectorOutput } }\n }\n const synthesisMs = Date.now() - synthStart\n\n return {\n answer: answer.trim(),\n citations: walked.map(a => ({ title: a.meta.title, path: a.path, type: a.meta.type })),\n candidates,\n walked: walked.map(w => ({ title: w.meta.title, path: w.path, type: w.meta.type, hop: (w as any).hop ?? 0 })),\n status: \"ok\",\n trace: { selectorMs, synthesisMs, selectorOutput },\n }\n}\n\n// --- Helpers ---\n\nfunction emptyResult(\n status: AgenticQueryResult[\"status\"],\n _question: string,\n error?: string,\n): AgenticQueryResult {\n return {\n answer: \"\",\n citations: [],\n candidates: [],\n walked: [],\n status,\n error,\n }\n}\n\nfunction walkSubgraph(\n candidates: Array<{ title: string; path: string }>,\n store: WikiStore,\n requesterId: string | undefined,\n maxHops: number,\n maxArticles: number,\n): Array<WikiArticle & { hop: number }> {\n // Build a title → path index from the store so wikilinks resolve.\n const titleIndex = new Map<string, string>()\n for (const article of store.listArticles(requesterId || \"\")) {\n titleIndex.set(article.meta.title.toLowerCase(), article.path)\n }\n\n const opened = new Map<string, WikiArticle & { hop: number }>()\n let frontier: Array<{ path: string; hop: number }> = []\n\n for (const c of candidates) {\n if (!opened.has(c.path)) frontier.push({ path: c.path, hop: 0 })\n }\n\n while (frontier.length && opened.size < maxArticles) {\n const next = frontier.shift()!\n if (opened.has(next.path)) continue\n if (next.hop > maxHops) continue\n\n const article = requesterId\n ? store.readArticleAs(next.path, requesterId)\n : store.readArticle(next.path)\n if (!article) continue\n\n opened.set(next.path, { ...article, hop: next.hop })\n if (next.hop >= maxHops) continue\n\n for (const target of article.meta.related || []) {\n const path = titleIndex.get(target.toLowerCase())\n if (path && !opened.has(path)) {\n frontier.push({ path, hop: next.hop + 1 })\n }\n }\n }\n\n return Array.from(opened.values())\n}\n\n// --- Prompts ---\n\n/**\n * Pick candidates with the wiki-rerank seat instead of a Claude CLI call.\n *\n * The selector is 56% of a wiki query — 14.1s of a 25s total, measured —\n * and its whole job is \"pick 3 articles from this catalog\", which is a\n * Choice with per-option probabilities. Jev answers that in about a\n * second. Synthesis stays on Sonnet; it writes prose, which Jev cannot.\n *\n * BM25 shortlists first because the shared catalog carries 971 entries,\n * past the 255-option cap. Same two-stage shape as findRelevantReranked,\n * and it reuses that seat rather than introducing a second one.\n *\n * Returns null whenever the seat is off, errors, or has nothing to rank,\n * and the caller falls back to the CLI selector — so this is strictly an\n * accelerator, never a new way to fail.\n */\nasync function selectCandidatesViaSeat(\n question: string,\n store: WikiStore,\n requesterId: string | undefined,\n maxCandidates: number,\n messagePath?: string[],\n graphWeight: number = DEFAULT_GRAPH_WEIGHT,\n): Promise<Array<{ title: string; path: string }> | null> {\n try {\n const index = store.rebuildIndex()\n const pool = (index.articles ?? []).filter((a) => a.path && !a.path.includes(\"/_versions/\"))\n if (pool.length < 2) return null\n\n const shortlist = rankCatalogPool(question, pool, messagePath, graphWeight).slice(0, DEFAULT_SHORTLIST)\n\n const candidates: RerankCandidate[] = shortlist.map((i) => ({\n id: `k${i}`,\n title: pool[i].title || pool[i].path,\n tags: pool[i].tags,\n // The catalog has no body — a title, its type, its wikilinks and its\n // branch of the intent graph are what the selector chooses on.\n excerpt: [\n pool[i].type ? `type: ${pool[i].type}` : \"\",\n (pool[i].related ?? []).length ? `related: ${(pool[i].related ?? []).join(\", \")}` : \"\",\n (pool[i].graphPath ?? []).length ? `graph: ${(pool[i].graphPath ?? []).join(\" › \")}` : \"\",\n ].filter(Boolean).join(\" · \"),\n }))\n\n const result = await askSeat(\n WIKI_RERANK_SEAT,\n rerankState({ query: question, candidates, excerptChars: 300 }),\n rerankQuestions(candidates),\n { features: { agent: requesterId ?? \"unknown\", stage: \"catalog-selector\" } },\n )\n if (!result || result.mode !== \"active\") return null\n\n const ranking = toRanking(result.answers as never, candidates)\n const picked = ranking.ranked\n .slice(0, maxCandidates)\n .map((id) => pool[Number(id.slice(1))])\n .filter(Boolean)\n .map((a) => ({ title: a.title, path: a.path }))\n return picked.length > 0 ? picked : null\n } catch {\n return null\n }\n}\n\n/** Weight of the intent-graph branch match against the text match when\n * shortlisting catalog candidates. Mirrors `graph.retrievalWeights.graph`. */\nexport const DEFAULT_GRAPH_WEIGHT = 0.6\n\n/**\n * Order the catalog pool for a question. Three bands, never mixed:\n *\n * 1. articles the text match scored, ordered by `text * (1 + w * branch)`\n * when the request was classified: the branch reorders text matches\n * but cannot lift an unrelated article above one;\n * 2. articles on the request's branch that the text never matched, by\n * how much of the path they share;\n * 3. the rest, in catalog order.\n *\n * Band 1 comes first in full because the shortlist the reranker sees is\n * finite (DEFAULT_SHORTLIST): a busy category holds more same-branch\n * articles than that, and a blended score let them push the article that\n * actually answers the question out of the list.\n *\n * Exported for tests; the seat and the CLI selector both consume the order.\n */\nexport function rankCatalogPool(\n question: string,\n pool: Array<{ title: string; tags?: string[]; related?: string[]; graphPath?: string[] }>,\n messagePath?: string[],\n graphWeight: number = DEFAULT_GRAPH_WEIGHT,\n): number[] {\n const docs = pool.map((a) =>\n [a.title, (a.tags ?? []).join(\" \"), (a.related ?? []).join(\" \")].join(\" \"),\n )\n const bm25 = scoreAll(question, buildIndex(docs))\n const maxBm25 = bm25.reduce((m, r) => Math.max(m, r.score), 0)\n const text = new Map(bm25.map((r) => [r.docIndex, maxBm25 > 0 ? r.score / maxBm25 : 0]))\n const useGraph = !!messagePath?.length\n const branch = (a: { graphPath?: string[] }) =>\n useGraph && a.graphPath?.length ? ancestryScore(messagePath!, a.graphPath) : 0\n\n const byScore = (x: { i: number; score: number }, y: { i: number; score: number }) => y.score - x.score || x.i - y.i\n const matched = pool\n .map((a, i) => ({ i, score: (text.get(i) ?? 0) * (1 + graphWeight * branch(a)) }))\n .filter((c) => text.has(c.i))\n .sort(byScore)\n const branchOnly = pool\n .map((a, i) => ({ i, score: branch(a) }))\n .filter((c) => !text.has(c.i) && c.score > 0)\n .sort(byScore)\n const ranked = [...matched, ...branchOnly].map((c) => c.i)\n for (let i = 0; i < pool.length; i++) if (!ranked.includes(i)) ranked.push(i)\n return ranked\n}\n\nfunction buildSelectorPrompt(question: string, catalog: string, maxCandidates: number, messagePath?: string[]): string {\n const branch = messagePath?.length\n ? `\\n## Intent\\n\\nThe request was classified under the intent-graph path \"${messagePath.join(\" › \")}\". Prefer articles filed under the same branch when their titles are equally plausible.\\n`\n : \"\"\n return `You are picking candidate articles from a wiki catalog to answer a question. You do NOT answer the question. You pick which articles the answer is likely to come from.\n\n## Question\n\n${question}\n${branch}\n## Catalog (_index.md — articles grouped by type, with wikilink previews)\n\n${catalog}\n\n## Your task\n\nPick up to ${maxCandidates} articles from the catalog that are most likely to answer the question. Prefer:\n- Articles whose title directly names a subject in the question.\n- Articles of the right type (e.g. a \"who owns X\" question → person or project; a \"what happened on DATE\" → event).\n- Articles whose wikilinks suggest they sit at the center of a relevant subgraph.\n\nReturn ONLY valid JSON, no markdown fencing, no prose:\n\n[\n {\"title\": \"Exact Article Title\", \"path\": \"path/from/catalog.md\"},\n ...\n]\n\nIf none of the articles match, return [].`\n}\n\nfunction buildSynthesisPrompt(\n question: string,\n articles: Array<WikiArticle & { hop: number }>,\n): string {\n const articlesBlock = articles\n .map(a => {\n const header = `### ${a.meta.title} — ${a.meta.type || \"untyped\"} (${a.path}) [hop ${a.hop}]`\n const related = a.meta.related?.length ? `Related: ${a.meta.related.join(\", \")}` : \"\"\n return [header, related, \"\", a.content].filter(Boolean).join(\"\\n\")\n })\n .join(\"\\n\\n---\\n\\n\")\n\n return `You are answering a question using a small subgraph of wiki articles. The articles were walked from the catalog; trust them over your prior knowledge.\n\n## Question\n\n${question}\n\n## Articles (${articles.length} walked from the catalog)\n\n${articlesBlock}\n\n## Your task\n\nAnswer the question in 2–6 sentences. Cite articles by their title in square brackets like [Article Title]. If the articles do not answer the question, say so plainly (do not invent). Prefer concrete facts over hedging.\n\nOutput ONLY the answer — no preamble, no \"here is my answer:\", no markdown fencing.`\n}\n\nfunction parseCandidates(raw: string): Array<{ title: string; path: string }> {\n const match = raw.match(/\\[[\\s\\S]*?\\]/)\n if (!match) return []\n try {\n const parsed = JSON.parse(match[0])\n if (!Array.isArray(parsed)) return []\n return parsed\n .filter((x: any) => x && typeof x.title === \"string\" && typeof x.path === \"string\")\n .map((x: any) => ({ title: x.title, path: x.path }))\n } catch {\n return []\n }\n}\n\nasync function runClaude(prompt: string, model: string, timeoutMs: number): Promise<string> {\n // Use stdin via a temp-file pipe to avoid shell-escaping a huge prompt.\n // Prompts can exceed the `-E` arg buffer on macOS, so we always pipe.\n const { writeFileSync, mkdirSync, rmSync } = await import(\"fs\")\n const { tmpdir } = await import(\"os\")\n const dir = resolve(tmpdir(), `agentx-wiki-query-${process.pid}`)\n mkdirSync(dir, { recursive: true })\n const promptPath = resolve(dir, `prompt-${Date.now()}.txt`)\n writeFileSync(promptPath, prompt)\n try {\n const cmd = `cat '${promptPath}' | claude -p - --output-format json --max-turns 1 --model ${model} --disallowedTools \"Bash Read Write Edit Glob Grep Agent WebSearch WebFetch NotebookEdit\"`\n const raw = execSync(cmd, { env: stripAnthropicApiKey({ ...process.env }), encoding: \"utf-8\", timeout: timeoutMs, maxBuffer: 4 * 1024 * 1024 })\n try {\n const envelope = JSON.parse(raw)\n return String(envelope.result || envelope.content || \"\")\n } catch {\n return raw\n }\n } finally {\n try { rmSync(promptPath, { force: true }) } catch {}\n }\n}\n"],"mappings":"iNAAA,OAAS,gBAAAA,EAAc,cAAAC,MAAkB,KAEzCC,IAWA,OAAS,WAAAC,MAAe,OACxB,OAAS,YAAAC,MAAgB,gBAiEzB,eAAsBC,GACpBC,EACAC,EACAC,EACAC,EAA4B,CAAC,EACA,CAC7B,IAAMC,EAAgBD,EAAK,eAAiB,QACtCE,EAAaF,EAAK,YAAc,SAChCG,EAAgBH,EAAK,eAAiB,EACtCI,EAAUJ,EAAK,SAAW,EAC1BK,EAAcL,EAAK,aAAe,EAClCM,EAAYN,EAAK,WAAa,IAC9BO,EAAMP,EAAK,KAAO,QAAQ,MAAM,KAAK,QAAS,cAAc,EAC5DQ,EAAcR,EAAK,aAAa,OAASA,EAAK,YAAc,OAC5DS,EAAcT,EAAK,aAAeU,EAGlCC,EAAcjB,EAAQI,EAAM,QAAS,WAAW,EACtD,GAAI,CAACc,EAAWD,CAAW,EACzB,OAAOE,EAAY,aAAchB,EAAU,gEAA2D,EAExG,IAAMiB,EAAUC,EAAaJ,EAAa,OAAO,EAG3CK,EAAgB,KAAK,IAAI,EAC3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F,IAAMQ,EAAM,QAAQD,+DAAwEN,6FACtFJ,EAAMnF,EAAS8F,EAAK,CAAE,IAAKC,EAAqB,CAAE,GAAG,QAAQ,GAAI,CAAC,EAAG,SAAU,QAAS,QAASpF,EAAW,UAAW,EAAI,KAAO,IAAK,CAAC,EAC9I,GAAI,CACF,IAAMqF,EAAW,KAAK,MAAMb,CAAG,EAC/B,OAAO,OAAOa,EAAS,QAAUA,EAAS,SAAW,EAAE,CACzD,MAAE,CACA,OAAOb,CACT,CACF,QAAE,CACA,GAAI,CAAEO,EAAOG,EAAY,CAAE,MAAO,EAAK,CAAC,CAAE,MAAE,CAAO,CACrD,CACF","names":["readFileSync","existsSync","init_seat","resolve","execSync","agenticQuery","question","store","requesterId","opts","selectorModel","synthModel","maxCandidates","maxHops","maxArticles","timeoutMs","log","messagePath","graphWeight","DEFAULT_GRAPH_WEIGHT","catalogPath","existsSync","emptyResult","catalog","readFileSync","selectorStart","candidates","selectorOutput","viaSeat","selectCandidatesViaSeat","c","runClaude","buildSelectorPrompt","parseCandidates","e","selectorMs","walked","walkSubgraph","synthStart","answer","buildSynthesisPrompt","w","synthesisMs","a","status","_question","error","titleIndex","article","opened","frontier","next","target","path","pool","rankCatalogPool","DEFAULT_SHORTLIST","result","askSeat","WIKI_RERANK_SEAT","rerankState","rerankQuestions","picked","toRanking","id","docs","bm25","scoreAll","buildIndex","maxBm25","m","r","text","useGraph","branch","ancestryScore","byScore","x","y","matched","i","branchOnly","ranked","articles","articlesBlock","header","related","raw","match","parsed","prompt","model","writeFileSync","mkdirSync","rmSync","tmpdir","dir","promptPath","cmd","stripAnthropicApiKey","envelope"]}
|
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as n}from"./chunk-
|
|
2
|
+
import{a as n}from"./chunk-MT3BD6WG.js";import"./chunk-BO4WLXXC.js";import"./chunk-IK2XG65P.js";import"./chunk-D233M73Q.js";import"./chunk-Z3IP66SL.js";import"./chunk-C4CDVE2E.js";import"./chunk-RKPAVWXF.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-SZDACK6O.js";import"./chunk-3C2SQDIH.js";import"./chunk-JU67IZLC.js";import"./chunk-BYJ3A55Y.js";import"./chunk-NMFXY3QU.js";import"./chunk-4XBYHKYG.js";import"./chunk-LQRBGQIR.js";import"./chunk-ZVP6GB4G.js";import"./chunk-JBVABB26.js";import"./chunk-2D3RYIDU.js";import"./chunk-EKJG63EJ.js";import"./chunk-OTMDMGHE.js";import"./chunk-6LTD7XL5.js";import"./chunk-N6EWZGIX.js";import"./chunk-WP6KLXTP.js";import"./chunk-DP7RTNDM.js";import"./chunk-HXW4NAWF.js";import"./chunk-SFQUP3BP.js";import"./chunk-SELIVR6U.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-5Y7QRFSL.js";import"./chunk-WLX4766Y.js";import"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-K6CHA6JJ.js";import"./chunk-DWADWDMU.js";import"./chunk-23A5K5UW.js";import"./chunk-QD6IICK7.js";import"./chunk-VWTBHLMX.js";import"./chunk-RCKICCTT.js";import"./chunk-EMRQ6W5J.js";import"./chunk-CECHWYJ2.js";import"./chunk-XJQNIFZ4.js";import"./chunk-AAA6NGY5.js";import"./chunk-WPNRDEHW.js";import"./chunk-2GIDVZ4H.js";import"./chunk-DJMUP6TK.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-5MUJZODV.js";import"./chunk-7I7IEX4S.js";import"./chunk-JHCI6XCJ.js";import"./chunk-DSYKYZMT.js";import"./chunk-AHOGFVHA.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";var r=["SIGINT","SIGTERM"];function o(t=process){for(let i of r)t.on(i,()=>{t.listenerCount(i)<=1&&t.exit(0)})}o();async function s(){let t=await n();if(process.argv.slice(2).length===0){t.outputHelp();return}t.parse()}s();
|
|
3
3
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/signal-exit.ts","../src/cli.ts"],"sourcesContent":["// --- Ctrl-C / SIGTERM for CLI commands ---\n//\n// Short commands should exit at once when stopped. Long-running ones (the\n// daemon above all) install their own handler to finish in-flight work first.\n// The CLI's quick exit used to be registered unconditionally, before the\n// daemon's, and Node runs listeners in registration order — so every stop\n// exited the process before the daemon's drain began and killed in-flight\n// agent tasks mid-turn (#103). Now the quick exit only fires when nobody\n// else handles the signal.\n\ntype SignalTarget = Pick<NodeJS.Process, \"on\" | \"listenerCount\" | \"exit\">\n\nexport const CLI_EXIT_SIGNALS = [\"SIGINT\", \"SIGTERM\"] as const\n\nexport function installCliSignalExit(proc: SignalTarget = process): void {\n for (const sig of CLI_EXIT_SIGNALS) {\n proc.on(sig, () => {\n // This listener is always one of them; anything more means a command\n // is handling the stop itself.\n if (proc.listenerCount(sig) <= 1) proc.exit(0)\n })\n }\n}\n","#!/usr/bin/env node\nimport { buildProgram } from \"@/program\"\nimport { installCliSignalExit } from \"@/utils/signal-exit\"\n\ninstallCliSignalExit()\n\nasync function main() {\n const program = await buildProgram()\n\n const args = process.argv.slice(2)\n if (args.length === 0) {\n program.outputHelp()\n return\n }\n\n program.parse()\n}\n\nmain()\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../src/utils/signal-exit.ts","../src/cli.ts"],"sourcesContent":["// --- Ctrl-C / SIGTERM for CLI commands ---\n//\n// Short commands should exit at once when stopped. Long-running ones (the\n// daemon above all) install their own handler to finish in-flight work first.\n// The CLI's quick exit used to be registered unconditionally, before the\n// daemon's, and Node runs listeners in registration order — so every stop\n// exited the process before the daemon's drain began and killed in-flight\n// agent tasks mid-turn (#103). Now the quick exit only fires when nobody\n// else handles the signal.\n\ntype SignalTarget = Pick<NodeJS.Process, \"on\" | \"listenerCount\" | \"exit\">\n\nexport const CLI_EXIT_SIGNALS = [\"SIGINT\", \"SIGTERM\"] as const\n\nexport function installCliSignalExit(proc: SignalTarget = process): void {\n for (const sig of CLI_EXIT_SIGNALS) {\n proc.on(sig, () => {\n // This listener is always one of them; anything more means a command\n // is handling the stop itself.\n if (proc.listenerCount(sig) <= 1) proc.exit(0)\n })\n }\n}\n","#!/usr/bin/env node\nimport { buildProgram } from \"@/program\"\nimport { installCliSignalExit } from \"@/utils/signal-exit\"\n\ninstallCliSignalExit()\n\nasync function main() {\n const program = await buildProgram()\n\n const args = process.argv.slice(2)\n if (args.length === 0) {\n program.outputHelp()\n return\n }\n\n program.parse()\n}\n\nmain()\n"],"mappings":";wyDAYO,IAAMA,EAAmB,CAAC,SAAU,SAAS,EAE7C,SAASC,EAAqBC,EAAqB,QAAe,CACvE,QAAWC,KAAOH,EAChBE,EAAK,GAAGC,EAAK,IAAM,CAGbD,EAAK,cAAcC,CAAG,GAAK,GAAGD,EAAK,KAAK,CAAC,CAC/C,CAAC,CAEL,CClBAE,EAAqB,EAErB,eAAeC,GAAO,CACpB,IAAMC,EAAU,MAAMC,EAAa,EAGnC,GADa,QAAQ,KAAK,MAAM,CAAC,EACxB,SAAW,EAAG,CACrBD,EAAQ,WAAW,EACnB,OAGFA,EAAQ,MAAM,CAChB,CAEAD,EAAK","names":["CLI_EXIT_SIGNALS","installCliSignalExit","proc","sig","installCliSignalExit","main","program","buildProgram"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{A as i,r as a,s as b,t as c,u as d,v as e,w as f,x as g,y as h}from"./chunk-AHOGFVHA.js";import"./chunk-QIJLFPWE.js";i();export{a as INTEGRATION_KINDS,d as approvalsConfigSchema,c as callsSchema,e as daemonConfigSchema,b as eventSubscriptionSchema,f as expandEnvVars,g as loadDaemonConfig,h as validateWorkspaces};
|
|
2
|
+
//# sourceMappingURL=config-UY5K6SCL.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as a,c as b,d as c,e as d,f as e}from"./chunk-IK2XG65P.js";import"./chunk-BYJ3A55Y.js";import"./chunk-AHOGFVHA.js";import"./chunk-QIJLFPWE.js";export{e as daemonVoiceCheck,b as doctor,a as runDoctorChecks,c as runNotificationChecks,d as runReminderChecks};
|
|
2
|
+
//# sourceMappingURL=doctor-GFPSIJGB.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -4082,6 +4082,38 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
4082
4082
|
accountId?: string | undefined;
|
|
4083
4083
|
} | undefined;
|
|
4084
4084
|
}>>;
|
|
4085
|
+
calls: z.ZodDefault<z.ZodObject<{
|
|
4086
|
+
/** Agents allowed to call: ids, or "*" for every agent on this node.
|
|
4087
|
+
* Empty: nobody can call until the owner allows it. */
|
|
4088
|
+
allow: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
4089
|
+
/** Most calls one agent may place in an hour. */
|
|
4090
|
+
maxPerHour: z.ZodDefault<z.ZodNumber>;
|
|
4091
|
+
/** How long a call rings before it counts as missed. */
|
|
4092
|
+
ringSeconds: z.ZodDefault<z.ZodNumber>;
|
|
4093
|
+
/** An answered call nobody hung up (widget quit or crashed, the Mac
|
|
4094
|
+
* slept, `agentx call answer` without a conversation) ends after this,
|
|
4095
|
+
* so the agent can call again. */
|
|
4096
|
+
maxCallMinutes: z.ZodDefault<z.ZodNumber>;
|
|
4097
|
+
/** Ring sound: a name from /System/Library/Sounds, without the extension. */
|
|
4098
|
+
ringSound: z.ZodDefault<z.ZodString>;
|
|
4099
|
+
/** After hang-up, ask the agent for a short summary and file it in the
|
|
4100
|
+
* dashboard's conversation history. */
|
|
4101
|
+
summary: z.ZodDefault<z.ZodBoolean>;
|
|
4102
|
+
}, "strip", z.ZodTypeAny, {
|
|
4103
|
+
summary: boolean;
|
|
4104
|
+
allow: string[];
|
|
4105
|
+
maxPerHour: number;
|
|
4106
|
+
maxCallMinutes: number;
|
|
4107
|
+
ringSeconds: number;
|
|
4108
|
+
ringSound: string;
|
|
4109
|
+
}, {
|
|
4110
|
+
summary?: boolean | undefined;
|
|
4111
|
+
allow?: string[] | undefined;
|
|
4112
|
+
maxPerHour?: number | undefined;
|
|
4113
|
+
maxCallMinutes?: number | undefined;
|
|
4114
|
+
ringSeconds?: number | undefined;
|
|
4115
|
+
ringSound?: string | undefined;
|
|
4116
|
+
}>>;
|
|
4085
4117
|
approvals: z.ZodDefault<z.ZodObject<{
|
|
4086
4118
|
/** A card without an `expires` gets this many days. */
|
|
4087
4119
|
defaultExpiryDays: z.ZodDefault<z.ZodNumber>;
|
|
@@ -4247,6 +4279,17 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
4247
4279
|
pollSeconds?: number | undefined;
|
|
4248
4280
|
lookbackHours?: number | undefined;
|
|
4249
4281
|
}>>;
|
|
4282
|
+
/** `agentx demo`, read from the agentx.json in the folder it runs from. */
|
|
4283
|
+
demo: z.ZodDefault<z.ZodObject<{
|
|
4284
|
+
/** Seconds each startup step (node /health, dashboard /live, mesh
|
|
4285
|
+
* discovery) may take. Unset: AGENTX_DEMO_STARTUP_TIMEOUT, else 60 s
|
|
4286
|
+
* scaled up by the load average (src/commands/demo-startup.ts). */
|
|
4287
|
+
startupTimeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
4288
|
+
}, "strip", z.ZodTypeAny, {
|
|
4289
|
+
startupTimeoutSeconds?: number | undefined;
|
|
4290
|
+
}, {
|
|
4291
|
+
startupTimeoutSeconds?: number | undefined;
|
|
4292
|
+
}>>;
|
|
4250
4293
|
/** The in-process event bus (src/events). `ringSize` bounds how many
|
|
4251
4294
|
* recent events GET /events/recent can return. */
|
|
4252
4295
|
events: z.ZodDefault<z.ZodObject<{
|
|
@@ -5887,6 +5930,9 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
5887
5930
|
sweepIntervalSeconds?: number | undefined;
|
|
5888
5931
|
}>>;
|
|
5889
5932
|
}, "strip", z.ZodTypeAny, {
|
|
5933
|
+
demo: {
|
|
5934
|
+
startupTimeoutSeconds?: number | undefined;
|
|
5935
|
+
};
|
|
5890
5936
|
agents: Record<string, {
|
|
5891
5937
|
name: string;
|
|
5892
5938
|
workspace: string;
|
|
@@ -6270,6 +6316,14 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
6270
6316
|
accountId?: string | undefined;
|
|
6271
6317
|
} | undefined;
|
|
6272
6318
|
};
|
|
6319
|
+
calls: {
|
|
6320
|
+
summary: boolean;
|
|
6321
|
+
allow: string[];
|
|
6322
|
+
maxPerHour: number;
|
|
6323
|
+
maxCallMinutes: number;
|
|
6324
|
+
ringSeconds: number;
|
|
6325
|
+
ringSound: string;
|
|
6326
|
+
};
|
|
6273
6327
|
approvals: {
|
|
6274
6328
|
digest: {
|
|
6275
6329
|
enabled: boolean;
|
|
@@ -6548,6 +6602,9 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
6548
6602
|
bind?: string | undefined;
|
|
6549
6603
|
defaultAgent?: string | undefined;
|
|
6550
6604
|
};
|
|
6605
|
+
demo?: {
|
|
6606
|
+
startupTimeoutSeconds?: number | undefined;
|
|
6607
|
+
} | undefined;
|
|
6551
6608
|
agents?: Record<string, {
|
|
6552
6609
|
name: string;
|
|
6553
6610
|
workspace: string;
|
|
@@ -6925,6 +6982,14 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
6925
6982
|
accountId?: string | undefined;
|
|
6926
6983
|
} | undefined;
|
|
6927
6984
|
} | undefined;
|
|
6985
|
+
calls?: {
|
|
6986
|
+
summary?: boolean | undefined;
|
|
6987
|
+
allow?: string[] | undefined;
|
|
6988
|
+
maxPerHour?: number | undefined;
|
|
6989
|
+
maxCallMinutes?: number | undefined;
|
|
6990
|
+
ringSeconds?: number | undefined;
|
|
6991
|
+
ringSound?: string | undefined;
|
|
6992
|
+
} | undefined;
|
|
6928
6993
|
approvals?: {
|
|
6929
6994
|
digest?: {
|
|
6930
6995
|
enabled?: boolean | undefined;
|
|
@@ -7355,6 +7420,12 @@ declare class A2AMesh {
|
|
|
7355
7420
|
* channelMeta — i.e., the globex/umbrella confusion incident on
|
|
7356
7421
|
* 2026-04-29 issue #709. Shape matches AgentTask.context. */
|
|
7357
7422
|
context?: Record<string, unknown>;
|
|
7423
|
+
/** The message being forwarded, so the receiver can post its answer
|
|
7424
|
+
* back through this node after a restart cut the forward off (#311). */
|
|
7425
|
+
replyVia?: {
|
|
7426
|
+
messageId?: string;
|
|
7427
|
+
accountId?: string;
|
|
7428
|
+
};
|
|
7358
7429
|
}): Promise<string>;
|
|
7359
7430
|
/**
|
|
7360
7431
|
* Streaming variant of `sendTask`. POSTs to the peer's `/task` with
|
|
@@ -7433,6 +7504,8 @@ declare class A2AMesh {
|
|
|
7433
7504
|
healthy: boolean;
|
|
7434
7505
|
skills: AgentSkill[];
|
|
7435
7506
|
channels: string[];
|
|
7507
|
+
/** The node's own name, from its agent card. */
|
|
7508
|
+
node?: string;
|
|
7436
7509
|
lastCheck?: Date;
|
|
7437
7510
|
}>;
|
|
7438
7511
|
}
|
|
@@ -7775,6 +7848,7 @@ declare class AgentXDaemon {
|
|
|
7775
7848
|
private business?;
|
|
7776
7849
|
private httpServer?;
|
|
7777
7850
|
private attachSweep?;
|
|
7851
|
+
private callSweep?;
|
|
7778
7852
|
private webhooks;
|
|
7779
7853
|
private github?;
|
|
7780
7854
|
private webrtc?;
|
|
@@ -7785,6 +7859,8 @@ declare class AgentXDaemon {
|
|
|
7785
7859
|
private wfHealth?;
|
|
7786
7860
|
/** Shares the daemon's SQLite handle; absent when running without one. */
|
|
7787
7861
|
private _assistant?;
|
|
7862
|
+
/** Agents ringing the owner (src/calls); needs SQLite. */
|
|
7863
|
+
private calls?;
|
|
7788
7864
|
private assistantStore;
|
|
7789
7865
|
/** Workflow health for the monitor. Cached for a minute: the dashboard
|
|
7790
7866
|
* polls every 15s and dormancy does not change on that timescale. */
|
|
@@ -7928,6 +8004,10 @@ declare class AgentXDaemon {
|
|
|
7928
8004
|
* this `callId` to the stream.
|
|
7929
8005
|
*/
|
|
7930
8006
|
private handleWebRtcSSE;
|
|
8007
|
+
/** Calls from agents to the owner (#321). The notice path is notify's:
|
|
8008
|
+
* Focus holds a non-urgent one; the push goes through the router with
|
|
8009
|
+
* its title as the first line, as `agentx notify` sends it. */
|
|
8010
|
+
private createCallService;
|
|
7931
8011
|
/**
|
|
7932
8012
|
* Serve the minimal browser call page. Static HTML; no framework.
|
|
7933
8013
|
* The page does getUserMedia, RTCPeerConnection, and POSTs/listens signals.
|
|
@@ -8216,7 +8296,21 @@ interface DirectOrigin {
|
|
|
8216
8296
|
model?: string;
|
|
8217
8297
|
autonomy?: string;
|
|
8218
8298
|
}
|
|
8219
|
-
|
|
8299
|
+
interface MeshOrigin {
|
|
8300
|
+
kind: "mesh";
|
|
8301
|
+
/** Node that received the message and forwarded it; absent from older
|
|
8302
|
+
* senders, in which case any healthy peer hosting the channel is used. */
|
|
8303
|
+
node?: string;
|
|
8304
|
+
channel: string;
|
|
8305
|
+
chatId: string;
|
|
8306
|
+
/** Posts as this agent on the forwarding node, like a live reply. */
|
|
8307
|
+
agentId?: string;
|
|
8308
|
+
/** The incoming message id, so the answer threads like a live reply. */
|
|
8309
|
+
replyTo?: string;
|
|
8310
|
+
accountId?: string;
|
|
8311
|
+
context?: Record<string, unknown>;
|
|
8312
|
+
}
|
|
8313
|
+
type RunOrigin = RouterOrigin | MeshOrigin | DirectOrigin;
|
|
8220
8314
|
|
|
8221
8315
|
interface FriendlyError {
|
|
8222
8316
|
/** One-line, operator-facing message suitable for a dashboard card or chat reply. */
|
|
@@ -10031,14 +10125,6 @@ declare class GraphStore {
|
|
|
10031
10125
|
}): Classification | null;
|
|
10032
10126
|
/** Read the last N classifications, newest first. Cheap enough for the admin UI. */
|
|
10033
10127
|
readRecentClassifications(limit?: number): Classification[];
|
|
10034
|
-
/**
|
|
10035
|
-
* The path the most recent classification in a conversation was filed
|
|
10036
|
-
* under, or undefined. Used by tools running inside that conversation
|
|
10037
|
-
* (`agentx_wiki_query`) to bias retrieval toward articles on the same
|
|
10038
|
-
* branch. Bounded by age so a stale label from a day-old thread does not
|
|
10039
|
-
* steer an unrelated question.
|
|
10040
|
-
*/
|
|
10041
|
-
latestPathForChat(agentId: string, channel: string, chatId: string, maxAgeMs?: number): string[] | undefined;
|
|
10042
10128
|
/**
|
|
10043
10129
|
* Hash that represents "this kind of message" for snap-to-path caching.
|
|
10044
10130
|
*
|
|
@@ -10249,6 +10335,9 @@ interface RunningTask {
|
|
|
10249
10335
|
/** The step the run is in right now (classify, compact, agent, …). A run
|
|
10250
10336
|
* that hangs shows here where it stopped. */
|
|
10251
10337
|
step?: string;
|
|
10338
|
+
/** Intent-graph path this request was classified under, once known.
|
|
10339
|
+
* Classification runs alongside the turn, so it is absent until then. */
|
|
10340
|
+
intentPath?: string[];
|
|
10252
10341
|
}
|
|
10253
10342
|
type TaskOutputSubscriber = (chunk: string) => void;
|
|
10254
10343
|
/** Persisted record of a finished task, written to .agentx/task-history. */
|
|
@@ -10566,6 +10655,14 @@ declare class AgentRegistry {
|
|
|
10566
10655
|
} | null;
|
|
10567
10656
|
/** True while `agentId` has a turn running on this chat. */
|
|
10568
10657
|
isChatBusy(agentId: string, channel: string, chatId: string): boolean;
|
|
10658
|
+
/**
|
|
10659
|
+
* The intent path of the turn running right now for this conversation,
|
|
10660
|
+
* or undefined while it is not classified yet (or nothing is running).
|
|
10661
|
+
* Tools launched by that turn ask for it through GET /agents/:id/intent-path;
|
|
10662
|
+
* reading the classification log instead would hand them the previous
|
|
10663
|
+
* request's path, since this turn's classification may still be in flight.
|
|
10664
|
+
*/
|
|
10665
|
+
runningIntentPath(agentId: string, channel: string, chatId: string): string[] | undefined;
|
|
10569
10666
|
/**
|
|
10570
10667
|
* Operator stop. Aborts the in-flight run for `taskId` (kills the
|
|
10571
10668
|
* underlying claude subprocess via the AbortSignal threaded through
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as L}from"./chunk-C245D4BZ.js";import{
|
|
1
|
+
import{a as L}from"./chunk-C245D4BZ.js";import{d as St,e as kt,ea as Tt,f as vt,fa as Mt,g as xt,h as $t,i as Ct,j as Pt,k as bt}from"./chunk-3C2SQDIH.js";import"./chunk-JU67IZLC.js";import"./chunk-BYJ3A55Y.js";import"./chunk-NMFXY3QU.js";import"./chunk-4XBYHKYG.js";import"./chunk-LQRBGQIR.js";import"./chunk-ZVP6GB4G.js";import"./chunk-JBVABB26.js";import"./chunk-2D3RYIDU.js";import"./chunk-EKJG63EJ.js";import{S as yt,l as lt,m as ct,n as dt,o as mt,p as pt}from"./chunk-OTMDMGHE.js";import"./chunk-6LTD7XL5.js";import"./chunk-N6EWZGIX.js";import"./chunk-WP6KLXTP.js";import"./chunk-DP7RTNDM.js";import{A as D,B as z,C as V,a as ye,b as we,c as Se,d as Ae,e as Ie,f as Oe,g as Ne,h as He,i as je,j as Ue,k as _e,l as I,m as q,n as Be,o as qe,p as Ye,q as O,r as ze,s as Ve,t as Xe,u as x,v as Y,w as Qe,x as Ze,y as et,z as wt}from"./chunk-HXW4NAWF.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-SELIVR6U.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import{s as ut}from"./chunk-5Y7QRFSL.js";import"./chunk-WLX4766Y.js";import"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-K6CHA6JJ.js";import"./chunk-DWADWDMU.js";import"./chunk-23A5K5UW.js";import"./chunk-QD6IICK7.js";import"./chunk-VWTBHLMX.js";import"./chunk-RCKICCTT.js";import{a as ht}from"./chunk-EMRQ6W5J.js";import"./chunk-CECHWYJ2.js";import"./chunk-XJQNIFZ4.js";import{f as gt,g as ft}from"./chunk-AAA6NGY5.js";import"./chunk-WPNRDEHW.js";import"./chunk-2GIDVZ4H.js";import{j as it,k as rt,l as at}from"./chunk-DJMUP6TK.js";import"./chunk-FX3D7YON.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import{a as ke,b as ve,c as xe,d as $e,e as Ce,f as Pe,g as be,h as Te,i as Me,j as Re,l as Ee,m as Ge,o as T,p as W}from"./chunk-5MUJZODV.js";import{a as m,b as G}from"./chunk-7I7IEX4S.js";import{b as Fe,c as Le,d as A,e as De}from"./chunk-JHCI6XCJ.js";import{a as Ke,b as Je,e as We}from"./chunk-DSYKYZMT.js";import{A as nt,v as tt,x as st,y as ot}from"./chunk-AHOGFVHA.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";W();G();import{execa as Rt}from"execa";import{existsSync as se,promises as X}from"fs";import S from"path";import ie from"node-fetch";async function Et(o,e){let t=o.split("/");if(t.length<2)throw new Error(`Invalid skill package ID: ${o}. Expected format: owner/repo`);let s=t[0],i=t[1],n=t[2];try{let a=n?`${s}/${i}/${n}`:`${s}/${i}`;await Rt("npx",["-y","skills","add",a],{cwd:e,stdio:"pipe"}),m.success(`Installed skill package: ${o}`);let r=S.resolve(e,".skills",`${s}_${i}`);if(se(r))return await ne(r,o);let d=S.resolve(e,".skills");return se(d)?await ne(d,o):[]}catch{return m.info(`Fetching skills directly from GitHub: ${s}/${i}`),await Gt(s,i,n,e)}}async function Gt(o,e,t,s){let i=[];try{let n=`https://api.github.com/repos/${o}/${e}/git/trees/main?recursive=1`,a=await ie(n);if(!a.ok)throw new Error(`GitHub API error: ${a.status}`);let d=(await a.json()).tree.filter(p=>p.type==="blob"&&p.path.endsWith("SKILL.md"));if(t){let p=d.find(f=>f.path.includes(`/${t}/`)||f.path===`${t}/SKILL.md`);if(p){let f=await oe(o,e,p.path,s);f&&i.push(f)}}else for(let p of d){let f=await oe(o,e,p.path,s);f&&i.push(f)}}catch(n){m.error(`Failed to fetch skills from GitHub: ${n.message}`)}return i}async function oe(o,e,t,s){try{let i=`https://raw.githubusercontent.com/${o}/${e}/main/${t}`,n=await ie(i);if(!n.ok)return null;let a=await n.text(),r=A(a);if(r){r.source="remote",r.packageId=`${o}/${e}`;let d=S.dirname(t),p=S.resolve(s,".skills",`${o}_${e}`,d);await X.mkdir(p,{recursive:!0}),await X.writeFile(S.resolve(p,"SKILL.md"),a),r.path=S.resolve(p,"SKILL.md")}return r}catch{return null}}async function ne(o,e){let t=[],{default:s}=await import("fast-glob"),i=await s.glob("**/SKILL.md",{cwd:o,deep:5});for(let n of i)try{let a=S.resolve(o,n),r=await X.readFile(a,"utf8"),d=A(r);d&&(d.source="remote",d.path=a,d.packageId=e,t.push(d))}catch{}return t}async function At(o,e,t,s,i){let n=["---",`name: ${o}`,`description: ${e}`];if(s?.length){n.push("tags:");for(let a of s)n.push(` - ${a}`)}if(i?.length){n.push("globs:");for(let a of i)n.push(` - ${a}`)}return n.push("---"),`${n.join(`
|
|
2
2
|
`)}
|
|
3
3
|
|
|
4
4
|
${t}`}async function It(o){let{loadLocalSkills:e}=await import("./loader-YFVSSYSL.js");return e(o)}async function Ot(o,e,t,s,i){let a=[{role:"system",content:`You are a skill author for the Agent Skills ecosystem (skills.sh).
|