agentix-cli 0.153.0 → 0.153.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/dist/{board-dashboard-OZJSS6EM.js → board-dashboard-UZF7MQZA.js} +3 -3
- package/dist/{chunk-R4R7EYY3.js → chunk-BNOGNRAM.js} +2 -2
- package/dist/{chunk-P24P43ZB.js → chunk-DZRD6BE4.js} +2 -2
- package/dist/{chunk-SW6HCRLU.js → chunk-IFOFBI3U.js} +2 -2
- package/dist/chunk-LQS27HSV.js +6 -0
- package/dist/chunk-LQS27HSV.js.map +1 -0
- package/dist/{chunk-D6U37WO3.js → chunk-VAK4LT62.js} +2 -2
- package/dist/{chunk-IJQ2UUMZ.js → chunk-XQ2VU6MM.js} +3 -3
- package/dist/{chunk-MOCDP7Q3.js → chunk-ZAH74SFX.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{doctor-UT32WKCP.js → doctor-QWVUVWTF.js} +2 -2
- package/dist/{grants-HSLB62EG.js → grants-YGA654NI.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/{program-NU6QIXJJ.js → program-2YK3YCBX.js} +5 -5
- package/package.json +1 -1
- package/dist/chunk-24QMHUU2.js +0 -5
- package/dist/chunk-24QMHUU2.js.map +0 -1
- /package/dist/{board-dashboard-OZJSS6EM.js.map → board-dashboard-UZF7MQZA.js.map} +0 -0
- /package/dist/{chunk-R4R7EYY3.js.map → chunk-BNOGNRAM.js.map} +0 -0
- /package/dist/{chunk-P24P43ZB.js.map → chunk-DZRD6BE4.js.map} +0 -0
- /package/dist/{chunk-SW6HCRLU.js.map → chunk-IFOFBI3U.js.map} +0 -0
- /package/dist/{chunk-D6U37WO3.js.map → chunk-VAK4LT62.js.map} +0 -0
- /package/dist/{chunk-IJQ2UUMZ.js.map → chunk-XQ2VU6MM.js.map} +0 -0
- /package/dist/{chunk-MOCDP7Q3.js.map → chunk-ZAH74SFX.js.map} +0 -0
- /package/dist/{doctor-UT32WKCP.js.map → doctor-QWVUVWTF.js.map} +0 -0
- /package/dist/{grants-HSLB62EG.js.map → grants-YGA654NI.js.map} +0 -0
- /package/dist/{program-NU6QIXJJ.js.map → program-2YK3YCBX.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as No,Ba as Mg,D as Hh,F as Ss,Fa as Og,Ga as Rs,H as sg,Ha as Ho,Ia as Dg,Ja as Ng,K as rg,Ka as Lg,La as jg,M as ig,Na as Fg,O as og,P as jo,Q as ag,R as Ke,S as cg,T as $s,Ua as Wg,V as Fo,Va as Ug,W as dg,X as Uo,Y as ct,Z as wg,_ as kg,a as gh,b as Ao,ba as dt,ca as bg,cb as Bo,da as vg,db as qo,ea as Sg,f as Eo,fa as $g,fb as Gg,g as ph,ga as Ig,h as fh,ha as Tg,i as Je,j as mh,ja as Se,k as yh,ka as Is,la as Go,m as wh,ma as xg,na as fn,o as kh,oa as Rg,p as Nt,pa as Oe,q as Po,qa as Ag,r as Oh,ra as Eg,s as Dh,sa as Cg,t as Nh,ta as Ts,u as Lh,ua as xs,v as jh,va as Pg,w as Fh,wa as _g,x as Wh,y as Uh,z as Gh}from"./chunk-
|
|
1
|
+
import{A as No,Ba as Mg,D as Hh,F as Ss,Fa as Og,Ga as Rs,H as sg,Ha as Ho,Ia as Dg,Ja as Ng,K as rg,Ka as Lg,La as jg,M as ig,Na as Fg,O as og,P as jo,Q as ag,R as Ke,S as cg,T as $s,Ua as Wg,V as Fo,Va as Ug,W as dg,X as Uo,Y as ct,Z as wg,_ as kg,a as gh,b as Ao,ba as dt,ca as bg,cb as Bo,da as vg,db as qo,ea as Sg,f as Eo,fa as $g,fb as Gg,g as ph,ga as Ig,h as fh,ha as Tg,i as Je,j as mh,ja as Se,k as yh,ka as Is,la as Go,m as wh,ma as xg,na as fn,o as kh,oa as Rg,p as Nt,pa as Oe,q as Po,qa as Ag,r as Oh,ra as Eg,s as Dh,sa as Cg,t as Nh,ta as Ts,u as Lh,ua as xs,v as jh,va as Pg,w as Fh,wa as _g,x as Wh,y as Uh,z as Gh}from"./chunk-VAK4LT62.js";import{d as lh,g as uh,h as hh}from"./chunk-GDLO7FC7.js";import{B as ys,C as _o,D as ws,E as Lt,I as Bh,c as eh,e as th,f as nh,g as ms,h as xo,i as sh,j as Xe,x as $h,y as Ih,z as Th}from"./chunk-ZAH74SFX.js";import{b as yg}from"./chunk-7LN4VKDU.js";import{a as bh}from"./chunk-ZVP6GB4G.js";import{g as Rh}from"./chunk-LQE73AZR.js";import{b as Ah,c as Eh}from"./chunk-2D3RYIDU.js";import{b as qh}from"./chunk-MRIVENBY.js";import{i as Xh,m as Lo,n as Vh,p as Jh,q as Kh,r as zh,s as Yh,t as Qh,u as Zh}from"./chunk-BNOGNRAM.js";import{e as Mo,k as Oo,l as Ch,m as bs,n as jt,o as Ft,p as Me,r as Ph,s as _h,t as Mh,u as Do,v as vs}from"./chunk-LQS27HSV.js";import{a as eg}from"./chunk-PPUN7YHA.js";import{a as tg,b as ng}from"./chunk-VZLIBDLH.js";import{b as lg,c as ug,d as Wo,e as hg,f as gg,g as pg,h as fg,i as mg}from"./chunk-EKJG63EJ.js";import{o as Co}from"./chunk-3LU2ZQZJ.js";import{b as ks}from"./chunk-EMGB23H5.js";import{d as xh}from"./chunk-JAML6222.js";import{a as Ve}from"./chunk-MNG2AMKZ.js";import{b as ch,c as dh}from"./chunk-X7UQY7CH.js";import{a as rh,b as at,c as ih,d as oh,e as ah}from"./chunk-PYHR4HXO.js";import{c as Dt}from"./chunk-KP7KDLZ2.js";import{a as vh,b as Sh}from"./chunk-A5GYG56I.js";import{$ as ps,B as Xl,C as Vl,D as Jl,E as Kl,F as ge,G as Yl,H as Ql,I as Zl,J as eu,K as tu,L as nu,M as su,N as Uu,O as Gu,P as Hu,Q as Bu,R as qu,S as Xu,U as pn,V as Vu,W as pe,X as qe,Y as Io,Z as _t,_ as To,a as wl,aa as Mt,b as go,ba as Ot,c as bl,ca as me,d as Al,da as ot,e as El,ea as oe,f as hn,h as fo,ha as zu,i as mo,j as yo,k as wo,l as Cl,ra as Yu,s as _l,t as Dl,u as rt,v as Nl,w as Ll,x as Ct,y as Wl,z as X}from"./chunk-5DPN2HIR.js";import{A as Cu,B as Pu,C as _u,D as Mu,E as Ou,F as Du,H as Nu,K as Lu,P as ju,Q as Fu,T as Wu,X as Ju,a as Ml,ba as Ku,c as jl,d as Fl,e as it,f as _e,l as ru,n as iu,p as ku,q as bu,r as Iu,s as Tu,t as xu,u as Ru,w as $o,x as gs,y as Au,z as Eu}from"./chunk-S5FRIHWM.js";import{a as ko,b as Ol}from"./chunk-MEFPXHQJ.js";import{A as Qu,B as fs,C as Zu,h as Cd,n as Pd,o as Ji}from"./chunk-MWYPW5XP.js";import{b as Rd}from"./chunk-SFQUP3BP.js";import{a as Ro}from"./chunk-6TTGRTDO.js";import{a as ou,b as bo,c as au,d as cu,e as du,i as lu,j as uu}from"./chunk-VE3SSOQX.js";import{b as zl}from"./chunk-W4YR2RO2.js";import{b as gu,c as pu,d as vo,f as us,g as fu,h as mu,i as yu,j as gn,k as hs,m as wu}from"./chunk-5TTHN7DP.js";import{b as he,d as Pt,f as Ge,g as ds,i as fe,j as hu,k as He,l as Be,m as $u,s as So}from"./chunk-LH3GOBZP.js";import{a as vu,b as Su}from"./chunk-BFONYVOM.js";import{d as Ul,e as Gl,f as Hl,g as Bl,h as ql,j as ls}from"./chunk-X5C5W3E4.js";import{c as cs}from"./chunk-OWNQ2FD4.js";import{c as Pl}from"./chunk-MWNCS57L.js";import{d as Md,e as aS,m as pl,n as kS,q as fl,v as ml,x as ho,y as Ue,z as un}from"./chunk-HVNWI63Z.js";import{a as Pe,b as ln,f as os}from"./chunk-72SZI2UW.js";import{a as cn,b as _d}from"./chunk-FCPTN6NF.js";import{c as yl}from"./chunk-MYVHVJWZ.js";import{e as kl}from"./chunk-6TURWSMN.js";import{d as vl,e as Sl,f as po,g as as,h as $l,i as Il,j as Tl,k as xl,q as Rl}from"./chunk-AV7T3SYT.js";import{o as xd,p as oS}from"./chunk-JNG3P5V2.js";import{a as es,b as iS}from"./chunk-7I7IEX4S.js";import{b as Ad,e as Ed}from"./chunk-JHCI6XCJ.js";import{e as tt}from"./chunk-DSYKYZMT.js";import{$ as dn,A as hS,B as el,C as gS,D as tl,E as pS,G as Rt,H as nl,J as so,K as ro,L as At,La as uo,M as Et,N as io,Na as gl,O as oo,S as sl,T as is,U as ao,Ua as wS,W as co,Y as rl,Z as il,aa as ol,ba as al,ca as cl,d as xt,da as dl,e as Dd,ea as fS,f as zi,g as cS,h as ts,ha as ll,i as Yi,j as ns,ka as ul,l as nt,la as hl,m as Qi,n as Nd,o as dS,p as ss,pa as mS,q as lS,r as rs,ra as lo,s as Ld,t as uS,ta as yS,u as jd,v as Fd,w as Wd,z as Zd}from"./chunk-5VPU5FHB.js";import{a as Ud,e as st,f as Gd,g as Hd,h as Zi}from"./chunk-BRK6M6LA.js";import{a as Bd,b as qd,c as Xd,e as Vd,f as eo,g as Jd,h as Kd,i as to,j as zd,k as Yd,m as no,n as Qd}from"./chunk-UIBUZ2N3.js";import{b as Ki,e as Od}from"./chunk-2QNT5JDS.js";import{d as Tt}from"./chunk-QIJLFPWE.js";import{existsSync as Qo,readFileSync as Zo}from"fs";Wd();var Hg=["answer","narration","line"],Bg=5e3;function qg(r){return r==="/voice/queue"||r.startsWith("/voice/queue/")}async function Xg(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 d=String(s.text??"").trim(),l=String(s.agentId??s.agent??""),u=String(s.kind??"line");if(!d||!l||!Hg.includes(u))return{status:400,body:{error:`Required: text and agentId; kind is ${Hg.join(" | ")}`}};if(d.length>Bg)return{status:413,body:{error:`text is over ${Bg} characters`}};let g=e(l);if(!g)return{status:404,body:{error:`Unknown agent: ${l}`}};let{item:m,done:p}=r.enqueue({voice:g,text:d,agentId:l,kind:u,...typeof s.floor=="string"?{floor:s.floor}:{}});return s.wait!==!0?{status:202,body:{item:m}}:{status:200,body:{item:m,played:await p}}}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()}:Xo(o);case"front":return r.front(o)?{status:200,body:r.view()}:Xo(o);case"replay":{let d=r.replay(o);return d?{status:202,body:{item:d}}:Xo(o)}default:return{status:404,body:{error:"Not found"}}}}function Vg(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?[Fd(r.floor)]:[],t,...r.waiting.map((n,s)=>`${s+1}. waiting: ${e(n)}`)].join(`
|
|
2
2
|
`)}var Xo=r=>({status:404,body:{error:`No such line in the queue: ${r}`}});var bS=20,Vo=120,vS=80,SS=new Set(["waiting_owner","needs_attention"]);function Jo(r,e){let t=String(r??"").replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function As(r){return{total:r.length,items:r.slice(0,bS)}}var Ko=r=>new Date(r).toISOString();function Jg(r){return{id:r.id,agentId:r.agentId,kind:r.kind,text:Jo(r.text,vS),enqueuedAt:Ko(r.enqueuedAt)}}function Kg(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:Jo(i.title,Vo),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:Jo(i.title,Vo),from:i.from,at:i.at,heldBecause:i.heldBecause})),n=(r.requests??[]).filter(i=>SS.has(i.state)).sort((i,o)=>i.createdAt-o.createdAt).map(i=>({id:i.id,title:Xe(i,Vo).headline,agentId:i.agentId,state:i.state,since:Ko(i.stateChangedAt??i.updatedAt)})),s=r.voice;return{ts:Ko(r.now),cards:As(e),held:As(t),voice:s?{paused:s.paused,reserved:s.reserved,playing:s.playing?Jg(s.playing):null,waiting:As(s.waiting.map(Jg))}:null,requests:As(n),errors:r.errors??[]}}function zg(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 ea}from"path";yS();var $S={name:"agentx",version:"0.1.0"},IS=["2024-11-05","2025-03-26","2025-06-18","2025-11-25"],TS="2024-11-05";function xS(r){return typeof r=="string"&&IS.includes(r)?r:TS}var RS={tools:{},elicitation:{form:{}}},AS=0;async function Yg(r,e){let t=++AS;return lt({jsonrpc:"2.0",id:`elicit-${t}`,method:"elicitation/create",params:{mode:"form",message:r,requestedSchema:e}}),new Promise(n=>{mn.set(`elicit-${t}`,s=>{s?.action==="accept"&&s.content?n(s.content):n(null)}),setTimeout(()=>{mn.has(`elicit-${t}`)&&(mn.delete(`elicit-${t}`),n(null))},6e4)})}var mn=new Map,ES="http://localhost:18800",zo;function CS(){if(process.env.AGENTX_DAEMON_URL)return process.env.AGENTX_DAEMON_URL;for(let r of["agentx.json",".agentx/config.json"])try{let e=ea(process.cwd(),r);if(!Qo(e))continue;let t=JSON.parse(Zo(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 ES}function V(){return zo===void 0&&(zo=CS()),zo}var Yo;function PS(r){try{let e=ea(process.cwd(),".env");if(!Qo(e))return"";for(let t of Zo(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 _S(r=process.env){if(r.AGENTX_TOKEN)return r.AGENTX_TOKEN;if(r.MESH_TOKEN)return r.MESH_TOKEN;let e=PS("MESH_TOKEN");if(e)return e;for(let t of["agentx.json",".agentx/config.json"])try{let n=ea(process.cwd(),t);if(!Qo(n))continue;let s=JSON.parse(Zo(n,"utf-8"))?.dashboard?.token;if(typeof s=="string"&&s)return s}catch{}return""}function MS(){return Yo===void 0&&(Yo=_S()),Yo}var J=(r,e)=>{let t=MS();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 Es(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 OS(){let r=process.env.AGENTX_AGENT_ID,e=Es();if(!(!r||!e.callerChannel||!e.callerChatId))try{let t=new URLSearchParams({channel:e.callerChannel,chatId:e.callerChatId}),n=await J(`${V()}/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}}var DS=1e4,NS=new Set(["ECONNREFUSED","ENOTFOUND","EAI_AGAIN","EHOSTUNREACH","ENETUNREACH"]);function LS(r,e){let t=e,n=t?.cause?.code??t?.code;if(n&&NS.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 jS=/\x1B\[[0-9;]*[A-Za-z]/g;function Wt(r){return r.replace(jS,"")}async function FS(r,e,t){let n=await J(`${V()}/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:WS(i,!!s.hasMore)}]}}function WS(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}:
|
|
@@ -552,7 +552,7 @@ ${d}`)}let $={agentId:o,message:w,context:{channel:y,sender:p?"opencode":"openai
|
|
|
552
552
|
|
|
553
553
|
`)}}function wf(r){r.writeHead(200,{"Content-Type":"text/event-stream; charset=utf-8","Cache-Control":"no-cache",Connection:"keep-alive","X-Accel-Buffering":"no"})}function kf(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}]})}
|
|
554
554
|
|
|
555
|
-
`)}function bf(r,e,t,n,s,i){let o=i?.usage?.inputTokens??0,a=i?.usage?.outputTokens??Math.ceil(s.length/4);xa(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 xa(r,e,t){r.writeHead(e,{"Content-Type":"application/json"}),r.end(JSON.stringify(t))}var Rn=class{module;minLevel;constructor(e,t="info"){this.module=e,this.minLevel=t}child(e){return new Rn(`${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(Rn.levelOrder[e]<Rn.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)}},xn=Rn;Tt(xn,"levelOrder",{debug:0,info:1,warn:2,error:3});import{realpathSync as Z$,statSync as eI}from"fs";var yt={version:"0.153.
|
|
555
|
+
`)}function bf(r,e,t,n,s,i){let o=i?.usage?.inputTokens??0,a=i?.usage?.outputTokens??Math.ceil(s.length/4);xa(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 xa(r,e,t){r.writeHead(e,{"Content-Type":"application/json"}),r.end(JSON.stringify(t))}var Rn=class{module;minLevel;constructor(e,t="info"){this.module=e,this.minLevel=t}child(e){return new Rn(`${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(Rn.levelOrder[e]<Rn.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)}},xn=Rn;Tt(xn,"levelOrder",{debug:0,info:1,warn:2,error:3});import{realpathSync as Z$,statSync as eI}from"fs";var yt={version:"0.153.1",commit:"b48be8f",startedAt:new Date(Date.now()-process.uptime()*1e3).toISOString()};function tI(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 Sf(){let r=null;try{r=eI(Z$(process.argv[1])).mtimeMs}catch{}let e=Gp().version;return tI(yt,{mtimeMs:r,version:e&&e!=="0.0.0"?e:null})}import{randomUUID as nI}from"crypto";var ir=class{constructor(e=new Wl){this.core=e}count=0;subscribe(e,t){this.count++;let n=this.core.subscribe((i,o)=>{if(!o||!sI.includes(o.kind))return;let a={...o,rootId:i.rootId,node:i.node};iI(e,a)&&t(a)}),s=!0;return()=>{s&&(s=!1,this.count--,n())}}publish(e){let t={id:typeof e.id=="string"?e.id:nI(),at:typeof e.at=="string"?e.at:new Date().toISOString(),...e},{type:n,summary:s,ref:i,agentId:o}=rI(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}},sI=["run","task","signal","mesh","channel","status"];function rI(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 iI(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 $f(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 or,timingSafeEqual as If}from"crypto";var ar=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),d=o||this.detectSource(e.headers);if(process.env.AGENTX_WEBHOOK_DEBUG_HEADERS==="1"){let v={};for(let[w,$]of Object.entries(e.headers))(w.startsWith("x-hubspot")||w.startsWith("x-hub")||w.startsWith("x-github")||w.startsWith("x-gitlab")||w.startsWith("stripe")||w.startsWith("sentry")||w.startsWith("x-vercel")||w.startsWith("x-odoo")||w.startsWith("x-webhook")||w==="user-agent"||w==="content-type"||w==="host"||w==="x-forwarded-host"||w==="x-forwarded-proto"||w==="x-forwarded-for")&&(v[w]=$);this.log(`Webhook [${d}] reqUrl=${e.url} headers: ${JSON.stringify(v)}`)}let l=this.validateSignature(e.headers,a,d,i,e.url);if(l){this.log(`Webhook [${d}] -> ${i}: REJECTED (${l})`),this.sendJson(t,401,{error:l});return}let u=this.buildSummary(d,c,e.headers);this.log(`Webhook [${d}] -> ${i}: ${u.slice(0,100)}`);let g=this.extractEventType(d,c,e.headers),m=this.webhookEntries.find(v=>v.enabled&&v.agentId===i&&v.source===d),p=g&&m?.triggers?.[g]||m?.defaultWorkflow||null;if(await this.fireHookSafe(d,g,i,c),p&&this.workflowDispatcher)try{let v=await this.workflowDispatcher.dispatchWorkflow({workflowId:p,entityRef:{kind:"webhook",id:`${d}:${i}:${g??"\u2014"}:${Date.now()}`},event:{kind:"webhook",source:d,eventType:g,payload:c},trigger:{source:d}});this.log(`Webhook [${d}/${g??"\u2014"}] -> workflow=${p} (claimed=${v.claimed})`),this.sendJson(t,202,{ok:!0,agent:i,source:d,eventType:g,workflow:p,claimed:v.claimed});return}catch(v){this.log(`Workflow dispatch failed [${d}/${g}/${p}]: ${v.message}`)}let y=this.webhookEntries.find(v=>v.enabled&&v.node&&v.agentId===i&&v.source===d);if(y?.node&&this.mesh){this.sendJson(t,202,{ok:!0,agent:i,source:d,node:y.node,status:"accepted"}),this.mesh.sendTask(y.node,u,i,{context:{channel:`webhook:${d}`,sender:`webhook:${d}`}}).then(v=>this.log(`Mesh-forwarded webhook [${d}] -> ${y.node}/${i}: ${v?.slice(0,100)||"ok"}`),v=>this.log(`Mesh forward failed [${d}] -> ${y.node}/${i}: ${v.message}`));return}try{let v=await this.registry.execute({message:u,agentId:i,context:{channel:`webhook:${d}`,sender:`webhook:${d}`}});this.sendJson(t,v.error?500:200,{ok:!v.error,agent:i,source:d,response:v.content?.slice(0,500),error:v.error,duration:v.duration})}catch(v){this.sendJson(t,500,{error:v.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 l of t.commits.slice(0,3))s.push(` - ${l.message?.split(`
|
|
556
556
|
`)[0]||"no message"} (${l.author?.name||""})`)}let d=t.object_attributes;if(d?.title&&(s.push(`Title: ${d.title}`),s.push(`State: ${d.state||""}`),s.push(`Action: ${d.action||""}`),d.source_branch&&s.push(`Branch: ${d.source_branch} -> ${d.target_branch}`),d.url&&s.push(`URL: ${d.url}`)),d?.iid&&!d?.source_branch&&(s.push(`Issue #${d.iid}: ${d.title||""}`),d.description&&s.push(`Description: ${d.description.slice(0,200)}`)),t.object_kind==="pipeline"){let l=t.object_attributes;s.push(`Pipeline: ${l?.status||""} (${l?.ref||""})`),s.push(`Duration: ${l?.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(`
|
|
557
557
|
`)[0]||""} (${u.author?.name||""})`);let d=t.pull_request;d&&(s.push(`PR #${d.number}: ${d.title}`),s.push(`Action: ${t.action}`),s.push(`Branch: ${d.head?.ref} -> ${d.base?.ref}`));let l=t.issue;l&&(s.push(`Issue #${l.number}: ${l.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 d of a.slice(0,3)){let l=d.subscriptionType??"?",u=d.objectId??"?",g=d.changeFlag??d.changeSource??"";s.push(` - ${l} (object ${u}${g?`, ${g}`:""})`)}}else{let d=t.subscriptionType??"event",l=t.objectId??"?";s.push(`Event: ${d} (object ${l})`)}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(`
|
|
558
558
|
`)}async readBody(e){return new Promise(t=>{let n="";e.on("data",s=>n+=s.toString()),e.on("end",()=>{let s;try{s=n?JSON.parse(n):{}}catch{s={raw:n}}t({raw:n,parsed:s})}),e.on("error",()=>t({raw:"",parsed:{}}))})}validateSignature(e,t,n,s,i){let o=this.webhookEntries.find(l=>l.enabled&&l.agentId===s&&l.source===n);if(!o?.secretEnv)return null;let a=process.env[o.secretEnv];if(!a)return`webhook entry "${o.id}" expects env ${o.secretEnv} but it is unset`;let c=l=>{let u=e[l.toLowerCase()];return Array.isArray(u)?u[0]:u};if(n==="github"){let l=c("x-hub-signature-256");if(!l)return"missing X-Hub-Signature-256";let u="sha256="+or("sha256",a).update(t).digest("hex");return Bt(u,l)}if(n==="gitlab"){let l=c("x-gitlab-token");return l?Bt(a,l):"missing X-Gitlab-Token"}if(n==="stripe"){let l=c("stripe-signature");if(!l)return"missing Stripe-Signature";let u=Object.fromEntries(l.split(",").map(m=>m.split("=")));if(!u.t||!u.v1)return"malformed Stripe-Signature";let g=or("sha256",a).update(`${u.t}.${t}`).digest("hex");return Bt(g,u.v1)}if(n==="hubspot"){let l=c("x-hubspot-signature-v3"),u=c("x-hubspot-request-timestamp");if(!l)return"missing X-HubSpot-Signature-v3";if(!u)return"missing X-HubSpot-Request-Timestamp";let g=parseInt(u,10);if(!Number.isFinite(g))return"malformed X-HubSpot-Request-Timestamp";let m=Date.now()-g;if(m>5*6e4)return`HubSpot webhook is ${Math.floor(m/1e3)}s old (>5min replay window)`;let p="POST",y=i||e["x-original-uri"]||e["x-forwarded-path"]||"",v=e["x-forwarded-host"],w=e.host,$=e["x-forwarded-proto"]||"https",b=new Set;v&&y&&b.add(`${$}://${v}${y}`),w&&y&&b.add(`https://${w}${y}`),w&&y&&b.add(`http://${w}${y}`),y&&b.add(y),b.add("");for(let T of b){let _=or("sha256",a).update(`${p}${T}${t}${u}`).digest("base64");if(l.length===_.length&&If(Buffer.from(l),Buffer.from(_)))return null}return`signature mismatch (tried ${b.size} URI variants)`}if(n==="odoo"){let l=c("x-odoo-signature");if(l){let g=or("sha256",a).update(t).digest("hex"),m=l.startsWith("sha256=")?l.slice(7):l;return Bt(g,m)}let u=c("x-odoo-webhook-token")??c("x-webhook-secret");return u?Bt(a,u):"missing X-Odoo-Signature or X-Odoo-Webhook-Token"}let d=c("x-webhook-secret");return d?Bt(a,d):"missing X-Webhook-Secret"}sendJson(e,t,n){e.writeHead(t,{"Content-Type":"application/json"}),e.end(JSON.stringify(n,null,2))}};function Bt(r,e){if(r.length!==e.length)return"signature mismatch";let t=Buffer.from(r),n=Buffer.from(e);return If(t,n)?null:"signature mismatch"}Qd();_d();Vd();function oI(r){return{insertTaskHistory:r.prepare(`
|
|
@@ -1253,4 +1253,4 @@ data: ${JSON.stringify(K)}
|
|
|
1253
1253
|
`)}catch{}},N=setInterval(()=>{try{t.write(`: ping
|
|
1254
1254
|
|
|
1255
1255
|
`)}catch{}},15e3);N.unref?.();let F=new AbortController;t.on("close",()=>{t.writableEnded||F.abort()});try{for await(let j of this.mesh.sendTaskStream(h.peer,h.message,h.agent,{context:h.context,signal:F.signal,vouchOwner:S}))E(j.event,j.data)}catch(j){E("error",{error:j?.message??String(j)})}finally{clearInterval(N);try{t.end()}catch{}}break}let C=h.context,M=typeof h.senderAgentId=="string"?h.senderAgentId:void 0;if(fv(h,!0)==="callback"){let E=this.delegationGate(e,h,{callee:h.agent,peer:h.peer,message:h.message,calleeContext:C});if(!("track"in E)){let N=Ei(E);this.json(t,N.status,N.body);break}}if(h.async===!0){let E=C?.channel,N=C?.chatId;if(!E||!N){this.json(t,400,{error:"async requires context.channel and context.chatId \u2014 there is no route back otherwise"});return}let F=`mesh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;this.json(t,202,{accepted:!0,taskId:F,deliverTo:`${E}:${N}`,note:"result will be delivered to the originating chat when the peer finishes"});let j=h.peer,K=h.agent,ee=this.mesh;(async()=>{let H=Date.now(),W;try{W=await ee.sendTask(j,h.message,K,{vouchOwner:S,context:C,senderAgentId:M}),this.log(`[mesh/task async ${F}] ${j}/${K??"default"} finished in ${Date.now()-H}ms`)}catch(q){W=`Delegation to ${j}/${K??"default"} failed: ${q?.message??q}`,this.log(`[mesh/task async ${F}] failed: ${q?.message??q}`)}try{await this.router.sendOutbound({channel:E,chatId:N,text:W,agentId:C?.agentId??M,accountId:C?.accountId})}catch(q){this.log(`[mesh/task async ${F}] delivery failed: ${q?.message??q}`)}})();break}let D=await this.mesh.sendTask(h.peer,h.message,h.agent,{context:C,senderAgentId:M,vouchOwner:S});this.json(t,200,{response:D});break}case"POST /webrtc/signal/out":{if(!this.webrtc){this.json(t,404,{error:"WebRTC signaling not enabled"});return}let f=await G(e);if(!f.kind||!f.callId||!f.from||!f.to){this.json(t,400,{error:"Missing: kind, callId, from, to"});return}let k=await this.webrtc.handleOutgoing(f);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 f=await G(e);if(!f.kind||!f.callId||!f.from||!f.to){this.json(t,400,{error:"Missing: kind, callId, from, to"});return}let k=this.webrtc.handleIncoming(f);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 h=await G(e),f=h.callId,k=h.target,S=h.agentId||this.config.channels.webrtc?.bot.defaultAgentId;if(!f||!k||!S){this.json(t,400,{error:"Missing: callId, target, agentId (or defaultAgentId in config)"});return}let I=await this.botManager.invite({callId:f,target:k,agentId:S});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 h=this.config.channels.webrtc;if(!h?.enabled){this.json(t,404,{error:"WebRTC signaling not enabled"});return}this.json(t,200,{localName:this.config.node.name,iceServers:[...h.stunServers.map(f=>({urls:f})),...h.turnServers],peers:this.mesh?.directory().map(f=>({name:f.peer,healthy:f.healthy}))||[],camera:h.camera,agents:this.registry.list().map(f=>({id:f.id,name:f.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(h=>{let f=this.config.agents[h.id]||{},k=typeof f.description=="string"&&f.description.trim()||WP(f.systemPrompt)||`Agent "${h.name}" (${h.tier})`,S=Array.isArray(f.mentions)?f.mentions.slice(0,4):[];return{id:h.id,name:h.name,description:k,tags:[h.tier,...S],color:ke(h.id,f).color}}),channels:this.router.getChannelNames(),githubLogins:this.github?.postingAccounts()??[],defaultInputModes:["text"],defaultOutputModes:["text"]});break;case"GET /wiki/agents":{let h=this.registry.getWikiHub();this.json(t,200,{nodeId:this.config.node.id,agents:h.summary()});break}case"GET /wiki/entries":{let h=this.registry.getWikiHub(),f=n.searchParams.get("agent")||void 0,k=n.searchParams.get("after")||void 0,S=f?h.getAgentEntries(f):h.getSharedStore().listEntries({after:k});this.json(t,200,{nodeId:this.config.node.id,count:S.length,entries:S.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 h=this.registry.getWikiHub(),f=n.searchParams.get("agent");if(!f){this.json(t,400,{error:"?agent= required"});break}let S=h.getAgentWiki(f).rebuildIndex();this.json(t,200,{nodeId:this.config.node.id,agentId:f,articles:S.articles});break}case"GET /wiki/article":{let h=this.registry.getWikiHub(),f=n.searchParams.get("agent"),k=n.searchParams.get("path");if(!f||!k){this.json(t,400,{error:"?agent= and ?path= required"});break}let I=h.getAgentWiki(f).readArticle(k);if(!I){this.json(t,404,{error:"Article not found"});break}this.json(t,200,{nodeId:this.config.node.id,agentId:f,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:h}=await import("./notes-WJJEJ4CJ.js"),f=n.searchParams.get("status")||"waiting";if(!["waiting","open","patched","rejected","deferred","expired","all"].includes(f)){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 h(this.registry.getWikiHub().getBaseDir()).list(f==="all"?void 0:f);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:h,validateNote:f}=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 S=await G(e),I=f({...S,to:k.inbox});if("error"in I){this.json(t,400,{error:I.error});break}let x=I.note;if(this.registry.getAgent(k.inbox)){try{let{note:D,added:E}=new h(this.registry.getWikiHub().getBaseDir()).add(x);this.json(t,E?201:200,{ok:!0,added:E,note:D,node:this.config.node.id})}catch(D){this.json(t,507,{error:D?.message??String(D)})}break}if(S.forwarded===!0){this.json(t,404,{error:`inbox agent "${k.inbox}" is not on this node`});break}let C=this.mesh?.findAgentPeer(k.inbox);if(!C){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(D=>D.peer===C.peer)?.peerUrl;if(!C.healthy||!M){this.json(t,503,{error:`the node hosting "${k.inbox}" (${C.peer}) is unreachable; try again later`});break}try{let D=await fetch(`${M.replace(/\/$/,"")}/wiki/notes`,{method:"POST",headers:{"Content-Type":"application/json",...this.mesh.authHeaders(C.peer)},body:JSON.stringify({...x,fromNode:x.fromNode||this.config.node.id,forwarded:!0}),signal:AbortSignal.timeout(1e4)}),E=await D.json().catch(()=>({}));this.json(t,D.status,{...E,peer:C.peer})}catch(D){this.json(t,502,{error:`forward to ${C.peer} failed: ${D?.message??D}`,peer:C.peer})}break}case"GET /graph/schema":{let h=this.registry.getGraphStore();if(!h){this.json(t,404,{error:"graph disabled on this node"});break}this.json(t,200,{nodeId:this.config.node.id,schema:h.loadSchema()});break}case"GET /graph/nodes":{let h=this.registry.getGraphStore();if(!h){this.json(t,404,{error:"graph disabled on this node"});break}this.json(t,200,{nodeId:this.config.node.id,...h.loadNodes()});break}case"GET /graph/classifications":{let h=this.registry.getGraphStore();if(!h){this.json(t,404,{error:"graph disabled on this node"});break}let f=n.searchParams.get("status")||"approved",k=Math.max(1,Math.min(1e3,parseInt(n.searchParams.get("limit")||"200",10)||200)),S=h.listByStatus(f,k);this.json(t,200,{nodeId:this.config.node.id,status:f,count:S.length,classifications:S});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 G(e);await vf(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 d=this.registry.list().find(l=>l.id===i)?.runningTasks.filter(l=>l.channel===o&&l.chatId===a)||[];for(let l of d)this.registry.cancelRunningTask(l.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=Qw(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=Kf();if(e==="json")return this.registry.getTodayUsage();let t=Jf(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||!rn(n)))try{let s=ie(n,".claude","skills");sS(s,{recursive:!0});let i=ie(s,Zw);if(!rn(i))Sd(i,kc(e)),this.log(` memory-skill: installed remember.md \u2192 ${t.id}`);else{let o=tk(on(i,"utf-8"),e);o&&(Sd(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||!rn(n))continue;let s=this.config.workflows.enabled&&(this.config.workflows.followUp.enabled&&(this.config.workflows.followUp.agents[e]??!0)||Nu(this.config.workflows,e)),i=nu(vl(t),this.config.requests.enabled||s?tu():null);try{switch(su(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 Pw(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 se(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 g=typeof n?.fromPeer=="string"?n.fromPeer:"unknown";this.log(`[workflows/mesh] received trigger from "${g}" source="${s.trigger.source}" chat="${s.trigger.chat??"*"}"`);let m=await this.workflowDispatcher.dispatch({trigger:s.trigger,entityRef:o,event:i,fromRemote:{peer:g}});this.log(`[workflows/mesh] dispatched broadcast: matched=${m.claimed.length} ${m.claimed.length?`(${m.claimed.map(p=>p.id).join(", ")})`:"[none \u2014 no workflow with mesh.allowRemote matched]"}`),this.json(t,202,{ok:!0,mode:"trigger-broadcast",matched:m.claimed.map(p=>p.id)});return}let l=(s.workflowId?this.workflowStore?.get(s.workflowId):null)?.nodes.find(g=>g.type.startsWith("trigger."))?.config??{},u={source:String(l.source??"hook"),project:l.filter?.project,repo:l.filter?.repo,chat:l.filter?.chat,labels:l.filter?.labels};await this.workflowDispatcher.dispatch({trigger: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 se(e)}catch(c){this.json(t,400,{error:"invalid JSON body",message:c.message});return}let{handlePushBridge:s,pushOrigin:i}=await import("./push-bridge-P7HH25VN.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 xh(String(e.headers.authorization||""),this.config.mesh.peers,process.env.MESH_TOKEN)}async handleChannelSend(e,t){let n;try{n=await se(e)}catch(d){this.json(t,400,{error:"invalid JSON body",message:d.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 d=this.pushBridgeCaller(e);if("origin"in d)c=d.origin;else if(i!=="default"){this.json(t,403,{error:d.error});return}}if(s==="push"&&i.includes(":")){let{scopedPushTarget:d}=await import("./push-bridge-P7HH25VN.js"),l=d(i,this.pushBridgeCaller(e));if("error"in l){this.json(t,403,{error:l.error});return}}try{let d=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,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:d??null})}catch(d){this.log(`[mesh] /channel/send "${s}" failed: ${d.message}`),this.json(t,500,{error:d.message})}}async handleChannelChats(e,t,n={}){let s=new Set,i=[],o=[],a=(d,l)=>{let u=0;for(let g of d)!g.id||s.has(g.id)||(s.add(g.id),i.push({...g,source:l}),u++);u>0&&o.push(`${l}:${u}`)},c=this.router.getChannel(t);if(c?.listKnownChats)try{a(c.listKnownChats(),"local")}catch{}else if(c?.listChats)try{a(c.listChats().map(d=>({id:d.jid,name:d.name,kind:d.isGroup?"group":"dm"})),"local")}catch{}if(!n.localOnly&&this.mesh){let d=this.mesh.directory().filter(l=>l.healthy&&l.channels?.includes(t));await Promise.allSettled(d.map(async l=>{try{let u=await fetch(`${l.peerUrl}/channels/${encodeURIComponent(t)}/chats?local=1`,{headers:this.mesh.authHeaders(l.peer),signal:AbortSignal.timeout(5e3)});if(!u.ok)return;let g=await u.json();Array.isArray(g.chats)&&a(g.chats.map(m=>({id:m.id,name:m.name,kind:m.kind??"dm",accountId:m.accountId})),`mesh:${l.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 se(e)}catch{s={}}try{let i=await Yw({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})}}},$d=Id;Tt($d,"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 WP(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 se(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 UP(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 G(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)})}iS();function Tq(r){typeof r=="string"&&(es.error(r),process.exit(1)),r instanceof Error&&(es.error(r.message),process.exit(1)),es.error("Something went wrong. Please try again."),process.exit(1)}export{i_ as a,ta as b,ut as c,wn as d,vn as e,pt as f,Gs as g,Gp as h,Lf as i,mI as j,yI as k,Gf as l,Te as m,qf as n,Xf as o,Fa as p,ZD as q,eN as r,Ha as s,yT as t,wT as u,Ga as v,wm as w,jN as x,Rm as y,bT as z,Am as A,Em as B,Cm as C,FN as D,WN as E,UN as F,Le as G,FL as H,Ex as I,dR as J,hc as K,l1 as L,u1 as M,h1 as N,Ww as O,UR as P,y1 as Q,w1 as R,Dn as S,Qt as T,Nn as U,B1 as V,wk as W,_A as X,NF as Y,ti as Z,_c as _,Mc as $,oi as aa,ke as ba,db as ca,li as da,EE as ea,Sb as fa,PE as ga,xb as ha,gi as ia,Bn as ja,yi as ka,ki as la,_b as ma,Vc as na,jb as oa,et as pa,Ee as qa,Hb as ra,Bb as sa,qb as ta,Xb as ua,ji as va,Ov as wa,fd as xa,Nv as ya,iP as za,tG as Aa,$d as Ba,Tq as Ca};
|
|
1256
|
-
//# sourceMappingURL=chunk-
|
|
1256
|
+
//# sourceMappingURL=chunk-XQ2VU6MM.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as N}from"./chunk-IMLAPB7G.js";import{k as y}from"./chunk-
|
|
1
|
+
import{a as N}from"./chunk-IMLAPB7G.js";import{k as y}from"./chunk-LQS27HSV.js";import{b as V}from"./chunk-KP7KDLZ2.js";import{I as B,J,K as X,L as K,P as k,T as Pe}from"./chunk-5VPU5FHB.js";import{existsSync as z,readFileSync as $e}from"node:fs";import{dirname as b,join as h}from"node:path";import{fileURLToPath as Oe}from"node:url";import{homedir as Ee}from"node:os";var M="tn.acme.agentx.voice",dt="AgentX Desktop.app",Y="AgentX Helper.app";function mt(e,t,n){return e!=="darwin"||t!=="arm64"||Number(n.split(".")[0])<23?"AgentX Desktop currently requires Apple Silicon and macOS 14 or newer.":null}function ft(e,t){if(t&&!Object.hasOwn(e,t))throw new Error(`Unknown agent: ${t}. Run agentx agent list.`);let n=t||Object.keys(e)[0];if(!n)throw new Error("No agents configured. Run agentx setup first.");return n}function I(e){return`'${e.replace(/'/g,"'\\''")}'`}var Z="/usr/bin:/bin:/usr/sbin:/sbin";function gt(e,t){return t||[...new Set([...e?[b(e)]:[],...Z.split(":")])].join(":")}function A(e){let t={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};return e.replace(/&(amp|lt|gt|quot|apos);/g,(n,r)=>t[r])}function yt(e){let t=e.match(/<key>PATH<\/key>\s*<string>([^<]*)<\/string>/);return t?A(t[1]):Z}var ht=e=>/agentx\.voice.*\.plist$/.test(e);function wt(e,t){let n=null,r=[];for(let{file:o,plist:i}of[...t].sort((s,u)=>s.file<u.file?-1:1)){let s=i.match(/<key>Label<\/key>\s*<string>([^<]*)<\/string>/)?.[1],u=i.match(/<key>ProgramArguments<\/key>\s*<array>\s*<string>([^<]*)<\/string>/)?.[1];!s||!u||!A(u).endsWith("/Contents/MacOS/AgentXVoice")||(n?r.push({file:o,label:A(s)}):n={file:o,label:A(s)})}return{keep:n??{file:h(e,`${M}.plist`),label:M},remove:r}}function Q(e,t,n){for(let r of t.split(":"))if(r&&n(h(r,e)))return h(r,e);return null}function St(e){let t=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),n={PATH:e.path,...e.agent?{AGENTX_VOICE_AGENT:e.agent}:{},AGENTX_DAEMON_URL:e.url,AGENTX_MAC_HELPER:e.helper,AGENTX_PASTE_COMMAND:`cd ${I(e.cwd)} && ${I(e.node)} ${I(e.cli)} paste`};return`<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
3
|
<plist version="1.0"><dict>
|
|
4
4
|
<key>Label</key><string>${t(e.label??M)}</string>
|
|
@@ -33,4 +33,4 @@ function run(argv) {
|
|
|
33
33
|
`),tt(r,n)}var ot=5*6e4;function An(e,t,n=Date.now()){let r=Ne(e),o=r.checkedAt?Date.parse(r.checkedAt):NaN;return!r.cards||!(n-o<=ot)?!1:r.items[`card:${t}`]?.state!=="failed"}var U=24*36e5;function be(e,t,n){let r=e+t.dueAfterMinutes*6e4;return new Date(n!==void 0&&Number.isFinite(n)?Math.max(e,Math.min(r,n)):r)}function st(e,t,n,r){let o=Date.parse(e.expires),i=[f(e.ask,y.ask)];return e.choices?.length&&i.push(...e.choices.map((s,u)=>`${u+1}. ${s}`)),e.recommend&&i.push(`Recommended: ${f(e.recommend,y.recommend)}`),i.push(`Answer: ${n}`,`agentx: card=${e.id}`),{key:`card:${e.id}`,title:f(e.title,y.title),notes:i.join(`
|
|
34
34
|
`),due:be(r,t,o),priority:Number.isFinite(o)&&o-r<=U?"high":"none"}}function at(e,t,n,r){let o=[f(e.question||e.text,y.ask),`Asked of ${e.agentId}.`,`Answer: ${n}`,`agentx: request=${e.id}`],i=e.dueAt??void 0;return{key:`request:${e.id}`,title:W(e,y.title).headline,notes:o.join(`
|
|
35
35
|
`),due:be(r,t,i),priority:i!==void 0&&i-r<=U?"high":"none"}}async function Rn(e){let{root:t,settings:n,tasks:r,log:o}=e,i=e.now??Date.now(),s=new Date(i).toISOString(),u={created:0,completed:0,dismissed:0,failed:0},l=Ne(t);delete l.lastError;let p=a=>{l.lastError={at:s,message:a}},w=new Map;try{if(n.include.includes("card"))for(let a of e.cards())a.status==="pending"&&Date.parse(a.expires)>i&&w.set(`card:${a.id}`,st(a,n,e.answerUrl,i));if(n.include.includes("request"))for(let a of e.requests())a.state==="waiting_owner"&&w.set(`request:${a.id}`,at(a,n,e.answerUrl,i))}catch(a){return o(`[mirror] could not read what is waiting: ${a?.message??a}`),p(String(a?.message??a)),ve(t,l),u}let G=!0,x=new Map,Ae=async a=>{if(!x.has(a))try{x.set(a,new Set((await r.listOpen(a)).map(c=>c.id)))}catch(c){o(`[mirror] could not read list "${a}": ${c?.message??c}`),p(String(c?.message??c)),x.set(a,null),G=!1}return x.get(a)};for(let[a,c]of Object.entries(l.items)){if(c.state!=="open"||!c.id)continue;let d=await Ae(c.list);if(d)if(w.has(a))d.has(c.id)||(l.items[a]={...c,state:"dismissed",at:s},u.dismissed++,o(`[mirror] ${a}: its task was ticked off or deleted; it stays on the Desk and is not mirrored again`));else{if(d.has(c.id))try{await r.complete(c.id)}catch(g){o(`[mirror] ${a}: could not complete its task: ${g?.message??g}`),p(String(g?.message??g));continue}l.items[a]={...c,state:"completed",at:s},u.completed++}}let C=null,S=[];for(let[a,c]of w){let d=l.items[a];if(d&&(d.state==="open"||d.state==="dismissed")||d?.state==="failed"&&d.failures>=j)continue;if(C===null)try{await r.ensureList(n.list),C=!0}catch(m){o(`[mirror] could not make list "${n.list}": ${m?.message??m}`),p(String(m?.message??m)),C=!1}let g=d?.state==="failed"?d.failures:0;try{let{id:m}=await r.add({list:n.list,title:c.title,notes:c.notes,due:c.due,priority:c.priority});l.items[a]={id:m,list:n.list,state:"open",at:s,failures:0},u.created++}catch(m){let v=String(m?.message??m),T=g+1;l.items[a]={list:n.list,state:"failed",at:s,failures:T,lastError:v},p(v),u.failed++,o(`[mirror] ${a}: could not add to Reminders (${T}/${j}): ${v}`),T===j&&S.push({title:c.title,message:v})}}let Re=l.failureToldAt?Date.parse(l.failureToldAt):NaN;if(S.length&&!(i-Re<U)){let a=S[0],c=S.length>1?` (and ${S.length-1} more)`:"";try{await e.notify("Could not add to Reminders",`${a.title}${c}: ${f(a.message,200)}. Still on the Desk.`),l.failureToldAt=s}catch(d){o(`[mirror] could not tell the owner: ${d?.message??d}`)}}G&&(l.checkedAt=s,l.cards=n.include.includes("card"));for(let[a,c]of Object.entries(l.items))c.state!=="open"&&!w.has(a)&&i-Date.parse(c.at)>it&&delete l.items[a];return ve(t,l),u}export{ln as a,ge as b,F as c,cn as d,pn as e,ze as f,dn as g,mn as h,fn as i,W as j,Sn as k,dt as l,Y as m,mt as n,ft as o,gt as p,yt as q,ht as r,wt as s,Q as t,St as u,xt as v,Ce as w,Te as x,Ie as y,_ as z,ie as A,q as B,fe as C,tn as D,nn as E,rn as F,Ne as G,An as H,Rn as I};
|
|
36
|
-
//# sourceMappingURL=chunk-
|
|
36
|
+
//# sourceMappingURL=chunk-ZAH74SFX.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-2YK3YCBX.js"),{installCliSignalExit:r}=await import("./signal-exit-WL7G3EEZ.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
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=doctor-
|
|
1
|
+
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i}from"./chunk-DZRD6BE4.js";import"./chunk-ZAH74SFX.js";import"./chunk-IMLAPB7G.js";import"./chunk-LQS27HSV.js";import"./chunk-MNG2AMKZ.js";import"./chunk-KP7KDLZ2.js";import"./chunk-OSH2PEBH.js";import"./chunk-5VPU5FHB.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";export{i as daemonVoiceCheck,b as doctor,g as meshPeerTokenChecks,h as meshTokenChecksFromConfig,a as runDoctorChecks,e as runMirrorChecks,d as runNativeChecks,c as runNotificationChecks,f as runReminderChecks};
|
|
2
|
+
//# sourceMappingURL=doctor-QWVUVWTF.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=grants-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u}from"./chunk-BNOGNRAM.js";import"./chunk-LQS27HSV.js";import"./chunk-MNG2AMKZ.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";export{c as DEFAULT_GRANT_DAYS,a as GUEST_SCOPE_PREFIX,b as JOIN_CARD_BY,h as JOIN_FAILED,d as MAX_GRANT_DAYS,j as NO_GRANT,l as PAUSED,k as WAITING_HOST,s as endGrant,o as grantBrief,u as grantForGuest,e as grantIdOf,n as guestAccess,p as guestTask,g as inviteGuest,i as joinGuest,f as newGrantId,q as pauseGrant,r as resumeGrant,m as settleGrant,t as updateGrant};
|
|
2
|
+
//# sourceMappingURL=grants-YGA654NI.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Ba as Tt,Ca 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{Ba as Tt,Ca 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-XQ2VU6MM.js";import"./chunk-VAK4LT62.js";import"./chunk-GTJIKXDB.js";import"./chunk-GDLO7FC7.js";import"./chunk-ZAH74SFX.js";import"./chunk-7LN4VKDU.js";import"./chunk-IMLAPB7G.js";import"./chunk-ZVP6GB4G.js";import"./chunk-LQE73AZR.js";import"./chunk-2D3RYIDU.js";import"./chunk-MRIVENBY.js";import"./chunk-BNOGNRAM.js";import"./chunk-LQS27HSV.js";import"./chunk-PPUN7YHA.js";import"./chunk-VZLIBDLH.js";import"./chunk-EKJG63EJ.js";import"./chunk-3LU2ZQZJ.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-EMGB23H5.js";import"./chunk-JAML6222.js";import"./chunk-YMX3QCV7.js";import"./chunk-JWDJMFU6.js";import"./chunk-5HLD66CW.js";import"./chunk-IS2IWRP7.js";import"./chunk-MNG2AMKZ.js";import"./chunk-X7UQY7CH.js";import"./chunk-ZQONMM3B.js";import"./chunk-PYHR4HXO.js";import"./chunk-KP7KDLZ2.js";import"./chunk-A5GYG56I.js";import{m as lt,n as ct,o as dt,p as mt,q as pt,ra as yt}from"./chunk-5DPN2HIR.js";import"./chunk-S5FRIHWM.js";import"./chunk-MEFPXHQJ.js";import{a as L}from"./chunk-IVBCCSDR.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-MWYPW5XP.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-6TTGRTDO.js";import"./chunk-SZDACK6O.js";import"./chunk-VE3SSOQX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-5TTHN7DP.js";import{s as ut}from"./chunk-LH3GOBZP.js";import"./chunk-BFONYVOM.js";import"./chunk-3UOTLMXD.js";import"./chunk-36AXN6ZB.js";import"./chunk-PE5V2LI7.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-VWTBHLMX.js";import"./chunk-RUQMUDSX.js";import{a as ht}from"./chunk-JPZBWHNZ.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-DPSHY7GN.js";import"./chunk-SKSYII3K.js";import{f as gt,g as ft}from"./chunk-RJCHFDF3.js";import"./chunk-WPNRDEHW.js";import"./chunk-MWNCS57L.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-Z2KGUEB6.js";import{j as it,k as rt,l as at}from"./chunk-HVNWI63Z.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-MYVHVJWZ.js";import"./chunk-6TURWSMN.js";import"./chunk-AV7T3SYT.js";import"./chunk-U23LVMMZ.js";import"./chunk-QD6IICK7.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-JNG3P5V2.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{Ja as tt,La as st,Na as ot,Ua as nt}from"./chunk-5VPU5FHB.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.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).
|