agentix-cli 0.207.2 → 0.208.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/{board-dashboard-DWJPDDGM.js → board-dashboard-6KGRVAK6.js} +2 -2
- package/dist/{chunk-S2LHJSB5.js → chunk-2BWTUD6Z.js} +1 -1
- package/dist/chunk-2BWTUD6Z.js.map +1 -0
- package/dist/{chunk-4M26YGFM.js → chunk-N2E73XNT.js} +3 -3
- package/dist/{chunk-LNGTVK6V.js → chunk-OW4XJDFO.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{program-RVODWQAM.js → program-AJVTYLTY.js} +5 -5
- package/dist/program-AJVTYLTY.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-S2LHJSB5.js.map +0 -1
- package/dist/program-RVODWQAM.js.map +0 -1
- /package/dist/{board-dashboard-DWJPDDGM.js.map → board-dashboard-6KGRVAK6.js.map} +0 -0
- /package/dist/{chunk-4M26YGFM.js.map → chunk-N2E73XNT.js.map} +0 -0
- /package/dist/{chunk-LNGTVK6V.js.map → chunk-OW4XJDFO.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$a as Nc,A as Tm,Aa as cy,Ab as Wy,B as Am,Ba as ly,C as rn,Ca as Mc,D as Pr,Da as Nr,E as xm,Ea as dy,F as Rm,Fb as Uy,G as Em,Ga as uy,H as Cm,Ha as Oc,I as Pm,Ia as hy,J as _m,Ja as We,Jb as Gy,K as Mm,Ka as gy,L as Dm,La as py,Lb as Ur,M as Nm,Ma as fy,Mb as jc,N as Lm,Na as on,Nb as Hy,O as _r,Ob as qy,P as jm,Pa as Lr,Pb as By,Q as Cc,Qa as my,Qb as Xy,Sb as Vy,T as Fm,Ta as yy,Ua as Ty,Ub as Jy,V as Wm,Wb as Ky,X as Pc,Xb as zy,a as Zf,ab as Et,ac as Yy,b as Ic,bb as Ay,bc as Qy,cb as xy,da as Gm,ea as Hm,f as Tc,fa as Mr,fb as Ct,g as em,ga as Or,gb as Ry,h as tm,hb as Ey,i as Ac,ib as Cy,j as nm,jb as Py,k as Yn,kb as _y,kc as Fc,l as sm,lb as My,lc as Wc,m as rm,ma as Dr,n as im,na as sy,nb as xe,nc as Zy,o as ot,ob as jr,p as om,pa as ry,pb as Lc,q as am,qa as Rt,qb as Oy,rb as Qn,s as cm,sb as Dy,ta as iy,tb as Ue,u as lm,ub as Ny,v as xt,vb as Ly,w as Rc,wa as oy,wb as jy,x as Sm,xb as Fr,y as $m,yb as Wr,z as Im,za as ay,zb as Fy}from"./chunk-
|
|
1
|
+
import{$a as Nc,A as Tm,Aa as cy,Ab as Wy,B as Am,Ba as ly,C as rn,Ca as Mc,D as Pr,Da as Nr,E as xm,Ea as dy,F as Rm,Fb as Uy,G as Em,Ga as uy,H as Cm,Ha as Oc,I as Pm,Ia as hy,J as _m,Ja as We,Jb as Gy,K as Mm,Ka as gy,L as Dm,La as py,Lb as Ur,M as Nm,Ma as fy,Mb as jc,N as Lm,Na as on,Nb as Hy,O as _r,Ob as qy,P as jm,Pa as Lr,Pb as By,Q as Cc,Qa as my,Qb as Xy,Sb as Vy,T as Fm,Ta as yy,Ua as Ty,Ub as Jy,V as Wm,Wb as Ky,X as Pc,Xb as zy,a as Zf,ab as Et,ac as Yy,b as Ic,bb as Ay,bc as Qy,cb as xy,da as Gm,ea as Hm,f as Tc,fa as Mr,fb as Ct,g as em,ga as Or,gb as Ry,h as tm,hb as Ey,i as Ac,ib as Cy,j as nm,jb as Py,k as Yn,kb as _y,kc as Fc,l as sm,lb as My,lc as Wc,m as rm,ma as Dr,n as im,na as sy,nb as xe,nc as Zy,o as ot,ob as jr,p as om,pa as ry,pb as Lc,q as am,qa as Rt,qb as Oy,rb as Qn,s as cm,sb as Dy,ta as iy,tb as Ue,u as lm,ub as Ny,v as xt,vb as Ly,w as Rc,wa as oy,wb as jy,x as Sm,xb as Fr,y as $m,yb as Wr,z as Im,za as ay,zb as Fy}from"./chunk-2BWTUD6Z.js";import{d as zf,g as Yf,h as Qf}from"./chunk-WXYO7JFL.js";import{a as dm}from"./chunk-ZVP6GB4G.js";import{F as fm,G as mm,I as Rr,J as Ec,K as Er,L as sn,P as qm,c as vf,d as Sf,f as $f,g as Kn,h as Tr,i as bc,j as If,k as Pe,p as gm,r as pm}from"./chunk-5Q62AXJG.js";import{b as wy,c as by,d as Dc,e as ky,f as vy,g as Sy,h as $y,i as Iy}from"./chunk-EKJG63EJ.js";import{d as Om}from"./chunk-JSCVOB4G.js";import{a as Um}from"./chunk-2GEO3AWE.js";import{b as Bm}from"./chunk-MRIVENBY.js";import{i as Xm,m as _c,n as Vm,p as Jm,q as Km,r as zm,s as Ym,t as Qm,u as Zm}from"./chunk-GJOKXP5D.js";import{a as ey}from"./chunk-PPUN7YHA.js";import{a as ty,b as ny}from"./chunk-VZLIBDLH.js";import{b as Cr}from"./chunk-UKUH662W.js";import{d as wm}from"./chunk-3Q6MRG3P.js";import{a as ym}from"./chunk-2P5NP4H6.js";import{g as bm}from"./chunk-LQE73AZR.js";import{b as km,c as vm}from"./chunk-2D3RYIDU.js";import{a as Uf,b as zn,c as Gf,d as Ar,e as xr,f as Sc,g as Hf,h as qf,j as Bf,k as Xf,l as Vf,o as Jf,p as $c,q as Kf}from"./chunk-TWWHZNHZ.js";import{a as kc,b as Tf,c as Af}from"./chunk-QPABR72X.js";import{a as um,b as hm}from"./chunk-A5GYG56I.js";import{o as xc}from"./chunk-E2JKO262.js";import{a as vc}from"./chunk-6TTGRTDO.js";import{c as Pf,d as _f,f as Mf,g as Of,i as Df,k as Nf,l as Lf}from"./chunk-RX5O5637.js";import{d as jf}from"./chunk-5ELIX7BQ.js";import{b as Ff,c as Wf}from"./chunk-X7UQY7CH.js";import{a as xf,b as it,c as Rf,d as Ef,e as Cf}from"./chunk-IFUAP7UD.js";import{c as nn}from"./chunk-KP7KDLZ2.js";import{A as zt,B as Bg,C as q,Ca as wf,E as Yg,F as Qg,G as Zg,H as ep,I as ye,J as np,K as sp,L as rp,M as Qt,N as ip,O as mr,P as fp,Q as mp,R as yp,S as rf,T as of,U as af,V as cf,W as lf,X as df,Z as Jn,_ as uf,a as ug,b as ec,ba as ce,c as gg,ca as rt,d as Rg,da as mc,e as Eg,ea as Zt,f as Bn,fa as yc,ga as Sr,h as ic,ha as en,i as oc,ia as tn,j as ac,ja as $e,k as cc,ka as At,l as Cg,la as le,ma as hf,na as gf,qa as mf,ta as yf,u as Mg,v as Lg,w as It,x as jg,y as Fg,z as Wg}from"./chunk-IJXCGKAB.js";import{$ as Xp,Aa as pf,Da as ff,G as gp,H as pp,N as wp,P as bp,R as Op,S as Dp,T as Up,U as Gp,V as Hp,W as qp,Y as fc,Z as vr,_ as Bp,a as Og,aa as Vp,ba as Jp,c as Ug,ca as Kp,d as Gg,da as zp,e as Tt,ea as Yp,f as Fe,fa as Qp,h as ap,ha as Zp,i as cp,j as lp,k as dc,ka as ef,l as dp,m as up,p as hp,pa as tf,q as wr,qa as nf,ta as sf,xa as $r,za as wc}from"./chunk-D4QTZJ4G.js";import{a as lc,b as Ng}from"./chunk-MEFPXHQJ.js";import{a as tt,d as op,e as yr}from"./chunk-7AB3QUGH.js";import{A as bf,B as Ir,C as kf,h as eh,n as th,o as Ra}from"./chunk-IANIJUL5.js";import{b as Yu}from"./chunk-SFQUP3BP.js";import{a as kp,b as uc,c as vp,d as Sp,e as $p,i as Ip,j as Tp}from"./chunk-VE3SSOQX.js";import{b as tp}from"./chunk-W4YR2RO2.js";import{b as xp,c as Rp,d as hc,f as br,g as Ep,h as Cp,i as Pp,j as Vn,k as kr,m as gc,n as _p,o as Mp}from"./chunk-VJVXEVZ7.js";import{b as me,c as Hg,e as Ze,f as qg,g as et,h as Xn,j as Se,k as Ap,l as nt,m as st,n as jp,q as Fp,s as Wp,u as pc}from"./chunk-C5VFABFI.js";import{a as Np,b as Lp}from"./chunk-TTAKAN5L.js";import{b as Dg}from"./chunk-5ONH4ITT.js";import{d as Xg,e as Vg,f as Jg,g as Kg,h as zg,j as Yt}from"./chunk-X5C5W3E4.js";import{c as fr}from"./chunk-OWNQ2FD4.js";import{c as _g}from"./chunk-LUOW2YHY.js";import{d as sh,e as Ox,m as ag,n as Xx,q as cg,v as lg,x as Za,y as Ye,z as qn}from"./chunk-NXOBCFUJ.js";import{a as je,b as Hn,f as ur}from"./chunk-72SZI2UW.js";import{a as jn,b as nh}from"./chunk-FCPTN6NF.js";import{c as dg}from"./chunk-MYVHVJWZ.js";import{f as hg}from"./chunk-QUFIUXMQ.js";import{d as pg,e as fg,f as tc,g as hr,h as mg,i as yg,j as wg,k as bg,l as Tg,m as Kt,o as Ag,y as xg}from"./chunk-3AHYZLGE.js";import{h as nc,n as sc,o as vg,p as gr,r as $t,s as Jt,t as Ae,v as Sg,w as $g,x as Ig,y as rc,z as pr}from"./chunk-XL7UWG36.js";import{a as Qe}from"./chunk-MNG2AMKZ.js";import{e as kg}from"./chunk-LY4G7PCW.js";import{c as Pg}from"./chunk-A7JSRDJL.js";import{o as xa,p as Mx}from"./chunk-DCIYOPJF.js";import{a as Js,b as _x}from"./chunk-7I7IEX4S.js";import{b as Qu,e as Zu}from"./chunk-JHCI6XCJ.js";import{e as kt}from"./chunk-DSYKYZMT.js";import{$ as ir,$a as ng,A as Zs,Aa as Uh,Ba as or,C as vt,Ca as Gh,D as La,Da as ar,E as lh,Ea as Hh,F as Nx,Fa as qh,G as er,Ga as Bh,H as Lx,Ha as Xh,Hb as Qa,I as tr,Ia as Ja,J as dh,Ja as Vh,K as jx,Ka,Kb as og,L as uh,M as hh,Ma as Vt,N as gh,Na as cr,Oa as Jh,Pa as Kh,Q as ja,Qa as za,R as mh,Ra as zh,Rb as Bx,S as yh,Sa as Gn,T as Wn,Ta as lr,U as rr,Ua as Yh,V as wh,Va as Qh,W as bh,Wa as Zh,X as Ch,Xa as eg,Y as Wx,Ya as tg,Z as Un,aa as Ga,ba as Ph,c as Ea,ca as Ux,cb as sg,d as Ks,da as _h,db as dr,e as Ca,ea as Gx,g as Pa,ga as Ce,h as zs,ha as Mh,hb as rg,ia as Oh,j as _a,ja as Ha,jb as Ya,k as rh,l as ih,la as qa,lb as Hx,m as oh,ma as Je,na as Ke,o as Fn,oa as Dh,p as Ma,qa as Ba,ra as Xa,sa as Nh,t as Xt,ta as Lh,u as ch,v as Da,va as jh,w as Dx,wa as Fh,x as Ys,xa as ze,y as Na,ya as Va,z as Qs,za as Wh}from"./chunk-ZAPHYYGT.js";import{a as ph,e as St,f as fh,g as nr,h as sr}from"./chunk-KEUW6YLL.js";import{a as kh,b as vh,c as Sh,e as $h,f as Ih,i as Fx,j as Fa,k as Th,l as Ah,m as Wa,n as xh,o as Rh,q as Ua,r as Eh}from"./chunk-UEEB3UTU.js";import{b as Oa,e as ah}from"./chunk-VQRY4IDI.js";import{b as ig,c as qx}from"./chunk-YSCT6DPR.js";import{d as Bt}from"./chunk-QIJLFPWE.js";import{existsSync as Jc,readFileSync as Kc}from"fs";gh();var ew=["answer","narration","line"],tw=5e3;function nw(r){return r==="/voice/queue"||r.startsWith("/voice/queue/")}async function sw(r,e,t,n,s,i){if(n==="/voice/queue"){if(t==="GET")return{status:200,body:{...r.view(),...i?{floor:i.view()}:{}}};if(t!=="POST")return{status:405,body:{error:"GET or POST"}};let l=String(s.text??"").trim(),d=String(s.agentId??s.agent??""),u=String(s.kind??"line");if(!l||!d||!ew.includes(u))return{status:400,body:{error:`Required: text and agentId; kind is ${ew.join(" | ")}`}};if(l.length>tw)return{status:413,body:{error:`text is over ${tw} characters`}};let h=e(d);if(!h)return{status:404,body:{error:`Unknown agent: ${d}`}};let{item:g,done:m}=r.enqueue({voice:h,text:l,agentId:d,kind:u,...typeof s.floor=="string"?{floor:s.floor}:{}});return s.wait!==!0?{status:202,body:{item:g}}:{status:200,body:{item:g,played:await m}}}if(t==="POST"&&n==="/voice/queue/pause")return r.pause(),{status:200,body:r.view()};if(t==="POST"&&n==="/voice/queue/resume")return r.resume(),{status:200,body:r.view()};let[,,,o,a,c]=n.split("/");if(t!=="POST"||!o||c!==void 0)return{status:404,body:{error:"Not found"}};switch(a){case"skip":return r.skip(o)?{status:200,body:r.view()}:Uc(o);case"front":return r.front(o)?{status:200,body:r.view()}:Uc(o);case"replay":{let l=r.replay(o);return l?{status:202,body:{item:l}}:Uc(o)}default:return{status:404,body:{error:"Not found"}}}}function rw(r){let e=n=>`${n.agentId??"someone"} (${n.kind}): "${n.text.length>80?`${n.text.slice(0,79)}\u2026`:n.text}" [${n.id}]`,t=r.playing?`Speaking: ${e(r.playing)}`:r.paused?"Paused: the listener is speaking; the queue plays on after.":"Nothing is speaking.";return[...r.floor?.held?[hh(r.floor)]:[],t,...r.waiting.map((n,s)=>`${s+1}. waiting: ${e(n)}`)].join(`
|
|
2
2
|
`)}var Uc=r=>({status:404,body:{error:`No such line in the queue: ${r}`}});var Vx=20,Gc=120,Jx=80,Kx=new Set(["waiting_owner","needs_attention"]);function Hc(r,e){let t=String(r??"").replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function Gr(r){return{total:r.length,items:r.slice(0,Vx)}}var qc=r=>new Date(r).toISOString();function iw(r){return{id:r.id,agentId:r.agentId,kind:r.kind,text:Hc(r.text,Jx),enqueuedAt:qc(r.enqueuedAt)}}function ow(r){let e=r.cards.filter(i=>i.status==="pending").sort((i,o)=>String(i.created_at??"").localeCompare(String(o.created_at??""))).map(i=>({id:i.id,title:Hc(i.title,Gc),raised_by:i.raised_by,node:i.node??null,createdAt:i.created_at})),t=[...r.held].sort((i,o)=>i.at.localeCompare(o.at)).map(i=>({id:i.id,title:Hc(i.title,Gc),from:i.from,at:i.at,heldBecause:i.heldBecause})),n=(r.requests??[]).filter(i=>Kx.has(i.state)).sort((i,o)=>i.createdAt-o.createdAt).map(i=>({id:i.id,title:Pe(i,Gc).headline,agentId:i.agentId,state:i.state,since:qc(i.stateChangedAt??i.updatedAt)})),s=r.voice;return{ts:qc(r.now),cards:Gr(e),held:Gr(t),voice:s?{paused:s.paused,reserved:s.reserved,playing:s.playing?iw(s.playing):null,waiting:Gr(s.waiting.map(iw))}:null,requests:Gr(n),errors:r.errors??[]}}function aw(r){let e=[],t=n=>n.total>n.items.length?[` \u2026 and ${n.total-n.items.length} more`]:[];e.push(`Decision cards waiting for an answer: ${r.cards.total}`);for(let n of r.cards.items)e.push(` - ${n.title} (by ${n.raised_by}${n.node?` on ${n.node}`:""}, ${n.createdAt}, ${n.id})`);e.push(...t(r.cards)),e.push(`Notices held by Focus or a call: ${r.held.total}`);for(let n of r.held.items)e.push(` - ${n.title} (from ${n.from}, ${n.at})`);if(e.push(...t(r.held)),r.voice){let n=r.voice.paused?", paused":r.voice.reserved?", the floor is held":"";e.push(`Speaking now: ${r.voice.playing?`${r.voice.playing.agentId??"the host"}: ${r.voice.playing.text}`:"nothing"}${n}`),e.push(`Lines waiting to be spoken: ${r.voice.waiting.total}`);for(let s of r.voice.waiting.items)e.push(` - ${s.agentId??"the host"} (${s.kind}): ${s.text}`);e.push(...t(r.voice.waiting))}e.push(`Open requests waiting on the owner: ${r.requests.total}`);for(let n of r.requests.items)e.push(` - ${n.title} (${n.agentId}, ${n.state.replace("_"," ")} since ${n.since}, ${n.id})`);e.push(...t(r.requests));for(let n of r.errors)e.push(`Could not read: ${n}`);return e.join(`
|
|
3
3
|
`)}import{resolve as zc}from"path";Hx();var zx={name:"agentx",version:"0.1.0"},Yx=["2024-11-05","2025-03-26","2025-06-18","2025-11-25"],Qx="2024-11-05";function Zx(r){return typeof r=="string"&&Yx.includes(r)?r:Qx}var eR={tools:{},elicitation:{form:{}}},tR=0;async function cw(r,e){let t=++tR;return Pt({jsonrpc:"2.0",id:`elicit-${t}`,method:"elicitation/create",params:{mode:"form",message:r,requestedSchema:e}}),new Promise(n=>{es.set(`elicit-${t}`,s=>{s?.action==="accept"&&s.content?n(s.content):n(null)}),setTimeout(()=>{es.has(`elicit-${t}`)&&(es.delete(`elicit-${t}`),n(null))},6e4)})}var es=new Map,nR="http://localhost:18800",Bc;function sR(){if(process.env.AGENTX_DAEMON_URL)return process.env.AGENTX_DAEMON_URL;for(let r of["agentx.json",".agentx/config.json"])try{let e=zc(process.cwd(),r);if(!Jc(e))continue;let t=JSON.parse(Kc(e,"utf-8"))?.node?.bind;if(typeof t!="string"||!t.includes(":"))continue;{let n=t.lastIndexOf(":"),s=t.slice(0,n),i=t.slice(n+1),o=!s||s==="0.0.0.0"||s==="::"||s==="*"?"127.0.0.1":s;if(i)return`http://${o}:${i}`}}catch{}return nR}function X(){return Bc===void 0&&(Bc=sR()),Bc}var Xc;function rR(r){try{let e=zc(process.cwd(),".env");if(!Jc(e))return"";for(let t of Kc(e,"utf-8").split(`
|
|
4
4
|
`)){let n=t.trim().replace(/^export\s+/,"");if(!n.startsWith(`${r}=`))continue;let s=n.slice(r.length+1).trim();return/^(["']).*\1$/.test(s)?s.slice(1,-1):s}}catch{}return""}function iR(r=process.env){if(r.AGENTX_TOKEN)return r.AGENTX_TOKEN;if(r.MESH_TOKEN)return r.MESH_TOKEN;let e=rR("MESH_TOKEN");if(e)return e;for(let t of["agentx.json",".agentx/config.json"])try{let n=zc(process.cwd(),t);if(!Jc(n))continue;let s=JSON.parse(Kc(n,"utf-8"))?.dashboard?.token;if(typeof s=="string"&&s)return s}catch{}return""}function oR(){return Xc===void 0&&(Xc=iR()),Xc}var J=(r,e)=>{let t=oR();if(!t)return fetch(r,e);let n=new Headers(e?.headers);return n.has("Authorization")||n.set("Authorization",`Bearer ${t}`),fetch(r,{...e,headers:n})};function Zn(r=process.env){let e={};return r.AGENTX_TASK_ID&&(e.callerTaskId=r.AGENTX_TASK_ID),r.AGENTX_CHANNEL&&(e.callerChannel=r.AGENTX_CHANNEL),r.AGENTX_CHAT_ID&&(e.callerChatId=r.AGENTX_CHAT_ID),e}async function aR(){let r=process.env.AGENTX_AGENT_ID,e=Zn();if(!(!r||!e.callerChannel||!e.callerChatId))try{let t=new URLSearchParams({channel:e.callerChannel,chatId:e.callerChatId}),n=await J(`${X()}/agents/${encodeURIComponent(r)}/intent-path?${t}`,{signal:AbortSignal.timeout(2e3)});if(!n.ok)return;let s=await n.json();return{...Array.isArray(s.path)&&s.path.length?{path:s.path}:{},...typeof s.graphWeight=="number"?{graphWeight:s.graphWeight}:{}}}catch{return}}function Vc(r,e){let t=e.agentId;return t||r==="gitlab"&&process.env.AGENTX_AGENT_ID||void 0}var cR=1e4,lR=new Set(["ECONNREFUSED","ENOTFOUND","EAI_AGAIN","EHOSTUNREACH","ENETUNREACH"]);function dR(r,e){let t=e,n=t?.cause?.code??t?.code;if(n&&lR.has(n))return`Error: the AgentX daemon could not be reached (${n}); the message to ${r} was not sent.`;let s=t?.name==="TimeoutError"||t?.name==="AbortError"?"no answer in time":t?.message||String(e);return`Probably delivered to ${r}: the daemon did not confirm (${s}), but the request was sent and is most likely queued. Do not treat this as a failure. If unsure, send the same message again: within 10 minutes a repeat returns the existing task id instead of a second task, and delivers it if the first never arrived. A busy ${r} shows no trace until its turn starts; later, \`agentx trace list --agent ${r} --since 1h\` or the daemon log ("[send/agent]") shows it.`}var uR=/\x1B\[[0-9;]*[A-Za-z]/g;function an(r){return r.replace(uR,"")}async function hR(r,e,t){let n=await J(`${X()}/recall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:r,channel:e,limit:Math.min(Math.max(t??30,1),100)})}),s=await n.json().catch(()=>({}));if(!n.ok)return{content:[{type:"text",text:`Error: ${s.error||n.statusText}`}]};let i=s.turns||[],o=e?`on ${e}`:"on any channel";return i.length===0?{content:[{type:"text",text:`No other messages ${o} today for ${r}.`}]}:{content:[{type:"text",text:gR(i,!!s.hasMore)}]}}function gR(r,e){let t=new Map;for(let s of r){let i=`${s.channel}/${s.chatId}`;t.has(i)||t.set(i,[]),t.get(i).push(s)}let n=[];for(let[s,i]of t){let o=[...i].sort((a,c)=>a.ts.localeCompare(c.ts)).map(a=>{let c=a.role==="agent"?"you":a.senderName||"user";return` [${a.ts.slice(11,16)}] ${c}: ${a.content.slice(0,300)}`});n.push(`From ${s}:
|
|
@@ -532,7 +532,7 @@ ${l}`)}let S={agentId:o,message:b,context:{channel:f,sender:m?"opencode":"openai
|
|
|
532
532
|
|
|
533
533
|
`)}}function vb(r){r.writeHead(200,{"Content-Type":"text/event-stream; charset=utf-8","Cache-Control":"no-cache",Connection:"keep-alive","X-Accel-Buffering":"no"})}function Sb(r,e,t,n,s,i){r.write(`data: ${JSON.stringify({id:e,object:"chat.completion.chunk",created:t,model:n,choices:[{index:0,delta:s,finish_reason:i}]})}
|
|
534
534
|
|
|
535
|
-
`)}function $b(r,e,t,n,s,i){let o=i?.usage?.inputTokens??0,a=i?.usage?.outputTokens??Math.ceil(s.length/4);vl(r,200,{id:e,object:"chat.completion",created:t,model:n,choices:[{index:0,message:{role:"assistant",content:s},finish_reason:"stop"}],usage:{prompt_tokens:o,completion_tokens:a,total_tokens:o+a}})}function vl(r,e,t){r.writeHead(e,{"Content-Type":"application/json"}),r.end(JSON.stringify(t))}var hs=class{module;minLevel;constructor(e,t="info"){this.module=e,this.minLevel=t}child(e){return new hs(`${this.module}:${e}`,this.minLevel)}debug(e,t){this.emit("debug",e,t)}info(e,t){this.emit("info",e,t)}warn(e,t){this.emit("warn",e,t)}error(e,t){this.emit("error",e,t)}asConsoleLog(){return(...e)=>{let n=e.map(s=>typeof s=="string"?s:JSON.stringify(s)).join(" ").replace(/^\[agentx\]\s*/,"");n&&this.info(n)}}emit(e,t,n){if(hs.levelOrder[e]<hs.levelOrder[this.minLevel])return;let s={time:new Date().toISOString(),level:e,module:this.module,msg:t,...n},i=e==="error"?"ERROR":e==="warn"?"WARN":"",o=`[${this.module}]`,a=i?`${o} ${i}: ${t}`:`${o} ${t}`;console.error(a)}},us=hs;Bt(us,"levelOrder",{debug:0,info:1,warn:2,error:3});import{realpathSync as vC,statSync as SC}from"fs";var qe={version:"0.
|
|
535
|
+
`)}function $b(r,e,t,n,s,i){let o=i?.usage?.inputTokens??0,a=i?.usage?.outputTokens??Math.ceil(s.length/4);vl(r,200,{id:e,object:"chat.completion",created:t,model:n,choices:[{index:0,message:{role:"assistant",content:s},finish_reason:"stop"}],usage:{prompt_tokens:o,completion_tokens:a,total_tokens:o+a}})}function vl(r,e,t){r.writeHead(e,{"Content-Type":"application/json"}),r.end(JSON.stringify(t))}var hs=class{module;minLevel;constructor(e,t="info"){this.module=e,this.minLevel=t}child(e){return new hs(`${this.module}:${e}`,this.minLevel)}debug(e,t){this.emit("debug",e,t)}info(e,t){this.emit("info",e,t)}warn(e,t){this.emit("warn",e,t)}error(e,t){this.emit("error",e,t)}asConsoleLog(){return(...e)=>{let n=e.map(s=>typeof s=="string"?s:JSON.stringify(s)).join(" ").replace(/^\[agentx\]\s*/,"");n&&this.info(n)}}emit(e,t,n){if(hs.levelOrder[e]<hs.levelOrder[this.minLevel])return;let s={time:new Date().toISOString(),level:e,module:this.module,msg:t,...n},i=e==="error"?"ERROR":e==="warn"?"WARN":"",o=`[${this.module}]`,a=i?`${o} ${i}: ${t}`:`${o} ${t}`;console.error(a)}},us=hs;Bt(us,"levelOrder",{debug:0,info:1,warn:2,error:3});import{realpathSync as vC,statSync as SC}from"fs";var qe={version:"0.208.0",commit:"9dcfc8a",startedAt:new Date(Date.now()-process.uptime()*1e3).toISOString()};function $C(r,e){let t=e.mtimeMs!==null&&e.mtimeMs>Date.parse(r.startedAt),n=!!e.version&&!!r.version&&e.version!==r.version;return{newer:t||n,changedAt:e.mtimeMs===null?null:new Date(e.mtimeMs).toISOString(),version:e.version}}function Tb(){let r=null;try{r=SC(vC(process.argv[1])).mtimeMs}catch{}let e=Kw().version;return $C(qe,{mtimeMs:r,version:e&&e!=="0.0.0"?e:null})}import{existsSync as Ab,mkdirSync as IC,readFileSync as TC,statSync as AC,writeFileSync as xC}from"fs";import{homedir as xb}from"os";import{dirname as RC,join as Sl,resolve as $l}from"path";var Rb=(r=xb())=>Sl(r,".agentx","daemon-root");function Eb(r,e=xb()){let t=Rb(e);IC(RC(t),{recursive:!0}),xC(t,$l(r)+`
|
|
536
536
|
`)}var EC=r=>Ab(Sl(r,"agentx.json"))||Ab(Sl(r,".agentx","config.json"));function CC(r){try{return AC(r).isDirectory()}catch{return!1}}function tH(r={}){let e=$l(r.cwd??process.cwd()),t=r.env??process.env;if(t.AGENTX_ROOT?.trim())return $l(t.AGENTX_ROOT.trim());if(EC(e))return e;let n="";try{n=TC(Rb(r.home),"utf-8").trim()}catch{}return n&&CC(n)?n:e}import{randomUUID as PC}from"crypto";var yi=class{constructor(e=new Bg){this.core=e}count=0;subscribe(e,t){this.count++;let n=this.core.subscribe((i,o)=>{if(!o||!_C.includes(o.kind))return;let a={...o,rootId:i.rootId,node:i.node};OC(e,a)&&t(a)}),s=!0;return()=>{s&&(s=!1,this.count--,n())}}publish(e){let t={id:typeof e.id=="string"?e.id:PC(),at:typeof e.at=="string"?e.at:new Date().toISOString(),...e},{type:n,summary:s,ref:i,agentId:o}=MC(t);this.core.publish({id:t.id,at:t.at,kind:t.kind,type:n,summary:s,ref:i,agentId:o,rootId:typeof e.rootId=="string"?e.rootId:void 0,data:t})}get size(){return this.count}},_C=["run","task","signal","mesh","channel","status"];function MC(r){switch(r.kind){case"run":return{type:r.phase,ref:r.runId,summary:[r.workflowId,r.nodeId,r.phase,r.note].filter(Boolean).join(" ")};case"task":return{type:r.phase,ref:r.taskId,summary:`${r.title??r.taskId} ${r.phase}`};case"signal":return{type:"emitted",summary:`signal ${r.name} (${r.scope})`};case"mesh":return{type:r.delta,summary:`peer ${r.peer} ${r.delta}`};case"channel":return{type:r.direction,ref:r.messageId,agentId:r.agentId,summary:`${r.channel} ${r.direction==="in"?"inbound":"outbound"}`};case"status":return{type:"status",summary:r.message}}}function OC(r,e){return!(r.kinds&&r.kinds.length>0&&!r.kinds.includes(e.kind)||r.workflowId&&(e.kind==="run"&&e.workflowId!==r.workflowId||e.kind==="task"&&e.workflowId!==r.workflowId||e.kind==="signal"&&e.workflowId&&e.workflowId!==r.workflowId)||r.runId&&(e.kind==="run"&&e.runId!==r.runId||e.kind==="task"&&e.runId!==r.runId)||r.actor&&(e.kind!=="task"||!(e.assignedTo?.includes(r.actor)||e.submittedBy===r.actor))||r.channel&&(e.kind!=="channel"||e.channel!==r.channel))}function Cb(r){if(!r)return;let e=["run","task","signal","mesh","channel","status"],n=r.split(",").map(s=>s.trim()).filter(Boolean).filter(s=>e.includes(s));return n.length?n:void 0}import{createHmac as wi,timingSafeEqual as Pb}from"crypto";var bi=class{registry;config;mesh;webhookEntries;log;workflowDispatcher;hooks;constructor(e,t={},n=console.error.bind(console,"[webhook]"),s,i=[],o){this.registry=e,this.config=t,this.log=n,this.mesh=s,this.webhookEntries=i,this.hooks=o}hookEventFor(e,t){if(e==="stripe")return"on:stripe-event";if(e==="sentry")return"on:sentry-issue";if(e==="vercel")return"on:vercel-deployment";if(e==="hubspot")return"on:hubspot-event";if(e==="odoo")return"on:odoo-event";if(e==="github"){let n=(t??"").split(".")[0];return n==="issues"||n==="issue_comment"?"on:github-issue":n==="pull_request"||n==="pull_request_review"?"on:github-pr":n==="push"?"on:github-push":null}return null}async fireHookSafe(e,t,n,s){let i=this.hookEventFor(e,t);if(!i||!this.hooks||!this.hooks.has(i))return;let o={};if(e==="github"){let a=s;typeof a.sender?.login=="string"&&(o.author=a.sender.login),typeof a.repository?.full_name=="string"&&(o.repo=a.repository.full_name);let c=a.issue?.number??a.pull_request?.number;typeof c=="number"&&(o.number=c)}try{await this.hooks.execute(i,{event:i,source:e,eventType:t,agentId:n,payload:s,...o})}catch(a){this.log(`${i} hook error (non-fatal): ${a?.message??a}`)}}setWorkflowDispatcher(e){this.workflowDispatcher=e}setWebhookEntries(e){this.webhookEntries=e}async handle(e,t,n){let s=n.replace(/^\/webhook\/?/,"").split("/").filter(Boolean),i=s[0],o=s[1];if(!i){this.sendJson(t,400,{error:"Missing agent ID. Use /webhook/:agentId"});return}let{raw:a,parsed:c}=await this.readBody(e),l=o||this.detectSource(e.headers);if(process.env.AGENTX_WEBHOOK_DEBUG_HEADERS==="1"){let w={};for(let[b,S]of Object.entries(e.headers))(b.startsWith("x-hubspot")||b.startsWith("x-hub")||b.startsWith("x-github")||b.startsWith("x-gitlab")||b.startsWith("stripe")||b.startsWith("sentry")||b.startsWith("x-vercel")||b.startsWith("x-odoo")||b.startsWith("x-webhook")||b==="user-agent"||b==="content-type"||b==="host"||b==="x-forwarded-host"||b==="x-forwarded-proto"||b==="x-forwarded-for")&&(w[b]=S);this.log(`Webhook [${l}] reqUrl=${e.url} headers: ${JSON.stringify(w)}`)}let d=this.validateSignature(e.headers,a,l,i,e.url);if(d){this.log(`Webhook [${l}] -> ${i}: REJECTED (${d})`),this.sendJson(t,401,{error:d});return}let u=this.buildSummary(l,c,e.headers);this.log(`Webhook [${l}] -> ${i}: ${u.slice(0,100)}`);let h=this.extractEventType(l,c,e.headers),g=this.webhookEntries.find(w=>w.enabled&&w.agentId===i&&w.source===l),m=h&&g?.triggers?.[h]||g?.defaultWorkflow||null;if(await this.fireHookSafe(l,h,i,c),m&&this.workflowDispatcher)try{let w=await this.workflowDispatcher.dispatchWorkflow({workflowId:m,entityRef:{kind:"webhook",id:`${l}:${i}:${h??"\u2014"}:${Date.now()}`},event:{kind:"webhook",source:l,eventType:h,payload:c},trigger:{source:l}});this.log(`Webhook [${l}/${h??"\u2014"}] -> workflow=${m} (claimed=${w.claimed})`),this.sendJson(t,202,{ok:!0,agent:i,source:l,eventType:h,workflow:m,claimed:w.claimed});return}catch(w){this.log(`Workflow dispatch failed [${l}/${h}/${m}]: ${w.message}`)}let f=this.webhookEntries.find(w=>w.enabled&&w.node&&w.agentId===i&&w.source===l);if(f?.node&&this.mesh){this.sendJson(t,202,{ok:!0,agent:i,source:l,node:f.node,status:"accepted"}),this.mesh.sendTask(f.node,u,i,{context:{channel:`webhook:${l}`,sender:`webhook:${l}`}}).then(w=>this.log(`Mesh-forwarded webhook [${l}] -> ${f.node}/${i}: ${w?.slice(0,100)||"ok"}`),w=>this.log(`Mesh forward failed [${l}] -> ${f.node}/${i}: ${w.message}`));return}try{let w=await this.registry.execute({message:u,agentId:i,context:{channel:`webhook:${l}`,sender:`webhook:${l}`}});this.sendJson(t,w.error?500:200,{ok:!w.error,agent:i,source:l,response:w.content?.slice(0,500),error:w.error,duration:w.duration})}catch(w){this.sendJson(t,500,{error:w.message})}}extractEventType(e,t,n){let s=i=>{let o=n[i.toLowerCase()];return Array.isArray(o)?o[0]:o};if(e==="github"){let i=s("x-github-event");if(!i)return;let o=typeof t.action=="string"?t.action:void 0;return o?`${i}.${o}`:i}if(e==="gitlab")return s("x-gitlab-event")||(typeof t.object_kind=="string"?t.object_kind:void 0);if(e==="stripe")return typeof t.type=="string"?t.type:void 0;if(e==="sentry")return s("sentry-hook-resource");if(e==="hubspot"){if(Array.isArray(t)&&t.length>0){let i=t[0];if(i&&typeof i.subscriptionType=="string")return i.subscriptionType}return typeof t.subscriptionType=="string"?t.subscriptionType:void 0}if(e==="odoo")return typeof t.event=="string"?t.event:typeof t.subscriptionType=="string"?t.subscriptionType:typeof t.model=="string"?typeof t.action=="string"?`${t.model}.${t.action}`:t.model:void 0}detectSource(e){return e["x-gitlab-event"]||e["x-gitlab-token"]?"gitlab":e["x-github-event"]?"github":e["stripe-signature"]?"stripe":e["sentry-hook-resource"]?"sentry":e["x-vercel-signature"]?"vercel":e["x-hubspot-signature-v3"]||e["x-hubspot-signature-version"]?"hubspot":e["x-odoo-database"]||e["x-odoo-signature"]?"odoo":e["x-hub-signature-256"]?"github":"unknown"}buildSummary(e,t,n){let s=[`[Webhook from ${e}]`];switch(e){case"gitlab":{let o=n["x-gitlab-event"]||t.object_kind||"event",a=t.project?.path_with_namespace||"",c=t.user?.name||t.user_username||"";if(s.push(`Event: ${o}`),a&&s.push(`Project: ${a}`),c&&s.push(`User: ${c}`),t.ref&&s.push(`Ref: ${t.ref}`),t.commits&&Array.isArray(t.commits)){s.push(`Commits: ${t.commits.length}`);for(let d of t.commits.slice(0,3))s.push(` - ${d.message?.split(`
|
|
537
537
|
`)[0]||"no message"} (${d.author?.name||""})`)}let l=t.object_attributes;if(l?.title&&(s.push(`Title: ${l.title}`),s.push(`State: ${l.state||""}`),s.push(`Action: ${l.action||""}`),l.source_branch&&s.push(`Branch: ${l.source_branch} -> ${l.target_branch}`),l.url&&s.push(`URL: ${l.url}`)),l?.iid&&!l?.source_branch&&(s.push(`Issue #${l.iid}: ${l.title||""}`),l.description&&s.push(`Description: ${l.description.slice(0,200)}`)),t.object_kind==="pipeline"){let d=t.object_attributes;s.push(`Pipeline: ${d?.status||""} (${d?.ref||""})`),s.push(`Duration: ${d?.duration||0}s`)}break}case"github":{let o=n["x-github-event"]||"event",a=t.repository?.full_name||"",c=t.sender?.login||"";if(s.push(`Event: ${o}`),a&&s.push(`Repository: ${a}`),c&&s.push(`Sender: ${c}`),t.ref&&s.push(`Ref: ${t.ref}`),t.commits&&Array.isArray(t.commits))for(let u of t.commits.slice(0,3))s.push(` - ${u.message?.split(`
|
|
538
538
|
`)[0]||""} (${u.author?.name||""})`);let l=t.pull_request;l&&(s.push(`PR #${l.number}: ${l.title}`),s.push(`Action: ${t.action}`),s.push(`Branch: ${l.head?.ref} -> ${l.base?.ref}`));let d=t.issue;d&&(s.push(`Issue #${d.number}: ${d.title}`),s.push(`Action: ${t.action}`));break}case"stripe":{let o=t.type||"event",a=t.data?.object||{};s.push(`Event: ${o}`),a.amount&&s.push(`Amount: ${(a.amount/100).toFixed(2)} ${a.currency?.toUpperCase()||""}`),a.customer_email&&s.push(`Customer: ${a.customer_email}`),a.description&&s.push(`Description: ${a.description}`),a.status&&s.push(`Status: ${a.status}`);break}case"sentry":{let o=n["sentry-hook-resource"]||"event";s.push(`Resource: ${o}`);let a=t.data||t;a.error?.title&&s.push(`Error: ${a.error.title}`),a.error?.culprit&&s.push(`Culprit: ${a.error.culprit}`),a.error?.metadata?.value&&s.push(`Message: ${a.error.metadata.value}`),t.url&&s.push(`URL: ${t.url}`);break}case"hubspot":{let o=Array.isArray(t)?t:null,a=o||null;if(a&&a.length){s.push(`Events: ${a.length}`);for(let l of a.slice(0,3)){let d=l.subscriptionType??"?",u=l.objectId??"?",h=l.changeFlag??l.changeSource??"";s.push(` - ${d} (object ${u}${h?`, ${h}`:""})`)}}else{let l=t.subscriptionType??"event",d=t.objectId??"?";s.push(`Event: ${l} (object ${d})`)}let c=a?.[0]?.portalId??t.portalId;c!=null&&s.push(`Portal: ${c}`);break}case"odoo":{let o=typeof t.event=="string"&&t.event||typeof t.subscriptionType=="string"&&t.subscriptionType||typeof t.model=="string"&&(typeof t.action=="string"?`${t.model}.${t.action}`:t.model)||"event";s.push(`Event: ${o}`);let a=n["x-odoo-database"]||(typeof t.database=="string"?t.database:"");a&&s.push(`Database: ${a}`);let c=t.record||t;c?.id&&s.push(`Record id: ${c.id}`),c?.name&&s.push(`Name: ${String(c.name).slice(0,200)}`),c?.partner_id?.[1]&&s.push(`Partner: ${c.partner_id[1]}`),c?.email&&s.push(`Email: ${c.email}`),c?.amount_total!=null&&s.push(`Amount: ${c.amount_total}`),c?.state&&s.push(`State: ${c.state}`);break}default:s.push(`Headers: ${JSON.stringify(Object.keys(n).filter(o=>o.startsWith("x-")).slice(0,5))}`),s.push(`Payload keys: ${Object.keys(t).slice(0,10).join(", ")}`);let i=JSON.stringify(t).slice(0,500);s.push(`Body: ${i}`)}return s.join(`
|
|
@@ -1373,4 +1373,4 @@ data: ${JSON.stringify(F)}
|
|
|
1373
1373
|
`)}catch{}},G=setInterval(()=>{try{t.write(`: ping
|
|
1374
1374
|
|
|
1375
1375
|
`)}catch{}},15e3);G.unref?.();let K=new AbortController;t.on("close",()=>{t.writableEnded||K.abort()});try{for await(let Y of this.mesh.sendTaskStream(p.peer,p.message,p.agent,{context:p.context,signal:K.signal,vouchOwner:A}))W(Y.event,Y.data)}catch(Y){W("error",{error:Y?.message??String(Y)})}finally{clearInterval(G);try{t.end()}catch{}}break}let N=p.context,_=typeof p.senderAgentId=="string"?p.senderAgentId:void 0;if(Cu(p,!0)==="callback"){let W=this.delegationGate(e,p,{callee:p.agent,peer:p.peer,message:p.message,calleeContext:N});if(!("track"in W)){let G=ia(W);this.json(t,G.status,G.body);break}}if(p.async===!0){let W=N?.channel,G=N?.chatId;if(!W||!G){this.json(t,400,{error:"async requires context.channel and context.chatId \u2014 there is no route back otherwise"});return}let K=`mesh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;this.json(t,202,{accepted:!0,taskId:K,deliverTo:`${W}:${G}`,note:"result will be delivered to the originating chat when the peer finishes"});let Y=p.peer,F=p.agent,z=this.mesh;(async()=>{let ee=Date.now(),Q;try{Q=await z.sendTask(Y,p.message,F,{vouchOwner:A,context:N,senderAgentId:_}),this.log(`[mesh/task async ${K}] ${Y}/${F??"default"} finished in ${Date.now()-ee}ms`)}catch(fe){Q=`Delegation to ${Y}/${F??"default"} failed: ${fe?.message??fe}`,this.log(`[mesh/task async ${K}] failed: ${fe?.message??fe}`)}try{await this.router.sendOutbound({channel:W,chatId:G,text:Q,agentId:N?.agentId??_,accountId:N?.accountId})}catch(fe){this.log(`[mesh/task async ${K}] delivery failed: ${fe?.message??fe}`)}})();break}let j=await this.mesh.sendTask(p.peer,p.message,p.agent,{context:N,senderAgentId:_,vouchOwner:A});this.json(t,200,{response:j});break}case"POST /webrtc/signal/out":{if(!this.webrtc){this.json(t,404,{error:"WebRTC signaling not enabled"});return}let y=await U(e);if(!y.kind||!y.callId||!y.from||!y.to){this.json(t,400,{error:"Missing: kind, callId, from, to"});return}let k=await this.webrtc.handleOutgoing(y);this.json(t,k.ok?200:400,k);break}case"POST /webrtc/signal":{if(!this.webrtc){this.json(t,404,{error:"WebRTC signaling not enabled"});return}let y=await U(e);if(!y.kind||!y.callId||!y.from||!y.to){this.json(t,400,{error:"Missing: kind, callId, from, to"});return}let k=this.webrtc.handleIncoming(y);this.json(t,k.ok?200:400,k);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 p=await U(e),y=p.callId,k=p.target,$=p.agentId||this.config.channels.webrtc?.bot.defaultAgentId;if(!y||!k||!$){this.json(t,400,{error:"Missing: callId, target, agentId (or defaultAgentId in config)"});return}let I=await this.botManager.invite({callId:y,target:k,agentId:$});this.json(t,I.ok?200:500,I);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 p=this.config.channels.webrtc;if(!p?.enabled){this.json(t,404,{error:"WebRTC signaling not enabled"});return}this.json(t,200,{localName:this.config.node.name,iceServers:[...p.stunServers.map(y=>({urls:y})),...p.turnServers],peers:this.mesh?.directory().map(y=>({name:y.peer,healthy:y.healthy}))||[],camera:p.camera,agents:this.registry.list().map(y=>({id:y.id,name:y.name}))});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(p=>{let y=this.config.agents[p.id]||{},k=typeof y.description=="string"&&y.description.trim()||UW(y.systemPrompt)||`Agent "${p.name}" (${p.tier})`,$=Array.isArray(y.mentions)?y.mentions.slice(0,4):[];return{id:p.id,name:p.name,description:k,tags:[p.tier,...$],color:ve(p.id,y).color}}),channels:this.router.getChannelNames(),githubLogins:this.github?.postingAccounts()??[],defaultInputModes:["text"],defaultOutputModes:["text"]});break;case"GET /wiki/agents":{let p=this.registry.getWikiHub();this.json(t,200,{nodeId:this.config.node.id,agents:p.summary()});break}case"GET /wiki/entries":{let p=this.registry.getWikiHub(),y=n.searchParams.get("agent")||void 0,k=n.searchParams.get("after")||void 0,$=y?p.getAgentEntries(y):p.getSharedStore().listEntries({after:k});this.json(t,200,{nodeId:this.config.node.id,count:$.length,entries:$.map(I=>({id:I.id,date:I.date,agentId:I.agentId,source:I.source,sourceContext:I.sourceContext,content:I.content}))});break}case"GET /wiki/articles":{let p=this.registry.getWikiHub(),y=n.searchParams.get("agent");if(!y){this.json(t,400,{error:"?agent= required"});break}let $=p.getAgentWiki(y).rebuildIndex();this.json(t,200,{nodeId:this.config.node.id,agentId:y,articles:$.articles});break}case"GET /wiki/article":{let p=this.registry.getWikiHub(),y=n.searchParams.get("agent"),k=n.searchParams.get("path");if(!y||!k){this.json(t,400,{error:"?agent= and ?path= required"});break}let I=p.getAgentWiki(y).readArticle(k);if(!I){this.json(t,404,{error:"Article not found"});break}this.json(t,200,{nodeId:this.config.node.id,agentId:y,path:I.path,title:I.meta.title,tags:I.meta.tags,owner:I.meta.owner,created:I.meta.created,lastUpdated:I.meta.lastUpdated,sources:I.meta.sources,content:I.content});break}case"GET /wiki/notes":{let{NoteStore:p}=await import("./notes-WJJEJ4CJ.js"),y=n.searchParams.get("status")||"waiting";if(!["waiting","open","patched","rejected","deferred","expired","all"].includes(y)){this.json(t,400,{error:"status must be waiting, open, patched, rejected, deferred, expired or all"});break}let k=Math.max(1,Math.min(200,parseInt(n.searchParams.get("limit")||"50",10)||50)),I=new p(this.registry.getWikiHub().getBaseDir()).list(y==="all"?void 0:y);this.json(t,200,{nodeId:this.config.node.id,enabled:this.config.wikiNotes.enabled,inbox:this.config.wikiNotes.inbox??null,crons:this.config.wikiNotes.crons,absorbAgent:this.config.wikiNotes.absorbAgent??null,total:I.length,notes:I.slice(-k).reverse()});break}case"POST /wiki/notes":{let{NoteStore:p,validateNote:y}=await import("./notes-WJJEJ4CJ.js"),k=this.config.wikiNotes;if(!k.enabled||!k.inbox){this.json(t,409,{error:"wiki notes are off on this node: set wikiNotes.enabled and wikiNotes.inbox"});break}let $=await U(e),I=y({...$,to:k.inbox});if("error"in I){this.json(t,400,{error:I.error});break}let A=I.note;if(this.registry.getAgent(k.inbox)){try{let{note:N,added:_}=new p(this.registry.getWikiHub().getBaseDir()).add(A);this.json(t,_?201:200,{ok:!0,added:_,note:N,node:this.config.node.id})}catch(N){this.json(t,507,{error:N?.message??String(N)})}break}if($.forwarded===!0){this.json(t,404,{error:`inbox agent "${k.inbox}" is not on this node`});break}let O=this.mesh?.findAgentPeer(k.inbox);if(!O){this.json(t,404,{error:`inbox agent "${k.inbox}" is not on this node or any known peer`});break}let M=this.mesh.directory().find(N=>N.peer===O.peer)?.peerUrl;if(!O.healthy||!M){this.json(t,503,{error:`the node hosting "${k.inbox}" (${O.peer}) is unreachable; try again later`});break}try{let N=await fetch(`${M.replace(/\/$/,"")}/wiki/notes`,{method:"POST",headers:{"Content-Type":"application/json",...this.mesh.authHeaders(O.peer)},body:JSON.stringify({...A,fromNode:A.fromNode||this.config.node.id,forwarded:!0}),signal:AbortSignal.timeout(1e4)}),_=await N.json().catch(()=>({}));this.json(t,N.status,{..._,peer:O.peer})}catch(N){this.json(t,502,{error:`forward to ${O.peer} failed: ${N?.message??N}`,peer:O.peer})}break}case"GET /graph/schema":{let p=this.registry.getGraphStore();if(!p){this.json(t,404,{error:"graph disabled on this node"});break}this.json(t,200,{nodeId:this.config.node.id,schema:p.loadSchema()});break}case"GET /graph/nodes":{let p=this.registry.getGraphStore();if(!p){this.json(t,404,{error:"graph disabled on this node"});break}this.json(t,200,{nodeId:this.config.node.id,...p.loadNodes()});break}case"GET /graph/classifications":{let p=this.registry.getGraphStore();if(!p){this.json(t,404,{error:"graph disabled on this node"});break}let y=n.searchParams.get("status")||"approved",k=Math.max(1,Math.min(1e3,parseInt(n.searchParams.get("limit")||"200",10)||200)),$=p.listByStatus(y,k);this.json(t,200,{nodeId:this.config.node.id,status:y,count:$.length,classifications:$});break}default:this.json(t,404,{error:"Not found",endpoints:["GET /health","GET /agents","GET /crons","GET /routines \u2014 schedules + cron/hook workflows with staleness flags","GET /mesh","GET /wiki/agents","GET /wiki/entries[?agent=X&after=YYYY-MM-DD]","GET /wiki/articles?agent=X","GET /wiki/notes[?status=waiting|open|patched|rejected|deferred|expired|all&limit=N]","POST /wiki/notes { from, change, source, date? } \u2014 a note for the wiki observe/sweep run","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 /voice/history[?agent=&limit=&before=] \u2014 past voice exchanges, bounded summaries","GET /voice/history/:id \u2014 one voice exchange in full; POST /voice/history/:id/replay","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 /usage/plan \u2014 Claude plan windows, cold-dispatch counters, active holds","POST /usage/plan/lift \u2014 drop the active Claude plan holds","GET /daemon/restart \u2014 in-flight count, service manager, pending restart","POST /daemon/restart \u2014 restart when idle { timeoutMinutes?, onTimeout? }","POST /daemon/restart/cancel","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","POST /webrtc/camera/watch { callId, agentId } \u2014 an agent watches the phone camera share","GET /webrtc/camera/watch \u2014 agents watching a camera now","POST /webrtc/camera/watch/:id/look { note? } \u2014 ask the watching agent what it sees","POST /webrtc/camera/watch/:id/stream { seconds, note? } \u2014 the agent keeps watching for a while (0 stops)","POST /webrtc/camera/look { agentId } \u2014 from an agent's run: the newest frame as a PNG path"]})}}catch(i){this.json(t,500,{error:i.message})}}async handleOpenAICompat(e,t,n){let s=await U(e);await Ib(e,t,n,s,{execute:(i,o,a,c)=>this.registry.execute(i,o,a,c),agentIds:Object.keys(this.config.agents),cancel:(i,o,a,c)=>{let l=this.registry.list().find(d=>d.id===i)?.runningTasks.filter(d=>d.channel===o&&d.chatId===a)||[];for(let d of l)this.registry.cancelRunningTask(d.id,c)},log:i=>this.log(i)})}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=Om(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=ik();if(e==="json")return this.registry.getTodayUsage();let t=rk(this.db);return e==="sqlite"||Object.keys(t.agents).length>0?t:this.registry.getTodayUsage()}installAgentMemorySurface(){let e=parseInt(this.config.node.bind.split(":")[1]||"18800",10);for(let t of this.registry.list()){let n=t.workspace;if(!(!n||!Mn(n)))try{let s=ne(n,".claude","skills");Cx(s,{recursive:!0});let i=ne(s,G$);if(!Mn(i))Ju(i,Ld(e)),this.log(` memory-skill: installed remember.md \u2192 ${t.id}`);else{let o=q$(Bs(i,"utf-8"),e);o&&(Ju(i,o),this.log(` memory-skill: updated remember.md \u2192 ${t.id}`))}this.agentMemory.syncToWorkspace(t.id,n,this.config.session.memoryIndexMaxChars)}catch(s){this.log(` memory-skill: ${t.id} install failed \u2014 ${s?.message??s}`)}}}installAgentMcpConfig(){for(let[e,t]of Object.entries(this.config.agents)){let n=t.workspace;if(!n||!Mn(n))continue;let s=this.config.workflows.enabled&&(this.config.workflows.followUp.enabled&&(this.config.workflows.followUp.agents[e]??!0)||Zp(this.config.workflows,e)),i=mp(pg(t),this.config.requests.enabled||s?fp():null);try{switch(yp(n,i)){case"installed":this.log(` mcp: installed ${Object.keys(i).length} server(s) \u2192 ${e}`);break;case"updated":this.log(` mcp: updated .mcp.json (${Object.keys(i).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(i).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(o){this.log(` mcp: ${e} install failed \u2014 ${o?.message??o}`)}}}workspaceFor(e){for(let t of this.registry.list())if(t.id===e)return t.workspace;return null}handleMemoryApi(e,t,n,s){return p$(e,t,n,s,{mem:this.agentMemory,workspaceFor:i=>this.workspaceFor(i),runningTaskOwner:i=>this.registry.runningTaskOwner(i),indexMaxChars:()=>this.config.session.memoryIndexMaxChars})}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 re(e)}catch(c){this.json(t,400,{error:"invalid JSON body",message:c.message});return}let s=n?.payload??n,i=s?.event,o=s?.entityRef;if(!i?.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 h=typeof n?.fromPeer=="string"?n.fromPeer:"unknown";this.log(`[workflows/mesh] received trigger from "${h}" source="${s.trigger.source}" chat="${s.trigger.chat??"*"}"`);let g=await this.workflowDispatcher.dispatch({trigger:s.trigger,entityRef:o,event:i,fromRemote:{peer:h}});this.log(`[workflows/mesh] dispatched broadcast: matched=${g.claimed.length} ${g.claimed.length?`(${g.claimed.map(m=>m.id).join(", ")})`:"[none \u2014 no workflow with mesh.allowRemote matched]"}`),this.json(t,202,{ok:!0,mode:"trigger-broadcast",matched:g.claimed.map(m=>m.id)});return}let d=(s.workflowId?this.workflowStore?.get(s.workflowId):null)?.nodes.find(h=>h.type.startsWith("trigger."))?.config??{},u={source:String(d.source??"hook"),project:d.filter?.project,repo:d.filter?.repo,chat:d.filter?.chat,labels:d.filter?.labels};await this.workflowDispatcher.dispatch({trigger:u,entityRef:o,event:i}),this.json(t,202,{ok:!0})}catch(c){this.log(`[workflows] /workflow/event failed: ${c.message}`),this.json(t,500,{error:c.message})}}async postToPushHost(e,t,n){let s=e.toLowerCase(),i=this.mesh?.directory().find(c=>c.peer.toLowerCase()===s);if(!i)throw new Error(`push: channels.push.relayTo "${e}" is not a mesh peer of this node`);let o=await fetch(`${i.peerUrl}${t}`,{method:"POST",headers:{"Content-Type":"application/json",...this.mesh.authHeaders(i.peer)},body:JSON.stringify(n),signal:AbortSignal.timeout(15e3)});if(!o.ok)throw new Error(`push: ${i.peer} ${t} -> ${o.status} ${(await o.text().catch(()=>"")).slice(0,200)}`);let a=await o.json().catch(()=>({}));if(t==="/channel/send")return a.messageId??void 0;if(typeof a.status!="number")throw new Error(`push: ${i.peer} ${t} gave no answer`);return{status:a.status,body:a.body??{}}}async handlePushApp(e,t){let n;try{n=await re(e)}catch(c){this.json(t,400,{error:"invalid JSON body",message:c.message});return}let{handlePushBridge:s,pushOrigin:i}=await import("./push-bridge-T5HZZRA2.js"),o=this.config.channels.push;if(!o?.enabled){this.json(t,200,{status:503,body:{error:`Notifications are off on ${this.config.node.name}.`}});return}if(o.relayTo){if(n?.origin!==void 0){this.json(t,200,{status:409,body:{error:`${this.config.node.name} relays its notifications too (channels.push.relayTo = ${o.relayTo})`}});return}if(n?.op!=="app"){this.json(t,400,{error:"op must be app"});return}try{this.json(t,200,await this.postToPushHost(o.relayTo,"/push/app",{op:"app",origin:i(this.config.node.name),call:n.call}))}catch(c){this.log(`[push] /push/app to ${o.relayTo} failed: ${c.message}`),this.json(t,502,{error:c.message})}return}let a=this.pushBridgeCaller(e);"error"in a&&n?.op!=="roster"&&this.log(`[push] /push/app from ${e.socket?.remoteAddress||"?"} refused: ${a.error}`),this.json(t,200,s(n,a,this.pushHost??null,this.pushHost?void 0:`Notifications are not running on ${this.config.node.name}. Check channels.push.subject and the database there.`))}pushBridgeCaller(e){return wm(String(e.headers.authorization||""),this.config.mesh.peers,process.env.MESH_TOKEN)}async handleChannelSend(e,t){let n;try{n=await re(e)}catch(l){this.json(t,400,{error:"invalid JSON body",message:l.message});return}let s=String(n?.channel??""),i=String(n?.chatId??""),o=String(n?.text??"");if(!s||!i||!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}let c;if(n.relayed===!0&&n.origin!==void 0){let l=this.pushBridgeCaller(e);if("origin"in l)c=l.origin;else if(i!=="default"){this.json(t,403,{error:l.error});return}}if(s==="push"&&i.includes(":")){let{scopedPushTarget:l}=await import("./push-bridge-T5HZZRA2.js"),d=l(i,this.pushBridgeCaller(e));if("error"in d){this.json(t,403,{error:d.error});return}}try{let l=await this.router.sendOutbound({channel:s,chatId:i,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,buttons:Array.isArray(n.buttons)?n.buttons:void 0,open:typeof n.open=="string"&&n.open.startsWith("/")?n.open:void 0,agentId:typeof n.agentId=="string"?n.agentId:void 0,relayed:n.relayed===!0?!0:void 0,...n.relayed===!0?{told:{passed:!0}}:{},origin:c},{recordInSession:!1});this.json(t,200,{ok:!0,messageId:l??null})}catch(l){this.log(`[mesh] /channel/send "${s}" failed: ${l.message}`),this.json(t,500,{error:l.message})}}async handleChannelChats(e,t,n={}){let s=new Set,i=[],o=[],a=(l,d)=>{let u=0;for(let h of l)!h.id||s.has(h.id)||(s.add(h.id),i.push({...h,source:d}),u++);u>0&&o.push(`${d}:${u}`)},c=this.router.getChannel(t);if(c?.listKnownChats)try{a(c.listKnownChats(),"local")}catch{}else if(c?.listChats)try{a(c.listChats().map(l=>({id:l.jid,name:l.name,kind:l.isGroup?"group":"dm"})),"local")}catch{}if(!n.localOnly&&this.mesh){let l=this.mesh.directory().filter(d=>d.healthy&&d.channels?.includes(t));await Promise.allSettled(l.map(async d=>{try{let u=await fetch(`${d.peerUrl}/channels/${encodeURIComponent(t)}/chats?local=1`,{headers:this.mesh.authHeaders(d.peer),signal:AbortSignal.timeout(5e3)});if(!u.ok)return;let h=await u.json();Array.isArray(h.chats)&&a(h.chats.map(g=>({id:g.id,name:g.name,kind:g.kind??"dm",accountId:g.accountId})),`mesh:${d.peer}`)}catch{}}))}this.json(e,200,{channel:t,source:o.join(", ")||"none",chats:i})}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;try{s=await re(e)}catch{s={}}try{let i=await U$({get:o=>this.workflowStore.get(o),dispatchWorkflow:o=>this.workflowDispatcher.dispatchWorkflow(o),startRun:o=>this.workflowDispatcher.startRun(o)},n,s);this.json(t,i.status,i.body)}catch(i){this.log(`[workflows] manual run "${n}" failed: ${i.message}`),this.json(t,500,{error:i.message})}}},Ku=zu;Bt(Ku,"MESH_PROTECTED_PATHS",new Set(["/task","/ask","/mesh/task","/mesh/inbox/send","/workflow/event","/workflow/transition","/channel/send","/push/app","/webrtc/signal","/gitlab/react","/gitlab/send-note","/gitlab/log-time","/channel/edit-comment","/github/send-comment"]));function UW(r){if(typeof r!="string")return"";let e=r.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 re(r){return new Promise((e,t)=>{let n="";r.setEncoding("utf8"),r.on("data",s=>{n+=s}),r.on("end",()=>{try{e(n?JSON.parse(n):{})}catch(s){t(s)}}),r.on("error",t)})}function GW(r,e){let t=["model","workspace","tier","permissionMode","mcpServers"],n=new Set,s=new Set([...Object.keys(r),...Object.keys(e)]);for(let i of s){let o=r[i],a=e[i];if(!o||!a){n.add("add/remove");continue}for(let c of t)JSON.stringify(o[c])!==JSON.stringify(a[c])&&n.add(`${i}.${c}`)}return Array.from(n).slice(0,6)}async function U(r){return new Promise((e,t)=>{let n="";r.on("data",s=>n+=s.toString()),r.on("end",()=>{try{e(n?JSON.parse(n):{})}catch{e({})}}),r.on("error",t)})}function Px(r){let e=r.business;return JSON.stringify([e?.roles,e?.orgChart,e?.relations,e?.projects,(r.people??[]).map(t=>t.id),[...Fn(r)]])}_x();function cZ(r){typeof r=="string"&&(Js.error(r),process.exit(1)),r instanceof Error&&(Js.error(r.message),process.exit(1)),Js.error("Something went wrong. Please try again."),process.exit(1)}export{aU as a,Yc as b,_t as c,ns as d,rs as e,Dt as f,Zr as g,Kw as h,tH as i,qb as j,BC as k,XC as l,Kb as m,Me as n,Zb as o,ek as p,vi as q,aq as r,cq as s,Di as t,jB as u,hM as v,gM as w,zl as x,uv as y,FB as z,vv as A,fM as B,Sv as C,$v as D,Iv as E,WB as F,UB as G,GB as H,Gi as I,FM as J,eS as K,Ne as L,aX as M,CO as N,QS as O,ZS as P,wD as Q,m0 as R,k0 as S,oN as T,Ed as U,c3 as V,l3 as W,d3 as X,$$ as Y,UN as Z,f3 as _,m3 as $,N$ as aa,As as ba,Sn as ca,xs as da,eJ as ea,Xd as fa,zL as ga,YL as ha,VJ as ia,xo as ja,Qd as ka,Zd as la,_o as ma,ve as na,sT as oa,Ms as pa,tF as qa,yT as ra,sF as sa,vT as ta,Fo as ua,Ns as va,Ho as wa,Bo as xa,xT as ya,fu as za,OT as Aa,yt as Ba,Re as Ca,Iu as Da,WT as Ea,UT as Fa,GT as Ga,HT as Ha,ga as Ia,UA as Ja,Fu as Ka,HA as La,B1 as Ma,Iz as Na,Ku as Oa,cZ as Pa};
|
|
1376
|
-
//# sourceMappingURL=chunk-
|
|
1376
|
+
//# sourceMappingURL=chunk-N2E73XNT.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ze,b as k,c as D,d as ea,e as fe,f as he,g as H,h as be,i as L,j as N,n as aa,o as ta,p as ra,q as na}from"./chunk-EFGAPAYZ.js";import{e as Ve,i as Qe}from"./chunk-QAWKN2N4.js";import{b as me}from"./chunk-DODL5POT.js";import{Kb as Ge,Wa as Ke,Xa as Ye,Ya as Je,_a as Xe,c as Le,ua as _,za as qe}from"./chunk-
|
|
1
|
+
import{a as Ze,b as k,c as D,d as ea,e as fe,f as he,g as H,h as be,i as L,j as N,n as aa,o as ta,p as ra,q as na}from"./chunk-EFGAPAYZ.js";import{e as Ve,i as Qe}from"./chunk-QAWKN2N4.js";import{b as me}from"./chunk-DODL5POT.js";import{Kb as Ge,Wa as Ke,Xa as Ye,Ya as Je,_a as Xe,c as Le,ua as _,za as qe}from"./chunk-2BWTUD6Z.js";import{a as V}from"./chunk-IMLAPB7G.js";import{k as Be}from"./chunk-LWVALEWQ.js";import{a as Z,b as Ue}from"./chunk-2GEO3AWE.js";import{b as Fe}from"./chunk-MRIVENBY.js";import{b as Q}from"./chunk-2VDO2HEK.js";import{c as Ne,e as We}from"./chunk-LQE73AZR.js";import{ga as G}from"./chunk-D4QTZJ4G.js";import{b as ue}from"./chunk-7AB3QUGH.js";import{a as K,b as X}from"./chunk-TTAKAN5L.js";import{a as He}from"./chunk-KN5LZ3JS.js";import{c as De,d as Me}from"./chunk-OWNQ2FD4.js";import{a as je}from"./chunk-ROLSSYXE.js";import{r as ge,t as Oe}from"./chunk-XL7UWG36.js";import{Db as pe,Gb as q,Hb as Re,Rb as xe,ab as Ee,g as le,hb as at,j as F,ma as ce,na as Pe,p as Za,xa as et}from"./chunk-ZAPHYYGT.js";import{existsSync as Y,readFileSync as xa,writeFileSync as ga,appendFileSync as lt,mkdirSync as ct}from"fs";import{dirname as pt,resolve as M}from"path";import{fileURLToPath as xt}from"url";import{hostname as gt}from"os";import{spawn as ut}from"child_process";var ve=`:root {
|
|
2
2
|
/* --- Brand (agentina) --------------------------------------------- */
|
|
3
3
|
--ax-blue: #2979FF;
|
|
4
4
|
--ax-blue-d: #1B5FD9;
|
|
@@ -2903,4 +2903,4 @@ tr:hover td { background: var(--bg-hover); }
|
|
|
2903
2903
|
${r}`).all(a,...t,...n).map(i=>({id:i.id,state:i.state,channel:i.channel,agentId:i.agent_id,text:i.text,createdAt:i.created_at})):[]}function Qo(e,a){return Ua(e,a,ce,"ORDER BY created_at")}function Zo(e,a,t=50){return Ua(e,a,[...ce,...Pe],"ORDER BY created_at DESC, rowid DESC LIMIT ?",Math.max(1,Math.min(t,500)))}at();var ze="member:",pr=90,xr="members",gr="tailscale-user-login",ur=400,mr=60*60*1e3;function fr(e){let a=e.scopes.find(t=>t.startsWith(ze));return a?a.slice(ze.length):null}function qa(e,a){if(!e)return null;let t=a.verify(e),r=t?fr(t):null;return t&&r?{rec:t,personId:r}:null}function ii(e,a){let t=e.people().find(s=>s.id===a);if(!t)return{ok:!1,error:`No person "${a}". Add them first: agentx people add ${a} --name "\u2026"`};let{token:r,record:n}=e.tokens.create({name:`${t.name} (machine not paired yet)`,scopes:[`${ze}${t.id}`],expiresInDays:pr}),{code:o,expiresAt:i}=e.codes.create({token:r,tokenId:n.id,name:t.id});return e.members.log({person:t.id,device:n.id,event:"invited"}),{ok:!0,code:o,expiresAt:i,tokenId:n.id,person:t}}var hr=Math.round(Ne/6e4);function br(e){return e==="client"?"Your project":"My work"}function si(e){let a=br(e.person.role),t=e.person.role==="client"?`I use AgentX to keep track of the work I do for you. It has a page for you, "${a}": what you asked us for, and where each request stands.`:`I use AgentX to give our AI agents their jobs. It has a page for you, "${a}": what you asked the agents for, and where each request stands.`;return[`Hi ${e.person.name},`,"",t,"","To open it:","1. Accept the Tailscale share I sent you. Tailscale is a small program that connects your computer to mine, privately.",`2. Open ${e.origin.replace(/\/+$/,"")}/member in Edge or Chrome, give your computer a name and type this code: ${We(e.code)}`,` The code works once, for ${hr} minutes. If it has stopped working, tell me and I will send you a new one.`,"","I then approve your machine, and the page opens by itself."].join(`
|
|
2904
2904
|
`)}var vr="The private network says someone else is connecting from this machine. Ask the person who invited you for a new code.",wr="Too many machines are waiting for the owner's answer. Try again later.",Fa="That code didn't work. Check it, or ask the person who invited you for a new one.",Ka=(e,a)=>{let t=e.headers[a];return(Array.isArray(t)?t[0]:t||"").trim()};function Ya(e){let a=e.socket?.remoteAddress||"";return a==="127.0.0.1"||a==="::1"||a==="::ffff:127.0.0.1"}function yr(e){if(!Ya(e))return null;let a=Ka(e,gr).toLowerCase();return a?a.slice(0,80):null}function kr(e){let a=e.socket?.remoteAddress||"unknown";if(!Ya(e))return a;let t=Ka(e,"x-forwarded-for").split(",").pop().trim();return/^[0-9a-fA-F:.]{2,45}$/.test(t)?t:a}function $r(e){return typeof e=="string"?e.replace(/[^\p{L}\p{N} ._'()-]/gu," ").replace(/\s+/g," ").trim().slice(0,60):""}function _r(e){return e.identities.map(Ee).filter(a=>!!a&&a.channel==="tailscale").map(a=>a.value)}async function di(e,a){let t=Date.now(),r=a.now??Date.now,n=a.log??(b=>console.log(b)),o=kr(e),i=a.limiter.retryAfter(o);if(i>0)return n(`[member] pair-code refused from ${o}: locked out for ${i}s more`),{status:429,body:{error:"too many attempts",retryAfter:i},retryAfter:i};let s=null,d="";try{let b=await Q(e,2048);s=b.code,d=$r(b.machine)}catch{}let l=a.codes.redeem(s),c=l?qa(l.token,a.tokens):null;if(await Cr(t,a.minMs??ur),!l||!c)return a.limiter.fail(o),n(`[member] pair-code failed from ${o}`),{status:401,body:{error:Fa}};a.limiter.succeed(o);let{rec:m,personId:g}=c,u=a.people().find(b=>b.id===g);if(!u)return a.tokens.revoke(m.id),a.members.log({person:g,device:m.id,event:"refused",address:o,detail:"person no longer listed"}),n(`[member] pair-code for ${g} refused from ${o}: person no longer listed`),{status:403,body:{error:Fa}};let x=yr(e),f=_r(u);if(f.length&&(!x||!f.includes(x)))return a.tokens.revoke(m.id),a.members.log({person:g,device:m.id,event:"refused",address:o,detail:`network login ${x??"missing"}; expected ${f.join(" or ")}`}),n(`[member] ${g}: pairing from ${o} refused: the network says "${x??"nobody"}", expected ${f.join(" or ")}`),{status:403,body:{error:vr}};let A=d||"Unnamed machine",y=u.name.slice(0,40),v=Oe(a.root,{title:`New machine for ${y}`,ask:`From ${o}, ${x?`network login ${x}`:"no network login reported"}. Machine name, as typed there: "${A}". Let it see their own work?`,recommend:`Yes if ${y} told you they just paired this machine. No if you did not expect it.`,if_silent:"discard",raised_by:xr},{now:r()});return v.ok?(a.members.add({tokenId:m.id,personId:g,name:A,state:"pending",cardId:v.card.id,address:o,...x?{network:x}:{},createdAt:new Date(r()).toISOString()}),a.members.log({person:g,device:m.id,event:"paired",address:o,detail:A}),n(`[member] ${g} paired "${A}" from ${o}; waiting for the owner (card ${v.card.id})`),{status:200,body:{person:g,name:A,state:"pending"},token:l.token}):(a.tokens.revoke(m.id),a.members.log({person:g,device:m.id,event:"refused",address:o,detail:v.error}),n(`[member] ${g}: pairing from ${o} refused: ${v.error}`),{status:503,body:{error:wr}})}var de="this machine is not paired",Sr="waiting for the owner to approve this machine";function Ja(e){return e?e.status==="decided"?e.verdict??null:e.status==="expired"?"no":null:null}function li(e,a){return a.state==="pending"&&a.cardId?Ja(ge(e,a.cardId)):null}function ci(e,a,t){let r=a.now??Date.now,n=a.log??(c=>console.log(c)),o=qa(e,a.tokens);if(!o)return{ok:!1,status:401,error:de};let{rec:i,personId:s}=o,d=a.members.byToken(i.id);if(!d||d.state==="removed"||d.personId!==s)return{ok:!1,status:401,error:de};if(a.people&&!a.people().some(c=>c.id===s))return Xa(a,i.id,"person no longer listed"),n(`[member] ${s}: "${d.name}" ended: person no longer listed`),{ok:!1,status:401,error:de};if(d.state==="pending"){let c=d.cardId?ge(a.root,d.cardId):null,m=Ja(c);if(m==="yes")d=a.members.update(i.id,{state:"active",approvedAt:new Date(r()).toISOString()})??d,a.members.log({person:s,device:i.id,event:"approved",detail:c?.decided_by}),n(`[member] ${s}: "${d.name}" approved`);else if(m==="no"){let g=c?.status==="expired"?"the owner did not answer in time":"the owner said no";return a.tokens.revoke(i.id),a.members.update(i.id,{state:"removed",removedAt:new Date(r()).toISOString(),removedReason:g}),a.members.log({person:s,device:i.id,event:"refused",detail:g}),n(`[member] ${s}: "${d.name}" refused: ${g}`),{ok:!1,status:401,error:de}}else return{ok:!1,status:403,error:Sr,waiting:!0}}let l=d.lastSeenAt?Date.parse(d.lastSeenAt):0;return t&&(r()-l>=mr||d.lastAddress!==t)&&(d=a.members.update(i.id,{lastSeenAt:new Date(r()).toISOString(),lastAddress:t})??d,a.members.log({person:s,device:i.id,event:"signed-in",address:t})),{ok:!0,device:d,personId:s,rec:i}}function Xa(e,a,t="removed by the owner"){let r=e.members.byToken(a);if(!r)return null;e.tokens.revoke(a);let n=e.members.update(a,{state:"removed",removedAt:new Date((e.now??Date.now)()).toISOString(),removedReason:t});return e.members.log({person:r.personId,device:a,event:"removed",detail:t}),n}function pi(e,a){return e.members.devices(a).filter(t=>t.state!=="removed").map(t=>Xa(e,t.tokenId,"person removed by the owner")).filter(t=>!!t)}async function Cr(e,a){let t=e+a-Date.now();t>0&&await new Promise(r=>setTimeout(r,t))}var Ga=["gitlab","github"];function Ar(e,a,t){let r=String(a||"").trim().toLowerCase();if(!Ga.includes(r))throw new Error(`Request status works on ${Ga.join(" and ")}, not on "${a}".`);e.requestStatus=e.requestStatus&&typeof e.requestStatus=="object"?e.requestStatus:{};let n=Array.isArray(e.requestStatus.channels)?e.requestStatus.channels.map(o=>String(o).toLowerCase()):[];return e.requestStatus.channels=t?[...new Set([...n,r])]:n.filter(o=>o!==r),`request status on ${r} is ${t?"on":"off"}`}function ui(e){return Array.isArray(e?.requestStatus?.channels)?e.requestStatus.channels.map(a=>String(a).toLowerCase()):[]}function mi(e){let{summary:a}=Z(t=>Ar(t,e?.channel,!!e?.enabled));return{summary:a}}var hi="https://myaccount.google.com/apppasswords";function bi(e){let a=e.split("@")[1]?.toLowerCase()??"";if(a==="gmail.com"||a==="googlemail.com")return{imapHost:"imap.gmail.com",imapPort:993,smtpHost:"smtp.gmail.com",smtpPort:465}}function vi(e){let a=e.user&&e.user!==e.address?{user:e.user}:{};return{agent:e.agent,address:e.address,imap:{host:e.imapHost,port:e.imapPort,secure:e.imapPort===993,...a,password:`\${${e.passwordEnv}}`},smtp:{host:e.smtpHost,port:e.smtpPort,secure:e.smtpPort===465},allowFrom:e.allowFrom,send:e.send}}function wi(e){return`EMAIL_${e.toUpperCase().replace(/[^A-Z0-9]/g,"_")}_PASSWORD`}function $i(e){return`${e.name} <${e.from}> via ${e.host}:${e.port}`}async function _i(e,a){return Be({host:e.host,port:e.port,secure:e.secure,user:e.user,password:e.password},{name:e.name,address:e.from},a,{"Auto-Submitted":"auto-generated"})}function Si(e,a){return{to:e,subject:`${a.name}: test mail`,text:[`This is a test mail from ${a.name}.`,"","If it reached you, AgentX can send mail through this sender.","You can ignore it."].join(`
|
|
2905
2905
|
`)}}function Ai(e){return new Set(Object.entries(e).filter(([,a])=>a?.wiki?.absorb?.enabled===!1).map(([a])=>a))}function Ti(e,a){return a.only?{agents:[a.only],skipped:[]}:{agents:e.filter(t=>!a.off.has(t)),skipped:e.filter(t=>a.off.has(t))}}function Ii(e,a){return`absorb is off for this agent (agents.${e}.wiki.absorb.enabled); skipped.${e===a?" It reads the wiki notes inbox, so the inbox was not read.":""} Use --agent ${e} to run it anyway.`}function zi(e,a){if(a){if(!e.wiki?.absorb)return;delete e.wiki.absorb.enabled,Object.keys(e.wiki.absorb).length===0&&delete e.wiki.absorb,Object.keys(e.wiki).length===0&&delete e.wiki;return}e.wiki??={},e.wiki.absorb??={},e.wiki.absorb.enabled=!1}var Tr="https://ntfy.sh";function Ei(e){return{enabled:!!e?.enabled,server:e?.server||Tr,topicSet:!!e?.topic,tokenSet:!!e?.token}}function Ri(e,a){let t={...e??{}};if("enabled"in a&&(t.enabled=!!a.enabled),"server"in a){let r=String(a.server).trim().replace(/\/+$/,"");if(!/^https?:\/\/\S+$/.test(r))throw new Error("ntfy server must be an http(s) URL");t.server=r}if("topic"in a){let r=String(a.topic).trim();if(!r)throw new Error("ntfy topic cannot be empty");t.topic=r}if("token"in a){let r=String(a.token??"").trim();r?t.token=r:delete t.token}if(t.enabled&&!t.topic)throw new Error("set a topic before enabling ntfy");return t}Za();function Va(e){return/^(agent|person):/.test(e)?F(e):`person:${e}`}function ji(e){let a=(e?.projects??[]).filter(t=>t?.id);return a.map(t=>({id:t.id,name:t.name?.trim()||t.id,client:Le(t.id,a),...t.pm?{pm:F(t.pm)}:{},...t.lead?{lead:Va(t.lead)}:{},team:[...new Set((t.team??[]).filter(Boolean).map(F))]})).sort((t,r)=>t.client.localeCompare(r.client)||t.name.localeCompare(r.name)||t.id.localeCompare(r.id))}function Hi(e,a,t){if(!t.lead&&!t.team?.length)return;let r=new Set(Object.keys(e.business?.orgChart||{})),n=new Set((e.people||[]).map(i=>String(i.id))),o={id:a,name:a,client:"",...t.lead?{lead:Va(t.lead)}:{},team:(t.team??[]).map(F)};return Ir([o],r,n)}function Ir(e,a,t){let r=n=>{let o=le(n);return o.kind==="agent"?a.has(o.id)?void 0:`"${o.id}", which is not an agent in business.orgChart`:t.has(o.id)?void 0:`"${o.id}", which is not a person in people`};for(let n of e){if(n.lead){if(le(n.lead).kind!=="person")return`Project ${n.name} is led by "${n.lead}"; a lead is a person (person:<id>), the PM is the agent`;let o=r(n.lead);if(o)return`Project ${n.name} is led by ${o}`}for(let o of n.team){let i=r(o);if(i)return`Project ${n.name} has ${i} in its team`}}}export{ve as a,da as b,ye as c,nt as d,ot as e,it as f,ua as g,mt as h,_n as i,Sn as j,Cn as k,ko as l,Co as m,Ba as n,Yo as o,Jo as p,Rn as q,On as r,It as s,Et as t,ke as u,Dn as v,Mn as w,Rt as x,Bn as y,Un as z,Fn as A,Vo as B,Qo as C,Zo as D,pr as E,xr as F,ii as G,hr as H,br as I,si as J,vr as K,wr as L,yr as M,kr as N,$r as O,_r as P,di as Q,Ja as R,li as S,ci as T,Xa as U,pi as V,Ga as W,Ar as X,ui as Y,mi as Z,hi as _,bi as $,vi as aa,wi as ba,$i as ca,_i as da,Si as ea,Ai as fa,Ti as ga,Ii as ha,zi as ia,Ei as ja,Ri as ka,Va as la,ji as ma,Hi as na,Ir as oa,Qt as pa,go as qa,vo as ra,wo as sa};
|
|
2906
|
-
//# sourceMappingURL=chunk-
|
|
2906
|
+
//# sourceMappingURL=chunk-OW4XJDFO.js.map
|
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{b as o}from"./chunk-OSH2PEBH.js";import"./chunk-QIJLFPWE.js";var e=o(process.versions.node);e&&(console.error(e),process.exit(1));var{buildProgram:s}=await import("./program-
|
|
2
|
+
import{b as o}from"./chunk-OSH2PEBH.js";import"./chunk-QIJLFPWE.js";var e=o(process.versions.node);e&&(console.error(e),process.exit(1));var{buildProgram:s}=await import("./program-AJVTYLTY.js"),{installCliSignalExit:r}=await import("./signal-exit-C5EUGHKI.js"),{applyConnectAttemptTimeout:i,configPathFromArgv:a,readConnectAttemptTimeout:n}=await import("./net-family-X2P3OVDP.js");r();i(n(process.cwd(),a(process.argv.slice(2))));var t=await s();process.argv.slice(2).length===0?t.outputHelp():t.parse();
|
|
3
3
|
//# sourceMappingURL=cli.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Oa as Tt,Pa as Mt,a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,h as bt}from"./chunk-
|
|
1
|
+
import{Oa as Tt,Pa as Mt,a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,h as bt}from"./chunk-N2E73XNT.js";import"./chunk-2BWTUD6Z.js";import"./chunk-GTJIKXDB.js";import"./chunk-WXYO7JFL.js";import"./chunk-ZVP6GB4G.js";import"./chunk-5Q62AXJG.js";import"./chunk-IMLAPB7G.js";import"./chunk-EKJG63EJ.js";import"./chunk-LWVALEWQ.js";import"./chunk-JSCVOB4G.js";import"./chunk-JLBRNYKY.js";import"./chunk-BYEL7KKR.js";import"./chunk-2GEO3AWE.js";import"./chunk-MRIVENBY.js";import"./chunk-GJOKXP5D.js";import"./chunk-PPUN7YHA.js";import"./chunk-VZLIBDLH.js";import"./chunk-UKUH662W.js";import"./chunk-3Q6MRG3P.js";import"./chunk-2VDO2HEK.js";import"./chunk-JWDJMFU6.js";import"./chunk-2P5NP4H6.js";import"./chunk-B4KQC3DG.js";import"./chunk-LQE73AZR.js";import"./chunk-2D3RYIDU.js";import"./chunk-Q3A5P373.js";import"./chunk-TWWHZNHZ.js";import"./chunk-QPABR72X.js";import"./chunk-A5GYG56I.js";import"./chunk-E2JKO262.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-6TTGRTDO.js";import"./chunk-RX5O5637.js";import"./chunk-DPN3EYW3.js";import"./chunk-5ELIX7BQ.js";import"./chunk-X7UQY7CH.js";import"./chunk-IFUAP7UD.js";import"./chunk-KP7KDLZ2.js";import"./chunk-XVV7ZZ77.js";import{Ca as yt,m as lt,n as ct,o as dt,p as mt,q as pt}from"./chunk-IJXCGKAB.js";import"./chunk-D4QTZJ4G.js";import"./chunk-MEFPXHQJ.js";import"./chunk-7AB3QUGH.js";import{a as L}from"./chunk-BAXGL6TY.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-IANIJUL5.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-GV7S5BAX.js";import"./chunk-SZDACK6O.js";import"./chunk-VE3SSOQX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-VJVXEVZ7.js";import{u as ut}from"./chunk-C5VFABFI.js";import"./chunk-TTAKAN5L.js";import"./chunk-3UOTLMXD.js";import"./chunk-VWTBHLMX.js";import"./chunk-BE64IJWM.js";import"./chunk-5ONH4ITT.js";import"./chunk-JRAG37V5.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-GSX4NK2N.js";import"./chunk-HPRLRD4P.js";import"./chunk-KN5LZ3JS.js";import{a as ht}from"./chunk-7GCB4HDJ.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-PAMMBHB2.js";import"./chunk-JTFCU5LH.js";import{f as gt,g as ft}from"./chunk-WD4HZAYI.js";import"./chunk-WPNRDEHW.js";import"./chunk-LUOW2YHY.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-XPKDQDBH.js";import{j as it,k as rt,l as at}from"./chunk-NXOBCFUJ.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-MYVHVJWZ.js";import"./chunk-QUFIUXMQ.js";import"./chunk-3AHYZLGE.js";import"./chunk-XL7UWG36.js";import"./chunk-MNG2AMKZ.js";import"./chunk-LY4G7PCW.js";import"./chunk-2HBEZV7L.js";import"./chunk-A7JSRDJL.js";import"./chunk-BERWTVG2.js";import"./chunk-AHWWJ7AF.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-DCIYOPJF.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{Fb as tt,Hb as st,Kb as ot,Rb as nt}from"./chunk-ZAPHYYGT.js";import"./chunk-KEUW6YLL.js";import"./chunk-UEEB3UTU.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.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).
|