agentix-cli 0.156.0 → 0.157.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/{App-NSZBO2ZD.js → App-AFRBV666.js} +2 -2
- package/dist/{ChatApp-HDLLCAE6.js → ChatApp-EBTSY27Z.js} +2 -2
- package/dist/{absorb-eval-A6HIYEBY.js → absorb-eval-VUJFGASJ.js} +2 -2
- package/dist/agent-EA55CR6J.js +2 -0
- package/dist/{board-dashboard-FPNEYUYE.js → board-dashboard-2X72LAVO.js} +4 -4
- package/dist/{board-dashboard-FPNEYUYE.js.map → board-dashboard-2X72LAVO.js.map} +1 -1
- package/dist/{chunk-SP323WDN.js → chunk-2NLPGLLL.js} +2 -2
- package/dist/{chunk-PXJWLJWA.js → chunk-3HO6CHT6.js} +3 -3
- package/dist/{chunk-FRSHCCRH.js → chunk-3ZMVYNFH.js} +2 -2
- package/dist/{chunk-YZHYE4LQ.js → chunk-4UJ7S2DD.js} +6 -6
- package/dist/chunk-4UJ7S2DD.js.map +1 -0
- package/dist/{chunk-HV7EIZUB.js → chunk-4UMMAI3Z.js} +2 -2
- package/dist/{chunk-C5W2QXHG.js → chunk-5OZMFHIZ.js} +3 -3
- package/dist/chunk-5OZMFHIZ.js.map +1 -0
- package/dist/{chunk-TO7TTQAW.js → chunk-6HNCLOHS.js} +2 -2
- package/dist/{chunk-JNG3P5V2.js → chunk-6QLRRSKU.js} +21 -21
- package/dist/chunk-6QLRRSKU.js.map +1 -0
- package/dist/{chunk-DWESRGS4.js → chunk-B3I4EBLE.js} +2 -2
- package/dist/{chunk-B2DFT7QY.js → chunk-BY2AAMOO.js} +2 -2
- package/dist/{chunk-U23LVMMZ.js → chunk-CCSG7MSD.js} +2 -2
- package/dist/{chunk-EVJ3A5EI.js → chunk-CLNOAP6S.js} +2 -2
- package/dist/{chunk-EVJ3A5EI.js.map → chunk-CLNOAP6S.js.map} +1 -1
- package/dist/{chunk-GJMTN72H.js → chunk-E4O32ZYZ.js} +2 -2
- package/dist/{chunk-L6LJEBXY.js → chunk-EWBUH2IU.js} +2 -2
- package/dist/{chunk-7U6YGXWE.js → chunk-FEF432WU.js} +2 -2
- package/dist/{chunk-GNRECXDY.js → chunk-FKYIYJF7.js} +2 -2
- package/dist/{chunk-5BOSHX42.js → chunk-GKQVXA3P.js} +264 -250
- package/dist/chunk-GKQVXA3P.js.map +1 -0
- package/dist/{chunk-YSRH6AXN.js → chunk-I5FRA3JS.js} +8 -8
- package/dist/{chunk-YSRH6AXN.js.map → chunk-I5FRA3JS.js.map} +1 -1
- package/dist/{chunk-7JRBOEWC.js → chunk-JJV7O7YK.js} +2 -2
- package/dist/{chunk-E7LKRV7R.js → chunk-KPNAXVET.js} +2 -2
- package/dist/{chunk-B4CZHRRV.js → chunk-MBPYC6QF.js} +2 -2
- package/dist/{chunk-HH3UZA4Y.js → chunk-MJHAMHEF.js} +2 -2
- package/dist/{chunk-HH3UZA4Y.js.map → chunk-MJHAMHEF.js.map} +1 -1
- package/dist/{chunk-RKGDYAOV.js → chunk-NY5ZY2WV.js} +2 -2
- package/dist/chunk-O5H6BCUN.js +77 -0
- package/dist/chunk-O5H6BCUN.js.map +1 -0
- package/dist/{chunk-HW4BVIWX.js → chunk-OABGAL3N.js} +2 -2
- package/dist/{chunk-W2KZCY7H.js → chunk-OYPKAYCH.js} +2 -2
- package/dist/{chunk-NGSEAAUR.js → chunk-PA3KFAXH.js} +2 -2
- package/dist/{chunk-U7BSIXY5.js → chunk-R4HBEILQ.js} +2 -2
- package/dist/{chunk-IVBCCSDR.js → chunk-TCC56PYX.js} +2 -2
- package/dist/{chunk-ATCWYDB2.js → chunk-YLFNY4OF.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{client-LOLBLWQH.js → client-7ZJZT5H7.js} +2 -2
- package/dist/{compaction-PFXWL4H7.js → compaction-GSUWZYBK.js} +3 -3
- package/dist/{config-XIHDFV7R.js → config-NFDEJ3NB.js} +2 -2
- package/dist/{config-mutate-GLGD4OXG.js → config-mutate-JYW5G7T6.js} +2 -2
- package/dist/config-mutator-OMWL5XHO.js +2 -0
- package/dist/{context-planner-DJB6CKY6.js → context-planner-2XBAPQ3S.js} +2 -2
- package/dist/{contributions-ZWZKNT7F.js → contributions-TMZ3DYY5.js} +2 -2
- package/dist/{doctor-P7TUOQJL.js → doctor-FTUB5ITL.js} +2 -2
- package/dist/{follow-up-tool-PS4ZST7N.js → follow-up-tool-FNO2IG72.js} +2 -2
- package/dist/heal-KCM6JYUK.js +2 -0
- package/dist/hub-MOAG5BEQ.js +2 -0
- package/dist/index.d.ts +509 -373
- package/dist/index.js +1 -1
- package/dist/memory-extract-PFJDJNBH.js +2 -0
- package/dist/{program-K3YRP5QZ.js → program-HWWXPPS5.js} +24 -24
- package/dist/program-HWWXPPS5.js.map +1 -0
- package/dist/{promote-U4MVP653.js → promote-AAEZYPBP.js} +2 -2
- package/dist/{providers-BDJXGHEY.js → providers-VVT2OBXA.js} +2 -2
- package/dist/{query-CHK6IY4Z.js → query-2EWUIUIT.js} +2 -2
- package/dist/{query-settings-NZT2BKX5.js → query-settings-7CB37D6D.js} +2 -2
- package/dist/{registry-VAZ7KJAX.js → registry-EZMQ2OYY.js} +2 -2
- package/dist/{request-planner-XOFWVB6L.js → request-planner-2AU3VK4P.js} +2 -2
- package/dist/{review-candidates-IYXJRG5K.js → review-candidates-CIEGXF7K.js} +2 -2
- package/dist/routing-XJ25QONX.js +2 -0
- package/dist/schedule-tool-5T4CH4CM.js +2 -0
- package/dist/{scheduler-O35FPVFM.js → scheduler-UKJWO2TR.js} +2 -2
- package/dist/{seat-C3D3GZCW.js → seat-JWRCBUKR.js} +2 -2
- package/dist/{select-AA7JJN2D.js → select-KIDX6WWF.js} +2 -2
- package/dist/{set-enabled-IDPKRK5C.js → set-enabled-F4D3VWKI.js} +2 -2
- package/dist/tool-7FFJSFTS.js +6 -0
- package/dist/tool-7FFJSFTS.js.map +1 -0
- package/dist/{tool-35X6HKUQ.js → tool-YSS2C2UX.js} +2 -2
- package/dist/wiki-PSUAAREB.js +2 -0
- package/dist/wiki-enrich-TJIL4B3V.js +2 -0
- package/package.json +2 -1
- package/dist/agent-PSZY33DQ.js +0 -2
- package/dist/chunk-5BOSHX42.js.map +0 -1
- package/dist/chunk-C5W2QXHG.js.map +0 -1
- package/dist/chunk-HM6VPTXV.js +0 -76
- package/dist/chunk-HM6VPTXV.js.map +0 -1
- package/dist/chunk-JNG3P5V2.js.map +0 -1
- package/dist/chunk-YZHYE4LQ.js.map +0 -1
- package/dist/config-mutator-OC6ZQQCR.js +0 -2
- package/dist/heal-RGM7X2ZG.js +0 -2
- package/dist/hub-5FDLTQA4.js +0 -2
- package/dist/memory-extract-GHLBXV4H.js +0 -2
- package/dist/program-K3YRP5QZ.js.map +0 -1
- package/dist/routing-ZMRPUXLA.js +0 -2
- package/dist/schedule-tool-EU2ILYUI.js +0 -2
- package/dist/tool-NWVSRBIK.js +0 -6
- package/dist/tool-NWVSRBIK.js.map +0 -1
- package/dist/wiki-I7BSMBAC.js +0 -2
- package/dist/wiki-enrich-G4GUITL4.js +0 -2
- /package/dist/{App-NSZBO2ZD.js.map → App-AFRBV666.js.map} +0 -0
- /package/dist/{ChatApp-HDLLCAE6.js.map → ChatApp-EBTSY27Z.js.map} +0 -0
- /package/dist/{absorb-eval-A6HIYEBY.js.map → absorb-eval-VUJFGASJ.js.map} +0 -0
- /package/dist/{agent-PSZY33DQ.js.map → agent-EA55CR6J.js.map} +0 -0
- /package/dist/{chunk-SP323WDN.js.map → chunk-2NLPGLLL.js.map} +0 -0
- /package/dist/{chunk-PXJWLJWA.js.map → chunk-3HO6CHT6.js.map} +0 -0
- /package/dist/{chunk-FRSHCCRH.js.map → chunk-3ZMVYNFH.js.map} +0 -0
- /package/dist/{chunk-HV7EIZUB.js.map → chunk-4UMMAI3Z.js.map} +0 -0
- /package/dist/{chunk-TO7TTQAW.js.map → chunk-6HNCLOHS.js.map} +0 -0
- /package/dist/{chunk-DWESRGS4.js.map → chunk-B3I4EBLE.js.map} +0 -0
- /package/dist/{chunk-B2DFT7QY.js.map → chunk-BY2AAMOO.js.map} +0 -0
- /package/dist/{chunk-U23LVMMZ.js.map → chunk-CCSG7MSD.js.map} +0 -0
- /package/dist/{chunk-GJMTN72H.js.map → chunk-E4O32ZYZ.js.map} +0 -0
- /package/dist/{chunk-L6LJEBXY.js.map → chunk-EWBUH2IU.js.map} +0 -0
- /package/dist/{chunk-7U6YGXWE.js.map → chunk-FEF432WU.js.map} +0 -0
- /package/dist/{chunk-GNRECXDY.js.map → chunk-FKYIYJF7.js.map} +0 -0
- /package/dist/{chunk-7JRBOEWC.js.map → chunk-JJV7O7YK.js.map} +0 -0
- /package/dist/{chunk-E7LKRV7R.js.map → chunk-KPNAXVET.js.map} +0 -0
- /package/dist/{chunk-B4CZHRRV.js.map → chunk-MBPYC6QF.js.map} +0 -0
- /package/dist/{chunk-RKGDYAOV.js.map → chunk-NY5ZY2WV.js.map} +0 -0
- /package/dist/{chunk-HW4BVIWX.js.map → chunk-OABGAL3N.js.map} +0 -0
- /package/dist/{chunk-W2KZCY7H.js.map → chunk-OYPKAYCH.js.map} +0 -0
- /package/dist/{chunk-NGSEAAUR.js.map → chunk-PA3KFAXH.js.map} +0 -0
- /package/dist/{chunk-U7BSIXY5.js.map → chunk-R4HBEILQ.js.map} +0 -0
- /package/dist/{chunk-IVBCCSDR.js.map → chunk-TCC56PYX.js.map} +0 -0
- /package/dist/{chunk-ATCWYDB2.js.map → chunk-YLFNY4OF.js.map} +0 -0
- /package/dist/{client-LOLBLWQH.js.map → client-7ZJZT5H7.js.map} +0 -0
- /package/dist/{compaction-PFXWL4H7.js.map → compaction-GSUWZYBK.js.map} +0 -0
- /package/dist/{config-XIHDFV7R.js.map → config-NFDEJ3NB.js.map} +0 -0
- /package/dist/{config-mutate-GLGD4OXG.js.map → config-mutate-JYW5G7T6.js.map} +0 -0
- /package/dist/{config-mutator-OC6ZQQCR.js.map → config-mutator-OMWL5XHO.js.map} +0 -0
- /package/dist/{context-planner-DJB6CKY6.js.map → context-planner-2XBAPQ3S.js.map} +0 -0
- /package/dist/{contributions-ZWZKNT7F.js.map → contributions-TMZ3DYY5.js.map} +0 -0
- /package/dist/{doctor-P7TUOQJL.js.map → doctor-FTUB5ITL.js.map} +0 -0
- /package/dist/{follow-up-tool-PS4ZST7N.js.map → follow-up-tool-FNO2IG72.js.map} +0 -0
- /package/dist/{heal-RGM7X2ZG.js.map → heal-KCM6JYUK.js.map} +0 -0
- /package/dist/{hub-5FDLTQA4.js.map → hub-MOAG5BEQ.js.map} +0 -0
- /package/dist/{memory-extract-GHLBXV4H.js.map → memory-extract-PFJDJNBH.js.map} +0 -0
- /package/dist/{promote-U4MVP653.js.map → promote-AAEZYPBP.js.map} +0 -0
- /package/dist/{providers-BDJXGHEY.js.map → providers-VVT2OBXA.js.map} +0 -0
- /package/dist/{query-CHK6IY4Z.js.map → query-2EWUIUIT.js.map} +0 -0
- /package/dist/{query-settings-NZT2BKX5.js.map → query-settings-7CB37D6D.js.map} +0 -0
- /package/dist/{registry-VAZ7KJAX.js.map → registry-EZMQ2OYY.js.map} +0 -0
- /package/dist/{request-planner-XOFWVB6L.js.map → request-planner-2AU3VK4P.js.map} +0 -0
- /package/dist/{review-candidates-IYXJRG5K.js.map → review-candidates-CIEGXF7K.js.map} +0 -0
- /package/dist/{routing-ZMRPUXLA.js.map → routing-XJ25QONX.js.map} +0 -0
- /package/dist/{schedule-tool-EU2ILYUI.js.map → schedule-tool-5T4CH4CM.js.map} +0 -0
- /package/dist/{scheduler-O35FPVFM.js.map → scheduler-UKJWO2TR.js.map} +0 -0
- /package/dist/{seat-C3D3GZCW.js.map → seat-JWRCBUKR.js.map} +0 -0
- /package/dist/{select-AA7JJN2D.js.map → select-KIDX6WWF.js.map} +0 -0
- /package/dist/{set-enabled-IDPKRK5C.js.map → set-enabled-F4D3VWKI.js.map} +0 -0
- /package/dist/{tool-35X6HKUQ.js.map → tool-YSS2C2UX.js.map} +0 -0
- /package/dist/{wiki-I7BSMBAC.js.map → wiki-PSUAAREB.js.map} +0 -0
- /package/dist/{wiki-enrich-G4GUITL4.js.map → wiki-enrich-TJIL4B3V.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ne}from"./chunk-GTJIKXDB.js";import{A as dn,H as mn,j as O}from"./chunk-
|
|
1
|
+
import{a as Ne}from"./chunk-GTJIKXDB.js";import{A as dn,H as mn,j as O}from"./chunk-MJHAMHEF.js";import{a as w}from"./chunk-7LN4VKDU.js";import{f as pn,i as gn,k as De,l as Ce,n as X,o as W,q as fn}from"./chunk-LQS27HSV.js";import{t as ln,u as cn}from"./chunk-KPNAXVET.js";import{d as on,e as an}from"./chunk-AQASR6KR.js";import{b as un}from"./chunk-2VDO2HEK.js";import{a as tn,b as nn,d as rn,e as sn}from"./chunk-MNG2AMKZ.js";import{g as Jt,h as Yt,i as Zt,k as Qt,l as en}from"./chunk-E4O32ZYZ.js";import{a as Kt,c as Gt}from"./chunk-KP7KDLZ2.js";import{X as Xt,Z as oe,_ as Ie,aa as Te,b as Ae}from"./chunk-OABGAL3N.js";import{q as zt}from"./chunk-OYPKAYCH.js";import{a as Bt,b as Ht}from"./chunk-EWBUH2IU.js";import{$ as Ut,Ya as Ee,_ as Mt,aa as Ft,ba as Wt,eb as qt,fb as jt,n as se,o as Ot,ob as Vt,p as Pt,q as Cs}from"./chunk-O5H6BCUN.js";import{a as Re,h as Ns}from"./chunk-BRK6M6LA.js";import{f as _e,n as Ls}from"./chunk-UIBUZ2N3.js";import{existsSync as Os,readdirSync as Ps,readFileSync as Ms,statSync as Us}from"fs";import{resolve as Fs}from"path";function hn(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),d=a.filter(f=>n-f.at>s&&n-f.at<=s*2),c=l.filter(f=>f.status==="failed").length,u=a.filter(f=>f.status==="paused").length,p=a.length?Math.max(...a.map(f=>f.at)):null,g=a.length?d.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:d.length,failed:c,paused:u}}).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 ie=new Map;function ec(t,e=1e3){if(!Os(t))return[];let n=Ps(t).filter(o=>o.endsWith(".jsonl")).map(o=>{let i=Fs(t,o);return{path:i,mtime:Us(i).mtimeMs}}).sort((o,i)=>i.mtime-o.mtime).slice(0,e),r=new Set(n.map(o=>o.path));for(let o of ie.keys())r.has(o)||ie.delete(o);let s=[];for(let{path:o,mtime:i}of n){let a=ie.get(o);if(a&&a.mtime===i){a.summary&&s.push(a.summary);continue}let l=Ws(o,i);ie.set(o,{mtime:i,summary:l}),l&&s.push(l)}return s}function Ws(t,e){try{let n=Ms(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 qs={failStreak:3,disabledDays:30,missedFires:2,graceMs:15*6e4},k={routines:200,summary:160,filters:6,filterValue:60,text:120},js=(t,e,n)=>{try{return zt(t,e,n)}catch{return null}},bn=864e5;function sc(t){let e=t.now??Date.now(),n={...qs,...t.thresholds},r=t.nextFire??js,s=[];for(let a of t.crons){let l=t.cronRuns.get(a.id)??[],d=a.timezone||"UTC",c=l.map(g=>({at:Date.parse(g.startedAt),status:g.status})),u=l[0],p={id:`cron:${a.id}`,source:"cron",kind:"schedule",name:E(a.id,k.text),trigger:{schedule:E(a.schedule,k.text),timezone:d},agent:a.agent||null,enabled:a.enabled,state:a.enabled?"enabled":"disabled",nextRunAt:a.enabled?Le(a.nextRun)??Le(r(a.schedule,new Date(e),d)):null,lastRun:u?{at:u.startedAt,status:u.status,summary:Ks(u.status==="success"?void 0:u.errorSummary,k.summary)}:null,lastSuccessAt:l.find(g=>g.status==="success")?.startedAt??null,consecutiveFailures:yn(c),sampledRuns:l.length,flags:[],attention:null};p.flags=wn(p,c,a.schedule,d,null,e,n,r),s.push(kn(p))}let o=new Map(hn(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 d=l.config??{},c=a.state||"active",u=c==="active",p=(i.get(a.id)??[]).slice().sort((T,$e)=>$e.at-T.at),g=p.map(T=>({at:T.at,status:Hs(T.status)})),f=g[0],m=l.type==="trigger.cron",b=typeof d.spec=="string"?d.spec:"",x=typeof d.timezone=="string"?d.timezone:"UTC",F={id:`workflow:${a.id}`,source:"workflow",kind:m?"schedule":"event",name:E(a.title||a.id,k.text),trigger:m?{schedule:E(b,k.text),timezone:x}:{event:E(typeof d.event=="string"?d.event:"",k.text),filters:Xs(d.filter,a)},agent:zs(a),enabled:u,state:c,nextRunAt:m&&u&&b?Le(r(b,new Date(e),x)):null,lastRun:f?{at:new Date(f.at).toISOString(),status:f.status}:null,lastSuccessAt:(()=>{let T=g.find($e=>$e.status==="success");return T?new Date(T.at).toISOString():null})(),consecutiveFailures:yn(g),sampledRuns:p.length,flags:[],attention:null},re=Date.parse(a.updated||a.created||"");F.flags=m?wn(F,g,b,x,Number.isFinite(re)?re:null,e,n,r):Vs(F,o.get(a.id)?.state==="dormant",Number.isFinite(re)?re:null,e,n),s.push(kn(F))}return s.sort(Bs).slice(0,k.routines)}function yn(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 wn(t,e,n,r,s,o,i,a){let l=[],d=e.length?e[0].at:null;if(!t.enabled){let p=xn(d,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`}),d===null)return l.push({reason:"never-ran",detail:"No persisted attempt"}),l;let c=new Date(d),u=null;for(let p=0;p<i.missedFires&&(u=a(n,c,r),!!u);p++)c=u;return u&&o>u.getTime()+i.graceMs&&l.push({reason:"overdue",detail:`No attempt since ${new Date(d).toISOString()}; ${i.missedFires} scheduled fires missed`}),l}function Vs(t,e,n,r,s){let o=[],i=t.lastRun?Date.parse(t.lastRun.at):null;if(!t.enabled){let a=xn(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 xn(t,e,n,r){let s=Math.max(t??0,e??0);return s&&n-s<r.disabledDays*bn?null:{reason:"disabled-long",detail:s?`Disabled; no activity for ${Math.floor((n-s)/bn)} days`:"Disabled and never ran"}}function kn(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 Sn={critical:0,warning:1,info:2};function Bs(t,e){let n=t.attention?Sn[t.attention]:3,r=e.attention?Sn[e.attention]:3;return n-r||Number(e.enabled)-Number(t.enabled)||t.name.localeCompare(e.name)}function Hs(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 zs(t){if(t.ownerAgent)return E(t.ownerAgent,k.text);let e=t.nodes.find(n=>n.type==="agent"&&typeof n.config?.agentId=="string"&&n.config.agentId);return e?E(String(e.config.agentId),k.text):null}function Xs(t,e){let n=[],r=e?.project;if(r&&n.push(E(`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(E(`${s}=${i.join(",")}`,k.filterValue))}return n.slice(0,k.filters)}function Le(t){if(!t)return null;let e=t instanceof Date?t:new Date(t);return Number.isFinite(e.getTime())?e.toISOString():null}function E(t,e){return t.length<=e?t:t.slice(0,e-3)+"..."}function Ks(t,e){return t===void 0?void 0:E(t,e)}import{mkdirSync as Gs,readFileSync as Js,renameSync as Ys,writeFileSync as Zs}from"fs";import{resolve as Qs}from"path";function vn(t){return Qs(Ce(t),"_state.json")}function v(t){try{let e=JSON.parse(Js(vn(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 K(t,e){Gs(Ce(t),{recursive:!0});let n=vn(t),r=`${n}.${process.pid}.tmp`;Zs(r,JSON.stringify(e,null,2)+`
|
|
3
3
|
`),Ys(r,n)}function $n(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(),K(t,{...s,snoozed:o})}function cc(t,e){K(t,{...v(t),lastDigest:e})}function Oe(t,e,n,r=Date.now()){let s=v(t),o=new Set(n),i={};for(let[l,d]of Object.entries(s.popped??{}))o.has(l)&&(i[l]=d);i[e]=new Date(r).toISOString();let a=(s.wanted??[]).filter(l=>l!==e&&o.has(l));K(t,{...s,popped:i,wanted:a})}function Rn(t,e){let n=v(t);K(t,{...n,wanted:[...(n.wanted??[]).filter(r=>r!==e),e]})}function dc(t,e=Date.now()){K(t,{...v(t),popped:{},passAt:new Date(e).toISOString()})}import{existsSync as G,readdirSync as ho,readFileSync as bo}from"fs";import{resolve as A}from"path";import{randomBytes as An}from"crypto";import{existsSync as to,mkdirSync as no,readdirSync as ro,readFileSync as so,renameSync as In,unlinkSync as oo,writeFileSync as io}from"fs";import{resolve as Tn}from"path";function _n(t){return[...t.account?["--account",t.account]:[],...t.store?["--store",t.store]:[]]}var eo=t=>t.trim().split(`
|
|
4
4
|
`).pop()?.slice(0,300)||"no output";async function En(t,e,n,r=Ne){let s=await r(t.bin,[..._n(t),"send","text","--to",e,"--message",n,"--no-preview"],{timeoutMs:6e4});return s.code===0?{ok:!0}:{ok:!1,error:`wacli send failed: ${eo(s.stderr||s.stdout)}`}}async function gc(t,e,n,r,s=Ne){return(await s(t.bin,[..._n(t),"--read-only","media","download","--chat",e,"--id",n,"--output",r],{timeoutMs:12e4})).code===0}var ao=2e3,lo=t=>En(t.wacli,t.to,t.text);function Pe(t){return Tn(t,".agentx","whatsapp-triage","drafts")}var co=t=>/^[a-z0-9-]{8,64}$/.test(t),ae=(t,e)=>Tn(Pe(t),`${e}.json`);function Dn(t,e){no(Pe(t),{recursive:!0});let n=ae(t,e.id),r=`${n}.${process.pid}.tmp`;io(r,JSON.stringify(e,null,2)+`
|
|
@@ -52,7 +52,7 @@ import{a as Ne}from"./chunk-GTJIKXDB.js";import{A as dn,H as mn,j as O}from"./ch
|
|
|
52
52
|
CREATE INDEX IF NOT EXISTS idx_request_plan_events ON request_plan_events(request_id, at);
|
|
53
53
|
`)}function On(t){return!!t.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'request_plans'").get()}function Me(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 Ln(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 go={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"},ce=class{constructor(e){this.db=e;po(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,
|
|
54
54
|
to_channel, to_chat, to_account, check_url, check_contains, stall_minutes, dispatched_at, updated_at)
|
|
55
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);this.db.transaction(()=>{o.run(e,n,s),r.forEach((a,l)=>{let d=l===0,c=d&&a.agentId===n&&a.kind!=="message";i.run(e,l+1,a.name,a.kind,a.agentId,a.doneWhen,d?"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?Me(n):null}steps(e){return this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? ORDER BY idx").all(e).map(Ln)}step(e,n){let r=this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? AND idx = ?").get(e,n);return r?Ln(r):null}listActive(){return this.db.prepare("SELECT * FROM request_plans WHERE state = 'active' ORDER BY created_at, rowid").all().map(Me)}updateStep(e,n,r){let s=[],o=[];for(let[i,a]of Object.entries(r)){let l=go[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(Me)}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,uo))}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}))}},vc=Mt;import{existsSync as fo,readFileSync as mo}from"fs";Vt();Ns();function Pn(t){let e=Bt(t),n={};if(fo(e))try{n=qt(JSON.parse(mo(e,"utf-8")))}catch{n={}}let r=Ee.safeParse(n?.requests);return r.success?r.data:Ee.parse(void 0)}async function Ic(t,e={}){let n=(t.channels??[]).filter(r=>!Re.has(r.toLowerCase().split("@")[0]));return n.length?{success:!1,error:`unknown channel ${n.map(r=>`"${r}"`).join(", ")}: use ${[...Re].join(", ")}`}:Ht(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.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})}var Fn=["card","schedule","memory","wiki","whatsapp","request"],yo=280;function q(t,e=yo){let n=t.replace(/\s+/g," ").trim();return n.length>e?`${n.slice(0,e-1)}\u2026`:n}function Ue(t){if(t.configPath)return A(t.configPath);let e=[A(t.root,"agentx.json"),A(t.root,".agentx","config.json")];return e.find(n=>G(n))??e[0]}function Fe(t){return t.wikiDir?A(t.wikiDir):A(t.root,".agentx","wiki")}function wo(t){return W(t.root,"pending").map(ko)}function ko(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:q([t.context,t.draft?`Suggested message: ${t.draft}`:""].filter(Boolean).join(" \xB7 "))}:{}}}function So(t){let e=Ue(t);if(!G(e))return[];let n;try{n=JSON.parse(bo(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",d=i.schedule?Jt(i.schedule):"",c=i.schedule?`${d.charAt(0).toLowerCase()}${d.slice(1)} (${i.schedule})`:"no schedule",u=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:q(`${u}${p&&i.schedule?` \xB7 first run ${Zt(Yt(i.schedule,l,r),l)}`:""}`),more:"agentx schedule list"})}return s}function Wn(t){let e=A(t,".agentx","memory");return G(e)?ho(e).filter(n=>n.endsWith(".jsonl")).map(n=>n.slice(0,-6)).sort():[]}function xo(t){let e=Wn(t.root);if(e.length===0)return[];let n=new Ae(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:q(o.content),more:`agentx memory facts held --agent ${s}`});return r}function vo(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 $o(t){return an(Fe(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:q(`${vo(n)} ${e.article.content}`),more:`agentx wiki proposals show ${e.id}`}})}function Ro(t){return Cn(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:q(`${e.triage}: ${e.summary}`),more:"agentx whatsapp triage log"}))}function P(t){if(t.requests)return t.requests;if(A(t.root)!==process.cwd()||!G(A(t.root,".agentx","db.sqlite")))return null;let e=_e({quiet:!0});if(!e)return null;let n=Mn.get(e);return!n&&!Ut(e)?null:(n||Mn.set(e,n=new Ft(e)),n)}var Mn=new WeakMap;function Hc(t){if(t.plans)return t.plans;if(t.requests||A(t.root)!==process.cwd()||!G(A(t.root,".agentx","db.sqlite")))return null;let e=_e({quiet:!0});if(!e||!On(e))return null;let n=Un.get(e);return n||Un.set(e,n=new ce(e)),n}var Un=new WeakMap;function _o(t){let e=P(t);return e?e.listByState("needs_attention").map(n=>({key:`request:${n.id}`,kind:"request",title:O(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:q(`${n.attentionReason??"It needs attention"}. You said (${n.channel}): ${n.text}`),more:`agentx requests show ${n.id}`})):[]}var qn={card:wo,schedule:So,memory:xo,wiki:$o,whatsapp:Ro,request:_o};function Eo(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 jn(t,e={}){let n=t.now??Date.now(),{snoozed:r}=v(t.root),s=[],o=[],i=0;for(let a of e.kinds??Fn){let l;try{l=qn[a](t)}catch(d){o.push({kind:a,error:String(d?.message??d).slice(0,200)});continue}for(let d of l){let c=r[d.key];if(c&&Date.parse(c)>n){if(!e.includeSnoozed){i++;continue}d.snoozed_until=c}s.push(d)}}return s.sort(Eo),{items:s,snoozed:i,errors:o}}function Ao(t){let e=t.indexOf(":");if(e<=0)return null;let n=t.slice(0,e),r=t.slice(e+1);return!Fn.includes(n)||!r?null:{kind:n,ref:r}}function Io(t,e,n){switch(e){case"card":return X(t.root,n)?.status==="pending";case"wiki":return on(Fe(t),n)?.status==="pending";case"whatsapp":return le(t.root,n)?.status==="pending";default:return qn[e](t).some(r=>r.key===`${e}:${n}`)}}async function Vn(t,e,n,r={}){let s=Ao(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(!Io(t,o,i))return{ok:!1,error:`nothing waiting for "${e}"`};let c=r.laterHours&&r.laterHours>0?r.laterHours:24,u=new Date(a+c*36e5);return $n(t.root,e,u,a),{ok:!0,message:`${e} put off until ${u.toISOString()}`}}let d=n==="yes";switch(o){case"card":{let c=fn(t.root,i,d?"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 ${d?"yes":"no"}${c.card.choice?` (${c.card.choice}${c.card.choice_suggested?", the suggested option":""})`:""}`}:c}case"schedule":{let c=await(d?Qt:en)(i,{configPath:Ue(t),reload:t.reload});return c.success?{ok:!0,message:c.message}:{ok:!1,error:c.message}}case"memory":{let c=i.indexOf("/");if(c<=0)return{ok:!1,error:"memory keys look like memory:<agent>/<fact-id>"};let u=i.slice(0,c),p=i.slice(c+1);if(!Wn(t.root).includes(u))return{ok:!1,error:`no memory for agent "${u}"`};let g=new Ae(t.root);return g.held(u).some(f=>f.id===p)?(g.review(u,p,d?"approved":"rejected",l),{ok:!0,message:`${e} ${d?"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=Fe(t),u=d?ln(c,i,{by:l,force:r.force,now:a}):cn(c,i,{by:l,reason:r.note,now:a});return u.ok?{ok:!0,message:d?`${u.proposal.article.path} written to the shared wiki`:`${e} rejected`}:u}case"whatsapp":{let c=await Nn(t.root,i,d?"yes":"no",{by:l,now:a,send:t.sendWhatsApp});return c.ok?{ok:!0,message:d?`${e}: sent to ${c.draft.chat_name||c.draft.to}`:`${e}: dropped, nothing sent`}:c}case"request":{let c=P(t),u=c?.get(i);return!c||!u||u.state!=="needs_attention"?{ok:!1,error:`nothing waiting for "${e}"`}:d?Pn(Ue(t)).enabled?(c.requestPickup(i,a),{ok:!0,message:`${e}: ${u.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 To=3,Do=7,Co=50,qe=120,No=280,We=600,Hn=36e5,Lo=24*Hn;function Kc(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 j(t,e){let n=t.replace(/\s+/g," ").trim();return n.length>e?`${n.slice(0,e-1)}\u2026`:n}var de=t=>new Date(t).toISOString();function Oo(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:j(e.title,qe),...e.ask?{ask:j(e.ask,We)}:{},...e.detail?{facts:j(e.detail,No)}:{},...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 Po={done:"Done",declined:"Declined",dropped:"Dropped"};function zn(t,e,n){let{record:r,links:s}=e,o=O(r,qe),i={key:`request:${r.id}`,kind:"request",node:t.node,nodeName:t.nodeName,title:o.headline,need:o.need,...r.headline?{said:j(o.said,We)}:{},agent:r.agentId,askedAt:de(r.createdAt),changedAt:de(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:j(r.question,We)}:{},can:{answer:!1,later:!1,reply:!0}};case"in_progress":case"waiting_other":{let a=s.some(d=>d.kind==="run"&&!!t.liveRuns?.has(d.ref)),l=t.now-r.updatedAt<(t.quietHours??To)*Hn;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:de(r.closedAt??r.stateChangedAt??r.updatedAt),outcome:Po[r.state]??r.state,...a?{evidence:a}:{},can:{answer:!1,later:!1,reply:!1}}}}}function Mo(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 Uo(t,e){return{key:`card:${e.id}`,kind:"card",column:"done",node:t.node,nodeName:t.nodeName,title:j(e.title,qe),ask:e.ask,agent:e.raised_by,askedAt:e.created_at,...e.decided_at?{changedAt:e.decided_at}:{},outcome:Mo(e),...e.resolution?{evidence:e.resolution}:{},can:{answer:!1,later:!1,reply:!1}}}var $=t=>t&&Date.parse(t)||0,Bn=(t,e)=>t.map(n=>n[e]).filter(n=>!!$(n)).sort((n,r)=>$(n)-$(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(Oo(s,o,s.node===t.node))}let r=Xn(t,e);for(let s of t.requests??[]){let o=zn(t,s,r);o?.column==="yours"&&e.push(o)}return{cards:e,errors:n}}function Xn(t,e){return new Set([...e.filter(n=>n.node===t.node).map(n=>n.key),...t.deferred??[]])}function Gc(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=Xn(t,n),o=[],i=[],a=[];for(let p of t.requests??[]){let g=zn(t,p,s);g&&g.column!=="yours"&&{agent:o,quiet:i,done:a}[g.column].push(g)}let l=t.now-(t.doneDays??Do)*Lo;for(let p of t.cards)p.status!=="pending"&&$(p.decided_at)>=l&&a.push(Uo(t,p));o.sort((p,g)=>$(g.changedAt)-$(p.changedAt)),i.sort((p,g)=>$(p.changedAt)-$(g.changedAt)),a.sort((p,g)=>$(g.changedAt)-$(p.changedAt));let d=a.filter(p=>$(p.changedAt)>=l).slice(0,Co),c=Bn(n,"askedAt"),u=Bn(i,"changedAt");return{ts:de(t.now),cards:[...n,...o,...i,...d],figures:{yours:{count:n.length,...c?{oldest:c}:{},...t.owner?.later?{later:t.owner.later}:{}},agent:{count:o.length},quiet:{count:i.length,...u?{oldest:u}:{}},done:{count:d.length}},errors:r}}function Fo(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 Wo(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 Qc(t,e){let n=t.now??Date.now(),r=[],s=jn(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=P(t);c&&(a=c.listByState("waiting_owner").map(u=>({record:u,links:c.links(u.id)})))}catch(c){r.push(`Requests could not be read: ${c?.message??c}`)}let{cards:l,errors:d}=je({now:n,node:e.url,nodeName:e.name,inbox:[{node:e.url,nodeName:e.name,items:o.map(Fo)}],requests:a,deferred:i});return Wo(l,i.size,[...r,...d])}var Kn=new Set(["127.0.0.1","::1","::ffff:127.0.0.1"]);function td(t){return t==="/api/memory"||t.startsWith("/api/memory/")||t==="/approvals"||t.startsWith("/approvals/")||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 nd(t){return t==="/reload"||t==="/api/processes/kill"||t==="/send"||t==="/send/agent"||t==="/send/contact"||t==="/mesh/announce"||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/review-gate/replay"}function rd(t){return Kn.has(t)}function sd(t){if(t.foreignBrowser)return{allowed:!1,reason:"foreign-browser-origin"};if(t.enforcementDisabled)return{allowed:!0,reason:"disabled"};if(Kn.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 od(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 id(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 ue(t){return(Array.isArray(t)?t[0]:t)?.trim()??""}function qo(t){try{return new URL(t).host.toLowerCase()}catch{return null}}function jo(t=process.env){return new Set((t.AGENTX_ALLOWED_ORIGINS||"").split(",").map(e=>e.trim().replace(/\/+$/,"").toLowerCase()).filter(Boolean))}function ld(t,e=jo()){let n=ue(t.origin);if(n){if(e.has(n.replace(/\/+$/,"").toLowerCase()))return"same-origin";let s=qo(n),o=[ue(t.host),ue(t["x-forwarded-host"])].filter(Boolean).map(i=>i.toLowerCase());return s&&o.includes(s)?"same-origin":"foreign"}let r=ue(t["sec-fetch-site"]).toLowerCase();return r==="cross-site"||r==="same-site"?"foreign":"none"}function cd(t){let e=(t||"GET").toUpperCase();return e!=="GET"&&e!=="HEAD"}import{existsSync as wr,mkdirSync as bi,readFileSync as yi,renameSync as wi,writeFileSync as ki}from"fs";import{homedir as Si}from"os";import{dirname as xi,join as vi}from"path";import{execFile as Qo,execFileSync as ei}from"child_process";import{execFileSync as Vo}from"child_process";import{existsSync as Jn,mkdirSync as Bo,readdirSync as Ho,readFileSync as Yn,renameSync as zo,writeFileSync as Xo}from"fs";import{homedir as Zn}from"os";import{join as Be}from"path";var R="siri:",Qn="com.apple.ttsbundle.gryphon-neural_",er=t=>!!t&&t.startsWith(Qn),Ko=["/usr/bin/say","/usr/bin/defaults","/usr/bin/plutil"],Go=()=>{try{return Vo("/usr/bin/defaults",["read","com.apple.Accessibility"],{stdio:"ignore",timeout:5e3}),!0}catch{return!1}},Ve;function He(t={}){let e=t.platform!==void 0||t.exists!==void 0||t.prefDomain!==void 0;if(!e&&Ve!==void 0)return Ve;let{platform:n=process.platform,exists:r=Jn,prefDomain:s=Go}=t,o=n==="darwin"&&Ko.every(i=>r(i))&&s();return e||(Ve=o),o}var tr=["/System/Library/AssetsV2/com_apple_MobileAsset_Trial_Siri_SiriTextToSpeech/purpose_auto","/System/Library/AssetsV2/com_apple_MobileAsset_UAF_Siri_TextToSpeech/purpose_auto"],nr={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"},ze=t=>nr[t.toLowerCase()]??null;function pe(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 Jo=/com\.apple\.siri\.tts\.voice\.([a-z]{2})_([A-Z]{2})\.([a-z]+)\.neural\.premium/g;function Yo(t){let e=new Map;for(let n of t)for(let[,r,s,o]of n.matchAll(Jo)){let i=`${r}-${s}`,a=`${Qn}${o}_${i}_premium`;e.has(a)||e.set(a,{id:a,name:o[0].toUpperCase()+o.slice(1),locale:i,quality:"premium",gender:nr[o]??null,siri:!0})}return[...e.values()]}function ge(t=tr,e={}){if(!He(e))return[];let n=[];for(let r of t){let s;try{s=Ho(r)}catch{continue}for(let o of s)try{n.push(Yn(Be(r,o,"Info.plist"),"latin1"))}catch{}}return Yo(n)}var Gn=`#!/bin/sh
|
|
55
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);this.db.transaction(()=>{o.run(e,n,s),r.forEach((a,l)=>{let d=l===0,c=d&&a.agentId===n&&a.kind!=="message";i.run(e,l+1,a.name,a.kind,a.agentId,a.doneWhen,d?"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?Me(n):null}steps(e){return this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? ORDER BY idx").all(e).map(Ln)}step(e,n){let r=this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? AND idx = ?").get(e,n);return r?Ln(r):null}listActive(){return this.db.prepare("SELECT * FROM request_plans WHERE state = 'active' ORDER BY created_at, rowid").all().map(Me)}updateStep(e,n,r){let s=[],o=[];for(let[i,a]of Object.entries(r)){let l=go[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(Me)}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,uo))}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}))}},vc=Mt;import{existsSync as fo,readFileSync as mo}from"fs";Vt();Ns();function Pn(t){let e=Bt(t),n={};if(fo(e))try{n=qt(JSON.parse(mo(e,"utf-8")))}catch{n={}}let r=Ee.safeParse(n?.requests);return r.success?r.data:Ee.parse(void 0)}async function Ic(t,e={}){let n=(t.channels??[]).filter(r=>!Re.has(r.toLowerCase().split("@")[0]));return n.length?{success:!1,error:`unknown channel ${n.map(r=>`"${r}"`).join(", ")}: use ${[...Re].join(", ")}`}:Ht(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})}var Fn=["card","schedule","memory","wiki","whatsapp","request"],yo=280;function q(t,e=yo){let n=t.replace(/\s+/g," ").trim();return n.length>e?`${n.slice(0,e-1)}\u2026`:n}function Ue(t){if(t.configPath)return A(t.configPath);let e=[A(t.root,"agentx.json"),A(t.root,".agentx","config.json")];return e.find(n=>G(n))??e[0]}function Fe(t){return t.wikiDir?A(t.wikiDir):A(t.root,".agentx","wiki")}function wo(t){return W(t.root,"pending").map(ko)}function ko(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:q([t.context,t.draft?`Suggested message: ${t.draft}`:""].filter(Boolean).join(" \xB7 "))}:{}}}function So(t){let e=Ue(t);if(!G(e))return[];let n;try{n=JSON.parse(bo(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",d=i.schedule?Jt(i.schedule):"",c=i.schedule?`${d.charAt(0).toLowerCase()}${d.slice(1)} (${i.schedule})`:"no schedule",u=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:q(`${u}${p&&i.schedule?` \xB7 first run ${Zt(Yt(i.schedule,l,r),l)}`:""}`),more:"agentx schedule list"})}return s}function Wn(t){let e=A(t,".agentx","memory");return G(e)?ho(e).filter(n=>n.endsWith(".jsonl")).map(n=>n.slice(0,-6)).sort():[]}function xo(t){let e=Wn(t.root);if(e.length===0)return[];let n=new Ae(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:q(o.content),more:`agentx memory facts held --agent ${s}`});return r}function vo(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 $o(t){return an(Fe(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:q(`${vo(n)} ${e.article.content}`),more:`agentx wiki proposals show ${e.id}`}})}function Ro(t){return Cn(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:q(`${e.triage}: ${e.summary}`),more:"agentx whatsapp triage log"}))}function P(t){if(t.requests)return t.requests;if(A(t.root)!==process.cwd()||!G(A(t.root,".agentx","db.sqlite")))return null;let e=_e({quiet:!0});if(!e)return null;let n=Mn.get(e);return!n&&!Ut(e)?null:(n||Mn.set(e,n=new Ft(e)),n)}var Mn=new WeakMap;function Hc(t){if(t.plans)return t.plans;if(t.requests||A(t.root)!==process.cwd()||!G(A(t.root,".agentx","db.sqlite")))return null;let e=_e({quiet:!0});if(!e||!On(e))return null;let n=Un.get(e);return n||Un.set(e,n=new ce(e)),n}var Un=new WeakMap;function _o(t){let e=P(t);return e?e.listByState("needs_attention").map(n=>({key:`request:${n.id}`,kind:"request",title:O(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:q(`${n.attentionReason??"It needs attention"}. You said (${n.channel}): ${n.text}`),more:`agentx requests show ${n.id}`})):[]}var qn={card:wo,schedule:So,memory:xo,wiki:$o,whatsapp:Ro,request:_o};function Eo(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 jn(t,e={}){let n=t.now??Date.now(),{snoozed:r}=v(t.root),s=[],o=[],i=0;for(let a of e.kinds??Fn){let l;try{l=qn[a](t)}catch(d){o.push({kind:a,error:String(d?.message??d).slice(0,200)});continue}for(let d of l){let c=r[d.key];if(c&&Date.parse(c)>n){if(!e.includeSnoozed){i++;continue}d.snoozed_until=c}s.push(d)}}return s.sort(Eo),{items:s,snoozed:i,errors:o}}function Ao(t){let e=t.indexOf(":");if(e<=0)return null;let n=t.slice(0,e),r=t.slice(e+1);return!Fn.includes(n)||!r?null:{kind:n,ref:r}}function Io(t,e,n){switch(e){case"card":return X(t.root,n)?.status==="pending";case"wiki":return on(Fe(t),n)?.status==="pending";case"whatsapp":return le(t.root,n)?.status==="pending";default:return qn[e](t).some(r=>r.key===`${e}:${n}`)}}async function Vn(t,e,n,r={}){let s=Ao(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(!Io(t,o,i))return{ok:!1,error:`nothing waiting for "${e}"`};let c=r.laterHours&&r.laterHours>0?r.laterHours:24,u=new Date(a+c*36e5);return $n(t.root,e,u,a),{ok:!0,message:`${e} put off until ${u.toISOString()}`}}let d=n==="yes";switch(o){case"card":{let c=fn(t.root,i,d?"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 ${d?"yes":"no"}${c.card.choice?` (${c.card.choice}${c.card.choice_suggested?", the suggested option":""})`:""}`}:c}case"schedule":{let c=await(d?Qt:en)(i,{configPath:Ue(t),reload:t.reload});return c.success?{ok:!0,message:c.message}:{ok:!1,error:c.message}}case"memory":{let c=i.indexOf("/");if(c<=0)return{ok:!1,error:"memory keys look like memory:<agent>/<fact-id>"};let u=i.slice(0,c),p=i.slice(c+1);if(!Wn(t.root).includes(u))return{ok:!1,error:`no memory for agent "${u}"`};let g=new Ae(t.root);return g.held(u).some(f=>f.id===p)?(g.review(u,p,d?"approved":"rejected",l),{ok:!0,message:`${e} ${d?"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=Fe(t),u=d?ln(c,i,{by:l,force:r.force,now:a}):cn(c,i,{by:l,reason:r.note,now:a});return u.ok?{ok:!0,message:d?`${u.proposal.article.path} written to the shared wiki`:`${e} rejected`}:u}case"whatsapp":{let c=await Nn(t.root,i,d?"yes":"no",{by:l,now:a,send:t.sendWhatsApp});return c.ok?{ok:!0,message:d?`${e}: sent to ${c.draft.chat_name||c.draft.to}`:`${e}: dropped, nothing sent`}:c}case"request":{let c=P(t),u=c?.get(i);return!c||!u||u.state!=="needs_attention"?{ok:!1,error:`nothing waiting for "${e}"`}:d?Pn(Ue(t)).enabled?(c.requestPickup(i,a),{ok:!0,message:`${e}: ${u.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 To=3,Do=7,Co=50,qe=120,No=280,We=600,Hn=36e5,Lo=24*Hn;function Kc(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 j(t,e){let n=t.replace(/\s+/g," ").trim();return n.length>e?`${n.slice(0,e-1)}\u2026`:n}var de=t=>new Date(t).toISOString();function Oo(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:j(e.title,qe),...e.ask?{ask:j(e.ask,We)}:{},...e.detail?{facts:j(e.detail,No)}:{},...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 Po={done:"Done",declined:"Declined",dropped:"Dropped"};function zn(t,e,n){let{record:r,links:s}=e,o=O(r,qe),i={key:`request:${r.id}`,kind:"request",node:t.node,nodeName:t.nodeName,title:o.headline,need:o.need,...r.headline?{said:j(o.said,We)}:{},agent:r.agentId,askedAt:de(r.createdAt),changedAt:de(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:j(r.question,We)}:{},can:{answer:!1,later:!1,reply:!0}};case"in_progress":case"waiting_other":{let a=s.some(d=>d.kind==="run"&&!!t.liveRuns?.has(d.ref)),l=t.now-r.updatedAt<(t.quietHours??To)*Hn;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:de(r.closedAt??r.stateChangedAt??r.updatedAt),outcome:Po[r.state]??r.state,...a?{evidence:a}:{},can:{answer:!1,later:!1,reply:!1}}}}}function Mo(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 Uo(t,e){return{key:`card:${e.id}`,kind:"card",column:"done",node:t.node,nodeName:t.nodeName,title:j(e.title,qe),ask:e.ask,agent:e.raised_by,askedAt:e.created_at,...e.decided_at?{changedAt:e.decided_at}:{},outcome:Mo(e),...e.resolution?{evidence:e.resolution}:{},can:{answer:!1,later:!1,reply:!1}}}var $=t=>t&&Date.parse(t)||0,Bn=(t,e)=>t.map(n=>n[e]).filter(n=>!!$(n)).sort((n,r)=>$(n)-$(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(Oo(s,o,s.node===t.node))}let r=Xn(t,e);for(let s of t.requests??[]){let o=zn(t,s,r);o?.column==="yours"&&e.push(o)}return{cards:e,errors:n}}function Xn(t,e){return new Set([...e.filter(n=>n.node===t.node).map(n=>n.key),...t.deferred??[]])}function Gc(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=Xn(t,n),o=[],i=[],a=[];for(let p of t.requests??[]){let g=zn(t,p,s);g&&g.column!=="yours"&&{agent:o,quiet:i,done:a}[g.column].push(g)}let l=t.now-(t.doneDays??Do)*Lo;for(let p of t.cards)p.status!=="pending"&&$(p.decided_at)>=l&&a.push(Uo(t,p));o.sort((p,g)=>$(g.changedAt)-$(p.changedAt)),i.sort((p,g)=>$(p.changedAt)-$(g.changedAt)),a.sort((p,g)=>$(g.changedAt)-$(p.changedAt));let d=a.filter(p=>$(p.changedAt)>=l).slice(0,Co),c=Bn(n,"askedAt"),u=Bn(i,"changedAt");return{ts:de(t.now),cards:[...n,...o,...i,...d],figures:{yours:{count:n.length,...c?{oldest:c}:{},...t.owner?.later?{later:t.owner.later}:{}},agent:{count:o.length},quiet:{count:i.length,...u?{oldest:u}:{}},done:{count:d.length}},errors:r}}function Fo(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 Wo(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 Qc(t,e){let n=t.now??Date.now(),r=[],s=jn(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=P(t);c&&(a=c.listByState("waiting_owner").map(u=>({record:u,links:c.links(u.id)})))}catch(c){r.push(`Requests could not be read: ${c?.message??c}`)}let{cards:l,errors:d}=je({now:n,node:e.url,nodeName:e.name,inbox:[{node:e.url,nodeName:e.name,items:o.map(Fo)}],requests:a,deferred:i});return Wo(l,i.size,[...r,...d])}var Kn=new Set(["127.0.0.1","::1","::ffff:127.0.0.1"]);function td(t){return t==="/api/memory"||t.startsWith("/api/memory/")||t==="/approvals"||t.startsWith("/approvals/")||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 nd(t){return t==="/reload"||t==="/api/processes/kill"||t==="/send"||t==="/send/agent"||t==="/send/contact"||t==="/mesh/announce"||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/review-gate/replay"}function rd(t){return Kn.has(t)}function sd(t){if(t.foreignBrowser)return{allowed:!1,reason:"foreign-browser-origin"};if(t.enforcementDisabled)return{allowed:!0,reason:"disabled"};if(Kn.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 od(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 id(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 ue(t){return(Array.isArray(t)?t[0]:t)?.trim()??""}function qo(t){try{return new URL(t).host.toLowerCase()}catch{return null}}function jo(t=process.env){return new Set((t.AGENTX_ALLOWED_ORIGINS||"").split(",").map(e=>e.trim().replace(/\/+$/,"").toLowerCase()).filter(Boolean))}function ld(t,e=jo()){let n=ue(t.origin);if(n){if(e.has(n.replace(/\/+$/,"").toLowerCase()))return"same-origin";let s=qo(n),o=[ue(t.host),ue(t["x-forwarded-host"])].filter(Boolean).map(i=>i.toLowerCase());return s&&o.includes(s)?"same-origin":"foreign"}let r=ue(t["sec-fetch-site"]).toLowerCase();return r==="cross-site"||r==="same-site"?"foreign":"none"}function cd(t){let e=(t||"GET").toUpperCase();return e!=="GET"&&e!=="HEAD"}import{existsSync as wr,mkdirSync as bi,readFileSync as yi,renameSync as wi,writeFileSync as ki}from"fs";import{homedir as Si}from"os";import{dirname as xi,join as vi}from"path";import{execFile as Qo,execFileSync as ei}from"child_process";import{execFileSync as Vo}from"child_process";import{existsSync as Jn,mkdirSync as Bo,readdirSync as Ho,readFileSync as Yn,renameSync as zo,writeFileSync as Xo}from"fs";import{homedir as Zn}from"os";import{join as Be}from"path";var R="siri:",Qn="com.apple.ttsbundle.gryphon-neural_",er=t=>!!t&&t.startsWith(Qn),Ko=["/usr/bin/say","/usr/bin/defaults","/usr/bin/plutil"],Go=()=>{try{return Vo("/usr/bin/defaults",["read","com.apple.Accessibility"],{stdio:"ignore",timeout:5e3}),!0}catch{return!1}},Ve;function He(t={}){let e=t.platform!==void 0||t.exists!==void 0||t.prefDomain!==void 0;if(!e&&Ve!==void 0)return Ve;let{platform:n=process.platform,exists:r=Jn,prefDomain:s=Go}=t,o=n==="darwin"&&Ko.every(i=>r(i))&&s();return e||(Ve=o),o}var tr=["/System/Library/AssetsV2/com_apple_MobileAsset_Trial_Siri_SiriTextToSpeech/purpose_auto","/System/Library/AssetsV2/com_apple_MobileAsset_UAF_Siri_TextToSpeech/purpose_auto"],nr={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"},ze=t=>nr[t.toLowerCase()]??null;function pe(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 Jo=/com\.apple\.siri\.tts\.voice\.([a-z]{2})_([A-Z]{2})\.([a-z]+)\.neural\.premium/g;function Yo(t){let e=new Map;for(let n of t)for(let[,r,s,o]of n.matchAll(Jo)){let i=`${r}-${s}`,a=`${Qn}${o}_${i}_premium`;e.has(a)||e.set(a,{id:a,name:o[0].toUpperCase()+o.slice(1),locale:i,quality:"premium",gender:nr[o]??null,siri:!0})}return[...e.values()]}function ge(t=tr,e={}){if(!He(e))return[];let n=[];for(let r of t){let s;try{s=Ho(r)}catch{continue}for(let o of s)try{n.push(Yn(Be(r,o,"Info.plist"),"latin1"))}catch{}}return Yo(n)}var Gn=`#!/bin/sh
|
|
56
56
|
# Written by agentx; shared by the daemon and AgentX Voice. Do not edit.
|
|
57
57
|
# siri-say.sh [voice] < text speak one line. A Siri voice id switches
|
|
58
58
|
# the OS default for it; any other id is
|
|
@@ -574,4 +574,4 @@ Document the arguments, commands, or files the skill expects. Example:
|
|
|
574
574
|
claude-code ${Lt(t)} --arg value
|
|
575
575
|
\`\`\`
|
|
576
576
|
`}Vt();var As={maxPixels:12e5,timeoutMs:5e3,intervalMs:100,changeThreshold:.015,stableMs:400,regions:{},buffer:{enabled:!1,seconds:10,fps:2,region:"screen",maxPixels:3e5}};function Is(t){return{...As,...t??{},regions:{...t?.regions??{}},buffer:{...As.buffer,...t?.buffer??{}}}}function og(t){try{return Is(jt(t).screen)}catch{return Is(void 0)}}var Yl=/^[a-z][\w-]*$/,Ts=["window","screen","menubar","notifications"];function ne(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 ve=(t,e)=>ne(t,e,n=>Number.isInteger(n)&&n>0,"a whole number above 0");function Ds(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 ig(t,e){let n={...t??{}};if("maxPixels"in e&&(n.maxPixels=ve(e.maxPixels,"maxPixels")),"timeoutMs"in e&&(n.timeoutMs=ve(e.timeoutMs,"timeoutMs")),"intervalMs"in e&&(n.intervalMs=ve(e.intervalMs,"intervalMs")),"stableMs"in e&&(n.stableMs=ne(e.stableMs,"stableMs",s=>Number.isInteger(s)&&s>=0,"a whole number, 0 or more")),"changeThreshold"in e&&(n.changeThreshold=ne(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(!Yl.test(o))throw new Error(`region name "${o}" must be lowercase letters, digits, - or _`);i===null?delete s[o]:s[o]=Ds(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=ne(s.seconds,"buffer.seconds",i=>i>0&&i<=120,"above 0 and at most 120")),"fps"in s&&(o.fps=ne(s.fps,"buffer.fps",i=>i>0&&i<=10,"above 0 and at most 10")),"maxPixels"in s&&(o.maxPixels=ve(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&&!Ts.includes(r)&&!n.regions?.[r])try{Ds(r)}catch{throw new Error(`buffer.region "${r}" is not a region \u2014 use ${[...Ts,...Object.keys(n.regions??{})].join(", ")}, or x,y,w,h`)}return n}export{hn as a,ec as b,pt as c,Bi as d,Hi as e,Kd as f,Gd as g,Jd as h,Qd as i,eu as j,tu as k,Ar as l,Ir as m,nu as n,Tr as o,su as p,iu as q,N as r,Dr as s,k as t,sc as u,Lr as v,pu as w,mu as x,Pr as y,hu as z,Mr as A,bu as B,Z as C,ya as D,yu as E,wu as F,Fr as G,gc as H,lo as I,wc as J,Nn as K,v as L,cc as M,dc as N,xc as O,ce as P,vc as Q,Pn as R,Ic as S,P as T,Hc as U,jn as V,Vn as W,Do as X,Co as Y,Kc as Z,Gc as _,Fo as $,Qc as aa,qr as ba,xu as ca,$r as da,rt as ea,Mi as fa,es as ga,Zu as ha,Qu as ia,rl as ja,rp as ka,is as la,sp as ma,op as na,up as oa,fl as pa,pp as qa,td as ra,nd as sa,rd as ta,sd as ua,od as va,id as wa,ld as xa,cd as ya,yd as za,Ke as Aa,wd as Ba,kd as Ca,J as Da,Y as Ea,kl as Fa,Sp as Ga,xp as Ha,vp as Ia,$p as Ja,xt as Ka,Rp as La,Ye as Ma,Ze as Na,he as Oa,ci as Pa,ui as Qa,Rd as Ra,et as Sa,tt as Ta,pi as Ua,gi as Va,gr as Wa,br as Xa,_d as Ya,hi as Za,Ed as _a,$i as $a,Ei as ab,nt as bb,Ii as cb,yr as db,L as eb,bs as fb,ys as gb,ws as hb,Dp as ib,Il as jb,Ss as kb,xs as lb,jp as mb,Vp as nb,Hl as ob,Bp as pb,$s as qb,be as rb,Fd as sb,dt as tb,zd as ub,Kp as vb,Gp as wb,Jp as xb,Yp as yb,Zp as zb,Qp as Ab,eg as Bb,tg as Cb,ng as Db,As as Eb,Is as Fb,og as Gb,Ts as Hb,ig as Ib};
|
|
577
|
-
//# sourceMappingURL=chunk-
|
|
577
|
+
//# sourceMappingURL=chunk-5OZMFHIZ.js.map
|