agentix-cli 0.31.0 → 0.32.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-6TP7YMQ3.js → App-2LAWZNMG.js} +2 -2
- package/dist/{ChatApp-G2MQUBR3.js → ChatApp-2KRDHMTV.js} +2 -2
- package/dist/{agent-A5G4DGVU.js → agent-ZRRIMLTX.js} +2 -2
- package/dist/{board-dashboard-BU6QJK6X.js → board-dashboard-LL3YVODL.js} +4 -4
- package/dist/{chunk-JC6ZHSTY.js → chunk-2DBGOCCW.js} +2 -2
- package/dist/chunk-2DMVKLLE.js +13 -0
- package/dist/chunk-2DMVKLLE.js.map +1 -0
- package/dist/chunk-2GIDVZ4H.js +3 -0
- package/dist/{chunk-EVWEG3VD.js.map → chunk-2GIDVZ4H.js.map} +1 -1
- package/dist/{chunk-2J3NV6RZ.js → chunk-4CR463C6.js} +2 -2
- package/dist/{chunk-7JWYLSFF.js → chunk-5FEQI22L.js} +2 -2
- package/dist/{chunk-COOJI5SR.js → chunk-6VQKHMEQ.js} +40 -40
- package/dist/chunk-6VQKHMEQ.js.map +1 -0
- package/dist/{chunk-R7WLFEW3.js → chunk-A4YR3PQY.js} +2 -2
- package/dist/{chunk-NZ346QCV.js → chunk-B2XTYYXV.js} +2 -2
- package/dist/{chunk-DLOYTMYZ.js → chunk-G5MFPNGJ.js} +2 -2
- package/dist/{chunk-JV52UMCI.js → chunk-GWQIMAJ7.js} +2 -2
- package/dist/{chunk-ZZQMR526.js → chunk-H57XXGMF.js} +96 -94
- package/dist/chunk-H57XXGMF.js.map +1 -0
- package/dist/{chunk-W6HKWISZ.js → chunk-JGJE5Y2J.js} +2 -2
- package/dist/{chunk-FFDXDUVQ.js → chunk-JWKIFAXA.js} +2 -2
- package/dist/{chunk-JJIYFBDH.js → chunk-K6E7WJ7O.js} +2 -2
- package/dist/{chunk-6DD4DA2L.js → chunk-MFVI5FOM.js} +2 -2
- package/dist/{chunk-UOGDSRG3.js → chunk-W3YGESNK.js} +2 -2
- package/dist/{chunk-7MNXKITO.js → chunk-WFIBOAXN.js} +3 -3
- package/dist/cli.js +1 -1
- package/dist/client-IP643GRO.js +2 -0
- package/dist/config-IVDP46ZG.js +2 -0
- package/dist/config-mutator-UCGAV3SP.js +2 -0
- package/dist/doctor-MMT4SREV.js +2 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +1 -1
- package/dist/program-7ULXLTD6.js +2 -0
- package/dist/query-RHVR6QUZ.js +2 -0
- package/dist/{registry-LUMYXZ6F.js → registry-OB6S66XX.js} +2 -2
- package/dist/{request-planner-RNQB4L6F.js → request-planner-F5NVL2G7.js} +2 -2
- package/dist/{review-candidates-ZX4JBWQL.js → review-candidates-IRPKFWL2.js} +2 -2
- package/dist/{rotation-memo-7T75BLEX.js → rotation-memo-QEO3COFH.js} +3 -3
- package/dist/rotation-memo-QEO3COFH.js.map +1 -0
- package/dist/{routing-5VGXQ4VG.js → routing-OSPRKRAY.js} +2 -2
- package/dist/scheduler-JL6K5HHI.js +2 -0
- package/dist/{seat-SXPFROXT.js → seat-2MHKVMW2.js} +2 -2
- package/dist/{select-GJ47QACY.js → select-7LCHJVPK.js} +2 -2
- package/dist/wiki-MY32MON3.js +2 -0
- package/package.json +2 -1
- package/dist/chunk-COOJI5SR.js.map +0 -1
- package/dist/chunk-EVWEG3VD.js +0 -3
- package/dist/chunk-Z3RKXKE2.js +0 -13
- package/dist/chunk-Z3RKXKE2.js.map +0 -1
- package/dist/chunk-ZZQMR526.js.map +0 -1
- package/dist/client-QALLJG62.js +0 -2
- package/dist/config-TNNODULV.js +0 -2
- package/dist/config-mutator-RI77M5YT.js +0 -2
- package/dist/doctor-DW27MR2T.js +0 -2
- package/dist/program-WZ3GEOXO.js +0 -2
- package/dist/query-7X6VO5VU.js +0 -2
- package/dist/rotation-memo-7T75BLEX.js.map +0 -1
- package/dist/scheduler-W5C43ZTE.js +0 -2
- package/dist/wiki-SRH3JKI4.js +0 -2
- /package/dist/{App-6TP7YMQ3.js.map → App-2LAWZNMG.js.map} +0 -0
- /package/dist/{ChatApp-G2MQUBR3.js.map → ChatApp-2KRDHMTV.js.map} +0 -0
- /package/dist/{agent-A5G4DGVU.js.map → agent-ZRRIMLTX.js.map} +0 -0
- /package/dist/{board-dashboard-BU6QJK6X.js.map → board-dashboard-LL3YVODL.js.map} +0 -0
- /package/dist/{chunk-JC6ZHSTY.js.map → chunk-2DBGOCCW.js.map} +0 -0
- /package/dist/{chunk-2J3NV6RZ.js.map → chunk-4CR463C6.js.map} +0 -0
- /package/dist/{chunk-7JWYLSFF.js.map → chunk-5FEQI22L.js.map} +0 -0
- /package/dist/{chunk-R7WLFEW3.js.map → chunk-A4YR3PQY.js.map} +0 -0
- /package/dist/{chunk-NZ346QCV.js.map → chunk-B2XTYYXV.js.map} +0 -0
- /package/dist/{chunk-DLOYTMYZ.js.map → chunk-G5MFPNGJ.js.map} +0 -0
- /package/dist/{chunk-JV52UMCI.js.map → chunk-GWQIMAJ7.js.map} +0 -0
- /package/dist/{chunk-W6HKWISZ.js.map → chunk-JGJE5Y2J.js.map} +0 -0
- /package/dist/{chunk-FFDXDUVQ.js.map → chunk-JWKIFAXA.js.map} +0 -0
- /package/dist/{chunk-JJIYFBDH.js.map → chunk-K6E7WJ7O.js.map} +0 -0
- /package/dist/{chunk-6DD4DA2L.js.map → chunk-MFVI5FOM.js.map} +0 -0
- /package/dist/{chunk-UOGDSRG3.js.map → chunk-W3YGESNK.js.map} +0 -0
- /package/dist/{chunk-7MNXKITO.js.map → chunk-WFIBOAXN.js.map} +0 -0
- /package/dist/{client-QALLJG62.js.map → client-IP643GRO.js.map} +0 -0
- /package/dist/{config-TNNODULV.js.map → config-IVDP46ZG.js.map} +0 -0
- /package/dist/{config-mutator-RI77M5YT.js.map → config-mutator-UCGAV3SP.js.map} +0 -0
- /package/dist/{doctor-DW27MR2T.js.map → doctor-MMT4SREV.js.map} +0 -0
- /package/dist/{program-WZ3GEOXO.js.map → program-7ULXLTD6.js.map} +0 -0
- /package/dist/{query-7X6VO5VU.js.map → query-RHVR6QUZ.js.map} +0 -0
- /package/dist/{registry-LUMYXZ6F.js.map → registry-OB6S66XX.js.map} +0 -0
- /package/dist/{request-planner-RNQB4L6F.js.map → request-planner-F5NVL2G7.js.map} +0 -0
- /package/dist/{review-candidates-ZX4JBWQL.js.map → review-candidates-IRPKFWL2.js.map} +0 -0
- /package/dist/{routing-5VGXQ4VG.js.map → routing-OSPRKRAY.js.map} +0 -0
- /package/dist/{scheduler-W5C43ZTE.js.map → scheduler-JL6K5HHI.js.map} +0 -0
- /package/dist/{seat-SXPFROXT.js.map → seat-2MHKVMW2.js.map} +0 -0
- /package/dist/{select-GJ47QACY.js.map → select-7LCHJVPK.js.map} +0 -0
- /package/dist/{wiki-SRH3JKI4.js.map → wiki-MY32MON3.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as R,b as j,c as O,d as W,e as D}from"./chunk-AJ5RMU7X.js";import{b as C}from"./chunk-
|
|
1
|
+
import{a as R,b as j,c as O,d as W,e as D}from"./chunk-AJ5RMU7X.js";import{b as C}from"./chunk-2GIDVZ4H.js";import{v,w as Q}from"./chunk-2DBGOCCW.js";import{b as $,c as M}from"./chunk-QOYAX2FT.js";import{readFileSync as T,existsSync as _}from"fs";Q();import{resolve as b}from"path";import{execSync as Y}from"child_process";async function V(n,i,s,e={}){let d=e.selectorModel??"haiku",a=e.synthModel??"sonnet",c=e.maxCandidates??3,l=e.maxHops??2,r=e.maxArticles??8,p=e.timeoutMs??6e4,u=e.log??console.error.bind(console,"[wiki-query]"),h=b(i.baseDir,"_index.md");if(!_(h))return w("no-catalog",n,"No _index.md found \u2014 run `agentx wiki status` to rebuild.");let k=T(h,"utf-8"),t=Date.now(),g=[],m="";try{let o=await B(n,i,s,c);o?(g=o,m=`[wiki-rerank seat] ${o.map(y=>y.title).join(" | ")}`):(m=await N(I(n,k,c),d,p),g=F(m))}catch(o){return u("selector failed:",o?.message),{...w("error",n,`Selector: ${o?.message||"unknown"}`),trace:{selectorMs:Date.now()-t,synthesisMs:0,selectorOutput:m}}}let A=Date.now()-t;if(g.length===0)return{...w("no-candidates",n,"Selector returned no candidates."),trace:{selectorMs:A,synthesisMs:0,selectorOutput:m}};let f=E(g,i,s,l,r);if(f.length===0)return{...w("no-candidates",n,"Candidates did not resolve to readable articles."),candidates:g,trace:{selectorMs:A,synthesisMs:0,selectorOutput:m}};let S=Date.now(),x="";try{x=await N(L(n,f),a,p*2)}catch(o){return u("synthesis failed:",o?.message),{...w("error",n,`Synthesis: ${o?.message||"unknown"}`),candidates:g,walked:f.map(y=>({title:y.meta.title,path:y.path,type:y.meta.type,hop:y.hop??0})),trace:{selectorMs:A,synthesisMs:Date.now()-S,selectorOutput:m}}}let P=Date.now()-S;return{answer:x.trim(),citations:f.map(o=>({title:o.meta.title,path:o.path,type:o.meta.type})),candidates:g,walked:f.map(o=>({title:o.meta.title,path:o.path,type:o.meta.type,hop:o.hop??0})),status:"ok",trace:{selectorMs:A,synthesisMs:P,selectorOutput:m}}}function w(n,i,s){return{answer:"",citations:[],candidates:[],walked:[],status:n,error:s}}function E(n,i,s,e,d){let a=new Map;for(let r of i.listArticles(s||""))a.set(r.meta.title.toLowerCase(),r.path);let c=new Map,l=[];for(let r of n)c.has(r.path)||l.push({path:r.path,hop:0});for(;l.length&&c.size<d;){let r=l.shift();if(c.has(r.path)||r.hop>e)continue;let p=s?i.readArticleAs(r.path,s):i.readArticle(r.path);if(p&&(c.set(r.path,{...p,hop:r.hop}),!(r.hop>=e)))for(let u of p.meta.related||[]){let h=a.get(u.toLowerCase());h&&!c.has(h)&&l.push({path:h,hop:r.hop+1})}}return Array.from(c.values())}async function B(n,i,s,e){try{let a=(i.rebuildIndex().articles??[]).filter(t=>t.path&&!t.path.includes("/_versions/"));if(a.length<2)return null;let c=a.map(t=>[t.title,(t.tags??[]).join(" "),(t.related??[]).join(" ")].join(" ")),l=M(n,$(c)).map(t=>t.docIndex);for(let t=0;t<a.length;t++)l.includes(t)||l.push(t);let p=l.slice(0,j).map(t=>({id:`k${t}`,title:a[t].title||a[t].path,tags:a[t].tags,excerpt:[a[t].type?`type: ${a[t].type}`:"",(a[t].related??[]).length?`related: ${(a[t].related??[]).join(", ")}`:""].filter(Boolean).join(" \xB7 ")})),u=await v(R,O({query:n,candidates:p,excerptChars:300}),W(p),{features:{agent:s??"unknown",stage:"catalog-selector"}});if(!u||u.mode!=="active")return null;let k=D(u.answers,p).ranked.slice(0,e).map(t=>a[Number(t.slice(1))]).filter(Boolean).map(t=>({title:t.title,path:t.path}));return k.length>0?k:null}catch{return null}}function I(n,i,s){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.
|
|
2
2
|
|
|
3
3
|
## Question
|
|
4
4
|
|
|
@@ -42,4 +42,4 @@ ${s}
|
|
|
42
42
|
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.
|
|
43
43
|
|
|
44
44
|
Output ONLY the answer \u2014 no preamble, no "here is my answer:", no markdown fencing.`}function F(n){let i=n.match(/\[[\s\S]*?\]/);if(!i)return[];try{let s=JSON.parse(i[0]);return Array.isArray(s)?s.filter(e=>e&&typeof e.title=="string"&&typeof e.path=="string").map(e=>({title:e.title,path:e.path})):[]}catch{return[]}}async function N(n,i,s){let{writeFileSync:e,mkdirSync:d,rmSync:a}=await import("fs"),{tmpdir:c}=await import("os"),l=b(c(),`agentx-wiki-query-${process.pid}`);d(l,{recursive:!0});let r=b(l,`prompt-${Date.now()}.txt`);e(r,n);try{let p=`cat '${r}' | claude -p - --output-format json --max-turns 1 --model ${i} --disallowedTools "Bash Read Write Edit Glob Grep Agent WebSearch WebFetch NotebookEdit"`,u=Y(p,{env:C({...process.env}),encoding:"utf-8",timeout:s,maxBuffer:4*1024*1024});try{let h=JSON.parse(u);return String(h.result||h.content||"")}catch{return u}}finally{try{a(r,{force:!0})}catch{}}}export{V as a};
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-JGJE5Y2J.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{e as m,f as $,j as S}from"./chunk-
|
|
1
|
+
import{e as m,f as $,j as S}from"./chunk-2DMVKLLE.js";S();import{readFileSync as x,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=x(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{J as a,N as b,j as c,A as d};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-JWKIFAXA.js.map
|
|
@@ -48,7 +48,7 @@ The "modified" field is optional and can contain updated values to pass forward.
|
|
|
48
48
|
... (output truncated)`:i;return s.exitCode!==0?{tool_use_id:e.id,content:`Command exited with code ${s.exitCode}:
|
|
49
49
|
${c}`,is_error:!0}:{tool_use_id:e.id,content:c||"(no output)"}}async editFile(e){let t=String(e.input.path||""),o=e.input.edits,n=ge.resolve(this.cwd,t);if(!o||o.length===0)return{tool_use_id:e.id,content:"No edits provided.",is_error:!0};let s=await W.checkFileWrite(t);if(s==="deny")return{tool_use_id:e.id,content:`File write blocked by permissions: ${t}`,is_error:!0};if(s==="skip")return{tool_use_id:e.id,content:`File write skipped (plan mode): ${t}`};if(f.has("pre:file-write")){let a=await f.execute("pre:file-write",{event:"pre:file-write",file:n,cwd:this.cwd});if(a.blocked)return{tool_use_id:e.id,content:a.message||`File edit blocked by pre:file-write hook: ${t}`,is_error:!0}}let i=await re.readFile(n,"utf8"),c=[];for(let a of o)i.includes(a.old_text)?(i=i.replace(a.old_text,a.new_text),c.push(`Replaced: "${a.old_text.slice(0,40)}..."`)):c.push(`Not found: "${a.old_text.slice(0,40)}..."`);return this.options.dryRun||await re.writeFile(n,i,"utf8"),f.has("post:file-write")&&await f.execute("post:file-write",{event:"post:file-write",file:n,fileContent:i,cwd:this.cwd}),{tool_use_id:e.id,content:`Edited ${t}:
|
|
50
50
|
${c.join(`
|
|
51
|
-
`)}`}}async createFiles(e){let t=e.input,o=t.files||[];return{tool_use_id:e.id,content:t.summary||`Queued ${o.length} file(s) for creation.`,files:o}}async spawnAgent(e){let t=String(e.input.agent_id||""),o=String(e.input.prompt||""),n=Number(e.input.timeout_seconds)||300;if(!t||!o)return{tool_use_id:e.id,content:"agent_id and prompt are required.",is_error:!0};try{let{SubAgentManager:s}=await import("./subagent-2SJHSSJS.js"),{getGlobalRegistry:i}=await import("./registry-
|
|
51
|
+
`)}`}}async createFiles(e){let t=e.input,o=t.files||[];return{tool_use_id:e.id,content:t.summary||`Queued ${o.length} file(s) for creation.`,files:o}}async spawnAgent(e){let t=String(e.input.agent_id||""),o=String(e.input.prompt||""),n=Number(e.input.timeout_seconds)||300;if(!t||!o)return{tool_use_id:e.id,content:"agent_id and prompt are required.",is_error:!0};try{let{SubAgentManager:s}=await import("./subagent-2SJHSSJS.js"),{getGlobalRegistry:i}=await import("./registry-OB6S66XX.js"),c=i();if(!c)return{tool_use_id:e.id,content:"Sub-agent spawning requires the daemon to be running.",is_error:!0};let p=await new s(c).spawn({targetAgentId:t,prompt:o,parentAgentId:"orchestrator",timeout:n*1e3});return p.success?{tool_use_id:e.id,content:`Sub-agent "${t}" completed (${Math.round(p.duration/1e3)}s):
|
|
52
52
|
|
|
53
53
|
${p.content}`}:{tool_use_id:e.id,content:`Sub-agent "${t}" failed: ${p.error}`,is_error:!0}}catch(s){return{tool_use_id:e.id,content:`Failed to spawn sub-agent: ${s.message}`,is_error:!0}}}async askUser(e){let t=String(e.input.question||""),o=e.input.options,n=t;return o?.length&&(n+=`
|
|
54
54
|
Options: ${o.join(", ")}`),{tool_use_id:e.id,content:"Question sent to user.",followUp:n}}};async function Ae(r){let{provider:e,systemPrompt:t,messages:o,providerOptions:n,cwd:s,maxIterations:i=20,enabledTools:c,interactive:a=!0,overwrite:p=!1,dryRun:l=!1,onProgress:d,abortSignal:u}=r,m=u?{...n,abortSignal:u}:n;if(!e.generateRaw)return dt(r);let I=new se(s,{interactive:a,overwrite:p,dryRun:l,acmeContext:r.acmeContext,abortSignal:u}),D=be(c);if(r.acmeContext)for(let g of at)D.push({name:g.name,description:g.description,input_schema:g.input_schema});let E=new Set;if(r.mcpTools?.length)for(let g of r.mcpTools)D.push({name:g.name,description:g.description,input_schema:g.input_schema}),E.add(g.name);let C=o.filter(g=>g.role!=="system").map(g=>({role:g.role,content:g.content})),B=[],G=0,F=0,A=0,O="",j,_=0;for(;_<i;){if(_++,u?.aborted)throw new Error("cancelled");d?.({type:"iteration_start",iteration:_}),b.step(_,`Agentic loop iteration (${D.length} tools available)`);let g,M=!!e.generateRawStream&&!!d;try{if(M){let T=null,U=null,v="";for await(let x of e.generateRawStream(C,t,D,m))x.type==="text_delta"?(v+=x.text,d?.({type:"text_delta",text:x.text})):x.type==="thinking_delta"?d?.({type:"thinking_delta",text:x.text}):x.type==="raw_result"?T=x.result:x.type==="error"&&(U=x.error);if(U&&!T)throw new Error(U);if(!T)throw new Error("generateRawStream returned no raw_result event");g=T,g._streamedText=v}else g=await e.generateRaw(C,t,D,m)}catch(T){if(T.message?.includes("not available"))return dt(r);throw T}G+=g.usage.input_tokens+g.usage.output_tokens,F+=g.usage.input_tokens,A+=g.usage.output_tokens;let P=g._streamedText;for(let T of g.content)T.type==="text"&&(O+=T.text,P===void 0&&d?.({type:"text_delta",text:T.text}));if(P!==void 0&&delete g._streamedText,g.stop_reason==="end_turn"||g.stop_reason==="max_tokens")break;if(g.stop_reason==="tool_use"){let T=g.content.filter(v=>v.type==="tool_use");if(T.length===0)break;C.push({role:"assistant",content:g.content});let U=[];for(let v of T){d?.({type:"tool_call",name:v.name,id:v.id,input:v.input}),b.step(_,`Tool call: ${v.name}`);let x;if(E.has(v.name)&&r.mcpDispatch){let h=await r.mcpDispatch(v.name,v.input);x={tool_use_id:v.id,content:h.content,is_error:h.isError}}else x=await I.execute({name:v.name,id:v.id,input:v.input});d?.({type:"tool_result",name:v.name,id:v.id,content:x.content.slice(0,200),is_error:x.is_error}),x.files?.length&&(B.push(...x.files),d?.({type:"files_created",files:x.files})),x.followUp&&(j=x.followUp),U.push({type:"tool_result",tool_use_id:x.tool_use_id,content:x.content,is_error:x.is_error})}if(C.push({role:"user",content:U}),j)break;continue}break}return d?.({type:"complete",iterations:_,totalTokens:G}),{files:B,content:O,followUp:j,tokensUsed:G,inputTokens:F||void 0,outputTokens:A||void 0,iterations:_}}async function dt(r){let{provider:e,systemPrompt:t,messages:o,providerOptions:n,maxIterations:s=5}=r,c=[{role:"system",content:t+`
|
|
@@ -123,4 +123,4 @@ ${r.projectInstructions}`),r.memoryContext&&o.push(r.memoryContext),o.push(`# Ou
|
|
|
123
123
|
Generate output appropriate for: ${e}. Use the \`create_files\` tool to output all files.`),o.join(`
|
|
124
124
|
|
|
125
125
|
`)}export{qe as a,Vt as b,Yt as c,We as d,ze as e,Ve as f,Ye as g,Pe as h,ee as i,Re as j,le as k,te as l,Tt as m,oe as n,Mt as o,f as p,et as q,tt as r,Me as s,de as t,W as u,ne as v,it as w,Ee as x,$e as y,se as z,mt as A,Zn as B,er as C};
|
|
126
|
-
//# sourceMappingURL=chunk-
|
|
126
|
+
//# sourceMappingURL=chunk-K6E7WJ7O.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as T,b as P,c as _,d as G}from"./chunk-PNWNVOEZ.js";import{b as ee}from"./chunk-64P4QHSZ.js";import{a as te,b as se,c as re,d as ie,e as ne}from"./chunk-AJ5RMU7X.js";import{v as Z,w as he}from"./chunk-
|
|
1
|
+
import{a as T,b as P,c as _,d as G}from"./chunk-PNWNVOEZ.js";import{b as ee}from"./chunk-64P4QHSZ.js";import{a as te,b as se,c as re,d as ie,e as ne}from"./chunk-AJ5RMU7X.js";import{v as Z,w as he}from"./chunk-2DBGOCCW.js";import{a as Q,b as pe}from"./chunk-AJONZWLT.js";import{c as M,d as L}from"./chunk-QOYAX2FT.js";import{o as X,p as de}from"./chunk-LCIREYTD.js";var A={version:2,levels:[{id:"category",description:"Top-level kind of work. Closed set \u2014 pick the closest fit.",axes:[{name:"kind",type:"enum",values:["code","ops","support","admin","knowledge","social","system"],description:"Which category this work belongs in."}]},{id:"verb",description:"Specific intent \u2014 verb-level only, NOT client/project-bound.",axes:[{name:"name",type:"free",description:"Lower-kebab dot-namespaced verb. Examples: review.merge-request, fix.bug, investigate.error, deploy.staging, deploy.production, rollback.release, spec.feature, triage.issue, document.feature, chat.greeting, chat.support-request, schedule.add, config.change, ingest.contact, transcribe.audio, brief.daily, summarize.thread, plan.work."}]}],leafInput:{name:"input",type:"enum",values:["telegram","whatsapp","slack","discord","gitlab-mr","gitlab-issue","github-issue","github-pr","cron","webhook","mesh","http"],description:"Where the message entered the system."},leafOutput:{name:"output",type:"free",description:"One short sentence describing what the agent is expected to produce. Generic \u2014 refers to the verb's outcome, not the specific client/project (those are on the event metadata already)."}},F=[{category:"code",verb:"review.merge-request",description:"Review a GitLab MR or GitHub PR"},{category:"code",verb:"review.code-change",description:"General code review (snippet, diff)"},{category:"code",verb:"fix.bug",description:"Fix a reported bug"},{category:"code",verb:"implement.feature",description:"Build a new feature"},{category:"code",verb:"investigate.error",description:"Investigate a failing test, exception, pipeline"},{category:"code",verb:"refactor.code",description:"Restructure existing code without behaviour change"},{category:"code",verb:"spec.feature",description:"Write or update a feature spec / RFC"},{category:"code",verb:"triage.issue",description:"Classify, label, or assign an issue"},{category:"code",verb:"answer.code-question",description:"Answer a code-related question"},{category:"ops",verb:"deploy.staging",description:"Deploy to a staging/preview environment"},{category:"ops",verb:"deploy.production",description:"Deploy to production"},{category:"ops",verb:"rollback.release",description:"Roll back a release"},{category:"ops",verb:"investigate.incident",description:"Investigate a production incident"},{category:"ops",verb:"monitor.system",description:"Check system status / metrics"},{category:"ops",verb:"rotate.credential",description:"Rotate a token, key, certificate"},{category:"ops",verb:"audit.security",description:"Review for security issues"},{category:"support",verb:"chat.greeting",description:"A casual hello, no actionable request"},{category:"support",verb:"chat.support-request",description:"End-user / customer asking for help"},{category:"support",verb:"chat.casual",description:"Informal back-and-forth chat"},{category:"support",verb:"answer.question",description:"Answer an open-ended question"},{category:"support",verb:"route.request",description:"Forward a request to the right agent"},{category:"admin",verb:"config.change",description:"Change agentx.json / environment / config"},{category:"admin",verb:"schedule.add",description:"Add a new cron / scheduled task"},{category:"admin",verb:"schedule.remove",description:"Remove or disable a schedule"},{category:"admin",verb:"token.create",description:"Mint a scoped API token"},{category:"admin",verb:"agent.add",description:"Configure a new agent"},{category:"admin",verb:"channel.add",description:"Wire up a new channel"},{category:"knowledge",verb:"document.feature",description:"Write or update documentation"},{category:"knowledge",verb:"summarize.thread",description:"Summarize a long conversation/thread"},{category:"knowledge",verb:"research.topic",description:"Investigate / gather info on a topic"},{category:"knowledge",verb:"wiki.absorb",description:"Roll raw entries into typed wiki articles"},{category:"social",verb:"brief.daily",description:"Compose a daily brief / digest"},{category:"social",verb:"draft.post",description:"Draft a marketing post / announcement"},{category:"social",verb:"report.weekly",description:"Compose a weekly status report"},{category:"system",verb:"classify.intent",description:"Internal: graph-classifier sub-call"}];import{readFileSync as D,writeFileSync as J,appendFileSync as ge,existsSync as I,mkdirSync as U,renameSync as ue}from"fs";import{resolve as R,dirname as ae}from"path";import{createHash as fe}from"crypto";var H=class{baseDir;log;constructor(e={}){this.baseDir=e.baseDir??R(process.cwd(),".agentx/graph"),this.log=e.log??console.error.bind(console,"[graph]"),U(this.baseDir,{recursive:!0})}schemaPath(){return R(this.baseDir,"schema.json")}nodesPath(){return R(this.baseDir,"nodes.json")}indexPath(){return R(this.baseDir,"index.json")}classificationsPath(){return R(this.baseDir,"classifications.jsonl")}loadSchema(){let e=this.schemaPath();if(!I(e))return this.saveSchema(A),this.log("seeded starter schema at",e),A;let t=D(e,"utf-8"),s=T.safeParse(JSON.parse(t));if(!s.success)throw new Error(`Invalid ${e}: ${s.error.issues.map(r=>r.message).join("; ")}`);if((s.data.version??1)<(A.version??2)){let r=e.replace(/\.json$/,`.v${s.data.version??1}.bak.json`);try{J(r,t),this.log(`migrated graph schema v${s.data.version??1} -> v${A.version}; old saved at ${r}`)}catch(n){this.log(`could not back up old schema: ${n?.message??n}`)}this.saveSchema(A);let o=this.nodesPath();if(I(o)){let n=o.replace(/\.json$/,".v1.bak.json");try{J(n,D(o,"utf-8")),this.log(`archived v1 nodes.json -> ${n}`)}catch(i){this.log(`could not back up old nodes: ${i?.message??i}`)}try{let i=oe();this.saveNodes(i)}catch(i){this.log(`could not seed v2 nodes: ${i?.message??i}`)}}return A}return s.data}saveSchema(e){let t=T.safeParse(e);if(!t.success)throw new Error(`Refusing to save invalid schema: ${t.error.issues.map(s=>s.message).join("; ")}`);B(this.schemaPath(),t.data)}loadNodes(){let e=this.nodesPath();if(!I(e)){let r=oe();return this.saveNodes(r),r}let t=D(e,"utf-8"),s=_.safeParse(JSON.parse(t));if(!s.success)throw new Error(`Invalid ${e}: ${s.error.issues.map(r=>r.message).join("; ")}`);return s.data}saveNodes(e){let t=_.safeParse(e);if(!t.success)throw new Error(`Refusing to save invalid nodes file: ${t.error.issues.map(s=>s.message).join("; ")}`);B(this.nodesPath(),t.data)}validateNode(e,t,s){let r=t.levels.find(i=>i.id===e.level);if(!r)throw new Error(`Unknown level: "${e.level}"`);let o=r.axes.filter(i=>!i.optional).filter(i=>!(i.name in e.axes));if(o.length)throw new Error(`Node ${e.id} (${e.level}) missing required axes: ${o.map(i=>i.name).join(", ")}`);for(let i of r.axes){let a=e.axes[i.name];if(a!=null){if(i.type==="enum"&&i.values&&!i.values.includes(a))throw new Error(`Node ${e.id}: axis ${i.name}="${a}" not in enum ${JSON.stringify(i.values)}`);if(i.type==="ref"){if(!s.some(c=>c.id===a))throw new Error(`Node ${e.id}: axis ${i.name}="${a}" refers to unknown node`);if(i.refLevel){let c=s.find(l=>l.id===a);if(c.level!==i.refLevel)throw new Error(`Node ${e.id}: axis ${i.name} expected level "${i.refLevel}" but got "${c.level}"`)}}}}let n=t.levels.findIndex(i=>i.id===e.level);if(n===0){if(e.parentId!==null)throw new Error(`Root-level node ${e.id} must have parentId: null`)}else{if(!e.parentId)throw new Error(`Non-root node ${e.id} must have a parentId`);let i=s.find(c=>c.id===e.parentId);if(!i)throw new Error(`Node ${e.id}: parent "${e.parentId}" not found`);let a=t.levels.findIndex(c=>c.id===i.level);if(a<0||a>=n)throw new Error(`Node ${e.id} at level "${e.level}" has parent at level "${i.level}" \u2014 parent must be at a higher level`)}}commitNodesAlongPath(e,t,s,r){let o=[],n=[],i=new Date().toISOString();for(let a=0;a<e.length;a++){let c=e[a],l=this.loadNodes().nodes;if(l.find(m=>m.id===c)){n.push(c);continue}let p=0;for(let m=a-1;m>=0;m--){let w=e[m],N=l.find(k=>k.id===w)||o.find(k=>k.id===w);if(N){p=s.levels.findIndex(k=>k.id===N.level)+1;break}}let g=t[c]??{},d=null;for(let m=p;m<s.levels.length;m++){let w=s.levels[m];if(w.axes.filter(k=>!k.optional).filter(k=>!(k.name in g)).length===0){d=w.id,p=m+1;break}}if(!d&&p<s.levels.length&&(d=s.levels[p].id,p++),!d)throw new Error(`Can't place node ${c} \u2014 no schema level left (cursor=${p}, levels=${s.levels.length})`);let h=null,f=s.levels.findIndex(m=>m.id===d);for(let m=a-1;m>=0;m--){let w=e[m],N=l.find(C=>C.id===w)||o.find(C=>C.id===w);if(!N)continue;let k=s.levels.findIndex(C=>C.id===N.level);if(k>=0&&k<f){h=w;break}}let u={id:c,level:d,parentId:h,axes:g,createdAt:i,createdBy:r};this.addNode(u),o.push(u)}return{added:o,skipped:n}}addNode(e){let t=this.loadSchema(),s=this.loadNodes();if(s.nodes.some(r=>r.id===e.id))throw new Error(`Node id already exists: ${e.id}`);return this.validateNode(e,t,[...s.nodes,e]),s.nodes.push(e),this.saveNodes(s),e}appendClassification(e){let t=P.safeParse(e);if(!t.success){let o=t.error.issues.map(n=>`${n.path.join(".")}: ${n.message}`).join(" \xB7 ");return this.log(`skipped invalid classification \u2014 ${o} \xB7`,`path=${JSON.stringify(e.path)}`,`axes-keys=${JSON.stringify(Object.keys(e.proposedAxes||{}))}`),!1}let s=JSON.stringify(t.data)+`
|
|
2
2
|
`,r=this.classificationsPath();return I(r)||U(ae(r),{recursive:!0}),ge(r,s),!0}listPendingClassifications(e=200){return this.listByStatus("pending",e)}listAllClassifications(){return this.readAllCollapsed()}listByStatus(e,t=200){return this.readAllCollapsed().filter(r=>r.status===e).slice(0,t)}readAllCollapsed(){let e=this.classificationsPath();if(!I(e))return[];let s=D(e,"utf-8").split(`
|
|
3
3
|
`).filter(Boolean),r=new Map;for(let o of s)try{let n=P.safeParse(JSON.parse(o));if(!n.success)continue;r.set(n.data.msgHash,n.data)}catch{}return Array.from(r.values()).sort((o,n)=>o.ts<n.ts?1:-1)}updateClassificationStatus(e,t){let r=this.readAllCollapsed().find(n=>n.msgHash===e);if(!r)return null;let o={...r,status:t.status,ts:new Date().toISOString()};if(t.reviewer||t.reviewReason){let n=` \xB7 ${t.reviewer?`reviewer=${t.reviewer}`:""}${t.reviewReason?` \xB7 ${t.reviewReason}`:""}`;o.preview=((r.preview||"")+n).slice(0,500)}return this.appendClassification(o),o}readRecentClassifications(e=50){let t=this.classificationsPath();if(!I(t))return[];let r=D(t,"utf-8").split(`
|
|
4
4
|
`).filter(Boolean),o=[];for(let n=r.length-1;n>=0&&o.length<e;n--)try{let i=P.safeParse(JSON.parse(r[n]));i.success&&o.push(i.data)}catch{}return o}fingerprint(e){let s=[e.text.toLowerCase().replace(/\s+/g," ").trim(),e.channel??"",e.sender??""].join("");return fe("sha256").update(s).digest("hex").slice(0,32)}loadIndex(){let e=this.indexPath();if(!I(e))return{version:1,entries:{}};let t=D(e,"utf-8"),s=G.safeParse(JSON.parse(t));if(!s.success)throw new Error(`Invalid ${e}: ${s.error.issues.map(r=>r.message).join("; ")}`);return s.data}saveIndex(e){let t=G.safeParse(e);if(!t.success)throw new Error(`Refusing to save invalid index: ${t.error.issues.map(s=>s.message).join("; ")}`);B(this.indexPath(),t.data)}getFingerprint(e){return this.loadIndex().entries[e]}setFingerprint(e,t){let s=this.loadIndex();s.entries[e]={...t,fingerprint:e,updatedAt:new Date().toISOString()},this.saveIndex(s)}updateNodeAxes(e,t){let s=this.loadSchema(),r=this.loadNodes(),o=r.nodes.find(i=>i.id===e);if(!o)throw new Error(`Node not found: ${e}`);let n={...o,axes:t};return this.validateNode(n,s,r.nodes.map(i=>i.id===e?n:i)),r.nodes=r.nodes.map(i=>i.id===e?n:i),this.saveNodes(r),n}deleteNode(e){let t=this.loadNodes(),s=t.nodes.find(o=>o.parentId===e);if(s)throw new Error(`Cannot delete "${e}" \u2014 child node "${s.id}" still points to it`);let r=t.nodes.find(o=>Object.values(o.axes).some(n=>n===e));if(r)throw new Error(`Cannot delete "${e}" \u2014 node "${r.id}" references it via an axis`);t.nodes=t.nodes.filter(o=>o.id!==e),this.saveNodes(t)}approveClassification(e){if(this.getFingerprint(e.msgHash))return;let t=this.loadSchema(),s=new Set(this.loadNodes().nodes.map(r=>r.id));for(let r=0;r<e.path.length;r++){let o=e.path[r];if(s.has(o))continue;let n=t.levels[r]?.id;if(!n)break;let i=e.proposedAxes?.[o]??{},a=r===0?null:e.path[r-1];this.addNode({id:o,level:n,parentId:a,axes:i,createdAt:new Date().toISOString(),createdBy:e.agentId}),s.add(o)}this.setFingerprint(e.msgHash,{path:e.path,leaf:e.leaf}),this.appendClassification({...e,status:"approved",ts:new Date().toISOString()})}rejectClassification(e){this.appendClassification({...e,status:"rejected",ts:new Date().toISOString()})}};function B(b,e){U(ae(b),{recursive:!0});let t=`${b}.tmp-${process.pid}`;J(t,JSON.stringify(e,null,2)),ue(t,b)}function oe(){let b=new Date().toISOString(),e=[],t=new Set;for(let s of F)t.has(s.category)||(e.push({id:s.category,level:"category",parentId:null,axes:{kind:s.category},createdAt:b,createdBy:"starter"}),t.add(s.category));for(let s of F)e.push({id:s.verb,level:"verb",parentId:s.category,axes:{name:s.verb,...s.description?{description:s.description}:{}},createdAt:b,createdBy:"starter"});return{version:1,nodes:e}}pe();de();import{createHash as me}from"crypto";var q=class{store;daemonUrl;token;draftAgent;autoApprove;autoApproveStructure;classifierModel;classifierProviderName;providerInstance;log;constructor(e){this.store=e.store,this.daemonUrl=e.daemonUrl.replace(/\/+$/,""),this.token=e.token,this.draftAgent=e.draftAgent,this.autoApprove=e.autoApproveConfidence??1,this.autoApproveStructure=e.autoApproveStructure??"extend-leaves",this.classifierModel=e.classifierModel??"claude-haiku-4-5-20251001",this.classifierProviderName=e.classifierProvider??"claude-code",this.log=e.log??console.error.bind(console,"[classifier]")}getProvider(){return this.providerInstance||(this.providerInstance=X(this.classifierProviderName)),this.providerInstance}async classify(e){let t=this.store.fingerprint({text:e.text,channel:e.channel,sender:e.sender}),s=this.store.getFingerprint(t);if(s)return this.store.appendClassification({ts:new Date().toISOString(),msgHash:t,agentId:e.agentId,channel:e.channel,sender:e.sender,path:s.path,proposedAxes:{},leaf:s.leaf,source:"cache",status:"approved",preview:e.text.slice(0,200)}),{path:s.path,pathId:z(s.path),pathLabel:K(s.path,this.store.loadNodes().nodes),axes:{},leaf:s.leaf,source:"cache",status:"approved"};let r=this.store.loadSchema(),o=this.store.loadNodes().nodes,n=await this.proposePath(e,r,o).catch(u=>(this.log("LLM proposal failed:",u?.message||u),null));if(!n)return null;let{path:i,proposedAxes:a,confidence:c,leaf:l}=n;if(i.length===0)return null;let v={ts:new Date().toISOString(),msgHash:t,agentId:e.agentId,channel:e.channel,sender:e.sender,path:i,proposedAxes:a,leaf:l,source:"llm",status:"pending",confidence:c,preview:e.text.slice(0,200)},p=new Set(o.map(u=>u.id)),g=i.map((u,m)=>p.has(u)?-1:m).filter(u=>u>=0),d=!1;if(this.autoApproveStructure==="any")d=!0;else if(this.autoApproveStructure==="extend-leaves"){let u=g.length===0,m=g.length===1&&g[0]===i.length-1;d=u||m}let h=c!==void 0&&c>=this.autoApprove,f="pending";if(d||h)try{this.commitNewNodes(i,a,r,o,e.sender),this.store.setFingerprint(t,{path:i,leaf:l}),f="approved"}catch(u){this.log("auto-approve failed \u2014 staying pending \xB7",`path=${JSON.stringify(i)}`,`reason=${(u?.message||u).toString().slice(0,200)}`)}return v.status=f,this.store.appendClassification(v),{path:i,pathId:z(i),pathLabel:K(i,this.store.loadNodes().nodes),axes:a,leaf:l,source:"llm",status:f,confidence:c}}async proposePath(e,t,s){let r=s.map(d=>({id:d.id,level:d.level,parentId:d.parentId,axes:d.axes})),o=["You are the intent classifier for AgentX. You answer ONE question:",'"what kind of work does this message describe?" \u2014 verb-level only.',"","IMPORTANT \u2014 what NOT to encode in the path:","- Client / company / project / team names. Those are already on the event"," metadata (project, channel, agentId). Embedding them in the path causes"," duplicate nodes (one per client) for the same verb.","- The specific subject (issue number, file name, person name). Same reason.","- The agent's name or role. Pick the verb the *requester* intended.","","SCHEMA (fixed levels \u2014 pick one node per level):","```json",JSON.stringify(t,null,2),"```","","EXISTING NODES (prefer reusing these; only invent a new node when no","existing one fits):","```json",JSON.stringify(r,null,2),"```","","MESSAGE:","```",e.text.slice(0,2e3),"```",`channel: ${e.channel??"?"}`,`sender: ${e.sender??"?"}`,"","TASK:","1. Classify into 'category' (closed enum): code, ops, support, admin,"," knowledge, social, system. Pick the closest fit.","2. Pick or propose a 'verb' node. Verb ids are dot-namespaced lower-kebab,",' e.g. "review.merge-request", "deploy.staging", "investigate.error",',' "chat.greeting", "fix.bug". Reuse an existing verb when the message is'," the same kind of work as something already classified, even when the"," client / project / subject differs.","","Examples (right vs wrong):",'- "Please review MR #957 on globex/system" \u2192 ["code", "review.merge-request"]',' NOT ["business", "acme", "globex-v2", "review-mr-957-system"]','- "Deploy initech-v2 to staging please" \u2192 ["ops", "deploy.staging"]',' NOT ["business", "acme", "initech-v2", "deploy-initech-v2-to-staging"]','- "Hello Atlas" \u2192 ["support", "chat.greeting"]',"","NODE ID RULES (strict \u2014 invalid ids get dropped):","- lowercase-kebab + dots only: [a-z0-9][a-z0-9._-]*","- no spaces, no uppercase, no Arabic/other non-Latin",'- verb ids should use a "category.specific" or "verb.modifier" shape',"","Return ONE JSON object on one line, no prose, no fences:",' { "path": string[], "proposedAxes": { [nodeId]: { [axisName]: string } }, "leaf": { "input"?: string, "output"?: string }, "confidence": number }',"confidence in [0,1]. Prefer low confidence over guessing."].join(`
|
|
@@ -106,4 +106,4 @@ We use GitLab for version control.
|
|
|
106
106
|
There are ${t.length} unprocessed entries. Read each, understand what it means, and create or update wiki articles.
|
|
107
107
|
|
|
108
108
|
${s}`}walkDir(e,t){if(x(e))for(let s of O(e)){let r=be(e,s);ye(r).isDirectory()?this.walkDir(r,t):t(r)}}};import{resolve as Y}from"path";import{existsSync as ke,readdirSync as Se,mkdirSync as xe}from"fs";var le=class{baseDir;agentsDir;mode;sharedStore;agentStores=new Map;log;constructor(e=Y(process.cwd(),".agentx/wiki"),t=console.error.bind(console,"[wiki-hub]"),s="graph"){this.baseDir=e,this.agentsDir=Y(e,"agents"),this.mode=s,this.log=t,xe(this.agentsDir,{recursive:!0}),this.sharedStore=new E(e,t)}getMode(){return this.mode}getAgentWiki(e){let t=`${e}:${this.mode}`;if(this.agentStores.has(t))return this.agentStores.get(t);let s=Y(this.agentsDir,e,this.mode),r=new E(s,this.log);return this.agentStores.set(t,r),r}getSharedStore(){return this.sharedStore}listAgents(){let e=new Set,t=this.sharedStore.listEntries();for(let s of t)e.add(s.agentId);if(ke(this.agentsDir))for(let s of Se(this.agentsDir))!s.startsWith("_")&&!s.startsWith(".")&&e.add(s);return[...e].sort()}getAgentEntries(e){return this.sharedStore.listEntries({agentId:e})}getUnabsorbedEntries(e){let t=this.getAgentWiki(e),s=this.getAgentEntries(e),r=new Set,o=t.rebuildIndex();for(let n of o.articles)if(n.sources)for(let i of n.sources)r.add(i);return s.filter(n=>!r.has(n.id))}summary(){return this.listAgents().map(t=>{let s=this.getAgentEntries(t),o=this.getAgentWiki(t).rebuildIndex(),n=this.getUnabsorbedEntries(t);return{agentId:t,totalEntries:s.length,totalArticles:o.articles.length,unabsorbed:n.length,articles:o.articles}})}};export{A as a,H as b,q as c,K as d,E as e,le as f};
|
|
109
|
-
//# sourceMappingURL=chunk-
|
|
109
|
+
//# sourceMappingURL=chunk-MFVI5FOM.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{v as l,w}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{v as l,w}from"./chunk-2DBGOCCW.js";import{a as i,f as p}from"./chunk-F4HZTZHW.js";w();p();var d="task-tier";function u(e){return{task:f(e.message,2e3),agent:e.agent,channel:e.channel??null,continuesExistingSession:e.isFollowUp??!1,...e.toolsAvailable?{toolsAvailable:e.toolsAvailable}:{}}}var c={needsFlagship:i("This task needs the strongest available model to be done correctly.",{true:"Doing it well takes real reasoning: writing or reviewing code, diagnosing a failure, planning work across several steps, weighing a judgement, handling money, touching production or anything irreversible, following a long or ambiguous instruction, or work where being subtly wrong would not be noticed. Anything where a weaker model would produce something that LOOKS right belongs here.",false:"It is mechanical and its result is obvious on sight: acknowledging or confirming a message, restating or formatting something already written, a greeting, a status echo, reading one file and reporting what it says, a lookup with one right answer, a scheduled heartbeat with nothing to decide."})};function g(e){return e.needsFlagship.noul}function f(e,n){return e.length>n?`${e.slice(0,n)}\u2026`:e}var h=.2,m=60*60*1e3;function F(e,n){if(e==="claude-code"){let t=n?.cheapModels?.[e]??n?.cheapModel;return t&&/^(claude-|haiku$|sonnet$|opus$)/.test(t)?t:void 0}if(e==="codex-cli"){let t=n?.cheapModels?.[e];return t&&/^(gpt-|o\d)/.test(t)?t:void 0}}async function M(e){let n=(o,r=null)=>({downgraded:!1,needsFlagship:r,reason:o});if(e.channel==="voice"||e.channel==="desktop"||e.channel==="opencode")return n(`${e.channel} requests retain the configured model`);if(!e.cheapModel)return n("no cheaper model configured");if(e.isFollowUp){let o=e.sessionIdleMs??0,r=e.cacheTtlMs??m;if(o<r)return n(`follow-up on a warm cache (idle ${Math.round(o/1e3)}s) \u2014 swapping would cost more than it saves`)}let t;try{t=await l(d,u(e),c,{incumbent:{needsFlagship:1},features:{agent:e.agent,channel:e.channel??"unknown"}})}catch{return n("routing seat threw \u2014 keeping the flagship")}if(!t)return n("routing seat unavailable \u2014 keeping the flagship");let s=g(t.answers);if(t.mode!=="active")return n(`shadow \u2014 would ${s<(e.threshold??h)?"downgrade":"keep"} (${s.toFixed(2)})`,s);let a=e.threshold??h;return s>=a?n(`needs the flagship (${s.toFixed(2)})`,s):{model:e.cheapModel,downgraded:!0,needsFlagship:s,reason:`mechanical task (${s.toFixed(2)} below ${a}) \u2192 ${e.cheapModel}`}}export{F as a,M as b};
|
|
2
|
+
//# sourceMappingURL=chunk-W3YGESNK.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as gr,b as hr,f as Qt,g as pr,h as mr,n as kr,o as vr}from"./chunk-F6CNF7V3.js";import{c as dr,f as lr,g as ur}from"./chunk-JV52UMCI.js";import{a as wr}from"./chunk-V7FYSZSV.js";import{a as fr}from"./chunk-ZVP6GB4G.js";import{A as ir,J as or,a as ws,b as ks,c as Kt,d as vs,e as Ts,f as As,g as xs,n as Es,o as Xe,p as V,r as _s,s as X,t as Zs,u as er,v as tr,w as nr,x as sr,y as rr}from"./chunk-COOJI5SR.js";import{a as Ms,g as Os,h as Ds,j as Xs,k as Ys,l as Vs,n as Qs}from"./chunk-7JWYLSFF.js";import{a as zs,b as Ks,c as Yt,d as Ye,e as qs,f as Ve}from"./chunk-VMDA2SX2.js";import{a as Re,b as Hs,c as Bs,d as Xt,e as Ws,f as Js}from"./chunk-QLTM3F7M.js";import{b as q,c as Y,d as Gs,e as ne,f as se,h as Vt}from"./chunk-R7WLFEW3.js";import{A as ar,B as Qe,C as cr,h as ls,n as us,o as Wt}from"./chunk-JJIYFBDH.js";import{b as as}from"./chunk-SFQUP3BP.js";import{q as yr,r as br}from"./chunk-3SCPRYJB.js";import{a as js,b as qt,c as Ns,d as Ls,e as Us,i as Fs}from"./chunk-76Z4VHDX.js";import{b as Ps}from"./chunk-W4YR2RO2.js";import{d as Ss,e as $s,j as Is}from"./chunk-DWADWDMU.js";import{e as Cs}from"./chunk-6DD4DA2L.js";import{b as Rs}from"./chunk-64P4QHSZ.js";import{d as hs,e as ka,m as ys,n as Sa,o as bs,v as qe,w as zt}from"./chunk-JC6ZHSTY.js";import{a as Ae,b as gs}from"./chunk-ZTEU5JVQ.js";import{a as xe,b as ms,f as fs}from"./chunk-F4HZTZHW.js";import{a as Ke,b as wa}from"./chunk-L2WSPY6S.js";import{a as cs,d as ds}from"./chunk-VDMYBPYB.js";import{e as ce}from"./chunk-DSYKYZMT.js";import{g as Jt,h as ps,j as va}from"./chunk-Z3RKXKE2.js";import{e as me}from"./chunk-FIOB3MEX.js";import{existsSync as $a,readFileSync as Ia}from"fs";import{resolve as Ta}from"path";var Aa={name:"agentx",version:"0.1.0"},xa="2024-11-05",Ra={tools:{},elicitation:{form:{}}},Ca=0;async function Sr(i,e){let t=++Ca;return de({jsonrpc:"2.0",id:`elicit-${t}`,method:"elicitation/create",params:{mode:"form",message:i,requestedSchema:e}}),new Promise(n=>{Ce.set(`elicit-${t}`,s=>{s?.action==="accept"&&s.content?n(s.content):n(null)}),setTimeout(()=>{Ce.has(`elicit-${t}`)&&(Ce.delete(`elicit-${t}`),n(null))},6e4)})}var Ce=new Map,Ea="http://localhost:19900",Zt;function Ma(){if(process.env.AGENTX_DAEMON_URL)return process.env.AGENTX_DAEMON_URL;for(let i of["agentx.json",".agentx/config.json"])try{let e=Ta(process.cwd(),i);if(!$a(e))continue;let t=JSON.parse(Ia(e,"utf-8"))?.node?.bind;if(typeof t!="string"||!t.includes(":"))continue;{let n=t.lastIndexOf(":"),s=t.slice(0,n),r=t.slice(n+1),o=!s||s==="0.0.0.0"||s==="::"||s==="*"?"127.0.0.1":s;if(r)return`http://${o}:${r}`}}catch{}return Ea}function H(){return Zt===void 0&&(Zt=Ma()),Zt}var _a=/\x1B\[[0-9;]*[A-Za-z]/g;function fe(i){return i.replace(_a,"")}var Pa=[{name:"agentx_generate",description:"Generate code, components, pages, APIs, documents, tests, workflows, schemas, emails, diagrams, and more using AI. Understands the project's tech stack, schemas, and skills automatically.",inputSchema:{type:"object",properties:{task:{type:"string",description:"Describe what to generate (e.g., 'a responsive pricing card', 'REST API for users', 'GitHub Actions CI pipeline')"},type:{type:"string",description:"Output type: component, page, api, website, document, script, config, skill, media, report, test, workflow, schema, email, diagram, auto",default:"auto"},output_dir:{type:"string",description:"Optional output directory (relative to project root)"},cwd:{type:"string",description:"Project working directory (defaults to current directory)"}},required:["task"]}},{name:"agentx_inspect",description:"Analyze a project and return its tech stack, frameworks, databases, schemas, installed skills, and dependencies. Use this to understand a project before generating code.",inputSchema:{type:"object",properties:{cwd:{type:"string",description:"Project working directory (defaults to current directory)"}}}},{name:"agentx_skill_match",description:"Find installed skills that are relevant to a given task description. Returns matched skills with relevance scores.",inputSchema:{type:"object",properties:{task:{type:"string",description:"The task to match skills against"},cwd:{type:"string",description:"Project working directory"}},required:["task"]}},{name:"agentx_detect_output_type",description:"Auto-detect the best output type for a given task description based on keyword analysis.",inputSchema:{type:"object",properties:{task:{type:"string",description:"The task description to analyze"}},required:["task"]}},{name:"agentx_channel_reply",description:"Reply to a channel (GitLab issue/MR comment, GitHub issue/PR comment, Telegram/WhatsApp message). PREFER THIS over raw curl/glab/HTTP \u2014 it auto-applies agent identity from agentMappings, the cascade-prevention marker, intent-ledger audit, and a 60s body-hash dedupe so an accidental retry within the window is a no-op. Returns the posted message id. For agent-to-agent delegation use agentx_send_agent. For arbitrary outbound sends use agentx_send.",inputSchema:{type:"object",properties:{channel:{type:"string",description:"Channel name. gitlab | github | telegram | whatsapp | discord | slack"},chatId:{type:"string",description:"Stable chat id you received in this task's context. GitLab: 'org/repo:issue:123' or 'org/repo:merge_request:123'. GitHub: 'org/repo:issue:123' or 'org/repo:pull:123'. Telegram: numeric. WhatsApp: '+phone@s.whatsapp.net'."},text:{type:"string",description:"Reply body. Markdown for gitlab/github/discord; plain for sms/whatsapp."},agentId:{type:"string",description:"Optional posting identity. Defaults to channel-adapter resolution from agentMappings."},accountId:{type:"string",description:"Multi-account adapters (telegram) need this when the chat is reachable from more than one bot."},replyTo:{type:"string",description:"Optional reply-to message id for threaded channels."},idempotencyKey:{type:"string",description:"Optional explicit dedupe key. When omitted, a body hash is used. Use a stable key for 'overwrite my last status update' patterns."}},required:["channel","chatId","text"]}},{name:"agentx_channel_label",description:"Add and/or remove labels on a GitLab issue or merge_request through the canonical adapter (per-agent token, ledger). Use this instead of curl when changing labels on the entity that triggered the current task.",inputSchema:{type:"object",properties:{channel:{type:"string",description:"Currently 'gitlab'.",default:"gitlab"},project:{type:"string",description:"GitLab project path \u2014 'org/repo'."},kind:{type:"string",description:"'issue' or 'merge_request'."},iid:{type:"string",description:"Numeric iid as a string."},add:{type:"array",items:{type:"string"},description:"Labels to add."},remove:{type:"array",items:{type:"string"},description:"Labels to remove."},agentId:{type:"string",description:"Optional posting identity."}},required:["project","kind","iid"]}},{name:"agentx_send",description:"Low-level outbound send when you ALREADY have a channel-native chatId (Telegram numeric chat id, GitLab 'group/project:issue:123', WhatsApp '+phone@s.whatsapp.net'). For sending to another agent by name, use agentx_send_agent instead. For sending to a human contact by name, use agentx_send_contact instead.",inputSchema:{type:"object",properties:{channel:{type:"string",description:"Target channel: telegram, whatsapp, gitlab, discord"},chatId:{type:"string",description:'Chat ID. Telegram: numeric ("-1001234567890"). GitLab: "group/project:issue:123". WhatsApp: "+phone@s.whatsapp.net".'},text:{type:"string",description:"Message text to send"},agentId:{type:"string",description:"Agent ID to send as (determines bot account on Telegram, GitLab token, etc.)"}},required:["channel","chatId","text"]}},{name:"agentx_send_agent",description:"Send a message to ANOTHER AGENT by exact agentId \u2014 uses the AgentX A2A mesh (or local registry when the agent lives on this daemon). This is the deterministic path for agent-to-agent communication; it never falls through to a contact lookup, so an unknown agentId returns 404 with the list of known agents instead of silently sending to a similarly-named human. Use this when the target is a registered agent.",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"Exact agentId of the target agent (e.g. 'peer', 'atlas'). Must match an agent in this daemon's registry or in a healthy mesh peer's directory."},text:{type:"string",description:"Message to send to the target agent"},senderAgentId:{type:"string",description:"Optional. The agentId on whose behalf this call is being made. Recorded in route_traces and (with A2A protocolVersion >= 2) validated by the receiving daemon."}},required:["agentId","text"]}},{name:"agentx_recent",description:"Read the most recent messages from a chat across ALL agents that have sessions for it. Returns inbound + each agent's replies in chronological order, so you can see what's actually been said in a Telegram chat / GitLab thread / WhatsApp DM regardless of which agent recorded it. Use this BEFORE speculating about what was sent \u2014 the cx/devops/marketing thread on 2026-04-29 about a Marketing/CX bot mixup would have been resolved in one call instead of three agents speculating. Bounded by sinceISO (default: last 24h) and limit (default: 30, max: 200).",inputSchema:{type:"object",properties:{channel:{type:"string",description:"Channel name. Examples: telegram, whatsapp, gitlab, github, discord, cron, api, a2a."},chatId:{type:"string",description:'Channel-native chat id. Telegram: numeric (e.g. "1816212449" for a DM, "-1001234567890" for a group). GitLab: "group/project:issue:123". WhatsApp: "+phone@s.whatsapp.net".'},sinceISO:{type:"string",description:"Optional ISO timestamp lower bound. Defaults to 24h ago."},limit:{type:"number",description:"Optional cap on returned messages. Default 30, max 200."}},required:["channel","chatId"]}},{name:"agentx_send_contact",description:"Send a message to a HUMAN CONTACT by name. Resolves through .agentx/contacts.json (id \u2192 exact alias \u2192 fuzzy substring). Refuses fuzzy matches without confirmed:true so the agent must ask the user to disambiguate before sending. Refuses when the name also matches a registered agent (use agentx_send_agent for those). Use this when the target is a person, not a bot.",inputSchema:{type:"object",properties:{contactName:{type:"string",description:"Free-form contact name. Tried as id first, then alias, then fuzzy substring."},text:{type:"string",description:"Message to send to the contact"},channel:{type:"string",description:"Optional explicit channel (telegram | whatsapp | gitlab | discord). Defaults to the first channel configured for the contact."},confirmed:{type:"boolean",description:"Pass true ONLY after the user has confirmed a fuzzy match. Without it, fuzzy matches return 409 with the candidate so you can ask the user."},agentId:{type:"string",description:"Optional agent identity used for the outbound send (determines bot account / token)."}},required:["contactName","text"]}},{name:"agentx_task",description:"Send a task to a specific agent on the daemon. The agent processes it and returns a response. Use to delegate work to specialized agents.",inputSchema:{type:"object",properties:{agent:{type:"string",description:"Agent ID to send the task to"},message:{type:"string",description:"Task message for the agent"},senderAgentId:{type:"string",description:"Optional caller agent id. Defaults to AGENTX_AGENT_ID when the MCP server was launched by an AgentX runtime."},freshSession:{type:"boolean",description:"Start the target agent with a clean AgentX-side conversation. Defaults to true for agent-to-agent delegation."},chatId:{type:"string",description:"Optional stable chat/session id for this delegated task. Omit for a one-off isolated delegation."}},required:["agent","message"]}},{name:"agentx_agents",description:"List all agents registered on the daemon with their status (active tasks, total tasks, errors, tier).",inputSchema:{type:"object",properties:{}}},{name:"agentx_health",description:"Get the daemon health status including node info, agents, crons, mesh peers, and uptime.",inputSchema:{type:"object",properties:{}}},{name:"agentx_attach_next",description:"Take the next message queued for the agent identity THIS session is attached to (attach mode). Returns the message plus who sent it and on which channel, or nothing when the inbox is empty. After calling this, just answer normally \u2014 your reply is captured automatically and sent back to the channel. Use when the user runs /inbox or asks you to check for waiting messages.",inputSchema:{type:"object",properties:{}}},{name:"agentx_attach_answer",description:"Explicitly answer the message currently claimed by this session (attach mode). Usually unnecessary \u2014 replying normally after agentx_attach_next is captured automatically. Use this only when your reply to the channel should differ from what you told the user in the terminal.",inputSchema:{type:"object",properties:{text:{type:"string",description:"The reply to send back to the channel, verbatim."}},required:["text"]}},{name:"agentx_crons",description:"List cron jobs and their health. Shows healthy, failing, disabled counts and per-job status with consecutive error counts.",inputSchema:{type:"object",properties:{}}},{name:"agentx_debug",description:"Toggle debug mode on the daemon. Enable verbose logging for specific categories (webhook, agent, channel, cron, mesh, context, memory, all) or disable it.",inputSchema:{type:"object",properties:{action:{type:"string",description:'"on", "off", or "status"',default:"status"},categories:{type:"string",description:'Comma-separated categories to enable (e.g. "webhook,agent"). Only used with action=on.'}}}},{name:"agentx_wiki_query",description:"Query the agentx institutional wiki: a cross-agent knowledge base organized by article type (person, project, place, concept, event, decision, pattern). Use this BEFORE grep/memory-search when the question is about who / what happened / what we decided / how we do something. The query walks the catalog + wikilink graph and returns a synthesized answer with citations.",inputSchema:{type:"object",properties:{question:{type:"string",description:"The question to answer from the wiki, in natural language."},agent:{type:"string",description:"Which agent's wiki to query (default: first agent with a catalog). Each agent has its own wiki dir under .agentx/wiki/agents/<id>/"},wiki_dir:{type:"string",description:"Wiki root dir (default: <cwd>/.agentx/wiki)."},max_hops:{type:"number",description:"Wikilink hops from candidates (default 2, max 3).",default:2}},required:["question"]}},{name:"agentx_wiki_patch",description:"Edit a single wiki article via an LLM-applied instruction and write the result. Use this for targeted fixes, additions, or clarifications to an existing article when you already know what's wrong. For brand-new articles, use `agentx_wiki_interview` instead.",inputSchema:{type:"object",properties:{agent:{type:"string",description:"Agent ID whose wiki owns the article (required)."},title_or_path:{type:"string",description:"Article title (case-insensitive) or relative path like 'people/alex.md'."},instruction:{type:"string",description:"Plain-English edit instruction (e.g. 'Add a section on the KSA Supabase rollout'). The LLM makes the minimum edit that satisfies it."},model:{type:"string",description:"Claude model for the patch (default: sonnet).",default:"sonnet"},dry_run:{type:"boolean",description:"Preview the patched body without writing.",default:!1}},required:["agent","title_or_path","instruction"]}},{name:"agentx_wiki_interview",description:"Run a scripted wiki interview \u2014 synthesize ONE typed article from a list of Q&A answers, and save it. Non-interactive: caller supplies the answers upfront. Use for capturing tacit knowledge (person/project/decision/pattern/...) that never hit a channel. For editing an existing article, use `agentx_wiki_patch`.",inputSchema:{type:"object",properties:{agent:{type:"string",description:"Agent ID that will own the new article (required)."},topic:{type:"string",description:"What the article is about \u2014 e.g. 'Globex deployment procedure', 'Jane Doe', 'DemoSite KSA migration'."},type:{type:"string",description:"Article type: person | project | place | concept | event | decision | pattern"},answers:{type:"array",description:"Answers to the type-specific question bank (one per question, in order). Empty string = skip that question. Final entry is typically 'save'.",items:{type:"string"}},model:{type:"string",description:"Synthesis model (default: sonnet).",default:"sonnet"},commit:{type:"boolean",description:"Write the article (true) or just preview (false).",default:!0}},required:["agent","topic","type","answers"]}},{name:"agentx_graph_review",description:"Triage pending intent-graph classifications via the configured review agent. The review agent sees each pending classification, may call `wiki query` for institutional context, and decides approve/reject/skip. Structural changes (new org, new unit) gate here; leaf additions auto-approve without this step.",inputSchema:{type:"object",properties:{max:{type:"number",description:"Cap reviews this run (default 20).",default:20},dry_run:{type:"boolean",description:"Show decisions but don't apply approvals/rejections.",default:!1},agent:{type:"string",description:"Override the review agent (defaults to graph.reviewAgent or graph.draftAgent)."}}}}];async function Oa(i,e){let t=e.cwd||process.cwd();switch(i){case"agentx_generate":{let n=e.task,s=e.type||"auto",r=e.output_dir,o=await Qe({task:n,outputType:s,outputDir:r,cwd:t,overwrite:!0,dryRun:!1,context7:!0,interactive:!1,maxSteps:5}),a=[];return o.content&&a.push(o.content),o.files.written.length&&a.push(`
|
|
1
|
+
import{a as gr,b as hr,f as Qt,g as pr,h as mr,n as kr,o as vr}from"./chunk-F6CNF7V3.js";import{c as dr,f as lr,g as ur}from"./chunk-GWQIMAJ7.js";import{a as wr}from"./chunk-V7FYSZSV.js";import{a as fr}from"./chunk-ZVP6GB4G.js";import{A as ir,J as or,a as ws,b as ks,c as Kt,d as vs,e as Ts,f as As,g as xs,n as Es,o as Xe,p as V,r as _s,s as X,t as Zs,u as er,v as tr,w as nr,x as sr,y as rr}from"./chunk-6VQKHMEQ.js";import{a as Ms,g as Os,h as Ds,j as Xs,k as Ys,l as Vs,n as Qs}from"./chunk-5FEQI22L.js";import{a as zs,b as Ks,c as Yt,d as Ye,e as qs,f as Ve}from"./chunk-VMDA2SX2.js";import{a as Re,b as Hs,c as Bs,d as Xt,e as Ws,f as Js}from"./chunk-QLTM3F7M.js";import{b as q,c as Y,d as Gs,e as ne,f as se,h as Vt}from"./chunk-A4YR3PQY.js";import{A as ar,B as Qe,C as cr,h as ls,n as us,o as Wt}from"./chunk-K6E7WJ7O.js";import{b as as}from"./chunk-SFQUP3BP.js";import{q as yr,r as br}from"./chunk-3SCPRYJB.js";import{a as js,b as qt,c as Ns,d as Ls,e as Us,i as Fs}from"./chunk-76Z4VHDX.js";import{b as Ps}from"./chunk-W4YR2RO2.js";import{d as Ss,e as $s,j as Is}from"./chunk-DWADWDMU.js";import{e as Cs}from"./chunk-MFVI5FOM.js";import{b as Rs}from"./chunk-64P4QHSZ.js";import{d as hs,e as ka,m as ys,n as Sa,o as bs,v as qe,w as zt}from"./chunk-2DBGOCCW.js";import{a as Ae,b as gs}from"./chunk-ZTEU5JVQ.js";import{a as xe,b as ms,f as fs}from"./chunk-F4HZTZHW.js";import{a as Ke,b as wa}from"./chunk-L2WSPY6S.js";import{a as cs,d as ds}from"./chunk-VDMYBPYB.js";import{e as ce}from"./chunk-DSYKYZMT.js";import{g as Jt,h as ps,j as va}from"./chunk-2DMVKLLE.js";import{e as me}from"./chunk-FIOB3MEX.js";import{existsSync as $a,readFileSync as Ia}from"fs";import{resolve as Ta}from"path";var Aa={name:"agentx",version:"0.1.0"},xa="2024-11-05",Ra={tools:{},elicitation:{form:{}}},Ca=0;async function Sr(i,e){let t=++Ca;return de({jsonrpc:"2.0",id:`elicit-${t}`,method:"elicitation/create",params:{mode:"form",message:i,requestedSchema:e}}),new Promise(n=>{Ce.set(`elicit-${t}`,s=>{s?.action==="accept"&&s.content?n(s.content):n(null)}),setTimeout(()=>{Ce.has(`elicit-${t}`)&&(Ce.delete(`elicit-${t}`),n(null))},6e4)})}var Ce=new Map,Ea="http://localhost:19900",Zt;function Ma(){if(process.env.AGENTX_DAEMON_URL)return process.env.AGENTX_DAEMON_URL;for(let i of["agentx.json",".agentx/config.json"])try{let e=Ta(process.cwd(),i);if(!$a(e))continue;let t=JSON.parse(Ia(e,"utf-8"))?.node?.bind;if(typeof t!="string"||!t.includes(":"))continue;{let n=t.lastIndexOf(":"),s=t.slice(0,n),r=t.slice(n+1),o=!s||s==="0.0.0.0"||s==="::"||s==="*"?"127.0.0.1":s;if(r)return`http://${o}:${r}`}}catch{}return Ea}function H(){return Zt===void 0&&(Zt=Ma()),Zt}var _a=/\x1B\[[0-9;]*[A-Za-z]/g;function fe(i){return i.replace(_a,"")}var Pa=[{name:"agentx_generate",description:"Generate code, components, pages, APIs, documents, tests, workflows, schemas, emails, diagrams, and more using AI. Understands the project's tech stack, schemas, and skills automatically.",inputSchema:{type:"object",properties:{task:{type:"string",description:"Describe what to generate (e.g., 'a responsive pricing card', 'REST API for users', 'GitHub Actions CI pipeline')"},type:{type:"string",description:"Output type: component, page, api, website, document, script, config, skill, media, report, test, workflow, schema, email, diagram, auto",default:"auto"},output_dir:{type:"string",description:"Optional output directory (relative to project root)"},cwd:{type:"string",description:"Project working directory (defaults to current directory)"}},required:["task"]}},{name:"agentx_inspect",description:"Analyze a project and return its tech stack, frameworks, databases, schemas, installed skills, and dependencies. Use this to understand a project before generating code.",inputSchema:{type:"object",properties:{cwd:{type:"string",description:"Project working directory (defaults to current directory)"}}}},{name:"agentx_skill_match",description:"Find installed skills that are relevant to a given task description. Returns matched skills with relevance scores.",inputSchema:{type:"object",properties:{task:{type:"string",description:"The task to match skills against"},cwd:{type:"string",description:"Project working directory"}},required:["task"]}},{name:"agentx_detect_output_type",description:"Auto-detect the best output type for a given task description based on keyword analysis.",inputSchema:{type:"object",properties:{task:{type:"string",description:"The task description to analyze"}},required:["task"]}},{name:"agentx_channel_reply",description:"Reply to a channel (GitLab issue/MR comment, GitHub issue/PR comment, Telegram/WhatsApp message). PREFER THIS over raw curl/glab/HTTP \u2014 it auto-applies agent identity from agentMappings, the cascade-prevention marker, intent-ledger audit, and a 60s body-hash dedupe so an accidental retry within the window is a no-op. Returns the posted message id. For agent-to-agent delegation use agentx_send_agent. For arbitrary outbound sends use agentx_send.",inputSchema:{type:"object",properties:{channel:{type:"string",description:"Channel name. gitlab | github | telegram | whatsapp | discord | slack"},chatId:{type:"string",description:"Stable chat id you received in this task's context. GitLab: 'org/repo:issue:123' or 'org/repo:merge_request:123'. GitHub: 'org/repo:issue:123' or 'org/repo:pull:123'. Telegram: numeric. WhatsApp: '+phone@s.whatsapp.net'."},text:{type:"string",description:"Reply body. Markdown for gitlab/github/discord; plain for sms/whatsapp."},agentId:{type:"string",description:"Optional posting identity. Defaults to channel-adapter resolution from agentMappings."},accountId:{type:"string",description:"Multi-account adapters (telegram) need this when the chat is reachable from more than one bot."},replyTo:{type:"string",description:"Optional reply-to message id for threaded channels."},idempotencyKey:{type:"string",description:"Optional explicit dedupe key. When omitted, a body hash is used. Use a stable key for 'overwrite my last status update' patterns."}},required:["channel","chatId","text"]}},{name:"agentx_channel_label",description:"Add and/or remove labels on a GitLab issue or merge_request through the canonical adapter (per-agent token, ledger). Use this instead of curl when changing labels on the entity that triggered the current task.",inputSchema:{type:"object",properties:{channel:{type:"string",description:"Currently 'gitlab'.",default:"gitlab"},project:{type:"string",description:"GitLab project path \u2014 'org/repo'."},kind:{type:"string",description:"'issue' or 'merge_request'."},iid:{type:"string",description:"Numeric iid as a string."},add:{type:"array",items:{type:"string"},description:"Labels to add."},remove:{type:"array",items:{type:"string"},description:"Labels to remove."},agentId:{type:"string",description:"Optional posting identity."}},required:["project","kind","iid"]}},{name:"agentx_send",description:"Low-level outbound send when you ALREADY have a channel-native chatId (Telegram numeric chat id, GitLab 'group/project:issue:123', WhatsApp '+phone@s.whatsapp.net'). For sending to another agent by name, use agentx_send_agent instead. For sending to a human contact by name, use agentx_send_contact instead.",inputSchema:{type:"object",properties:{channel:{type:"string",description:"Target channel: telegram, whatsapp, gitlab, discord"},chatId:{type:"string",description:'Chat ID. Telegram: numeric ("-1001234567890"). GitLab: "group/project:issue:123". WhatsApp: "+phone@s.whatsapp.net".'},text:{type:"string",description:"Message text to send"},agentId:{type:"string",description:"Agent ID to send as (determines bot account on Telegram, GitLab token, etc.)"}},required:["channel","chatId","text"]}},{name:"agentx_send_agent",description:"Send a message to ANOTHER AGENT by exact agentId \u2014 uses the AgentX A2A mesh (or local registry when the agent lives on this daemon). This is the deterministic path for agent-to-agent communication; it never falls through to a contact lookup, so an unknown agentId returns 404 with the list of known agents instead of silently sending to a similarly-named human. Use this when the target is a registered agent.",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"Exact agentId of the target agent (e.g. 'peer', 'atlas'). Must match an agent in this daemon's registry or in a healthy mesh peer's directory."},text:{type:"string",description:"Message to send to the target agent"},senderAgentId:{type:"string",description:"Optional. The agentId on whose behalf this call is being made. Recorded in route_traces and (with A2A protocolVersion >= 2) validated by the receiving daemon."}},required:["agentId","text"]}},{name:"agentx_recent",description:"Read the most recent messages from a chat across ALL agents that have sessions for it. Returns inbound + each agent's replies in chronological order, so you can see what's actually been said in a Telegram chat / GitLab thread / WhatsApp DM regardless of which agent recorded it. Use this BEFORE speculating about what was sent \u2014 the cx/devops/marketing thread on 2026-04-29 about a Marketing/CX bot mixup would have been resolved in one call instead of three agents speculating. Bounded by sinceISO (default: last 24h) and limit (default: 30, max: 200).",inputSchema:{type:"object",properties:{channel:{type:"string",description:"Channel name. Examples: telegram, whatsapp, gitlab, github, discord, cron, api, a2a."},chatId:{type:"string",description:'Channel-native chat id. Telegram: numeric (e.g. "1816212449" for a DM, "-1001234567890" for a group). GitLab: "group/project:issue:123". WhatsApp: "+phone@s.whatsapp.net".'},sinceISO:{type:"string",description:"Optional ISO timestamp lower bound. Defaults to 24h ago."},limit:{type:"number",description:"Optional cap on returned messages. Default 30, max 200."}},required:["channel","chatId"]}},{name:"agentx_send_contact",description:"Send a message to a HUMAN CONTACT by name. Resolves through .agentx/contacts.json (id \u2192 exact alias \u2192 fuzzy substring). Refuses fuzzy matches without confirmed:true so the agent must ask the user to disambiguate before sending. Refuses when the name also matches a registered agent (use agentx_send_agent for those). Use this when the target is a person, not a bot.",inputSchema:{type:"object",properties:{contactName:{type:"string",description:"Free-form contact name. Tried as id first, then alias, then fuzzy substring."},text:{type:"string",description:"Message to send to the contact"},channel:{type:"string",description:"Optional explicit channel (telegram | whatsapp | gitlab | discord). Defaults to the first channel configured for the contact."},confirmed:{type:"boolean",description:"Pass true ONLY after the user has confirmed a fuzzy match. Without it, fuzzy matches return 409 with the candidate so you can ask the user."},agentId:{type:"string",description:"Optional agent identity used for the outbound send (determines bot account / token)."}},required:["contactName","text"]}},{name:"agentx_task",description:"Send a task to a specific agent on the daemon. The agent processes it and returns a response. Use to delegate work to specialized agents.",inputSchema:{type:"object",properties:{agent:{type:"string",description:"Agent ID to send the task to"},message:{type:"string",description:"Task message for the agent"},senderAgentId:{type:"string",description:"Optional caller agent id. Defaults to AGENTX_AGENT_ID when the MCP server was launched by an AgentX runtime."},freshSession:{type:"boolean",description:"Start the target agent with a clean AgentX-side conversation. Defaults to true for agent-to-agent delegation."},chatId:{type:"string",description:"Optional stable chat/session id for this delegated task. Omit for a one-off isolated delegation."}},required:["agent","message"]}},{name:"agentx_agents",description:"List all agents registered on the daemon with their status (active tasks, total tasks, errors, tier).",inputSchema:{type:"object",properties:{}}},{name:"agentx_health",description:"Get the daemon health status including node info, agents, crons, mesh peers, and uptime.",inputSchema:{type:"object",properties:{}}},{name:"agentx_attach_next",description:"Take the next message queued for the agent identity THIS session is attached to (attach mode). Returns the message plus who sent it and on which channel, or nothing when the inbox is empty. After calling this, just answer normally \u2014 your reply is captured automatically and sent back to the channel. Use when the user runs /inbox or asks you to check for waiting messages.",inputSchema:{type:"object",properties:{}}},{name:"agentx_attach_answer",description:"Explicitly answer the message currently claimed by this session (attach mode). Usually unnecessary \u2014 replying normally after agentx_attach_next is captured automatically. Use this only when your reply to the channel should differ from what you told the user in the terminal.",inputSchema:{type:"object",properties:{text:{type:"string",description:"The reply to send back to the channel, verbatim."}},required:["text"]}},{name:"agentx_crons",description:"List cron jobs and their health. Shows healthy, failing, disabled counts and per-job status with consecutive error counts.",inputSchema:{type:"object",properties:{}}},{name:"agentx_debug",description:"Toggle debug mode on the daemon. Enable verbose logging for specific categories (webhook, agent, channel, cron, mesh, context, memory, all) or disable it.",inputSchema:{type:"object",properties:{action:{type:"string",description:'"on", "off", or "status"',default:"status"},categories:{type:"string",description:'Comma-separated categories to enable (e.g. "webhook,agent"). Only used with action=on.'}}}},{name:"agentx_wiki_query",description:"Query the agentx institutional wiki: a cross-agent knowledge base organized by article type (person, project, place, concept, event, decision, pattern). Use this BEFORE grep/memory-search when the question is about who / what happened / what we decided / how we do something. The query walks the catalog + wikilink graph and returns a synthesized answer with citations.",inputSchema:{type:"object",properties:{question:{type:"string",description:"The question to answer from the wiki, in natural language."},agent:{type:"string",description:"Which agent's wiki to query (default: first agent with a catalog). Each agent has its own wiki dir under .agentx/wiki/agents/<id>/"},wiki_dir:{type:"string",description:"Wiki root dir (default: <cwd>/.agentx/wiki)."},max_hops:{type:"number",description:"Wikilink hops from candidates (default 2, max 3).",default:2}},required:["question"]}},{name:"agentx_wiki_patch",description:"Edit a single wiki article via an LLM-applied instruction and write the result. Use this for targeted fixes, additions, or clarifications to an existing article when you already know what's wrong. For brand-new articles, use `agentx_wiki_interview` instead.",inputSchema:{type:"object",properties:{agent:{type:"string",description:"Agent ID whose wiki owns the article (required)."},title_or_path:{type:"string",description:"Article title (case-insensitive) or relative path like 'people/alex.md'."},instruction:{type:"string",description:"Plain-English edit instruction (e.g. 'Add a section on the KSA Supabase rollout'). The LLM makes the minimum edit that satisfies it."},model:{type:"string",description:"Claude model for the patch (default: sonnet).",default:"sonnet"},dry_run:{type:"boolean",description:"Preview the patched body without writing.",default:!1}},required:["agent","title_or_path","instruction"]}},{name:"agentx_wiki_interview",description:"Run a scripted wiki interview \u2014 synthesize ONE typed article from a list of Q&A answers, and save it. Non-interactive: caller supplies the answers upfront. Use for capturing tacit knowledge (person/project/decision/pattern/...) that never hit a channel. For editing an existing article, use `agentx_wiki_patch`.",inputSchema:{type:"object",properties:{agent:{type:"string",description:"Agent ID that will own the new article (required)."},topic:{type:"string",description:"What the article is about \u2014 e.g. 'Globex deployment procedure', 'Jane Doe', 'DemoSite KSA migration'."},type:{type:"string",description:"Article type: person | project | place | concept | event | decision | pattern"},answers:{type:"array",description:"Answers to the type-specific question bank (one per question, in order). Empty string = skip that question. Final entry is typically 'save'.",items:{type:"string"}},model:{type:"string",description:"Synthesis model (default: sonnet).",default:"sonnet"},commit:{type:"boolean",description:"Write the article (true) or just preview (false).",default:!0}},required:["agent","topic","type","answers"]}},{name:"agentx_graph_review",description:"Triage pending intent-graph classifications via the configured review agent. The review agent sees each pending classification, may call `wiki query` for institutional context, and decides approve/reject/skip. Structural changes (new org, new unit) gate here; leaf additions auto-approve without this step.",inputSchema:{type:"object",properties:{max:{type:"number",description:"Cap reviews this run (default 20).",default:20},dry_run:{type:"boolean",description:"Show decisions but don't apply approvals/rejections.",default:!1},agent:{type:"string",description:"Override the review agent (defaults to graph.reviewAgent or graph.draftAgent)."}}}}];async function Oa(i,e){let t=e.cwd||process.cwd();switch(i){case"agentx_generate":{let n=e.task,s=e.type||"auto",r=e.output_dir,o=await Qe({task:n,outputType:s,outputDir:r,cwd:t,overwrite:!0,dryRun:!1,context7:!0,interactive:!1,maxSteps:5}),a=[];return o.content&&a.push(o.content),o.files.written.length&&a.push(`
|
|
2
2
|
Created ${o.files.written.length} file(s):
|
|
3
3
|
${o.files.written.map(d=>` - ${d}`).join(`
|
|
4
4
|
`)}`),o.files.skipped.length&&a.push(`
|
|
@@ -22,7 +22,7 @@ ${r.map(a=>`- **${a.skill.frontmatter.name}** (relevance: ${(a.relevance*100).to
|
|
|
22
22
|
`)}]}}case"agentx_attach_answer":{let n=process.env.CLAUDE_CODE_SESSION_ID;if(!n)return{content:[{type:"text",text:"Not running inside a Claude Code session \u2014 attach mode is unavailable here."}]};let s=await fetch(`${H()}/attach/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:n,text:String(e.text??"")})}),r=await s.json();if(!s.ok)return{content:[{type:"text",text:`Could not answer: ${r?.error??s.status}`}]};let o=r.pending>0?` ${r.pending} still queued.`:"";return{content:[{type:"text",text:`Sent to ${r.item?.channel}.${o}`}]}}case"agentx_crons":{let s=await(await fetch(`${H()}/crons/health`)).json(),r=`Healthy: ${s.healthy}, Failing: ${s.failing}, Disabled: ${s.disabled}, Missed: ${s.missed}`,o=(s.jobs||[]).map(a=>` ${a.id}: ${a.status}${a.consecutiveErrors?` (${a.consecutiveErrors} errors)`:""}${a.lastError?` \u2014 ${a.lastError.slice(0,100)}`:""}`).join(`
|
|
23
23
|
`);return{content:[{type:"text",text:`${r}
|
|
24
24
|
|
|
25
|
-
${o}`}]}}case"agentx_wiki_query":{let n=String(e.question||"").trim();if(!n)return{content:[{type:"text",text:"Error: `question` is required."}]};let{WikiHub:s}=await import("./wiki-
|
|
25
|
+
${o}`}]}}case"agentx_wiki_query":{let n=String(e.question||"").trim();if(!n)return{content:[{type:"text",text:"Error: `question` is required."}]};let{WikiHub:s}=await import("./wiki-MY32MON3.js"),{agenticQuery:r}=await import("./query-RHVR6QUZ.js"),{resolve:o}=await import("path"),a=e.wiki_dir||o(process.cwd(),".agentx/wiki"),d=new s(a,void 0,"graph"),c=e.agent||"";if(!c){let{existsSync:S}=await import("fs");for(let k of d.listAgents()){let T=o(d.getAgentWiki(k).baseDir,"_index.md");if(S(T)){c=k;break}}}if(!c)return{content:[{type:"text",text:"Error: no agent has a wiki catalog yet. Run `agentx wiki absorb` first."}]};let l=d.getAgentWiki(c),h=typeof e.max_hops=="number"?Math.min(3,Math.max(0,e.max_hops)):2,g=await r(n,l,c,{maxHops:h});if(g.status!=="ok")return{content:[{type:"text",text:`Query returned status "${g.status}"${g.error?`: ${g.error}`:""}`}]};let w=g.citations.map(S=>` - ${S.title} [${S.type||"?"}] (${S.path})`).join(`
|
|
26
26
|
`),m=g.walked.length;return{content:[{type:"text",text:`${g.answer}
|
|
27
27
|
|
|
28
28
|
Citations (${m} article${m===1?"":"s"} walked):
|
|
@@ -1198,4 +1198,4 @@ data: ${JSON.stringify(A)}
|
|
|
1198
1198
|
`)}catch{}},15e3);x.unref?.();try{for await(let R of this.mesh.sendTaskStream(u.peer,u.message,u.agent,{context:u.context}))$(R.event,R.data)}catch(R){$("error",{error:R?.message??String(R)})}finally{clearInterval(x);try{t.end()}catch{}}break}let y=u.context,v=typeof u.senderAgentId=="string"?u.senderAgentId:void 0;if(u.async===!0){let $=y?.channel,x=y?.chatId;if(!$||!x){this.json(t,400,{error:"async requires context.channel and context.chatId \u2014 there is no route back otherwise"});return}let R=`mesh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;this.json(t,202,{accepted:!0,taskId:R,deliverTo:`${$}:${x}`,note:"result will be delivered to the originating chat when the peer finishes"});let A=u.peer,E=u.agent,M=this.mesh;(async()=>{let _=Date.now(),O;try{O=await M.sendTask(A,u.message,E,{context:y,senderAgentId:v}),this.log(`[mesh/task async ${R}] ${A}/${E??"default"} finished in ${Date.now()-_}ms`)}catch(U){O=`Delegation to ${A}/${E??"default"} failed: ${U?.message??U}`,this.log(`[mesh/task async ${R}] failed: ${U?.message??U}`)}try{await this.router.sendOutbound({channel:$,chatId:x,text:O,agentId:y?.agentId??v,accountId:y?.accountId})}catch(U){this.log(`[mesh/task async ${R}] delivery failed: ${U?.message??U}`)}})();break}let I=await this.mesh.sendTask(u.peer,u.message,u.agent,{context:y,senderAgentId:v});this.json(t,200,{response:I});break}case"POST /webrtc/signal/out":{if(!this.webrtc){this.json(t,404,{error:"WebRTC signaling not enabled"});return}let p=await L(e);if(!p.kind||!p.callId||!p.from||!p.to){this.json(t,400,{error:"Missing: kind, callId, from, to"});return}let f=await this.webrtc.handleOutgoing(p);this.json(t,f.ok?200:400,f);break}case"POST /webrtc/signal":{if(!this.webrtc){this.json(t,404,{error:"WebRTC signaling not enabled"});return}let p=await L(e);if(!p.kind||!p.callId||!p.from||!p.to){this.json(t,400,{error:"Missing: kind, callId, from, to"});return}let f=this.webrtc.handleIncoming(p);this.json(t,f.ok?200:400,f);break}case"POST /webrtc/bot/invite":{if(!this.botManager){this.json(t,404,{error:"WebRTC bot not enabled (channels.webrtc.bot.enabled=false)"});return}let u=await L(e),p=u.callId,f=u.target,y=u.agentId||this.config.channels.webrtc?.bot.defaultAgentId;if(!p||!f||!y){this.json(t,400,{error:"Missing: callId, target, agentId (or defaultAgentId in config)"});return}let v=await this.botManager.invite({callId:p,target:f,agentId:y});this.json(t,v.ok?200:500,v);break}case"GET /webrtc/bots":{if(!this.botManager){this.json(t,404,{error:"WebRTC bot not enabled"});return}this.json(t,200,{active:this.botManager.active()});break}case"GET /webrtc/history":{if(!this.botManager){this.json(t,404,{error:"WebRTC bot not enabled"});return}this.json(t,200,{active:this.botManager.active(),history:this.botManager.history()});break}case"GET /webrtc/config":{let u=this.config.channels.webrtc;if(!u?.enabled){this.json(t,404,{error:"WebRTC signaling not enabled"});return}this.json(t,200,{localName:this.config.node.name,iceServers:[...u.stunServers.map(p=>({urls:p})),...u.turnServers],peers:this.mesh?.directory().map(p=>({name:p.peer,healthy:p.healthy}))||[]});break}case"GET /.well-known/agent-card.json":this.json(t,200,{name:this.config.node.name,description:`AgentX daemon node "${this.config.node.name}"`,url:`http://${this.config.node.bind}`,version:"1.0.0",capabilities:{streaming:!1,pushNotifications:!1,stateTransitionHistory:!1},skills:this.registry.list().map(u=>{let p=this.config.agents[u.id]||{},f=typeof p.description=="string"&&p.description.trim()||ju(p.systemPrompt)||`Agent "${u.name}" (${u.tier})`,y=Array.isArray(p.mentions)?p.mentions.slice(0,4):[];return{id:u.id,name:u.name,description:f,tags:[u.tier,...y]}}),channels:this.router.getChannelNames(),defaultInputModes:["text"],defaultOutputModes:["text"]});break;case"GET /wiki/agents":{let u=this.registry.getWikiHub();this.json(t,200,{nodeId:this.config.node.id,agents:u.summary()});break}case"GET /wiki/entries":{let u=this.registry.getWikiHub(),p=n.searchParams.get("agent")||void 0,f=n.searchParams.get("after")||void 0,y=p?u.getAgentEntries(p):u.getSharedStore().listEntries({after:f});this.json(t,200,{nodeId:this.config.node.id,count:y.length,entries:y.map(v=>({id:v.id,date:v.date,agentId:v.agentId,source:v.source,sourceContext:v.sourceContext,content:v.content}))});break}case"GET /wiki/articles":{let u=this.registry.getWikiHub(),p=n.searchParams.get("agent");if(!p){this.json(t,400,{error:"?agent= required"});break}let y=u.getAgentWiki(p).rebuildIndex();this.json(t,200,{nodeId:this.config.node.id,agentId:p,articles:y.articles});break}case"GET /wiki/article":{let u=this.registry.getWikiHub(),p=n.searchParams.get("agent"),f=n.searchParams.get("path");if(!p||!f){this.json(t,400,{error:"?agent= and ?path= required"});break}let v=u.getAgentWiki(p).readArticle(f);if(!v){this.json(t,404,{error:"Article not found"});break}this.json(t,200,{nodeId:this.config.node.id,agentId:p,path:v.path,title:v.meta.title,tags:v.meta.tags,owner:v.meta.owner,created:v.meta.created,lastUpdated:v.meta.lastUpdated,sources:v.meta.sources,content:v.content});break}case"GET /graph/schema":{let u=this.registry.getGraphStore();if(!u){this.json(t,404,{error:"graph disabled on this node"});break}this.json(t,200,{nodeId:this.config.node.id,schema:u.loadSchema()});break}case"GET /graph/nodes":{let u=this.registry.getGraphStore();if(!u){this.json(t,404,{error:"graph disabled on this node"});break}this.json(t,200,{nodeId:this.config.node.id,...u.loadNodes()});break}case"GET /graph/classifications":{let u=this.registry.getGraphStore();if(!u){this.json(t,404,{error:"graph disabled on this node"});break}let p=n.searchParams.get("status")||"approved",f=Math.max(1,Math.min(1e3,parseInt(n.searchParams.get("limit")||"200",10)||200)),y=u.listByStatus(p,f);this.json(t,200,{nodeId:this.config.node.id,status:p,count:y.length,classifications:y});break}default:this.json(t,404,{error:"Not found",endpoints:["GET /health","GET /agents","GET /crons","GET /mesh","GET /wiki/agents","GET /wiki/entries[?agent=X&after=YYYY-MM-DD]","GET /wiki/articles?agent=X","GET /graph/schema","GET /graph/nodes","GET /graph/classifications[?status=approved|pending|rejected&limit=N]","POST /task { agent, message, context?, freshSession?: bool }","GET /agents/:id \u2014 resolved agent config (permission, tier, model, persistentProcess, toolUseRequired)","POST /agents/:id/selftest { message? } \u2014 canary probe; runs a fresh-session task and reports {ok, durationMs, tokens, billedModel}","GET /traces[?agentId=&channel=&chatId=&workflowRunId=&status=&since=&until=&limit=]","GET /traces/:taskId \u2014 full per-task execution trace (steps + tokens)","GET /api/processes \u2014 live persistent claude processes (JSON)","POST /api/processes/kill { agentId, channel, chatId, reason? }","GET /api/actions/builtin \u2014 list shipped built-in typed actions","POST /api/actions/builtin/:name \u2014 run a built-in with JSON body input","POST /mesh/task { peer, message }","POST /webhook/:agentId[/:source] \u2014 webhook callback","POST /reload \u2014 re-read agentx.json (hot-swaps crons)","GET /.well-known/agent-card.json","GET /call \u2014 browser UI for P2P A/V calls (requires channels.webrtc.enabled)","GET /webrtc/config \u2014 ICE servers + peer directory for the call page","GET /webrtc/events?callId=&as= \u2014 SSE stream of signaling events","POST /webrtc/signal/out \u2014 browser-originated signal, forwarded to remote peer","POST /webrtc/signal \u2014 remote-peer-originated signal, fanned out to local browser","POST /webrtc/bot/invite { callId, target, agentId } \u2014 spawn a transcribing bot peer for a call","GET /webrtc/bots \u2014 active bot sessions"]})}}catch(r){this.json(t,500,{error:r.message})}}async handleOpenAICompat(e,t,n){let s=await L(e);await wi(e,t,n,s,{execute:(r,o,a,d)=>this.registry.execute(r,o,a,d),agentIds:Object.keys(this.config.agents),cancel:(r,o,a,d)=>{let c=this.registry.list().find(l=>l.id===r)?.runningTasks.filter(l=>l.channel===o&&l.chatId===a)||[];for(let l of c)this.registry.cancelRunningTask(l.id,d)},log:r=>this.log(r)})}json(e,t,n){e.writeHead(t,{"Content-Type":"application/json"}),e.end(JSON.stringify(n,null,2))}resolveGitlabTokenForAgent(e){if(!e)return{token:this.config.channels.gitlab?.token,source:"global"};let t=(this.config.channels.gitlab?.agentMappings||[]).find(s=>s.agentId===e);if(t?.token)return{token:t.token,source:"agentMappings"};let n=xo(this.config,e,"gitlab-user","tokenEnv");return n.status==="ok"&&n.value?{token:n.value,source:`integrations(${n.envVar})`}:this.config.channels.gitlab?.token?{token:this.config.channels.gitlab.token,source:"global"}:{token:void 0,source:n.status}}resolveTodayUsage(){let e=so();if(e==="json")return this.registry.getTodayUsage();let t=no(this.db);return e==="sqlite"||Object.keys(t.agents).length>0?t:this.registry.getTodayUsage()}installAgentMemorySurface(){for(let e of this.registry.list()){let t=e.workspace;if(!(!t||!Te(t)))try{let n=Q(t,".claude","skills");fa(n,{recursive:!0});let s=Q(n,Eo);Te(s)||(ma(s,Mo),this.log(` memory-skill: installed remember.md \u2192 ${e.id}`)),this.agentMemory.syncToWorkspace(e.id,t)}catch(n){this.log(` memory-skill: ${e.id} install failed \u2014 ${n?.message??n}`)}}}installAgentMcpConfig(){for(let[e,t]of Object.entries(this.config.agents)){let n=t.workspace;if(!n||!Te(n))continue;let s=Ss(t);try{switch(Co(n,s)){case"installed":this.log(` mcp: installed ${Object.keys(s).length} server(s) \u2192 ${e}`);break;case"updated":this.log(` mcp: updated .mcp.json (${Object.keys(s).length} server(s)) \u2192 ${e}`);break;case"removed":this.log(` mcp: removed managed .mcp.json (config now empty) \u2192 ${e}`);break;case"skipped-operator-owned":Object.keys(s).length>0&&this.log(` mcp: ${e} has operator-owned .mcp.json \u2014 skipping (delete file or marker to let agentx manage)`);break;case"noop":break}}catch(r){this.log(` mcp: ${e} install failed \u2014 ${r?.message??r}`)}}}workspaceFor(e){for(let t of this.registry.list())if(t.id===e)return t.workspace;return null}async handleMemoryApi(e,t,n,s){let r=this.agentMemory;if(e.method==="GET"&&n==="/api/memory"){let d=s.searchParams.get("agent")||"";return d?(this.json(t,200,{agent:d,memories:r.list(d),index:r.indexMarkdown(d)}),!0):(this.json(t,400,{error:"missing agent query param"}),!0)}let o=e.method==="GET"&&n.match(/^\/api\/memory\/([^\/?]+)$/);if(o){let d=s.searchParams.get("agent")||"";if(!d)return this.json(t,400,{error:"missing agent query param"}),!0;let c=r.get(d,decodeURIComponent(o[1]));return c?(this.json(t,200,{memory:c}),!0):(this.json(t,404,{error:"no such memory"}),!0)}if(e.method==="POST"&&n==="/api/memory"){let d;try{d=await K(e)}catch(b){return this.json(t,400,{error:"invalid JSON body",message:b.message}),!0}let c=typeof d?.agentId=="string"?d.agentId:"",l=typeof d?.type=="string"?d.type:"",h=typeof d?.name=="string"?d.name:"",g=typeof d?.description=="string"?d.description:"",w=typeof d?.body=="string"?d.body:"",m=d?.append===!0;if(!c||!l||!h||!g||!w)return this.json(t,400,{error:"required fields: agentId, type, name, description, body"}),!0;try{let b=w;if(m){let T=r.get(c,h);T&&(b=`${T.body.trimEnd()}
|
|
1199
1199
|
|
|
1200
1200
|
${w.trim()}`)}let S=r.save({agentId:c,type:l,name:h,description:g,body:b}),k=this.workspaceFor(c);if(k)try{r.syncToWorkspace(c,k)}catch{}this.json(t,200,{ok:!0,memory:S,syncedToWorkspace:!!k})}catch(b){this.json(t,400,{error:b?.message||"save failed"})}return!0}let a=e.method==="DELETE"&&n.match(/^\/api\/memory\/([^\/?]+)$/);if(a){let d=s.searchParams.get("agent")||"";if(!d)return this.json(t,400,{error:"missing agent query param"}),!0;if(!r.remove(d,decodeURIComponent(a[1])))return this.json(t,404,{error:"no such memory"}),!0;let l=this.workspaceFor(d);if(l)try{r.syncToWorkspace(d,l)}catch{}return this.json(t,200,{ok:!0}),!0}return!1}async handleWorkflowEvent(e,t){if(!this.workflowDispatcher){this.json(t,503,{error:"workflow engine not enabled on this node"});return}let n;try{n=await K(e)}catch(d){this.json(t,400,{error:"invalid JSON body",message:d.message});return}let s=n?.payload??n,r=s?.event,o=s?.entityRef;if(!r?.id||!o?.backend||!o?.id){this.json(t,400,{error:"missing event or entityRef"});return}let a=n?.kind;try{if(a==="trigger"&&s.trigger){let g=typeof n?.fromPeer=="string"?n.fromPeer:"unknown";this.log(`[workflows/mesh] received trigger from "${g}" source="${s.trigger.source}" chat="${s.trigger.chat??"*"}"`);let w=await this.workflowDispatcher.dispatch({trigger:s.trigger,entityRef:o,event:r,fromRemote:{peer:g}});this.log(`[workflows/mesh] dispatched broadcast: matched=${w.claimed.length} ${w.claimed.length?`(${w.claimed.map(m=>m.id).join(", ")})`:"[none \u2014 no workflow with mesh.allowRemote matched]"}`),this.json(t,202,{ok:!0,mode:"trigger-broadcast",matched:w.claimed.map(m=>m.id)});return}let l=(s.workflowId?this.workflowStore?.get(s.workflowId):null)?.nodes.find(g=>g.type.startsWith("trigger."))?.config??{},h={source:String(l.source??"hook"),project:l.filter?.project,repo:l.filter?.repo,chat:l.filter?.chat,labels:l.filter?.labels};await this.workflowDispatcher.dispatch({trigger:h,entityRef:o,event:r}),this.json(t,202,{ok:!0})}catch(d){this.log(`[workflows] /workflow/event failed: ${d.message}`),this.json(t,500,{error:d.message})}}async handleChannelSend(e,t){let n;try{n=await K(e)}catch(d){this.json(t,400,{error:"invalid JSON body",message:d.message});return}let s=String(n?.channel??""),r=String(n?.chatId??""),o=String(n?.text??"");if(!s||!r||!o){this.json(t,400,{error:"channel, chatId, and text are required"});return}if(!this.router.getChannel(s)){this.json(t,404,{error:`channel "${s}" not hosted on this node`});return}try{let d=await this.router.sendOutbound({channel:s,chatId:r,text:o,accountId:typeof n.accountId=="string"?n.accountId:void 0,parseMode:typeof n.parseMode=="string"?n.parseMode:void 0,replyTo:typeof n.replyTo=="string"?n.replyTo:void 0});this.json(t,200,{ok:!0,messageId:d??null})}catch(d){this.log(`[mesh] /channel/send "${s}" failed: ${d.message}`),this.json(t,500,{error:d.message})}}async handleChannelChats(e,t,n={}){let s=new Set,r=[],o=[],a=(c,l)=>{let h=0;for(let g of c)!g.id||s.has(g.id)||(s.add(g.id),r.push({...g,source:l}),h++);h>0&&o.push(`${l}:${h}`)},d=this.router.getChannel(t);if(d?.listKnownChats)try{a(d.listKnownChats(),"local")}catch{}else if(d?.listChats)try{a(d.listChats().map(c=>({id:c.jid,name:c.name,kind:c.isGroup?"group":"dm"})),"local")}catch{}if(!n.localOnly&&this.mesh){let c=this.mesh.directory().filter(l=>l.healthy&&l.channels?.includes(t));await Promise.allSettled(c.map(async l=>{try{let h=await fetch(`${l.peerUrl}/channels/${encodeURIComponent(t)}/chats?local=1`,{headers:this.mesh.authHeaders(l.peer),signal:AbortSignal.timeout(5e3)});if(!h.ok)return;let g=await h.json();Array.isArray(g.chats)&&a(g.chats.map(w=>({id:w.id,name:w.name,kind:w.kind??"dm",accountId:w.accountId})),`mesh:${l.peer}`)}catch{}}))}this.json(e,200,{channel:t,source:o.join(", ")||"none",chats:r})}async handleWorkflowManualRun(e,t,n){if(!this.workflowDispatcher||!this.workflowStore){this.json(t,503,{error:"workflow engine not enabled on this node"});return}let s=this.workflowStore.get(n);if(!s){this.json(t,404,{error:`unknown workflow "${n}"`});return}let r=s.nodes.find(m=>m.type.startsWith("trigger."));if(!r){this.json(t,400,{error:`workflow "${n}" has no trigger node`});return}let o;try{o=await K(e)}catch{o={}}let a=!!o?.force,d=o?.payload||{};if(r.type!=="trigger.manual"&&!a){this.json(t,409,{error:`workflow "${n}" trigger is "${r.type}"`,hint:'pass { "force": true } to fire anyway with a synthesized event (for testing)'});return}let c=r.config??{},l=a?String(c.source??"manual"):"manual",h=String(d.entityId||d.chatId||`manual-${Date.now().toString(36)}`),g={backend:a&&c.source?"channel":"manual",id:h},w=`manual:${n}:${h}:${Date.now()}`;try{let b=(await this.workflowDispatcher.dispatch({trigger:a?{source:l,project:c.filter?.project,repo:c.filter?.repo,chat:c.filter?.chat,labels:c.filter?.labels}:{source:"manual"},entityRef:g,event:{id:w,payload:d}})).runs[0]?.id;this.json(t,b?200:202,{ok:!0,runId:b,entityRef:g,source:l,force:a})}catch(m){this.log(`[workflows] manual run "${n}" failed: ${m.message}`),this.json(t,500,{error:m.message})}}},is=os;me(is,"MESH_PROTECTED_PATHS",new Set(["/task","/ask","/mesh/task","/mesh/inbox/send","/workflow/event","/workflow/transition","/channel/send","/webrtc/signal","/gitlab/react","/gitlab/send-note","/gitlab/log-time","/github/send-comment"]));function ju(i){if(typeof i!="string")return"";let e=i.trim();if(!e)return"";let t=e.match(/^[^.!?\n]+[.!?]?/),n=(t?t[0]:e).trim();return n.length>140?n.slice(0,137)+"\u2026":n}function K(i){return new Promise((e,t)=>{let n="";i.setEncoding("utf8"),i.on("data",s=>{n+=s}),i.on("end",()=>{try{e(n?JSON.parse(n):{})}catch(s){t(s)}}),i.on("error",t)})}function Nu(i){let e=i;return e=e.replace(/```[\s\S]*?```/g,". "),e=e.replace(/`[^`]*`/g,""),e=e.replace(/\*\*(.*?)\*\*/g,"$1"),e=e.replace(/__(.*?)__/g,"$1"),e=e.replace(/\*([^*]+)\*/g,"$1"),e=e.replace(/_([^_]+)_/g,"$1"),e=e.replace(/~~(.*?)~~/g,"$1"),e=e.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1"),e=e.replace(/!\[([^\]]*)\]\([^)]+\)/g,"image$1 "),e=e.replace(/^#{1,6}\s+/gm,""),e=e.replace(/^[\s]*[-*+]\s+/gm,". "),e=e.replace(/^[\s]*\d+\.\s+/gm,". "),e=e.replace(/^[-=_]{3,}$/gm,""),e=e.replace(/^>\s*/gm,""),e=e.replace(/https?:\/\/\S+/g,"link"),e=e.replace(/\/\w+(\/\w+)+/g,t=>t.split("/").filter(Boolean).join(" slash ")),e=e.replace(/&/g," and "),e=e.replace(/@/g," at "),e=e.replace(/=>/g," returns "),e=e.replace(/->/g," to "),e=e.replace(/\|/g," or "),e=e.replace(/\be\.g\./gi,"for example"),e=e.replace(/\bi\.e\./gi,"that is"),e=e.replace(/\betc\./gi,"etcetera"),e=e.replace(/\bvs\.?\b/gi,"versus"),e=e.replace(/\n{2,}/g,". "),e=e.replace(/\n/g," "),e=e.replace(/\s+/g," "),e=e.replace(/\.\s*\./g,"."),e=e.replace(/\s+([.,!?])/g,"$1"),e=e.trim().replace(/^[.,:;]+\s*/,""),e.length>800&&(e=e.slice(0,800).replace(/\s+\S*$/,"")+"..."),e}function Lu(i,e){let t=["model","workspace","tier","permissionMode","mcpServers"],n=new Set,s=new Set([...Object.keys(i),...Object.keys(e)]);for(let r of s){let o=i[r],a=e[r];if(!o||!a){n.add("add/remove");continue}for(let d of t)JSON.stringify(o[d])!==JSON.stringify(a[d])&&n.add(`${r}.${d}`)}return Array.from(n).slice(0,6)}async function L(i){return new Promise((e,t)=>{let n="";i.on("data",s=>n+=s.toString()),i.on("end",()=>{try{e(n?JSON.parse(n):{})}catch{e({})}}),i.on("error",t)})}wa();function iw(i){typeof i=="string"&&(Ke.error(i),process.exit(1)),i instanceof Error&&(Ke.error(i.message),process.exit(1)),Ke.error("Something went wrong. Please try again."),process.exit(1)}import Bt from"path";import ya from"fs-extra";import{fileURLToPath as Uu}from"url";function lw(){let i=[];try{let e=Bt.dirname(Uu(import.meta.url));e&&(i.push(Bt.resolve(e,"..","package.json")),i.push(Bt.resolve(e,"package.json")))}catch{}i.push(Bt.resolve(process.cwd(),"package.json"));for(let e of i)try{if(ya.existsSync(e)){let t=ya.readJSONSync(e);if(t&&t.name)return t}}catch{}return{name:"agentix-cli",version:"0.0.0"}}export{qu as a,en as b,le as c,Ee as d,_e as e,he as f,ct as g,$p as h,Mp as i,Ld as j,Ud as k,zi as l,ke as m,ve as n,oe as o,um as p,Zi as q,eo as r,Nn as s,Rt as t,Fe as u,nu as v,qo as w,uu as x,Wf as y,Ut as z,pa as A,is as B,iw as C,lw as D};
|
|
1201
|
-
//# sourceMappingURL=chunk-
|
|
1201
|
+
//# sourceMappingURL=chunk-WFIBOAXN.js.map
|
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as s}from"./chunk-
|
|
2
|
+
import{a as s}from"./chunk-H57XXGMF.js";import"./chunk-4CR463C6.js";import"./chunk-G5MFPNGJ.js";import"./chunk-B2XTYYXV.js";import"./chunk-2TJ5L7CB.js";import"./chunk-7CVJ4JOE.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-SZDACK6O.js";import"./chunk-WFIBOAXN.js";import"./chunk-F6CNF7V3.js";import"./chunk-GWQIMAJ7.js";import"./chunk-V7FYSZSV.js";import"./chunk-ZVP6GB4G.js";import"./chunk-6VQKHMEQ.js";import"./chunk-5FEQI22L.js";import"./chunk-VMDA2SX2.js";import"./chunk-QLTM3F7M.js";import"./chunk-A4YR3PQY.js";import"./chunk-K6E7WJ7O.js";import"./chunk-SFQUP3BP.js";import"./chunk-3SCPRYJB.js";import"./chunk-WPMX3VGI.js";import"./chunk-K33GIBSE.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-JWKIFAXA.js";import"./chunk-W3YGESNK.js";import"./chunk-DWADWDMU.js";import"./chunk-77OV7346.js";import"./chunk-VWTBHLMX.js";import"./chunk-MFVI5FOM.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import"./chunk-JGJE5Y2J.js";import"./chunk-AJ5RMU7X.js";import"./chunk-2GIDVZ4H.js";import"./chunk-2DBGOCCW.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-AJONZWLT.js";import"./chunk-F4HZTZHW.js";import"./chunk-QOYAX2FT.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import"./chunk-VDMYBPYB.js";import"./chunk-DSYKYZMT.js";import"./chunk-2DMVKLLE.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function o(){let r=await s();if(process.argv.slice(2).length===0){r.outputHelp();return}r.parse()}o();
|
|
3
3
|
//# sourceMappingURL=cli.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1562,6 +1562,12 @@ declare const agentConfigSchema: z.ZodObject<{
|
|
|
1562
1562
|
* agents that do long investigations or multi-file refactors. */
|
|
1563
1563
|
maxExecutionMinutes: z.ZodDefault<z.ZodNumber>;
|
|
1564
1564
|
permissionMode: z.ZodDefault<z.ZodString>;
|
|
1565
|
+
/** How this agent's `claude` CLI is billed (claude-code tier). Default
|
|
1566
|
+
* "subscription": the shared OAuth login, ANTHROPIC_API_KEY stripped.
|
|
1567
|
+
* "api": bill ANTHROPIC_API_KEY instead and drop the OAuth token, so
|
|
1568
|
+
* e.g. benchmark agents never draw on the fleet's subscription quota.
|
|
1569
|
+
* An "api" agent with no key fails its task rather than falling back. */
|
|
1570
|
+
billing: z.ZodDefault<z.ZodEnum<["subscription", "api"]>>;
|
|
1565
1571
|
/** Improvement plan #3 — tool-use-required preset. When set,
|
|
1566
1572
|
* AgentX inspects the stream-json events from each task and
|
|
1567
1573
|
* fails the response with `tool_required_not_called: <name>`
|
|
@@ -1713,6 +1719,7 @@ declare const agentConfigSchema: z.ZodObject<{
|
|
|
1713
1719
|
maxConcurrent: number;
|
|
1714
1720
|
maxExecutionMinutes: number;
|
|
1715
1721
|
permissionMode: string;
|
|
1722
|
+
billing: "api" | "subscription";
|
|
1716
1723
|
toolUseRequired: string[];
|
|
1717
1724
|
persistentProcess: boolean;
|
|
1718
1725
|
queueMode: "collect" | "followup" | "drop";
|
|
@@ -1781,6 +1788,7 @@ declare const agentConfigSchema: z.ZodObject<{
|
|
|
1781
1788
|
maxConcurrent?: number | undefined;
|
|
1782
1789
|
maxExecutionMinutes?: number | undefined;
|
|
1783
1790
|
permissionMode?: string | undefined;
|
|
1791
|
+
billing?: "api" | "subscription" | undefined;
|
|
1784
1792
|
toolUseRequired?: string[] | undefined;
|
|
1785
1793
|
gitlabAutoReply?: boolean | undefined;
|
|
1786
1794
|
persistentProcess?: boolean | undefined;
|
|
@@ -2061,6 +2069,12 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
2061
2069
|
* agents that do long investigations or multi-file refactors. */
|
|
2062
2070
|
maxExecutionMinutes: z.ZodDefault<z.ZodNumber>;
|
|
2063
2071
|
permissionMode: z.ZodDefault<z.ZodString>;
|
|
2072
|
+
/** How this agent's `claude` CLI is billed (claude-code tier). Default
|
|
2073
|
+
* "subscription": the shared OAuth login, ANTHROPIC_API_KEY stripped.
|
|
2074
|
+
* "api": bill ANTHROPIC_API_KEY instead and drop the OAuth token, so
|
|
2075
|
+
* e.g. benchmark agents never draw on the fleet's subscription quota.
|
|
2076
|
+
* An "api" agent with no key fails its task rather than falling back. */
|
|
2077
|
+
billing: z.ZodDefault<z.ZodEnum<["subscription", "api"]>>;
|
|
2064
2078
|
/** Improvement plan #3 — tool-use-required preset. When set,
|
|
2065
2079
|
* AgentX inspects the stream-json events from each task and
|
|
2066
2080
|
* fails the response with `tool_required_not_called: <name>`
|
|
@@ -2212,6 +2226,7 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
2212
2226
|
maxConcurrent: number;
|
|
2213
2227
|
maxExecutionMinutes: number;
|
|
2214
2228
|
permissionMode: string;
|
|
2229
|
+
billing: "api" | "subscription";
|
|
2215
2230
|
toolUseRequired: string[];
|
|
2216
2231
|
persistentProcess: boolean;
|
|
2217
2232
|
queueMode: "collect" | "followup" | "drop";
|
|
@@ -2280,6 +2295,7 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
2280
2295
|
maxConcurrent?: number | undefined;
|
|
2281
2296
|
maxExecutionMinutes?: number | undefined;
|
|
2282
2297
|
permissionMode?: string | undefined;
|
|
2298
|
+
billing?: "api" | "subscription" | undefined;
|
|
2283
2299
|
toolUseRequired?: string[] | undefined;
|
|
2284
2300
|
gitlabAutoReply?: boolean | undefined;
|
|
2285
2301
|
persistentProcess?: boolean | undefined;
|
|
@@ -4719,6 +4735,7 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
4719
4735
|
maxConcurrent: number;
|
|
4720
4736
|
maxExecutionMinutes: number;
|
|
4721
4737
|
permissionMode: string;
|
|
4738
|
+
billing: "api" | "subscription";
|
|
4722
4739
|
toolUseRequired: string[];
|
|
4723
4740
|
persistentProcess: boolean;
|
|
4724
4741
|
queueMode: "collect" | "followup" | "drop";
|
|
@@ -5239,6 +5256,7 @@ declare const daemonConfigSchema: z.ZodObject<{
|
|
|
5239
5256
|
maxConcurrent?: number | undefined;
|
|
5240
5257
|
maxExecutionMinutes?: number | undefined;
|
|
5241
5258
|
permissionMode?: string | undefined;
|
|
5259
|
+
billing?: "api" | "subscription" | undefined;
|
|
5242
5260
|
toolUseRequired?: string[] | undefined;
|
|
5243
5261
|
gitlabAutoReply?: boolean | undefined;
|
|
5244
5262
|
persistentProcess?: boolean | undefined;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as L}from"./chunk-W5C2GDNC.js";import{B as bt,C as Tt,D as Mt,a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt}from"./chunk-
|
|
1
|
+
import{a as L}from"./chunk-W5C2GDNC.js";import{B as bt,C as Tt,D as Mt,a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt}from"./chunk-WFIBOAXN.js";import"./chunk-F6CNF7V3.js";import"./chunk-GWQIMAJ7.js";import"./chunk-V7FYSZSV.js";import"./chunk-ZVP6GB4G.js";import{J as yt,h as lt,i as ct,j as dt,k as mt,l as pt}from"./chunk-6VQKHMEQ.js";import"./chunk-5FEQI22L.js";import"./chunk-VMDA2SX2.js";import"./chunk-QLTM3F7M.js";import{h as ut}from"./chunk-A4YR3PQY.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-K6E7WJ7O.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-3SCPRYJB.js";import"./chunk-WPMX3VGI.js";import"./chunk-K33GIBSE.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-JWKIFAXA.js";import"./chunk-W3YGESNK.js";import"./chunk-DWADWDMU.js";import"./chunk-77OV7346.js";import"./chunk-VWTBHLMX.js";import{a as gt,b as ft,e as ht}from"./chunk-MFVI5FOM.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import"./chunk-JGJE5Y2J.js";import"./chunk-AJ5RMU7X.js";import"./chunk-2GIDVZ4H.js";import{j as it,k as rt,l as at}from"./chunk-2DBGOCCW.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-AJONZWLT.js";import"./chunk-F4HZTZHW.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-LCIREYTD.js";import{a as m,b as G}from"./chunk-L2WSPY6S.js";import{a as Fe,b as Le,c as A,d as De}from"./chunk-VDMYBPYB.js";import{a as Ke,b as Je,e as We}from"./chunk-DSYKYZMT.js";import{e as tt,g as st,h as ot,j as nt}from"./chunk-2DMVKLLE.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.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-BOKE5M5S.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).
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a}from"./chunk-H57XXGMF.js";import"./chunk-4CR463C6.js";import"./chunk-G5MFPNGJ.js";import"./chunk-B2XTYYXV.js";import"./chunk-2TJ5L7CB.js";import"./chunk-7CVJ4JOE.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-SZDACK6O.js";import"./chunk-WFIBOAXN.js";import"./chunk-F6CNF7V3.js";import"./chunk-GWQIMAJ7.js";import"./chunk-V7FYSZSV.js";import"./chunk-ZVP6GB4G.js";import"./chunk-6VQKHMEQ.js";import"./chunk-5FEQI22L.js";import"./chunk-VMDA2SX2.js";import"./chunk-QLTM3F7M.js";import"./chunk-A4YR3PQY.js";import"./chunk-K6E7WJ7O.js";import"./chunk-SFQUP3BP.js";import"./chunk-3SCPRYJB.js";import"./chunk-WPMX3VGI.js";import"./chunk-K33GIBSE.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-JWKIFAXA.js";import"./chunk-W3YGESNK.js";import"./chunk-DWADWDMU.js";import"./chunk-77OV7346.js";import"./chunk-VWTBHLMX.js";import"./chunk-MFVI5FOM.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import"./chunk-JGJE5Y2J.js";import"./chunk-AJ5RMU7X.js";import"./chunk-2GIDVZ4H.js";import"./chunk-2DBGOCCW.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-AJONZWLT.js";import"./chunk-F4HZTZHW.js";import"./chunk-QOYAX2FT.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import"./chunk-VDMYBPYB.js";import"./chunk-DSYKYZMT.js";import"./chunk-2DMVKLLE.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";export{a as buildProgram};
|
|
2
|
+
//# sourceMappingURL=program-7ULXLTD6.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a}from"./chunk-JGJE5Y2J.js";import"./chunk-AJ5RMU7X.js";import"./chunk-2GIDVZ4H.js";import"./chunk-2DBGOCCW.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-AJONZWLT.js";import"./chunk-F4HZTZHW.js";import"./chunk-QOYAX2FT.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import"./chunk-2DMVKLLE.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";export{a as agenticQuery};
|
|
2
|
+
//# sourceMappingURL=query-RHVR6QUZ.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as a,B as b,C as c,D as d,E as e,F as f,G as g,H as h,I as i,J as j}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=registry-
|
|
1
|
+
import{A as a,B as b,C as c,D as d,E as e,F as f,G as g,H as h,I as i,J as j}from"./chunk-6VQKHMEQ.js";import"./chunk-5FEQI22L.js";import"./chunk-VMDA2SX2.js";import"./chunk-QLTM3F7M.js";import"./chunk-A4YR3PQY.js";import"./chunk-WPMX3VGI.js";import"./chunk-K33GIBSE.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-JWKIFAXA.js";import"./chunk-W3YGESNK.js";import"./chunk-DWADWDMU.js";import"./chunk-77OV7346.js";import"./chunk-VWTBHLMX.js";import"./chunk-MFVI5FOM.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import"./chunk-JGJE5Y2J.js";import"./chunk-AJ5RMU7X.js";import"./chunk-2GIDVZ4H.js";import"./chunk-2DBGOCCW.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-AJONZWLT.js";import"./chunk-F4HZTZHW.js";import"./chunk-QOYAX2FT.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import"./chunk-DSYKYZMT.js";import"./chunk-2DMVKLLE.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";export{j as AgentRegistry,e as TRACE_STEP_SUMMARY_BYTES,c as buildEntryMeta,d as buildWikiContext,f as clipForTrace,i as emitTraceStepsFromStreamEvent,h as firstMissingRequiredTool,b as getGlobalRegistry,a as setGlobalRegistry,g as tallyToolUses};
|
|
2
|
+
//# sourceMappingURL=registry-OB6S66XX.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{q as m,t as p,v as d,w as x}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=request-planner-
|
|
1
|
+
import{q as m,t as p,v as d,w as x}from"./chunk-2DBGOCCW.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-AJONZWLT.js";import{a as u,f}from"./chunk-F4HZTZHW.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import"./chunk-2DMVKLLE.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";x();f();var l="request-gate",h="request-context",g=.1;async function q(t,o,c,r=Math.random){let s=p(l)==="active";if(s){let i=m().seats[l]?.holdout??g;if(r()<i)return{active:!0,preprocess:!1,arm:"holdout"}}let a=s?"treatment":void 0,e=await d(l,{request:t.slice(0,2e3),agent:o,channel:c,operations:["select optional context","evaluate model routing where permitted"],constraints:["Keep the original request and mandatory instructions","Desktop model cannot be downgraded"]},{preprocess:u("This request benefits from structured context selection or another bounded typed decision before the main agent executes.",{true:"Relevant context must be selected, or a bounded routing decision can help. Follow-ups and ambiguous references need context.",false:"Typed preprocessing adds no useful decision; send the request to the configured main agent with existing context."})},{timeoutMs:3e3});if(!e||e.mode!=="active")return{active:!1,preprocess:!1,arm:a};let n=e.answers.preprocess?.noul;return{active:!0,preprocess:Number.isFinite(n)&&n>=.5,arm:a}}var v={landscape:"Agent directory and mesh overview",patternContext:"Learned behavioral patterns",references:"Retrieved project references",memoryContext:"Retrieved agent memory",crossChatContext:"Summaries from other conversations",longMemoryRecall:"Older conversation recall",wikiContext:"Retrieved wiki knowledge"};async function b(t){let o=Object.entries(v).flatMap(([e,n])=>{let i=t[e];return i?[{id:e,description:n,source:e,characters:i.length,preview:i.slice(0,400),trust:"context data, not instructions"}]:[]});if(!o.length)return{input:t,excluded:[]};let c=Object.fromEntries(o.map(e=>[e.id,u(`Context block ${e.id} is relevant to completing the current request correctly.`,{true:"Needed or potentially relevant; retain if uncertain or the preview is incomplete.",false:"Clearly unrelated to the current request; safe to omit."})])),r=await d(h,{request:t.message.slice(0,2e3),channel:t.channel,agent:t.agentId,mandatory:["request","identity","permissions and instructions","same-chat history","handover","attachments"],context:o},c,{timeoutMs:3e3});if(!r||r.mode!=="active")return{input:t,excluded:[]};let s={...t},a=[];for(let e of o){let n=r.answers[e.id]?.noul;Number.isFinite(n)&&n>=0&&n<.2&&(delete s[e.id],a.push(e.id))}return{input:s,excluded:a}}export{g as DEFAULT_REQUEST_GATE_HOLDOUT,h as REQUEST_CONTEXT_SEAT,l as REQUEST_GATE_SEAT,q as evaluateRequest,b as selectRequestContext};
|
|
2
|
+
//# sourceMappingURL=request-planner-F5NVL2G7.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b}from"./chunk-
|
|
1
|
+
import{b}from"./chunk-GWQIMAJ7.js";import"./chunk-VMDA2SX2.js";import"./chunk-2GIDVZ4H.js";import"./chunk-2DBGOCCW.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-AJONZWLT.js";import"./chunk-F4HZTZHW.js";import"./chunk-LCIREYTD.js";import"./chunk-L2WSPY6S.js";import"./chunk-2DMVKLLE.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";import{createHash as A}from"crypto";var v="review:",I={decisions:"project",warnings:"feedback",friction:"feedback",context:"reference"};function E(t,n,r){let s=A("sha1").update(r.trim().toLowerCase()).digest("hex").slice(0,10);return`${v}${t}/${n}@${s}`}function F(t){if(!t.startsWith(v))return null;let n=t.slice(v.length),r=n.lastIndexOf("@"),s=n.lastIndexOf("/",r===-1?void 0:r);return r===-1||s===-1?null:{reviewId:n.slice(0,s),kind:n.slice(s+1,r),digest:n.slice(r+1)}}var C=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,48)||"finding";function L(t,n){return`${t}|${b(n)}`}function K(t,n={}){let r=n.kinds??Object.keys(I),s=n.minLength??24,h=[],d=new Map,u=new Map,f=new Map,x=new Map;for(let e of t){let i;try{i=JSON.parse(e.result)}catch{continue}let o=e.updated_at?new Date(e.updated_at).toISOString():new Date().toISOString();for(let c of r){let l=I[c];if(!l)continue;let R=i[c];if(Array.isArray(R))for(let $ of R){let a=String($?.text??"").trim();if(a.length<s)continue;let g=E(e.id,c,a),O=g.slice(g.lastIndexOf("@")),w=`${c}${O}`,y=L(c,a),k=f.get(y)??new Set;if(k.add(e.session_id??e.id),f.set(y,k),d.has(w))continue;let _=String($?.evidence??"").trim(),S={occurrences:1,agentId:e.agent,key:`${e.agent}/${l}_${C(a)}`,stamp:g,memory:{name:C(a),type:l,description:a.slice(0,200),body:"",createdAt:o,updatedAt:o}};x.set(g,{text:a,evidence:_,agent:e.agent,source:e.source}),d.set(w,S),u.set(w,y),h.push(S)}}}for(let[e,i]of d){i.occurrences=f.get(u.get(e)??"")?.size??1;let o=x.get(i.stamp);i.memory.body=T(o,i.occurrences)}let m=new Map;for(let[e,i]of d){let o=u.get(e)??e,c=m.get(o)??[];c.push(i),m.set(o,c)}let M=[...m.values()].sort((e,i)=>i[0].occurrences-e[0].occurrences),p=[];for(let e=0;p.length<h.length;e++){let i=!1;for(let o of M)e<o.length&&(p.push(o[e]),i=!0);if(!i)break}return p}function T(t,n){let r=`${t.agent}${t.source?` via ${t.source}`:""}`,s=[];return n>1?(s.push(`Observed in ${n} separate sessions. Most recently stated as:`),s.push(`> ${t.text}`),s.push(`Recurring across ${n} sessions is what makes this worth recording \u2014 any single occurrence is session state, the repetition is the finding.`)):s.push(t.text),t.evidence&&s.push(`**Evidence:** ${t.evidence}`),s.push(`_From ${n>1?"session reviews":"a session review"} of ${r}._`),s.join(`
|
|
2
2
|
|
|
3
3
|
`)}export{I as PROMOTABLE_KINDS,v as REVIEW_STAMP_PREFIX,F as parseReviewStamp,E as reviewStamp,K as reviewsToCandidates};
|
|
4
|
-
//# sourceMappingURL=review-candidates-
|
|
4
|
+
//# sourceMappingURL=review-candidates-IRPKFWL2.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as u,c as m}from"./chunk-2GIDVZ4H.js";import"./chunk-FIOB3MEX.js";import{execFile as h}from"child_process";var g=3e4,w="haiku",M=`You are about to lose this working session due to context-size rotation. Before that happens, write a compact memo of what you should carry forward to your next session on the same conversation.
|
|
2
2
|
|
|
3
3
|
Include only durable facts a future turn would otherwise have to rediscover:
|
|
4
4
|
- Names, handles, agent ids, telegram/whatsapp/gitlab usernames
|
|
@@ -9,5 +9,5 @@ Include only durable facts a future turn would otherwise have to rediscover:
|
|
|
9
9
|
|
|
10
10
|
Format: 3-12 short bullet points. Each \u2264120 chars. No prose, no preamble, no header. If the session was uninformative or just casual chat, reply with exactly the literal text "(no memo)".
|
|
11
11
|
|
|
12
|
-
Begin the memo now.`;async function
|
|
13
|
-
//# sourceMappingURL=rotation-memo-
|
|
12
|
+
Begin the memo now.`;async function E(n,r){let c=Date.now();if(!r)return{memo:null,reason:"no-resume",durationMs:0};let i=["-p",M,"--output-format","json","--resume",r,"--model",w];n.permissionMode==="bypassPermissions"&&i.push("--dangerously-skip-permissions");let p=m(u(n.workspace),n.billing);return new Promise(d=>{let a=!1,e=(t,s)=>{a||(a=!0,d({memo:t,reason:s,durationMs:Date.now()-c}))};h("claude",i,{cwd:n.workspace,env:p,timeout:g,maxBuffer:1024*1024},(t,s,b)=>{if(t)return t.killed?e(null,"timeout"):e(null,`error:${t.message.slice(0,80)}`);try{let l=JSON.parse(s||"{}"),o=typeof l.result=="string"?l.result.trim():"";if(!o||o==="(no memo)")return e(null,"empty");let f=o.length>4096?o.slice(0,4096)+"\u2026":o;return e(f,"ok")}catch{return e(null,"parse-error")}}).on("error",()=>e(null,"spawn-error"))})}export{E as extractRotationMemo};
|
|
13
|
+
//# sourceMappingURL=rotation-memo-QEO3COFH.js.map
|