agentix-cli 0.226.0 → 0.226.2

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 (142) hide show
  1. package/dist/{App-PRA4ELTK.js → App-KOHZIHFD.js} +2 -2
  2. package/dist/{ChatApp-ZFYU5GL5.js → ChatApp-24AJYZEC.js} +2 -2
  3. package/dist/{absorb-eval-TRJJVOJZ.js → absorb-eval-VCDJPF6M.js} +2 -2
  4. package/dist/{adapter-R3ZRSWOT.js → adapter-JGB45SCW.js} +2 -2
  5. package/dist/{agent-HSCGRWXM.js → agent-QCB3FOPN.js} +2 -2
  6. package/dist/{board-dashboard-ZHF34H4B.js → board-dashboard-B6QSOGCC.js} +4 -4
  7. package/dist/{chunk-W7XVPLDN.js → chunk-2TVJTWFC.js} +2 -2
  8. package/dist/{chunk-YEX3NOLR.js → chunk-2XQMUSGM.js} +2 -2
  9. package/dist/{chunk-L5LKL2N7.js → chunk-6ECXITK2.js} +2 -2
  10. package/dist/{chunk-2CFEXC67.js → chunk-7K7ZQU3C.js} +2 -2
  11. package/dist/{chunk-FWJHLDAX.js → chunk-A24QXLEG.js} +2 -2
  12. package/dist/{chunk-ZN5SZLO4.js → chunk-ATZRBMUZ.js} +2 -2
  13. package/dist/{chunk-N4XPOJMC.js → chunk-BDHWTWD7.js} +2 -2
  14. package/dist/{chunk-YGGPPZTW.js → chunk-BTLADRMY.js} +2 -2
  15. package/dist/{chunk-KLWQ4KLG.js → chunk-CF2R6BOX.js} +2 -2
  16. package/dist/{chunk-LZBOQ3SA.js → chunk-D6LX27PO.js} +2 -2
  17. package/dist/{chunk-Y7ASJTMM.js → chunk-DG56PTYL.js} +2 -2
  18. package/dist/{chunk-YM5JAK3F.js → chunk-EYVPRIO3.js} +2 -2
  19. package/dist/{chunk-3QJZ5TXT.js → chunk-FGHJDZDB.js} +2 -2
  20. package/dist/{chunk-CUNUXJSF.js → chunk-FWNP27H4.js} +2 -2
  21. package/dist/chunk-FWNP27H4.js.map +1 -0
  22. package/dist/{chunk-YCXODM2J.js → chunk-GMAORBGM.js} +2 -2
  23. package/dist/{chunk-DDYGJEH4.js → chunk-I32TCCAK.js} +2 -2
  24. package/dist/{chunk-J3PUOD3I.js → chunk-LGYIHB73.js} +3 -3
  25. package/dist/{chunk-DQNMJXEM.js → chunk-LLVVT5OB.js} +2 -2
  26. package/dist/{chunk-NCADCW3E.js → chunk-LTOSEP7C.js} +2 -2
  27. package/dist/{chunk-PVNAUVBQ.js → chunk-MM7U4PWY.js} +2 -2
  28. package/dist/{chunk-3G3XXCHY.js → chunk-Q6TGKWZE.js} +2 -2
  29. package/dist/{chunk-TU6D4I4T.js → chunk-QU7ICYFR.js} +2 -2
  30. package/dist/{chunk-LMH4Z5QE.js → chunk-QZ24XACR.js} +2 -2
  31. package/dist/{chunk-MRSJOAWK.js → chunk-TA437DWX.js} +41 -40
  32. package/dist/{chunk-MRSJOAWK.js.map → chunk-TA437DWX.js.map} +1 -1
  33. package/dist/{chunk-4GUFZT5S.js → chunk-TEYFN6YL.js} +104 -103
  34. package/dist/{chunk-4GUFZT5S.js.map → chunk-TEYFN6YL.js.map} +1 -1
  35. package/dist/{chunk-AU6ABL2P.js → chunk-UBONPGNT.js} +2 -2
  36. package/dist/{chunk-S656M5R5.js → chunk-VNXYQH45.js} +2 -2
  37. package/dist/{chunk-BEH3UJGT.js → chunk-W7PIHJHH.js} +2 -2
  38. package/dist/{chunk-IKSCPOUA.js → chunk-X2LFAJ5D.js} +260 -260
  39. package/dist/chunk-X2LFAJ5D.js.map +1 -0
  40. package/dist/{chunk-5DEGAL4M.js → chunk-XV3QPZWH.js} +2 -2
  41. package/dist/{chunk-FAZMGEPF.js → chunk-ZUZYJQJ4.js} +2 -2
  42. package/dist/cli.js +1 -1
  43. package/dist/{client-CUI3YEXS.js → client-D3HDGKKI.js} +2 -2
  44. package/dist/{config-WZ5O3SCZ.js → config-OBH67S4V.js} +2 -2
  45. package/dist/{config-mutate-BX4WUTRK.js → config-mutate-KSTFRHFL.js} +2 -2
  46. package/dist/{config-mutator-2SK2P355.js → config-mutator-XXZPHMS5.js} +2 -2
  47. package/dist/{contributions-AOVWT4GQ.js → contributions-ROZVACRZ.js} +2 -2
  48. package/dist/{doctor-KMKVMWIH.js → doctor-UCH5FAYV.js} +2 -2
  49. package/dist/{follow-up-tool-GOVILMAF.js → follow-up-tool-IPVPMERA.js} +2 -2
  50. package/dist/{hub-JLASJLAR.js → hub-UY6IPKJU.js} +2 -2
  51. package/dist/index.d.ts +8 -6
  52. package/dist/index.js +1 -1
  53. package/dist/{org-tool-TZOPMOVD.js → org-tool-YOLOEYRA.js} +2 -2
  54. package/dist/{program-ERNKLXGC.js → program-YIKCSZBC.js} +24 -24
  55. package/dist/{promote-JL6T7KS7.js → promote-LKKZS7DD.js} +2 -2
  56. package/dist/{query-ZSGNVHAX.js → query-UGQY7TE7.js} +2 -2
  57. package/dist/{query-settings-PPJICZ26.js → query-settings-HS2YNSLM.js} +2 -2
  58. package/dist/{registry-EZBD7QJ3.js → registry-77HLNAQF.js} +2 -2
  59. package/dist/{request-planner-HF7ZY7HX.js → request-planner-3MKTH2B6.js} +2 -2
  60. package/dist/{review-candidates-XCEOBHCM.js → review-candidates-ODCGXSYY.js} +2 -2
  61. package/dist/{routing-CVVEL76N.js → routing-K3O27TBW.js} +2 -2
  62. package/dist/{schedule-tool-UMSHKANT.js → schedule-tool-5ZIJOA7R.js} +2 -2
  63. package/dist/{scheduler-L6KEZI43.js → scheduler-Y2COW5JL.js} +2 -2
  64. package/dist/{seat-KEBD5OUK.js → seat-YMSIXFTN.js} +2 -2
  65. package/dist/{select-FSKHWU4T.js → select-F6DEPWZH.js} +2 -2
  66. package/dist/{set-enabled-N2EESOLU.js → set-enabled-UEYUQHF3.js} +2 -2
  67. package/dist/{sprint-tool-K4EDAGGZ.js → sprint-tool-WPVO3XBV.js} +2 -2
  68. package/dist/{tool-ISMGGPUZ.js → tool-7TXMGK5Q.js} +2 -2
  69. package/dist/{tool-MN65SRXS.js → tool-F5GN7WSE.js} +2 -2
  70. package/dist/{tool-V7ZNX6RY.js → tool-FZPOQXSQ.js} +2 -2
  71. package/dist/tool-HHMSHXUP.js +2 -0
  72. package/dist/{tool-HZRDVPDJ.js → tool-QVQZRRSO.js} +2 -2
  73. package/dist/{wiki-FVOQWOT5.js → wiki-ZI3GXGNW.js} +2 -2
  74. package/dist/wiki-enrich-JK46USSG.js +2 -0
  75. package/package.json +1 -1
  76. package/dist/chunk-CUNUXJSF.js.map +0 -1
  77. package/dist/chunk-IKSCPOUA.js.map +0 -1
  78. package/dist/tool-T6RJUVPW.js +0 -2
  79. package/dist/wiki-enrich-RKTYIZOM.js +0 -2
  80. /package/dist/{App-PRA4ELTK.js.map → App-KOHZIHFD.js.map} +0 -0
  81. /package/dist/{ChatApp-ZFYU5GL5.js.map → ChatApp-24AJYZEC.js.map} +0 -0
  82. /package/dist/{absorb-eval-TRJJVOJZ.js.map → absorb-eval-VCDJPF6M.js.map} +0 -0
  83. /package/dist/{adapter-R3ZRSWOT.js.map → adapter-JGB45SCW.js.map} +0 -0
  84. /package/dist/{agent-HSCGRWXM.js.map → agent-QCB3FOPN.js.map} +0 -0
  85. /package/dist/{board-dashboard-ZHF34H4B.js.map → board-dashboard-B6QSOGCC.js.map} +0 -0
  86. /package/dist/{chunk-W7XVPLDN.js.map → chunk-2TVJTWFC.js.map} +0 -0
  87. /package/dist/{chunk-YEX3NOLR.js.map → chunk-2XQMUSGM.js.map} +0 -0
  88. /package/dist/{chunk-L5LKL2N7.js.map → chunk-6ECXITK2.js.map} +0 -0
  89. /package/dist/{chunk-2CFEXC67.js.map → chunk-7K7ZQU3C.js.map} +0 -0
  90. /package/dist/{chunk-FWJHLDAX.js.map → chunk-A24QXLEG.js.map} +0 -0
  91. /package/dist/{chunk-ZN5SZLO4.js.map → chunk-ATZRBMUZ.js.map} +0 -0
  92. /package/dist/{chunk-N4XPOJMC.js.map → chunk-BDHWTWD7.js.map} +0 -0
  93. /package/dist/{chunk-YGGPPZTW.js.map → chunk-BTLADRMY.js.map} +0 -0
  94. /package/dist/{chunk-KLWQ4KLG.js.map → chunk-CF2R6BOX.js.map} +0 -0
  95. /package/dist/{chunk-LZBOQ3SA.js.map → chunk-D6LX27PO.js.map} +0 -0
  96. /package/dist/{chunk-Y7ASJTMM.js.map → chunk-DG56PTYL.js.map} +0 -0
  97. /package/dist/{chunk-YM5JAK3F.js.map → chunk-EYVPRIO3.js.map} +0 -0
  98. /package/dist/{chunk-3QJZ5TXT.js.map → chunk-FGHJDZDB.js.map} +0 -0
  99. /package/dist/{chunk-YCXODM2J.js.map → chunk-GMAORBGM.js.map} +0 -0
  100. /package/dist/{chunk-DDYGJEH4.js.map → chunk-I32TCCAK.js.map} +0 -0
  101. /package/dist/{chunk-J3PUOD3I.js.map → chunk-LGYIHB73.js.map} +0 -0
  102. /package/dist/{chunk-DQNMJXEM.js.map → chunk-LLVVT5OB.js.map} +0 -0
  103. /package/dist/{chunk-NCADCW3E.js.map → chunk-LTOSEP7C.js.map} +0 -0
  104. /package/dist/{chunk-PVNAUVBQ.js.map → chunk-MM7U4PWY.js.map} +0 -0
  105. /package/dist/{chunk-3G3XXCHY.js.map → chunk-Q6TGKWZE.js.map} +0 -0
  106. /package/dist/{chunk-TU6D4I4T.js.map → chunk-QU7ICYFR.js.map} +0 -0
  107. /package/dist/{chunk-LMH4Z5QE.js.map → chunk-QZ24XACR.js.map} +0 -0
  108. /package/dist/{chunk-AU6ABL2P.js.map → chunk-UBONPGNT.js.map} +0 -0
  109. /package/dist/{chunk-S656M5R5.js.map → chunk-VNXYQH45.js.map} +0 -0
  110. /package/dist/{chunk-BEH3UJGT.js.map → chunk-W7PIHJHH.js.map} +0 -0
  111. /package/dist/{chunk-5DEGAL4M.js.map → chunk-XV3QPZWH.js.map} +0 -0
  112. /package/dist/{chunk-FAZMGEPF.js.map → chunk-ZUZYJQJ4.js.map} +0 -0
  113. /package/dist/{client-CUI3YEXS.js.map → client-D3HDGKKI.js.map} +0 -0
  114. /package/dist/{config-WZ5O3SCZ.js.map → config-OBH67S4V.js.map} +0 -0
  115. /package/dist/{config-mutate-BX4WUTRK.js.map → config-mutate-KSTFRHFL.js.map} +0 -0
  116. /package/dist/{config-mutator-2SK2P355.js.map → config-mutator-XXZPHMS5.js.map} +0 -0
  117. /package/dist/{contributions-AOVWT4GQ.js.map → contributions-ROZVACRZ.js.map} +0 -0
  118. /package/dist/{doctor-KMKVMWIH.js.map → doctor-UCH5FAYV.js.map} +0 -0
  119. /package/dist/{follow-up-tool-GOVILMAF.js.map → follow-up-tool-IPVPMERA.js.map} +0 -0
  120. /package/dist/{hub-JLASJLAR.js.map → hub-UY6IPKJU.js.map} +0 -0
  121. /package/dist/{org-tool-TZOPMOVD.js.map → org-tool-YOLOEYRA.js.map} +0 -0
  122. /package/dist/{program-ERNKLXGC.js.map → program-YIKCSZBC.js.map} +0 -0
  123. /package/dist/{promote-JL6T7KS7.js.map → promote-LKKZS7DD.js.map} +0 -0
  124. /package/dist/{query-ZSGNVHAX.js.map → query-UGQY7TE7.js.map} +0 -0
  125. /package/dist/{query-settings-PPJICZ26.js.map → query-settings-HS2YNSLM.js.map} +0 -0
  126. /package/dist/{registry-EZBD7QJ3.js.map → registry-77HLNAQF.js.map} +0 -0
  127. /package/dist/{request-planner-HF7ZY7HX.js.map → request-planner-3MKTH2B6.js.map} +0 -0
  128. /package/dist/{review-candidates-XCEOBHCM.js.map → review-candidates-ODCGXSYY.js.map} +0 -0
  129. /package/dist/{routing-CVVEL76N.js.map → routing-K3O27TBW.js.map} +0 -0
  130. /package/dist/{schedule-tool-UMSHKANT.js.map → schedule-tool-5ZIJOA7R.js.map} +0 -0
  131. /package/dist/{scheduler-L6KEZI43.js.map → scheduler-Y2COW5JL.js.map} +0 -0
  132. /package/dist/{seat-KEBD5OUK.js.map → seat-YMSIXFTN.js.map} +0 -0
  133. /package/dist/{select-FSKHWU4T.js.map → select-F6DEPWZH.js.map} +0 -0
  134. /package/dist/{set-enabled-N2EESOLU.js.map → set-enabled-UEYUQHF3.js.map} +0 -0
  135. /package/dist/{sprint-tool-K4EDAGGZ.js.map → sprint-tool-WPVO3XBV.js.map} +0 -0
  136. /package/dist/{tool-ISMGGPUZ.js.map → tool-7TXMGK5Q.js.map} +0 -0
  137. /package/dist/{tool-MN65SRXS.js.map → tool-F5GN7WSE.js.map} +0 -0
  138. /package/dist/{tool-V7ZNX6RY.js.map → tool-FZPOQXSQ.js.map} +0 -0
  139. /package/dist/{tool-T6RJUVPW.js.map → tool-HHMSHXUP.js.map} +0 -0
  140. /package/dist/{tool-HZRDVPDJ.js.map → tool-QVQZRRSO.js.map} +0 -0
  141. /package/dist/{wiki-FVOQWOT5.js.map → wiki-ZI3GXGNW.js.map} +0 -0
  142. /package/dist/{wiki-enrich-RKTYIZOM.js.map → wiki-enrich-JK46USSG.js.map} +0 -0
