agentix-cli 0.186.0 → 0.187.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-56FXNO7Q.js → board-dashboard-IUIXTKCG.js} +519 -545
- package/dist/board-dashboard-IUIXTKCG.js.map +1 -0
- package/dist/{chunk-6PENXBLH.js → chunk-SVZZUZ3K.js} +3 -3
- package/dist/{chunk-TAZIS2VP.js → chunk-XCDN62CQ.js} +2 -2
- package/dist/{chunk-BXTSO66H.js → chunk-ZFMNH47D.js} +2 -2
- package/dist/{chunk-BXTSO66H.js.map → chunk-ZFMNH47D.js.map} +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{program-KAJ47AIG.js → program-K7IWAPAJ.js} +4 -4
- package/package.json +1 -1
- package/dist/board-dashboard-56FXNO7Q.js.map +0 -1
- /package/dist/{chunk-6PENXBLH.js.map → chunk-SVZZUZ3K.js.map} +0 -0
- /package/dist/{chunk-TAZIS2VP.js.map → chunk-XCDN62CQ.js.map} +0 -0
- /package/dist/{program-KAJ47AIG.js.map → program-K7IWAPAJ.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$a as ve,A as Vp,Ab as gm,B as Jp,Ba as Wa,Bb as pm,C as Xt,Ca as Ff,Cb as fm,D as Js,E as Kp,Eb as mm,F as zp,Fa as Wf,G as Yp,Ga as Jf,H as nf,I as sf,J as rf,Jb as ym,K as of,Kb as wm,L as af,M as cf,N as lf,Na as Ga,O as df,Oa as kt,P as uf,Pa as Kf,Q as hf,Qa as zf,R as Da,Ta as vt,Tb as qa,U as gf,Ua as Yf,Ub as Xa,Va as Qf,W as pf,Wa as Zf,Wb as bm,Xa as em,Ya as tm,Za as nm,a as $p,ab as Zs,b as xa,ba as Ys,bb as Ha,ca as Rf,cb as sm,db as Dn,ea as Ef,eb as rm,f as Aa,fa as La,fb as De,g as Ip,gb as im,h as Tp,hb as om,i as Ra,ia as Cf,ib as am,j as xp,jb as er,k as On,kb as tr,l as Ap,la as Pf,lb as cm,m as Rp,mb as lm,n as Ep,o as Ze,oa as _f,p as Cp,pa as Mf,q as Pp,qa as Of,ra as ja,rb as dm,s as _p,sa as Df,u as Mp,ua as Nf,v as et,va as Fa,vb as um,w as Ca,wa as Lf,x as Bp,xa as Oe,xb as nr,y as qp,ya as jf,yb as Ba,z as Xp,za as Qs,zb as hm}from"./chunk-
|
|
1
|
+
import{$a as ve,A as Vp,Ab as gm,B as Jp,Ba as Wa,Bb as pm,C as Xt,Ca as Ff,Cb as fm,D as Js,E as Kp,Eb as mm,F as zp,Fa as Wf,G as Yp,Ga as Jf,H as nf,I as sf,J as rf,Jb as ym,K as of,Kb as wm,L as af,M as cf,N as lf,Na as Ga,O as df,Oa as kt,P as uf,Pa as Kf,Q as hf,Qa as zf,R as Da,Ta as vt,Tb as qa,U as gf,Ua as Yf,Ub as Xa,Va as Qf,W as pf,Wa as Zf,Wb as bm,Xa as em,Ya as tm,Za as nm,a as $p,ab as Zs,b as xa,ba as Ys,bb as Ha,ca as Rf,cb as sm,db as Dn,ea as Ef,eb as rm,f as Aa,fa as La,fb as De,g as Ip,gb as im,h as Tp,hb as om,i as Ra,ia as Cf,ib as am,j as xp,jb as er,k as On,kb as tr,l as Ap,la as Pf,lb as cm,m as Rp,mb as lm,n as Ep,o as Ze,oa as _f,p as Cp,pa as Mf,q as Pp,qa as Of,ra as ja,rb as dm,s as _p,sa as Df,u as Mp,ua as Nf,v as et,va as Fa,vb as um,w as Ca,wa as Lf,x as Bp,xa as Oe,xb as nr,y as qp,ya as jf,yb as Ba,z as Xp,za as Qs,zb as hm}from"./chunk-ZFMNH47D.js";import{d as kp,g as vp,h as Sp}from"./chunk-NBWSZ53L.js";import{a as Op}from"./chunk-ZVP6GB4G.js";import{A as jp,B as Fp,D as qs,E as Pa,F as Xs,G as qt,K as ff,c as ep,d as tp,f as np,g as Mn,h as Bs,i as $a,j as sp,k as ze,z as Lp}from"./chunk-ZRC2ZHHE.js";import{a as xf,b as Af}from"./chunk-VZLIBDLH.js";import{b as Uf,c as Gf,d as Ua,e as Hf,f as Bf,g as qf,h as Xf,i as Vf}from"./chunk-EKJG63EJ.js";import{d as Wp}from"./chunk-6V5JBHUN.js";import{g as Up}from"./chunk-LQE73AZR.js";import{b as Gp,c as Hp}from"./chunk-2D3RYIDU.js";import{b as mf}from"./chunk-MRIVENBY.js";import{i as yf,m as Na,n as wf,p as bf,q as kf,r as vf,s as Sf,t as $f,u as If}from"./chunk-BIYEGA7Q.js";import{h as _a,n as Ma,o as Qp,p as Ks,q as bt,r as Vt,s as Me,u as Zp,v as ef,w as tf,x as Oa,y as zs}from"./chunk-XPZSEDE3.js";import{a as Tf}from"./chunk-PPUN7YHA.js";import{a as Dp,b as Np}from"./chunk-A5GYG56I.js";import{o as Ea}from"./chunk-2V6ZGE74.js";import{b as Vs}from"./chunk-UKUH662W.js";import{a as Qe}from"./chunk-MNG2AMKZ.js";import{c as dp,d as up,f as hp,g as gp,i as pp,k as fp,l as mp}from"./chunk-RX5O5637.js";import{d as yp}from"./chunk-5ELIX7BQ.js";import{b as wp,c as bp}from"./chunk-X7UQY7CH.js";import{a as Ia,b as rp,c as ip}from"./chunk-QPABR72X.js";import{a as op,b as Ye,c as ap,d as cp,e as lp}from"./chunk-AJ5HMDRW.js";import{c as Bt}from"./chunk-KP7KDLZ2.js";import{$ as va,A as B,C as Mh,D as Oh,E as Dh,F as Nh,G as ge,H as jh,I as Fh,J as Wh,K as Uh,L as zh,M as Yh,N as Qh,O as Fg,P as Wg,Q as Ug,R as Gg,S as Hg,T as Bg,V as _n,W as qg,Z as ie,_ as Ke,a as sh,aa as Ut,b as ca,ba as Sa,c as ih,ca as Gs,d as gh,da as Gt,e as ph,ea as Ht,f as Rn,fa as me,ga as wt,h as da,ha as oe,i as ua,ia as Xg,j as ha,ja as Vg,k as ga,l as fh,ma as zg,s as yh,t as vh,u as mt,v as Sh,w as $h,x as Ih,y as Wt,ya as Yg,z as Ah}from"./chunk-UASRZKZQ.js";import{$ as Ag,Da as Kg,G as Jh,H as Kh,N as Zh,P as eg,R as fg,S as mg,T as Sg,U as $g,V as Ig,W as Tg,Y as ka,Z as Us,_ as xg,a as wh,aa as Rg,ba as Eg,c as Th,ca as Cg,d as xh,da as Pg,e as yt,ea as _g,f as _e,fa as Mg,h as Gh,ha as Og,i as Hh,j as Bh,k as fa,ka as Dg,l as qh,m as Xh,p as Vh,pa as Ng,q as js,qa as Lg,ta as jg,xa as Jg}from"./chunk-2GIYVYIM.js";import{a as pa,b as kh}from"./chunk-MEFPXHQJ.js";import{A as Qg,B as Hs,C as Zg,h as qd,n as Xd,o as Fo}from"./chunk-2LTZUZJU.js";import{b as Gd}from"./chunk-SFQUP3BP.js";import{a as Ta}from"./chunk-6TTGRTDO.js";import{a as tg,b as ma,c as ng,d as sg,e as rg,i as ig,j as og}from"./chunk-VE3SSOQX.js";import{b as Lh}from"./chunk-W4YR2RO2.js";import{b as cg,c as lg,d as ya,f as Fs,g as dg,h as ug,i as hg,j as Pn,k as Ws,m as wa,n as gg,o as pg}from"./chunk-VJVXEVZ7.js";import{b as he,d as qe,f as Xe,g as En,i as fe,j as ag,k as Ve,l as Je,m as bg,p as kg,r as vg,t as ba}from"./chunk-RTIGD4NG.js";import{a as yg,b as wg}from"./chunk-NS2HSAHF.js";import{b as bh}from"./chunk-PE5V2LI7.js";import{d as Rh,e as Eh,f as Ch,g as Ph,h as _h,j as Cn}from"./chunk-X5C5W3E4.js";import{c as Ls}from"./chunk-OWNQ2FD4.js";import{c as mh}from"./chunk-LUOW2YHY.js";import{d as Jd,e as dT,m as Zu,n as IT,q as eh,v as th,x as aa,y as Be,z as An}from"./chunk-LR4QUAJT.js";import{a as Pe,b as xn,f as Ds}from"./chunk-72SZI2UW.js";import{a as $n,b as Vd}from"./chunk-FCPTN6NF.js";import{c as nh}from"./chunk-MYVHVJWZ.js";import{f as rh}from"./chunk-QUFIUXMQ.js";import{d as oh,e as ah,f as la,g as Ns,h as ch,i as lh,j as dh,k as uh,q as hh}from"./chunk-AV7T3SYT.js";import{o as jo,p as lT}from"./chunk-DCIYOPJF.js";import{a as xs,b as cT}from"./chunk-7I7IEX4S.js";import{b as Hd,e as Bd}from"./chunk-JHCI6XCJ.js";import{e as ut}from"./chunk-DSYKYZMT.js";import{$ as pt,A as pT,Aa as sa,B as Cs,Ba as ra,C as tu,D as fT,Da as Os,E as nu,Ea as Wu,F as su,G as ru,Ga as Uu,Gb as $T,Ha as Gu,Ia as Hu,J as Vo,Ja as Tn,K as cu,Ka as Bu,L as lu,La as qu,M as In,Ma as Xu,N as Ps,Na as Vu,O as du,Oa as Ju,P as uu,Pa as kT,Q as Su,R as yT,S as $u,Sa as Ku,U as Yo,V as Iu,Va as zu,W as Tu,Wa as Yu,X as wT,Y as xu,Z as bT,_a as vT,aa as Au,ab as ia,ca as Qo,cb as ST,d as Wo,da as Zo,e as Uo,ea as He,f as Kd,fa as Ft,g as zd,ga as Ru,h as Yd,ia as ea,j as uT,ja as ta,ka as Eu,la as Cu,n as jt,na as Pu,o as Zd,oa as _u,p as Ho,pa as ft,q as hT,qa as na,r as As,ra as Mu,s as Bo,sa as Ou,t as Rs,ta as _s,ua as Du,v as ht,va as Ms,w as qo,wa as Nu,x as eu,xa as Lu,xb as oa,y as gT,ya as ju,z as Es,za as Fu,zb as Qu}from"./chunk-BZJF7DJR.js";import{a as iu,e as gt,f as ou,g as au,h as Xo}from"./chunk-VJ5HC63R.js";import{a as hu,b as gu,c as pu,e as fu,f as mu,i as mT,j as Jo,k as yu,l as wu,m as Ko,n as bu,o as ku,q as zo,r as vu}from"./chunk-UEEB3UTU.js";import{b as Go,e as Qd}from"./chunk-VQRY4IDI.js";import{d as Lt}from"./chunk-QIJLFPWE.js";import{existsSync as Za,readFileSync as ec}from"fs";ru();var km=["answer","narration","line"],vm=5e3;function Sm(r){return r==="/voice/queue"||r.startsWith("/voice/queue/")}async function $m(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||!km.includes(u))return{status:400,body:{error:`Required: text and agentId; kind is ${km.join(" | ")}`}};if(l.length>vm)return{status:413,body:{error:`text is over ${vm} characters`}};let h=e(d);if(!h)return{status:404,body:{error:`Unknown agent: ${d}`}};let{item:f,done:y}=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:f}}:{status:200,body:{item:f,played:await y}}}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()}:Va(o);case"front":return r.front(o)?{status:200,body:r.view()}:Va(o);case"replay":{let l=r.replay(o);return l?{status:202,body:{item:l}}:Va(o)}default:return{status:404,body:{error:"Not found"}}}}function Im(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?[su(r.floor)]:[],t,...r.waiting.map((n,s)=>`${s+1}. waiting: ${e(n)}`)].join(`
|
|
2
2
|
`)}var Va=r=>({status:404,body:{error:`No such line in the queue: ${r}`}});var TT=20,Ja=120,xT=80,AT=new Set(["waiting_owner","needs_attention"]);function Ka(r,e){let t=String(r??"").replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function sr(r){return{total:r.length,items:r.slice(0,TT)}}var za=r=>new Date(r).toISOString();function Tm(r){return{id:r.id,agentId:r.agentId,kind:r.kind,text:Ka(r.text,xT),enqueuedAt:za(r.enqueuedAt)}}function xm(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:Ka(i.title,Ja),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:Ka(i.title,Ja),from:i.from,at:i.at,heldBecause:i.heldBecause})),n=(r.requests??[]).filter(i=>AT.has(i.state)).sort((i,o)=>i.createdAt-o.createdAt).map(i=>({id:i.id,title:ze(i,Ja).headline,agentId:i.agentId,state:i.state,since:za(i.stateChangedAt??i.updatedAt)})),s=r.voice;return{ts:za(r.now),cards:sr(e),held:sr(t),voice:s?{paused:s.paused,reserved:s.reserved,playing:s.playing?Tm(s.playing):null,waiting:sr(s.waiting.map(Tm))}:null,requests:sr(n),errors:r.errors??[]}}function Am(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 tc}from"path";ST();var RT={name:"agentx",version:"0.1.0"},ET=["2024-11-05","2025-03-26","2025-06-18","2025-11-25"],CT="2024-11-05";function PT(r){return typeof r=="string"&&ET.includes(r)?r:CT}var _T={tools:{},elicitation:{form:{}}},MT=0;async function Rm(r,e){let t=++MT;return St({jsonrpc:"2.0",id:`elicit-${t}`,method:"elicitation/create",params:{mode:"form",message:r,requestedSchema:e}}),new Promise(n=>{Ln.set(`elicit-${t}`,s=>{s?.action==="accept"&&s.content?n(s.content):n(null)}),setTimeout(()=>{Ln.has(`elicit-${t}`)&&(Ln.delete(`elicit-${t}`),n(null))},6e4)})}var Ln=new Map,OT="http://localhost:18800",Ya;function DT(){if(process.env.AGENTX_DAEMON_URL)return process.env.AGENTX_DAEMON_URL;for(let r of["agentx.json",".agentx/config.json"])try{let e=tc(process.cwd(),r);if(!Za(e))continue;let t=JSON.parse(ec(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 OT}function X(){return Ya===void 0&&(Ya=DT()),Ya}var Qa;function NT(r){try{let e=tc(process.cwd(),".env");if(!Za(e))return"";for(let t of ec(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 LT(r=process.env){if(r.AGENTX_TOKEN)return r.AGENTX_TOKEN;if(r.MESH_TOKEN)return r.MESH_TOKEN;let e=NT("MESH_TOKEN");if(e)return e;for(let t of["agentx.json",".agentx/config.json"])try{let n=tc(process.cwd(),t);if(!Za(n))continue;let s=JSON.parse(ec(n,"utf-8"))?.dashboard?.token;if(typeof s=="string"&&s)return s}catch{}return""}function jT(){return Qa===void 0&&(Qa=LT()),Qa}var V=(r,e)=>{let t=jT();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 Nn(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 FT(){let r=process.env.AGENTX_AGENT_ID,e=Nn();if(!(!r||!e.callerChannel||!e.callerChatId))try{let t=new URLSearchParams({channel:e.callerChannel,chatId:e.callerChatId}),n=await V(`${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}}var WT=1e4,UT=new Set(["ECONNREFUSED","ENOTFOUND","EAI_AGAIN","EHOSTUNREACH","ENETUNREACH"]);function GT(r,e){let t=e,n=t?.cause?.code??t?.code;if(n&&UT.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 HT=/\x1B\[[0-9;]*[A-Za-z]/g;function Jt(r){return r.replace(HT,"")}async function BT(r,e,t){let n=await V(`${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:qT(i,!!s.hasMore)}]}}function qT(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}:
|
|
@@ -531,7 +531,7 @@ ${l}`)}let S={agentId:o,message:w,context:{channel:g,sender:y?"opencode":"openai
|
|
|
531
531
|
|
|
532
532
|
`)}}function Hy(r){r.writeHead(200,{"Content-Type":"text/event-stream; charset=utf-8","Cache-Control":"no-cache",Connection:"keep-alive","X-Accel-Buffering":"no"})}function By(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}]})}
|
|
533
533
|
|
|
534
|
-
`)}function qy(r,e,t,n,s,i){let o=i?.usage?.inputTokens??0,a=i?.usage?.outputTokens??Math.ceil(s.length/4);xc(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 xc(r,e,t){r.writeHead(e,{"Content-Type":"application/json"}),r.end(JSON.stringify(t))}var Jn=class{module;minLevel;constructor(e,t="info"){this.module=e,this.minLevel=t}child(e){return new Jn(`${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(Jn.levelOrder[e]<Jn.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)}},Vn=Jn;Lt(Vn,"levelOrder",{debug:0,info:1,warn:2,error:3});import{realpathSync as QA,statSync as ZA}from"fs";var tt={version:"0.
|
|
534
|
+
`)}function qy(r,e,t,n,s,i){let o=i?.usage?.inputTokens??0,a=i?.usage?.outputTokens??Math.ceil(s.length/4);xc(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 xc(r,e,t){r.writeHead(e,{"Content-Type":"application/json"}),r.end(JSON.stringify(t))}var Jn=class{module;minLevel;constructor(e,t="info"){this.module=e,this.minLevel=t}child(e){return new Jn(`${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(Jn.levelOrder[e]<Jn.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)}},Vn=Jn;Lt(Vn,"levelOrder",{debug:0,info:1,warn:2,error:3});import{realpathSync as QA,statSync as ZA}from"fs";var tt={version:"0.187.0",commit:"bf7d569",startedAt:new Date(Date.now()-process.uptime()*1e3).toISOString()};function eR(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 Vy(){let r=null;try{r=ZA(QA(process.argv[1])).mtimeMs}catch{}let e=fy().version;return eR(tt,{mtimeMs:r,version:e&&e!=="0.0.0"?e:null})}import{randomUUID as tR}from"crypto";var Pr=class{constructor(e=new Ah){this.core=e}count=0;subscribe(e,t){this.count++;let n=this.core.subscribe((i,o)=>{if(!o||!nR.includes(o.kind))return;let a={...o,rootId:i.rootId,node:i.node};rR(e,a)&&t(a)}),s=!0;return()=>{s&&(s=!1,this.count--,n())}}publish(e){let t={id:typeof e.id=="string"?e.id:tR(),at:typeof e.at=="string"?e.at:new Date().toISOString(),...e},{type:n,summary:s,ref:i,agentId:o}=sR(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}},nR=["run","task","signal","mesh","channel","status"];function sR(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 rR(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 Jy(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 _r,timingSafeEqual as Ky}from"crypto";var Mr=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 b={};for(let[w,S]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")&&(b[w]=S);this.log(`Webhook [${l}] reqUrl=${e.url} headers: ${JSON.stringify(b)}`)}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),f=this.webhookEntries.find(b=>b.enabled&&b.agentId===i&&b.source===l),y=h&&f?.triggers?.[h]||f?.defaultWorkflow||null;if(await this.fireHookSafe(l,h,i,c),y&&this.workflowDispatcher)try{let b=await this.workflowDispatcher.dispatchWorkflow({workflowId:y,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=${y} (claimed=${b.claimed})`),this.sendJson(t,202,{ok:!0,agent:i,source:l,eventType:h,workflow:y,claimed:b.claimed});return}catch(b){this.log(`Workflow dispatch failed [${l}/${h}/${y}]: ${b.message}`)}let g=this.webhookEntries.find(b=>b.enabled&&b.node&&b.agentId===i&&b.source===l);if(g?.node&&this.mesh){this.sendJson(t,202,{ok:!0,agent:i,source:l,node:g.node,status:"accepted"}),this.mesh.sendTask(g.node,u,i,{context:{channel:`webhook:${l}`,sender:`webhook:${l}`}}).then(b=>this.log(`Mesh-forwarded webhook [${l}] -> ${g.node}/${i}: ${b?.slice(0,100)||"ok"}`),b=>this.log(`Mesh forward failed [${l}] -> ${g.node}/${i}: ${b.message}`));return}try{let b=await this.registry.execute({message:u,agentId:i,context:{channel:`webhook:${l}`,sender:`webhook:${l}`}});this.sendJson(t,b.error?500:200,{ok:!b.error,agent:i,source:l,response:b.content?.slice(0,500),error:b.error,duration:b.duration})}catch(b){this.sendJson(t,500,{error:b.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(`
|
|
535
535
|
`)[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(`
|
|
536
536
|
`)[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(`
|
|
537
537
|
`)}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(d=>d.enabled&&d.agentId===s&&d.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=d=>{let u=e[d.toLowerCase()];return Array.isArray(u)?u[0]:u};if(n==="github"){let d=c("x-hub-signature-256");if(!d)return"missing X-Hub-Signature-256";let u="sha256="+_r("sha256",a).update(t).digest("hex");return Zt(u,d)}if(n==="gitlab"){let d=c("x-gitlab-token");return d?Zt(a,d):"missing X-Gitlab-Token"}if(n==="stripe"){let d=c("stripe-signature");if(!d)return"missing Stripe-Signature";let u=Object.fromEntries(d.split(",").map(f=>f.split("=")));if(!u.t||!u.v1)return"malformed Stripe-Signature";let h=_r("sha256",a).update(`${u.t}.${t}`).digest("hex");return Zt(h,u.v1)}if(n==="hubspot"){let d=c("x-hubspot-signature-v3"),u=c("x-hubspot-request-timestamp");if(!d)return"missing X-HubSpot-Signature-v3";if(!u)return"missing X-HubSpot-Request-Timestamp";let h=parseInt(u,10);if(!Number.isFinite(h))return"malformed X-HubSpot-Request-Timestamp";let f=Date.now()-h;if(f>5*6e4)return`HubSpot webhook is ${Math.floor(f/1e3)}s old (>5min replay window)`;let y="POST",g=i||e["x-original-uri"]||e["x-forwarded-path"]||"",b=e["x-forwarded-host"],w=e.host,S=e["x-forwarded-proto"]||"https",k=new Set;b&&g&&k.add(`${S}://${b}${g}`),w&&g&&k.add(`https://${w}${g}`),w&&g&&k.add(`http://${w}${g}`),g&&k.add(g),k.add("");for(let x of k){let E=_r("sha256",a).update(`${y}${x}${t}${u}`).digest("base64");if(d.length===E.length&&Ky(Buffer.from(d),Buffer.from(E)))return null}return`signature mismatch (tried ${k.size} URI variants)`}if(n==="odoo"){let d=c("x-odoo-signature");if(d){let h=_r("sha256",a).update(t).digest("hex"),f=d.startsWith("sha256=")?d.slice(7):d;return Zt(h,f)}let u=c("x-odoo-webhook-token")??c("x-webhook-secret");return u?Zt(a,u):"missing X-Odoo-Signature or X-Odoo-Webhook-Token"}let l=c("x-webhook-secret");return l?Zt(a,l):"missing X-Webhook-Secret"}sendJson(e,t,n){e.writeHead(t,{"Content-Type":"application/json"}),e.end(JSON.stringify(n,null,2))}};function Zt(r,e){if(r.length!==e.length)return"signature mismatch";let t=Buffer.from(r),n=Buffer.from(e);return Ky(t,n)?null:"signature mismatch"}vu();Vd();fu();mT();function iR(r){return{insertTaskHistory:r.prepare(`
|
|
@@ -1336,4 +1336,4 @@ data: ${JSON.stringify(z)}
|
|
|
1336
1336
|
`)}catch{}},L=setInterval(()=>{try{t.write(`: ping
|
|
1337
1337
|
|
|
1338
1338
|
`)}catch{}},15e3);L.unref?.();let H=new AbortController;t.on("close",()=>{t.writableEnded||H.abort()});try{for await(let W of this.mesh.sendTaskStream(p.peer,p.message,p.agent,{context:p.context,signal:H.signal,vouchOwner:$}))C(W.event,W.data)}catch(W){C("error",{error:W?.message??String(W)})}finally{clearInterval(L);try{t.end()}catch{}}break}let _=p.context,M=typeof p.senderAgentId=="string"?p.senderAgentId:void 0;if(J$(p,!0)==="callback"){let C=this.delegationGate(e,p,{callee:p.agent,peer:p.peer,message:p.message,calleeContext:_});if(!("track"in C)){let L=wo(C);this.json(t,L.status,L.body);break}}if(p.async===!0){let C=_?.channel,L=_?.chatId;if(!C||!L){this.json(t,400,{error:"async requires context.channel and context.chatId \u2014 there is no route back otherwise"});return}let H=`mesh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;this.json(t,202,{accepted:!0,taskId:H,deliverTo:`${C}:${L}`,note:"result will be delivered to the originating chat when the peer finishes"});let W=p.peer,z=p.agent,Se=this.mesh;(async()=>{let J=Date.now(),Y;try{Y=await Se.sendTask(W,p.message,z,{vouchOwner:$,context:_,senderAgentId:M}),this.log(`[mesh/task async ${H}] ${W}/${z??"default"} finished in ${Date.now()-J}ms`)}catch(K){Y=`Delegation to ${W}/${z??"default"} failed: ${K?.message??K}`,this.log(`[mesh/task async ${H}] failed: ${K?.message??K}`)}try{await this.router.sendOutbound({channel:C,chatId:L,text:Y,agentId:_?.agentId??M,accountId:_?.accountId})}catch(K){this.log(`[mesh/task async ${H}] delivery failed: ${K?.message??K}`)}})();break}let N=await this.mesh.sendTask(p.peer,p.message,p.agent,{context:_,senderAgentId:M,vouchOwner:$});this.json(t,200,{response:N});break}case"POST /webrtc/signal/out":{if(!this.webrtc){this.json(t,404,{error:"WebRTC signaling not enabled"});return}let m=await U(e);if(!m.kind||!m.callId||!m.from||!m.to){this.json(t,400,{error:"Missing: kind, callId, from, to"});return}let v=await this.webrtc.handleOutgoing(m);this.json(t,v.ok?200:400,v);break}case"POST /webrtc/signal":{if(!this.webrtc){this.json(t,404,{error:"WebRTC signaling not enabled"});return}let m=await U(e);if(!m.kind||!m.callId||!m.from||!m.to){this.json(t,400,{error:"Missing: kind, callId, from, to"});return}let v=this.webrtc.handleIncoming(m);this.json(t,v.ok?200:400,v);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),m=p.callId,v=p.target,$=p.agentId||this.config.channels.webrtc?.bot.defaultAgentId;if(!m||!v||!$){this.json(t,400,{error:"Missing: callId, target, agentId (or defaultAgentId in config)"});return}let I=await this.botManager.invite({callId:m,target:v,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(m=>({urls:m})),...p.turnServers],peers:this.mesh?.directory().map(m=>({name:m.peer,healthy:m.healthy}))||[],camera:p.camera,agents:this.registry.list().map(m=>({id:m.id,name:m.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 m=this.config.agents[p.id]||{},v=typeof m.description=="string"&&m.description.trim()||aj(m.systemPrompt)||`Agent "${p.name}" (${p.tier})`,$=Array.isArray(m.mentions)?m.mentions.slice(0,4):[];return{id:p.id,name:p.name,description:v,tags:[p.tier,...$],color:we(p.id,m).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(),m=n.searchParams.get("agent")||void 0,v=n.searchParams.get("after")||void 0,$=m?p.getAgentEntries(m):p.getSharedStore().listEntries({after:v});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(),m=n.searchParams.get("agent");if(!m){this.json(t,400,{error:"?agent= required"});break}let $=p.getAgentWiki(m).rebuildIndex();this.json(t,200,{nodeId:this.config.node.id,agentId:m,articles:$.articles});break}case"GET /wiki/article":{let p=this.registry.getWikiHub(),m=n.searchParams.get("agent"),v=n.searchParams.get("path");if(!m||!v){this.json(t,400,{error:"?agent= and ?path= required"});break}let I=p.getAgentWiki(m).readArticle(v);if(!I){this.json(t,404,{error:"Article not found"});break}this.json(t,200,{nodeId:this.config.node.id,agentId:m,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"),m=n.searchParams.get("status")||"waiting";if(!["waiting","open","patched","rejected","deferred","expired","all"].includes(m)){this.json(t,400,{error:"status must be waiting, open, patched, rejected, deferred, expired or all"});break}let v=Math.max(1,Math.min(200,parseInt(n.searchParams.get("limit")||"50",10)||50)),I=new p(this.registry.getWikiHub().getBaseDir()).list(m==="all"?void 0:m);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(-v).reverse()});break}case"POST /wiki/notes":{let{NoteStore:p,validateNote:m}=await import("./notes-WJJEJ4CJ.js"),v=this.config.wikiNotes;if(!v.enabled||!v.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=m({...$,to:v.inbox});if("error"in I){this.json(t,400,{error:I.error});break}let R=I.note;if(this.registry.getAgent(v.inbox)){try{let{note:N,added:C}=new p(this.registry.getWikiHub().getBaseDir()).add(R);this.json(t,C?201:200,{ok:!0,added:C,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 "${v.inbox}" is not on this node`});break}let _=this.mesh?.findAgentPeer(v.inbox);if(!_){this.json(t,404,{error:`inbox agent "${v.inbox}" is not on this node or any known peer`});break}let M=this.mesh.directory().find(N=>N.peer===_.peer)?.peerUrl;if(!_.healthy||!M){this.json(t,503,{error:`the node hosting "${v.inbox}" (${_.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(_.peer)},body:JSON.stringify({...R,fromNode:R.fromNode||this.config.node.id,forwarded:!0}),signal:AbortSignal.timeout(1e4)}),C=await N.json().catch(()=>({}));this.json(t,N.status,{...C,peer:_.peer})}catch(N){this.json(t,502,{error:`forward to ${_.peer} failed: ${N?.message??N}`,peer:_.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 m=n.searchParams.get("status")||"approved",v=Math.max(1,Math.min(1e3,parseInt(n.searchParams.get("limit")||"200",10)||200)),$=p.listByStatus(m,v);this.json(t,200,{nodeId:this.config.node.id,status:m,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 Xy(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=af(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=vw();if(e==="json")return this.registry.getTodayUsage();let t=kw(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||!vn(n)))try{let s=te(n,".claude","skills");iT(s,{recursive:!0});let i=te(s,xS);if(!vn(i))jd(i,Ml(e)),this.log(` memory-skill: installed remember.md \u2192 ${t.id}`);else{let o=RS(Is(i,"utf-8"),e);o&&(jd(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||!vn(n))continue;let s=this.config.workflows.enabled&&(this.config.workflows.followUp.enabled&&(this.config.workflows.followUp.agents[e]??!0)||Og(this.config.workflows,e)),i=Yh(oh(t),this.config.requests.enabled||s?zh():null);try{switch(Qh(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 iS(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 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 f=await this.workflowDispatcher.dispatch({trigger:s.trigger,entityRef:o,event:i,fromRemote:{peer:h}});this.log(`[workflows/mesh] dispatched broadcast: matched=${f.claimed.length} ${f.claimed.length?`(${f.claimed.map(y=>y.id).join(", ")})`:"[none \u2014 no workflow with mesh.allowRemote matched]"}`),this.json(t,202,{ok:!0,mode:"trigger-broadcast",matched:f.claimed.map(y=>y.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 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-NR7SLHGX.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 Wp(String(e.headers.authorization||""),this.config.mesh.peers,process.env.MESH_TOKEN)}async handleChannelSend(e,t){let n;try{n=await se(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-NR7SLHGX.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,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(f=>({id:f.id,name:f.name,kind:f.kind??"dm",accountId:f.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 se(e)}catch{s={}}try{let i=await TS({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})}}},Fd=Wd;Lt(Fd,"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 aj(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 cj(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 oT(r){let e=r.business;return JSON.stringify([e?.roles,e?.orgChart,e?.relations,e?.projects,(r.people??[]).map(t=>t.id)])}cT();function Jz(r){typeof r=="string"&&(xs.error(r),process.exit(1)),r instanceof Error&&(xs.error(r.message),process.exit(1)),xs.error("Something went wrong. Please try again."),process.exit(1)}export{xj as a,nc as b,$t as c,Fn as d,Un as e,xt as f,pr as g,fy as h,cw as i,fR as j,mR as k,gw as l,Te as m,mw as n,yw as o,Dr as p,b2 as q,k2 as r,Kr as s,LU as t,EC as u,CC as v,zc as w,gb as x,jU as y,$b as z,_C as A,Ib as B,Tb as C,xb as D,FU as E,WU as F,UU as G,ni as H,QC as I,je as J,VG as K,CP as L,Hk as M,Bk as N,y_ as O,av as P,uv as Q,iM as R,xl as S,WB as T,UB as U,GB as V,pS as W,LM as X,VB as Y,JB as Z,os as _,un as $,as as aa,b4 as ba,qS as ca,xO as da,uq as ea,Gi as fa,Xl as ga,Vl as ha,Vi as ia,we as ja,N0 as ka,Yi as la,TD as ma,K0 as na,AD as oa,Z0 as pa,eo as qa,fs as ra,ro as sa,oo as ta,i$ as ua,ad as va,h$ as wa,ct as xa,Ee as ya,y$ as za,w$ as Aa,b$ as Ba,k$ as Ca,xo as Da,mI as Ea,Ed as Fa,wI as Ga,uL as Ha,M3 as Ia,Fd as Ja,Jz as Ka};
|
|
1339
|
-
//# sourceMappingURL=chunk-
|
|
1339
|
+
//# sourceMappingURL=chunk-SVZZUZ3K.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ge,b as k,c as D,d as Xe,e as ge,f as ue,g as j,h as me,i as N,j as L,n as Ve,o as Qe,p as Ze,q as ea}from"./chunk-EFGAPAYZ.js";import{e as Ye,i as Je}from"./chunk-QAWKN2N4.js";import{b as xe}from"./chunk-DODL5POT.js";import{a as Q,b as Ke}from"./chunk-A4PW7EIK.js";import{Ia as We,Ja as Be,Ka as Ue,Ma as Fe,ja as _,oa as Le,wb as qe}from"./chunk-
|
|
1
|
+
import{a as Ge,b as k,c as D,d as Xe,e as ge,f as ue,g as j,h as me,i as N,j as L,n as Ve,o as Qe,p as Ze,q as ea}from"./chunk-EFGAPAYZ.js";import{e as Ye,i as Je}from"./chunk-QAWKN2N4.js";import{b as xe}from"./chunk-DODL5POT.js";import{a as Q,b as Ke}from"./chunk-A4PW7EIK.js";import{Ia as We,Ja as Be,Ka as Ue,Ma as Fe,ja as _,oa as Le,wb as qe}from"./chunk-ZFMNH47D.js";import{a as X}from"./chunk-IMLAPB7G.js";import{b as V}from"./chunk-2VDO2HEK.js";import{c as Me,e as He}from"./chunk-LQE73AZR.js";import{b as Ne}from"./chunk-MRIVENBY.js";import{q as pe,s as je}from"./chunk-XPZSEDE3.js";import{ga as G}from"./chunk-2GIYVYIM.js";import{a as q,b as J}from"./chunk-NS2HSAHF.js";import{a as De}from"./chunk-FJMTCU4S.js";import{c as Ee,d as Re}from"./chunk-OWNQ2FD4.js";import{a as Oe}from"./chunk-ROLSSYXE.js";import{a as Pe}from"./chunk-QUFIUXMQ.js";import{Gb as ce,Ta as Ie,_a as Va,ea as de,fa as Te,pa as Xa,tb as le,wb as F,xb as ze}from"./chunk-BZJF7DJR.js";import{existsSync as K,readFileSync as da,writeFileSync as la,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 fe=`:root {
|
|
2
2
|
/* --- Brand (agentina) --------------------------------------------- */
|
|
3
3
|
--ax-blue: #2979FF;
|
|
4
4
|
--ax-blue-d: #1B5FD9;
|
|
@@ -2900,4 +2900,4 @@ ${a}=${t}
|
|
|
2900
2900
|
WHERE person = ? AND state IN (${t.map(()=>"?").join(",")})
|
|
2901
2901
|
${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 Zo(e,a){return Wa(e,a,de,"ORDER BY created_at")}function ei(e,a,t=50){return Wa(e,a,[...de,...Te],"ORDER BY created_at DESC, rowid DESC LIMIT ?",Math.max(1,Math.min(t,500)))}Va();var Ce="member:",mr=90,fr="members",hr="tailscale-user-login",br=400,vr=60*60*1e3;function wr(e){let a=e.scopes.find(t=>t.startsWith(Ce));return a?a.slice(Ce.length):null}function Ua(e,a){if(!e)return null;let t=a.verify(e),r=t?wr(t):null;return t&&r?{rec:t,personId:r}:null}function si(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:[`${Ce}${t.id}`],expiresInDays:mr}),{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 yr=Math.round(Me/6e4);function kr(e){return e==="client"?"Your project":"My work"}function di(e){let a=kr(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: ${He(e.code)}`,` The code works once, for ${yr} 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(`
|
|
2902
2902
|
`)}var _r="The private network says someone else is connecting from this machine. Ask the person who invited you for a new code.",$r="Too many machines are waiting for the owner's answer. Try again later.",Ba="That code didn't work. Check it, or ask the person who invited you for a new one.",Fa=(e,a)=>{let t=e.headers[a];return(Array.isArray(t)?t[0]:t||"").trim()};function qa(e){let a=e.socket?.remoteAddress||"";return a==="127.0.0.1"||a==="::1"||a==="::ffff:127.0.0.1"}function Sr(e){if(!qa(e))return null;let a=Fa(e,hr).toLowerCase();return a?a.slice(0,80):null}function Ar(e){let a=e.socket?.remoteAddress||"unknown";if(!qa(e))return a;let t=Fa(e,"x-forwarded-for").split(",").pop().trim();return/^[0-9a-fA-F:.]{2,45}$/.test(t)?t:a}function Cr(e){return typeof e=="string"?e.replace(/[^\p{L}\p{N} ._'()-]/gu," ").replace(/\s+/g," ").trim().slice(0,60):""}function Tr(e){return e.identities.map(Ie).filter(a=>!!a&&a.channel==="tailscale").map(a=>a.value)}async function li(e,a){let t=Date.now(),r=a.now??Date.now,n=a.log??(b=>console.log(b)),o=Ar(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 V(e,2048);s=b.code,d=Cr(b.machine)}catch{}let l=a.codes.redeem(s),c=l?Ua(l.token,a.tokens):null;if(await zr(t,a.minMs??br),!l||!c)return a.limiter.fail(o),n(`[member] pair-code failed from ${o}`),{status:401,body:{error:Ba}};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:Ba}};let x=Sr(e),f=Tr(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:_r}};let C=d||"Unnamed machine",w=u.name.slice(0,40),v=je(a.root,{title:`New machine for ${w}`,ask:`From ${o}, ${x?`network login ${x}`:"no network login reported"}. Machine name, as typed there: "${C}". Let it see ${w}'s own work?`,recommend:`Yes if ${w} told you they just paired this machine. No if you did not expect it.`,if_silent:"discard",raised_by:fr},{now:r()});return v.ok?(a.members.add({tokenId:m.id,personId:g,name:C,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:C}),n(`[member] ${g} paired "${C}" from ${o}; waiting for the owner (card ${v.card.id})`),{status:200,body:{person:g,name:C,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:$r}})}var se="this machine is not paired",Ir="waiting for the owner to approve this machine";function Ka(e){return e?e.status==="decided"?e.verdict??null:e.status==="expired"?"no":null:null}function ci(e,a){return a.state==="pending"&&a.cardId?Ka(pe(e,a.cardId)):null}function pi(e,a,t){let r=a.now??Date.now,n=a.log??(c=>console.log(c)),o=Ua(e,a.tokens);if(!o)return{ok:!1,status:401,error:se};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:se};if(a.people&&!a.people().some(c=>c.id===s))return Ya(a,i.id,"person no longer listed"),n(`[member] ${s}: "${d.name}" ended: person no longer listed`),{ok:!1,status:401,error:se};if(d.state==="pending"){let c=d.cardId?pe(a.root,d.cardId):null,m=Ka(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:se}}else return{ok:!1,status:403,error:Ir,waiting:!0}}let l=d.lastSeenAt?Date.parse(d.lastSeenAt):0;return t&&(r()-l>=vr||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 Ya(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 xi(e,a){return e.members.devices(a).filter(t=>t.state!=="removed").map(t=>Ya(e,t.tokenId,"person removed by the owner")).filter(t=>!!t)}async function zr(e,a){let t=e+a-Date.now();t>0&&await new Promise(r=>setTimeout(r,t))}var Ja=["gitlab","github"];function Pr(e,a,t){let r=String(a||"").trim().toLowerCase();if(!Ja.includes(r))throw new Error(`Request status works on ${Ja.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 mi(e){return Array.isArray(e?.requestStatus?.channels)?e.requestStatus.channels.map(a=>String(a).toLowerCase()):[]}function fi(e){let{summary:a}=Q(t=>Pr(t,e?.channel,!!e?.enabled));return{summary:a}}var bi="https://myaccount.google.com/apppasswords";function vi(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 wi(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 yi(e){return`EMAIL_${e.toUpperCase().replace(/[^A-Z0-9]/g,"_")}_PASSWORD`}function _i(e){return new Set(Object.entries(e).filter(([,a])=>a?.wiki?.absorb?.enabled===!1).map(([a])=>a))}function $i(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 Si(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 Ai(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 Er="https://ntfy.sh";function Ti(e){return{enabled:!!e?.enabled,server:e?.server||Er,topicSet:!!e?.topic,tokenSet:!!e?.token}}function Ii(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}export{fe as a,na as b,be as c,Za as d,et as e,at as f,tt as g,rt as h,nt as i,ot as j,it as k,ca as l,mt as m,yn as n,kn as o,_n as p,vo as q,dr as r,_o as s,Co as t,La as u,Jo as v,Go as w,zn as x,Pn as y,It as z,Et as A,ve as B,En as C,Rn as D,Rt as E,Nn as F,Ln as G,Wn as H,Qo as I,Zo as J,ei as K,mr as L,si as M,yr as N,kr as O,di as P,Ar as Q,li as R,ci as S,pi as T,Ya as U,xi as V,Ja as W,Pr as X,mi as Y,fi as Z,bi as _,vi as $,wi as aa,yi as ba,_i as ca,$i as da,Si as ea,Ai as fa,Ti as ga,Ii as ha,Qt as ia,co as ja,fo as ka,ho as la};
|
|
2903
|
-
//# sourceMappingURL=chunk-
|
|
2903
|
+
//# sourceMappingURL=chunk-XCDN62CQ.js.map
|
|
@@ -535,7 +535,7 @@ ${e}`;r-(this.written.get(o)??-1/0)<this.throttleMs||(this.written.set(o,r),this
|
|
|
535
535
|
AND ((outcome = 'sent' AND at <= ?) OR outcome = 'failed')
|
|
536
536
|
ORDER BY at LIMIT 20`).all(Math.max(o-Rl*s,o-kl),o-s),a=e.prepare("UPDATE owner_told SET escalated_at = ? WHERE id = ? AND escalated_at IS NULL"),l=0;for(let{id:c}of i){if(a.run(o,c).changes!==1)continue;let d=n.get(c);if(!d)continue;let u=`${d.channel}:${d.chatId}`,p=Al(t.stops,u,t.up);if(!p){t.log(`[reach] urgent "${d.title.slice(0,80)}" ${d.outcome==="failed"?"failed":"unseen"} on ${u}; no other address to try`);continue}let g=Math.round((o-d.at)/Ee),f=d.outcome==="failed"?`it could not be sent on ${d.channel}`:`not seen on ${d.channel} for ${g} min`,m=`${d.text?`${d.text}
|
|
537
537
|
|
|
538
|
-
`:""}(Sent again here: ${f}.)`,b=n.add({at:o,key:d.key,requestId:d.requestId,kind:d.kind,channel:ne(p),chatId:_l(p),from:d.from,title:d.title,text:m,outcome:"sent",urgent:!0,escalationOf:d.id});try{await t.send(p,d,m),l++,t.log(`[reach] urgent "${d.title.slice(0,80)}": ${f}; sent once to ${p}`)}catch($){n.setOutcome(b,"failed"),t.log(`[reach] urgent "${d.title.slice(0,80)}": escalation to ${p} failed: ${$?.message??$}`)}}return l}var Io=class{constructor(e){this.opts=e}state=new Map;tick(){let e=(this.opts.now??Date.now)(),n=this.opts.confirmChecks??2;for(let[r,o]of Object.entries(this.opts.read())){let s=this.state.get(r)??{downSince:null,checks:0,told:!1};if(o.up){s.downSince!==null&&this.opts.log(`[reach] channel ${r} is up again`),this.state.set(r,{downSince:null,checks:0,told:!1});continue}s.downSince??=e,s.checks++,s.reason=o.reason,!s.told&&s.checks>=n&&(s.told=!0,this.opts.log(`[reach] channel ${r} is down: ${o.reason??"no reason given"}`),this.opts.notice(r,o.reason??"no reason given")),this.state.set(r,s)}}downSince(e){return this.state.get(e)?.downSince??void 0}};var Il={perClient:5,global:10,windowMs:10*60*1e3,lockoutMs:5*60*1e3},Do=class{constructor(e=Il,n=Date.now){this.opts=e;this.now=n}clients=new Map;all={failures:[],lockedUntil:0};retryAfter(e){let n=this.now(),r=Math.max(this.all.lockedUntil,this.clients.get(e)?.lockedUntil??0);return r>n?Math.ceil((r-n)/1e3):0}fail(e){let n=this.clients.get(e);n||this.clients.set(e,n={failures:[],lockedUntil:0}),this.bump(n,this.opts.perClient),this.bump(this.all,this.opts.global)}succeed(e){this.clients.delete(e)}bump(e,n){let r=this.now();e.failures=e.failures.filter(o=>r-o<this.opts.windowMs),e.failures.push(r),e.failures.length>=n&&(e.lockedUntil=r+this.opts.lockoutMs)}},Tl="That code didn't work. Check it, or run agentx app pair for a new one.",Dl=400;async function lg(t,e){let n=Date.now(),r=e.log??(c=>console.log(c)),o=t.socket.remoteAddress||"unknown",s=e.limiter.retryAfter(o);if(s>0)return r(`[app] pair-code refused from ${o}: locked out for ${s}s more`),{status:429,body:{error:"too many attempts",retryAfter:s},retryAfter:s};let i=null;try{i=(await Wn(t,1024)).code}catch{}let a=e.codes.redeem(i),l=a?e.verify(a.token):null;return await Cl(n,e.minMs??Dl),!a||!l?(e.limiter.fail(o),r(`[app] pair-code failed from ${o}`),{status:401,body:{error:Tl}}):(e.limiter.succeed(o),r(`[app] pair-code paired ${a.tokenId} (${l}) from ${o}`),{status:200,body:{device:l},token:a.token})}async function Cl(t,e){let n=t+e-Date.now();n>0&&await new Promise(r=>setTimeout(r,n))}function v(t){return String(t??"").replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e])}
|
|
538
|
+
`:""}(Sent again here: ${f}.)`,b=n.add({at:o,key:d.key,requestId:d.requestId,kind:d.kind,channel:ne(p),chatId:_l(p),from:d.from,title:d.title,text:m,outcome:"sent",urgent:!0,escalationOf:d.id});try{await t.send(p,d,m),l++,t.log(`[reach] urgent "${d.title.slice(0,80)}": ${f}; sent once to ${p}`)}catch($){n.setOutcome(b,"failed"),t.log(`[reach] urgent "${d.title.slice(0,80)}": escalation to ${p} failed: ${$?.message??$}`)}}return l}var Io=class{constructor(e){this.opts=e}state=new Map;tick(){let e=(this.opts.now??Date.now)(),n=this.opts.confirmChecks??2;for(let[r,o]of Object.entries(this.opts.read())){let s=this.state.get(r)??{downSince:null,checks:0,told:!1};if(o.up){s.downSince!==null&&this.opts.log(`[reach] channel ${r} is up again`),this.state.set(r,{downSince:null,checks:0,told:!1});continue}s.downSince??=e,s.checks++,s.reason=o.reason,!s.told&&s.checks>=n&&(s.told=!0,this.opts.log(`[reach] channel ${r} is down: ${o.reason??"no reason given"}`),this.opts.notice(r,o.reason??"no reason given")),this.state.set(r,s)}}downSince(e){return this.state.get(e)?.downSince??void 0}};var Il={perClient:5,global:10,windowMs:10*60*1e3,lockoutMs:5*60*1e3},Do=class{constructor(e=Il,n=Date.now){this.opts=e;this.now=n}clients=new Map;all={failures:[],lockedUntil:0};retryAfter(e){let n=this.now(),r=Math.max(this.all.lockedUntil,this.clients.get(e)?.lockedUntil??0);return r>n?Math.ceil((r-n)/1e3):0}fail(e){let n=this.clients.get(e);n||this.clients.set(e,n={failures:[],lockedUntil:0}),this.bump(n,this.opts.perClient),this.bump(this.all,this.opts.global)}succeed(e){this.clients.delete(e)}bump(e,n){let r=this.now();e.failures=e.failures.filter(o=>r-o<this.opts.windowMs),e.failures.push(r),e.failures.length>=n&&(e.lockedUntil=r+this.opts.lockoutMs)}},Tl="That code didn't work. Check it, or run agentx app pair for a new one.",Dl=400;async function lg(t,e){let n=Date.now(),r=e.log??(c=>console.log(c)),o=t.socket.remoteAddress||"unknown",s=e.limiter.retryAfter(o);if(s>0)return r(`[app] pair-code refused from ${o}: locked out for ${s}s more`),{status:429,body:{error:"too many attempts",retryAfter:s},retryAfter:s};let i=null;try{i=(await Wn(t,1024)).code}catch{}let a=e.codes.redeem(i),l=a?e.verify(a.token):null;return await Cl(n,e.minMs??Dl),!a||!l?(e.limiter.fail(o),r(`[app] pair-code failed from ${o}`),{status:401,body:{error:Tl}}):(e.limiter.succeed(o),r(`[app] pair-code paired ${a.tokenId} (${l}) from ${o}`),{status:200,body:{device:l},token:a.token})}async function Cl(t,e){let n=t+e-Date.now();n>0&&await new Promise(r=>setTimeout(r,n))}import{execFile as Gl}from"child_process";import{mkdtempSync as ql,rmSync as Bl,writeFileSync as Vl}from"fs";import{tmpdir as Hl}from"os";import{join as Oo}from"path";import{randomBytes as Nl}from"crypto";function v(t){return String(t??"").replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e])}var L={top:8,side:32,bottom:60},Dt={height:56,keep:52},Co=`
|
|
539
539
|
:root {
|
|
540
540
|
--ac-paper: #fafaf9; --ac-soft: #f4f4f2; --ac-edge: #e9e9e6;
|
|
541
541
|
--ac-text: #0b1413; --ac-muted: #4a5856; --ac-subtle: #7c8987;
|
|
@@ -885,4 +885,4 @@ Document the arguments, commands, or files the skill expects. Example:
|
|
|
885
885
|
claude-code ${Yt(t)} --arg value
|
|
886
886
|
\`\`\`
|
|
887
887
|
`}ln();var ys={maxPixels:12e5,timeoutMs:5e3,intervalMs:100,changeThreshold:.015,stableMs:400,regions:{},buffer:{enabled:!1,seconds:10,fps:2,region:"screen",maxPixels:3e5}};function ws(t){return{...ys,...t??{},regions:{...t?.regions??{}},buffer:{...ys.buffer,...t?.buffer??{}}}}function Xf(t){try{return ws(an(t).screen)}catch{return ws(void 0)}}var od=/^[a-z][\w-]*$/,xs=["window","screen","menubar","notifications"];function ie(t,e,n,r){let o=Number(t);if(t===""||t===null||!Number.isFinite(o)||!n(o))throw new Error(`${e} must be ${r}`);return o}var Ie=(t,e)=>ie(t,e,n=>Number.isInteger(n)&&n>0,"a whole number above 0");function ks(t){let e=typeof t=="string"?t.split(",").map(Number):[t?.x,t?.y,t?.width,t?.height].map(Number);if(e.length!==4||!e.every(Number.isFinite)||e[2]<=0||e[3]<=0)throw new Error("a region is x,y,width,height in screen points, with width and height above 0");return{x:e[0],y:e[1],width:e[2],height:e[3]}}function Kf(t,e){let n={...t??{}};if("maxPixels"in e&&(n.maxPixels=Ie(e.maxPixels,"maxPixels")),"timeoutMs"in e&&(n.timeoutMs=Ie(e.timeoutMs,"timeoutMs")),"intervalMs"in e&&(n.intervalMs=Ie(e.intervalMs,"intervalMs")),"stableMs"in e&&(n.stableMs=ie(e.stableMs,"stableMs",o=>Number.isInteger(o)&&o>=0,"a whole number, 0 or more")),"changeThreshold"in e&&(n.changeThreshold=ie(e.changeThreshold,"changeThreshold",o=>o>=0&&o<=1,"between 0 and 1")),e.regions&&typeof e.regions=="object"){let o={...n.regions??{}};for(let[s,i]of Object.entries(e.regions)){if(!od.test(s))throw new Error(`region name "${s}" must be lowercase letters, digits, - or _`);i===null?delete o[s]:o[s]=ks(i)}n.regions=o}if(e.buffer&&typeof e.buffer=="object"){let o=e.buffer,s={...n.buffer??{}};"enabled"in o&&(s.enabled=!!o.enabled),"seconds"in o&&(s.seconds=ie(o.seconds,"buffer.seconds",i=>i>0&&i<=120,"above 0 and at most 120")),"fps"in o&&(s.fps=ie(o.fps,"buffer.fps",i=>i>0&&i<=10,"above 0 and at most 10")),"maxPixels"in o&&(s.maxPixels=Ie(o.maxPixels,"buffer.maxPixels")),"region"in o&&(s.region=String(o.region).trim()),n.buffer=s}let r=n.buffer?.region;if(r!==void 0&&!xs.includes(r)&&!n.regions?.[r])try{ks(r)}catch{throw new Error(`buffer.region "${r}" is not a region \u2014 use ${[...xs,...Object.keys(n.regions??{})].join(", ")}, or x,y,w,h`)}return n}export{Jn as a,ad as b,It as c,Ya as d,Za as e,Lp as f,Pp as g,Op as h,Fp as i,Wp as j,jp as k,yo as l,wo as m,qp as n,xo as o,Vp as p,zp as q,O as r,ko as s,k as t,ud as u,$o as v,Zp as w,tg as x,Eo as y,ng as z,Ao as A,rg as B,ne as C,_l as D,og as E,sg as F,Io as G,Ed as H,ti as I,Cd as J,mr as K,Ld as L,_ as M,hd as N,bd as O,qd as P,fe as Q,Bd as R,ar as S,Sd as T,F as U,gu as V,Rr as W,Tr as X,Ci as Y,Ni as Z,hu as _,bu as $,Wi as aa,ku as ba,Do as ca,lg as da,$u as ea,_u as fa,fo as ga,xt as ha,Va as ia,v as ja,Vo as ka,Fg as la,Wg as ma,dc as na,Vg as oa,Jo as pa,Hg as qa,zg as ra,Zg as sa,kc as ta,Qg as ua,Au as va,Ru as wa,Iu as xa,Tu as ya,Du as za,Cu as Aa,Lu as Ba,Pu as Ca,Uu as Da,Fu as Ea,Wu as Fa,qu as Ga,Bu as Ha,Vu as Ia,Hu as Ja,zu as Ka,Xu as La,Ku as Ma,rp as Na,ut as Oa,op as Pa,sp as Qa,ee as Ra,te as Sa,Ac as Ta,cf as Ua,df as Va,uf as Wa,pf as Xa,Ft as Ya,gf as Za,ft as _a,mt as $a,ve as ab,ha as bb,ya as cb,dp as db,bt as eb,yt as fb,wa as gb,xa as hb,no as ib,io as jb,up as kb,Sa as lb,pp as mb,Da as nb,La as ob,wt as pb,Oa as qb,ao as rb,M as sb,as as tb,ls as ub,cs as vb,jt as wb,wf as xb,Oc as yb,us as zb,ps as Ab,Tf as Bb,Df as Cb,Zc as Db,Cf as Eb,fs as Fb,Se as Gb,$p as Hb,At as Ib,Dp as Jb,Of as Kb,Mf as Lb,Uf as Mb,Ff as Nb,Wf as Ob,jf as Pb,qf as Qb,Bf as Rb,Vf as Sb,ys as Tb,ws as Ub,Xf as Vb,xs as Wb,Kf as Xb};
|
|
888
|
-
//# sourceMappingURL=chunk-
|
|
888
|
+
//# sourceMappingURL=chunk-ZFMNH47D.js.map
|