agentix-cli 0.81.0 → 0.81.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/mac-voice/Sources/AgentXVoice/CallModel.swift +11 -0
- package/apps/mac-voice/Sources/AgentXVoice/Calls.swift +7 -4
- package/apps/mac-voice/Sources/AgentXVoice/main.swift +15 -3
- package/dist/{agent-BDEPUFBQ.js → agent-75URYGWI.js} +2 -2
- package/dist/{chunk-ZDDJNKU5.js → chunk-3FCYKGU6.js} +2 -2
- package/dist/chunk-LLNPKE7H.js +11 -0
- package/dist/chunk-LLNPKE7H.js.map +1 -0
- package/dist/{chunk-HYE2UUQ4.js → chunk-R64DAHBH.js} +160 -160
- package/dist/chunk-R64DAHBH.js.map +1 -0
- package/dist/{chunk-EFV7U5LD.js → chunk-V4GXHBOH.js} +64 -64
- package/dist/chunk-V4GXHBOH.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{program-FUYHN2F7.js → program-7UH4FCA3.js} +4 -4
- package/dist/{registry-PLSOZ3CL.js → registry-MDWD7EAO.js} +2 -2
- package/dist/{tool-MSXWU44P.js → tool-GPCJM7U5.js} +2 -2
- package/dist/{tool-X7YEIJVZ.js → tool-VKQIDEG7.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-EFV7U5LD.js.map +0 -1
- package/dist/chunk-HYE2UUQ4.js.map +0 -1
- package/dist/chunk-OVN5LVJY.js +0 -11
- package/dist/chunk-OVN5LVJY.js.map +0 -1
- /package/dist/{agent-BDEPUFBQ.js.map → agent-75URYGWI.js.map} +0 -0
- /package/dist/{chunk-ZDDJNKU5.js.map → chunk-3FCYKGU6.js.map} +0 -0
- /package/dist/{program-FUYHN2F7.js.map → program-7UH4FCA3.js.map} +0 -0
- /package/dist/{registry-PLSOZ3CL.js.map → registry-MDWD7EAO.js.map} +0 -0
- /package/dist/{tool-MSXWU44P.js.map → tool-GPCJM7U5.js.map} +0 -0
- /package/dist/{tool-X7YEIJVZ.js.map → tool-VKQIDEG7.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{b as o}from"./chunk-JXF54PT7.js";import"./chunk-QIJLFPWE.js";var s=o(process.versions.node);s&&(console.error(s),process.exit(1));var{buildProgram:r}=await import("./program-
|
|
2
|
+
import{b as o}from"./chunk-JXF54PT7.js";import"./chunk-QIJLFPWE.js";var s=o(process.versions.node);s&&(console.error(s),process.exit(1));var{buildProgram:r}=await import("./program-7UH4FCA3.js"),{installCliSignalExit:i}=await import("./signal-exit-WL7G3EEZ.js");i();var e=await r();process.argv.slice(2).length===0?e.outputHelp():e.parse();
|
|
3
3
|
//# sourceMappingURL=cli.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as St,b as kt,c as vt,ca as Tt,d as xt,da as Mt,e as $t,f as Ct,g as Pt,h as bt}from"./chunk-
|
|
1
|
+
import{a as St,b as kt,c as vt,ca as Tt,d as xt,da as Mt,e as $t,f as Ct,g as Pt,h as bt}from"./chunk-R64DAHBH.js";import"./chunk-BDM4VTBR.js";import"./chunk-GTJIKXDB.js";import"./chunk-ZUAV3PTL.js";import"./chunk-S2GAEH2F.js";import"./chunk-CL53UVOF.js";import"./chunk-ZVP6GB4G.js";import"./chunk-WWU2D65N.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-2D3RYIDU.js";import"./chunk-EKJG63EJ.js";import{U as yt,l as lt,m as ct,n as dt,o as mt,p as pt}from"./chunk-V4GXHBOH.js";import"./chunk-ES7Z64Z5.js";import"./chunk-GLQLCBJS.js";import"./chunk-DP7RTNDM.js";import{a as L}from"./chunk-C245D4BZ.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-3FCYKGU6.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-Y4CYQV7G.js";import"./chunk-LLNPKE7H.js";import"./chunk-SHEUCITK.js";import"./chunk-BB3ESU74.js";import"./chunk-SZDACK6O.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import{s as ut}from"./chunk-4KJ3PCAI.js";import"./chunk-XF65CDNS.js";import"./chunk-VWTBHLMX.js";import"./chunk-ATXE3EMV.js";import{a as ht}from"./chunk-LUL4ILAQ.js";import"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-74FSHUB3.js";import"./chunk-MYVHVJWZ.js";import"./chunk-DWADWDMU.js";import"./chunk-23A5K5UW.js";import"./chunk-QD6IICK7.js";import"./chunk-CECHWYJ2.js";import"./chunk-HUQRPEDP.js";import{f as gt,g as ft}from"./chunk-GUAJNZIX.js";import"./chunk-WPNRDEHW.js";import"./chunk-2GIDVZ4H.js";import{j as it,k as rt,l as at}from"./chunk-5GXCOHDM.js";import"./chunk-72SZI2UW.js";import"./chunk-FX3D7YON.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import{a as ke,b as ve,c as xe,d as $e,e as Ce,f as Pe,g as be,h as Te,i as Me,j as Re,l as Ee,m as Ge,o as T,p as W}from"./chunk-5MUJZODV.js";import{a as m,b as G}from"./chunk-7I7IEX4S.js";import{b as Fe,c as Le,d as A,e as De}from"./chunk-JHCI6XCJ.js";import{a as Ke,b as Je,e as We}from"./chunk-DSYKYZMT.js";import{_ as tt,aa as st,ba as ot,da as nt}from"./chunk-LTHQXWZN.js";import"./chunk-UCKKAWLZ.js";import"./chunk-PN6XHTG5.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";W();G();import{execa as Rt}from"execa";import{existsSync as se,promises as X}from"fs";import S from"path";import ie from"node-fetch";async function Et(o,e){let t=o.split("/");if(t.length<2)throw new Error(`Invalid skill package ID: ${o}. Expected format: owner/repo`);let s=t[0],i=t[1],n=t[2];try{let a=n?`${s}/${i}/${n}`:`${s}/${i}`;await Rt("npx",["-y","skills","add",a],{cwd:e,stdio:"pipe"}),m.success(`Installed skill package: ${o}`);let r=S.resolve(e,".skills",`${s}_${i}`);if(se(r))return await ne(r,o);let d=S.resolve(e,".skills");return se(d)?await ne(d,o):[]}catch{return m.info(`Fetching skills directly from GitHub: ${s}/${i}`),await Gt(s,i,n,e)}}async function Gt(o,e,t,s){let i=[];try{let n=`https://api.github.com/repos/${o}/${e}/git/trees/main?recursive=1`,a=await ie(n);if(!a.ok)throw new Error(`GitHub API error: ${a.status}`);let d=(await a.json()).tree.filter(p=>p.type==="blob"&&p.path.endsWith("SKILL.md"));if(t){let p=d.find(f=>f.path.includes(`/${t}/`)||f.path===`${t}/SKILL.md`);if(p){let f=await oe(o,e,p.path,s);f&&i.push(f)}}else for(let p of d){let f=await oe(o,e,p.path,s);f&&i.push(f)}}catch(n){m.error(`Failed to fetch skills from GitHub: ${n.message}`)}return i}async function oe(o,e,t,s){try{let i=`https://raw.githubusercontent.com/${o}/${e}/main/${t}`,n=await ie(i);if(!n.ok)return null;let a=await n.text(),r=A(a);if(r){r.source="remote",r.packageId=`${o}/${e}`;let d=S.dirname(t),p=S.resolve(s,".skills",`${o}_${e}`,d);await X.mkdir(p,{recursive:!0}),await X.writeFile(S.resolve(p,"SKILL.md"),a),r.path=S.resolve(p,"SKILL.md")}return r}catch{return null}}async function ne(o,e){let t=[],{default:s}=await import("fast-glob"),i=await s.glob("**/SKILL.md",{cwd:o,deep:5});for(let n of i)try{let a=S.resolve(o,n),r=await X.readFile(a,"utf8"),d=A(r);d&&(d.source="remote",d.path=a,d.packageId=e,t.push(d))}catch{}return t}async function At(o,e,t,s,i){let n=["---",`name: ${o}`,`description: ${e}`];if(s?.length){n.push("tags:");for(let a of s)n.push(` - ${a}`)}if(i?.length){n.push("globs:");for(let a of i)n.push(` - ${a}`)}return n.push("---"),`${n.join(`
|
|
2
2
|
`)}
|
|
3
3
|
|
|
4
4
|
${t}`}async function It(o){let{loadLocalSkills:e}=await import("./loader-YFVSSYSL.js");return e(o)}async function Ot(o,e,t,s,i){let a=[{role:"system",content:`You are a skill author for the Agent Skills ecosystem (skills.sh).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Dl,b as ks,g as Pl}from"./chunk-JG3O5GL6.js";import{a as El,c as Al}from"./chunk-XQ7MVPWP.js";import{a as eo,b as kl,f as vl,g as xl,h as Sl,i as Rt,j as Tl,k as Ol,l as Ji,m as Cl,p as Hi,q as Rl,s as _l}from"./chunk-VVW4JYV6.js";import{a as jl,c as Il,d as Nl}from"./chunk-BYD5B3P3.js";import"./chunk-O5U5NVLR.js";import{a as Ci,b as Xa}from"./chunk-RKPAVWXF.js";import{$ as $s,A as Yc,B as Vc,C as Kc,D as Xc,E as Qc,F as il,G as Ct,H as ys,I as Li,J as rl,K as al,L as cl,M as ll,N as dl,O as gl,P as jt,Q as It,R as ml,S as pl,T as De,U as ws,V as Sn,W as qi,X as ul,Y as yl,Z as Wi,_ as $l,a as ic,aa as Nt,b as rc,ba as bs,ca as Bi,da as bl,h as cs,i as dc,j as kn,k as ls,l as pc,m as uc,n as Ac,o as Tc,p as ps,q as Ii,r as Nc,s as qc,t as Wc,u as Bc,v as Jc,w as Hc,x as Gc,y as Ri,z as zc}from"./chunk-
|
|
1
|
+
import{a as Dl,b as ks,g as Pl}from"./chunk-JG3O5GL6.js";import{a as El,c as Al}from"./chunk-XQ7MVPWP.js";import{a as eo,b as kl,f as vl,g as xl,h as Sl,i as Rt,j as Tl,k as Ol,l as Ji,m as Cl,p as Hi,q as Rl,s as _l}from"./chunk-VVW4JYV6.js";import{a as jl,c as Il,d as Nl}from"./chunk-BYD5B3P3.js";import"./chunk-O5U5NVLR.js";import{a as Ci,b as Xa}from"./chunk-RKPAVWXF.js";import{$ as $s,A as Yc,B as Vc,C as Kc,D as Xc,E as Qc,F as il,G as Ct,H as ys,I as Li,J as rl,K as al,L as cl,M as ll,N as dl,O as gl,P as jt,Q as It,R as ml,S as pl,T as De,U as ws,V as Sn,W as qi,X as ul,Y as yl,Z as Wi,_ as $l,a as ic,aa as Nt,b as rc,ba as bs,ca as Bi,da as bl,h as cs,i as dc,j as kn,k as ls,l as pc,m as uc,n as Ac,o as Tc,p as ps,q as Ii,r as Nc,s as qc,t as Wc,u as Bc,v as Jc,w as Hc,x as Gc,y as Ri,z as zc}from"./chunk-R64DAHBH.js";import{Aa as hs,Da as nl,Ea as sl,Fa as Mi,K as Ni,L as Pc,N as Mc,O as us,P as Lc,Va as fl,Wa as Ui,Xa as hl,Ya as Fi,ca as vn,fa as _i,ga as fs,ha as Zc,kb as fo,mb as wl,oa as Po,p as Do,pa as el,qa as Di,sa as Pi,t as Rc,ua as ol,va as tl,wa as xn,x as _c,y as Dc}from"./chunk-BDM4VTBR.js";import"./chunk-GTJIKXDB.js";import{a as ac,d as cc,e as lc}from"./chunk-ZUAV3PTL.js";import{a as ds,b as gs,c as fc,d as hc,e as yc,g as wc,h as $c,j as bc,k as kc,l as vc,m as xc,p as ms,s as Sc,t as Ec}from"./chunk-S2GAEH2F.js";import"./chunk-CL53UVOF.js";import"./chunk-ZVP6GB4G.js";import{a as gc,p as mc}from"./chunk-WWU2D65N.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import{a as Oc,b as Cc,c as jc,d as Ic}from"./chunk-2D3RYIDU.js";import{a as Uc,b as Fc}from"./chunk-EKJG63EJ.js";import{D as _o,J as za,U as Ya,g as Ia,q as Na,x as Ai,y as Pa}from"./chunk-V4GXHBOH.js";import{b as xt,g as Et,h as rs,i as as,j as At,k as Ma,l as ot,m as $n}from"./chunk-ES7Z64Z5.js";import{e as Ba,f as Oi,k as Ja}from"./chunk-GLQLCBJS.js";import{b as St}from"./chunk-DP7RTNDM.js";import"./chunk-3FCYKGU6.js";import"./chunk-SFQUP3BP.js";import"./chunk-Y4CYQV7G.js";import{b as bn}from"./chunk-LLNPKE7H.js";import{a as Va,b as Ka}from"./chunk-SHEUCITK.js";import{a as ji,e as Qa,f as Za,h as ec,i as oc,k as tc,l as nc,m as sc}from"./chunk-BB3ESU74.js";import{c as qa}from"./chunk-SZDACK6O.js";import{f as Ua,g as Fa,h as Ti}from"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import{a as _a,k as Wa}from"./chunk-4KJ3PCAI.js";import{a as Ha,b as se,c as je,d as Ot,e as Ga}from"./chunk-XF65CDNS.js";import"./chunk-VWTBHLMX.js";import{a as Si}from"./chunk-ATXE3EMV.js";import"./chunk-LUL4ILAQ.js";import"./chunk-KA2UIZXG.js";import{a as Ei,b as Ra}from"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import{j as Da}from"./chunk-X5C5W3E4.js";import{a as Tt}from"./chunk-GV7S5BAX.js";import{e as La}from"./chunk-GSX4NK2N.js";import"./chunk-74FSHUB3.js";import"./chunk-MYVHVJWZ.js";import{h as ja}from"./chunk-DWADWDMU.js";import"./chunk-23A5K5UW.js";import"./chunk-QD6IICK7.js";import"./chunk-CECHWYJ2.js";import"./chunk-HUQRPEDP.js";import{g as Ro,i as is}from"./chunk-GUAJNZIX.js";import"./chunk-WPNRDEHW.js";import{b as vt,d as Ca}from"./chunk-2GIDVZ4H.js";import{a as bi,b as ga,c as pp,d as ts,e as ma,f as xa,g as yp,h as Sa,i as wp,m as kt,n as Aa,o as Ta,s as Oa,v as uo,w as wn}from"./chunk-5GXCOHDM.js";import{a as vo,b as bt,e as ba,f as yn}from"./chunk-72SZI2UW.js";import{a as Ea,b as $p}from"./chunk-FX3D7YON.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-JXF54PT7.js";import"./chunk-5MUJZODV.js";import{a as ko,b as mp}from"./chunk-7I7IEX4S.js";import"./chunk-JHCI6XCJ.js";import"./chunk-DSYKYZMT.js";import{$ as $a,A as ya,N as vi,O as xi,Q as fp,_ as wa,aa as O,ba as ss,da as ee,m as pa,n as ua,p as fa,q as up,x as ki,z as ha}from"./chunk-LTHQXWZN.js";import"./chunk-UCKKAWLZ.js";import{a as No,i as ns}from"./chunk-PN6XHTG5.js";import{g as ka,k as va,l as hp}from"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";import{Command as bp}from"commander";var Ml=new bp().name("a2a").description("start an A2A (Agent-to-Agent) protocol server for external agent integration").option("--port <port>","server port","3171").option("--host <host>","server host","0.0.0.0").option("-p, --provider <provider>","AI provider","claude-code").option("-m, --model <model>","model to use").option("--api-key <key>","API key for the provider").option("-c, --cwd <cwd>","working directory",process.cwd()).option("--no-cors","disable CORS headers").action(async e=>{await new rc({port:parseInt(e.port,10),host:e.host,provider:e.provider,model:e.model,apiKey:e.apiKey,cwd:e.cwd,cors:e.cors!==!1}).start()});ee();import{Command as kp}from"commander";import{execFileSync as to}from"node:child_process";import{cpSync as Ll,existsSync as Yi,mkdirSync as Gi,mkdtempSync as vp,readdirSync as xp,rmSync as ql,writeFileSync as Ul}from"node:fs";import{dirname as Fl,join as Le}from"node:path";import{homedir as vs,release as Sp,tmpdir as Ep}from"node:os";import{setTimeout as Ap}from"node:timers/promises";function xs(){let e=fc(process.platform,process.arch,Sp());if(e)throw new Error(e)}function Ss(){let e=Le(vs(),"Library/LaunchAgents"),o=[];try{o=xp(e).filter(wc)}catch{}let t=o.flatMap(n=>{let s=Le(e,n);try{return[{file:s,plist:to("plutil",["-convert","xml1","-o","-",s],{encoding:"utf8",stdio:["ignore","pipe","ignore"]})}]}catch{return[]}});return $c(e,t)}function En(e){return`gui/${process.getuid()}/${e.label}`}async function zi(e){try{to("launchctl",["bootout",En(e)],{stdio:"pipe"})}catch{}for(let o=0;o<30;o++){try{to("launchctl",["print",En(e)],{stdio:"pipe"})}catch{return}await Ap(200)}throw new Error("The desktop login service did not stop. Retry agentx desktop stop before installing.")}function Wl(e){if(!Yi(e.file))throw new Error("Run agentx desktop install first.");let o=!0;try{to("launchctl",["print",En(e)],{stdio:"pipe"})}catch{o=!1}o||to("launchctl",["bootstrap",`gui/${process.getuid()}`,e.file],{stdio:"pipe"}),to("launchctl",["kickstart",En(e)],{stdio:"pipe"})}function Tp(){let e=xc();if(e&&Yi(Le(e,"apps/mac-voice/build.sh")))return e;throw new Error("Desktop sources are missing from this installation. Update AgentX to a release containing apps/mac-voice and apps/mac-helper.")}var _t=new kp("desktop").description("install and control the macOS desktop assistant");_t.command("install").description("build, install, and start voice and computer-use helpers at login").option("--agent <id>","pin this agent; without it, pick the agent from the menu-bar icon").option("--dry-run","show the installation plan without building or changing login items").action(async e=>{xs();let o=O(),t=hc(o.agents,e.agent),n=e.agent,s=o.dashboard?.daemonUrl||`http://${o.node.bind.replace(/^0\.0\.0\.0:/,"127.0.0.1:")}`,i=Tp(),r=Le(vs(),"Applications"),{keep:a,remove:c}=Ss();if(console.log(`Desktop assistant \u2192 ${Le(r,ds)}
|
|
2
2
|
Computer-use helper \u2192 ${Le(r,gs)}
|
|
3
3
|
Agent \u2192 ${n?`${t} (pinned)`:"picked from the menu-bar icon"}
|
|
4
4
|
Daemon \u2192 ${s}
|
|
@@ -420,7 +420,7 @@ return aid ?? null`}function xh(e,o){if(e.kind==="path"){let s=e.pts,i=s[Math.fl
|
|
|
420
420
|
Latest runs (${s.length})`),s.length===0&&console.log(Me.dim(" nothing recorded yet"));for(let r of s){let a=r.status==="ok"?Me.green("ok"):r.status==="in-flight"?Me.yellow("running"):Me.red(r.status);console.log(` ${Me.dim(Fg(r.startedAt))} ${(r.channel??"?").padEnd(9)} ${r.agentId} ${a} ${Wg(r.messagePreview)}`)}console.log()});ns();ya();import{Command as Cy}from"commander";import{existsSync as jy}from"fs";import fe from"chalk";var Kt=new Cy("requests").description("what you asked agents for that is not finished, oldest first"),Hg={in_progress:"in progress",waiting_owner:"waiting on you",waiting_other:"waiting on another agent",needs_attention:"needs attention",done:"done",declined:"declined",dropped:"dropped"};function Ir(){if(!jy(Ha()))return console.error(fe.red(" no agentx.json here: run this from the install folder, the one that holds agentx.json")),process.exitCode=1,null;let e=No();return e?new ha(e):(process.exitCode=1,null)}var Ks=e=>new Date(e).toISOString().slice(0,16).replace("T"," ")+" UTC";function Gg(e){let o=e.state==="needs_attention"?fe.red:e.state==="waiting_owner"?fe.yellow:fe.dim;console.log(` ${fe.cyan(e.id)} ${o(`[${Hg[e.state]??e.state}]`)} ${fe.dim(`${Ks(e.createdAt)} \xB7 ${e.channel} \xB7 ${e.agentId}`)}`),console.log(` ${e.text.replace(/\s+/g," ").trim().slice(0,240)}`),e.state==="waiting_owner"&&e.question&&console.log(fe.yellow(` Question: ${e.question}`)),e.state==="needs_attention"&&e.attentionReason&&console.log(fe.red(` ${e.attentionReason}`)),e.evidence&&console.log(fe.green(` Evidence: ${e.evidence}`)),e.closeReason&&console.log(fe.dim(` Reason: ${e.closeReason}`))}Kt.command("list",{isDefault:!0}).alias("ls").description("open requests, oldest first").option("--json","machine-readable output").action(e=>{let o=Ir();if(!o)return;let t=o.listOpen();if(e.json){console.log(JSON.stringify(t,null,2));return}if(Ni().enabled||console.log(fe.dim(" requests are off: turn them on with `agentx requests settings --enabled on`")),t.length===0){console.log(fe.dim(" no open requests"));return}for(let n of t)Gg(n);console.log(fe.dim(`
|
|
421
421
|
${t.length} open. Close one: agentx requests done <id> --evidence <link> \xB7 agentx requests drop <id>`))});Kt.command("show <id>").description("one request and the runs, delegations and cards linked to it").action(e=>{let o=Ir();if(!o)return;let t=o.get(e);if(!t||t.state==="candidate"){console.error(fe.red(` no request "${e}"`)),process.exitCode=1;return}Gg(t),console.log(fe.dim(` Last activity ${Ks(t.updatedAt)}${t.closedAt?` \xB7 closed ${Ks(t.closedAt)}`:""}`));for(let n of o.links(e))console.log(fe.dim(` ${n.kind} ${n.ref} (${Ks(n.at)})`))});function zg(e,o,t,n){Kt.command(`${e} <id>`).description(o).option(t,e==="done"?"link to the proof: PR, issue, message, deploy":"why it is dropped").action((s,i)=>{let r=Ir();if(!r)return;let a=e==="done"?i.evidence:i.reason??"dropped by the owner";if(!a){console.error(fe.red(` ${n}`)),process.exitCode=1;return}let c=r.get(s);if(!c||c.state==="candidate"){console.error(fe.red(` no request "${s}"`)),process.exitCode=1;return}if(!r.close(s,e==="done"?"done":"dropped",a,Date.now())){console.error(fe.red(` ${s} is already closed (${Hg[c.state]??c.state})`)),process.exitCode=1;return}console.log(fe.green(` \u2713 ${s} ${e==="done"?"closed as done":"dropped"}`))})}zg("done","close a request as finished, with a link to the evidence","--evidence <link>","a finished request needs --evidence <link>");zg("drop","drop a request you no longer want","--reason <text>","");Kt.command("settings").description("show or change the requests settings").option("--enabled <on|off>","record and follow your requests").option("--from <id,...>",'who counts as you on channels other people can reach, as channel:id (your login on GitLab and GitHub, your sender id elsewhere); "none" to clear').option("--channels <name,...>",'channels to record on; "all" for every channel a person writes on').option("--stale-hours <n>","hours without activity before an open request comes back to you").option("--retention-days <n>","days a closed request is kept").action(async e=>{let o={};try{let n=(i,r)=>{if(r===void 0)return;let a=Number(r);if(!(a>0))throw new Error(`${i} must be a positive number`);return a},s=(i,r)=>i===void 0?void 0:i===r?[]:i.split(",").map(a=>a.trim()).filter(Boolean);if(e.enabled!==void 0){if(e.enabled!=="on"&&e.enabled!=="off")throw new Error("--enabled takes on or off");o.enabled=e.enabled==="on"}o.from=s(e.from,"none"),o.channels=s(e.channels,"all"),o.staleAfterHours=n("--stale-hours",e.staleHours),o.retentionDays=n("--retention-days",e.retentionDays)}catch(n){console.error(fe.red(` ${n.message}`)),process.exitCode=1;return}if(Object.values(o).some(n=>n!==void 0)){let n=await Pc(o);if(!n.success){console.error(fe.red(` ${n.error}`)),process.exitCode=1;return}console.log(fe.green(" \u2713 saved")+(n.reloaded?fe.dim(" (daemon reloaded)"):""))}let t=Ni();console.log(` Requests ${t.enabled?"on":"off"}`),console.log(` Channels ${t.channels.length?t.channels.join(", "):"every channel a person writes on"}`),console.log(` Counts as you ${t.from.length?t.from.join(", "):"only voice, the app and the dashboard on this machine"}`),console.log(` Comes back after ${t.staleAfterHours} hour(s) without activity`),console.log(` Closed requests kept ${t.retentionDays} day(s)`)});import{Command as Iy}from"commander";import Xt from"chalk";ee();var Yg=new Iy("request-status").description("show each person the state of their request in the thread where they asked (GitLab, GitHub)").argument("[channel]",Ji.join(" or ")).argument("[state]","on or off").action(async(e,o)=>{if(e!==void 0){o!=="on"&&o!=="off"&&(console.error(Xt.red("\u2717 say on or off, for example: agentx request-status gitlab on")),process.exit(1));let n="",s=await se(i=>{n=Cl(i,e,o==="on")});s.success||(console.error(Xt.red(`\u2717 ${s.error}`)),process.exit(1)),console.log(Xt.green(`\u2713 ${n}`)),s.reloaded&&console.log(Xt.dim(" daemon hot-reloaded"))}let t=O().requestStatus.channels.map(n=>n.toLowerCase());for(let n of Ji)console.log(` ${n.padEnd(8)} ${t.includes(n)?Xt.green("on"):Xt.dim("off")}`)});import{Command as ew}from"commander";import Qt from"chalk";import re from"chalk";import Wn from"prompts";import{readFileSync as Ny,writeFileSync as Ry,existsSync as _y}from"fs";import{resolve as Vg}from"path";var Dy=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/;function Py(e){let o=e.trim();return o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'")?o.slice(1,-1):o}function Nr(e){return/[\s#"'\\]/.test(e)||e===""?JSON.stringify(e):e}function Kg(e=".env"){let o=Vg(e);if(!_y(o))return[];let t=Ny(o,"utf-8"),n=[];for(let s of t.split(/\r?\n/)){if(s.trim()===""){n.push({kind:"blank",raw:s});continue}if(s.trim().startsWith("#")){n.push({kind:"comment",raw:s});continue}let i=s.match(Dy);i?n.push({kind:"kv",key:i[1],value:Py(i[2]),raw:s}):n.push({kind:"comment",raw:s})}return n.length&&n[n.length-1].kind==="blank"&&n.pop(),n}function My(e){return e.map(o=>o.kind==="kv"?`${o.key}=${Nr(o.value)}`:o.raw).join(`
|
|
422
422
|
`)+`
|
|
423
|
-
`}function Fn(e,o,t=".env"){let n=Vg(t),s=Kg(n),i=s.findIndex(r=>r.kind==="kv"&&r.key===e);i>=0?s[i]={kind:"kv",key:e,value:o,raw:`${e}=${Nr(o)}`}:(s.length&&s[s.length-1].kind!=="blank"&&s.push({kind:"blank",raw:""}),s.push({kind:"kv",key:e,value:o,raw:`${e}=${Nr(o)}`})),Ry(n,My(s))}function Rr(e,o=".env"){return Kg(o).find(s=>s.kind==="kv"&&s.key===e)?.value}var Xg="https://t.me/BotFather";async function Ly(e){try{let o=await fetch(`https://api.telegram.org/bot${e}/getMe`,{signal:AbortSignal.timeout(8e3)});if(!o.ok)return null;let t=await o.json();return t?.ok?t.result:null}catch{return null}}async function qy(e,o){let t=Date.now()+o,n=0;try{let i=await(await fetch(`https://api.telegram.org/bot${e}/getUpdates?offset=-1&timeout=0`,{signal:AbortSignal.timeout(5e3)})).json();i?.result?.length&&(n=i.result[0].update_id+1)}catch{}for(;Date.now()<t;)try{let i=await(await fetch(`https://api.telegram.org/bot${e}/getUpdates?offset=${n}&timeout=10`,{signal:AbortSignal.timeout(15e3)})).json();for(let r of i?.result||[]){n=Math.max(n,r.update_id+1);let a=r.message||r.edited_message||r.channel_post;if(a?.chat?.id)return{chatId:a.chat.id,chatTitle:a.chat.title||a.chat.username||a.chat.first_name,from:a.from?.first_name||a.from?.username||"unknown"}}}catch{}return null}async function Qg(e={}){console.log(),console.log(re.bold(" Connect Telegram")),console.log(),console.log(re.dim(` 1. Open ${Xg}`)),console.log(re.dim(" /newbot (or /mybots \u2192 pick existing \u2192 API Token)")),console.log(re.dim(" 2. Copy the HTTP API token \u2014 looks like 123456789:ABCdef...")),console.log();let{wantsBrowser:o}=await Wn({type:"confirm",name:"wantsBrowser",message:"Open BotFather in your browser?",initial:!0});o&&nt(Xg);let{token:t}=await Wn({type:"password",name:"token",message:"Paste the bot token from BotFather:",validate:b=>/^\d+:[A-Za-z0-9_-]{20,}$/.test(b.trim())||"That doesn't look like a Telegram token"});t||(console.log(re.red(" Aborted")),process.exit(1)),process.stdout.write(" Verifying token... ");let n=await Ly(t.trim());n||(console.log(re.red("\u2717 invalid or revoked")),process.exit(1)),console.log(re.green(`\u2713 ${n.first_name} (@${n.username})`));let{readFileSync:s,existsSync:i}=await import("fs"),{resolve:r}=await import("path"),a=e.configPath||r(process.cwd(),"agentx.json");i(a)||(console.log(re.red(` No agentx.json at ${a}. Run: agentx init`)),process.exit(1));let c=JSON.parse(s(a,"utf-8")),l=Object.keys(c.agents||{});l.length===0&&(console.log(re.red(" No agents configured. Run: agentx agent add")),process.exit(1));let g=e.agent;g||(g=(await Wn({type:"select",name:"agent",message:"Bind this bot to which agent?",choices:l.map($=>({title:$,value:$})),initial:0})).agent),g||(console.log(re.red(" Aborted")),process.exit(1));let d=c.channels?.telegram?.accounts||{},u=e.account||g;d[u]&&d[u].agentBinding!==g&&(u=(await Wn({type:"text",name:"account",message:`Account "${u}" is already in use. Pick a different label:`,initial:`${g}-2`,validate:$=>/^[a-z0-9-]+$/i.test($)||"lowercase letters, digits, hyphens only"})).account),u||(console.log(re.red(" Aborted")),process.exit(1));let f=`TG_${u.toUpperCase().replace(/-/g,"_")}_BOT_TOKEN`;Fn(f,t.trim()),process.env[f]=t.trim();let p=await se(b=>{je(b,"channels.telegram.enabled",!0),je(b,`channels.telegram.accounts.${u}`,{token:`\${${f}}`,agentBinding:g});let $=Ot(b,`agents.${g}.mentions`)||[],E=`@${n.username}`;$.includes(E)||($.push(E),je(b,`agents.${g}.mentions`,$))},{configPath:e.configPath});if(p.success||(console.log(re.red(` \u2717 ${p.error}`)),process.exit(1)),console.log(),console.log(re.green(` \u2713 Bot @${n.username} bound to agent "${g}"`)),console.log(re.dim(` Token stored in .env as ${f}`)),console.log(re.dim(` Mentions updated to include @${n.username}`)),p.reloaded?console.log(re.dim(" Daemon hot-reloaded.")):console.log(re.dim(" Start the daemon to begin polling (agentx daemon start)")),e.skipChatCapture)return;console.log();let{capture:h}=await Wn({type:"confirm",name:"capture",message:"Listen for a message so we can set this as your default --notify target?",initial:!0});if(!h)return;console.log(),console.log(re.dim(` Send any message to @${n.username} from the chat you want to use.`)),console.log(re.dim(" Waiting up to 90s..."));let w=await qy(t.trim(),9e4);if(!w){console.log(re.yellow(" No message received \u2014 skipping. You can set it later with:")),console.log(re.dim(" agentx config set notifications.destination.channel telegram")),console.log(re.dim(" agentx config set notifications.destination.chatId <chatId>")),console.log(re.dim(` agentx config set notifications.destination.accountId ${u}`));return}let k=await se(b=>{je(b,"notifications.destination",{channel:"telegram",chatId:String(w.chatId),accountId:u})},{configPath:e.configPath});if(!k.success){console.log(re.red(` \u2717 failed to save destination: ${k.error}`));return}console.log(re.green(" \u2713 Default --notify target set")),console.log(re.dim(` Chat: ${w.chatTitle||w.chatId} (from ${w.from})`)),console.log(re.dim(" From now on, --notify me resolves to this chat.")),k.reloaded&&console.log(re.dim(" Daemon hot-reloaded."))}import ke from"chalk";import _r from"prompts";import{existsSync as Pr,mkdirSync as Uy,readdirSync as Fy,readFileSync as Zg}from"fs";import{resolve as Dr}from"path";var Wy=".agentx/whatsapp-sessions";function By(){let e=Dr(process.cwd(),".agentx/daemon.pid");if(!Pr(e))return!1;try{let o=parseInt(Zg(e,"utf-8").trim(),10);return o?(process.kill(o,0),!0):!1}catch{return!1}}function Jy(e){if(!Pr(e))return!1;try{return Fy(e).some(o=>o.includes("creds")||o.endsWith(".json"))}catch{return!1}}async function Hy(e,o){let t;try{t=await import("@whiskeysockets/baileys")}catch{return o(ke.red(" WhatsApp pairing needs @whiskeysockets/baileys.")),o(ke.red(" Install with: pnpm add @whiskeysockets/baileys (or npm install)")),!1}let{makeWASocket:n,useMultiFileAuthState:s}=t.default||t;Uy(e,{recursive:!0});let{state:i,saveCreds:r}=await s(e),a;try{a=(await t.fetchLatestBaileysVersion()).version}catch{}let c={level:"silent",trace:()=>{},debug:()=>{},info:()=>{},warn:()=>{},fatal:()=>{},error:()=>{},child:()=>c},l=n({auth:{creds:i.creds,keys:t.makeCacheableSignalKeyStore?t.makeCacheableSignalKeyStore(i.keys,c):i.keys},...a?{version:a}:{},logger:c,printQRInTerminal:!1,browser:["agentx-connect","pairing","1.0"],syncFullHistory:!1,markOnlineOnConnect:!1});return l.ev.on("creds.update",r),await new Promise(g=>{let u=setTimeout(()=>{o(ke.yellow(" Timed out waiting for scan (2min)."));try{l.end(void 0)}catch{}g(!1)},12e4);l.ev.on("connection.update",async f=>{if(f.qr){o(ke.dim(" Scan this QR with WhatsApp \u2192 Linked devices \u2192 Link a device:")),o("");try{let{default:p}=await import("qrcode-terminal");p.generate(f.qr,{small:!0})}catch{o(` QR: ${f.qr}`)}o("")}if(f.connection==="open"){clearTimeout(u),o(ke.green(" \u2713 Paired"));try{l.end(void 0)}catch{}g(!0)}f.connection==="close"&&!f.qr&&f.lastDisconnect?.error?.output?.statusCode===401&&(clearTimeout(u),o(ke.red(" \u2717 Authorization failed \u2014 rescan required")),g(!1))})})}async function em(e={}){if(console.log(),console.log(ke.bold(" Connect WhatsApp")),console.log(),By()){console.log(ke.yellow(" \u26A0 The daemon is running. Stop it first so pairing can open a fresh Baileys session:")),console.log(ke.dim(" agentx daemon stop")),console.log();let{cont:l}=await _r({type:"confirm",name:"cont",message:"Continue anyway? (expect errors)",initial:!1});l||(console.log(ke.red(" Aborted")),process.exit(1))}let o=e.configPath||Dr(process.cwd(),"agentx.json");Pr(o)||(console.log(ke.red(` No agentx.json at ${o}. Run: agentx init`)),process.exit(1));let t=JSON.parse(Zg(o,"utf-8")),n=e.sessionDir||t.channels?.whatsapp?.sessionDir||Wy,s=Dr(process.cwd(),n),i=Object.keys(t.agents||{});i.length===0&&(console.log(ke.red(" No agents configured. Run: agentx agent add")),process.exit(1));let r=e.agent;r||(r=(await _r({type:"select",name:"agent",message:"Default agent for incoming messages:",choices:i.map(g=>({title:g,value:g})),initial:0})).agent),r||(console.log(ke.red(" Aborted")),process.exit(1));let a=!e.skipPair;if(Jy(s)&&a){let{keep:l}=await _r({type:"confirm",name:"keep",message:`An existing session was found at ${n}. Keep it (recommended), or pair again?`,initial:!0});a=!l,l&&console.log(ke.dim(" Keeping existing session \u2014 skipping QR pair."))}a&&(await Hy(s,g=>console.log(g))||(console.log(ke.red(" Pairing failed. You can retry with `agentx connect whatsapp`.")),process.exit(1)));let c=await se(l=>{je(l,"channels.whatsapp.enabled",!0),je(l,"channels.whatsapp.sessionDir",n),je(l,"channels.whatsapp.defaultAgent",r)},{configPath:e.configPath});c.success||(console.log(ke.red(` \u2717 ${c.error}`)),process.exit(1)),console.log(),console.log(ke.green(` \u2713 WhatsApp bound to agent "${r}"`)),console.log(ke.dim(` Session: ${n}`)),console.log(ke.dim(" Start the daemon to begin receiving:")),console.log(ke.dim(" agentx daemon start")),console.log(ke.dim(" Add routes later with:")),console.log(ke.dim(` agentx config set channels.whatsapp.routes '[{"contact":"+1234567890","agent":"${r}"}]'`)),console.log()}import{randomBytes as Gy}from"crypto";import Te from"chalk";import om from"prompts";var Xs="agentx-mesh:",Qs="//join/";function zy(e){return Buffer.from(e,"utf-8").toString("base64url")}function Yy(e){return Buffer.from(e,"base64url").toString("utf-8")}function Vy(e){return`${Xs}${Qs}${zy(JSON.stringify(e))}`}function Ky(e){if(!e.startsWith(`${Xs}${Qs}`))throw new Error(`Not a mesh invite link \u2014 expected ${Xs}${Qs}\u2026`);let o=e.slice(Xs.length+Qs.length),t=JSON.parse(Yy(o));if(t.version!==1)throw new Error(`Unsupported invite version: ${t.version}`);if(typeof t.url!="string"||typeof t.token!="string"||typeof t.name!="string")throw new Error("Invite payload missing required fields (url, token, name)");return t}function Xy(){return Gy(32).toString("hex")}function Qy(e){let o=e?.node?.bind||"127.0.0.1:18800",[t,n]=o.split(":");return`http://${t}:${n}`}function Zy(e){return e?.node?.name||e?.node?.id||"node"}async function tm(e){let{readFileSync:o,existsSync:t}=await import("fs"),{resolve:n}=await import("path"),s=e.configPath||n(process.cwd(),"agentx.json");t(s)||(console.log(Te.red(` No agentx.json at ${s}. Run: agentx init`)),process.exit(1));let i=JSON.parse(o(s,"utf-8")),r=Rr("MESH_TOKEN");r||(r=Xy(),Fn("MESH_TOKEN",r),console.log(Te.dim(" Generated new MESH_TOKEN (32 bytes) and saved to .env")));let a=e.url||Qy(i);if((a.includes("0.0.0.0")||a.includes("127.0.0.1")||a.includes("localhost"))&&!e.url){let{url:d}=await om({type:"text",name:"url",message:"This node's URL as peers should reach it (e.g. http://100.x.x.x:18800):",initial:a,validate:u=>/^https?:\/\//.test(u)||"must start with http:// or https://"});d||(console.log(Te.red(" Aborted")),process.exit(1)),a=d}let l=await se(d=>{je(d,"mesh.enabled",!0)},{configPath:e.configPath});l.success||(console.log(Te.red(` \u2717 ${l.error}`)),process.exit(1));let g=Vy({url:a,token:r,name:Zy(i),version:1});console.log(),console.log(Te.bold(" Mesh invite")),console.log(),console.log(` ${Te.cyan(g)}`),console.log(),console.log(Te.dim(" Run on the other node:")),console.log(Te.dim(` agentx connect mesh join "${g}"`)),console.log(),console.log(Te.yellow(" Share over a trusted channel only \u2014 whoever holds this link can join your mesh.")),console.log()}async function nm(e,o={}){let t;try{t=Ky(e)}catch(i){console.log(Te.red(` \u2717 ${i.message}`)),process.exit(1)}let n=Rr("MESH_TOKEN");if(n&&n!==t.token){let{overwrite:i}=await om({type:"confirm",name:"overwrite",message:"A different MESH_TOKEN already exists in .env. Overwrite with the invite's token?",initial:!1});i||(console.log(Te.red(" Aborted (keeping existing .env)")),process.exit(1))}Fn("MESH_TOKEN",t.token);let s=await se(i=>{je(i,"mesh.enabled",!0);let r=Ot(i,"mesh.peers")||[],a=r.findIndex(l=>l.name===t.name),c={name:t.name,url:t.url,token:"${MESH_TOKEN}"};a>=0?r[a]=c:r.push(c),je(i,"mesh.peers",r)},{configPath:o.configPath});s.success||(console.log(Te.red(` \u2717 ${s.error}`)),process.exit(1)),console.log(Te.green(" \u2713 Joined mesh")),console.log(Te.dim(` Peer: ${t.name} @ ${t.url}`)),console.log(Te.dim(" Shared token stored in .env as MESH_TOKEN")),s.reloaded?console.log(Te.dim(" Daemon hot-reloaded.")):console.log(Te.dim(" Restart the daemon to start the mesh (agentx daemon start).")),console.log();try{let i=await fetch(`${t.url.replace(/\/$/,"")}/.well-known/agent-card.json`,{signal:AbortSignal.timeout(5e3)});if(i.ok){let r=await i.json(),a=Array.isArray(r.agents)?r.agents.length:"?";console.log(Te.dim(` Reachable \u2014 ${t.name} exposes ${a} agents`))}else console.log(Te.yellow(` Peer returned HTTP ${i.status} \u2014 double-check the URL`))}catch(i){console.log(Te.yellow(` Could not reach ${t.url} right now (${i?.cause?.code||i.message}) \u2014 verify VPN / Tailscale when the peer daemon is up`))}}var Zt=new ew().name("connect").description("connect a channel or mesh peer \u2014 no manual file editing required");Zt.command("telegram").description("pair a Telegram bot \u2014 persists token in .env, binds to an agent, auto-detects default chat").option("--agent <id>","agent to bind the bot to (skips the prompt)").option("--account <name>","account label in channels.telegram.accounts (defaults to agent id)").option("--skip-chat-capture","don't listen for the first message after pairing").option("-c, --config <path>","path to agentx.json").action(async e=>{await Qg({agent:e.agent,account:e.account,configPath:e.config,skipChatCapture:!!e.skipChatCapture})});Zt.command("whatsapp").description("pair WhatsApp via QR (prints in terminal), then writes channels.whatsapp config").option("--agent <id>","default agent for inbound messages").option("--session-dir <path>","session directory (default: .agentx/whatsapp-sessions)").option("--skip-pair","skip QR pairing (use when session already exists)").option("-c, --config <path>","path to agentx.json").action(async e=>{await em({agent:e.agent,sessionDir:e.sessionDir,skipPair:!!e.skipPair,configPath:e.config})});var sm=Zt.command("mesh").description("mesh invite + join \u2014 replaces manual MESH_TOKEN copy-paste");sm.command("invite").description("emit a single-use join link for another AgentX node").option("--url <url>","this node's URL as peers should reach it (Tailscale IP etc.)").option("-c, --config <path>","path to agentx.json").action(async e=>{await tm({url:e.url,configPath:e.config})});sm.command("join <link>").description("accept an invite link from another AgentX node").option("-c, --config <path>","path to agentx.json").action(async(e,o)=>{await nm(e,{configPath:o.config})});Zt.action(()=>{console.log(),console.log(Qt.bold(" agentx connect \u2014 which channel?")),console.log(),console.log(` ${Qt.cyan("agentx connect telegram")} \u2014 pair a Telegram bot`),console.log(` ${Qt.cyan("agentx connect whatsapp")} \u2014 pair WhatsApp via QR`),console.log(` ${Qt.cyan("agentx connect mesh invite")} \u2014 emit a mesh join link for another node`),console.log(` ${Qt.cyan("agentx connect mesh join <link>")} \u2014 accept a mesh invite`),console.log(),console.log(Qt.dim(" GitLab connect is the next slice.")),console.log()});ee();import{Command as ow}from"commander";import he from"chalk";var Bn=new ow().name("usage").description("token usage analysis and reporting");Bn.command("today",{isDefault:!0}).description("show today's token usage").action(async()=>{try{let e=O(),[o,t]=e.node.bind.split(":"),s=await(await fetch(`http://${o||"127.0.0.1"}:${t}/usage`,{signal:AbortSignal.timeout(3e3)})).json();if(console.log(),console.log(he.bold(" Token Usage (last 7 days)")),console.log(),s.totalTasks===0){console.log(he.dim(" No tasks recorded yet")),console.log();return}let i=a=>a.toLocaleString();console.log(` Total: ${he.bold(i(s.totalTokens))} tokens across ${s.totalTasks} tasks`),console.log(` Input: ${i(s.totalInput)}`),console.log(` Output: ${i(s.totalOutput)}`),console.log(` Cache read: ${i(s.totalCacheRead)}`),console.log(` Cache create: ${i(s.totalCacheCreate)}`),s.cacheHitRatio>0&&console.log(` Cache hit: ${(s.cacheHitRatio*100).toFixed(1)}%`),s.totalErrors>0&&console.log(` Errors: ${he.red(String(s.totalErrors))}`),console.log(),console.log(he.bold(" By Agent:"));let r=Object.entries(s.byAgent||{});r.sort((a,c)=>c[1].total-a[1].total);for(let[a,c]of r){let l=i(c.total||c.input+c.output+c.cacheRead+c.cacheCreate),g=c.avgDuration?`${(c.avgDuration/1e3).toFixed(1)}s avg`:"";console.log(` ${he.cyan(a)}: ${l} tokens (${c.tasks} tasks) ${he.dim(g)}`)}console.log()}catch(e){e.cause?.code==="ECONNREFUSED"?console.log(he.red(" Daemon not running. Start with: agentx daemon start")):console.log(he.red(` ${e.message}`))}});Bn.command("report").description("run full session analysis (parses Claude Code JSONL files)").option("--days <n>","analyze last N days","7").action(async e=>{let{execSync:o}=await import("child_process"),{existsSync:t}=await import("fs"),{resolve:n}=await import("path"),s=n(process.cwd(),"scripts/token-report.py");if(!t(s)){console.log(he.red(` Script not found: ${s}`)),console.log(he.dim(" The token analyzer script should be at scripts/token-report.py"));return}console.log(he.dim(" Analyzing Claude Code sessions..."));try{o(`SINCE_DAYS=${e.days} python3 "${s}"`,{stdio:"inherit"})}catch{console.log(he.red(" Analysis failed. Is Python 3 installed?"))}});Bn.command("surfaces").description("which CLI commands and dashboard pages are actually used").option("--days <n>","window in days","30").option("--kind <kind>","cli | page (default: both)").option("--unused","list registered surfaces with ZERO recorded use instead").option("--json","raw JSON output").action(async e=>{let{listSurfaceUse:o}=await import("./surface-usage-O5L4KLGS.js"),t=e.kind==="cli"||e.kind==="page"?e.kind:void 0,n=o({kind:t,sinceDays:Number(e.days)||30});if(e.unused){let{buildProgram:i}=await import("./program-FUYHN2F7.js"),r=await i(),a=new Set(n.filter(d=>d.kind==="cli").map(d=>d.name)),c=[],l=(d,u)=>{for(let f of d.commands??[]){let p=u?`${u} ${f.name()}`:f.name();c.push(p),l(f,p)}};l(r,"");let g=c.filter(d=>!a.has(d)).sort();if(e.json){console.log(JSON.stringify({windowDays:Number(e.days)||30,unused:g},null,2));return}console.log(),console.log(he.bold(` Never used in the last ${e.days} days (${g.length}/${c.length})`)),console.log();for(let d of g)console.log(` ${he.dim("\xB7")} ${d}`);console.log(),console.log(he.dim(" Zero use is necessary but not sufficient to remove a surface \u2014")),console.log(he.dim(" it must also fail the impact test. See docs/architecture/surface-reduction.md")),console.log();return}if(e.json){console.log(JSON.stringify(n,null,2));return}if(n.length===0){console.log(),console.log(he.dim(` No surface usage recorded in the last ${e.days} days.`)),console.log(he.dim(" Counting starts once this build has been running for a while.")),console.log();return}console.log(),console.log(he.bold(` Surface usage \u2014 last ${e.days} days`)),console.log();let s="";for(let i of n){i.kind!==s&&(console.log(he.dim(` ${i.kind==="cli"?"CLI commands":"Dashboard pages"}`)),s=i.kind);let r=String(i.count).padStart(6),a=he.dim(`${i.days}d`);console.log(` ${he.cyan(r)} ${i.name.padEnd(28)} ${a}`)}console.log(),console.log(he.dim(` ${n.length} surface(s) with recorded use. See --unused for the rest.`)),console.log()});import{Command as tw}from"commander";import ve from"chalk";import{readFileSync as nw}from"fs";import{resolve as sw}from"path";ee();var Vo=new tw().name("board").description("kanban board dashboard \u2014 visual work view over configured sources");Vo.command("serve",{isDefault:!0}).description("start the dashboard server (live view always; boards if configured)").option("--port <n>","override dashboard.port").option("--bind <host>","override dashboard.bind (e.g. 0.0.0.0)").action(async e=>{try{try{Ca(sw(process.cwd(),".env"))}catch{}let o=iw(e.port,e.bind),{startBoardDashboard:t}=await import("./board-dashboard-TWEF5XVE.js");t(o)}catch(o){console.log(ve.red(` ${o.message}`)),process.env.DEBUG&&o.stack&&console.log(ve.dim(o.stack)),process.exit(1)}});function iw(e,o){try{let t=O();return e&&(t.dashboard.port=parseInt(e,10)),o&&(t.dashboard.bind=o),t}catch{return console.log(ve.yellow(" No agentx.json found \u2014 starting dashboard in setup-only mode.")),console.log(ve.dim(" Visit http://127.0.0.1:"+(e||"4202")+` to run the wizard.
|
|
423
|
+
`}function Fn(e,o,t=".env"){let n=Vg(t),s=Kg(n),i=s.findIndex(r=>r.kind==="kv"&&r.key===e);i>=0?s[i]={kind:"kv",key:e,value:o,raw:`${e}=${Nr(o)}`}:(s.length&&s[s.length-1].kind!=="blank"&&s.push({kind:"blank",raw:""}),s.push({kind:"kv",key:e,value:o,raw:`${e}=${Nr(o)}`})),Ry(n,My(s))}function Rr(e,o=".env"){return Kg(o).find(s=>s.kind==="kv"&&s.key===e)?.value}var Xg="https://t.me/BotFather";async function Ly(e){try{let o=await fetch(`https://api.telegram.org/bot${e}/getMe`,{signal:AbortSignal.timeout(8e3)});if(!o.ok)return null;let t=await o.json();return t?.ok?t.result:null}catch{return null}}async function qy(e,o){let t=Date.now()+o,n=0;try{let i=await(await fetch(`https://api.telegram.org/bot${e}/getUpdates?offset=-1&timeout=0`,{signal:AbortSignal.timeout(5e3)})).json();i?.result?.length&&(n=i.result[0].update_id+1)}catch{}for(;Date.now()<t;)try{let i=await(await fetch(`https://api.telegram.org/bot${e}/getUpdates?offset=${n}&timeout=10`,{signal:AbortSignal.timeout(15e3)})).json();for(let r of i?.result||[]){n=Math.max(n,r.update_id+1);let a=r.message||r.edited_message||r.channel_post;if(a?.chat?.id)return{chatId:a.chat.id,chatTitle:a.chat.title||a.chat.username||a.chat.first_name,from:a.from?.first_name||a.from?.username||"unknown"}}}catch{}return null}async function Qg(e={}){console.log(),console.log(re.bold(" Connect Telegram")),console.log(),console.log(re.dim(` 1. Open ${Xg}`)),console.log(re.dim(" /newbot (or /mybots \u2192 pick existing \u2192 API Token)")),console.log(re.dim(" 2. Copy the HTTP API token \u2014 looks like 123456789:ABCdef...")),console.log();let{wantsBrowser:o}=await Wn({type:"confirm",name:"wantsBrowser",message:"Open BotFather in your browser?",initial:!0});o&&nt(Xg);let{token:t}=await Wn({type:"password",name:"token",message:"Paste the bot token from BotFather:",validate:b=>/^\d+:[A-Za-z0-9_-]{20,}$/.test(b.trim())||"That doesn't look like a Telegram token"});t||(console.log(re.red(" Aborted")),process.exit(1)),process.stdout.write(" Verifying token... ");let n=await Ly(t.trim());n||(console.log(re.red("\u2717 invalid or revoked")),process.exit(1)),console.log(re.green(`\u2713 ${n.first_name} (@${n.username})`));let{readFileSync:s,existsSync:i}=await import("fs"),{resolve:r}=await import("path"),a=e.configPath||r(process.cwd(),"agentx.json");i(a)||(console.log(re.red(` No agentx.json at ${a}. Run: agentx init`)),process.exit(1));let c=JSON.parse(s(a,"utf-8")),l=Object.keys(c.agents||{});l.length===0&&(console.log(re.red(" No agents configured. Run: agentx agent add")),process.exit(1));let g=e.agent;g||(g=(await Wn({type:"select",name:"agent",message:"Bind this bot to which agent?",choices:l.map($=>({title:$,value:$})),initial:0})).agent),g||(console.log(re.red(" Aborted")),process.exit(1));let d=c.channels?.telegram?.accounts||{},u=e.account||g;d[u]&&d[u].agentBinding!==g&&(u=(await Wn({type:"text",name:"account",message:`Account "${u}" is already in use. Pick a different label:`,initial:`${g}-2`,validate:$=>/^[a-z0-9-]+$/i.test($)||"lowercase letters, digits, hyphens only"})).account),u||(console.log(re.red(" Aborted")),process.exit(1));let f=`TG_${u.toUpperCase().replace(/-/g,"_")}_BOT_TOKEN`;Fn(f,t.trim()),process.env[f]=t.trim();let p=await se(b=>{je(b,"channels.telegram.enabled",!0),je(b,`channels.telegram.accounts.${u}`,{token:`\${${f}}`,agentBinding:g});let $=Ot(b,`agents.${g}.mentions`)||[],E=`@${n.username}`;$.includes(E)||($.push(E),je(b,`agents.${g}.mentions`,$))},{configPath:e.configPath});if(p.success||(console.log(re.red(` \u2717 ${p.error}`)),process.exit(1)),console.log(),console.log(re.green(` \u2713 Bot @${n.username} bound to agent "${g}"`)),console.log(re.dim(` Token stored in .env as ${f}`)),console.log(re.dim(` Mentions updated to include @${n.username}`)),p.reloaded?console.log(re.dim(" Daemon hot-reloaded.")):console.log(re.dim(" Start the daemon to begin polling (agentx daemon start)")),e.skipChatCapture)return;console.log();let{capture:h}=await Wn({type:"confirm",name:"capture",message:"Listen for a message so we can set this as your default --notify target?",initial:!0});if(!h)return;console.log(),console.log(re.dim(` Send any message to @${n.username} from the chat you want to use.`)),console.log(re.dim(" Waiting up to 90s..."));let w=await qy(t.trim(),9e4);if(!w){console.log(re.yellow(" No message received \u2014 skipping. You can set it later with:")),console.log(re.dim(" agentx config set notifications.destination.channel telegram")),console.log(re.dim(" agentx config set notifications.destination.chatId <chatId>")),console.log(re.dim(` agentx config set notifications.destination.accountId ${u}`));return}let k=await se(b=>{je(b,"notifications.destination",{channel:"telegram",chatId:String(w.chatId),accountId:u})},{configPath:e.configPath});if(!k.success){console.log(re.red(` \u2717 failed to save destination: ${k.error}`));return}console.log(re.green(" \u2713 Default --notify target set")),console.log(re.dim(` Chat: ${w.chatTitle||w.chatId} (from ${w.from})`)),console.log(re.dim(" From now on, --notify me resolves to this chat.")),k.reloaded&&console.log(re.dim(" Daemon hot-reloaded."))}import ke from"chalk";import _r from"prompts";import{existsSync as Pr,mkdirSync as Uy,readdirSync as Fy,readFileSync as Zg}from"fs";import{resolve as Dr}from"path";var Wy=".agentx/whatsapp-sessions";function By(){let e=Dr(process.cwd(),".agentx/daemon.pid");if(!Pr(e))return!1;try{let o=parseInt(Zg(e,"utf-8").trim(),10);return o?(process.kill(o,0),!0):!1}catch{return!1}}function Jy(e){if(!Pr(e))return!1;try{return Fy(e).some(o=>o.includes("creds")||o.endsWith(".json"))}catch{return!1}}async function Hy(e,o){let t;try{t=await import("@whiskeysockets/baileys")}catch{return o(ke.red(" WhatsApp pairing needs @whiskeysockets/baileys.")),o(ke.red(" Install with: pnpm add @whiskeysockets/baileys (or npm install)")),!1}let{makeWASocket:n,useMultiFileAuthState:s}=t.default||t;Uy(e,{recursive:!0});let{state:i,saveCreds:r}=await s(e),a;try{a=(await t.fetchLatestBaileysVersion()).version}catch{}let c={level:"silent",trace:()=>{},debug:()=>{},info:()=>{},warn:()=>{},fatal:()=>{},error:()=>{},child:()=>c},l=n({auth:{creds:i.creds,keys:t.makeCacheableSignalKeyStore?t.makeCacheableSignalKeyStore(i.keys,c):i.keys},...a?{version:a}:{},logger:c,printQRInTerminal:!1,browser:["agentx-connect","pairing","1.0"],syncFullHistory:!1,markOnlineOnConnect:!1});return l.ev.on("creds.update",r),await new Promise(g=>{let u=setTimeout(()=>{o(ke.yellow(" Timed out waiting for scan (2min)."));try{l.end(void 0)}catch{}g(!1)},12e4);l.ev.on("connection.update",async f=>{if(f.qr){o(ke.dim(" Scan this QR with WhatsApp \u2192 Linked devices \u2192 Link a device:")),o("");try{let{default:p}=await import("qrcode-terminal");p.generate(f.qr,{small:!0})}catch{o(` QR: ${f.qr}`)}o("")}if(f.connection==="open"){clearTimeout(u),o(ke.green(" \u2713 Paired"));try{l.end(void 0)}catch{}g(!0)}f.connection==="close"&&!f.qr&&f.lastDisconnect?.error?.output?.statusCode===401&&(clearTimeout(u),o(ke.red(" \u2717 Authorization failed \u2014 rescan required")),g(!1))})})}async function em(e={}){if(console.log(),console.log(ke.bold(" Connect WhatsApp")),console.log(),By()){console.log(ke.yellow(" \u26A0 The daemon is running. Stop it first so pairing can open a fresh Baileys session:")),console.log(ke.dim(" agentx daemon stop")),console.log();let{cont:l}=await _r({type:"confirm",name:"cont",message:"Continue anyway? (expect errors)",initial:!1});l||(console.log(ke.red(" Aborted")),process.exit(1))}let o=e.configPath||Dr(process.cwd(),"agentx.json");Pr(o)||(console.log(ke.red(` No agentx.json at ${o}. Run: agentx init`)),process.exit(1));let t=JSON.parse(Zg(o,"utf-8")),n=e.sessionDir||t.channels?.whatsapp?.sessionDir||Wy,s=Dr(process.cwd(),n),i=Object.keys(t.agents||{});i.length===0&&(console.log(ke.red(" No agents configured. Run: agentx agent add")),process.exit(1));let r=e.agent;r||(r=(await _r({type:"select",name:"agent",message:"Default agent for incoming messages:",choices:i.map(g=>({title:g,value:g})),initial:0})).agent),r||(console.log(ke.red(" Aborted")),process.exit(1));let a=!e.skipPair;if(Jy(s)&&a){let{keep:l}=await _r({type:"confirm",name:"keep",message:`An existing session was found at ${n}. Keep it (recommended), or pair again?`,initial:!0});a=!l,l&&console.log(ke.dim(" Keeping existing session \u2014 skipping QR pair."))}a&&(await Hy(s,g=>console.log(g))||(console.log(ke.red(" Pairing failed. You can retry with `agentx connect whatsapp`.")),process.exit(1)));let c=await se(l=>{je(l,"channels.whatsapp.enabled",!0),je(l,"channels.whatsapp.sessionDir",n),je(l,"channels.whatsapp.defaultAgent",r)},{configPath:e.configPath});c.success||(console.log(ke.red(` \u2717 ${c.error}`)),process.exit(1)),console.log(),console.log(ke.green(` \u2713 WhatsApp bound to agent "${r}"`)),console.log(ke.dim(` Session: ${n}`)),console.log(ke.dim(" Start the daemon to begin receiving:")),console.log(ke.dim(" agentx daemon start")),console.log(ke.dim(" Add routes later with:")),console.log(ke.dim(` agentx config set channels.whatsapp.routes '[{"contact":"+1234567890","agent":"${r}"}]'`)),console.log()}import{randomBytes as Gy}from"crypto";import Te from"chalk";import om from"prompts";var Xs="agentx-mesh:",Qs="//join/";function zy(e){return Buffer.from(e,"utf-8").toString("base64url")}function Yy(e){return Buffer.from(e,"base64url").toString("utf-8")}function Vy(e){return`${Xs}${Qs}${zy(JSON.stringify(e))}`}function Ky(e){if(!e.startsWith(`${Xs}${Qs}`))throw new Error(`Not a mesh invite link \u2014 expected ${Xs}${Qs}\u2026`);let o=e.slice(Xs.length+Qs.length),t=JSON.parse(Yy(o));if(t.version!==1)throw new Error(`Unsupported invite version: ${t.version}`);if(typeof t.url!="string"||typeof t.token!="string"||typeof t.name!="string")throw new Error("Invite payload missing required fields (url, token, name)");return t}function Xy(){return Gy(32).toString("hex")}function Qy(e){let o=e?.node?.bind||"127.0.0.1:18800",[t,n]=o.split(":");return`http://${t}:${n}`}function Zy(e){return e?.node?.name||e?.node?.id||"node"}async function tm(e){let{readFileSync:o,existsSync:t}=await import("fs"),{resolve:n}=await import("path"),s=e.configPath||n(process.cwd(),"agentx.json");t(s)||(console.log(Te.red(` No agentx.json at ${s}. Run: agentx init`)),process.exit(1));let i=JSON.parse(o(s,"utf-8")),r=Rr("MESH_TOKEN");r||(r=Xy(),Fn("MESH_TOKEN",r),console.log(Te.dim(" Generated new MESH_TOKEN (32 bytes) and saved to .env")));let a=e.url||Qy(i);if((a.includes("0.0.0.0")||a.includes("127.0.0.1")||a.includes("localhost"))&&!e.url){let{url:d}=await om({type:"text",name:"url",message:"This node's URL as peers should reach it (e.g. http://100.x.x.x:18800):",initial:a,validate:u=>/^https?:\/\//.test(u)||"must start with http:// or https://"});d||(console.log(Te.red(" Aborted")),process.exit(1)),a=d}let l=await se(d=>{je(d,"mesh.enabled",!0)},{configPath:e.configPath});l.success||(console.log(Te.red(` \u2717 ${l.error}`)),process.exit(1));let g=Vy({url:a,token:r,name:Zy(i),version:1});console.log(),console.log(Te.bold(" Mesh invite")),console.log(),console.log(` ${Te.cyan(g)}`),console.log(),console.log(Te.dim(" Run on the other node:")),console.log(Te.dim(` agentx connect mesh join "${g}"`)),console.log(),console.log(Te.yellow(" Share over a trusted channel only \u2014 whoever holds this link can join your mesh.")),console.log()}async function nm(e,o={}){let t;try{t=Ky(e)}catch(i){console.log(Te.red(` \u2717 ${i.message}`)),process.exit(1)}let n=Rr("MESH_TOKEN");if(n&&n!==t.token){let{overwrite:i}=await om({type:"confirm",name:"overwrite",message:"A different MESH_TOKEN already exists in .env. Overwrite with the invite's token?",initial:!1});i||(console.log(Te.red(" Aborted (keeping existing .env)")),process.exit(1))}Fn("MESH_TOKEN",t.token);let s=await se(i=>{je(i,"mesh.enabled",!0);let r=Ot(i,"mesh.peers")||[],a=r.findIndex(l=>l.name===t.name),c={name:t.name,url:t.url,token:"${MESH_TOKEN}"};a>=0?r[a]=c:r.push(c),je(i,"mesh.peers",r)},{configPath:o.configPath});s.success||(console.log(Te.red(` \u2717 ${s.error}`)),process.exit(1)),console.log(Te.green(" \u2713 Joined mesh")),console.log(Te.dim(` Peer: ${t.name} @ ${t.url}`)),console.log(Te.dim(" Shared token stored in .env as MESH_TOKEN")),s.reloaded?console.log(Te.dim(" Daemon hot-reloaded.")):console.log(Te.dim(" Restart the daemon to start the mesh (agentx daemon start).")),console.log();try{let i=await fetch(`${t.url.replace(/\/$/,"")}/.well-known/agent-card.json`,{signal:AbortSignal.timeout(5e3)});if(i.ok){let r=await i.json(),a=Array.isArray(r.agents)?r.agents.length:"?";console.log(Te.dim(` Reachable \u2014 ${t.name} exposes ${a} agents`))}else console.log(Te.yellow(` Peer returned HTTP ${i.status} \u2014 double-check the URL`))}catch(i){console.log(Te.yellow(` Could not reach ${t.url} right now (${i?.cause?.code||i.message}) \u2014 verify VPN / Tailscale when the peer daemon is up`))}}var Zt=new ew().name("connect").description("connect a channel or mesh peer \u2014 no manual file editing required");Zt.command("telegram").description("pair a Telegram bot \u2014 persists token in .env, binds to an agent, auto-detects default chat").option("--agent <id>","agent to bind the bot to (skips the prompt)").option("--account <name>","account label in channels.telegram.accounts (defaults to agent id)").option("--skip-chat-capture","don't listen for the first message after pairing").option("-c, --config <path>","path to agentx.json").action(async e=>{await Qg({agent:e.agent,account:e.account,configPath:e.config,skipChatCapture:!!e.skipChatCapture})});Zt.command("whatsapp").description("pair WhatsApp via QR (prints in terminal), then writes channels.whatsapp config").option("--agent <id>","default agent for inbound messages").option("--session-dir <path>","session directory (default: .agentx/whatsapp-sessions)").option("--skip-pair","skip QR pairing (use when session already exists)").option("-c, --config <path>","path to agentx.json").action(async e=>{await em({agent:e.agent,sessionDir:e.sessionDir,skipPair:!!e.skipPair,configPath:e.config})});var sm=Zt.command("mesh").description("mesh invite + join \u2014 replaces manual MESH_TOKEN copy-paste");sm.command("invite").description("emit a single-use join link for another AgentX node").option("--url <url>","this node's URL as peers should reach it (Tailscale IP etc.)").option("-c, --config <path>","path to agentx.json").action(async e=>{await tm({url:e.url,configPath:e.config})});sm.command("join <link>").description("accept an invite link from another AgentX node").option("-c, --config <path>","path to agentx.json").action(async(e,o)=>{await nm(e,{configPath:o.config})});Zt.action(()=>{console.log(),console.log(Qt.bold(" agentx connect \u2014 which channel?")),console.log(),console.log(` ${Qt.cyan("agentx connect telegram")} \u2014 pair a Telegram bot`),console.log(` ${Qt.cyan("agentx connect whatsapp")} \u2014 pair WhatsApp via QR`),console.log(` ${Qt.cyan("agentx connect mesh invite")} \u2014 emit a mesh join link for another node`),console.log(` ${Qt.cyan("agentx connect mesh join <link>")} \u2014 accept a mesh invite`),console.log(),console.log(Qt.dim(" GitLab connect is the next slice.")),console.log()});ee();import{Command as ow}from"commander";import he from"chalk";var Bn=new ow().name("usage").description("token usage analysis and reporting");Bn.command("today",{isDefault:!0}).description("show today's token usage").action(async()=>{try{let e=O(),[o,t]=e.node.bind.split(":"),s=await(await fetch(`http://${o||"127.0.0.1"}:${t}/usage`,{signal:AbortSignal.timeout(3e3)})).json();if(console.log(),console.log(he.bold(" Token Usage (last 7 days)")),console.log(),s.totalTasks===0){console.log(he.dim(" No tasks recorded yet")),console.log();return}let i=a=>a.toLocaleString();console.log(` Total: ${he.bold(i(s.totalTokens))} tokens across ${s.totalTasks} tasks`),console.log(` Input: ${i(s.totalInput)}`),console.log(` Output: ${i(s.totalOutput)}`),console.log(` Cache read: ${i(s.totalCacheRead)}`),console.log(` Cache create: ${i(s.totalCacheCreate)}`),s.cacheHitRatio>0&&console.log(` Cache hit: ${(s.cacheHitRatio*100).toFixed(1)}%`),s.totalErrors>0&&console.log(` Errors: ${he.red(String(s.totalErrors))}`),console.log(),console.log(he.bold(" By Agent:"));let r=Object.entries(s.byAgent||{});r.sort((a,c)=>c[1].total-a[1].total);for(let[a,c]of r){let l=i(c.total||c.input+c.output+c.cacheRead+c.cacheCreate),g=c.avgDuration?`${(c.avgDuration/1e3).toFixed(1)}s avg`:"";console.log(` ${he.cyan(a)}: ${l} tokens (${c.tasks} tasks) ${he.dim(g)}`)}console.log()}catch(e){e.cause?.code==="ECONNREFUSED"?console.log(he.red(" Daemon not running. Start with: agentx daemon start")):console.log(he.red(` ${e.message}`))}});Bn.command("report").description("run full session analysis (parses Claude Code JSONL files)").option("--days <n>","analyze last N days","7").action(async e=>{let{execSync:o}=await import("child_process"),{existsSync:t}=await import("fs"),{resolve:n}=await import("path"),s=n(process.cwd(),"scripts/token-report.py");if(!t(s)){console.log(he.red(` Script not found: ${s}`)),console.log(he.dim(" The token analyzer script should be at scripts/token-report.py"));return}console.log(he.dim(" Analyzing Claude Code sessions..."));try{o(`SINCE_DAYS=${e.days} python3 "${s}"`,{stdio:"inherit"})}catch{console.log(he.red(" Analysis failed. Is Python 3 installed?"))}});Bn.command("surfaces").description("which CLI commands and dashboard pages are actually used").option("--days <n>","window in days","30").option("--kind <kind>","cli | page (default: both)").option("--unused","list registered surfaces with ZERO recorded use instead").option("--json","raw JSON output").action(async e=>{let{listSurfaceUse:o}=await import("./surface-usage-O5L4KLGS.js"),t=e.kind==="cli"||e.kind==="page"?e.kind:void 0,n=o({kind:t,sinceDays:Number(e.days)||30});if(e.unused){let{buildProgram:i}=await import("./program-7UH4FCA3.js"),r=await i(),a=new Set(n.filter(d=>d.kind==="cli").map(d=>d.name)),c=[],l=(d,u)=>{for(let f of d.commands??[]){let p=u?`${u} ${f.name()}`:f.name();c.push(p),l(f,p)}};l(r,"");let g=c.filter(d=>!a.has(d)).sort();if(e.json){console.log(JSON.stringify({windowDays:Number(e.days)||30,unused:g},null,2));return}console.log(),console.log(he.bold(` Never used in the last ${e.days} days (${g.length}/${c.length})`)),console.log();for(let d of g)console.log(` ${he.dim("\xB7")} ${d}`);console.log(),console.log(he.dim(" Zero use is necessary but not sufficient to remove a surface \u2014")),console.log(he.dim(" it must also fail the impact test. See docs/architecture/surface-reduction.md")),console.log();return}if(e.json){console.log(JSON.stringify(n,null,2));return}if(n.length===0){console.log(),console.log(he.dim(` No surface usage recorded in the last ${e.days} days.`)),console.log(he.dim(" Counting starts once this build has been running for a while.")),console.log();return}console.log(),console.log(he.bold(` Surface usage \u2014 last ${e.days} days`)),console.log();let s="";for(let i of n){i.kind!==s&&(console.log(he.dim(` ${i.kind==="cli"?"CLI commands":"Dashboard pages"}`)),s=i.kind);let r=String(i.count).padStart(6),a=he.dim(`${i.days}d`);console.log(` ${he.cyan(r)} ${i.name.padEnd(28)} ${a}`)}console.log(),console.log(he.dim(` ${n.length} surface(s) with recorded use. See --unused for the rest.`)),console.log()});import{Command as tw}from"commander";import ve from"chalk";import{readFileSync as nw}from"fs";import{resolve as sw}from"path";ee();var Vo=new tw().name("board").description("kanban board dashboard \u2014 visual work view over configured sources");Vo.command("serve",{isDefault:!0}).description("start the dashboard server (live view always; boards if configured)").option("--port <n>","override dashboard.port").option("--bind <host>","override dashboard.bind (e.g. 0.0.0.0)").action(async e=>{try{try{Ca(sw(process.cwd(),".env"))}catch{}let o=iw(e.port,e.bind),{startBoardDashboard:t}=await import("./board-dashboard-TWEF5XVE.js");t(o)}catch(o){console.log(ve.red(` ${o.message}`)),process.env.DEBUG&&o.stack&&console.log(ve.dim(o.stack)),process.exit(1)}});function iw(e,o){try{let t=O();return e&&(t.dashboard.port=parseInt(e,10)),o&&(t.dashboard.bind=o),t}catch{return console.log(ve.yellow(" No agentx.json found \u2014 starting dashboard in setup-only mode.")),console.log(ve.dim(" Visit http://127.0.0.1:"+(e||"4202")+` to run the wizard.
|
|
424
424
|
`)),{node:{id:"setup",name:"Setup",bind:"127.0.0.1:18800"},providers:{},agents:{},channels:{},crons:{},mesh:{enabled:!1,peers:[],discovery:"static",healthCheck:{interval:60,timeout:10}},boards:[],dashboard:{enabled:!0,port:e?parseInt(e,10):4202,bind:o||"127.0.0.1",daemonUrl:"http://localhost:18800",daemons:[]},business:void 0,session:{staleMinutes:120}}}}Vo.command("list").description("list configured boards").action(()=>{try{let e=O();if(!e.boards?.length){console.log(ve.dim(`
|
|
425
425
|
No boards configured.
|
|
426
426
|
`));return}console.log();for(let o of e.boards){console.log(` ${ve.cyan(o.id)} \u2014 ${o.name}`);let t=o.source;console.log(ve.dim(` source: ${t.type}${t.projects?" ("+t.projects.join(", ")+")":""}`)),o.primaryToolLabel&&console.log(ve.dim(` primary label: ${o.primaryToolLabel}`)),console.log(ve.dim(` window: ${o.timeRangeDays} days`))}console.log()}catch(e){console.log(ve.red(` ${e.message}`)),process.exit(1)}});Vo.command("add <id>").description("add a GitLab board to agentx.json").requiredOption("--name <name>","human-readable board name").requiredOption("--projects <paths>","comma-separated GitLab project paths (e.g. 'globex/system,globex/website')").option("--label <label>","primary tool label ANDed into every query (e.g. 'Tool::Claude')").option("--days <n>","open-window time range in days","30").option("--closed-days <n>","closed-window in days","30").action((e,o)=>{try{Jn(t=>{if(Array.isArray(t.boards)||(t.boards=[]),t.boards.find(i=>i.id===e))throw new Error(`board "${e}" already exists`);let n=String(o.projects).split(",").map(i=>i.trim()).filter(Boolean);if(n.length===0)throw new Error("--projects must include at least one path");let s={id:e,name:o.name,source:{type:"gitlab",projects:n},timeRangeDays:parseInt(o.days,10)||30,closedWindowDays:parseInt(o.closedDays,10)||30};return o.label&&(s.primaryToolLabel=o.label),t.boards.push(s),`added board "${e}" (${n.join(", ")})`})}catch(t){console.log(ve.red(` ${t.message}`)),process.exit(1)}});Vo.command("edit <id>").description("edit board fields without re-creating it").option("--name <name>","rename").option("--projects <paths>","comma-separated GitLab project paths (replaces the list)").option("--label <label>","primary tool label (set to '-' to clear)").option("--days <n>","open-window time range in days").option("--closed-days <n>","closed-window in days").action((e,o)=>{try{Jn(t=>{let s=(Array.isArray(t.boards)?t.boards:[]).find(r=>r.id===e);if(!s)throw new Error(`board "${e}" not found`);let i=[];if(o.name&&(s.name=o.name,i.push(`name="${o.name}"`)),o.projects){let r=String(o.projects).split(",").map(a=>a.trim()).filter(Boolean);if(r.length===0)throw new Error("--projects must include at least one path");s.source={...s.source||{type:"gitlab"},type:"gitlab",projects:r},i.push(`projects=${r.length}`)}if(o.label!==void 0&&(o.label==="-"?(delete s.primaryToolLabel,i.push("label cleared")):(s.primaryToolLabel=o.label,i.push(`label="${o.label}"`))),o.days&&(s.timeRangeDays=parseInt(o.days,10)||s.timeRangeDays,i.push(`days=${s.timeRangeDays}`)),o.closedDays&&(s.closedWindowDays=parseInt(o.closedDays,10)||s.closedWindowDays,i.push(`closed-days=${s.closedWindowDays}`)),i.length===0)throw new Error("no changes \u2014 pass at least one option");return`board "${e}" updated (${i.join(", ")})`})}catch(t){console.log(ve.red(` ${t.message}`)),process.exit(1)}});var Mr=Vo.command("column").description("manage a board's columns (add / remove / edit / list)");Mr.command("list <boardId>").description("list columns on a board, in order").action(e=>{try{let t=(JSON.parse(nw("agentx.json","utf-8")).boards||[]).find(s=>s.id===e);if(!t)throw new Error(`board "${e}" not found`);let n=t.columns||[];if(n.length===0){console.log(ve.dim(" no columns (board falls back to GitLab default flow)"));return}for(let s of n){let i=s.kind==="scoped-label"?`scoped="${s.scopedLabel}"`:s.kind==="label"?`label="${s.mapsToLabel||""}"`:s.kind==="open-backlog"?`prefix="${s.scopedPrefix}"`:s.kind;console.log(` ${ve.cyan(s.id.padEnd(12))} ${s.title.padEnd(14)} ${ve.dim(i)}`)}}catch(o){console.log(ve.red(` ${o.message}`)),process.exit(1)}});Mr.command("add <boardId> <columnId>").description("add a column to a board").requiredOption("--title <title>","column title").option("--kind <kind>","open-backlog | scoped-label | closed | label","scoped-label").option("--scoped <label>","for kind=scoped-label, the full label (e.g. 'Status::Doing')").option("--label <label>","for kind=label, the label name to add/remove").option("--scoped-prefix <prefix>","for kind=open-backlog/scoped-label","Status").option("--accent <color>","hex/CSS color for the column accent bar").action((e,o,t)=>{try{Jn(n=>{let i=(Array.isArray(n.boards)?n.boards:[]).find(a=>a.id===e);if(!i)throw new Error(`board "${e}" not found`);if(i.columns=i.columns||[],i.columns.find(a=>a.id===o))throw new Error(`column "${o}" already exists on board "${e}"`);let r={id:o,title:t.title,kind:t.kind,scopedPrefix:t.scopedPrefix};if(t.kind==="scoped-label"){if(!t.scoped)throw new Error("--scoped required for kind=scoped-label");r.scopedLabel=t.scoped}if(t.kind==="label"){if(!t.label)throw new Error("--label required for kind=label");r.mapsToLabel=t.label}return t.accent&&(r.accent=t.accent),i.columns.push(r),`column "${o}" added to board "${e}"`})}catch(n){console.log(ve.red(` ${n.message}`)),process.exit(1)}});Mr.command("remove <boardId> <columnId>").alias("rm").description("remove a column from a board").action((e,o)=>{try{Jn(t=>{let s=(Array.isArray(t.boards)?t.boards:[]).find(r=>r.id===e);if(!s)throw new Error(`board "${e}" not found`);let i=(s.columns||[]).length;if(s.columns=(s.columns||[]).filter(r=>r.id!==o),s.columns.length===i)throw new Error(`column "${o}" not found`);return`column "${o}" removed from board "${e}"`})}catch(t){console.log(ve.red(` ${t.message}`)),process.exit(1)}});Vo.command("remove <id>").alias("rm").description("remove a board from agentx.json").action(e=>{try{Jn(o=>{if(!Array.isArray(o.boards)||o.boards.length===0)throw new Error("no boards configured");let t=o.boards.length;if(o.boards=o.boards.filter(n=>n.id!==e),o.boards.length===t)throw new Error(`board "${e}" not found`);return`removed board "${e}"`})}catch(o){console.log(ve.red(` ${o.message}`)),process.exit(1)}});function Jn(e){let{summary:o,backupPath:t}=eo(n=>e(n));console.log(ve.green(`
|
|
@@ -647,7 +647,7 @@ Restart the daemon to activate.
|
|
|
647
647
|
dist/
|
|
648
648
|
*.log
|
|
649
649
|
.env
|
|
650
|
-
`}import{Command as K$}from"commander";import _e from"chalk";import{writeFileSync as X$,mkdirSync as Q$,existsSync as fi,readFileSync as ep,appendFileSync as op}from"fs";import{resolve as pn,dirname as sp}from"path";import{homedir as ia}from"os";var ip=new K$().name("completion").description("generate a shell completion script for agentx").option("-s, --shell <shell>","shell to generate completion for: zsh|bash|fish","zsh").option("-i, --install","install the completion script to a default path for the shell").option("-o, --output <path>","write the script to this path (overrides default install path)").option("-y, --yes","skip confirmation prompts (non-interactive)").action(async e=>{let{buildProgram:o}=await import("./program-
|
|
650
|
+
`}import{Command as K$}from"commander";import _e from"chalk";import{writeFileSync as X$,mkdirSync as Q$,existsSync as fi,readFileSync as ep,appendFileSync as op}from"fs";import{resolve as pn,dirname as sp}from"path";import{homedir as ia}from"os";var ip=new K$().name("completion").description("generate a shell completion script for agentx").option("-s, --shell <shell>","shell to generate completion for: zsh|bash|fish","zsh").option("-i, --install","install the completion script to a default path for the shell").option("-o, --output <path>","write the script to this path (overrides default install path)").option("-y, --yes","skip confirmation prompts (non-interactive)").action(async e=>{let{buildProgram:o}=await import("./program-7UH4FCA3.js"),t=await o(),n=String(e.shell||"zsh").toLowerCase(),s;switch(n){case"zsh":s=ob(t);break;case"bash":s=rb(t);break;case"fish":s=ab(t);break;default:console.error(_e.red(`unsupported shell: ${n}`)),console.error(_e.dim("supported: zsh, bash, fish")),process.exit(1)}if(!e.install&&!e.output){process.stdout.write(s);return}let i=e.output?pn(String(e.output)):Z$(n);Q$(sp(i),{recursive:!0}),X$(i,s),console.log(_e.green(`\u2713 Wrote ${n} completion to:`)),console.log(` ${i}`),console.log(),eb(n,i,!!e.yes)});function Z$(e){let o=ia();switch(e){case"zsh":return pn(o,".zsh","completions","_agentx");case"bash":return pn(o,".bash_completion.d","agentx.bash");case"fish":return pn(o,".config","fish","completions","agentx.fish");default:throw new Error(`unsupported shell: ${e}`)}}function eb(e,o,t){if(e==="zsh"){let n=pn(ia(),".zshrc"),s=sp(o),i=`fpath=(${s} $fpath)`,r="autoload -U compinit && compinit",a=fi(n)?ep(n,"utf-8"):"",c=!a.includes(s),l=!/autoload\s+-U\s+compinit/.test(a);if(!c&&!l){console.log(_e.dim("~/.zshrc already has fpath + compinit wired up. Run `exec zsh` to pick up the new script."));return}if(t&&fi(n)){let g=["","# agentx completion"];c&&g.push(i),l&&g.push(r),op(n,g.join(`
|
|
651
651
|
`)+`
|
|
652
652
|
`),console.log(_e.green("\u2713 Patched ~/.zshrc")),console.log(_e.dim("Reload your shell: exec zsh"));return}console.log(_e.dim("Add this to ~/.zshrc if not already present:")),c&&console.log(_e.cyan(` ${i}`)),l&&console.log(_e.cyan(` ${r}`)),console.log(),console.log(_e.dim("Then reload: exec zsh")),console.log(_e.dim("Or rerun with --yes to auto-patch ~/.zshrc"));return}if(e==="bash"){let n=pn(ia(),".bashrc"),s=`[ -f "${o}" ] && source "${o}"`;if((fi(n)?ep(n,"utf-8"):"").includes(o)){console.log(_e.dim("~/.bashrc already sources this file. Start a new shell to pick it up."));return}if(t&&fi(n)){op(n,`
|
|
653
653
|
# agentx completion
|
|
@@ -663,4 +663,4 @@ ${cb({...o,category:e.category})}`),g&&a.set(l.id,g)}let c=`https://github.com/$
|
|
|
663
663
|
${t.url}`)}catch(o){console.error(fn.red(` ${o.message}`)),process.exitCode=1}});os.command("draft <file>").description("turn a draft JSON file ({category, title, fields}) into a pre-filled issue form link; '-' reads stdin").requiredOption("--model <model>","the model that wrote the draft").option("--models <pathOrUrl>","model list to read",aa).action(async(e,o)=>{try{let t=await da(o.models);if(!ca(o.model,t)){console.log(la(o.model,t)),process.exitCode=1;return}let n=e==="-"?await gb():await db(e,"utf8"),s=JSON.parse(n),{version:i}=await cs(),r=lp({...s,fields:s.fields??{}},{model:o.model,version:i??"unknown"});console.log(r)}catch(t){console.error(fn.red(` ${t.message}`)),process.exitCode=1}});async function gb(){let e=[];for await(let o of process.stdin)e.push(o);return Buffer.concat(e).toString("utf8")}async function Oj(){let e=await cs(),o=new mb().name("agentx").description("self-hosted multi-agent orchestrator \u2014 Telegram, WhatsApp, crons, A2A mesh, wiki knowledge").version(e.version||"1.0.0","-v, --version","display the version number");o.hook("preAction",(t,n)=>{let s=Il(n);Nl(s)&&jl("cli",s)});for(let t of[sd,nd,Zt,_t,Mt,no,Al,st,js,Eo,To,Kt,Yg,zo,Cs,Nm,Jo,Sd,Rd,Mn,Jd,Yd,Xd,eg,og,wg,vg,xg,zt,Bn,Mm,jn,qo,ip,os])o.addCommand(t);for(let t of gp)o.addCommand(t,{hidden:!0});return o.addHelpText("after",()=>{let t=gp.map(n=>n.name()).sort();return["",`Advanced (${t.length}, hidden \u2014 run \`agentx <command> --help\` for any of them):`,pb(t,74," "),""].join(`
|
|
664
664
|
`)}),o}var gp=[oe,tn,Qo,po,Nn,Yt,Ke,Co,Vo,ut,an,cn,Wo,Ge,Ft,Ys,Cm,jm,xo,it,Ml,rt,Zn,sr,Xo,Yo,qt,ir,ci,bo,jo,zm,Vm,Pm];function pb(e,o,t){let n=[],s="";for(let i of e)s&&s.length+i.length+2>o&&(n.push(t+s),s=""),s+=(s?", ":"")+i;return s&&n.push(t+s),n.join(`
|
|
665
665
|
`)}export{Oj as buildProgram};
|
|
666
|
-
//# sourceMappingURL=program-
|
|
666
|
+
//# sourceMappingURL=program-7UH4FCA3.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=registry-
|
|
1
|
+
import{K as a,L as b,M as c,N as d,O as e,P as f,Q as g,R as h,S as i,T as j,U as k,V as l}from"./chunk-V4GXHBOH.js";import"./chunk-ES7Z64Z5.js";import"./chunk-GLQLCBJS.js";import"./chunk-DP7RTNDM.js";import"./chunk-SZDACK6O.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-4KJ3PCAI.js";import"./chunk-XF65CDNS.js";import"./chunk-VWTBHLMX.js";import"./chunk-ATXE3EMV.js";import"./chunk-LUL4ILAQ.js";import"./chunk-KA2UIZXG.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-74FSHUB3.js";import"./chunk-MYVHVJWZ.js";import"./chunk-DWADWDMU.js";import"./chunk-23A5K5UW.js";import"./chunk-QD6IICK7.js";import"./chunk-CECHWYJ2.js";import"./chunk-HUQRPEDP.js";import"./chunk-GUAJNZIX.js";import"./chunk-WPNRDEHW.js";import"./chunk-2GIDVZ4H.js";import"./chunk-5GXCOHDM.js";import"./chunk-72SZI2UW.js";import"./chunk-FX3D7YON.js";import"./chunk-FCPTN6NF.js";import"./chunk-QOYAX2FT.js";import"./chunk-5MUJZODV.js";import"./chunk-7I7IEX4S.js";import"./chunk-DSYKYZMT.js";import"./chunk-LTHQXWZN.js";import"./chunk-UCKKAWLZ.js";import"./chunk-PN6XHTG5.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{k as AgentRegistry,f as TRACE_STEP_SUMMARY_BYTES,c as buildEntryMeta,d as buildEventDigest,e as buildWikiContext,g as clipForTrace,j as emitTraceStepsFromStreamEvent,i as firstMissingRequiredTool,b as getGlobalRegistry,l as richReplyPrompt,a as setGlobalRegistry,h as tallyToolUses};
|
|
2
|
+
//# sourceMappingURL=registry-MDWD7EAO.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as g}from"./chunk-TW4L6RP2.js";import"./chunk-RKPAVWXF.js";import{b as h}from"./chunk-
|
|
1
|
+
import{b as g}from"./chunk-TW4L6RP2.js";import"./chunk-RKPAVWXF.js";import{b as h}from"./chunk-LLNPKE7H.js";import"./chunk-SHEUCITK.js";import"./chunk-BB3ESU74.js";import"./chunk-4KJ3PCAI.js";import"./chunk-XF65CDNS.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-LTHQXWZN.js";import"./chunk-UCKKAWLZ.js";import"./chunk-PN6XHTG5.js";import"./chunk-QIJLFPWE.js";var $=t=>typeof t=="string"?t.trim():"",w={in_progress:"in progress",waiting_owner:"waiting on the owner",waiting_other:"waiting on another agent",needs_attention:"needs attention"};function f(t){return t.length?t.map(e=>{let i=new Date(e.createdAt).toISOString().slice(0,16).replace("T"," "),a=e.state==="waiting_owner"&&e.question?` Question: ${e.question}`:e.state==="needs_attention"&&e.attentionReason?` ${e.attentionReason}`:"",n=String(e.text).replace(/\s+/g," ").trim();return`- ${e.id} [${w[e.state]??e.state}] ${i} UTC, ${e.channel}, ${e.agentId}: ${n.length>160?`${n.slice(0,159)}\u2026`:n}.${a}`}).join(`
|
|
2
2
|
`):"No open requests."}async function m(t,e){let i=e.fetch??fetch,a=e.daemonUrl.replace(/\/$/,""),n=($(t.action)||"list").toLowerCase();try{if(n==="list"){let d=await i(`${a}/requests`,{signal:AbortSignal.timeout(1e4)}),r=await d.json().catch(()=>({}));return d.ok?r.enabled?`${r.count} open request${r.count===1?"":"s"}, oldest first.
|
|
3
3
|
${f(r.items??[])}`:"Requests are turned off on this node (requests.enabled), so nothing is recorded.":`Error: ${r?.error||`HTTP ${d.status}`}`}let s=e.env??process.env,u=g(t,s);if(!u)return"Error: couldn't tell which agent you are. Pass callerAgentId.";let c=await i(`${a}/requests`,{method:"POST",headers:{"Content-Type":"application/json",...h(s)},body:JSON.stringify({action:n,agentId:u.agentId,id:t.id,question:t.question,evidence:t.evidence,reason:t.reason}),signal:AbortSignal.timeout(1e4)}),l=await c.json().catch(()=>({}));if(!c.ok)return`Error: ${l?.error||`HTTP ${c.status}`}`;let o=l.request;return n==="accept"?`Request ${o.id} is open and in progress. Close it with done (and a link to the evidence) or decline (and the reason); it stays on the owner's list until then.`:n==="wait"?`Request ${o.id} is waiting on the owner with your question. Ask them the question now, once.`:n==="done"?`Request ${o.id} is closed as done. Evidence: ${o.evidence}`:`Request ${o.id} is closed as declined. Reason: ${o.closeReason}`}catch(s){return`Error: couldn't reach the daemon (${s?.message??s}).`}}export{f as describeOpen,m as runRequestTool};
|
|
4
|
-
//# sourceMappingURL=tool-
|
|
4
|
+
//# sourceMappingURL=tool-GPCJM7U5.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as h}from"./chunk-TW4L6RP2.js";import"./chunk-RKPAVWXF.js";import{f}from"./chunk-Y4CYQV7G.js";import{b as u}from"./chunk-
|
|
1
|
+
import{b as h}from"./chunk-TW4L6RP2.js";import"./chunk-RKPAVWXF.js";import{f}from"./chunk-Y4CYQV7G.js";import{b as u}from"./chunk-LLNPKE7H.js";import"./chunk-SHEUCITK.js";import"./chunk-BB3ESU74.js";import"./chunk-4KJ3PCAI.js";import"./chunk-XF65CDNS.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-LTHQXWZN.js";import"./chunk-UCKKAWLZ.js";import"./chunk-PN6XHTG5.js";import"./chunk-QIJLFPWE.js";var m=new Set(["cron","heartbeat","api","a2a","mesh","approvals","requests"]);function y(e){return typeof e=="string"?e.trim():""}async function A(e,i){let c=i.fetch??fetch,d=i.daemonUrl.replace(/\/$/,""),s=(y(e.action)||"create").toLowerCase(),r=h(e,i.env??process.env);if(s==="status"){let o=y(e.id);if(!o)return"Error: `id` is required for status (the card id you got when you raised it).";try{let n=await c(`${d}/approvals/${encodeURIComponent(o)}`,{signal:AbortSignal.timeout(1e4)}),a=await n.json().catch(()=>({}));if(!n.ok)return`Error: ${a?.error||`HTTP ${n.status}`}`;let t=a.card;if(r&&t.raised_by!==r.agentId)return`Error: card "${o}" was raised by another agent.`;if(t.status==="pending")return`Card ${t.id} is still waiting for the operator. It expires ${t.expires}; then "${t.if_silent}" applies.`;if(t.status==="decided"){let p=t.verdict==="yes"?f(t).join(`
|
|
2
2
|
`):"";return`Card ${t.id}: the operator said ${String(t.verdict).toUpperCase()}.${t.note?` Note: ${t.note}`:""}${p?`
|
|
3
3
|
${p}`:""}`}return`Card ${t.id} expired unanswered; the default applied: ${t.outcome??t.if_silent}.`}catch(n){return`Error: couldn't reach the daemon (${n?.message??n}).`}}if(s!=="create")return`Error: unknown action "${s}". Use create or status.`;if(!r)return"Error: couldn't tell which agent you are. Pass callerAgentId.";let l=r.channel&&r.chatId&&!m.has(r.channel)?{channel:r.channel,chatId:r.chatId,...r.accountId?{accountId:r.accountId}:{}}:void 0,$={title:e.title,ask:e.ask,recommend:e.recommend,if_silent:e.if_silent,expires:e.expires,source:e.source,choices:e.choices,draft:e.draft,say:e.say,context:e.context,raised_by:r.agentId,...l?{reply:l}:{}};try{let o=await c(`${d}/approvals`,{method:"POST",headers:{"Content-Type":"application/json",...u(i.env??process.env)},body:JSON.stringify($),signal:AbortSignal.timeout(1e4)}),n=await o.json().catch(()=>({}));if(!o.ok)return`Error: ${n?.error||`HTTP ${o.status}`}`;let a=n.card;return[`Decision card ${a.id} is in the operator's Approvals inbox.`,`If nobody answers by ${a.expires}, "${a.if_silent}" applies.`,"You will get a message with the result. Tell the requester it is waiting for approval; don't ask the operator again in chat."].join(" ")}catch(o){return`Error: couldn't reach the daemon (${o?.message??o}).`}}export{A as runApprovalTool};
|
|
4
|
-
//# sourceMappingURL=tool-
|
|
4
|
+
//# sourceMappingURL=tool-VKQIDEG7.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentix-cli",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.1",
|
|
4
4
|
"description": "AI operations layer for small and medium businesses. Routes Telegram, WhatsApp, GitLab, GitHub, crons, webhooks, and mesh tasks to AI agents. Web wizard for operators, CLI for engineers. Self-hosted.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|