@@ -1,3 +1,3 @@
1
- import{Dc as $,_b as S}from"./chunk-CUNUXJSF.js";import{randomBytes as x}from"crypto";import{existsSync as b,mkdirSync as k,readdirSync as M,readFileSync as j,renameSync as E,unlinkSync as y,writeFileSync as C}from"fs";import{resolve as c}from"path";function m(t){return c(t,".agentx","email")}function u(t,e){k(c(t,".."),{recursive:!0});let r=`${t}.${process.pid}.tmp`;C(r,JSON.stringify(e,null,2)+`
1
+ import{Dc as $,_b as S}from"./chunk-FWNP27H4.js";import{randomBytes as x}from"crypto";import{existsSync as b,mkdirSync as k,readdirSync as M,readFileSync as j,renameSync as E,unlinkSync as y,writeFileSync as C}from"fs";import{resolve as c}from"path";function m(t){return c(t,".agentx","email")}function u(t,e){k(c(t,".."),{recursive:!0});let r=`${t}.${process.pid}.tmp`;C(r,JSON.stringify(e,null,2)+`
2
2
  `,{mode:384}),E(r,t)}function g(t){try{return JSON.parse(j(t,"utf-8"))}catch{return null}}var D=t=>c(m(t),"threads.json");function w(t){return g(D(t))??{}}function I(t,e){return w(t)[e.toLowerCase()]}function L(t,e){let r=w(t);r[e.to.toLowerCase()]=e,u(D(t),r)}var h=(t,e)=>c(m(t),"cursors",`${e}.json`);function z(t,e){return g(h(t,e))}function B(t,e,r){u(h(t,e),r)}var T=2e4,_=t=>c(m(t),"drafts"),N=t=>/^[a-z0-9-]{8,64}$/.test(t),a=(t,e)=>c(_(t),`${e}.json`);function U(t,e,r=Date.now()){let n=e.text.trim().slice(0,T);if(!n)throw new Error("empty reply");let s={...e,text:n,id:`${r.toString(36)}-${x(4).toString("hex")}`,status:"pending",created_at:new Date(r).toISOString()};return u(a(t,s.id),s),s}function v(t,e){return N(e)?g(a(t,e)):null}function V(t,e){let r=_(t);return b(r)?M(r).filter(n=>n.endsWith(".json")).map(n=>v(t,n.slice(0,-5))).filter(n=>!!n&&(!e||n.status===e)).sort((n,s)=>n.created_at.localeCompare(s.created_at)):[]}async function W(t,e,r,n){let s=v(t,e);if(!s||s.status!=="pending")return{ok:!1,error:`no email reply "${e}" is waiting`};let i=`${a(t,e)}.${process.pid}.${x(3).toString("hex")}.claim`;try{E(a(t,e),i)}catch{return{ok:!1,error:`email reply "${e}" is already being decided`}}let d=n.text!==void 0&&n.text.trim()!==""&&n.text.trim()!==s.text,o={...s,...d?{text:n.text.trim().slice(0,T),edited:!0}:{},decided_by:n.by??"operator",decided_at:new Date(n.now??Date.now()).toISOString()};if(r==="no")o.status="rejected";else{let f=await n.send(o).catch(p=>({ok:!1,error:String(p?.message??p)}));if(!f.ok){u(a(t,e),{...s,error:f.error});try{y(i)}catch{}return{ok:!1,error:`not sent: ${f.error}`}}o.status="sent",delete o.error}u(a(t,e),o);try{y(i)}catch{}return{ok:!0,draft:o}}$();function l(t,e){return(t??"").replace(/\$\{(\w+)\}/g,(r,n)=>e[n]??"")}function P(t,e=process.env){let r={host:t.imap.host,port:t.imap.port,secure:t.imap.secure,user:l(t.imap.user,e)||t.address,password:l(t.imap.password,e)},n={host:t.smtp.host,port:t.smtp.port,secure:t.smtp.secure,user:l(t.smtp.user,e)||r.user,password:l(t.smtp.password,e)||r.password};return{imap:r,smtp:n}}async function R(t,e,r,n=process.env){let{smtp:s}=P(t,n);if(!s.password)throw new Error(`no SMTP password for ${t.address}: set it in .env`);return J(s,{name:e,address:t.address},r,{"Auto-Submitted":"auto-replied"})}async function J(t,e,r,n){let{default:s}=await import("nodemailer"),i=s.createTransport({host:t.host,port:t.port,secure:t.secure,auth:{user:t.user,pass:t.password},connectionTimeout:2e4,greetingTimeout:2e4,socketTimeout:6e4});try{return(await i.sendMail({from:e,to:r.toName?{name:r.toName,address:r.to}:r.to,subject:r.subject,text:r.text,...r.inReplyTo?{inReplyTo:r.inReplyTo}:{},...r.references?{references:r.references}:{},headers:n})).messageId}finally{i.close()}}function G(t,e){return async r=>{let n=t?.channels?.email?.accounts?.[r.account];if(!n)return{ok:!1,error:`no email account "${r.account}" in agentx.json`};let s=S.safeParse(n);if(!s.success)return{ok:!1,error:`email account "${r.account}": ${s.error.issues[0]?.message}`};let i=s.data,d=i.name||t?.agents?.[r.agent]?.name||r.agent;return await R(i,d,{to:r.to,toName:r.to_name,subject:r.subject,inReplyTo:r.in_reply_to,references:r.references,text:r.text},e),{ok:!0}}}export{I as a,L as b,z as c,B as d,U as e,v as f,V as g,W as h,P as i,R as j,J as k,G as l};
3
- //# sourceMappingURL=chunk-AU6ABL2P.js.map
3
+ //# sourceMappingURL=chunk-UBONPGNT.js.map
@@ -1,8 +1,8 @@
1
- import{a as _,b as O,c as q,d as B,f as L,g as z,h as T,i as b,j as v,k as w}from"./chunk-TU6D4I4T.js";import{a as R,b as P,c as E,d as k,e as D}from"./chunk-3G3XXCHY.js";import{existsSync as K,readFileSync as Y}from"fs";import J from"cronstrue";var A={sun:0,sunday:0,mon:1,monday:1,tue:2,tuesday:2,tues:2,wed:3,wednesday:3,thu:4,thursday:4,thurs:4,fri:5,friday:5,sat:6,saturday:6},S={morning:{h:9,m:0},afternoon:{h:14,m:0},evening:{h:18,m:0},night:{h:22,m:0},noon:{h:12,m:0},midnight:{h:0,m:0}};function g(n){try{return J.toString(n,{use24HourTimeFormat:!1})}catch{return n}}function V(n){if(/\b(noon|midday)\b/.test(n))return S.noon;if(/\bmidnight\b/.test(n))return S.midnight;let e=n.match(/\b(?:at|by|@)\s*(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\b/);if(e){let r=parseInt(e[1],10),i=e[2]?parseInt(e[2],10):0,a=e[3];return a==="pm"&&r<12&&(r+=12),a==="am"&&r===12&&(r=0),r>23||i>59?null:{h:r,m:i}}return null}function H(n){let e=n.trim().toLowerCase();if(!e)return null;let r;if(r=e.match(/\bevery\s+(\d+)\s*(minutes|mins|m)\b/)){let t=parseInt(r[1],10);return t<1||t>59?null:{cron:`*/${t} * * * *`,human:g(`*/${t} * * * *`),matched:r[0]}}if(/\bevery\s+minute\b/.test(e))return{cron:"* * * * *",human:g("* * * * *"),matched:"every minute"};if(r=e.match(/\bevery\s+(\d+)\s*(hours|hrs|h)\b/)){let t=parseInt(r[1],10);return t<1||t>23?null:{cron:`0 */${t} * * *`,human:g(`0 */${t} * * *`),matched:r[0]}}if(/\b(every hour|hourly)\b/.test(e))return{cron:"0 * * * *",human:g("0 * * * *"),matched:"every hour"};let i=V(e),a=null;for(let[t,o]of Object.entries(S))if(!(t==="noon"||t==="midnight")&&new RegExp(`\\b(every\\s+)?${t}s?\\b`).test(e)){a=o;break}let d=i||a,m=e.match(/\b(first|1st|2nd|3rd|last|(\d+)(?:st|nd|rd|th)?)\s+(day\s+)?of\s+(every|each|the)\s+month\b/);if(m){let t=m[1],o=1;if(t==="last"||(/^\d+(st|nd|rd|th)?$/.test(t)?o=parseInt(t,10):t==="first"||t==="1st"?o=1:t==="2nd"?o=2:t==="3rd"&&(o=3),o<1||o>31))return null;let u=d||{h:9,m:0},p=`${u.m} ${u.h} ${o} * *`;return{cron:p,human:g(p),matched:m[0]}}let s=[],y=Object.keys(A).join("|"),l=new RegExp(`\\b(?:every|on|each|by)\\s+((?:${y})s?(?:\\s*(?:,|and|&)\\s*(?:${y})s?)*)\\b`),c=e.match(l);if(c){let t=c[1];for(let o of Object.keys(A))if(new RegExp(`\\b${o}s?\\b`).test(t)){let u=A[o];s.includes(u)||s.push(u)}}if(s.length){let t=d||{h:9,m:0};s.sort((p,h)=>p-h);let o=s.join(","),u=`${t.m} ${t.h} * * ${o}`;return{cron:u,human:g(u),matched:`on ${o}`}}if(/\b(weekday|workday|business day)s?\b/.test(e)){let t=d||{h:9,m:0},o=`${t.m} ${t.h} * * 1-5`;return{cron:o,human:g(o),matched:"weekdays"}}if(/\bweekends?\b/.test(e)){let t=d||{h:9,m:0},o=`${t.m} ${t.h} * * 0,6`;return{cron:o,human:g(o),matched:"weekends"}}if(/\b(every day|daily|each day)\b/.test(e)||a){let t=d||{h:9,m:0},o=`${t.m} ${t.h} * * *`;return{cron:o,human:g(o),matched:a&&Object.entries(S).find(([,u])=>u===a)?.[0]||"daily"}}if(i){let t=`${i.m} ${i.h} * * *`;return{cron:t,human:g(t),matched:`at ${i.h}:${String(i.m).padStart(2,"0")}`}}return null}function G(n,e){return`${n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)||"job"}-${e}`}var Z=new Set(["cron","heartbeat","api","a2a","mesh"]),Q=160;function f(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function x(n,e=Q){let r=n.replace(/\s+/g," ").trim();return r.length>e?`${r.slice(0,e-1)}\u2026`:r}function ee(n){let e=R(n);if(!K(e))throw new Error(`config not found at ${e}`);return JSON.parse(Y(e,"utf-8"))}function te(n,e){return n?.agents?.[e]?.admin===!0}function ne(n,e,r){return te(n,r.agentId)||e?.createdBy===r.agentId}function re(n,e){let r=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${r}. Agents manage only schedules they created (unless configured admin).`}function oe(n,e){let r=f(n.notify);if(r!=="none"){if(r&&r!=="here"){let i=r.split(":");return i.length<2||!i[0]||!i[1]?"invalid":{channel:i[0],chatId:i.slice(1).join(":")}}if(e.channel&&e.chatId&&!Z.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function ie(n,e,r){let i=e.timezone||"UTC",a=e.enabled&&!w(e)?v(b(e.schedule,i,r),i):"\u2014",d=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",m=[`- ${n} [${d}] ${e.schedule} \u2014 ${T(e.schedule)} (${i})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${a}`];return e.notify&&m.push(` notify: ${e.notify.channel} ${e.notify.chatId} ${z(e)}`),e.command?m.push(` command: ${x(String(e.command))}`):e.prompt&&m.push(` prompt: ${x(String(e.prompt))}`),m.join(`
1
+ import{a as _,b as O,c as q,d as B,f as L,g as z,h as T,i as b,j as v,k as w}from"./chunk-QU7ICYFR.js";import{a as R,b as P,c as E,d as k,e as D}from"./chunk-Q6TGKWZE.js";import{existsSync as K,readFileSync as Y}from"fs";import J from"cronstrue";var A={sun:0,sunday:0,mon:1,monday:1,tue:2,tuesday:2,tues:2,wed:3,wednesday:3,thu:4,thursday:4,thurs:4,fri:5,friday:5,sat:6,saturday:6},S={morning:{h:9,m:0},afternoon:{h:14,m:0},evening:{h:18,m:0},night:{h:22,m:0},noon:{h:12,m:0},midnight:{h:0,m:0}};function g(n){try{return J.toString(n,{use24HourTimeFormat:!1})}catch{return n}}function V(n){if(/\b(noon|midday)\b/.test(n))return S.noon;if(/\bmidnight\b/.test(n))return S.midnight;let e=n.match(/\b(?:at|by|@)\s*(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\b/);if(e){let r=parseInt(e[1],10),i=e[2]?parseInt(e[2],10):0,a=e[3];return a==="pm"&&r<12&&(r+=12),a==="am"&&r===12&&(r=0),r>23||i>59?null:{h:r,m:i}}return null}function H(n){let e=n.trim().toLowerCase();if(!e)return null;let r;if(r=e.match(/\bevery\s+(\d+)\s*(minutes|mins|m)\b/)){let t=parseInt(r[1],10);return t<1||t>59?null:{cron:`*/${t} * * * *`,human:g(`*/${t} * * * *`),matched:r[0]}}if(/\bevery\s+minute\b/.test(e))return{cron:"* * * * *",human:g("* * * * *"),matched:"every minute"};if(r=e.match(/\bevery\s+(\d+)\s*(hours|hrs|h)\b/)){let t=parseInt(r[1],10);return t<1||t>23?null:{cron:`0 */${t} * * *`,human:g(`0 */${t} * * *`),matched:r[0]}}if(/\b(every hour|hourly)\b/.test(e))return{cron:"0 * * * *",human:g("0 * * * *"),matched:"every hour"};let i=V(e),a=null;for(let[t,o]of Object.entries(S))if(!(t==="noon"||t==="midnight")&&new RegExp(`\\b(every\\s+)?${t}s?\\b`).test(e)){a=o;break}let d=i||a,m=e.match(/\b(first|1st|2nd|3rd|last|(\d+)(?:st|nd|rd|th)?)\s+(day\s+)?of\s+(every|each|the)\s+month\b/);if(m){let t=m[1],o=1;if(t==="last"||(/^\d+(st|nd|rd|th)?$/.test(t)?o=parseInt(t,10):t==="first"||t==="1st"?o=1:t==="2nd"?o=2:t==="3rd"&&(o=3),o<1||o>31))return null;let u=d||{h:9,m:0},p=`${u.m} ${u.h} ${o} * *`;return{cron:p,human:g(p),matched:m[0]}}let s=[],y=Object.keys(A).join("|"),l=new RegExp(`\\b(?:every|on|each|by)\\s+((?:${y})s?(?:\\s*(?:,|and|&)\\s*(?:${y})s?)*)\\b`),c=e.match(l);if(c){let t=c[1];for(let o of Object.keys(A))if(new RegExp(`\\b${o}s?\\b`).test(t)){let u=A[o];s.includes(u)||s.push(u)}}if(s.length){let t=d||{h:9,m:0};s.sort((p,h)=>p-h);let o=s.join(","),u=`${t.m} ${t.h} * * ${o}`;return{cron:u,human:g(u),matched:`on ${o}`}}if(/\b(weekday|workday|business day)s?\b/.test(e)){let t=d||{h:9,m:0},o=`${t.m} ${t.h} * * 1-5`;return{cron:o,human:g(o),matched:"weekdays"}}if(/\bweekends?\b/.test(e)){let t=d||{h:9,m:0},o=`${t.m} ${t.h} * * 0,6`;return{cron:o,human:g(o),matched:"weekends"}}if(/\b(every day|daily|each day)\b/.test(e)||a){let t=d||{h:9,m:0},o=`${t.m} ${t.h} * * *`;return{cron:o,human:g(o),matched:a&&Object.entries(S).find(([,u])=>u===a)?.[0]||"daily"}}if(i){let t=`${i.m} ${i.h} * * *`;return{cron:t,human:g(t),matched:`at ${i.h}:${String(i.m).padStart(2,"0")}`}}return null}function G(n,e){return`${n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)||"job"}-${e}`}var Z=new Set(["cron","heartbeat","api","a2a","mesh"]),Q=160;function f(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function x(n,e=Q){let r=n.replace(/\s+/g," ").trim();return r.length>e?`${r.slice(0,e-1)}\u2026`:r}function ee(n){let e=R(n);if(!K(e))throw new Error(`config not found at ${e}`);return JSON.parse(Y(e,"utf-8"))}function te(n,e){return n?.agents?.[e]?.admin===!0}function ne(n,e,r){return te(n,r.agentId)||e?.createdBy===r.agentId}function re(n,e){let r=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${r}. Agents manage only schedules they created (unless configured admin).`}function oe(n,e){let r=f(n.notify);if(r!=="none"){if(r&&r!=="here"){let i=r.split(":");return i.length<2||!i[0]||!i[1]?"invalid":{channel:i[0],chatId:i.slice(1).join(":")}}if(e.channel&&e.chatId&&!Z.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function ie(n,e,r){let i=e.timezone||"UTC",a=e.enabled&&!w(e)?v(b(e.schedule,i,r),i):"\u2014",d=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",m=[`- ${n} [${d}] ${e.schedule} \u2014 ${T(e.schedule)} (${i})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${a}`];return e.notify&&m.push(` notify: ${e.notify.channel} ${e.notify.chatId} ${z(e)}`),e.command?m.push(` command: ${x(String(e.command))}`):e.prompt&&m.push(` prompt: ${x(String(e.prompt))}`),m.join(`
2
2
  `)}async function F(n,e,r){let i=n?.notifications?.destination;if(!i?.channel||!i?.chatId)return"No operator notification destination is configured (notifications.destination); the operator must check `agentx schedule list`.";if(!e.notifyOperator)return"Operator notification is unavailable in this context.";try{return await e.notifyOperator({channel:i.channel,chatId:i.chatId,accountId:i.accountId},r),"The operator has been notified."}catch(a){return`Could not notify the operator (${a?.message??a}); the request is still recorded.`}}async function he(n,e,r={}){let i=(f(n.action)||"list").toLowerCase(),a=r.now?r.now():new Date,d;try{d=ee(r.configPath)}catch(c){return`Error: ${c.message}`}let m=d.crons||{};if(i==="list"){let c=n.mine===!0,t=Object.entries(m).filter(([,o])=>!c||e&&o?.createdBy===e.agentId);return t.length?t.map(([o,u])=>ie(o,u,a)).join(`
3
3
  `):c?"You have no schedules.":"No schedules."}if(!e?.agentId)return"Error: caller agent is unknown (AGENTX_AGENT_ID not set). Pass callerAgentId.";if(!d.agents?.[e.agentId])return`Error: caller "${e.agentId}" is not an agent on this node.`;let s=f(n.id),y=c=>P(c,{configPath:r.configPath,reload:r.reload});if(i==="create"){let c=f(n.when),t=f(n.prompt);if(!c||!t)return"Error: create needs `when` (plain English) and `prompt`.";let o=H(c);if(!o)return`Error: couldn't parse "${c}". ${O}.`;let u=f(n.agent)||e.agentId;if(!d.agents?.[u])return`Error: agent "${u}" not found on this node.`;let p=f(n.timezone)||_;if(!B(p))return`Error: unknown timezone "${p}".`;let h=s||G(o.matched,u);if(!q(h))return`Error: invalid id "${h}" (letters, digits, "-" and "_" only).`;if(m[h])return`Error: a schedule "${h}" already exists. Pick another \`id\`.`;let $=oe(n,e);if($==="invalid")return'Error: `notify` must be "here", "none", or "channel:chatId".';let I=f(n.report);if(I&&I!=="always"&&I!=="exceptions")return'Error: `report` must be "always" or "exceptions".';let M={action:"create",requestedBy:e.agentId,requestedAt:a.toISOString()},U=L({parsed:o,agent:u,prompt:t,timezone:p,notify:$,report:I,enabled:!1,createdBy:e.agentId,approval:M}),N=await y(j=>E(j,`crons.${h}`,U));if(!N.success)return`Error: ${N.error}`;let C=v(b(o.cron,p,a),p),W=[`Schedule approval requested by ${e.agentId}`,`Create: ${h}`,`When: ${o.human} \u2014 cron \`${o.cron}\` (${p})`,`Next fire: ${C}`,`Agent: ${u}`,$?`${I==="exceptions"?"Exceptions":"Results"} and failures go to: ${$.channel} ${$.chatId}${$.channel==="voice"?" (as a push notification)":""}`:"Results go to: run log only (no chat)",`Prompt: ${x(t,400)}`,"",`Approve: agentx schedule approve ${h}`,`Reject: agentx schedule reject ${h}`].join(`
4
4
  `),X=await F(d,r,W);return[`Requested schedule "${h}": ${o.human} (cron ${o.cron}, ${p}); next fire would be ${C}.`,"It is saved DISABLED and will not run until the operator approves it.",X].join(`
5
5
  `)}if(!s)return`Error: ${i} needs \`id\`.`;let l=m[s];if(!l)return`Error: schedule "${s}" not found.`;if(!ne(d,l,e))return re(s,l);if(i==="pause"||i==="resume"){let c=i==="resume";if(c&&w(l))return`"${s}" is still awaiting operator approval; it can't be resumed until approved.`;if(l.enabled===c)return`"${s}" is already ${c?"active":"paused"}.`;let t=await y(o=>E(o,`crons.${s}.enabled`,c));return t.success?`"${s}" ${c?"resumed":"paused"}.`:`Error: ${t.error}`}if(i==="delete"){if(w(l)&&l.approval.requestedBy===e.agentId){let h=await y($=>D($,`crons.${s}`));return h.success?`Withdrew the pending request "${s}".`:`Error: ${h.error}`}if(w(l))return`"${s}" is a creation request still awaiting approval; only its requester or the operator (\`agentx schedule reject ${s}\`) can drop it.`;if(l.approval?.action==="delete")return`Deletion of "${s}" is already awaiting approval.`;let c={action:"delete",requestedBy:e.agentId,requestedAt:a.toISOString()},t=await y(h=>{if(!k(h,`crons.${s}`))throw new Error(`schedule "${s}" not found`);E(h,`crons.${s}.approval`,c)});if(!t.success)return`Error: ${t.error}`;let o=l.timezone||"UTC",u=[`Schedule approval requested by ${e.agentId}`,`Delete: ${s}`,`When: ${T(l.schedule)} \u2014 cron \`${l.schedule}\` (${o})`,`Next fire: ${l.enabled?v(b(l.schedule,o,a),o):"\u2014 (paused)"}`,`Agent: ${l.agent}`,"",`Approve: agentx schedule approve ${s}`,`Reject: agentx schedule reject ${s}`].join(`
6
6
  `),p=await F(d,r,u);return[`Deletion of "${s}" requested. It keeps its current state until the operator approves.`,p].join(`
7
7
  `)}return`Error: unknown action "${i}". Use list, create, pause, resume or delete.`}function fe(n,e=process.env){let r=f(e.AGENTX_AGENT_ID)||f(n.callerAgentId);if(!r)return null;let i=!!(f(e.AGENTX_CHANNEL)&&f(e.AGENTX_CHAT_ID)),a=f(i?e.AGENTX_CHANNEL:n.channel),d=f(i?e.AGENTX_CHAT_ID:n.chatId),m=f(n.accountId);return{agentId:r,channel:a,chatId:d,...m?{accountId:m}:{}}}export{H as a,G as b,he as c,fe as d};
8
- //# sourceMappingURL=chunk-S656M5R5.js.map
8
+ //# sourceMappingURL=chunk-VNXYQH45.js.map
@@ -48,7 +48,7 @@ The "modified" field is optional and can contain updated values to pass forward.
48
48
  ... (output truncated)`:i;return s.exitCode!==0?{tool_use_id:e.id,content:`Command exited with code ${s.exitCode}:
49
49
  ${l}`,is_error:!0}:{tool_use_id:e.id,content:l||"(no output)"}}async editFile(e){let t=String(e.input.path||""),o=e.input.edits,r=ge.resolve(this.cwd,t);if(!o||o.length===0)return{tool_use_id:e.id,content:"No edits provided.",is_error:!0};let s=await W.checkFileWrite(t);if(s==="deny")return{tool_use_id:e.id,content:`File write blocked by permissions: ${t}`,is_error:!0};if(s==="skip")return{tool_use_id:e.id,content:`File write skipped (plan mode): ${t}`};if(f.has("pre:file-write")){let a=await f.execute("pre:file-write",{event:"pre:file-write",file:r,cwd:this.cwd});if(a.blocked)return{tool_use_id:e.id,content:a.message||`File edit blocked by pre:file-write hook: ${t}`,is_error:!0}}let i=await ne.readFile(r,"utf8"),l=[];for(let a of o)i.includes(a.old_text)?(i=i.replace(a.old_text,a.new_text),l.push(`Replaced: "${a.old_text.slice(0,40)}..."`)):l.push(`Not found: "${a.old_text.slice(0,40)}..."`);return this.options.dryRun||await ne.writeFile(r,i,"utf8"),f.has("post:file-write")&&await f.execute("post:file-write",{event:"post:file-write",file:r,fileContent:i,cwd:this.cwd}),{tool_use_id:e.id,content:`Edited ${t}:
50
50
  ${l.join(`
51
- `)}`}}async createFiles(e){let t=e.input,o=t.files||[];return{tool_use_id:e.id,content:t.summary||`Queued ${o.length} file(s) for creation.`,files:o}}async spawnAgent(e){let t=String(e.input.agent_id||""),o=String(e.input.prompt||""),r=Number(e.input.timeout_seconds)||300;if(!t||!o)return{tool_use_id:e.id,content:"agent_id and prompt are required.",is_error:!0};try{let{SubAgentManager:s}=await import("./subagent-XY5N7TUU.js"),{getGlobalRegistry:i}=await import("./registry-EZBD7QJ3.js"),l=i();if(!l)return{tool_use_id:e.id,content:"Sub-agent spawning requires the daemon to be running.",is_error:!0};let p=await new s(l).spawn({targetAgentId:t,prompt:o,parentAgentId:"orchestrator",timeout:r*1e3});return p.success?{tool_use_id:e.id,content:`Sub-agent "${t}" completed (${Math.round(p.duration/1e3)}s):
51
+ `)}`}}async createFiles(e){let t=e.input,o=t.files||[];return{tool_use_id:e.id,content:t.summary||`Queued ${o.length} file(s) for creation.`,files:o}}async spawnAgent(e){let t=String(e.input.agent_id||""),o=String(e.input.prompt||""),r=Number(e.input.timeout_seconds)||300;if(!t||!o)return{tool_use_id:e.id,content:"agent_id and prompt are required.",is_error:!0};try{let{SubAgentManager:s}=await import("./subagent-XY5N7TUU.js"),{getGlobalRegistry:i}=await import("./registry-77HLNAQF.js"),l=i();if(!l)return{tool_use_id:e.id,content:"Sub-agent spawning requires the daemon to be running.",is_error:!0};let p=await new s(l).spawn({targetAgentId:t,prompt:o,parentAgentId:"orchestrator",timeout:r*1e3});return p.success?{tool_use_id:e.id,content:`Sub-agent "${t}" completed (${Math.round(p.duration/1e3)}s):
52
52
 
53
53
  ${p.content}`}:{tool_use_id:e.id,content:`Sub-agent "${t}" failed: ${p.error}`,is_error:!0}}catch(s){return{tool_use_id:e.id,content:`Failed to spawn sub-agent: ${s.message}`,is_error:!0}}}async askUser(e){let t=String(e.input.question||""),o=e.input.options,r=t;return o?.length&&(r+=`
54
54
  Options: ${o.join(", ")}`),{tool_use_id:e.id,content:"Question sent to user.",followUp:r}}};async function Oe(n){let{provider:e,systemPrompt:t,messages:o,providerOptions:r,cwd:s,maxIterations:i=20,enabledTools:l,interactive:a=!0,overwrite:p=!1,dryRun:c=!1,onProgress:d,abortSignal:u}=n,m=u?{...r,abortSignal:u}:r;if(!e.generateRaw)return mt(n);let I=new se(s,{interactive:a,overwrite:p,dryRun:c,acmeContext:n.acmeContext,abortSignal:u}),D=be(l);if(n.acmeContext)for(let g of ct)D.push({name:g.name,description:g.description,input_schema:g.input_schema});let E=new Set;if(n.mcpTools?.length)for(let g of n.mcpTools)D.push({name:g.name,description:g.description,input_schema:g.input_schema}),E.add(g.name);let C=o.filter(g=>g.role!=="system").map(g=>({role:g.role,content:g.content})),B=[],G=0,F=0,O=0,A="",j,_=0;for(;_<i;){if(_++,u?.aborted)throw new Error("cancelled");d?.({type:"iteration_start",iteration:_}),k.step(_,`Agentic loop iteration (${D.length} tools available)`);let g,M=!!e.generateRawStream&&!!d;try{if(M){let S=null,H=null,v="";for await(let x of e.generateRawStream(C,t,D,m))x.type==="text_delta"?(v+=x.text,d?.({type:"text_delta",text:x.text})):x.type==="thinking_delta"?d?.({type:"thinking_delta",text:x.text}):x.type==="raw_result"?S=x.result:x.type==="error"&&(H=x.error);if(H&&!S)throw new Error(H);if(!S)throw new Error("generateRawStream returned no raw_result event");g=S,g._streamedText=v}else g=await e.generateRaw(C,t,D,m)}catch(S){if(S.message?.includes("not available"))return mt(n);throw S}G+=g.usage.input_tokens+g.usage.output_tokens,F+=g.usage.input_tokens,O+=g.usage.output_tokens;let P=g._streamedText;for(let S of g.content)S.type==="text"&&(A+=S.text,P===void 0&&d?.({type:"text_delta",text:S.text}));if(P!==void 0&&delete g._streamedText,g.stop_reason==="end_turn"||g.stop_reason==="max_tokens")break;if(g.stop_reason==="tool_use"){let S=g.content.filter(v=>v.type==="tool_use");if(S.length===0)break;C.push({role:"assistant",content:g.content});let H=[];for(let v of S){d?.({type:"tool_call",name:v.name,id:v.id,input:v.input}),k.step(_,`Tool call: ${v.name}`);let x;if(E.has(v.name)&&n.mcpDispatch){let h=await n.mcpDispatch(v.name,v.input);x={tool_use_id:v.id,content:h.content,is_error:h.isError}}else x=await I.execute({name:v.name,id:v.id,input:v.input});d?.({type:"tool_result",name:v.name,id:v.id,content:x.content.slice(0,200),is_error:x.is_error}),x.files?.length&&(B.push(...x.files),d?.({type:"files_created",files:x.files})),x.followUp&&(j=x.followUp),H.push({type:"tool_result",tool_use_id:x.tool_use_id,content:x.content,is_error:x.is_error})}if(C.push({role:"user",content:H}),j)break;continue}break}return d?.({type:"complete",iterations:_,totalTokens:G}),{files:B,content:A,followUp:j,tokensUsed:G,inputTokens:F||void 0,outputTokens:O||void 0,iterations:_}}async function mt(n){let{provider:e,systemPrompt:t,messages:o,providerOptions:r,maxIterations:s=5}=n,l=[{role:"system",content:t+`
@@ -123,4 +123,4 @@ ${n.projectInstructions}`),n.memoryContext&&o.push(n.memoryContext),o.push(`# Ou
123
123
  Generate output appropriate for: ${e}. Use the \`create_files\` tool to output all files.`),o.join(`
124
124
 
125
125
  `)}export{We as a,Xt as b,Qt as c,Je as d,Ke as e,Xe as f,Qe as g,Pe as h,ee as i,Re as j,ce as k,te as l,Pt as m,oe as n,Et as o,f as p,ot as q,rt as r,Me as s,de as t,W as u,re as v,lt as w,Ee as x,$e as y,se as z,gt as A,tn as B,on as C};
126
- //# sourceMappingURL=chunk-BEH3UJGT.js.map
126
+ //# sourceMappingURL=chunk-W7PIHJHH.js.map