agentix-cli 0.171.0 → 0.172.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.
Files changed (31) hide show
  1. package/README.md +175 -73
  2. package/dist/{agent-2SQYGIUD.js → agent-4637FJMD.js} +2 -2
  3. package/dist/{board-dashboard-QFCOFP7F.js → board-dashboard-DJKRLABN.js} +565 -345
  4. package/dist/board-dashboard-DJKRLABN.js.map +1 -0
  5. package/dist/{chunk-BAAKV4HK.js → chunk-7FGJOVML.js} +3 -3
  6. package/dist/chunk-7FGJOVML.js.map +1 -0
  7. package/dist/{chunk-YE3MGLJF.js → chunk-7NA5VSQE.js} +311 -306
  8. package/dist/chunk-7NA5VSQE.js.map +1 -0
  9. package/dist/{chunk-74RXD676.js → chunk-I7EO2WXC.js} +2 -2
  10. package/dist/{chunk-FBNU7MMW.js → chunk-MH55YCUS.js} +80 -80
  11. package/dist/chunk-MH55YCUS.js.map +1 -0
  12. package/dist/{chunk-P3GQPEMU.js → chunk-PD5BZYBO.js} +8 -8
  13. package/dist/chunk-PD5BZYBO.js.map +1 -0
  14. package/dist/{chunk-LXRLD4VQ.js → chunk-SP7VFTXO.js} +2 -2
  15. package/dist/cli.js +1 -1
  16. package/dist/index.d.ts +9 -1
  17. package/dist/index.js +1 -1
  18. package/dist/{program-O3BJYC47.js → program-XKQTHEQ3.js} +260 -259
  19. package/dist/program-XKQTHEQ3.js.map +1 -0
  20. package/dist/{registry-MXZBIPE5.js → registry-GROEORK6.js} +2 -2
  21. package/package.json +2 -2
  22. package/dist/board-dashboard-QFCOFP7F.js.map +0 -1
  23. package/dist/chunk-BAAKV4HK.js.map +0 -1
  24. package/dist/chunk-FBNU7MMW.js.map +0 -1
  25. package/dist/chunk-P3GQPEMU.js.map +0 -1
  26. package/dist/chunk-YE3MGLJF.js.map +0 -1
  27. package/dist/program-O3BJYC47.js.map +0 -1
  28. /package/dist/{agent-2SQYGIUD.js.map → agent-4637FJMD.js.map} +0 -0
  29. /package/dist/{chunk-74RXD676.js.map → chunk-I7EO2WXC.js.map} +0 -0
  30. /package/dist/{chunk-LXRLD4VQ.js.map → chunk-SP7VFTXO.js.map} +0 -0
  31. /package/dist/{registry-MXZBIPE5.js.map → registry-GROEORK6.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as Fe}from"./chunk-GTJIKXDB.js";import{C as vn,J as Cn,k as P}from"./chunk-TAUXWIYB.js";import{f as An,g as In,h as Tn,k as Dn}from"./chunk-AQGQLVCD.js";import{a as w}from"./chunk-N6VBEITO.js";import{b as $n}from"./chunk-2VDO2HEK.js";import{f as En,i as _n,k as Me,l as Ue,n as G,o as j,q as Rn}from"./chunk-LQS27HSV.js";import{t as Sn,u as xn}from"./chunk-HZXLZIB4.js";import{d as wn,e as kn}from"./chunk-AQASR6KR.js";import{a as dn,b as pn,d as gn,e as fn}from"./chunk-MNG2AMKZ.js";import{h as K,j as mn,l as hn,m as bn,n as yn}from"./chunk-RX5O5637.js";import{h as on,i as an,j as ln,l as cn,m as un}from"./chunk-35R7Y7BT.js";import{a as rn,c as sn}from"./chunk-KP7KDLZ2.js";import{Ba as Pe,b as Ce,r as Ne,t as Le,wa as nn,ya as le,za as Oe}from"./chunk-P3GQPEMU.js";import{r as tn}from"./chunk-LB55Q3K4.js";import{a as Qt,b as ae,e as en}from"./chunk-TB3ZEMTC.js";import{a as Zt}from"./chunk-QUFIUXMQ.js";import{ba as Ht,ca as zt,cb as De,ea as Xt,fa as Kt,lb as Gt,mb as Jt,p as ie,q as Vt,r as Bt,s as no,vb as Yt}from"./chunk-NGGEGY5K.js";import{a as Ie,h as ro}from"./chunk-VJ5HC63R.js";import{j as Te,r as so}from"./chunk-UEEB3UTU.js";import{existsSync as oo,readdirSync as io,readFileSync as ao,statSync as lo}from"fs";import{resolve as co}from"path";function Nn(t,e,n=Date.now(),r=7){let s=r*864e5,o=new Map;for(let i of e){let a=o.get(i.workflowId);a?a.push(i):o.set(i.workflowId,[i])}return t.map(i=>{let a=o.get(i.id)??[],l=a.filter(f=>n-f.at<=s),u=a.filter(f=>n-f.at>s&&n-f.at<=s*2),c=l.filter(f=>f.status==="failed").length,d=a.filter(f=>f.status==="paused").length,p=a.length?Math.max(...a.map(f=>f.at)):null,g=a.length?u.length>0&&l.length===0?"dormant":l.length>0&&c*2>=l.length?"failing":l.length>0?"active":"quiet":"never";return{id:i.id,name:i.name||i.id,state:g,lastRunAt:p,recent:l.length,prior:u.length,failed:c,paused:d}}).sort((i,a)=>{let l={dormant:0,failing:1,active:2,quiet:3,never:4};return l[i.state]-l[a.state]||(a.lastRunAt??0)-(i.lastRunAt??0)})}var ce=new Map;function Mc(t,e=1e3){if(!oo(t))return[];let n=io(t).filter(o=>o.endsWith(".jsonl")).map(o=>{let i=co(t,o);return{path:i,mtime:lo(i).mtimeMs}}).sort((o,i)=>i.mtime-o.mtime).slice(0,e),r=new Set(n.map(o=>o.path));for(let o of ce.keys())r.has(o)||ce.delete(o);let s=[];for(let{path:o,mtime:i}of n){let a=ce.get(o);if(a&&a.mtime===i){a.summary&&s.push(a.summary);continue}let l=uo(o,i);ce.set(o,{mtime:i,summary:l}),l&&s.push(l)}return s}function uo(t,e){try{let n=ao(t,"utf-8").split(`
1
+ import{a as Fe}from"./chunk-GTJIKXDB.js";import{C as vn,J as Cn,k as P}from"./chunk-TAUXWIYB.js";import{f as An,g as In,h as Tn,k as Dn}from"./chunk-AQGQLVCD.js";import{a as w}from"./chunk-N6VBEITO.js";import{b as $n}from"./chunk-2VDO2HEK.js";import{f as En,i as _n,k as Me,l as Ue,n as G,o as j,q as Rn}from"./chunk-LQS27HSV.js";import{t as Sn,u as xn}from"./chunk-HZXLZIB4.js";import{d as wn,e as kn}from"./chunk-AQASR6KR.js";import{a as dn,b as pn,d as gn,e as fn}from"./chunk-MNG2AMKZ.js";import{h as K,j as mn,l as hn,m as bn,n as yn}from"./chunk-RX5O5637.js";import{h as on,i as an,j as ln,l as cn,m as un}from"./chunk-35R7Y7BT.js";import{a as rn,c as sn}from"./chunk-KP7KDLZ2.js";import{Aa as Oe,Ca as Pe,b as Ce,s as Ne,u as Le,xa as nn,za as le}from"./chunk-PD5BZYBO.js";import{r as tn}from"./chunk-LB55Q3K4.js";import{a as Qt,b as ae,e as en}from"./chunk-TB3ZEMTC.js";import{a as Zt}from"./chunk-QUFIUXMQ.js";import{ba as Ht,ca as zt,cb as De,ea as Xt,fa as Kt,lb as Gt,mb as Jt,p as ie,q as Vt,r as Bt,s as no,vb as Yt}from"./chunk-NGGEGY5K.js";import{a as Ie,h as ro}from"./chunk-VJ5HC63R.js";import{j as Te,r as so}from"./chunk-UEEB3UTU.js";import{existsSync as oo,readdirSync as io,readFileSync as ao,statSync as lo}from"fs";import{resolve as co}from"path";function Nn(t,e,n=Date.now(),r=7){let s=r*864e5,o=new Map;for(let i of e){let a=o.get(i.workflowId);a?a.push(i):o.set(i.workflowId,[i])}return t.map(i=>{let a=o.get(i.id)??[],l=a.filter(f=>n-f.at<=s),u=a.filter(f=>n-f.at>s&&n-f.at<=s*2),c=l.filter(f=>f.status==="failed").length,d=a.filter(f=>f.status==="paused").length,p=a.length?Math.max(...a.map(f=>f.at)):null,g=a.length?u.length>0&&l.length===0?"dormant":l.length>0&&c*2>=l.length?"failing":l.length>0?"active":"quiet":"never";return{id:i.id,name:i.name||i.id,state:g,lastRunAt:p,recent:l.length,prior:u.length,failed:c,paused:d}}).sort((i,a)=>{let l={dormant:0,failing:1,active:2,quiet:3,never:4};return l[i.state]-l[a.state]||(a.lastRunAt??0)-(i.lastRunAt??0)})}var ce=new Map;function Mc(t,e=1e3){if(!oo(t))return[];let n=io(t).filter(o=>o.endsWith(".jsonl")).map(o=>{let i=co(t,o);return{path:i,mtime:lo(i).mtimeMs}}).sort((o,i)=>i.mtime-o.mtime).slice(0,e),r=new Set(n.map(o=>o.path));for(let o of ce.keys())r.has(o)||ce.delete(o);let s=[];for(let{path:o,mtime:i}of n){let a=ce.get(o);if(a&&a.mtime===i){a.summary&&s.push(a.summary);continue}let l=uo(o,i);ce.set(o,{mtime:i,summary:l}),l&&s.push(l)}return s}function uo(t,e){try{let n=ao(t,"utf-8").split(`
2
2
  `).filter(Boolean);if(!n.length)return null;let r=JSON.parse(n[0]),s=r.run?.workflowId;if(!s)return null;let o=r.run?.status??"unknown";for(let i=n.length-1;i>=0;i--){let a=JSON.parse(n[i]),l=a.status??a.run?.status;if(l){o=l;break}}return{workflowId:s,status:o,at:e}}catch{return null}}var po={failStreak:3,disabledDays:30,missedFires:2,graceMs:15*6e4},k={routines:200,summary:160,filters:6,filterValue:60,text:120},go=(t,e,n)=>{try{return tn(t,e,n)}catch{return null}},Ln=864e5;function jc(t){let e=t.now??Date.now(),n={...po,...t.thresholds},r=t.nextFire??go,s=[];for(let a of t.crons){let l=t.cronRuns.get(a.id)??[],u=a.timezone||"UTC",c=l.map(g=>({at:Date.parse(g.startedAt),status:g.status})),d=l[0],p={id:`cron:${a.id}`,source:"cron",kind:"schedule",name:A(a.id,k.text),trigger:{schedule:A(a.schedule,k.text),timezone:u},agent:a.agent||null,enabled:a.enabled,state:a.enabled?"enabled":"disabled",nextRunAt:a.enabled?We(a.nextRun)??We(r(a.schedule,new Date(e),u)):null,lastRun:d?{at:d.startedAt,status:d.status,summary:wo(d.status==="success"?void 0:d.errorSummary,k.summary)}:null,lastSuccessAt:l.find(g=>g.status==="success")?.startedAt??null,consecutiveFailures:On(c),sampledRuns:l.length,flags:[],attention:null};p.flags=Pn(p,c,a.schedule,u,null,e,n,r),s.push(Mn(p))}let o=new Map(Nn(t.workflows.map(a=>({id:a.id,name:a.title})),t.workflowRuns,e).map(a=>[a.id,a])),i=new Map;for(let a of t.workflowRuns){let l=i.get(a.workflowId);l?l.push(a):i.set(a.workflowId,[a])}for(let a of t.workflows){let l=a.nodes.find(T=>T.type.startsWith("trigger."));if(!l||l.type!=="trigger.cron"&&l.type!=="trigger.hook")continue;let u=l.config??{},c=a.state||"active",d=c==="active",p=(i.get(a.id)??[]).slice().sort((T,Ae)=>Ae.at-T.at),g=p.map(T=>({at:T.at,status:ho(T.status)})),f=g[0],m=l.type==="trigger.cron",b=typeof u.spec=="string"?u.spec:"",x=typeof u.timezone=="string"?u.timezone:"UTC",W={id:`workflow:${a.id}`,source:"workflow",kind:m?"schedule":"event",name:A(a.title||a.id,k.text),trigger:m?{schedule:A(b,k.text),timezone:x}:{event:A(typeof u.event=="string"?u.event:"",k.text),filters:yo(u.filter,a)},agent:bo(a),enabled:d,state:c,nextRunAt:m&&d&&b?We(r(b,new Date(e),x)):null,lastRun:f?{at:new Date(f.at).toISOString(),status:f.status}:null,lastSuccessAt:(()=>{let T=g.find(Ae=>Ae.status==="success");return T?new Date(T.at).toISOString():null})(),consecutiveFailures:On(g),sampledRuns:p.length,flags:[],attention:null},oe=Date.parse(a.updated||a.created||"");W.flags=m?Pn(W,g,b,x,Number.isFinite(oe)?oe:null,e,n,r):fo(W,o.get(a.id)?.state==="dormant",Number.isFinite(oe)?oe:null,e,n),s.push(Mn(W))}return s.sort(mo).slice(0,k.routines)}function On(t){let e=0;for(let n of t)if(!(n.status==="running"||n.status==="paused"||n.status==="unknown"))if(n.status==="failed"||n.status==="timeout")e++;else break;return e}function Pn(t,e,n,r,s,o,i,a){let l=[],u=e.length?e[0].at:null;if(!t.enabled){let p=Fn(u,s,o,i);return p&&l.push(p),l}if(t.consecutiveFailures>=i.failStreak&&l.push({reason:"failing",detail:`${t.consecutiveFailures} failed attempts in a row`}),u===null)return l.push({reason:"never-ran",detail:"No persisted attempt"}),l;let c=new Date(u),d=null;for(let p=0;p<i.missedFires&&(d=a(n,c,r),!!d);p++)c=d;return d&&o>d.getTime()+i.graceMs&&l.push({reason:"overdue",detail:`No attempt since ${new Date(u).toISOString()}; ${i.missedFires} scheduled fires missed`}),l}function fo(t,e,n,r,s){let o=[],i=t.lastRun?Date.parse(t.lastRun.at):null;if(!t.enabled){let a=Fn(i,n,r,s);return a&&o.push(a),o}return t.consecutiveFailures>=s.failStreak&&o.push({reason:"failing",detail:`${t.consecutiveFailures} failed runs in a row`}),i===null?o.push({reason:"never-ran",detail:"No run recorded for this trigger"}):e&&o.push({reason:"dormant",detail:"Fired in the prior week, silent in the last one"}),o}function Fn(t,e,n,r){let s=Math.max(t??0,e??0);return s&&n-s<r.disabledDays*Ln?null:{reason:"disabled-long",detail:s?`Disabled; no activity for ${Math.floor((n-s)/Ln)} days`:"Disabled and never ran"}}function Mn(t){let e=new Set(t.flags.map(n=>n.reason));return t.attention=e.has("failing")?"critical":e.has("overdue")||e.has("dormant")||e.has("never-ran")?"warning":e.has("disabled-long")?"info":null,t}var Un={critical:0,warning:1,info:2};function mo(t,e){let n=t.attention?Un[t.attention]:3,r=e.attention?Un[e.attention]:3;return n-r||Number(e.enabled)-Number(t.enabled)||t.name.localeCompare(e.name)}function ho(t){switch(t){case"completed":case"ok":return"success";case"failed":return"failed";case"timeout":return"timeout";case"canceled":return"canceled";case"running":return"running";case"paused":return"paused";default:return"unknown"}}function bo(t){if(t.ownerAgent)return A(t.ownerAgent,k.text);let e=t.nodes.find(n=>n.type==="agent"&&typeof n.config?.agentId=="string"&&n.config.agentId);return e?A(String(e.config.agentId),k.text):null}function yo(t,e){let n=[],r=e?.project;if(r&&n.push(A(`project=${r}`,k.filterValue)),t&&typeof t=="object"&&!Array.isArray(t))for(let[s,o]of Object.entries(t)){let i=Array.isArray(o)?o.map(String):o==null?[]:[String(o)];i.length&&n.push(A(`${s}=${i.join(",")}`,k.filterValue))}return n.slice(0,k.filters)}function We(t){if(!t)return null;let e=t instanceof Date?t:new Date(t);return Number.isFinite(e.getTime())?e.toISOString():null}function A(t,e){return t.length<=e?t:t.slice(0,e-3)+"..."}function wo(t,e){return t===void 0?void 0:A(t,e)}import{mkdirSync as ko,readFileSync as So,renameSync as xo,writeFileSync as vo}from"fs";import{resolve as $o}from"path";function Wn(t){return $o(Ue(t),"_state.json")}function v(t){try{let e=JSON.parse(So(Wn(t),"utf-8"));return{snoozed:e&&typeof e.snoozed=="object"&&e.snoozed?e.snoozed:{},...typeof e?.lastDigest=="string"?{lastDigest:e.lastDigest}:{},...e?.popped&&typeof e.popped=="object"?{popped:e.popped}:{},...typeof e?.passAt=="string"?{passAt:e.passAt}:{},...Array.isArray(e?.wanted)?{wanted:e.wanted.filter(n=>typeof n=="string")}:{}}}catch{return{snoozed:{}}}}function J(t,e){ko(Ue(t),{recursive:!0});let n=Wn(t),r=`${n}.${process.pid}.tmp`;vo(r,JSON.stringify(e,null,2)+`
3
3
  `),xo(r,n)}function jn(t,e,n,r=Date.now()){let s=v(t),o={};for(let[i,a]of Object.entries(s.snoozed))Date.parse(a)>r&&(o[i]=a);o[e]=n.toISOString(),J(t,{...s,snoozed:o})}function zc(t,e){J(t,{...v(t),lastDigest:e})}function je(t,e,n,r=Date.now()){let s=v(t),o=new Set(n),i={};for(let[l,u]of Object.entries(s.popped??{}))o.has(l)&&(i[l]=u);i[e]=new Date(r).toISOString();let a=(s.wanted??[]).filter(l=>l!==e&&o.has(l));J(t,{...s,popped:i,wanted:a})}function qn(t,e){let n=v(t);J(t,{...n,wanted:[...(n.wanted??[]).filter(r=>r!==e),e]})}function Xc(t,e=Date.now()){J(t,{...v(t),popped:{},passAt:new Date(e).toISOString()})}import{existsSync as Eo,readFileSync as _o}from"fs";Yt();ro();function Vn(t){let e=Qt(t),n={};if(Eo(e))try{n=Gt(JSON.parse(_o(e,"utf-8")))}catch{n={}}let r=De.safeParse(n?.requests);return r.success?r.data:De.parse(void 0)}async function Qc(t,e={}){let n=(t.channels??[]).filter(r=>!Ie.has(r.toLowerCase().split("@")[0]));return n.length?{success:!1,error:`unknown channel ${n.map(r=>`"${r}"`).join(", ")}: use ${[...Ie].join(", ")}`}:ae(r=>{let s=r.requests??={};for(let o of["enabled","channels","from","staleAfterHours","retentionDays","settleHandedBack"])t[o]!==void 0&&(s[o]=t[o]);if(t.plans){let o=s.plans??={};for(let i of["enabled","stallMinutes","maxNudges","approveKinds","disabledAgents","requireForWork","requireOverMinutes"])t.plans[i]!==void 0&&(o[i]=t.plans[i])}if(t.headlines?.enabled!==void 0&&((s.headlines??={}).enabled=t.headlines.enabled),t.catchPromises){let o=s.catchPromises??={};for(let i of["enabled","dailyCap"])t.catchPromises[i]!==void 0&&(o[i]=t.catchPromises[i])}if(t.checkers){let o=s.checkers??={};for(let i of["enabled","checkEveryMinutes"])t.checkers[i]!==void 0&&(o[i]=t.checkers[i])}},{configPath:e.configPath,reload:e.reload})}import{existsSync as Y,readdirSync as Ko,readFileSync as ze}from"fs";import{dirname as Go,resolve as $}from"path";import{randomBytes as zn}from"crypto";import{existsSync as Ao,mkdirSync as Io,readdirSync as To,readFileSync as Do,renameSync as Xn,unlinkSync as Co,writeFileSync as No}from"fs";import{resolve as Kn}from"path";function Bn(t){return[...t.account?["--account",t.account]:[],...t.store?["--store",t.store]:[]]}var Ro=t=>t.trim().split(`
4
4
  `).pop()?.slice(0,300)||"no output";async function Hn(t,e,n,r=Fe){let s=await r(t.bin,[...Bn(t),"send","text","--to",e,"--message",n,"--no-preview"],{timeoutMs:6e4});return s.code===0?{ok:!0}:{ok:!1,error:`wacli send failed: ${Ro(s.stderr||s.stdout)}`}}async function nu(t,e,n,r,s=Fe){return(await s(t.bin,[...Bn(t),"--read-only","media","download","--chat",e,"--id",n,"--output",r],{timeoutMs:12e4})).code===0}var Lo=2e3,Oo=t=>Hn(t.wacli,t.to,t.text);function qe(t){return Kn(t,".agentx","whatsapp-triage","drafts")}var Po=t=>/^[a-z0-9-]{8,64}$/.test(t),ue=(t,e)=>Kn(qe(t),`${e}.json`);function Gn(t,e){Io(qe(t),{recursive:!0});let n=ue(t,e.id),r=`${n}.${process.pid}.tmp`;No(r,JSON.stringify(e,null,2)+`
@@ -55,7 +55,7 @@ import{a as Fe}from"./chunk-GTJIKXDB.js";import{C as vn,J as Cn,k as P}from"./ch
55
55
  `)}function or(t){return!!t.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'request_plans'").get()}function Be(t){return{requestId:t.request_id,createdBy:t.created_by,createdAt:t.created_at,state:t.state,finishedAt:t.finished_at??null,notifiedAt:t.notified_at??null}}function sr(t){return{requestId:t.request_id,idx:t.idx,name:t.name,kind:t.kind,agentId:t.agent_id,doneWhen:t.done_when,state:t.state,needsApproval:!!t.needs_approval,approval:t.approval,cardId:t.card_id??null,message:t.message??null,toChannel:t.to_channel??null,toChat:t.to_chat??null,toAccount:t.to_account??null,checkUrl:t.check_url??null,checkContains:t.check_contains??null,stallMinutes:t.stall_minutes??null,evidence:t.evidence??null,note:t.note??null,dispatchedAt:t.dispatched_at??null,updatedAt:t.updated_at,nudges:t.nudges,lastNudgeAt:t.last_nudge_at??null,notifiedAt:t.notified_at??null}}var Xo={state:"state",approval:"approval",cardId:"card_id",message:"message",evidence:"evidence",note:"note",dispatchedAt:"dispatched_at",updatedAt:"updated_at",nudges:"nudges",lastNudgeAt:"last_nudge_at",notifiedAt:"notified_at"},pe=class{constructor(e){this.db=e;zo(e)}create(e,n,r,s){let o=this.db.prepare("INSERT INTO request_plans (request_id, created_by, created_at, state) VALUES (?, ?, ?, 'active')"),i=this.db.prepare(`INSERT INTO request_plan_steps (request_id, idx, name, kind, agent_id, done_when, state, needs_approval, message,
56
56
  to_channel, to_chat, to_account, check_url, check_contains, stall_minutes, dispatched_at, updated_at)
57
57
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);this.db.transaction(()=>{o.run(e,n,s),r.forEach((a,l)=>{let u=l===0,c=u&&a.agentId===n&&a.kind!=="message";i.run(e,l+1,a.name,a.kind,a.agentId,a.doneWhen,u?"active":"pending",a.needsApproval?1:0,a.message??null,a.toChannel??null,a.toChat??null,a.toAccount??null,a.checkUrl??null,a.checkContains??null,a.stallMinutes??null,c?s:null,s)}),this.event(e,null,"created",`${r.length} steps, written by ${n}`,s)})()}get(e){let n=this.db.prepare("SELECT * FROM request_plans WHERE request_id = ?").get(e);return n?Be(n):null}steps(e){return this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? ORDER BY idx").all(e).map(sr)}step(e,n){let r=this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? AND idx = ?").get(e,n);return r?sr(r):null}listActive(){return this.db.prepare("SELECT * FROM request_plans WHERE state = 'active' ORDER BY created_at, rowid").all().map(Be)}updateStep(e,n,r){let s=[],o=[];for(let[i,a]of Object.entries(r)){let l=Xo[i];!l||a===void 0||(s.push(`${l} = ?`),o.push(typeof a=="boolean"?a?1:0:a))}s.length&&this.db.prepare(`UPDATE request_plan_steps SET ${s.join(", ")} WHERE request_id = ? AND idx = ?`).run(...o,e,n)}finish(e,n,r){return this.db.prepare("UPDATE request_plans SET state = ?, finished_at = ? WHERE request_id = ? AND state = 'active'").run(n,r,e).changes>0}markNotified(e,n){this.db.prepare("UPDATE request_plans SET notified_at = ? WHERE request_id = ?").run(n,e)}awaitingSummary(){return this.db.prepare("SELECT * FROM request_plans WHERE state = 'done' AND notified_at IS NULL ORDER BY finished_at").all().map(Be)}event(e,n,r,s,o){this.db.prepare("INSERT INTO request_plan_events (request_id, step, at, kind, detail) VALUES (?, ?, ?, ?, ?)").run(e,n,o,r,s.replace(/\s+/g," ").trim().slice(0,Ho))}events(e,n=200){return this.db.prepare("SELECT request_id, step, at, kind, detail FROM request_plan_events WHERE request_id = ? ORDER BY at, rowid LIMIT ?").all(e,n).map(r=>({requestId:r.request_id,step:r.step??null,at:r.at,kind:r.kind,detail:r.detail}))}},wu=Ht;var lr=["card","schedule","agent","memory","wiki","whatsapp","email","content","request"],Jo=280;function D(t,e=Jo){let n=t.replace(/\s+/g," ").trim();return n.length>e?`${n.slice(0,e-1)}\u2026`:n}function q(t){if(t.configPath)return $(t.configPath);let e=[$(t.root,"agentx.json"),$(t.root,".agentx","config.json")];return e.find(n=>Y(n))??e[0]}function Xe(t){return t.wikiDir?$(t.wikiDir):$(t.root,".agentx","wiki")}function Yo(t){return j(t.root,"pending").map(Zo)}function Zo(t){return{key:`card:${t.id}`,kind:"card",title:t.title,ask:t.ask,yes:`tell ${t.raised_by} yes`,no:`tell ${t.raised_by} no`,recommend:t.recommend,if_silent:t.if_silent,expires:t.expires,...t.source?{source:t.source}:{},raised_by:t.raised_by,...t.node?{node:t.node}:{},created_at:t.created_at,...t.choices?{choices:t.choices,more:`agentx approvals popup card:${t.id}`}:{},...t.draft?{draft:t.draft}:{},...t.context||t.draft?{detail:D([t.context,t.draft?`Suggested message: ${t.draft}`:""].filter(Boolean).join(" \xB7 "))}:{}}}function Qo(t){let e=q(t);if(!Y(e))return[];let n;try{n=JSON.parse(ze(e,"utf-8"))}catch{return[]}let r=new Date(t.now??Date.now()),s=[];for(let[o,i]of Object.entries(n?.crons??{})){let a=i?.approval;if(!a||a.action!=="create"&&a.action!=="delete")continue;let l=i.timezone||"UTC",u=i.schedule?on(i.schedule):"",c=i.schedule?`${u.charAt(0).toLowerCase()}${u.slice(1)} (${i.schedule})`:"no schedule",d=String(i.prompt??i.command??""),p=a.action==="create";s.push({key:`schedule:${o}`,kind:"schedule",title:p?`New schedule "${o}" for ${i.agent??"an agent"}`:`Delete schedule "${o}"`,ask:p?`Let ${i.agent??"the agent"} run this ${c}?`:`Remove the schedule "${o}" (${c})?`,yes:p?"enable it":"remove it",no:p?"drop the request":"keep the schedule",raised_by:String(a.requestedBy??"unknown"),created_at:String(a.requestedAt??""),detail:D(`${d}${p&&i.schedule?` \xB7 first run ${ln(an(i.schedule,l,r),l)}`:""}`),more:"agentx schedule list"})}return s}function cr(t){let e=$(t,".agentx","memory");return Y(e)?Ko(e).filter(n=>n.endsWith(".jsonl")).map(n=>n.slice(0,-6)).sort():[]}function ei(t){let e=cr(t.root);if(e.length===0)return[];let n=new Ce(t.root),r=[];for(let s of e)for(let o of n.held(s))r.push({key:`memory:${s}/${o.id}`,kind:"memory",title:`Fact ${s} learned from ${o.source.channel}`,ask:`Let ${s} use this fact in its prompts?`,yes:"use it",no:"keep it out for good",raised_by:s,created_at:o.createdAt,detail:D(o.content),more:`agentx memory facts held --agent ${s}`});return r}function ti(t){let e=t.sources.filter(n=>n.failure);return e.length?e.map(n=>`Recurring failure: ${n.agentId}'s ${n.failure.tool} fails with "${n.failure.errorClass}" in ${n.occurrences??1} sessions (${n.failure.runs} runs).`).join(" "):`${t.sources.length} source(s)${t.occurrences>1?`, seen in ${t.occurrences} sessions`:""}.`}function ni(t){return kn(Xe(t),"pending").map(e=>{let n=e.evidence;return{key:`wiki:${e.id}`,kind:"wiki",title:e.article.title,ask:e.replaces?`Update "${e.article.path}" in the shared wiki?`:`Add "${e.article.path}" to the shared wiki?`,yes:"write the article",no:"decline it",raised_by:n.agents.join(", ")||"wiki promote",created_at:e.createdAt,detail:D(`${ti(n)} ${e.article.content}`),more:`agentx wiki proposals show ${e.id}`}})}function ri(t){return Jn(t.root,"pending").map(e=>({key:`whatsapp:${e.id}`,kind:"whatsapp",title:`WhatsApp reply to ${e.chat_name||e.to}`,ask:`Send this to ${e.chat_name||e.to}? "${e.text}"`,yes:"send it on WhatsApp",no:"drop the draft",raised_by:e.agent,created_at:e.created_at,detail:D(`${e.triage}: ${e.summary}`),more:"agentx whatsapp triage log"}))}function si(t){return In(t.root,"pending").map(e=>({key:`email:${e.id}`,kind:"email",title:`Email reply to ${e.to_name?`${e.to_name} <${e.to}>`:e.to}`,ask:`Send this reply to ${e.to}, subject "${e.subject}"?`,yes:"send the email",no:"drop the reply",raised_by:e.agent,created_at:e.created_at,draft:e.text,...e.error?{detail:D(`Last try not sent: ${e.error}`)}:{}}))}function oi(t){let e=Object.entries(Ne(t.root)).filter(([,r])=>r.kind==="approval");if(e.length===0)return[];let n=ge(t).agents??{};return e.map(([r,s])=>{let o=n[r]??{};return{key:`agent:${r}`,kind:"agent",title:`New agent "${o.name||r}", created by ${s.by}`,ask:`Let ${o.name||r} (${o.tier||"claude-code"}) start working?`,yes:"let it run",no:"remove it from agentx.json (its folder is kept)",raised_by:s.by,created_at:s.at,detail:D(`Workspace: ${o.workspace||"?"}. Instructions: ${o.systemPrompt||"(none)"}`),more:"agentx agent list"}})}function ge(t){try{return JSON.parse(ze(q(t),"utf-8"))}catch{return{}}}function He(t){let e={};try{e=Object.fromEntries(Zt(ze($(Go(q(t)),".env"),"utf-8")))}catch{}return{...e,...process.env}}function ii(t){let e=bn(t.root,"pending");if(e.length===0)return[];let n=ge(t),r=He(t);return e.map(s=>{let o=K[s.platform]??s.platform;return{key:`content:${s.id}`,kind:"content",title:`${o} post${s.topic?`: ${s.topic}`:""}${s.date?` (for ${s.date})`:""}`,ask:`Publish this on ${o}? "${s.text}"`,yes:nr({config:n,env:r},s.agent,s.platform)?`post it on ${o}`:"save it ready to paste (no connector is set)",no:"drop the draft",raised_by:s.agent,created_at:s.created_at,detail:D(`Follows your past posts: ${s.samples.join(", ")}`),more:`agentx content show ${s.id}`,text_hash:mn(s.text)}})}function M(t){if(t.requests)return t.requests;if($(t.root)!==process.cwd()||!Y($(t.root,".agentx","db.sqlite")))return null;let e=Te({quiet:!0});if(!e)return null;let n=ir.get(e);return!n&&!zt(e)?null:(n||ir.set(e,n=new Xt(e)),n)}var ir=new WeakMap;function qu(t){if(t.plans)return t.plans;if(t.requests||$(t.root)!==process.cwd()||!Y($(t.root,".agentx","db.sqlite")))return null;let e=Te({quiet:!0});if(!e||!or(e))return null;let n=ar.get(e);return n||ar.set(e,n=new pe(e)),n}var ar=new WeakMap;function ai(t){let e=M(t);return e?e.listByState("needs_attention").map(n=>({key:`request:${n.id}`,kind:"request",title:P(n,120).headline,ask:`Not finished. Ask ${n.agentId} to pick it up again?`,yes:`hand it back to ${n.agentId}`,no:"drop the request",raised_by:n.agentId,created_at:new Date(n.createdAt).toISOString(),detail:D(`${n.attentionReason??"It needs attention"}. You said (${n.channel}): ${n.text}`),more:`agentx requests show ${n.id}`})):[]}var ur={card:Yo,schedule:Qo,agent:oi,memory:ei,wiki:ni,whatsapp:ri,email:si,content:ii,request:ai};function li(t,e){let n=t.expires?Date.parse(t.expires):1/0,r=e.expires?Date.parse(e.expires):1/0;return n!==r?n-r:(Date.parse(t.created_at)||0)-(Date.parse(e.created_at)||0)}function dr(t,e={}){let n=t.now??Date.now(),{snoozed:r}=v(t.root),s=[],o=[],i=0;for(let a of e.kinds??lr){let l;try{l=ur[a](t)}catch(u){o.push({kind:a,error:String(u?.message??u).slice(0,200)});continue}for(let u of l){let c=r[u.key];if(c&&Date.parse(c)>n){if(!e.includeSnoozed){i++;continue}u.snoozed_until=c}s.push(u)}}return s.sort(li),{items:s,snoozed:i,errors:o}}function ci(t){let e=t.indexOf(":");if(e<=0)return null;let n=t.slice(0,e),r=t.slice(e+1);return!lr.includes(n)||!r?null:{kind:n,ref:r}}function ui(t,e,n){switch(e){case"card":return G(t.root,n)?.status==="pending";case"wiki":return wn(Xe(t),n)?.status==="pending";case"whatsapp":return de(t.root,n)?.status==="pending";case"email":return An(t.root,n)?.status==="pending";case"content":return hn(t.root,n)?.status==="pending";default:return ur[e](t).some(r=>r.key===`${e}:${n}`)}}async function pr(t,e,n,r={}){let s=ci(e);if(!s)return{ok:!1,error:`unknown item "${e}": use a key from \`agentx approvals list\``};let{kind:o,ref:i}=s,a=t.now??Date.now(),l=r.by??"operator";if(n==="later"){if(!ui(t,o,i))return{ok:!1,error:`nothing waiting for "${e}"`};let c=r.laterHours&&r.laterHours>0?r.laterHours:24,d=new Date(a+c*36e5);return jn(t.root,e,d,a),{ok:!0,message:`${e} put off until ${d.toISOString()}`}}let u=n==="yes";switch(o){case"card":{let c=Rn(t.root,i,u?"yes":"no",{by:l,note:r.note,now:a,choice:r.choice,text:r.text});return c.ok?{ok:!0,message:`${e}: ${c.card.raised_by} will be told ${u?"yes":"no"}${c.card.choice?` (${c.card.choice}${c.card.choice_suggested?", the suggested option":""})`:""}`}:c}case"schedule":{let c=await(u?cn:un)(i,{configPath:q(t),reload:t.reload});return c.success?{ok:!0,message:c.message}:{ok:!1,error:c.message}}case"agent":{if(Ne(t.root)[i]?.kind!=="approval")return{ok:!1,error:`no new agent "${i}" waits for approval`};if(u)return Le(t.root,i,"approval"),{ok:!0,message:`${e}: approved. It runs once the daemon has loaded it; if it was added while the daemon was running, run: agentx daemon restart`};let c=[],d=await ae(p=>{en(p,`agents.${i}`);for(let[g,f]of Object.entries(p.crons??{}))f?.agent===i&&(delete p.crons[g],c.push(g))},{configPath:q(t),reload:t.reload});return d.success?(Le(t.root,i),{ok:!0,message:`${e}: removed from agentx.json${c.length?`, with its schedules ${c.join(", ")}`:""}; its folder is kept`}):{ok:!1,error:d.error||"could not remove it from agentx.json"}}case"memory":{let c=i.indexOf("/");if(c<=0)return{ok:!1,error:"memory keys look like memory:<agent>/<fact-id>"};let d=i.slice(0,c),p=i.slice(c+1);if(!cr(t.root).includes(d))return{ok:!1,error:`no memory for agent "${d}"`};let g=new Ce(t.root);return g.held(d).some(f=>f.id===p)?(g.review(d,p,u?"approved":"rejected",l),{ok:!0,message:`${e} ${u?"approved: the agent may use it":"rejected: it stays out of prompts"}`}):{ok:!1,error:`fact "${p}" isn't waiting for review`}}case"wiki":{let c=Xe(t),d=u?Sn(c,i,{by:l,force:r.force,now:a}):xn(c,i,{by:l,reason:r.note,now:a});return d.ok?{ok:!0,message:u?`${d.proposal.article.path} written to the shared wiki`:`${e} rejected`}:d}case"whatsapp":{let c=await Yn(t.root,i,u?"yes":"no",{by:l,now:a,send:t.sendWhatsApp});return c.ok?{ok:!0,message:u?`${e}: sent to ${c.draft.chat_name||c.draft.to}`:`${e}: dropped, nothing sent`}:c}case"email":{let c=t.sendEmail??Dn(ge(t),He(t)),d=await Tn(t.root,i,u?"yes":"no",{by:l,now:a,text:r.text,send:c});return d.ok?{ok:!0,message:u?`${e}: sent to ${d.draft.to}${d.draft.edited?" (as you edited it)":""}`:`${e}: dropped, nothing sent`}:d}case"content":{let c=t.publishContent??rr({config:ge(t),env:He(t)}),d=await yn(t.root,i,u?"yes":"no",{by:l,now:a,text:r.text,seen:r.seen,publish:c});if(!d.ok)return d;if(!u)return{ok:!0,message:`${e}: dropped, nothing published`};let p=K[d.draft.platform];return{ok:!0,message:d.draft.status==="posted"?`${e}: posted on ${p}${d.draft.url?` (${d.draft.url})`:""}`:`${e}: no ${p} connector is set, so it is saved ready to paste: ${d.draft.file}`}}case"request":{let c=M(t),d=c?.get(i);return!c||!d||d.state!=="needs_attention"?{ok:!1,error:`nothing waiting for "${e}"`}:u?Vn(q(t)).enabled?(c.requestPickup(i,a),{ok:!0,message:`${e}: ${d.agentId} will be asked to pick it up again`}):{ok:!1,error:"Requests are off, so nothing would hand it back. Turn them on (agentx requests settings --enabled on), or answer no to drop it."}:(c.close(i,"dropped",r.note?.trim()||`dropped by ${l}`,a),{ok:!0,message:`${e}: dropped`})}}}var di=3,pi=7,gi=50,Ge=120,fi=280,Ke=600,fr=36e5,mi=24*fr;function Hu(t){let e=new Set;for(let n of t)for(let r of n.runningTasks??[])r.traceId&&e.add(r.traceId);return e}function V(t,e){let n=t.replace(/\s+/g," ").trim();return n.length>e?`${n.slice(0,e-1)}\u2026`:n}var fe=t=>new Date(t).toISOString();function hi(t,e,n){let r=e.key.slice(0,Math.max(0,e.key.indexOf(":")))||"card";return{key:e.key,kind:r,column:"yours",node:t.node,nodeName:t.nodeName,title:V(e.title,Ge),...e.ask?{ask:V(e.ask,Ke)}:{},...e.detail?{facts:V(e.detail,fi)}:{},...e.recommend?{recommend:e.recommend}:{},...e.raisedBy?{agent:e.raisedBy}:{},...e.yes?{yes:e.yes}:{},...e.no?{no:e.no}:{},...e.choices?.length?{choices:e.choices}:{},...e.draft?{draft:e.draft}:{},...e.expires?{expires:e.expires}:{},...e.ifSilent?{ifSilent:e.ifSilent}:{},...e.createdAt?{askedAt:e.createdAt}:{},can:{answer:!0,later:!0,reply:n&&r==="request"}}}var bi={done:"Done",declined:"Declined",dropped:"Dropped"};function mr(t,e,n){let{record:r,links:s}=e,o=P(r,Ge),i={key:`request:${r.id}`,kind:"request",node:t.node,nodeName:t.nodeName,title:o.headline,need:o.need,...r.headline?{said:V(o.said,Ke)}:{},agent:r.agentId,askedAt:fe(r.createdAt),changedAt:fe(r.stateChangedAt??r.updatedAt)};switch(r.state){case"candidate":case"needs_attention":return null;case"waiting_owner":return s.some(a=>a.kind==="card"&&n.has(`card:${a.ref}`))?null:{...i,column:"yours",...r.question?{ask:V(r.question,Ke)}:{},can:{answer:!1,later:!1,reply:!0}};case"in_progress":case"waiting_other":{let a=s.some(u=>u.kind==="run"&&!!t.liveRuns?.has(u.ref)),l=t.now-r.updatedAt<(t.quietHours??di)*fr;return{...i,column:a||l?"agent":"quiet",...a?{live:a}:{},can:{answer:!1,later:!1,reply:!a}}}default:{let a=r.state==="done"?r.evidence:r.closeReason;return{...i,need:void 0,column:"done",changedAt:fe(r.closedAt??r.stateChangedAt??r.updatedAt),outcome:bi[r.state]??r.state,...a?{evidence:a}:{},can:{answer:!1,later:!1,reply:!1}}}}}function yi(t){return t.status==="decided"?t.verdict==="yes"?`Answered yes${t.choice?`: ${t.choice}`:""}`:"Answered no":t.status==="expired"?`No answer in time: ${t.outcome==="discard"?"discarded":t.outcome==="pause"?"paused":"kept"}`:"Closed by the agent"}function wi(t,e){return{key:`card:${e.id}`,kind:"card",column:"done",node:t.node,nodeName:t.nodeName,title:V(e.title,Ge),ask:e.ask,agent:e.raised_by,askedAt:e.created_at,...e.decided_at?{changedAt:e.decided_at}:{},outcome:yi(e),...e.resolution?{evidence:e.resolution}:{},can:{answer:!1,later:!1,reply:!1}}}var E=t=>t&&Date.parse(t)||0,gr=(t,e)=>t.map(n=>n[e]).filter(n=>!!E(n)).sort((n,r)=>E(n)-E(r))[0];function Je(t){let e=[],n=[];for(let s of t.inbox){s.error&&n.push(`What waits on ${s.nodeName} could not be read: ${s.error}`);for(let o of s.items)e.push(hi(s,o,s.node===t.node))}let r=hr(t,e);for(let s of t.requests??[]){let o=mr(t,s,r);o?.column==="yours"&&e.push(o)}return{cards:e,errors:n}}function hr(t,e){return new Set([...e.filter(n=>n.node===t.node).map(n=>n.key),...t.deferred??[]])}function zu(t){let e=Je(t.owner?{...t,requests:null}:t),n=t.owner?[...t.owner.items,...e.cards]:e.cards,r=t.owner?[...t.owner.errors,...e.errors]:e.errors,s=hr(t,n),o=[],i=[],a=[];for(let p of t.requests??[]){let g=mr(t,p,s);g&&g.column!=="yours"&&{agent:o,quiet:i,done:a}[g.column].push(g)}let l=t.now-(t.doneDays??pi)*mi;for(let p of t.cards)p.status!=="pending"&&E(p.decided_at)>=l&&a.push(wi(t,p));o.sort((p,g)=>E(g.changedAt)-E(p.changedAt)),i.sort((p,g)=>E(p.changedAt)-E(g.changedAt)),a.sort((p,g)=>E(g.changedAt)-E(p.changedAt));let u=a.filter(p=>E(p.changedAt)>=l).slice(0,gi),c=gr(n,"askedAt"),d=gr(i,"changedAt");return{ts:fe(t.now),cards:[...n,...o,...i,...u],figures:{yours:{count:n.length,...c?{oldest:c}:{},...t.owner?.later?{later:t.owner.later}:{}},agent:{count:o.length},quiet:{count:i.length,...d?{oldest:d}:{}},done:{count:u.length}},errors:r}}function ki(t){return{key:t.key,title:t.title,ask:t.ask,recommend:t.recommend,yes:t.yes,no:t.no,raisedBy:t.raised_by,expires:t.expires,...t.if_silent?{ifSilent:t.if_silent}:{},...t.choices?{choices:t.choices}:{},...t.draft?{draft:t.draft}:{},...t.detail?{detail:t.detail}:{},...t.created_at?{createdAt:t.created_at}:{}}}function Si(t,e,n){let r=t.map(s=>s.askedAt).filter(s=>!!s&&!!Date.parse(s)).sort((s,o)=>Date.parse(s)-Date.parse(o));return{count:t.length,later:e,...r[0]?{oldest:r[0]}:{},items:t,errors:n}}function Ju(t,e){let n=t.now??Date.now(),r=[],s=dr(t,{includeSnoozed:!0});for(let c of s.errors)r.push(`What waits (${c.kind}) could not be read: ${c.error}`);let o=s.items.filter(c=>!c.snoozed_until),i=new Set(s.items.filter(c=>c.snoozed_until).map(c=>c.key)),a=null;try{let c=M(t);c&&(a=c.listByState("waiting_owner").map(d=>({record:d,links:c.links(d.id)})))}catch(c){r.push(`Requests could not be read: ${c?.message??c}`)}let{cards:l,errors:u}=Je({now:n,node:e.url,nodeName:e.name,inbox:[{node:e.url,nodeName:e.name,items:o.map(ki)}],requests:a,deferred:i});return Si(l,i.size,[...r,...u])}import{readFileSync as xi}from"fs";var vi=1e4,br=/^[0-9a-f]{7,64}$/i;function Qu(t){let e=t.fetch??fetch;return async n=>{if(n==="self"){let i=t.self();return i&&br.test(i)?{source:n,commit:i}:{source:n,commit:null,error:"this build does not carry its commit (run from source?)"}}let r;try{r=await e(n,{signal:AbortSignal.timeout(vi)})}catch(i){return{source:n,commit:null,error:`could not be reached: ${String(i?.message??i).slice(0,200)}`}}if(!r.ok)return{source:n,commit:null,error:`HTTP ${r.status}`};let s=await r.json().catch(()=>null),o=t.field.split(".").reduce((i,a)=>i&&typeof i=="object"?i[a]:void 0,s);return typeof o=="string"&&br.test(o.trim())?{source:n,commit:o.trim()}:{source:n,commit:null,error:`no commit under "${t.field}"`}}}function ed(t){let e=t.requests.checkers,n=t.channels.github,r=e?.github?.token??n?.token;if(!r&&n?.tokenFile)try{r=xi(n.tokenFile,"utf-8").trim().split(`
58
- `)[0].trim()||void 0}catch{}let s=t.channels.gitlab;return{github:{apiUrl:e?.github?.apiUrl??"https://api.github.com",token:r},gitlab:{url:e?.gitlab?.url??s?.host??"https://gitlab.com",token:e?.gitlab?.token??s?.token}}}var yr=new Set(["127.0.0.1","::1","::ffff:127.0.0.1"]);function nd(t){return t==="/api/memory"||t.startsWith("/api/memory/")||t==="/approvals"||t.startsWith("/approvals/")||t==="/content"||t.startsWith("/content/")||t==="/screen"||t==="/native/notes"||t==="/requests"||t.startsWith("/requests/")||t==="/watchers"||t.startsWith("/watchers/")||t==="/follow-up"||t.startsWith("/follow-up/")||t==="/events/recent"||/^\/agents\/[^/]+\/events$/.test(t)||t==="/a2a/delegations"||t.startsWith("/a2a/delegations/")||t==="/traces"||t.startsWith("/traces/")||t==="/voice/history"||t.startsWith("/voice/history/")||t==="/voice/transcribe"||t==="/voice/speak"||t==="/app-files"||t==="/calls"||t.startsWith("/calls/")||t==="/webrtc/camera"||t.startsWith("/webrtc/camera/")||t==="/mesh/guests"||t.startsWith("/mesh/guests/")||t==="/wiki/agents"||t==="/wiki/entries"||t==="/wiki/articles"||t==="/wiki/article"||t==="/wiki/notes"||t==="/api/wiki/curate"||t==="/api/wiki/curate/restore"||t==="/api/signals/stopped"||t.startsWith("/api/signals/stopped/")||t==="/api/review-gate/reviews"||t==="/owner/told"||t==="/owner/presence"}function rd(t){return t==="/reload"||t==="/api/processes/kill"||t==="/send"||t==="/send/agent"||t==="/send/contact"||t==="/mesh/announce"||t==="/events"||t==="/voice/settings"||t==="/voice/preview"||/^\/api\/tasks\/[^/]+\/(cancel|followup)$/.test(t)||/^\/mesh\/guests\/[^/]+\/(pause|resume|end|update)$/.test(t)||/^\/crons\/[^/]+\/enabled$/.test(t)||/^\/channels\/[^/]+\/switch$/.test(t)||/^\/workflow-runs\/[^/]+\/cancel$/.test(t)||t==="/api/signals/stop"||t==="/api/signals/resume"||t==="/api/signals/drop"||t==="/api/signals/stop-all"||t==="/api/review-gate/replay"}function sd(t){return yr.has(t)}function od(t){if(t.foreignBrowser)return{allowed:!1,reason:"foreign-browser-origin"};if(t.enforcementDisabled)return{allowed:!0,reason:"disabled"};if(yr.has(t.remoteAddress))return{allowed:!0,reason:"loopback"};if(t.acceptedTokens.size===0)return{allowed:!0,reason:"no-tokens-configured"};let e=t.authorizationHeader||"",n=e.startsWith("Bearer ")?e.slice(7).trim():"";return n&&t.acceptedTokens.has(n)?{allowed:!0,reason:"token"}:{allowed:!1,reason:"missing-or-invalid-token"}}function id(t,e=process.env){let n=new Set;e.MESH_TOKEN&&n.add(e.MESH_TOKEN);for(let r of t.mesh?.peers||[])r.token&&n.add(r.token);return n}function ad(t,e,n=process.env){let r=o=>o.replace(/\/+$/,"");return(e===r(t.daemonUrl)?t.token:t.daemons.find(o=>r(o.url)===e)?.token)||n.MESH_TOKEN||void 0}function me(t){return(Array.isArray(t)?t[0]:t)?.trim()??""}function $i(t){try{return new URL(t).host.toLowerCase()}catch{return null}}function Ei(t=process.env){return new Set((t.AGENTX_ALLOWED_ORIGINS||"").split(",").map(e=>e.trim().replace(/\/+$/,"").toLowerCase()).filter(Boolean))}function cd(t,e=Ei()){let n=me(t.origin);if(n){if(e.has(n.replace(/\/+$/,"").toLowerCase()))return"same-origin";let s=$i(n),o=[me(t.host),me(t["x-forwarded-host"])].filter(Boolean).map(i=>i.toLowerCase());return s&&o.includes(s)?"same-origin":"foreign"}let r=me(t["sec-fetch-site"]).toLowerCase();return r==="cross-site"||r==="same-site"?"foreign":"none"}function ud(t){let e=(t||"GET").toUpperCase();return e!=="GET"&&e!=="HEAD"}import{existsSync as Vr,mkdirSync as ea,readFileSync as ta,renameSync as na,writeFileSync as ra}from"fs";import{homedir as sa}from"os";import{dirname as oa,join as ia}from"path";import{execFile as Pi,execFileSync as Mi}from"child_process";import{execFileSync as _i}from"child_process";import{existsSync as kr,mkdirSync as Ri,readdirSync as Ai,readFileSync as Sr,renameSync as Ii,writeFileSync as Ti}from"fs";import{homedir as xr}from"os";import{join as Ze}from"path";var _="siri:",vr="com.apple.ttsbundle.gryphon-neural_",$r=t=>!!t&&t.startsWith(vr),Di=["/usr/bin/say","/usr/bin/defaults","/usr/bin/plutil"],Ci=()=>{try{return _i("/usr/bin/defaults",["read","com.apple.Accessibility"],{stdio:"ignore",timeout:5e3}),!0}catch{return!1}},Ye;function Qe(t={}){let e=t.platform!==void 0||t.exists!==void 0||t.prefDomain!==void 0;if(!e&&Ye!==void 0)return Ye;let{platform:n=process.platform,exists:r=kr,prefDomain:s=Ci}=t,o=n==="darwin"&&Di.every(i=>r(i))&&s();return e||(Ye=o),o}var Er=["/System/Library/AssetsV2/com_apple_MobileAsset_Trial_Siri_SiriTextToSpeech/purpose_auto","/System/Library/AssetsV2/com_apple_MobileAsset_UAF_Siri_TextToSpeech/purpose_auto"],_r={aaron:"male",damon:"male",daniel:"male",pierre:"male",samer:"male",arthur:"male",gordon:"male",martin:"male",nora:"female",simone:"female",marie:"female",soha:"female",martha:"female",catherine:"female",helena:"female",nicky:"female"},et=t=>_r[t.toLowerCase()]??null;function he(t){let e=/^com\.apple\.ttsbundle\.gryphon-neural_([a-z]+)_([a-z]{2}-[A-Z]{2})_premium$/.exec(t);return e?{name:e[1],locale:e[2]}:null}var Ni=/com\.apple\.siri\.tts\.voice\.([a-z]{2})_([A-Z]{2})\.([a-z]+)\.neural\.premium/g;function Li(t){let e=new Map;for(let n of t)for(let[,r,s,o]of n.matchAll(Ni)){let i=`${r}-${s}`,a=`${vr}${o}_${i}_premium`;e.has(a)||e.set(a,{id:a,name:o[0].toUpperCase()+o.slice(1),locale:i,quality:"premium",gender:_r[o]??null,siri:!0})}return[...e.values()]}function be(t=Er,e={}){if(!Qe(e))return[];let n=[];for(let r of t){let s;try{s=Ai(r)}catch{continue}for(let o of s)try{n.push(Sr(Ze(r,o,"Info.plist"),"latin1"))}catch{}}return Li(n)}var wr=`#!/bin/sh
58
+ `)[0].trim()||void 0}catch{}let s=t.channels.gitlab;return{github:{apiUrl:e?.github?.apiUrl??"https://api.github.com",token:r},gitlab:{url:e?.gitlab?.url??s?.host??"https://gitlab.com",token:e?.gitlab?.token??s?.token}}}var yr=new Set(["127.0.0.1","::1","::ffff:127.0.0.1"]);function nd(t){return t==="/api/memory"||t.startsWith("/api/memory/")||t==="/approvals"||t.startsWith("/approvals/")||t==="/content"||t.startsWith("/content/")||t==="/screen"||t==="/native/notes"||t==="/requests"||t.startsWith("/requests/")||t==="/watchers"||t.startsWith("/watchers/")||t==="/follow-up"||t.startsWith("/follow-up/")||t==="/events/recent"||/^\/agents\/[^/]+\/events$/.test(t)||t==="/a2a/delegations"||t.startsWith("/a2a/delegations/")||t==="/traces"||t.startsWith("/traces/")||t==="/voice/history"||t.startsWith("/voice/history/")||t==="/voice/transcribe"||t==="/voice/speak"||t==="/app-files"||t==="/calls"||t.startsWith("/calls/")||t==="/webrtc/camera"||t.startsWith("/webrtc/camera/")||t==="/mesh/guests"||t.startsWith("/mesh/guests/")||t==="/wiki/agents"||t==="/wiki/entries"||t==="/wiki/articles"||t==="/wiki/article"||t==="/wiki/notes"||t==="/api/wiki/curate"||t==="/api/wiki/curate/restore"||t==="/api/signals/stopped"||t.startsWith("/api/signals/stopped/")||t==="/api/review-gate/reviews"||t==="/owner/told"||t==="/owner/presence"}function rd(t){return t==="/reload"||t==="/api/processes/kill"||t==="/send"||t==="/send/agent"||t==="/send/contact"||t==="/mesh/announce"||t==="/events"||t==="/voice/settings"||t==="/voice/preview"||/^\/api\/tasks\/[^/]+\/(cancel|followup)$/.test(t)||/^\/mesh\/guests\/[^/]+\/(pause|resume|end|update)$/.test(t)||/^\/crons\/[^/]+\/enabled$/.test(t)||/^\/channels\/[^/]+\/switch$/.test(t)||/^\/workflow-runs\/[^/]+\/cancel$/.test(t)||t==="/api/signals/stop"||t==="/api/signals/resume"||t==="/api/signals/drop"||t==="/api/signals/stop-all"||t==="/api/signals/stop-all/report"||t==="/api/review-gate/replay"}function sd(t){return yr.has(t)}function od(t){if(t.foreignBrowser)return{allowed:!1,reason:"foreign-browser-origin"};if(t.enforcementDisabled)return{allowed:!0,reason:"disabled"};if(yr.has(t.remoteAddress))return{allowed:!0,reason:"loopback"};if(t.acceptedTokens.size===0)return{allowed:!0,reason:"no-tokens-configured"};let e=t.authorizationHeader||"",n=e.startsWith("Bearer ")?e.slice(7).trim():"";return n&&t.acceptedTokens.has(n)?{allowed:!0,reason:"token"}:{allowed:!1,reason:"missing-or-invalid-token"}}function id(t,e=process.env){let n=new Set;e.MESH_TOKEN&&n.add(e.MESH_TOKEN);for(let r of t.mesh?.peers||[])r.token&&n.add(r.token);return n}function ad(t,e,n=process.env){let r=o=>o.replace(/\/+$/,"");return(e===r(t.daemonUrl)?t.token:t.daemons.find(o=>r(o.url)===e)?.token)||n.MESH_TOKEN||void 0}function me(t){return(Array.isArray(t)?t[0]:t)?.trim()??""}function $i(t){try{return new URL(t).host.toLowerCase()}catch{return null}}function Ei(t=process.env){return new Set((t.AGENTX_ALLOWED_ORIGINS||"").split(",").map(e=>e.trim().replace(/\/+$/,"").toLowerCase()).filter(Boolean))}function cd(t,e=Ei()){let n=me(t.origin);if(n){if(e.has(n.replace(/\/+$/,"").toLowerCase()))return"same-origin";let s=$i(n),o=[me(t.host),me(t["x-forwarded-host"])].filter(Boolean).map(i=>i.toLowerCase());return s&&o.includes(s)?"same-origin":"foreign"}let r=me(t["sec-fetch-site"]).toLowerCase();return r==="cross-site"||r==="same-site"?"foreign":"none"}function ud(t){let e=(t||"GET").toUpperCase();return e!=="GET"&&e!=="HEAD"}import{existsSync as Vr,mkdirSync as ea,readFileSync as ta,renameSync as na,writeFileSync as ra}from"fs";import{homedir as sa}from"os";import{dirname as oa,join as ia}from"path";import{execFile as Pi,execFileSync as Mi}from"child_process";import{execFileSync as _i}from"child_process";import{existsSync as kr,mkdirSync as Ri,readdirSync as Ai,readFileSync as Sr,renameSync as Ii,writeFileSync as Ti}from"fs";import{homedir as xr}from"os";import{join as Ze}from"path";var _="siri:",vr="com.apple.ttsbundle.gryphon-neural_",$r=t=>!!t&&t.startsWith(vr),Di=["/usr/bin/say","/usr/bin/defaults","/usr/bin/plutil"],Ci=()=>{try{return _i("/usr/bin/defaults",["read","com.apple.Accessibility"],{stdio:"ignore",timeout:5e3}),!0}catch{return!1}},Ye;function Qe(t={}){let e=t.platform!==void 0||t.exists!==void 0||t.prefDomain!==void 0;if(!e&&Ye!==void 0)return Ye;let{platform:n=process.platform,exists:r=kr,prefDomain:s=Ci}=t,o=n==="darwin"&&Di.every(i=>r(i))&&s();return e||(Ye=o),o}var Er=["/System/Library/AssetsV2/com_apple_MobileAsset_Trial_Siri_SiriTextToSpeech/purpose_auto","/System/Library/AssetsV2/com_apple_MobileAsset_UAF_Siri_TextToSpeech/purpose_auto"],_r={aaron:"male",damon:"male",daniel:"male",pierre:"male",samer:"male",arthur:"male",gordon:"male",martin:"male",nora:"female",simone:"female",marie:"female",soha:"female",martha:"female",catherine:"female",helena:"female",nicky:"female"},et=t=>_r[t.toLowerCase()]??null;function he(t){let e=/^com\.apple\.ttsbundle\.gryphon-neural_([a-z]+)_([a-z]{2}-[A-Z]{2})_premium$/.exec(t);return e?{name:e[1],locale:e[2]}:null}var Ni=/com\.apple\.siri\.tts\.voice\.([a-z]{2})_([A-Z]{2})\.([a-z]+)\.neural\.premium/g;function Li(t){let e=new Map;for(let n of t)for(let[,r,s,o]of n.matchAll(Ni)){let i=`${r}-${s}`,a=`${vr}${o}_${i}_premium`;e.has(a)||e.set(a,{id:a,name:o[0].toUpperCase()+o.slice(1),locale:i,quality:"premium",gender:_r[o]??null,siri:!0})}return[...e.values()]}function be(t=Er,e={}){if(!Qe(e))return[];let n=[];for(let r of t){let s;try{s=Ai(r)}catch{continue}for(let o of s)try{n.push(Sr(Ze(r,o,"Info.plist"),"latin1"))}catch{}}return Li(n)}var wr=`#!/bin/sh
59
59
  # Written by agentx; shared by the daemon and AgentX Voice. Do not edit.
60
60
  # siri-say.sh [voice] < text speak one line. A Siri voice id switches
61
61
  # the OS default for it; any other id is
@@ -577,4 +577,4 @@ Document the arguments, commands, or files the skill expects. Example:
577
577
  claude-code ${qt(t)} --arg value
578
578
  \`\`\`
579
579
  `}Yt();var Zs={maxPixels:12e5,timeoutMs:5e3,intervalMs:100,changeThreshold:.015,stableMs:400,regions:{},buffer:{enabled:!1,seconds:10,fps:2,region:"screen",maxPixels:3e5}};function Qs(t){return{...Zs,...t??{},regions:{...t?.regions??{}},buffer:{...Zs.buffer,...t?.buffer??{}}}}function af(t){try{return Qs(Jt(t).screen)}catch{return Qs(void 0)}}var Lc=/^[a-z][\w-]*$/,eo=["window","screen","menubar","notifications"];function se(t,e,n,r){let s=Number(t);if(t===""||t===null||!Number.isFinite(s)||!n(s))throw new Error(`${e} must be ${r}`);return s}var Re=(t,e)=>se(t,e,n=>Number.isInteger(n)&&n>0,"a whole number above 0");function to(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 lf(t,e){let n={...t??{}};if("maxPixels"in e&&(n.maxPixels=Re(e.maxPixels,"maxPixels")),"timeoutMs"in e&&(n.timeoutMs=Re(e.timeoutMs,"timeoutMs")),"intervalMs"in e&&(n.intervalMs=Re(e.intervalMs,"intervalMs")),"stableMs"in e&&(n.stableMs=se(e.stableMs,"stableMs",s=>Number.isInteger(s)&&s>=0,"a whole number, 0 or more")),"changeThreshold"in e&&(n.changeThreshold=se(e.changeThreshold,"changeThreshold",s=>s>=0&&s<=1,"between 0 and 1")),e.regions&&typeof e.regions=="object"){let s={...n.regions??{}};for(let[o,i]of Object.entries(e.regions)){if(!Lc.test(o))throw new Error(`region name "${o}" must be lowercase letters, digits, - or _`);i===null?delete s[o]:s[o]=to(i)}n.regions=s}if(e.buffer&&typeof e.buffer=="object"){let s=e.buffer,o={...n.buffer??{}};"enabled"in s&&(o.enabled=!!s.enabled),"seconds"in s&&(o.seconds=se(s.seconds,"buffer.seconds",i=>i>0&&i<=120,"above 0 and at most 120")),"fps"in s&&(o.fps=se(s.fps,"buffer.fps",i=>i>0&&i<=10,"above 0 and at most 10")),"maxPixels"in s&&(o.maxPixels=Re(s.maxPixels,"buffer.maxPixels")),"region"in s&&(o.region=String(s.region).trim()),n.buffer=o}let r=n.buffer?.region;if(r!==void 0&&!eo.includes(r)&&!n.regions?.[r])try{to(r)}catch{throw new Error(`buffer.region "${r}" is not a region \u2014 use ${[...eo,...Object.keys(n.regions??{})].join(", ")}, or x,y,w,h`)}return n}export{Nn as a,Mc as b,kt as c,Ra as d,Aa as e,Gd as f,Jd as g,Yd as h,ep as i,tp as j,np as k,Zr as l,Qr as m,rp as n,es as o,op as p,ap as q,L as r,ts as s,k as t,jc as u,ss as v,gp as w,hp as x,is as y,bp as z,as as A,yp as B,ee as C,tl as D,wp as E,kp as F,cs as G,nu as H,Oo as I,lu as J,Yn as K,uu as L,v as M,zc as N,Xc as O,yu as P,pe as Q,wu as R,Vn as S,Qc as T,M as U,qu as V,dr as W,pr as X,pi as Y,gi as Z,Hu as _,zu as $,ki as aa,Ju as ba,ds as ca,vp as da,Qu as ea,ed as fa,Kr as ga,dt as ha,ka as ia,$s as ja,Qp as ka,eg as la,Wl as ma,sg as na,Ts as oa,og as pa,ig as qa,pg as ra,Yl as sa,gg as ta,nd as ua,rd as va,sd as wa,od as xa,id as ya,ad as za,cd as Aa,ud as Ba,wd as Ca,nt as Da,kd as Ea,Sd as Fa,Z as Ga,Q as Ha,rc as Ia,xg as Ja,vg as Ka,$g as La,Eg as Ma,Tt as Na,_g as Oa,ot as Pa,it as Qa,ke as Ra,zi as Sa,Ki as Ta,_d as Ua,lt as Va,ct as Wa,Gi as Xa,Ji as Ya,Mr as Za,jr as _a,Rd as $a,Qi as ab,Ad as bb,aa as cb,ua as db,ut as eb,pa as fb,qr as gb,O as hb,js as ib,qs as jb,Vs as kb,Ct as lb,Cg as mb,pc as nb,Hs as ob,zs as pb,Vg as qb,Bg as rb,Ac as sb,Hg as tb,Ks as ub,Se as vb,Wd as wb,yt as xb,Xd as yb,Gg as zb,Jg as Ab,Yg as Bb,Zg as Cb,Qg as Db,ef as Eb,tf as Fb,nf as Gb,rf as Hb,Zs as Ib,Qs as Jb,af as Kb,eo as Lb,lf as Mb};
580
- //# sourceMappingURL=chunk-BAAKV4HK.js.map
580
+ //# sourceMappingURL=chunk-7FGJOVML.js.map