agentix-cli 0.153.1 → 0.154.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 (126) hide show
  1. package/dist/{App-2SWSYFED.js → App-OL5GYZBS.js} +2 -2
  2. package/dist/{ChatApp-NYTNFLIB.js → ChatApp-EEHKOZQX.js} +2 -2
  3. package/dist/{absorb-eval-SYX5QN4H.js → absorb-eval-PVCA7UE6.js} +2 -2
  4. package/dist/{agent-UCYQELAQ.js → agent-3ETFZSEZ.js} +2 -2
  5. package/dist/{board-dashboard-UZF7MQZA.js → board-dashboard-RUO6R5NI.js} +4 -4
  6. package/dist/{chunk-GDLO7FC7.js → chunk-2FH4TULF.js} +2 -2
  7. package/dist/{chunk-ZAH74SFX.js → chunk-2K2QDTGP.js} +2 -2
  8. package/dist/{chunk-VAK4LT62.js → chunk-4FKFEWCE.js} +3 -3
  9. package/dist/chunk-4FKFEWCE.js.map +1 -0
  10. package/dist/{chunk-IFOFBI3U.js → chunk-5NTEGDXT.js} +2 -2
  11. package/dist/{chunk-DZRD6BE4.js → chunk-ABKEGNY4.js} +2 -2
  12. package/dist/{chunk-2J2OES2S.js → chunk-BMZK232D.js} +2 -2
  13. package/dist/{chunk-XQ2VU6MM.js → chunk-CJKN4APJ.js} +119 -119
  14. package/dist/chunk-CJKN4APJ.js.map +1 -0
  15. package/dist/{chunk-3LU2ZQZJ.js → chunk-F5KWRBTF.js} +2 -2
  16. package/dist/{chunk-HVNWI63Z.js → chunk-FFPQS2C4.js} +2 -2
  17. package/dist/{chunk-Z2KGUEB6.js → chunk-GDNKUNT7.js} +2 -2
  18. package/dist/chunk-GVJMPSE2.js +76 -0
  19. package/dist/chunk-GVJMPSE2.js.map +1 -0
  20. package/dist/{chunk-FVRREIVV.js → chunk-HF55LKFC.js} +2 -2
  21. package/dist/{chunk-ZQONMM3B.js → chunk-HOLJZIVJ.js} +2 -2
  22. package/dist/{chunk-RUQMUDSX.js → chunk-IRDPIQRR.js} +2 -2
  23. package/dist/{chunk-UUVJX6WD.js → chunk-IYL4YUXQ.js} +2 -2
  24. package/dist/{chunk-I45WFYGM.js → chunk-JXY7EEAR.js} +2 -2
  25. package/dist/{chunk-MM3ABEOW.js → chunk-M5TMFCPA.js} +2 -2
  26. package/dist/{chunk-MWYPW5XP.js → chunk-MKIJAGES.js} +2 -2
  27. package/dist/{chunk-5DPN2HIR.js → chunk-NKTBJHIF.js} +5 -5
  28. package/dist/{chunk-BFONYVOM.js → chunk-NUMWHIFL.js} +2 -2
  29. package/dist/{chunk-RJCHFDF3.js → chunk-RARXW4KB.js} +2 -2
  30. package/dist/{chunk-3OPW64OM.js → chunk-RTXFDYFR.js} +2 -2
  31. package/dist/{chunk-CFPRIE6F.js → chunk-TDMX6HTT.js} +2 -2
  32. package/dist/{chunk-DPSHY7GN.js → chunk-U3PHNPIJ.js} +3 -3
  33. package/dist/{chunk-LH3GOBZP.js → chunk-USCFJVVI.js} +2 -2
  34. package/dist/{chunk-S5FRIHWM.js → chunk-UWUJVING.js} +2 -2
  35. package/dist/{chunk-JPZBWHNZ.js → chunk-VCAVVCXT.js} +2 -2
  36. package/dist/cli.js +1 -1
  37. package/dist/{client-PBIUMGDL.js → client-WBAWHYAY.js} +2 -2
  38. package/dist/{config-VLH5DJTH.js → config-VXXKMXHH.js} +2 -2
  39. package/dist/{config-mutate-G7HW2R6H.js → config-mutate-MMTHEXWM.js} +2 -2
  40. package/dist/config-mutator-R75BQXMB.js +2 -0
  41. package/dist/{contributions-GZVKJXSJ.js → contributions-3ZE2TK24.js} +2 -2
  42. package/dist/{doctor-QWVUVWTF.js → doctor-TP4GSLZV.js} +2 -2
  43. package/dist/{follow-up-tool-PTKDMFA7.js → follow-up-tool-L3QXZIU2.js} +2 -2
  44. package/dist/{hub-BHCBRQZP.js → hub-U65U7SE6.js} +2 -2
  45. package/dist/index.d.ts +8 -0
  46. package/dist/index.js +1 -1
  47. package/dist/{program-2YK3YCBX.js → program-7WISM624.js} +24 -24
  48. package/dist/program-7WISM624.js.map +1 -0
  49. package/dist/{promote-73ZGTRDV.js → promote-GP2MZX7S.js} +2 -2
  50. package/dist/{query-KHW4AERR.js → query-WHNB46XD.js} +2 -2
  51. package/dist/{query-settings-P6RUUEFO.js → query-settings-U5ZMQREP.js} +2 -2
  52. package/dist/{registry-RQBXAPUZ.js → registry-GXGHPROE.js} +2 -2
  53. package/dist/{request-planner-EUIMJ7R3.js → request-planner-HALSGCA5.js} +2 -2
  54. package/dist/{review-candidates-KKGDAZIB.js → review-candidates-WIXZZCF7.js} +2 -2
  55. package/dist/{routing-FQNGOTMV.js → routing-U543HNNU.js} +2 -2
  56. package/dist/schedule-tool-FIKDTGXF.js +2 -0
  57. package/dist/{scheduler-JXZBVPOS.js → scheduler-OEKYXZPJ.js} +2 -2
  58. package/dist/{seat-DZB3NSZ7.js → seat-FWF2HKWS.js} +2 -2
  59. package/dist/{select-YD4CA7FP.js → select-QDSG7NQX.js} +2 -2
  60. package/dist/{set-enabled-UK4SE5MZ.js → set-enabled-W7U5SXYX.js} +2 -2
  61. package/dist/{tool-2PA2USUG.js → tool-QIFV7Q4M.js} +2 -2
  62. package/dist/{tool-DIJN4XBY.js → tool-VN7W6QGC.js} +2 -2
  63. package/dist/{wiki-CQBXLZ2Y.js → wiki-TN5WFJ5P.js} +2 -2
  64. package/dist/wiki-enrich-GEHA6NJQ.js +2 -0
  65. package/package.json +1 -1
  66. package/dist/chunk-5VPU5FHB.js +0 -67
  67. package/dist/chunk-5VPU5FHB.js.map +0 -1
  68. package/dist/chunk-VAK4LT62.js.map +0 -1
  69. package/dist/chunk-XQ2VU6MM.js.map +0 -1
  70. package/dist/config-mutator-XWWW3PSV.js +0 -2
  71. package/dist/program-2YK3YCBX.js.map +0 -1
  72. package/dist/schedule-tool-2OWGAK4H.js +0 -2
  73. package/dist/wiki-enrich-PA6JS2YN.js +0 -2
  74. /package/dist/{App-2SWSYFED.js.map → App-OL5GYZBS.js.map} +0 -0
  75. /package/dist/{ChatApp-NYTNFLIB.js.map → ChatApp-EEHKOZQX.js.map} +0 -0
  76. /package/dist/{absorb-eval-SYX5QN4H.js.map → absorb-eval-PVCA7UE6.js.map} +0 -0
  77. /package/dist/{agent-UCYQELAQ.js.map → agent-3ETFZSEZ.js.map} +0 -0
  78. /package/dist/{board-dashboard-UZF7MQZA.js.map → board-dashboard-RUO6R5NI.js.map} +0 -0
  79. /package/dist/{chunk-GDLO7FC7.js.map → chunk-2FH4TULF.js.map} +0 -0
  80. /package/dist/{chunk-ZAH74SFX.js.map → chunk-2K2QDTGP.js.map} +0 -0
  81. /package/dist/{chunk-IFOFBI3U.js.map → chunk-5NTEGDXT.js.map} +0 -0
  82. /package/dist/{chunk-DZRD6BE4.js.map → chunk-ABKEGNY4.js.map} +0 -0
  83. /package/dist/{chunk-2J2OES2S.js.map → chunk-BMZK232D.js.map} +0 -0
  84. /package/dist/{chunk-3LU2ZQZJ.js.map → chunk-F5KWRBTF.js.map} +0 -0
  85. /package/dist/{chunk-HVNWI63Z.js.map → chunk-FFPQS2C4.js.map} +0 -0
  86. /package/dist/{chunk-Z2KGUEB6.js.map → chunk-GDNKUNT7.js.map} +0 -0
  87. /package/dist/{chunk-FVRREIVV.js.map → chunk-HF55LKFC.js.map} +0 -0
  88. /package/dist/{chunk-ZQONMM3B.js.map → chunk-HOLJZIVJ.js.map} +0 -0
  89. /package/dist/{chunk-RUQMUDSX.js.map → chunk-IRDPIQRR.js.map} +0 -0
  90. /package/dist/{chunk-UUVJX6WD.js.map → chunk-IYL4YUXQ.js.map} +0 -0
  91. /package/dist/{chunk-I45WFYGM.js.map → chunk-JXY7EEAR.js.map} +0 -0
  92. /package/dist/{chunk-MM3ABEOW.js.map → chunk-M5TMFCPA.js.map} +0 -0
  93. /package/dist/{chunk-MWYPW5XP.js.map → chunk-MKIJAGES.js.map} +0 -0
  94. /package/dist/{chunk-5DPN2HIR.js.map → chunk-NKTBJHIF.js.map} +0 -0
  95. /package/dist/{chunk-BFONYVOM.js.map → chunk-NUMWHIFL.js.map} +0 -0
  96. /package/dist/{chunk-RJCHFDF3.js.map → chunk-RARXW4KB.js.map} +0 -0
  97. /package/dist/{chunk-3OPW64OM.js.map → chunk-RTXFDYFR.js.map} +0 -0
  98. /package/dist/{chunk-CFPRIE6F.js.map → chunk-TDMX6HTT.js.map} +0 -0
  99. /package/dist/{chunk-DPSHY7GN.js.map → chunk-U3PHNPIJ.js.map} +0 -0
  100. /package/dist/{chunk-LH3GOBZP.js.map → chunk-USCFJVVI.js.map} +0 -0
  101. /package/dist/{chunk-S5FRIHWM.js.map → chunk-UWUJVING.js.map} +0 -0
  102. /package/dist/{chunk-JPZBWHNZ.js.map → chunk-VCAVVCXT.js.map} +0 -0
  103. /package/dist/{client-PBIUMGDL.js.map → client-WBAWHYAY.js.map} +0 -0
  104. /package/dist/{config-VLH5DJTH.js.map → config-VXXKMXHH.js.map} +0 -0
  105. /package/dist/{config-mutate-G7HW2R6H.js.map → config-mutate-MMTHEXWM.js.map} +0 -0
  106. /package/dist/{config-mutator-XWWW3PSV.js.map → config-mutator-R75BQXMB.js.map} +0 -0
  107. /package/dist/{contributions-GZVKJXSJ.js.map → contributions-3ZE2TK24.js.map} +0 -0
  108. /package/dist/{doctor-QWVUVWTF.js.map → doctor-TP4GSLZV.js.map} +0 -0
  109. /package/dist/{follow-up-tool-PTKDMFA7.js.map → follow-up-tool-L3QXZIU2.js.map} +0 -0
  110. /package/dist/{hub-BHCBRQZP.js.map → hub-U65U7SE6.js.map} +0 -0
  111. /package/dist/{promote-73ZGTRDV.js.map → promote-GP2MZX7S.js.map} +0 -0
  112. /package/dist/{query-KHW4AERR.js.map → query-WHNB46XD.js.map} +0 -0
  113. /package/dist/{query-settings-P6RUUEFO.js.map → query-settings-U5ZMQREP.js.map} +0 -0
  114. /package/dist/{registry-RQBXAPUZ.js.map → registry-GXGHPROE.js.map} +0 -0
  115. /package/dist/{request-planner-EUIMJ7R3.js.map → request-planner-HALSGCA5.js.map} +0 -0
  116. /package/dist/{review-candidates-KKGDAZIB.js.map → review-candidates-WIXZZCF7.js.map} +0 -0
  117. /package/dist/{routing-FQNGOTMV.js.map → routing-U543HNNU.js.map} +0 -0
  118. /package/dist/{schedule-tool-2OWGAK4H.js.map → schedule-tool-FIKDTGXF.js.map} +0 -0
  119. /package/dist/{scheduler-JXZBVPOS.js.map → scheduler-OEKYXZPJ.js.map} +0 -0
  120. /package/dist/{seat-DZB3NSZ7.js.map → seat-FWF2HKWS.js.map} +0 -0
  121. /package/dist/{select-YD4CA7FP.js.map → select-QDSG7NQX.js.map} +0 -0
  122. /package/dist/{set-enabled-UK4SE5MZ.js.map → set-enabled-W7U5SXYX.js.map} +0 -0
  123. /package/dist/{tool-2PA2USUG.js.map → tool-QIFV7Q4M.js.map} +0 -0
  124. /package/dist/{tool-DIJN4XBY.js.map → tool-VN7W6QGC.js.map} +0 -0
  125. /package/dist/{wiki-CQBXLZ2Y.js.map → wiki-TN5WFJ5P.js.map} +0 -0
  126. /package/dist/{wiki-enrich-PA6JS2YN.js.map → wiki-enrich-GEHA6NJQ.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as Re}from"./chunk-GTJIKXDB.js";import{A as Zt,H as rn,j as B}from"./chunk-ZAH74SFX.js";import{a as w}from"./chunk-7LN4VKDU.js";import{f as en,i as tn,k as Ae,l as _e,n as q,o as M,q as nn}from"./chunk-LQS27HSV.js";import{t as Jt,u as Yt}from"./chunk-3LU2ZQZJ.js";import{d as Gt,e as Kt}from"./chunk-AQASR6KR.js";import{b as Qt}from"./chunk-YMX3QCV7.js";import{a as qt,b as Ht,d as zt,e as Xt}from"./chunk-MNG2AMKZ.js";import{g as Ft,h as Wt,i as Vt,k as Ut,l as Bt}from"./chunk-ZQONMM3B.js";import{a as Mt,c as jt}from"./chunk-KP7KDLZ2.js";import{X as Ot,Z as ne,_ as ve,aa as $e,b as xe}from"./chunk-S5FRIHWM.js";import{q as Lt}from"./chunk-LH3GOBZP.js";import{a as Pt,b as Nt}from"./chunk-BFONYVOM.js";import{Ca as Se,Ka as Tt,La as Ct,Q as _t,R as Rt,S as It,T as Et,Ua as Dt,n as te,o as $t,p as At,q as ni}from"./chunk-5VPU5FHB.js";import{a as we,h as ri}from"./chunk-BRK6M6LA.js";import{f as ke,n as ii}from"./chunk-UIBUZ2N3.js";import{existsSync as si,readdirSync as oi,readFileSync as ai,statSync as li}from"fs";import{resolve as ci}from"path";function sn(t,e,n=Date.now(),i=7){let r=i*864e5,s=new Map;for(let a of e){let o=s.get(a.workflowId);o?o.push(a):s.set(a.workflowId,[a])}return t.map(a=>{let o=s.get(a.id)??[],l=o.filter(g=>n-g.at<=r),c=o.filter(g=>n-g.at>r&&n-g.at<=r*2),u=l.filter(g=>g.status==="failed").length,d=o.filter(g=>g.status==="paused").length,p=o.length?Math.max(...o.map(g=>g.at)):null,f=o.length?c.length>0&&l.length===0?"dormant":l.length>0&&u*2>=l.length?"failing":l.length>0?"active":"quiet":"never";return{id:a.id,name:a.name||a.id,state:f,lastRunAt:p,recent:l.length,prior:c.length,failed:u,paused:d}}).sort((a,o)=>{let l={dormant:0,failing:1,active:2,quiet:3,never:4};return l[a.state]-l[o.state]||(o.lastRunAt??0)-(a.lastRunAt??0)})}var re=new Map;function Wa(t,e=1e3){if(!si(t))return[];let n=oi(t).filter(s=>s.endsWith(".jsonl")).map(s=>{let a=ci(t,s);return{path:a,mtime:li(a).mtimeMs}}).sort((s,a)=>a.mtime-s.mtime).slice(0,e),i=new Set(n.map(s=>s.path));for(let s of re.keys())i.has(s)||re.delete(s);let r=[];for(let{path:s,mtime:a}of n){let o=re.get(s);if(o&&o.mtime===a){o.summary&&r.push(o.summary);continue}let l=ui(s,a);re.set(s,{mtime:a,summary:l}),l&&r.push(l)}return r}function ui(t,e){try{let n=ai(t,"utf-8").split(`
1
+ import{a as Re}from"./chunk-GTJIKXDB.js";import{A as Zt,H as rn,j as B}from"./chunk-2K2QDTGP.js";import{a as w}from"./chunk-7LN4VKDU.js";import{f as en,i as tn,k as Ae,l as _e,n as q,o as M,q as nn}from"./chunk-LQS27HSV.js";import{t as Jt,u as Yt}from"./chunk-F5KWRBTF.js";import{d as Gt,e as Kt}from"./chunk-AQASR6KR.js";import{b as Qt}from"./chunk-YMX3QCV7.js";import{a as qt,b as Ht,d as zt,e as Xt}from"./chunk-MNG2AMKZ.js";import{g as Ft,h as Wt,i as Vt,k as Ut,l as Bt}from"./chunk-HOLJZIVJ.js";import{a as Mt,c as jt}from"./chunk-KP7KDLZ2.js";import{X as Ot,Z as ne,_ as ve,aa as $e,b as xe}from"./chunk-UWUJVING.js";import{q as Lt}from"./chunk-USCFJVVI.js";import{a as Pt,b as Nt}from"./chunk-NUMWHIFL.js";import{Ca as Se,Ka as Tt,La as Ct,Q as _t,R as Rt,S as It,T as Et,Ua as Dt,n as te,o as $t,p as At,q as ni}from"./chunk-GVJMPSE2.js";import{a as we,h as ri}from"./chunk-BRK6M6LA.js";import{f as ke,n as ii}from"./chunk-UIBUZ2N3.js";import{existsSync as si,readdirSync as oi,readFileSync as ai,statSync as li}from"fs";import{resolve as ci}from"path";function sn(t,e,n=Date.now(),i=7){let r=i*864e5,s=new Map;for(let a of e){let o=s.get(a.workflowId);o?o.push(a):s.set(a.workflowId,[a])}return t.map(a=>{let o=s.get(a.id)??[],l=o.filter(g=>n-g.at<=r),c=o.filter(g=>n-g.at>r&&n-g.at<=r*2),u=l.filter(g=>g.status==="failed").length,d=o.filter(g=>g.status==="paused").length,p=o.length?Math.max(...o.map(g=>g.at)):null,f=o.length?c.length>0&&l.length===0?"dormant":l.length>0&&u*2>=l.length?"failing":l.length>0?"active":"quiet":"never";return{id:a.id,name:a.name||a.id,state:f,lastRunAt:p,recent:l.length,prior:c.length,failed:u,paused:d}}).sort((a,o)=>{let l={dormant:0,failing:1,active:2,quiet:3,never:4};return l[a.state]-l[o.state]||(o.lastRunAt??0)-(a.lastRunAt??0)})}var re=new Map;function Wa(t,e=1e3){if(!si(t))return[];let n=oi(t).filter(s=>s.endsWith(".jsonl")).map(s=>{let a=ci(t,s);return{path:a,mtime:li(a).mtimeMs}}).sort((s,a)=>a.mtime-s.mtime).slice(0,e),i=new Set(n.map(s=>s.path));for(let s of re.keys())i.has(s)||re.delete(s);let r=[];for(let{path:s,mtime:a}of n){let o=re.get(s);if(o&&o.mtime===a){o.summary&&r.push(o.summary);continue}let l=ui(s,a);re.set(s,{mtime:a,summary:l}),l&&r.push(l)}return r}function ui(t,e){try{let n=ai(t,"utf-8").split(`
2
2
  `).filter(Boolean);if(!n.length)return null;let i=JSON.parse(n[0]),r=i.run?.workflowId;if(!r)return null;let s=i.run?.status??"unknown";for(let a=n.length-1;a>=0;a--){let o=JSON.parse(n[a]),l=o.status??o.run?.status;if(l){s=l;break}}return{workflowId:r,status:s,at:e}}catch{return null}}var di={failStreak:3,disabledDays:30,missedFires:2,graceMs:15*6e4},k={routines:200,summary:160,filters:6,filterValue:60,text:120},pi=(t,e,n)=>{try{return Lt(t,e,n)}catch{return null}},on=864e5;function qa(t){let e=t.now??Date.now(),n={...di,...t.thresholds},i=t.nextFire??pi,r=[];for(let o of t.crons){let l=t.cronRuns.get(o.id)??[],c=o.timezone||"UTC",u=l.map(f=>({at:Date.parse(f.startedAt),status:f.status})),d=l[0],p={id:`cron:${o.id}`,source:"cron",kind:"schedule",name:A(o.id,k.text),trigger:{schedule:A(o.schedule,k.text),timezone:c},agent:o.agent||null,enabled:o.enabled,state:o.enabled?"enabled":"disabled",nextRunAt:o.enabled?Ie(o.nextRun)??Ie(i(o.schedule,new Date(e),c)):null,lastRun:d?{at:d.startedAt,status:d.status,summary:yi(d.status==="success"?void 0:d.errorSummary,k.summary)}:null,lastSuccessAt:l.find(f=>f.status==="success")?.startedAt??null,consecutiveFailures:an(u),sampledRuns:l.length,flags:[],attention:null};p.flags=ln(p,u,o.schedule,c,null,e,n,i),r.push(cn(p))}let s=new Map(sn(t.workflows.map(o=>({id:o.id,name:o.title})),t.workflowRuns,e).map(o=>[o.id,o])),a=new Map;for(let o of t.workflowRuns){let l=a.get(o.workflowId);l?l.push(o):a.set(o.workflowId,[o])}for(let o of t.workflows){let l=o.nodes.find(I=>I.type.startsWith("trigger."));if(!l||l.type!=="trigger.cron"&&l.type!=="trigger.hook")continue;let c=l.config??{},u=o.state||"active",d=u==="active",p=(a.get(o.id)??[]).slice().sort((I,ye)=>ye.at-I.at),f=p.map(I=>({at:I.at,status:mi(I.status)})),g=f[0],h=l.type==="trigger.cron",b=typeof c.spec=="string"?c.spec:"",C=typeof c.timezone=="string"?c.timezone:"UTC",O={id:`workflow:${o.id}`,source:"workflow",kind:h?"schedule":"event",name:A(o.title||o.id,k.text),trigger:h?{schedule:A(b,k.text),timezone:C}:{event:A(typeof c.event=="string"?c.event:"",k.text),filters:bi(c.filter,o)},agent:hi(o),enabled:d,state:u,nextRunAt:h&&d&&b?Ie(i(b,new Date(e),C)):null,lastRun:g?{at:new Date(g.at).toISOString(),status:g.status}:null,lastSuccessAt:(()=>{let I=f.find(ye=>ye.status==="success");return I?new Date(I.at).toISOString():null})(),consecutiveFailures:an(f),sampledRuns:p.length,flags:[],attention:null},ee=Date.parse(o.updated||o.created||"");O.flags=h?ln(O,f,b,C,Number.isFinite(ee)?ee:null,e,n,i):fi(O,s.get(o.id)?.state==="dormant",Number.isFinite(ee)?ee:null,e,n),r.push(cn(O))}return r.sort(gi).slice(0,k.routines)}function an(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 ln(t,e,n,i,r,s,a,o){let l=[],c=e.length?e[0].at:null;if(!t.enabled){let p=dn(c,r,s,a);return p&&l.push(p),l}if(t.consecutiveFailures>=a.failStreak&&l.push({reason:"failing",detail:`${t.consecutiveFailures} failed attempts in a row`}),c===null)return l.push({reason:"never-ran",detail:"No persisted attempt"}),l;let u=new Date(c),d=null;for(let p=0;p<a.missedFires&&(d=o(n,u,i),!!d);p++)u=d;return d&&s>d.getTime()+a.graceMs&&l.push({reason:"overdue",detail:`No attempt since ${new Date(c).toISOString()}; ${a.missedFires} scheduled fires missed`}),l}function fi(t,e,n,i,r){let s=[],a=t.lastRun?Date.parse(t.lastRun.at):null;if(!t.enabled){let o=dn(a,n,i,r);return o&&s.push(o),s}return t.consecutiveFailures>=r.failStreak&&s.push({reason:"failing",detail:`${t.consecutiveFailures} failed runs in a row`}),a===null?s.push({reason:"never-ran",detail:"No run recorded for this trigger"}):e&&s.push({reason:"dormant",detail:"Fired in the prior week, silent in the last one"}),s}function dn(t,e,n,i){let r=Math.max(t??0,e??0);return r&&n-r<i.disabledDays*on?null:{reason:"disabled-long",detail:r?`Disabled; no activity for ${Math.floor((n-r)/on)} days`:"Disabled and never ran"}}function cn(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 gi(t,e){let n=t.attention?un[t.attention]:3,i=e.attention?un[e.attention]:3;return n-i||Number(e.enabled)-Number(t.enabled)||t.name.localeCompare(e.name)}function mi(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 hi(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 bi(t,e){let n=[],i=e?.project;if(i&&n.push(A(`project=${i}`,k.filterValue)),t&&typeof t=="object"&&!Array.isArray(t))for(let[r,s]of Object.entries(t)){let a=Array.isArray(s)?s.map(String):s==null?[]:[String(s)];a.length&&n.push(A(`${r}=${a.join(",")}`,k.filterValue))}return n.slice(0,k.filters)}function Ie(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 yi(t,e){return t===void 0?void 0:A(t,e)}import{mkdirSync as wi,readFileSync as ki,renameSync as Si,writeFileSync as xi}from"fs";import{resolve as vi}from"path";function pn(t){return vi(_e(t),"_state.json")}function x(t){try{let e=JSON.parse(ki(pn(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 H(t,e){wi(_e(t),{recursive:!0});let n=pn(t),i=`${n}.${process.pid}.tmp`;xi(i,JSON.stringify(e,null,2)+`
3
3
  `),Si(i,n)}function fn(t,e,n,i=Date.now()){let r=x(t),s={};for(let[a,o]of Object.entries(r.snoozed))Date.parse(o)>i&&(s[a]=o);s[e]=n.toISOString(),H(t,{...r,snoozed:s})}function Ka(t,e){H(t,{...x(t),lastDigest:e})}function Ee(t,e,n,i=Date.now()){let r=x(t),s=new Set(n),a={};for(let[l,c]of Object.entries(r.popped??{}))s.has(l)&&(a[l]=c);a[e]=new Date(i).toISOString();let o=(r.wanted??[]).filter(l=>l!==e&&s.has(l));H(t,{...r,popped:a,wanted:o})}function gn(t,e){let n=x(t);H(t,{...n,wanted:[...(n.wanted??[]).filter(i=>i!==e),e]})}function Ja(t,e=Date.now()){H(t,{...x(t),popped:{},passAt:new Date(e).toISOString()})}import{existsSync as z,readdirSync as Fi,readFileSync as Wi}from"fs";import{resolve as _}from"path";import{randomBytes as bn}from"crypto";import{existsSync as Ai,mkdirSync as _i,readdirSync as Ri,readFileSync as Ii,renameSync as yn,unlinkSync as Ei,writeFileSync as Ti}from"fs";import{resolve as wn}from"path";function mn(t){return[...t.account?["--account",t.account]:[],...t.store?["--store",t.store]:[]]}var $i=t=>t.trim().split(`
4
4
  `).pop()?.slice(0,300)||"no output";async function hn(t,e,n,i=Re){let r=await i(t.bin,[...mn(t),"send","text","--to",e,"--message",n,"--no-preview"],{timeoutMs:6e4});return r.code===0?{ok:!0}:{ok:!1,error:`wacli send failed: ${$i(r.stderr||r.stdout)}`}}async function Qa(t,e,n,i,r=Re){return(await r(t.bin,[...mn(t),"--read-only","media","download","--chat",e,"--id",n,"--output",i],{timeoutMs:12e4})).code===0}var Ci=2e3,Di=t=>hn(t.wacli,t.to,t.text);function Te(t){return wn(t,".agentx","whatsapp-triage","drafts")}var Pi=t=>/^[a-z0-9-]{8,64}$/.test(t),ie=(t,e)=>wn(Te(t),`${e}.json`);function kn(t,e){_i(Te(t),{recursive:!0});let n=ie(t,e.id),i=`${n}.${process.pid}.tmp`;Ti(i,JSON.stringify(e,null,2)+`
@@ -52,7 +52,7 @@ import{a as Re}from"./chunk-GTJIKXDB.js";import{A as Zt,H as rn,j as B}from"./ch
52
52
  CREATE INDEX IF NOT EXISTS idx_request_plan_events ON request_plan_events(request_id, at);
53
53
  `)}function $n(t){return!!t.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'request_plans'").get()}function Ce(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 vn(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 Oi={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"},oe=class{constructor(e){this.db=e;Li(e)}create(e,n,i,r){let s=this.db.prepare("INSERT INTO request_plans (request_id, created_by, created_at, state) VALUES (?, ?, ?, 'active')"),a=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(()=>{s.run(e,n,r),i.forEach((o,l)=>{let c=l===0,u=c&&o.agentId===n&&o.kind!=="message";a.run(e,l+1,o.name,o.kind,o.agentId,o.doneWhen,c?"active":"pending",o.needsApproval?1:0,o.message??null,o.toChannel??null,o.toChat??null,o.toAccount??null,o.checkUrl??null,o.checkContains??null,o.stallMinutes??null,u?r:null,r)}),this.event(e,null,"created",`${i.length} steps, written by ${n}`,r)})()}get(e){let n=this.db.prepare("SELECT * FROM request_plans WHERE request_id = ?").get(e);return n?Ce(n):null}steps(e){return this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? ORDER BY idx").all(e).map(vn)}step(e,n){let i=this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? AND idx = ?").get(e,n);return i?vn(i):null}listActive(){return this.db.prepare("SELECT * FROM request_plans WHERE state = 'active' ORDER BY created_at, rowid").all().map(Ce)}updateStep(e,n,i){let r=[],s=[];for(let[a,o]of Object.entries(i)){let l=Oi[a];!l||o===void 0||(r.push(`${l} = ?`),s.push(typeof o=="boolean"?o?1:0:o))}r.length&&this.db.prepare(`UPDATE request_plan_steps SET ${r.join(", ")} WHERE request_id = ? AND idx = ?`).run(...s,e,n)}finish(e,n,i){return this.db.prepare("UPDATE request_plans SET state = ?, finished_at = ? WHERE request_id = ? AND state = 'active'").run(n,i,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(Ce)}event(e,n,i,r,s){this.db.prepare("INSERT INTO request_plan_events (request_id, step, at, kind, detail) VALUES (?, ?, ?, ?, ?)").run(e,n,s,i,r.replace(/\s+/g," ").trim().slice(0,Ni))}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(i=>({requestId:i.request_id,step:i.step??null,at:i.at,kind:i.kind,detail:i.detail}))}},cl=_t;import{existsSync as Mi,readFileSync as ji}from"fs";Dt();ri();function An(t){let e=Pt(t),n={};if(Mi(e))try{n=Tt(JSON.parse(ji(e,"utf-8")))}catch{n={}}let i=Se.safeParse(n?.requests);return i.success?i.data:Se.parse(void 0)}async function ml(t,e={}){let n=(t.channels??[]).filter(i=>!we.has(i.toLowerCase().split("@")[0]));return n.length?{success:!1,error:`unknown channel ${n.map(i=>`"${i}"`).join(", ")}: use ${[...we].join(", ")}`}:Nt(i=>{let r=i.requests??={};for(let s of["enabled","channels","from","staleAfterHours","retentionDays"])t[s]!==void 0&&(r[s]=t[s]);if(t.plans){let s=r.plans??={};for(let a of["enabled","stallMinutes","maxNudges","approveKinds","disabledAgents","requireForWork","requireOverMinutes"])t.plans[a]!==void 0&&(s[a]=t.plans[a])}if(t.headlines?.enabled!==void 0&&((r.headlines??={}).enabled=t.headlines.enabled),t.checkers){let s=r.checkers??={};for(let a of["enabled","checkEveryMinutes"])t.checkers[a]!==void 0&&(s[a]=t.checkers[a])}},{configPath:e.configPath,reload:e.reload})}var In=["card","schedule","memory","wiki","whatsapp","request"],Vi=280;function j(t,e=Vi){let n=t.replace(/\s+/g," ").trim();return n.length>e?`${n.slice(0,e-1)}\u2026`:n}function De(t){if(t.configPath)return _(t.configPath);let e=[_(t.root,"agentx.json"),_(t.root,".agentx","config.json")];return e.find(n=>z(n))??e[0]}function Pe(t){return t.wikiDir?_(t.wikiDir):_(t.root,".agentx","wiki")}function Ui(t){return M(t.root,"pending").map(Bi)}function Bi(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:j([t.context,t.draft?`Suggested message: ${t.draft}`:""].filter(Boolean).join(" \xB7 "))}:{}}}function qi(t){let e=De(t);if(!z(e))return[];let n;try{n=JSON.parse(Wi(e,"utf-8"))}catch{return[]}let i=new Date(t.now??Date.now()),r=[];for(let[s,a]of Object.entries(n?.crons??{})){let o=a?.approval;if(!o||o.action!=="create"&&o.action!=="delete")continue;let l=a.timezone||"UTC",c=a.schedule?Ft(a.schedule):"",u=a.schedule?`${c.charAt(0).toLowerCase()}${c.slice(1)} (${a.schedule})`:"no schedule",d=String(a.prompt??a.command??""),p=o.action==="create";r.push({key:`schedule:${s}`,kind:"schedule",title:p?`New schedule "${s}" for ${a.agent??"an agent"}`:`Delete schedule "${s}"`,ask:p?`Let ${a.agent??"the agent"} run this ${u}?`:`Remove the schedule "${s}" (${u})?`,yes:p?"enable it":"remove it",no:p?"drop the request":"keep the schedule",raised_by:String(o.requestedBy??"unknown"),created_at:String(o.requestedAt??""),detail:j(`${d}${p&&a.schedule?` \xB7 first run ${Vt(Wt(a.schedule,l,i),l)}`:""}`),more:"agentx schedule list"})}return r}function En(t){let e=_(t,".agentx","memory");return z(e)?Fi(e).filter(n=>n.endsWith(".jsonl")).map(n=>n.slice(0,-6)).sort():[]}function Hi(t){let e=En(t.root);if(e.length===0)return[];let n=new xe(t.root),i=[];for(let r of e)for(let s of n.held(r))i.push({key:`memory:${r}/${s.id}`,kind:"memory",title:`Fact ${r} learned from ${s.source.channel}`,ask:`Let ${r} use this fact in its prompts?`,yes:"use it",no:"keep it out for good",raised_by:r,created_at:s.createdAt,detail:j(s.content),more:`agentx memory facts held --agent ${r}`});return i}function zi(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 Xi(t){return Kt(Pe(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:j(`${zi(n)} ${e.article.content}`),more:`agentx wiki proposals show ${e.id}`}})}function Gi(t){return Sn(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:j(`${e.triage}: ${e.summary}`),more:"agentx whatsapp triage log"}))}function X(t){if(t.requests)return t.requests;if(_(t.root)!==process.cwd()||!z(_(t.root,".agentx","db.sqlite")))return null;let e=ke({quiet:!0});if(!e)return null;let n=_n.get(e);return!n&&!Rt(e)?null:(n||_n.set(e,n=new It(e)),n)}var _n=new WeakMap;function Cl(t){if(t.plans)return t.plans;if(t.requests||_(t.root)!==process.cwd()||!z(_(t.root,".agentx","db.sqlite")))return null;let e=ke({quiet:!0});if(!e||!$n(e))return null;let n=Rn.get(e);return n||Rn.set(e,n=new oe(e)),n}var Rn=new WeakMap;function Ki(t){let e=X(t);return e?e.listByState("needs_attention").map(n=>({key:`request:${n.id}`,kind:"request",title:B(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:j(`${n.attentionReason??"It needs attention"}. You said (${n.channel}): ${n.text}`),more:`agentx requests show ${n.id}`})):[]}var Tn={card:Ui,schedule:qi,memory:Hi,wiki:Xi,whatsapp:Gi,request:Ki};function Ji(t,e){let n=t.expires?Date.parse(t.expires):1/0,i=e.expires?Date.parse(e.expires):1/0;return n!==i?n-i:(Date.parse(t.created_at)||0)-(Date.parse(e.created_at)||0)}function Dl(t,e={}){let n=t.now??Date.now(),{snoozed:i}=x(t.root),r=[],s=[],a=0;for(let o of e.kinds??In){let l;try{l=Tn[o](t)}catch(c){s.push({kind:o,error:String(c?.message??c).slice(0,200)});continue}for(let c of l){let u=i[c.key];if(u&&Date.parse(u)>n){if(!e.includeSnoozed){a++;continue}c.snoozed_until=u}r.push(c)}}return r.sort(Ji),{items:r,snoozed:a,errors:s}}function Yi(t){let e=t.indexOf(":");if(e<=0)return null;let n=t.slice(0,e),i=t.slice(e+1);return!In.includes(n)||!i?null:{kind:n,ref:i}}function Zi(t,e,n){switch(e){case"card":return q(t.root,n)?.status==="pending";case"wiki":return Gt(Pe(t),n)?.status==="pending";case"whatsapp":return se(t.root,n)?.status==="pending";default:return Tn[e](t).some(i=>i.key===`${e}:${n}`)}}async function Cn(t,e,n,i={}){let r=Yi(e);if(!r)return{ok:!1,error:`unknown item "${e}": use a key from \`agentx approvals list\``};let{kind:s,ref:a}=r,o=t.now??Date.now(),l=i.by??"operator";if(n==="later"){if(!Zi(t,s,a))return{ok:!1,error:`nothing waiting for "${e}"`};let u=i.laterHours&&i.laterHours>0?i.laterHours:24,d=new Date(o+u*36e5);return fn(t.root,e,d,o),{ok:!0,message:`${e} put off until ${d.toISOString()}`}}let c=n==="yes";switch(s){case"card":{let u=nn(t.root,a,c?"yes":"no",{by:l,note:i.note,now:o,choice:i.choice,text:i.text});return u.ok?{ok:!0,message:`${e}: ${u.card.raised_by} will be told ${c?"yes":"no"}${u.card.choice?` (${u.card.choice}${u.card.choice_suggested?", the suggested option":""})`:""}`}:u}case"schedule":{let u=await(c?Ut:Bt)(a,{configPath:De(t),reload:t.reload});return u.success?{ok:!0,message:u.message}:{ok:!1,error:u.message}}case"memory":{let u=a.indexOf("/");if(u<=0)return{ok:!1,error:"memory keys look like memory:<agent>/<fact-id>"};let d=a.slice(0,u),p=a.slice(u+1);if(!En(t.root).includes(d))return{ok:!1,error:`no memory for agent "${d}"`};let f=new xe(t.root);return f.held(d).some(g=>g.id===p)?(f.review(d,p,c?"approved":"rejected",l),{ok:!0,message:`${e} ${c?"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 u=Pe(t),d=c?Jt(u,a,{by:l,force:i.force,now:o}):Yt(u,a,{by:l,reason:i.note,now:o});return d.ok?{ok:!0,message:c?`${d.proposal.article.path} written to the shared wiki`:`${e} rejected`}:d}case"whatsapp":{let u=await xn(t.root,a,c?"yes":"no",{by:l,now:o,send:t.sendWhatsApp});return u.ok?{ok:!0,message:c?`${e}: sent to ${u.draft.chat_name||u.draft.to}`:`${e}: dropped, nothing sent`}:u}case"request":{let u=X(t),d=u?.get(a);return!u||!d||d.state!=="needs_attention"?{ok:!1,error:`nothing waiting for "${e}"`}:c?An(De(t)).enabled?(u.requestPickup(a,o),{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."}:(u.close(a,"dropped",i.note?.trim()||`dropped by ${l}`,o),{ok:!0,message:`${e}: dropped`})}}}var Dn=new Set(["127.0.0.1","::1","::ffff:127.0.0.1"]);function Nl(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"}function Ll(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)||/^\/workflow-runs\/[^/]+\/cancel$/.test(t)||t==="/api/signals/stop"||t==="/api/signals/resume"||t==="/api/signals/drop"||t==="/api/review-gate/replay"}function Ol(t){return Dn.has(t)}function Ml(t){if(t.foreignBrowser)return{allowed:!1,reason:"foreign-browser-origin"};if(t.enforcementDisabled)return{allowed:!0,reason:"disabled"};if(Dn.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 jl(t,e=process.env){let n=new Set;e.MESH_TOKEN&&n.add(e.MESH_TOKEN);for(let i of t.mesh?.peers||[])i.token&&n.add(i.token);return n}function Fl(t,e,n=process.env){let i=s=>s.replace(/\/+$/,"");return(e===i(t.daemonUrl)?t.token:t.daemons.find(s=>i(s.url)===e)?.token)||n.MESH_TOKEN||void 0}function ae(t){return(Array.isArray(t)?t[0]:t)?.trim()??""}function Qi(t){try{return new URL(t).host.toLowerCase()}catch{return null}}function es(t=process.env){return new Set((t.AGENTX_ALLOWED_ORIGINS||"").split(",").map(e=>e.trim().replace(/\/+$/,"").toLowerCase()).filter(Boolean))}function Vl(t,e=es()){let n=ae(t.origin);if(n){if(e.has(n.replace(/\/+$/,"").toLowerCase()))return"same-origin";let r=Qi(n),s=[ae(t.host),ae(t["x-forwarded-host"])].filter(Boolean).map(a=>a.toLowerCase());return r&&s.includes(r)?"same-origin":"foreign"}let i=ae(t["sec-fetch-site"]).toLowerCase();return i==="cross-site"||i==="same-site"?"foreign":"none"}function Ul(t){let e=(t||"GET").toUpperCase();return e!=="GET"&&e!=="HEAD"}import{existsSync as rr,mkdirSync as Es,readFileSync as Ts,renameSync as Cs,writeFileSync as Ds}from"fs";import{homedir as Ps}from"os";import{dirname as Ns,join as Ls}from"path";import{execFile as ds,execFileSync as ps}from"child_process";import{execFileSync as ts}from"child_process";import{existsSync as Nn,mkdirSync as ns,readdirSync as rs,readFileSync as Ln,renameSync as is,writeFileSync as ss}from"fs";import{homedir as On}from"os";import{join as Le}from"path";var v="siri:",Mn="com.apple.ttsbundle.gryphon-neural_",jn=t=>!!t&&t.startsWith(Mn),os=["/usr/bin/say","/usr/bin/defaults","/usr/bin/plutil"],as=()=>{try{return ts("/usr/bin/defaults",["read","com.apple.Accessibility"],{stdio:"ignore",timeout:5e3}),!0}catch{return!1}},Ne;function Oe(t={}){let e=t.platform!==void 0||t.exists!==void 0||t.prefDomain!==void 0;if(!e&&Ne!==void 0)return Ne;let{platform:n=process.platform,exists:i=Nn,prefDomain:r=as}=t,s=n==="darwin"&&os.every(a=>i(a))&&r();return e||(Ne=s),s}var Fn=["/System/Library/AssetsV2/com_apple_MobileAsset_Trial_Siri_SiriTextToSpeech/purpose_auto","/System/Library/AssetsV2/com_apple_MobileAsset_UAF_Siri_TextToSpeech/purpose_auto"],Wn={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"},Me=t=>Wn[t.toLowerCase()]??null;function le(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 ls=/com\.apple\.siri\.tts\.voice\.([a-z]{2})_([A-Z]{2})\.([a-z]+)\.neural\.premium/g;function cs(t){let e=new Map;for(let n of t)for(let[,i,r,s]of n.matchAll(ls)){let a=`${i}-${r}`,o=`${Mn}${s}_${a}_premium`;e.has(o)||e.set(o,{id:o,name:s[0].toUpperCase()+s.slice(1),locale:a,quality:"premium",gender:Wn[s]??null,siri:!0})}return[...e.values()]}function ce(t=Fn,e={}){if(!Oe(e))return[];let n=[];for(let i of t){let r;try{r=rs(i)}catch{continue}for(let s of r)try{n.push(Ln(Le(i,s,"Info.plist"),"latin1"))}catch{}}return cs(n)}var Pn=`#!/bin/sh
55
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);this.db.transaction(()=>{s.run(e,n,r),i.forEach((o,l)=>{let c=l===0,u=c&&o.agentId===n&&o.kind!=="message";a.run(e,l+1,o.name,o.kind,o.agentId,o.doneWhen,c?"active":"pending",o.needsApproval?1:0,o.message??null,o.toChannel??null,o.toChat??null,o.toAccount??null,o.checkUrl??null,o.checkContains??null,o.stallMinutes??null,u?r:null,r)}),this.event(e,null,"created",`${i.length} steps, written by ${n}`,r)})()}get(e){let n=this.db.prepare("SELECT * FROM request_plans WHERE request_id = ?").get(e);return n?Ce(n):null}steps(e){return this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? ORDER BY idx").all(e).map(vn)}step(e,n){let i=this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? AND idx = ?").get(e,n);return i?vn(i):null}listActive(){return this.db.prepare("SELECT * FROM request_plans WHERE state = 'active' ORDER BY created_at, rowid").all().map(Ce)}updateStep(e,n,i){let r=[],s=[];for(let[a,o]of Object.entries(i)){let l=Oi[a];!l||o===void 0||(r.push(`${l} = ?`),s.push(typeof o=="boolean"?o?1:0:o))}r.length&&this.db.prepare(`UPDATE request_plan_steps SET ${r.join(", ")} WHERE request_id = ? AND idx = ?`).run(...s,e,n)}finish(e,n,i){return this.db.prepare("UPDATE request_plans SET state = ?, finished_at = ? WHERE request_id = ? AND state = 'active'").run(n,i,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(Ce)}event(e,n,i,r,s){this.db.prepare("INSERT INTO request_plan_events (request_id, step, at, kind, detail) VALUES (?, ?, ?, ?, ?)").run(e,n,s,i,r.replace(/\s+/g," ").trim().slice(0,Ni))}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(i=>({requestId:i.request_id,step:i.step??null,at:i.at,kind:i.kind,detail:i.detail}))}},cl=_t;import{existsSync as Mi,readFileSync as ji}from"fs";Dt();ri();function An(t){let e=Pt(t),n={};if(Mi(e))try{n=Tt(JSON.parse(ji(e,"utf-8")))}catch{n={}}let i=Se.safeParse(n?.requests);return i.success?i.data:Se.parse(void 0)}async function ml(t,e={}){let n=(t.channels??[]).filter(i=>!we.has(i.toLowerCase().split("@")[0]));return n.length?{success:!1,error:`unknown channel ${n.map(i=>`"${i}"`).join(", ")}: use ${[...we].join(", ")}`}:Nt(i=>{let r=i.requests??={};for(let s of["enabled","channels","from","staleAfterHours","retentionDays","settleHandedBack"])t[s]!==void 0&&(r[s]=t[s]);if(t.plans){let s=r.plans??={};for(let a of["enabled","stallMinutes","maxNudges","approveKinds","disabledAgents","requireForWork","requireOverMinutes"])t.plans[a]!==void 0&&(s[a]=t.plans[a])}if(t.headlines?.enabled!==void 0&&((r.headlines??={}).enabled=t.headlines.enabled),t.checkers){let s=r.checkers??={};for(let a of["enabled","checkEveryMinutes"])t.checkers[a]!==void 0&&(s[a]=t.checkers[a])}},{configPath:e.configPath,reload:e.reload})}var In=["card","schedule","memory","wiki","whatsapp","request"],Vi=280;function j(t,e=Vi){let n=t.replace(/\s+/g," ").trim();return n.length>e?`${n.slice(0,e-1)}\u2026`:n}function De(t){if(t.configPath)return _(t.configPath);let e=[_(t.root,"agentx.json"),_(t.root,".agentx","config.json")];return e.find(n=>z(n))??e[0]}function Pe(t){return t.wikiDir?_(t.wikiDir):_(t.root,".agentx","wiki")}function Ui(t){return M(t.root,"pending").map(Bi)}function Bi(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:j([t.context,t.draft?`Suggested message: ${t.draft}`:""].filter(Boolean).join(" \xB7 "))}:{}}}function qi(t){let e=De(t);if(!z(e))return[];let n;try{n=JSON.parse(Wi(e,"utf-8"))}catch{return[]}let i=new Date(t.now??Date.now()),r=[];for(let[s,a]of Object.entries(n?.crons??{})){let o=a?.approval;if(!o||o.action!=="create"&&o.action!=="delete")continue;let l=a.timezone||"UTC",c=a.schedule?Ft(a.schedule):"",u=a.schedule?`${c.charAt(0).toLowerCase()}${c.slice(1)} (${a.schedule})`:"no schedule",d=String(a.prompt??a.command??""),p=o.action==="create";r.push({key:`schedule:${s}`,kind:"schedule",title:p?`New schedule "${s}" for ${a.agent??"an agent"}`:`Delete schedule "${s}"`,ask:p?`Let ${a.agent??"the agent"} run this ${u}?`:`Remove the schedule "${s}" (${u})?`,yes:p?"enable it":"remove it",no:p?"drop the request":"keep the schedule",raised_by:String(o.requestedBy??"unknown"),created_at:String(o.requestedAt??""),detail:j(`${d}${p&&a.schedule?` \xB7 first run ${Vt(Wt(a.schedule,l,i),l)}`:""}`),more:"agentx schedule list"})}return r}function En(t){let e=_(t,".agentx","memory");return z(e)?Fi(e).filter(n=>n.endsWith(".jsonl")).map(n=>n.slice(0,-6)).sort():[]}function Hi(t){let e=En(t.root);if(e.length===0)return[];let n=new xe(t.root),i=[];for(let r of e)for(let s of n.held(r))i.push({key:`memory:${r}/${s.id}`,kind:"memory",title:`Fact ${r} learned from ${s.source.channel}`,ask:`Let ${r} use this fact in its prompts?`,yes:"use it",no:"keep it out for good",raised_by:r,created_at:s.createdAt,detail:j(s.content),more:`agentx memory facts held --agent ${r}`});return i}function zi(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 Xi(t){return Kt(Pe(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:j(`${zi(n)} ${e.article.content}`),more:`agentx wiki proposals show ${e.id}`}})}function Gi(t){return Sn(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:j(`${e.triage}: ${e.summary}`),more:"agentx whatsapp triage log"}))}function X(t){if(t.requests)return t.requests;if(_(t.root)!==process.cwd()||!z(_(t.root,".agentx","db.sqlite")))return null;let e=ke({quiet:!0});if(!e)return null;let n=_n.get(e);return!n&&!Rt(e)?null:(n||_n.set(e,n=new It(e)),n)}var _n=new WeakMap;function Cl(t){if(t.plans)return t.plans;if(t.requests||_(t.root)!==process.cwd()||!z(_(t.root,".agentx","db.sqlite")))return null;let e=ke({quiet:!0});if(!e||!$n(e))return null;let n=Rn.get(e);return n||Rn.set(e,n=new oe(e)),n}var Rn=new WeakMap;function Ki(t){let e=X(t);return e?e.listByState("needs_attention").map(n=>({key:`request:${n.id}`,kind:"request",title:B(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:j(`${n.attentionReason??"It needs attention"}. You said (${n.channel}): ${n.text}`),more:`agentx requests show ${n.id}`})):[]}var Tn={card:Ui,schedule:qi,memory:Hi,wiki:Xi,whatsapp:Gi,request:Ki};function Ji(t,e){let n=t.expires?Date.parse(t.expires):1/0,i=e.expires?Date.parse(e.expires):1/0;return n!==i?n-i:(Date.parse(t.created_at)||0)-(Date.parse(e.created_at)||0)}function Dl(t,e={}){let n=t.now??Date.now(),{snoozed:i}=x(t.root),r=[],s=[],a=0;for(let o of e.kinds??In){let l;try{l=Tn[o](t)}catch(c){s.push({kind:o,error:String(c?.message??c).slice(0,200)});continue}for(let c of l){let u=i[c.key];if(u&&Date.parse(u)>n){if(!e.includeSnoozed){a++;continue}c.snoozed_until=u}r.push(c)}}return r.sort(Ji),{items:r,snoozed:a,errors:s}}function Yi(t){let e=t.indexOf(":");if(e<=0)return null;let n=t.slice(0,e),i=t.slice(e+1);return!In.includes(n)||!i?null:{kind:n,ref:i}}function Zi(t,e,n){switch(e){case"card":return q(t.root,n)?.status==="pending";case"wiki":return Gt(Pe(t),n)?.status==="pending";case"whatsapp":return se(t.root,n)?.status==="pending";default:return Tn[e](t).some(i=>i.key===`${e}:${n}`)}}async function Cn(t,e,n,i={}){let r=Yi(e);if(!r)return{ok:!1,error:`unknown item "${e}": use a key from \`agentx approvals list\``};let{kind:s,ref:a}=r,o=t.now??Date.now(),l=i.by??"operator";if(n==="later"){if(!Zi(t,s,a))return{ok:!1,error:`nothing waiting for "${e}"`};let u=i.laterHours&&i.laterHours>0?i.laterHours:24,d=new Date(o+u*36e5);return fn(t.root,e,d,o),{ok:!0,message:`${e} put off until ${d.toISOString()}`}}let c=n==="yes";switch(s){case"card":{let u=nn(t.root,a,c?"yes":"no",{by:l,note:i.note,now:o,choice:i.choice,text:i.text});return u.ok?{ok:!0,message:`${e}: ${u.card.raised_by} will be told ${c?"yes":"no"}${u.card.choice?` (${u.card.choice}${u.card.choice_suggested?", the suggested option":""})`:""}`}:u}case"schedule":{let u=await(c?Ut:Bt)(a,{configPath:De(t),reload:t.reload});return u.success?{ok:!0,message:u.message}:{ok:!1,error:u.message}}case"memory":{let u=a.indexOf("/");if(u<=0)return{ok:!1,error:"memory keys look like memory:<agent>/<fact-id>"};let d=a.slice(0,u),p=a.slice(u+1);if(!En(t.root).includes(d))return{ok:!1,error:`no memory for agent "${d}"`};let f=new xe(t.root);return f.held(d).some(g=>g.id===p)?(f.review(d,p,c?"approved":"rejected",l),{ok:!0,message:`${e} ${c?"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 u=Pe(t),d=c?Jt(u,a,{by:l,force:i.force,now:o}):Yt(u,a,{by:l,reason:i.note,now:o});return d.ok?{ok:!0,message:c?`${d.proposal.article.path} written to the shared wiki`:`${e} rejected`}:d}case"whatsapp":{let u=await xn(t.root,a,c?"yes":"no",{by:l,now:o,send:t.sendWhatsApp});return u.ok?{ok:!0,message:c?`${e}: sent to ${u.draft.chat_name||u.draft.to}`:`${e}: dropped, nothing sent`}:u}case"request":{let u=X(t),d=u?.get(a);return!u||!d||d.state!=="needs_attention"?{ok:!1,error:`nothing waiting for "${e}"`}:c?An(De(t)).enabled?(u.requestPickup(a,o),{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."}:(u.close(a,"dropped",i.note?.trim()||`dropped by ${l}`,o),{ok:!0,message:`${e}: dropped`})}}}var Dn=new Set(["127.0.0.1","::1","::ffff:127.0.0.1"]);function Nl(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"}function Ll(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)||/^\/workflow-runs\/[^/]+\/cancel$/.test(t)||t==="/api/signals/stop"||t==="/api/signals/resume"||t==="/api/signals/drop"||t==="/api/review-gate/replay"}function Ol(t){return Dn.has(t)}function Ml(t){if(t.foreignBrowser)return{allowed:!1,reason:"foreign-browser-origin"};if(t.enforcementDisabled)return{allowed:!0,reason:"disabled"};if(Dn.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 jl(t,e=process.env){let n=new Set;e.MESH_TOKEN&&n.add(e.MESH_TOKEN);for(let i of t.mesh?.peers||[])i.token&&n.add(i.token);return n}function Fl(t,e,n=process.env){let i=s=>s.replace(/\/+$/,"");return(e===i(t.daemonUrl)?t.token:t.daemons.find(s=>i(s.url)===e)?.token)||n.MESH_TOKEN||void 0}function ae(t){return(Array.isArray(t)?t[0]:t)?.trim()??""}function Qi(t){try{return new URL(t).host.toLowerCase()}catch{return null}}function es(t=process.env){return new Set((t.AGENTX_ALLOWED_ORIGINS||"").split(",").map(e=>e.trim().replace(/\/+$/,"").toLowerCase()).filter(Boolean))}function Vl(t,e=es()){let n=ae(t.origin);if(n){if(e.has(n.replace(/\/+$/,"").toLowerCase()))return"same-origin";let r=Qi(n),s=[ae(t.host),ae(t["x-forwarded-host"])].filter(Boolean).map(a=>a.toLowerCase());return r&&s.includes(r)?"same-origin":"foreign"}let i=ae(t["sec-fetch-site"]).toLowerCase();return i==="cross-site"||i==="same-site"?"foreign":"none"}function Ul(t){let e=(t||"GET").toUpperCase();return e!=="GET"&&e!=="HEAD"}import{existsSync as rr,mkdirSync as Es,readFileSync as Ts,renameSync as Cs,writeFileSync as Ds}from"fs";import{homedir as Ps}from"os";import{dirname as Ns,join as Ls}from"path";import{execFile as ds,execFileSync as ps}from"child_process";import{execFileSync as ts}from"child_process";import{existsSync as Nn,mkdirSync as ns,readdirSync as rs,readFileSync as Ln,renameSync as is,writeFileSync as ss}from"fs";import{homedir as On}from"os";import{join as Le}from"path";var v="siri:",Mn="com.apple.ttsbundle.gryphon-neural_",jn=t=>!!t&&t.startsWith(Mn),os=["/usr/bin/say","/usr/bin/defaults","/usr/bin/plutil"],as=()=>{try{return ts("/usr/bin/defaults",["read","com.apple.Accessibility"],{stdio:"ignore",timeout:5e3}),!0}catch{return!1}},Ne;function Oe(t={}){let e=t.platform!==void 0||t.exists!==void 0||t.prefDomain!==void 0;if(!e&&Ne!==void 0)return Ne;let{platform:n=process.platform,exists:i=Nn,prefDomain:r=as}=t,s=n==="darwin"&&os.every(a=>i(a))&&r();return e||(Ne=s),s}var Fn=["/System/Library/AssetsV2/com_apple_MobileAsset_Trial_Siri_SiriTextToSpeech/purpose_auto","/System/Library/AssetsV2/com_apple_MobileAsset_UAF_Siri_TextToSpeech/purpose_auto"],Wn={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"},Me=t=>Wn[t.toLowerCase()]??null;function le(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 ls=/com\.apple\.siri\.tts\.voice\.([a-z]{2})_([A-Z]{2})\.([a-z]+)\.neural\.premium/g;function cs(t){let e=new Map;for(let n of t)for(let[,i,r,s]of n.matchAll(ls)){let a=`${i}-${r}`,o=`${Mn}${s}_${a}_premium`;e.has(o)||e.set(o,{id:o,name:s[0].toUpperCase()+s.slice(1),locale:a,quality:"premium",gender:Wn[s]??null,siri:!0})}return[...e.values()]}function ce(t=Fn,e={}){if(!Oe(e))return[];let n=[];for(let i of t){let r;try{r=rs(i)}catch{continue}for(let s of r)try{n.push(Ln(Le(i,s,"Info.plist"),"latin1"))}catch{}}return cs(n)}var Pn=`#!/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
@@ -530,4 +530,4 @@ Document the arguments, commands, or files the skill expects. Example:
530
530
  claude-code ${vt(t)} --arg value
531
531
  \`\`\`
532
532
  `}Dt();var Zr={maxPixels:12e5,timeoutMs:5e3,intervalMs:100,changeThreshold:.015,stableMs:400,regions:{},buffer:{enabled:!1,seconds:10,fps:2,region:"screen",maxPixels:3e5}};function Qr(t){return{...Zr,...t??{},regions:{...t?.regions??{}},buffer:{...Zr.buffer,...t?.buffer??{}}}}function wd(t){try{return Qr(Ct(t).screen)}catch{return Qr(void 0)}}var Ma=/^[a-z][\w-]*$/,ei=["window","screen","menubar","notifications"];function Q(t,e,n,i){let r=Number(t);if(t===""||t===null||!Number.isFinite(r)||!n(r))throw new Error(`${e} must be ${i}`);return r}var be=(t,e)=>Q(t,e,n=>Number.isInteger(n)&&n>0,"a whole number above 0");function ti(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 kd(t,e){let n={...t??{}};if("maxPixels"in e&&(n.maxPixels=be(e.maxPixels,"maxPixels")),"timeoutMs"in e&&(n.timeoutMs=be(e.timeoutMs,"timeoutMs")),"intervalMs"in e&&(n.intervalMs=be(e.intervalMs,"intervalMs")),"stableMs"in e&&(n.stableMs=Q(e.stableMs,"stableMs",r=>Number.isInteger(r)&&r>=0,"a whole number, 0 or more")),"changeThreshold"in e&&(n.changeThreshold=Q(e.changeThreshold,"changeThreshold",r=>r>=0&&r<=1,"between 0 and 1")),e.regions&&typeof e.regions=="object"){let r={...n.regions??{}};for(let[s,a]of Object.entries(e.regions)){if(!Ma.test(s))throw new Error(`region name "${s}" must be lowercase letters, digits, - or _`);a===null?delete r[s]:r[s]=ti(a)}n.regions=r}if(e.buffer&&typeof e.buffer=="object"){let r=e.buffer,s={...n.buffer??{}};"enabled"in r&&(s.enabled=!!r.enabled),"seconds"in r&&(s.seconds=Q(r.seconds,"buffer.seconds",a=>a>0&&a<=120,"above 0 and at most 120")),"fps"in r&&(s.fps=Q(r.fps,"buffer.fps",a=>a>0&&a<=10,"above 0 and at most 10")),"maxPixels"in r&&(s.maxPixels=be(r.maxPixels,"buffer.maxPixels")),"region"in r&&(s.region=String(r.region).trim()),n.buffer=s}let i=n.buffer?.region;if(i!==void 0&&!ei.includes(i)&&!n.regions?.[i])try{ti(i)}catch{throw new Error(`buffer.region "${i}" is not a region \u2014 use ${[...ei,...Object.keys(n.regions??{})].join(", ")}, or x,y,w,h`)}return n}export{sn as a,Wa as b,rt as c,to as d,no as e,Rc as f,Ic as g,Ec as h,dr as i,Cc as j,Pc as k,D as l,pr as m,k as n,qa as o,mr as p,Fc as q,Qa as r,Di as s,sl as t,xn as u,x as v,Ka as w,Ja as x,ll as y,oe as z,cl as A,An as B,ml as C,X as D,Cl as E,Dl as F,Cn as G,hr as H,Uc as I,Er as J,yu as K,wu as L,Au as M,ea as N,_u as O,Nl as P,Ll as Q,Ol as R,Ml as S,jl as T,Fl as U,Vl as V,Ul as W,Yl as X,Fe as Y,Zl as Z,Ql as _,G as $,K as aa,oa as ba,Lu as ca,Ou as da,Mu as ea,ju as fa,dt as ga,Fu as ha,Ue as ia,Be as ja,pe as ka,Ss as la,vs as ma,ic as na,He as oa,ze as pa,$s as qa,As as ra,Yn as sa,tr as ta,sc as ua,Is as va,oc as wa,Os as xa,Fs as ya,Xe as za,Vs as Aa,nr as Ba,P as Ca,Vr as Da,Ur as Ea,Br as Fa,Hu as Ga,ma as Ha,Hr as Ia,zr as Ja,nd as Ka,rd as La,Ca as Ma,id as Na,Gr as Oa,fe as Pa,yc as Qa,lr as Ra,Ge as Sa,tt as Ta,Ac as Ua,ld as Va,cd as Wa,ud as Xa,dd as Ya,pd as Za,fd as _a,gd as $a,md as ab,hd as bb,Zr as cb,Qr as db,wd as eb,ei as fb,kd as gb};
533
- //# sourceMappingURL=chunk-VAK4LT62.js.map
533
+ //# sourceMappingURL=chunk-4FKFEWCE.js.map