agentix-cli 0.216.0 → 0.218.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 (166) hide show
  1. package/dist/{App-YGVVIKZD.js → App-2IEK5HWX.js} +2 -2
  2. package/dist/{ChatApp-6TEK2WMU.js → ChatApp-YHC7ASGR.js} +2 -2
  3. package/dist/{absorb-eval-MJ475CNV.js → absorb-eval-GJ47IOFG.js} +2 -2
  4. package/dist/{adapter-C6YORAE6.js → adapter-WROHSAHE.js} +2 -2
  5. package/dist/{agent-44SGRWX2.js → agent-5MYO4YCO.js} +2 -2
  6. package/dist/{board-dashboard-TZKV4DFV.js → board-dashboard-3CSSUGNZ.js} +621 -394
  7. package/dist/board-dashboard-3CSSUGNZ.js.map +1 -0
  8. package/dist/{chunk-TFHJT2AZ.js → chunk-2REJBHT5.js} +2 -2
  9. package/dist/{chunk-T7SD5EVH.js → chunk-AKPLNPUY.js} +2 -2
  10. package/dist/{chunk-JTS563OC.js → chunk-B5JK4MQX.js} +2 -2
  11. package/dist/{chunk-3UATFGSB.js → chunk-B7WQT7GG.js} +2 -2
  12. package/dist/chunk-BXK5S2KK.js +13 -0
  13. package/dist/chunk-BXK5S2KK.js.map +1 -0
  14. package/dist/{chunk-PA7CP74O.js → chunk-CHCAPQ6E.js} +2 -2
  15. package/dist/{chunk-F32VADB7.js → chunk-D3HNIOZ7.js} +2 -2
  16. package/dist/{chunk-JNBUJKNG.js → chunk-ETMUGFPI.js} +2 -2
  17. package/dist/{chunk-TO6T6AQY.js → chunk-EVFQINOQ.js} +2 -2
  18. package/dist/{chunk-WLDRIJQX.js → chunk-FJJ5PVQK.js} +5 -5
  19. package/dist/{chunk-F2XNWKIL.js → chunk-FSEJ2LX5.js} +393 -434
  20. package/dist/chunk-FSEJ2LX5.js.map +1 -0
  21. package/dist/chunk-GMQLDXEM.js +8 -0
  22. package/dist/chunk-GMQLDXEM.js.map +1 -0
  23. package/dist/{chunk-7OJUZ3L5.js → chunk-GP56ZRAF.js} +2 -2
  24. package/dist/{chunk-MH7KJQ4N.js → chunk-HCQX6LVZ.js} +2 -2
  25. package/dist/{chunk-JMWPBZLU.js → chunk-IATCZJP7.js} +2 -2
  26. package/dist/chunk-JE2EV6NS.js +134 -0
  27. package/dist/chunk-JE2EV6NS.js.map +1 -0
  28. package/dist/{chunk-SZXFWCKA.js → chunk-K5VZS747.js} +2 -2
  29. package/dist/{chunk-I4E6BH27.js → chunk-M75VNIVM.js} +2 -2
  30. package/dist/{chunk-I4E6BH27.js.map → chunk-M75VNIVM.js.map} +1 -1
  31. package/dist/{chunk-XXFVK5D7.js → chunk-MSOAI54R.js} +141 -87
  32. package/dist/chunk-MSOAI54R.js.map +1 -0
  33. package/dist/{chunk-T3B7OUDC.js → chunk-NJLWS44P.js} +2 -2
  34. package/dist/{chunk-LJUBWMPB.js → chunk-NLMQ7ZAE.js} +2 -2
  35. package/dist/{chunk-AU7SN4G3.js → chunk-OQEP2Q32.js} +2 -2
  36. package/dist/{chunk-GEKJQ7VV.js → chunk-PJ2OFOAL.js} +2 -2
  37. package/dist/{chunk-LDSBFDYB.js → chunk-QAMVAZ67.js} +2 -2
  38. package/dist/chunk-QEGBOPAP.js +10 -0
  39. package/dist/chunk-QEGBOPAP.js.map +1 -0
  40. package/dist/{chunk-BLKXK27S.js → chunk-QW5WOBSU.js} +2 -2
  41. package/dist/{chunk-6UTOBSEA.js → chunk-SYIDD7CI.js} +2 -2
  42. package/dist/{chunk-YTWRIIAT.js → chunk-VFG7GZC6.js} +2 -2
  43. package/dist/{chunk-IKXDCPXS.js → chunk-WZIFXZZX.js} +2 -2
  44. package/dist/{chunk-2KQECT4H.js → chunk-X23I2U26.js} +2 -2
  45. package/dist/{chunk-M4H2RYP4.js → chunk-XQH4LCZR.js} +2 -2
  46. package/dist/{chunk-U5DSMDCJ.js → chunk-YB2QYUXG.js} +2 -2
  47. package/dist/{chunk-5SQRJUAK.js → chunk-YG5GPPGI.js} +3 -3
  48. package/dist/{chunk-2ZNYIHRB.js → chunk-ZXABOPXF.js} +2 -2
  49. package/dist/cli.js +1 -1
  50. package/dist/{client-SJLHZDIC.js → client-2TJ3TOCH.js} +2 -2
  51. package/dist/{config-Q3ENZQYL.js → config-JHSM6KFT.js} +2 -2
  52. package/dist/{config-mutate-NNAUMQ2Y.js → config-mutate-YERBKGAB.js} +2 -2
  53. package/dist/{config-mutator-2F2BJNMA.js → config-mutator-WNNU4EDV.js} +2 -2
  54. package/dist/{contributions-SOUGZCAH.js → contributions-HAWUHQWM.js} +2 -2
  55. package/dist/{doctor-H6I433KY.js → doctor-GOMB6LDS.js} +2 -2
  56. package/dist/{follow-up-tool-4FX455DL.js → follow-up-tool-5YFJS2JZ.js} +2 -2
  57. package/dist/{follow-up-tool-4FX455DL.js.map → follow-up-tool-5YFJS2JZ.js.map} +1 -1
  58. package/dist/{grants-U2734ZHZ.js → grants-ZA35QVTX.js} +2 -2
  59. package/dist/{hub-XFZFHLJK.js → hub-3M4HJMYR.js} +2 -2
  60. package/dist/index.d.ts +34 -3
  61. package/dist/index.js +1 -1
  62. package/dist/org-tool-JS4WKB35.js +2 -0
  63. package/dist/{org-tool-OE5QP6W7.js.map → org-tool-JS4WKB35.js.map} +1 -1
  64. package/dist/{program-7QFRDJUY.js → program-OFMRVB7N.js} +308 -308
  65. package/dist/program-OFMRVB7N.js.map +1 -0
  66. package/dist/{promote-FQY3HNL6.js → promote-BME3QLM6.js} +2 -2
  67. package/dist/{query-LIII4CGT.js → query-BFZDI667.js} +2 -2
  68. package/dist/{query-settings-6LHW2NCF.js → query-settings-ICYJNA6H.js} +2 -2
  69. package/dist/{registry-WQNBXOUL.js → registry-NUO4JEA5.js} +2 -2
  70. package/dist/{request-planner-HYYT3W7X.js → request-planner-CUAEVQKB.js} +2 -2
  71. package/dist/{review-candidates-JOCZEZ2L.js → review-candidates-PGF3IRZR.js} +2 -2
  72. package/dist/{routing-D7W4BDER.js → routing-CXGJMM55.js} +2 -2
  73. package/dist/schedule-tool-G3RBORJS.js +2 -0
  74. package/dist/{scheduler-JHY767T4.js → scheduler-FKCNMUB7.js} +2 -2
  75. package/dist/{seat-44NEMWB5.js → seat-6TUUPDR6.js} +2 -2
  76. package/dist/{select-5FMPLCCG.js → select-ARQMXFFV.js} +2 -2
  77. package/dist/{set-enabled-GVQFNLOS.js → set-enabled-CYS6NYKQ.js} +2 -2
  78. package/dist/{sprint-tool-X3A5VPJP.js → sprint-tool-5RNJZDQJ.js} +2 -2
  79. package/dist/{sprint-tool-X3A5VPJP.js.map → sprint-tool-5RNJZDQJ.js.map} +1 -1
  80. package/dist/tool-243ZBIYG.js +2 -0
  81. package/dist/{tool-QIS3CLU2.js → tool-CHHSFKU2.js} +2 -2
  82. package/dist/{tool-QIS3CLU2.js.map → tool-CHHSFKU2.js.map} +1 -1
  83. package/dist/{tool-H7RMHTXM.js → tool-JAVKPEKS.js} +2 -2
  84. package/dist/{tool-H7RMHTXM.js.map → tool-JAVKPEKS.js.map} +1 -1
  85. package/dist/tool-KY7WN3HV.js +4 -0
  86. package/dist/{tool-ILYSRPZ5.js.map → tool-KY7WN3HV.js.map} +1 -1
  87. package/dist/{tool-KCOCIAFM.js → tool-YQFTOJJL.js} +2 -2
  88. package/dist/{tool-KCOCIAFM.js.map → tool-YQFTOJJL.js.map} +1 -1
  89. package/dist/{wiki-UMPPYYFR.js → wiki-RJKQ6ZLV.js} +2 -2
  90. package/dist/wiki-enrich-4ZKID3ZU.js +2 -0
  91. package/dist/{workspace-setup-VGXHYCD5.js → workspace-setup-CQ5FMT2B.js} +2 -2
  92. package/dist/workspace-setup-CQ5FMT2B.js.map +1 -0
  93. package/package.json +1 -1
  94. package/dist/board-dashboard-TZKV4DFV.js.map +0 -1
  95. package/dist/chunk-4A6UVU2X.js +0 -134
  96. package/dist/chunk-4A6UVU2X.js.map +0 -1
  97. package/dist/chunk-F2XNWKIL.js.map +0 -1
  98. package/dist/chunk-MOEXP6U3.js +0 -8
  99. package/dist/chunk-MOEXP6U3.js.map +0 -1
  100. package/dist/chunk-OQQTV3OF.js +0 -12
  101. package/dist/chunk-OQQTV3OF.js.map +0 -1
  102. package/dist/chunk-RKPAVWXF.js +0 -2
  103. package/dist/chunk-RKPAVWXF.js.map +0 -1
  104. package/dist/chunk-XXFVK5D7.js.map +0 -1
  105. package/dist/org-tool-OE5QP6W7.js +0 -2
  106. package/dist/program-7QFRDJUY.js.map +0 -1
  107. package/dist/schedule-tool-B4RDOKCN.js +0 -2
  108. package/dist/tool-ILYSRPZ5.js +0 -4
  109. package/dist/tool-Z7TIGVEW.js +0 -7
  110. package/dist/tool-Z7TIGVEW.js.map +0 -1
  111. package/dist/wiki-enrich-UVCZ7GTW.js +0 -2
  112. /package/dist/{App-YGVVIKZD.js.map → App-2IEK5HWX.js.map} +0 -0
  113. /package/dist/{ChatApp-6TEK2WMU.js.map → ChatApp-YHC7ASGR.js.map} +0 -0
  114. /package/dist/{absorb-eval-MJ475CNV.js.map → absorb-eval-GJ47IOFG.js.map} +0 -0
  115. /package/dist/{adapter-C6YORAE6.js.map → adapter-WROHSAHE.js.map} +0 -0
  116. /package/dist/{agent-44SGRWX2.js.map → agent-5MYO4YCO.js.map} +0 -0
  117. /package/dist/{chunk-TFHJT2AZ.js.map → chunk-2REJBHT5.js.map} +0 -0
  118. /package/dist/{chunk-T7SD5EVH.js.map → chunk-AKPLNPUY.js.map} +0 -0
  119. /package/dist/{chunk-JTS563OC.js.map → chunk-B5JK4MQX.js.map} +0 -0
  120. /package/dist/{chunk-3UATFGSB.js.map → chunk-B7WQT7GG.js.map} +0 -0
  121. /package/dist/{chunk-PA7CP74O.js.map → chunk-CHCAPQ6E.js.map} +0 -0
  122. /package/dist/{chunk-F32VADB7.js.map → chunk-D3HNIOZ7.js.map} +0 -0
  123. /package/dist/{chunk-JNBUJKNG.js.map → chunk-ETMUGFPI.js.map} +0 -0
  124. /package/dist/{chunk-TO6T6AQY.js.map → chunk-EVFQINOQ.js.map} +0 -0
  125. /package/dist/{chunk-WLDRIJQX.js.map → chunk-FJJ5PVQK.js.map} +0 -0
  126. /package/dist/{chunk-7OJUZ3L5.js.map → chunk-GP56ZRAF.js.map} +0 -0
  127. /package/dist/{chunk-MH7KJQ4N.js.map → chunk-HCQX6LVZ.js.map} +0 -0
  128. /package/dist/{chunk-JMWPBZLU.js.map → chunk-IATCZJP7.js.map} +0 -0
  129. /package/dist/{chunk-SZXFWCKA.js.map → chunk-K5VZS747.js.map} +0 -0
  130. /package/dist/{chunk-T3B7OUDC.js.map → chunk-NJLWS44P.js.map} +0 -0
  131. /package/dist/{chunk-LJUBWMPB.js.map → chunk-NLMQ7ZAE.js.map} +0 -0
  132. /package/dist/{chunk-AU7SN4G3.js.map → chunk-OQEP2Q32.js.map} +0 -0
  133. /package/dist/{chunk-GEKJQ7VV.js.map → chunk-PJ2OFOAL.js.map} +0 -0
  134. /package/dist/{chunk-LDSBFDYB.js.map → chunk-QAMVAZ67.js.map} +0 -0
  135. /package/dist/{chunk-BLKXK27S.js.map → chunk-QW5WOBSU.js.map} +0 -0
  136. /package/dist/{chunk-6UTOBSEA.js.map → chunk-SYIDD7CI.js.map} +0 -0
  137. /package/dist/{chunk-YTWRIIAT.js.map → chunk-VFG7GZC6.js.map} +0 -0
  138. /package/dist/{chunk-IKXDCPXS.js.map → chunk-WZIFXZZX.js.map} +0 -0
  139. /package/dist/{chunk-2KQECT4H.js.map → chunk-X23I2U26.js.map} +0 -0
  140. /package/dist/{chunk-M4H2RYP4.js.map → chunk-XQH4LCZR.js.map} +0 -0
  141. /package/dist/{chunk-U5DSMDCJ.js.map → chunk-YB2QYUXG.js.map} +0 -0
  142. /package/dist/{chunk-5SQRJUAK.js.map → chunk-YG5GPPGI.js.map} +0 -0
  143. /package/dist/{chunk-2ZNYIHRB.js.map → chunk-ZXABOPXF.js.map} +0 -0
  144. /package/dist/{client-SJLHZDIC.js.map → client-2TJ3TOCH.js.map} +0 -0
  145. /package/dist/{config-Q3ENZQYL.js.map → config-JHSM6KFT.js.map} +0 -0
  146. /package/dist/{config-mutate-NNAUMQ2Y.js.map → config-mutate-YERBKGAB.js.map} +0 -0
  147. /package/dist/{config-mutator-2F2BJNMA.js.map → config-mutator-WNNU4EDV.js.map} +0 -0
  148. /package/dist/{contributions-SOUGZCAH.js.map → contributions-HAWUHQWM.js.map} +0 -0
  149. /package/dist/{doctor-H6I433KY.js.map → doctor-GOMB6LDS.js.map} +0 -0
  150. /package/dist/{grants-U2734ZHZ.js.map → grants-ZA35QVTX.js.map} +0 -0
  151. /package/dist/{hub-XFZFHLJK.js.map → hub-3M4HJMYR.js.map} +0 -0
  152. /package/dist/{promote-FQY3HNL6.js.map → promote-BME3QLM6.js.map} +0 -0
  153. /package/dist/{query-LIII4CGT.js.map → query-BFZDI667.js.map} +0 -0
  154. /package/dist/{query-settings-6LHW2NCF.js.map → query-settings-ICYJNA6H.js.map} +0 -0
  155. /package/dist/{registry-WQNBXOUL.js.map → registry-NUO4JEA5.js.map} +0 -0
  156. /package/dist/{request-planner-HYYT3W7X.js.map → request-planner-CUAEVQKB.js.map} +0 -0
  157. /package/dist/{review-candidates-JOCZEZ2L.js.map → review-candidates-PGF3IRZR.js.map} +0 -0
  158. /package/dist/{routing-D7W4BDER.js.map → routing-CXGJMM55.js.map} +0 -0
  159. /package/dist/{schedule-tool-B4RDOKCN.js.map → schedule-tool-G3RBORJS.js.map} +0 -0
  160. /package/dist/{scheduler-JHY767T4.js.map → scheduler-FKCNMUB7.js.map} +0 -0
  161. /package/dist/{seat-44NEMWB5.js.map → seat-6TUUPDR6.js.map} +0 -0
  162. /package/dist/{select-5FMPLCCG.js.map → select-ARQMXFFV.js.map} +0 -0
  163. /package/dist/{set-enabled-GVQFNLOS.js.map → set-enabled-CYS6NYKQ.js.map} +0 -0
  164. /package/dist/{wiki-UMPPYYFR.js.map → tool-243ZBIYG.js.map} +0 -0
  165. /package/dist/{wiki-enrich-UVCZ7GTW.js.map → wiki-RJKQ6ZLV.js.map} +0 -0
  166. /package/dist/{workspace-setup-VGXHYCD5.js.map → wiki-enrich-4ZKID3ZU.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as _,b as F,c as K,d as z,e as J}from"./chunk-JTFCU5LH.js";import{a as H}from"./chunk-LUOW2YHY.js";import{a as j,b as I,c as Y,d as V,e as B,j as G}from"./chunk-T7SD5EVH.js";import{b as E,c as L}from"./chunk-AHWWJ7AF.js";import{y as N,z as ot}from"./chunk-BLKXK27S.js";import{h as Q}from"./chunk-QUFIUXMQ.js";import{readFileSync as lt,existsSync as X}from"fs";ot();import{resolve as R}from"path";import{execSync as ct}from"child_process";var ht="haiku",dt="sonnet",pt=.8;function mt(e,r,o,t){if(t.size===0)return 0;let c=e.listArticles(r||"").map(l=>l.path).filter(l=>!l.includes("/_versions/"));return c.length===0&&(c=o.sharedPool.map(l=>l.path)),c.length===0?0:c.filter(l=>t.has(l)).length/c.length}async function _t(e,r,o,t={}){let c=t.selectorModel??ht,l=t.synthModel??dt,m=t.maxCandidates??3,g=t.maxHops??2,d=t.maxArticles??8,i=t.timeoutMs??6e4,s=t.log??console.error.bind(console,"[wiki-query]"),h=t.messagePath?.length?t.messagePath:void 0,n=t.graphWeight??W,a=R(r.baseDir,"_index.md"),p=tt(r,o,t.shared),b=t.method??"catalog";if(b!=="catalog"){let u=z(r,t.shared);if(b==="summaries"||mt(r,o,p,u)>=pt){let f=t.summaries??K,P=t.notes&&o&&t.notes.owner===o?F(t.notes):void 0,y=await J(e,P?gt(p,P):p,P?new Map([...u,...P.summaries]):u,{...f,navigatorModel:t.selectorModel??f.navigatorModel,answerModel:t.synthModel??f.answerModel},{call:t.call??H,fetch:t.fetch,timeoutMs:i,log:s}),$=y.picked.map(w=>({title:w.meta.title,path:w.path,type:_(w.path)?"note":w.meta.type,hop:w.hop}));return{answer:y.answer,citations:y.status==="ok"?$.map(({hop:w,...v})=>v):[],candidates:$.filter(w=>w.hop===0).map(({title:w,path:v})=>({title:w,path:v})),walked:$,status:y.status,method:"summaries",basis:y.basis,live:y.live,liveAsked:y.liveAsked,trace:y.trace,...y.error?{error:y.error}:{}}}}if(!X(a)&&p.sharedPool.length===0)return M("no-catalog",e,"No _index.md found \u2014 run `agentx wiki status` to rebuild.");let it=(X(a)?lt(a,"utf-8"):"")+yt(e,p.sharedPool,h,n),T=Date.now(),A=[],S="";try{let u=await nt(e,p.pool,o,m,h,n);u?(A=u,S=`[wiki-rerank seat] ${u.map(f=>f.title).join(" | ")}`):(S=await Z(wt(e,it,m,h),c,i),A=bt(S))}catch(u){return s("selector failed:",u?.message),{...M("error",e,`Selector: ${u?.message||"unknown"}`),trace:{selectorMs:Date.now()-T,synthesisMs:0,selectorOutput:S}}}let x=Date.now()-T;if(A.length===0)return{...M("no-candidates",e,"Selector returned no candidates."),trace:{selectorMs:x,synthesisMs:0,selectorOutput:S}};let C=rt(A,p,g,d);if(C.length===0)return{...M("no-candidates",e,"Candidates did not resolve to readable articles."),candidates:A,trace:{selectorMs:x,synthesisMs:0,selectorOutput:S}};let D=Date.now(),U="";try{U=await Z(kt(e,C),l,i*2)}catch(u){return s("synthesis failed:",u?.message),{...M("error",e,`Synthesis: ${u?.message||"unknown"}`),candidates:A,walked:C.map(f=>({title:f.meta.title,path:f.path,type:f.meta.type,hop:f.hop??0})),trace:{selectorMs:x,synthesisMs:Date.now()-D,selectorOutput:S}}}let st=Date.now()-D;return{answer:U.trim(),citations:C.map(u=>({title:u.meta.title,path:u.path,type:u.meta.type})),candidates:A,walked:C.map(u=>({title:u.meta.title,path:u.path,type:u.meta.type,hop:u.hop??0})),status:"ok",trace:{selectorMs:x,synthesisMs:st,selectorOutput:S}}}async function Rt(e,r,o,t={}){let c=t.maxCandidates??3,l=t.graphWeight??W,m=t.messagePath?.length?t.messagePath:void 0,g=t.pool??q(r);if(g.length===0||!e.trim())return[];let d=await nt(e,g,o,c,m,l,t.stage??"retrieve");if(!d){let i=new Set(L(e,E(g.map(at))).map(s=>s.docIndex));d=O(e,g,m,l).filter(s=>i.has(s)).slice(0,c).map(s=>({title:g[s].title,path:g[s].path}))}return d.length===0?[]:rt(d,tt(r,o),t.maxHops??1,t.maxArticles??6)}function q(e){try{return(e.rebuildIndex().articles??[]).filter(r=>r.path&&!r.path.includes("/_versions/"))}catch{return[]}}function M(e,r,o){return{answer:"",citations:[],candidates:[],walked:[],status:e,error:o}}function tt(e,r,o=[]){let t=new Map,c=[];for(let i of e.listArticles(r||""))t.set(i.meta.title.toLowerCase(),i.path),c.push({path:i.path,related:i.meta.related??[],lastUpdated:i.meta.lastUpdated??""});let l=[],m=new Map;for(let i of o)if(i.store.baseDir!==e.baseDir){m.set(i.id,i);for(let s of i.store.listArticles(r||"")){if(s.path.includes("/_versions/")||i.skip?.(s.path))continue;let h=`@${i.id}/${s.path}`;l.push(ut(s,h)),c.push({path:h,related:s.meta.related??[],lastUpdated:s.meta.lastUpdated??""});let n=s.meta.title.toLowerCase();t.has(n)||t.set(n,h)}}let g=new Map;if(m.size>0)for(let i of[...c].sort((s,h)=>h.lastUpdated.localeCompare(s.lastUpdated)))for(let s of i.related){let h=s.toLowerCase(),n=g.get(h)??[];n.includes(i.path)||n.push(i.path),g.set(h,n)}let d;return{backlinks:g,readable:new Set(c.map(i=>i.path)),get pool(){return d??=[...q(e),...l]},sharedPool:l,titleIndex:t,read(i){let s=i.match(/^@([^/]+)\/(.+)$/),h=s?m.get(s[1]):void 0;if(s&&!h)return null;let n=h?.store??e,a=s?s[2]:i,p=r?n.readArticleAs(a,r):n.readArticle(a);return p?{...p,path:i}:null},links(i){let s=(i.meta.related??[]).map(a=>t.get(a.toLowerCase())).filter(a=>!!a),h=[i.meta.title,...i.meta.aliases??[]].map(a=>a.toLowerCase()),n=[...new Set(h.flatMap(a=>g.get(a)??[]))].filter(a=>a!==i.path).slice(0,et);return[...new Set([...s,...n])].filter(a=>a!==i.path)}}}function gt(e,r){return{...e,pool:[...e.pool,...r.pool],readable:new Set([...e.readable,...r.pool.map(o=>o.path)]),read:o=>_(o)?r.read(o):e.read(o)}}function ut(e,r){return{path:r,title:e.meta.title,type:e.meta.type,related:e.meta.related,tags:e.meta.tags||[],owner:e.meta.owner,access:e.meta.access,sharedWith:e.meta.sharedWith,aliases:[e.meta.title.toLowerCase(),...(e.meta.aliases??[]).map(o=>o.toLowerCase())],backlinks:0,sources:e.meta.sources,lastUpdated:e.meta.lastUpdated,graphPath:e.meta.graphPath}}var ft=150;function yt(e,r,o,t){return r.length===0?"":`
1
+ import{a as _,b as F,c as K,d as z,e as J}from"./chunk-JTFCU5LH.js";import{a as H}from"./chunk-LUOW2YHY.js";import{a as j,b as I,c as Y,d as V,e as B,j as G}from"./chunk-AKPLNPUY.js";import{b as E,c as L}from"./chunk-AHWWJ7AF.js";import{y as N,z as ot}from"./chunk-QW5WOBSU.js";import{h as Q}from"./chunk-QUFIUXMQ.js";import{readFileSync as lt,existsSync as X}from"fs";ot();import{resolve as R}from"path";import{execSync as ct}from"child_process";var ht="haiku",dt="sonnet",pt=.8;function mt(e,r,o,t){if(t.size===0)return 0;let c=e.listArticles(r||"").map(l=>l.path).filter(l=>!l.includes("/_versions/"));return c.length===0&&(c=o.sharedPool.map(l=>l.path)),c.length===0?0:c.filter(l=>t.has(l)).length/c.length}async function _t(e,r,o,t={}){let c=t.selectorModel??ht,l=t.synthModel??dt,m=t.maxCandidates??3,g=t.maxHops??2,d=t.maxArticles??8,i=t.timeoutMs??6e4,s=t.log??console.error.bind(console,"[wiki-query]"),h=t.messagePath?.length?t.messagePath:void 0,n=t.graphWeight??W,a=R(r.baseDir,"_index.md"),p=tt(r,o,t.shared),b=t.method??"catalog";if(b!=="catalog"){let u=z(r,t.shared);if(b==="summaries"||mt(r,o,p,u)>=pt){let f=t.summaries??K,P=t.notes&&o&&t.notes.owner===o?F(t.notes):void 0,y=await J(e,P?gt(p,P):p,P?new Map([...u,...P.summaries]):u,{...f,navigatorModel:t.selectorModel??f.navigatorModel,answerModel:t.synthModel??f.answerModel},{call:t.call??H,fetch:t.fetch,timeoutMs:i,log:s}),$=y.picked.map(w=>({title:w.meta.title,path:w.path,type:_(w.path)?"note":w.meta.type,hop:w.hop}));return{answer:y.answer,citations:y.status==="ok"?$.map(({hop:w,...v})=>v):[],candidates:$.filter(w=>w.hop===0).map(({title:w,path:v})=>({title:w,path:v})),walked:$,status:y.status,method:"summaries",basis:y.basis,live:y.live,liveAsked:y.liveAsked,trace:y.trace,...y.error?{error:y.error}:{}}}}if(!X(a)&&p.sharedPool.length===0)return M("no-catalog",e,"No _index.md found \u2014 run `agentx wiki status` to rebuild.");let it=(X(a)?lt(a,"utf-8"):"")+yt(e,p.sharedPool,h,n),T=Date.now(),A=[],S="";try{let u=await nt(e,p.pool,o,m,h,n);u?(A=u,S=`[wiki-rerank seat] ${u.map(f=>f.title).join(" | ")}`):(S=await Z(wt(e,it,m,h),c,i),A=bt(S))}catch(u){return s("selector failed:",u?.message),{...M("error",e,`Selector: ${u?.message||"unknown"}`),trace:{selectorMs:Date.now()-T,synthesisMs:0,selectorOutput:S}}}let x=Date.now()-T;if(A.length===0)return{...M("no-candidates",e,"Selector returned no candidates."),trace:{selectorMs:x,synthesisMs:0,selectorOutput:S}};let C=rt(A,p,g,d);if(C.length===0)return{...M("no-candidates",e,"Candidates did not resolve to readable articles."),candidates:A,trace:{selectorMs:x,synthesisMs:0,selectorOutput:S}};let D=Date.now(),U="";try{U=await Z(kt(e,C),l,i*2)}catch(u){return s("synthesis failed:",u?.message),{...M("error",e,`Synthesis: ${u?.message||"unknown"}`),candidates:A,walked:C.map(f=>({title:f.meta.title,path:f.path,type:f.meta.type,hop:f.hop??0})),trace:{selectorMs:x,synthesisMs:Date.now()-D,selectorOutput:S}}}let st=Date.now()-D;return{answer:U.trim(),citations:C.map(u=>({title:u.meta.title,path:u.path,type:u.meta.type})),candidates:A,walked:C.map(u=>({title:u.meta.title,path:u.path,type:u.meta.type,hop:u.hop??0})),status:"ok",trace:{selectorMs:x,synthesisMs:st,selectorOutput:S}}}async function Rt(e,r,o,t={}){let c=t.maxCandidates??3,l=t.graphWeight??W,m=t.messagePath?.length?t.messagePath:void 0,g=t.pool??q(r);if(g.length===0||!e.trim())return[];let d=await nt(e,g,o,c,m,l,t.stage??"retrieve");if(!d){let i=new Set(L(e,E(g.map(at))).map(s=>s.docIndex));d=O(e,g,m,l).filter(s=>i.has(s)).slice(0,c).map(s=>({title:g[s].title,path:g[s].path}))}return d.length===0?[]:rt(d,tt(r,o),t.maxHops??1,t.maxArticles??6)}function q(e){try{return(e.rebuildIndex().articles??[]).filter(r=>r.path&&!r.path.includes("/_versions/"))}catch{return[]}}function M(e,r,o){return{answer:"",citations:[],candidates:[],walked:[],status:e,error:o}}function tt(e,r,o=[]){let t=new Map,c=[];for(let i of e.listArticles(r||""))t.set(i.meta.title.toLowerCase(),i.path),c.push({path:i.path,related:i.meta.related??[],lastUpdated:i.meta.lastUpdated??""});let l=[],m=new Map;for(let i of o)if(i.store.baseDir!==e.baseDir){m.set(i.id,i);for(let s of i.store.listArticles(r||"")){if(s.path.includes("/_versions/")||i.skip?.(s.path))continue;let h=`@${i.id}/${s.path}`;l.push(ut(s,h)),c.push({path:h,related:s.meta.related??[],lastUpdated:s.meta.lastUpdated??""});let n=s.meta.title.toLowerCase();t.has(n)||t.set(n,h)}}let g=new Map;if(m.size>0)for(let i of[...c].sort((s,h)=>h.lastUpdated.localeCompare(s.lastUpdated)))for(let s of i.related){let h=s.toLowerCase(),n=g.get(h)??[];n.includes(i.path)||n.push(i.path),g.set(h,n)}let d;return{backlinks:g,readable:new Set(c.map(i=>i.path)),get pool(){return d??=[...q(e),...l]},sharedPool:l,titleIndex:t,read(i){let s=i.match(/^@([^/]+)\/(.+)$/),h=s?m.get(s[1]):void 0;if(s&&!h)return null;let n=h?.store??e,a=s?s[2]:i,p=r?n.readArticleAs(a,r):n.readArticle(a);return p?{...p,path:i}:null},links(i){let s=(i.meta.related??[]).map(a=>t.get(a.toLowerCase())).filter(a=>!!a),h=[i.meta.title,...i.meta.aliases??[]].map(a=>a.toLowerCase()),n=[...new Set(h.flatMap(a=>g.get(a)??[]))].filter(a=>a!==i.path).slice(0,et);return[...new Set([...s,...n])].filter(a=>a!==i.path)}}}function gt(e,r){return{...e,pool:[...e.pool,...r.pool],readable:new Set([...e.readable,...r.pool.map(o=>o.path)]),read:o=>_(o)?r.read(o):e.read(o)}}function ut(e,r){return{path:r,title:e.meta.title,type:e.meta.type,related:e.meta.related,tags:e.meta.tags||[],owner:e.meta.owner,access:e.meta.access,sharedWith:e.meta.sharedWith,aliases:[e.meta.title.toLowerCase(),...(e.meta.aliases??[]).map(o=>o.toLowerCase())],backlinks:0,sources:e.meta.sources,lastUpdated:e.meta.lastUpdated,graphPath:e.meta.graphPath}}var ft=150;function yt(e,r,o,t){return r.length===0?"":`
2
2
 
3
3
  ## Shared wiki (other agents' articles)
4
4
 
@@ -51,5 +51,5 @@ ${o}
51
51
 
52
52
  Answer the question in 2\u20136 sentences. Cite articles by their title in square brackets like [Article Title]. When two articles disagree, prefer the one updated more recently, and say which agent's page and date the answer comes from. If the articles do not answer the question, say so plainly (do not invent). Prefer concrete facts over hedging.
53
53
 
54
- Output ONLY the answer \u2014 no preamble, no "here is my answer:", no markdown fencing.`}function bt(e){let r=e.match(/\[[\s\S]*?\]/);if(!r)return[];try{let o=JSON.parse(r[0]);return Array.isArray(o)?o.filter(t=>t&&typeof t.title=="string"&&typeof t.path=="string").map(t=>({title:t.title,path:t.path})):[]}catch{return[]}}async function Z(e,r,o){let{writeFileSync:t,mkdirSync:c,rmSync:l}=await import("fs"),{tmpdir:m}=await import("os"),g=R(m(),`agentx-wiki-query-${process.pid}`);c(g,{recursive:!0});let d=R(g,`prompt-${Date.now()}.txt`);t(d,e);try{let i=`cat '${d}' | claude -p - --output-format json --max-turns 1 --model ${r} --disallowedTools "Bash Read Write Edit Glob Grep Agent WebSearch WebFetch NotebookEdit"`,s=ct(i,{env:Q(),encoding:"utf-8",timeout:o,maxBuffer:4*1024*1024});try{let h=JSON.parse(s);return String(h.result||h.content||"")}catch{return s}}finally{try{l(d,{force:!0})}catch{}}}async function Ot(e){try{let{loadDaemonConfig:r}=await import("./config-Q3ENZQYL.js");return r(e).wiki.query.shared}catch{return!0}}export{ht as a,dt as b,pt as c,_t as d,Rt as e,q as f,ft as g,W as h,O as i,Ot as j};
55
- //# sourceMappingURL=chunk-5SQRJUAK.js.map
54
+ Output ONLY the answer \u2014 no preamble, no "here is my answer:", no markdown fencing.`}function bt(e){let r=e.match(/\[[\s\S]*?\]/);if(!r)return[];try{let o=JSON.parse(r[0]);return Array.isArray(o)?o.filter(t=>t&&typeof t.title=="string"&&typeof t.path=="string").map(t=>({title:t.title,path:t.path})):[]}catch{return[]}}async function Z(e,r,o){let{writeFileSync:t,mkdirSync:c,rmSync:l}=await import("fs"),{tmpdir:m}=await import("os"),g=R(m(),`agentx-wiki-query-${process.pid}`);c(g,{recursive:!0});let d=R(g,`prompt-${Date.now()}.txt`);t(d,e);try{let i=`cat '${d}' | claude -p - --output-format json --max-turns 1 --model ${r} --disallowedTools "Bash Read Write Edit Glob Grep Agent WebSearch WebFetch NotebookEdit"`,s=ct(i,{env:Q(),encoding:"utf-8",timeout:o,maxBuffer:4*1024*1024});try{let h=JSON.parse(s);return String(h.result||h.content||"")}catch{return s}}finally{try{l(d,{force:!0})}catch{}}}async function Ot(e){try{let{loadDaemonConfig:r}=await import("./config-JHSM6KFT.js");return r(e).wiki.query.shared}catch{return!0}}export{ht as a,dt as b,pt as c,_t as d,Rt as e,q as f,ft as g,W as h,O as i,Ot as j};
55
+ //# sourceMappingURL=chunk-YG5GPPGI.js.map
@@ -1,4 +1,4 @@
1
- import{jc as l,tc as m}from"./chunk-4A6UVU2X.js";m();import{existsSync as g,readFileSync as u,writeFileSync as a,copyFileSync as y}from"fs";import{resolve as p}from"path";function P(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(!g(t))throw new Error(`agentx.json not found at ${t}`);let i=JSON.parse(u(t,"utf-8")),o=e(i),s=typeof o=="string"?{summary:o}:o,c=JSON.stringify(i,null,2)+`
1
+ import{Bc as m,rc as l}from"./chunk-JE2EV6NS.js";m();import{existsSync as g,readFileSync as u,writeFileSync as a,copyFileSync as y}from"fs";import{resolve as p}from"path";function P(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(!g(t))throw new Error(`agentx.json not found at ${t}`);let i=JSON.parse(u(t,"utf-8")),o=e(i),s=typeof o=="string"?{summary:o}:o,c=JSON.stringify(i,null,2)+`
2
2
  `,f=t+".tmp";a(f,c,"utf-8");try{JSON.parse(u(f,"utf-8"))}catch(d){throw new Error(`config did not round-trip cleanly: ${d.message}`)}let r;return n.skipBackup||(r=`${t}.bak.${Date.now()}`,y(t,r)),a(t,c,"utf-8"),n.skipReload||h().catch(()=>{}),{summary:s.summary,payload:s.payload,backupPath:r}}function S(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(g(t)&&!n.overwrite)throw new Error(`agentx.json already exists at ${t}. Pass overwrite=true to replace it.`);return a(t,JSON.stringify(e,null,2)+`
3
3
  `,"utf-8"),{file:t}}async function h(){try{let n=l().dashboard.daemonUrl?.replace(/\/+$/,"")||"http://127.0.0.1:18800";await fetch(`${n}/reload`,{method:"POST"}).catch(()=>null)}catch{}}export{P as a,S as b};
4
- //# sourceMappingURL=chunk-2ZNYIHRB.js.map
4
+ //# sourceMappingURL=chunk-ZXABOPXF.js.map
package/dist/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{b as o}from"./chunk-OSH2PEBH.js";import"./chunk-QIJLFPWE.js";var e=o(process.versions.node);e&&(console.error(e),process.exit(1));var{buildProgram:s}=await import("./program-7QFRDJUY.js"),{installCliSignalExit:r}=await import("./signal-exit-C5EUGHKI.js"),{applyConnectAttemptTimeout:i,configPathFromArgv:a,readConnectAttemptTimeout:n}=await import("./net-family-X2P3OVDP.js");r();i(n(process.cwd(),a(process.argv.slice(2))));var t=await s();process.argv.slice(2).length===0?t.outputHelp():t.parse();
2
+ import{b as o}from"./chunk-OSH2PEBH.js";import"./chunk-QIJLFPWE.js";var e=o(process.versions.node);e&&(console.error(e),process.exit(1));var{buildProgram:s}=await import("./program-OFMRVB7N.js"),{installCliSignalExit:r}=await import("./signal-exit-C5EUGHKI.js"),{applyConnectAttemptTimeout:i,configPathFromArgv:a,readConnectAttemptTimeout:n}=await import("./net-family-X2P3OVDP.js");r();i(n(process.cwd(),a(process.argv.slice(2))));var t=await s();process.argv.slice(2).length===0?t.outputHelp():t.parse();
3
3
  //# sourceMappingURL=cli.js.map
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e,f,g}from"./chunk-7OJUZ3L5.js";import"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{b as fetchAgents,d as fetchCrons,c as fetchProcesses,e as killProcess,a as resolveConn,f as sendTask,g as streamTask};
2
- //# sourceMappingURL=client-SJLHZDIC.js.map
1
+ import{a,b,c,d,e,f,g}from"./chunk-GP56ZRAF.js";import"./chunk-JE2EV6NS.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{b as fetchAgents,d as fetchCrons,c as fetchProcesses,e as killProcess,a as resolveConn,f as sendTask,g as streamTask};
2
+ //# sourceMappingURL=client-2TJ3TOCH.js.map
@@ -1,2 +1,2 @@
1
- import{$b as n,Ob as a,Pb as b,Qb as c,Rb as d,Sb as e,Tb as f,Ub as g,Vb as h,Wb as i,Xb as j,Yb as k,Zb as l,_b as m,ac as o,bc as p,cc as q,dc as r,ec as s,fc as t,gc as u,hc as v,ic as w,jc as x,kc as y,lc as z,mc as A,nc as B,oc as C,pc as D,qc as E,rc as F,tc as G}from"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";G();export{a as INTEGRATION_KINDS,B as WIKI_CONTRIBUTE_JOB,C as WIKI_CONTRIBUTE_MERGE_JOB,E as WIKI_SUMMARIZE_JOB,s as approvalsConfigSchema,g as callsSchema,e as cameraBotSchema,z as crossFieldProblems,v as daemonConfigSchema,c as emailAccountSchema,b as eventSubscriptionSchema,w as expandEnvVars,r as improveConfigSchema,f as isCronExpression,y as literalSecretProblems,x as loadDaemonConfig,d as mailSenderSchema,o as membersConfigSchema,j as mergePolicyConfigSchema,t as numbersConfigSchema,n as peopleConfigSchema,m as personSchema,q as qualityReportConfigSchema,p as requestStatusConfigSchema,l as requestsConfigSchema,h as reviewGateConfigSchema,i as trackersConfigSchema,A as validateWorkspaces,u as wallConfigSchema,k as watchersConfigSchema,D as withContributionJobs,F as withSummariesJob};
2
- //# sourceMappingURL=config-Q3ENZQYL.js.map
1
+ import{$b as f,Bc as G,Wb as a,Xb as b,Yb as c,Zb as d,_b as e,ac as g,bc as h,cc as i,dc as j,ec as k,fc as l,gc as m,hc as n,ic as o,jc as p,kc as q,lc as r,mc as s,nc as t,oc as u,pc as v,qc as w,rc as x,sc as y,tc as z,uc as A,vc as B,wc as C,xc as D,yc as E,zc as F}from"./chunk-JE2EV6NS.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";G();export{a as INTEGRATION_KINDS,B as WIKI_CONTRIBUTE_JOB,C as WIKI_CONTRIBUTE_MERGE_JOB,E as WIKI_SUMMARIZE_JOB,s as approvalsConfigSchema,g as callsSchema,e as cameraBotSchema,z as crossFieldProblems,v as daemonConfigSchema,c as emailAccountSchema,b as eventSubscriptionSchema,w as expandEnvVars,r as improveConfigSchema,f as isCronExpression,y as literalSecretProblems,x as loadDaemonConfig,d as mailSenderSchema,o as membersConfigSchema,j as mergePolicyConfigSchema,t as numbersConfigSchema,n as peopleConfigSchema,m as personSchema,q as qualityReportConfigSchema,p as requestStatusConfigSchema,l as requestsConfigSchema,h as reviewGateConfigSchema,i as trackersConfigSchema,A as validateWorkspaces,u as wallConfigSchema,k as watchersConfigSchema,D as withContributionJobs,F as withSummariesJob};
2
+ //# sourceMappingURL=config-JHSM6KFT.js.map
@@ -1,2 +1,2 @@
1
- import{a,b}from"./chunk-2ZNYIHRB.js";import"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{a as mutateAgentxConfig,b as writeAgentxConfig};
2
- //# sourceMappingURL=config-mutate-NNAUMQ2Y.js.map
1
+ import{a,b}from"./chunk-ZXABOPXF.js";import"./chunk-JE2EV6NS.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{a as mutateAgentxConfig,b as writeAgentxConfig};
2
+ //# sourceMappingURL=config-mutate-YERBKGAB.js.map
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e}from"./chunk-LDSBFDYB.js";import"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{b as applyConfigMutation,a as findConfigPath,d as getAtPath,c as setAtPath,e as unsetAtPath};
2
- //# sourceMappingURL=config-mutator-2F2BJNMA.js.map
1
+ import{a,b,c,d,e}from"./chunk-QAMVAZ67.js";import"./chunk-JE2EV6NS.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{b as applyConfigMutation,a as findConfigPath,d as getAtPath,c as setAtPath,e as unsetAtPath};
2
+ //# sourceMappingURL=config-mutator-WNNU4EDV.js.map
@@ -1,4 +1,4 @@
1
- import{a as ee}from"./chunk-JTS563OC.js";import"./chunk-TO6T6AQY.js";import{f as Q,k as V}from"./chunk-IH65GDJR.js";import"./chunk-5SQRJUAK.js";import"./chunk-JTFCU5LH.js";import"./chunk-LUOW2YHY.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import{b as O}from"./chunk-5ONH4ITT.js";import"./chunk-JRAG37V5.js";import"./chunk-ILEC3IAV.js";import"./chunk-BERWTVG2.js";import"./chunk-A7JSRDJL.js";import"./chunk-T7SD5EVH.js";import"./chunk-WPNRDEHW.js";import"./chunk-OWNQ2FD4.js";import{b as N,c as H}from"./chunk-AHWWJ7AF.js";import{b as X}from"./chunk-KEXBEUSU.js";import"./chunk-BLKXK27S.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-QUFIUXMQ.js";import"./chunk-DCIYOPJF.js";import"./chunk-7I7IEX4S.js";import"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";import{createHash as le}from"crypto";import{existsSync as z,mkdirSync as ne,readdirSync as re,readFileSync as ge,renameSync as se,writeFileSync as pe}from"fs";import{resolve as w}from"path";var _={maxPatches:30,maxCostUsd:.5,maxItems:60},he=12,fe=2e3,me=1500,M=8,U=300,be=12,B="## Checked facts";function S(n){return w(n,"_contributions")}function E(n,r){if(!z(n))return r;try{return JSON.parse(ge(n,"utf-8"))}catch(t){throw new Error(`${n} is not valid JSON: ${t.message}`)}}function L(n,r){ne(w(n,".."),{recursive:!0});let t=`${n}.${process.pid}.tmp`;pe(t,`${JSON.stringify(r,null,2)}
1
+ import{a as ee}from"./chunk-B5JK4MQX.js";import"./chunk-EVFQINOQ.js";import{f as Q,k as V}from"./chunk-IH65GDJR.js";import"./chunk-YG5GPPGI.js";import"./chunk-JTFCU5LH.js";import"./chunk-LUOW2YHY.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import{b as O}from"./chunk-5ONH4ITT.js";import"./chunk-JRAG37V5.js";import"./chunk-ILEC3IAV.js";import"./chunk-BERWTVG2.js";import"./chunk-A7JSRDJL.js";import"./chunk-AKPLNPUY.js";import"./chunk-WPNRDEHW.js";import"./chunk-OWNQ2FD4.js";import{b as N,c as H}from"./chunk-AHWWJ7AF.js";import{b as X}from"./chunk-KEXBEUSU.js";import"./chunk-QW5WOBSU.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-QUFIUXMQ.js";import"./chunk-DCIYOPJF.js";import"./chunk-7I7IEX4S.js";import"./chunk-JE2EV6NS.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";import{createHash as le}from"crypto";import{existsSync as z,mkdirSync as ne,readdirSync as re,readFileSync as ge,renameSync as se,writeFileSync as pe}from"fs";import{resolve as w}from"path";var _={maxPatches:30,maxCostUsd:.5,maxItems:60},he=12,fe=2e3,me=1500,M=8,U=300,be=12,B="## Checked facts";function S(n){return w(n,"_contributions")}function E(n,r){if(!z(n))return r;try{return JSON.parse(ge(n,"utf-8"))}catch(t){throw new Error(`${n} is not valid JSON: ${t.message}`)}}function L(n,r){ne(w(n,".."),{recursive:!0});let t=`${n}.${process.pid}.tmp`;pe(t,`${JSON.stringify(r,null,2)}
2
2
  `),se(t,n)}function ie(n){return{agents:E(w(S(n),"state.json"),{agents:{}}).agents??{}}}function ye(n){let r=w(S(n),"pending");return z(r)?re(r).filter(t=>t.endsWith(".json")).sort().map(t=>E(w(r,t),null)).filter(t=>!!t):[]}function G(n){return w(S(n),"held.json")}function K(n,r={}){let t=E(G(n),[]);return r.all?t:t.filter(a=>a.status==="held")}function _e(n){let r=w(S(n),"reports");if(!z(r))return null;let t=re(r).filter(a=>a.endsWith(".json")).sort().pop();return t?E(w(r,t),null):null}function ke(n,r,t,a={}){let o=ie(r).agents[t],c=a.now??Date.now(),e=a.since??o?.lastRunAt??new Date(c-864e5).toISOString(),d=e.slice(0,10),u=new Set(o?.processed??[]),s=[];for(let g of n.getAgentEntries(t))g.date<d||u.has(g.id)||s.push({id:g.id,at:g.date,kind:"chat",title:[g.source,g.sourceContext].filter(Boolean).join(" \xB7 "),text:g.content});if(a.db){let g=Date.parse(e);for(let l of V(a.db,{agentId:t,since:Number.isFinite(g)?g:void 0,limit:500})){if(l.status==="in-flight"||u.has(l.taskId))continue;let k=(Q(a.db,l.taskId)?.steps??[]).filter(b=>b.name==="tool_use"||b.action).slice(0,be).map(b=>`- ${b.action??b.name}${b.inputSummary?` ${x(b.inputSummary,160)}`:""}${b.outputSummary?` \u2192 ${x(b.outputSummary,240)}`:""}${b.error?` \u2717 ${x(b.error,120)}`:""}`),y=[`Request: ${x(l.originalMessage??l.messagePreview??"",600)}`,k.length?`Tool calls:
3
3
  ${k.join(`
4
4
  `)}`:"",l.finalResponse?`Reply: ${x(l.finalResponse,800)}`:""].filter(Boolean).join(`
@@ -54,4 +54,4 @@ _Sources: ${t.sources.join("; ")}._`,a);return n.writeArticle(r,{title:t.title,.
54
54
  `).replace(/\n{3,}/g,`
55
55
 
56
56
  `).trim(),superseded:d}}function Ce(n){let r=n.previous?` (previously: ${n.previous})`:"";return`- **${n.attribute}:** ${n.value} \u2014 ${n.source}; checked ${n.checkedAt.slice(0,10)} by ${n.by}${r}`}function Re(n){let r=n.match(/^- \*\*.+?:\*\* (.*?) — .*?; checked (\S+) by \S+(?: \(previously: (.*)\))?$/);return r?{value:r[1],checkedAt:r[2],...r[3]?{previous:r[3]}:{}}:void 0}function J(n,r){return`contribution:${n}@${r.slice(0,10)}`}var Te={person:"people",project:"projects",place:"places",concept:"concepts",event:"events",decision:"decisions",pattern:"patterns"};function de(n,r,t){let a=r.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,60)||"page",o=t?Te[t]:"contributions",c=`${o}/${a}.md`;for(let e=2;n.readArticle(c);e++)c=`${o}/${a}-${e}.md`;return c}export{_ as DEFAULT_CONTRIBUTION_LIMITS,B as FACTS_HEADING,ue as applyFactLines,De as approveHeld,xe as buildContributionPrompt,S as contributionsDir,_e as latestReport,K as listHeld,ye as listPendingBatches,Be as mergeContributions,W as pageKey,Ae as parseContributionPatches,ke as pendingWork,Se as possibleDuplicate,Fe as rejectHeld,ce as replaceOnce,Me as runContribution};
57
- //# sourceMappingURL=contributions-SOUGZCAH.js.map
57
+ //# sourceMappingURL=contributions-HAWUHQWM.js.map
@@ -1,2 +1,2 @@
1
- import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j}from"./chunk-YTWRIIAT.js";import"./chunk-WMZ4TGMR.js";import"./chunk-2YDG5CSS.js";import"./chunk-U5DSMDCJ.js";import"./chunk-IMLAPB7G.js";import"./chunk-QPABR72X.js";import"./chunk-KP7KDLZ2.js";import"./chunk-OQQTV3OF.js";import"./chunk-4NZ4T3TQ.js";import"./chunk-LY4G7PCW.js";import"./chunk-7IW25T4K.js";import"./chunk-Q3A5P373.js";import"./chunk-JLBRNYKY.js";import"./chunk-BYEL7KKR.js";import"./chunk-QUFIUXMQ.js";import"./chunk-OSH2PEBH.js";import"./chunk-7I7IEX4S.js";import"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{j as daemonVoiceCheck,b as doctor,i as mcpHeaderEnvChecks,g as meshPeerTokenChecks,h as meshTokenChecksFromConfig,a as runDoctorChecks,e as runMirrorChecks,d as runNativeChecks,c as runNotificationChecks,f as runReminderChecks};
2
- //# sourceMappingURL=doctor-H6I433KY.js.map
1
+ import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j}from"./chunk-VFG7GZC6.js";import"./chunk-WMZ4TGMR.js";import"./chunk-2YDG5CSS.js";import"./chunk-YB2QYUXG.js";import"./chunk-IMLAPB7G.js";import"./chunk-QPABR72X.js";import"./chunk-KP7KDLZ2.js";import"./chunk-BXK5S2KK.js";import"./chunk-4NZ4T3TQ.js";import"./chunk-LY4G7PCW.js";import"./chunk-7IW25T4K.js";import"./chunk-Q3A5P373.js";import"./chunk-JLBRNYKY.js";import"./chunk-BYEL7KKR.js";import"./chunk-QUFIUXMQ.js";import"./chunk-OSH2PEBH.js";import"./chunk-7I7IEX4S.js";import"./chunk-JE2EV6NS.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";export{j as daemonVoiceCheck,b as doctor,i as mcpHeaderEnvChecks,g as meshPeerTokenChecks,h as meshTokenChecksFromConfig,a as runDoctorChecks,e as runMirrorChecks,d as runNativeChecks,c as runNotificationChecks,f as runReminderChecks};
2
+ //# sourceMappingURL=doctor-GOMB6LDS.js.map
@@ -1,7 +1,7 @@
1
- import{b as h}from"./chunk-MOEXP6U3.js";import"./chunk-RKPAVWXF.js";import{b as I}from"./chunk-IFUAP7UD.js";import"./chunk-KP7KDLZ2.js";import"./chunk-F32VADB7.js";import"./chunk-AU7SN4G3.js";import"./chunk-LDSBFDYB.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";var p=t=>typeof t=="string"?t.trim():"";function $(t){return[`Run ${t.runId} "${t.title}" [${t.status}] on step ${t.step}: waiting on ${t.waitingOn}.`,t.tags?.length?`Tags: ${t.tags.join(", ")}`:"",...(t.steps??[]).slice(-8).map(s=>`- ${String(s.at).slice(0,16).replace("T"," ")} ${s.step} ${s.status}${s.note?`: ${s.note}`:""}`)].filter(Boolean).join(`
1
+ import{d as h}from"./chunk-GMQLDXEM.js";import{b as I}from"./chunk-IFUAP7UD.js";import"./chunk-KP7KDLZ2.js";import"./chunk-D3HNIOZ7.js";import"./chunk-OQEP2Q32.js";import"./chunk-QAMVAZ67.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-JE2EV6NS.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";var p=t=>typeof t=="string"?t.trim():"";function $(t){return[`Run ${t.runId} "${t.title}" [${t.status}] on step ${t.step}: waiting on ${t.waitingOn}.`,t.tags?.length?`Tags: ${t.tags.join(", ")}`:"",...(t.steps??[]).slice(-8).map(s=>`- ${String(s.at).slice(0,16).replace("T"," ")} ${s.step} ${s.status}${s.note?`: ${s.note}`:""}`)].filter(Boolean).join(`
2
2
  `)}async function T(t,c){let s=c.fetch??fetch,m=c.daemonUrl.replace(/\/$/,""),r=(p(t.action)||"list").toLowerCase(),f=c.env??process.env,w=async i=>{let l=await s(`${m}${i}`,{signal:AbortSignal.timeout(1e4)}),n=await l.json().catch(()=>({}));return{ok:l.ok,status:l.status,data:n}};try{if(r==="list"){let e=await w("/follow-up");if(!e.ok)return`Error: ${e.data?.error||`HTTP ${e.status}`}`;let o=e.data.groups??[];return o.length?o.map(d=>[`${d.tag}:`,...d.rows.map(a=>`- ${a.runId} "${a.title}" on ${a.step}: waiting on ${a.waitingOn} (since ${String(a.since).slice(0,16).replace("T"," ")} UTC)`)].join(`
3
3
  `)).join(`
4
4
  `):"No follow-up workflows are running."}if(r==="match"){let e=p(t.request)||p(t.title);if(!e)return"Error: match needs `request`: the owner's request in their words.";let o=h(t,f),d=await w(`/follow-up/match?q=${encodeURIComponent(e)}${o?`&agentId=${encodeURIComponent(o.agentId)}`:""}`);if(!d.ok)return`Error: ${d.data?.error||`HTTP ${d.status}`}`;let a=d.data.matches??[];return a.length?["Saved workflows, best fit first (confidence 0-1):",...a.map(u=>`- ${u.workflowId} "${u.title}" (${u.confidence}${u.autoStart?", starts without asking":""}): ${u.steps.map(k=>k.id).join(" \u2192 ")}`),'Start one with {action:"start", workflowId:"<id>", title:"\u2026", tags:["client:<name>"]}. Run its steps through the workflow, not by hand.'].join(`
5
5
  `):"No saved workflow fits. If the request has several steps, build one: start with title and steps."}if(r==="status"){let e=p(t.runId);if(!e)return"Error: status needs runId.";let o=await w(`/follow-up/${encodeURIComponent(e)}`);return o.ok?$(o.data.run):`Error: ${o.data?.error||`HTTP ${o.status}`}`}let i=h(t,f);if(!i)return"Error: couldn't tell which agent you are. Pass callerAgentId.";let l=await s(`${m}/follow-up`,{method:"POST",headers:{"Content-Type":"application/json",...I(f)},body:JSON.stringify({action:r,agentId:i.agentId,workflowId:t.workflowId,title:t.title,description:t.description,tags:t.tags,inputs:t.inputs,steps:t.steps,edges:t.edges,approval:t.approval,autoStart:t.autoStart,requestId:t.requestId,runId:t.runId,step:t.step,evidence:t.evidence,note:t.note,reason:t.reason,fromRun:t.fromRun,status:t.status}),signal:AbortSignal.timeout(2e4)}),n=await l.json().catch(()=>({}));if(!l.ok)return`Error: ${n?.error||`HTTP ${l.status}`}`;if(r==="start"){let e=n.run;return[`Started run ${e.runId} "${e.title}"${n.built?" (built from the steps you gave; propose it with fromRun to keep it)":""}.`,n.awaitingApproval?"It waits for the owner's approval before the first step.":`It is on step ${e.step}: ${e.waitingOn}.`,"AgentX follows it from here: it starts each step, reminds whoever is slow, and tells the owner when it ends. Do not run its steps by hand.",...n.warning?[`Note: ${n.warning}`]:[]].join(" ")}return r==="plan"?[`Plan recorded on run ${n.run?.runId??t.runId}:`,...(n.plan??[]).map(e=>`- ${e.id} ${e.title}`),'Report each step with {action:"step", runId, step:"<id>", status:"started"|"done"|"failed"}.'].join(`
6
6
  `):r==="step"?`Step recorded. ${n.run?$(n.run):""}`.trim():r==="done"?`Step recorded as done. ${n.run?$(n.run):""}`.trim():r==="blocked"?"The step is marked blocked and the owner is told. Nothing more happens on it until it is sorted.":`Saved ${n.workflowId} switched off, and asked the owner (card ${n.cardId}) whether to keep it as a reusable workflow.`}catch(i){return`Error: couldn't reach the daemon (${i?.message??i}).`}}export{T as runWorkflowTool};
7
- //# sourceMappingURL=follow-up-tool-4FX455DL.js.map
7
+ //# sourceMappingURL=follow-up-tool-5YFJS2JZ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/workflows/follow-up-tool.ts"],"sourcesContent":["import { resolveScheduleCaller } from \"@/crons/schedule-tool\"\nimport { callerHeaders } from \"@/calls/service\"\n\n// --- Agent-facing `agentx_workflow` tool (#788) ---\n//\n// A request with several steps is run as a workflow, not by hand:\n// match saved workflows that fit the request in front of you\n// start start one (workflowId), or build one from the owner's words\n// (title + steps) and run it; tags say what it concerns\n// status one run: the step it is on and what it waits on\n// list every follow-up still going, grouped by tag\n// done the step you own is finished (evidence)\n// blocked your step cannot go on without the owner (reason)\n// propose ask the owner to keep a workflow as a reusable template\n// plan write or change the plan of the run your task is wrapped in\n// step report a step of that plan (started, done, failed)\n// It talks to the daemon's /follow-up endpoints.\n\nexport interface WorkflowToolDeps {\n daemonUrl: string\n fetch?: typeof fetch\n env?: NodeJS.ProcessEnv\n}\n\nconst str = (v: unknown) => (typeof v === \"string\" ? v.trim() : \"\")\n\nfunction describe(run: any): string {\n const lines = [\n `Run ${run.runId} \"${run.title}\" [${run.status}] on step ${run.step}: waiting on ${run.waitingOn}.`,\n run.tags?.length ? `Tags: ${run.tags.join(\", \")}` : \"\",\n ...(run.steps ?? []).slice(-8).map((s: any) => `- ${String(s.at).slice(0, 16).replace(\"T\", \" \")} ${s.step} ${s.status}${s.note ? `: ${s.note}` : \"\"}`),\n ]\n return lines.filter(Boolean).join(\"\\n\")\n}\n\n/** Returns the text the agent sees. Every refusal is text, never a throw. */\nexport async function runWorkflowTool(args: Record<string, unknown>, deps: WorkflowToolDeps): Promise<string> {\n const doFetch = deps.fetch ?? fetch\n const base = deps.daemonUrl.replace(/\\/$/, \"\")\n const action = (str(args.action) || \"list\").toLowerCase()\n const env = deps.env ?? process.env\n const read = async (path: string) => {\n const res = await doFetch(`${base}${path}`, { signal: AbortSignal.timeout(10_000) })\n const data = await res.json().catch(() => ({})) as any\n return { ok: res.ok, status: res.status, data }\n }\n\n try {\n if (action === \"list\") {\n const r = await read(\"/follow-up\")\n if (!r.ok) return `Error: ${r.data?.error || `HTTP ${r.status}`}`\n const groups = r.data.groups ?? []\n if (!groups.length) return \"No follow-up workflows are running.\"\n return groups.map((g: any) => [`${g.tag}:`, ...g.rows.map((row: any) => `- ${row.runId} \"${row.title}\" on ${row.step}: waiting on ${row.waitingOn} (since ${String(row.since).slice(0, 16).replace(\"T\", \" \")} UTC)`)].join(\"\\n\")).join(\"\\n\")\n }\n if (action === \"match\") {\n const q = str(args.request) || str(args.title)\n if (!q) return \"Error: match needs `request`: the owner's request in their words.\"\n const caller = resolveScheduleCaller(args, env)\n const r = await read(`/follow-up/match?q=${encodeURIComponent(q)}${caller ? `&agentId=${encodeURIComponent(caller.agentId)}` : \"\"}`)\n if (!r.ok) return `Error: ${r.data?.error || `HTTP ${r.status}`}`\n const matches = r.data.matches ?? []\n if (!matches.length) return \"No saved workflow fits. If the request has several steps, build one: start with title and steps.\"\n return [\n \"Saved workflows, best fit first (confidence 0-1):\",\n ...matches.map((x: any) => `- ${x.workflowId} \"${x.title}\" (${x.confidence}${x.autoStart ? \", starts without asking\" : \"\"}): ${x.steps.map((s: any) => s.id).join(\" → \")}`),\n `Start one with {action:\"start\", workflowId:\"<id>\", title:\"…\", tags:[\"client:<name>\"]}. Run its steps through the workflow, not by hand.`,\n ].join(\"\\n\")\n }\n if (action === \"status\") {\n const runId = str(args.runId)\n if (!runId) return \"Error: status needs runId.\"\n const r = await read(`/follow-up/${encodeURIComponent(runId)}`)\n if (!r.ok) return `Error: ${r.data?.error || `HTTP ${r.status}`}`\n return describe(r.data.run)\n }\n\n const caller = resolveScheduleCaller(args, env)\n if (!caller) return \"Error: couldn't tell which agent you are. Pass callerAgentId.\"\n const res = await doFetch(`${base}/follow-up`, {\n method: \"POST\",\n // The headers name this run: the daemon refuses a write that does\n // not come from a running turn of the agent.\n headers: { \"Content-Type\": \"application/json\", ...callerHeaders(env) },\n body: JSON.stringify({\n action, agentId: caller.agentId,\n workflowId: args.workflowId, title: args.title, description: args.description, tags: args.tags, inputs: args.inputs,\n steps: args.steps, edges: args.edges, approval: args.approval, autoStart: args.autoStart, requestId: args.requestId,\n runId: args.runId, step: args.step, evidence: args.evidence, note: args.note, reason: args.reason, fromRun: args.fromRun, status: args.status,\n }),\n signal: AbortSignal.timeout(20_000),\n })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n if (action === \"start\") {\n const run = data.run\n return [\n `Started run ${run.runId} \"${run.title}\"${data.built ? \" (built from the steps you gave; propose it with fromRun to keep it)\" : \"\"}.`,\n data.awaitingApproval ? \"It waits for the owner's approval before the first step.\" : `It is on step ${run.step}: ${run.waitingOn}.`,\n \"AgentX follows it from here: it starts each step, reminds whoever is slow, and tells the owner when it ends. Do not run its steps by hand.\",\n ...(data.warning ? [`Note: ${data.warning}`] : []),\n ].join(\" \")\n }\n if (action === \"plan\") {\n return [\n `Plan recorded on run ${data.run?.runId ?? args.runId}:`,\n ...(data.plan ?? []).map((s: any) => `- ${s.id} ${s.title}`),\n `Report each step with {action:\"step\", runId, step:\"<id>\", status:\"started\"|\"done\"|\"failed\"}.`,\n ].join(\"\\n\")\n }\n if (action === \"step\") return `Step recorded. ${data.run ? describe(data.run) : \"\"}`.trim()\n if (action === \"done\") return `Step recorded as done. ${data.run ? describe(data.run) : \"\"}`.trim()\n if (action === \"blocked\") return \"The step is marked blocked and the owner is told. Nothing more happens on it until it is sorted.\"\n return `Saved ${data.workflowId} switched off, and asked the owner (card ${data.cardId}) whether to keep it as a reusable workflow.`\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n}\n"],"mappings":"wdAwBA,IAAMA,EAAOC,GAAgB,OAAOA,GAAM,SAAWA,EAAE,KAAK,EAAI,GAEhE,SAASC,EAASC,EAAkB,CAMlC,MALc,CACZ,OAAOA,EAAI,UAAUA,EAAI,WAAWA,EAAI,mBAAmBA,EAAI,oBAAoBA,EAAI,aACvFA,EAAI,MAAM,OAAS,SAASA,EAAI,KAAK,KAAK,IAAI,IAAM,GACpD,IAAIA,EAAI,OAAS,CAAC,GAAG,MAAM,EAAE,EAAE,IAAK,GAAW,KAAK,OAAO,EAAE,EAAE,EAAE,MAAM,EAAG,EAAE,EAAE,QAAQ,IAAK,GAAG,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAO,KAAK,EAAE,OAAS,IAAI,CACvJ,EACa,OAAO,OAAO,EAAE,KAAK;AAAA,CAAI,CACxC,CAGA,eAAsBC,EAAgBC,EAA+BC,EAAyC,CAC5G,IAAMC,EAAUD,EAAK,OAAS,MACxBE,EAAOF,EAAK,UAAU,QAAQ,MAAO,EAAE,EACvCG,GAAUT,EAAIK,EAAK,MAAM,GAAK,QAAQ,YAAY,EAClDK,EAAMJ,EAAK,KAAO,QAAQ,IAC1BK,EAAO,MAAOC,GAAiB,CACnC,IAAMC,EAAM,MAAMN,EAAQ,GAAGC,IAAOI,IAAQ,CAAE,OAAQ,YAAY,QAAQ,GAAM,CAAE,CAAC,EAC7EE,EAAO,MAAMD,EAAI,KAAK,EAAE,MAAM,KAAO,CAAC,EAAE,EAC9C,MAAO,CAAE,GAAIA,EAAI,GAAI,OAAQA,EAAI,OAAQ,KAAAC,CAAK,CA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IAAW,OACN,CACL,wBAAwBK,EAAK,KAAK,OAAST,EAAK,SAChD,IAAIS,EAAK,MAAQ,CAAC,GAAG,IAAKU,GAAW,KAAKA,EAAE,MAAMA,EAAE,OAAO,EAC3D,8FACF,EAAE,KAAK;AAAA,CAAI,EAETf,IAAW,OAAe,kBAAkBK,EAAK,IAAMZ,EAASY,EAAK,GAAG,EAAI,KAAK,KAAK,EACtFL,IAAW,OAAe,0BAA0BK,EAAK,IAAMZ,EAASY,EAAK,GAAG,EAAI,KAAK,KAAK,EAC9FL,IAAW,UAAkB,mGAC1B,SAASK,EAAK,sDAAsDA,EAAK,oDAClF,OAASa,EAAP,CACA,MAAO,qCAAqCA,GAAG,SAAWA,KAC5D,CACF","names":["str","v","describe","run","runWorkflowTool","args","deps","doFetch","base","action","env","read","path","res","data","r","groups","g","row","q","caller","resolveScheduleCaller","matches","x","s","runId","callerHeaders","e"]}
1
+ {"version":3,"sources":["../src/workflows/follow-up-tool.ts"],"sourcesContent":["import { resolveScheduleCaller } from \"@/crons/schedule-tool\"\nimport { callerHeaders } from \"@/calls/service\"\n\n// --- Agent-facing `agentx_workflow` tool (#788) ---\n//\n// A request with several steps is run as a workflow, not by hand:\n// match saved workflows that fit the request in front of you\n// start start one (workflowId), or build one from the owner's words\n// (title + steps) and run it; tags say what it concerns\n// status one run: the step it is on and what it waits on\n// list every follow-up still going, grouped by tag\n// done the step you own is finished (evidence)\n// blocked your step cannot go on without the owner (reason)\n// propose ask the owner to keep a workflow as a reusable template\n// plan write or change the plan of the run your task is wrapped in\n// step report a step of that plan (started, done, failed)\n// It talks to the daemon's /follow-up endpoints.\n\nexport interface WorkflowToolDeps {\n daemonUrl: string\n fetch?: typeof fetch\n env?: NodeJS.ProcessEnv\n}\n\nconst str = (v: unknown) => (typeof v === \"string\" ? v.trim() : \"\")\n\nfunction describe(run: any): string {\n const lines = [\n `Run ${run.runId} \"${run.title}\" [${run.status}] on step ${run.step}: waiting on ${run.waitingOn}.`,\n run.tags?.length ? `Tags: ${run.tags.join(\", \")}` : \"\",\n ...(run.steps ?? []).slice(-8).map((s: any) => `- ${String(s.at).slice(0, 16).replace(\"T\", \" \")} ${s.step} ${s.status}${s.note ? `: ${s.note}` : \"\"}`),\n ]\n return lines.filter(Boolean).join(\"\\n\")\n}\n\n/** Returns the text the agent sees. Every refusal is text, never a throw. */\nexport async function runWorkflowTool(args: Record<string, unknown>, deps: WorkflowToolDeps): Promise<string> {\n const doFetch = deps.fetch ?? fetch\n const base = deps.daemonUrl.replace(/\\/$/, \"\")\n const action = (str(args.action) || \"list\").toLowerCase()\n const env = deps.env ?? process.env\n const read = async (path: string) => {\n const res = await doFetch(`${base}${path}`, { signal: AbortSignal.timeout(10_000) })\n const data = await res.json().catch(() => ({})) as any\n return { ok: res.ok, status: res.status, data }\n }\n\n try {\n if (action === \"list\") {\n const r = await read(\"/follow-up\")\n if (!r.ok) return `Error: ${r.data?.error || `HTTP ${r.status}`}`\n const groups = r.data.groups ?? []\n if (!groups.length) return \"No follow-up workflows are running.\"\n return groups.map((g: any) => [`${g.tag}:`, ...g.rows.map((row: any) => `- ${row.runId} \"${row.title}\" on ${row.step}: waiting on ${row.waitingOn} (since ${String(row.since).slice(0, 16).replace(\"T\", \" \")} UTC)`)].join(\"\\n\")).join(\"\\n\")\n }\n if (action === \"match\") {\n const q = str(args.request) || str(args.title)\n if (!q) return \"Error: match needs `request`: the owner's request in their words.\"\n const caller = resolveScheduleCaller(args, env)\n const r = await read(`/follow-up/match?q=${encodeURIComponent(q)}${caller ? `&agentId=${encodeURIComponent(caller.agentId)}` : \"\"}`)\n if (!r.ok) return `Error: ${r.data?.error || `HTTP ${r.status}`}`\n const matches = r.data.matches ?? []\n if (!matches.length) return \"No saved workflow fits. If the request has several steps, build one: start with title and steps.\"\n return [\n \"Saved workflows, best fit first (confidence 0-1):\",\n ...matches.map((x: any) => `- ${x.workflowId} \"${x.title}\" (${x.confidence}${x.autoStart ? \", starts without asking\" : \"\"}): ${x.steps.map((s: any) => s.id).join(\" → \")}`),\n `Start one with {action:\"start\", workflowId:\"<id>\", title:\"…\", tags:[\"client:<name>\"]}. Run its steps through the workflow, not by hand.`,\n ].join(\"\\n\")\n }\n if (action === \"status\") {\n const runId = str(args.runId)\n if (!runId) return \"Error: status needs runId.\"\n const r = await read(`/follow-up/${encodeURIComponent(runId)}`)\n if (!r.ok) return `Error: ${r.data?.error || `HTTP ${r.status}`}`\n return describe(r.data.run)\n }\n\n const caller = resolveScheduleCaller(args, env)\n if (!caller) return \"Error: couldn't tell which agent you are. Pass callerAgentId.\"\n const res = await doFetch(`${base}/follow-up`, {\n method: \"POST\",\n // The headers name this run: the daemon refuses a write that does\n // not come from a running turn of the agent.\n headers: { \"Content-Type\": \"application/json\", ...callerHeaders(env) },\n body: JSON.stringify({\n action, agentId: caller.agentId,\n workflowId: args.workflowId, title: args.title, description: args.description, tags: args.tags, inputs: args.inputs,\n steps: args.steps, edges: args.edges, approval: args.approval, autoStart: args.autoStart, requestId: args.requestId,\n runId: args.runId, step: args.step, evidence: args.evidence, note: args.note, reason: args.reason, fromRun: args.fromRun, status: args.status,\n }),\n signal: AbortSignal.timeout(20_000),\n })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n if (action === \"start\") {\n const run = data.run\n return [\n `Started run ${run.runId} \"${run.title}\"${data.built ? \" (built from the steps you gave; propose it with fromRun to keep it)\" : \"\"}.`,\n data.awaitingApproval ? \"It waits for the owner's approval before the first step.\" : `It is on step ${run.step}: ${run.waitingOn}.`,\n \"AgentX follows it from here: it starts each step, reminds whoever is slow, and tells the owner when it ends. Do not run its steps by hand.\",\n ...(data.warning ? [`Note: ${data.warning}`] : []),\n ].join(\" \")\n }\n if (action === \"plan\") {\n return [\n `Plan recorded on run ${data.run?.runId ?? args.runId}:`,\n ...(data.plan ?? []).map((s: any) => `- ${s.id} ${s.title}`),\n `Report each step with {action:\"step\", runId, step:\"<id>\", status:\"started\"|\"done\"|\"failed\"}.`,\n ].join(\"\\n\")\n }\n if (action === \"step\") return `Step recorded. ${data.run ? describe(data.run) : \"\"}`.trim()\n if (action === \"done\") return `Step recorded as done. ${data.run ? describe(data.run) : \"\"}`.trim()\n if (action === \"blocked\") return \"The step is marked blocked and the owner is told. Nothing more happens on it until it is sorted.\"\n return `Saved ${data.workflowId} switched off, and asked the owner (card ${data.cardId}) whether to keep it as a reusable workflow.`\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n}\n"],"mappings":"4bAwBA,IAAMA,EAAOC,GAAgB,OAAOA,GAAM,SAAWA,EAAE,KAAK,EAAI,GAEhE,SAASC,EAASC,EAAkB,CAMlC,MALc,CACZ,OAAOA,EAAI,UAAUA,EAAI,WAAWA,EAAI,mBAAmBA,EAAI,oBAAoBA,EAAI,aACvFA,EAAI,MAAM,OAAS,SAASA,EAAI,KAAK,KAAK,IAAI,IAAM,GACpD,IAAIA,EAAI,OAAS,CAAC,GAAG,MAAM,EAAE,EAAE,IAAK,GAAW,KAAK,OAAO,EAAE,EAAE,EAAE,MAAM,EAAG,EAAE,EAAE,QAAQ,IAAK,GAAG,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAO,KAAK,EAAE,OAAS,IAAI,CACvJ,EACa,OAAO,OAAO,EAAE,KAAK;AAAA,CAAI,CACxC,CAGA,eAAsBC,EAAgBC,EAA+BC,EAAyC,CAC5G,IAAMC,EAAUD,EAAK,OAAS,MACxBE,EAAOF,EAAK,UAAU,QAAQ,MAAO,EAAE,EACvCG,GAAUT,EAAIK,EAAK,MAAM,GAAK,QAAQ,YAAY,EAClDK,EAAMJ,EAAK,KAAO,QAAQ,IAC1BK,EAAO,MAAOC,GAAiB,CACnC,IAAMC,EAAM,MAAMN,EAAQ,GAAGC,IAAOI,IAAQ,CAAE,OAAQ,YAAY,QAAQ,GAAM,CAAE,CAAC,EAC7EE,EAAO,MAAMD,EAAI,KAAK,EAAE,MAAM,KAAO,CAAC,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QAAU,CAAC,SAASA,EAAK,SAAS,EAAI,CAAC,CAClD,EAAE,KAAK,GAAG,EAEZ,OAAIL,IAAW,OACN,CACL,wBAAwBK,EAAK,KAAK,OAAST,EAAK,SAChD,IAAIS,EAAK,MAAQ,CAAC,GAAG,IAAKU,GAAW,KAAKA,EAAE,MAAMA,EAAE,OAAO,EAC3D,8FACF,EAAE,KAAK;AAAA,CAAI,EAETf,IAAW,OAAe,kBAAkBK,EAAK,IAAMZ,EAASY,EAAK,GAAG,EAAI,KAAK,KAAK,EACtFL,IAAW,OAAe,0BAA0BK,EAAK,IAAMZ,EAASY,EAAK,GAAG,EAAI,KAAK,KAAK,EAC9FL,IAAW,UAAkB,mGAC1B,SAASK,EAAK,sDAAsDA,EAAK,oDAClF,OAASa,EAAP,CACA,MAAO,qCAAqCA,GAAG,SAAWA,KAC5D,CACF","names":["str","v","describe","run","runWorkflowTool","args","deps","doFetch","base","action","env","read","path","res","data","r","groups","g","row","q","caller","resolveScheduleCaller","matches","x","s","runId","callerHeaders","e"]}
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u}from"./chunk-6UTOBSEA.js";import"./chunk-OQQTV3OF.js";import"./chunk-4NZ4T3TQ.js";import"./chunk-7I7IEX4S.js";import"./chunk-VQRY4IDI.js";import"./chunk-QIJLFPWE.js";export{c as DEFAULT_GRANT_DAYS,a as GUEST_SCOPE_PREFIX,b as JOIN_CARD_BY,h as JOIN_FAILED,d as MAX_GRANT_DAYS,j as NO_GRANT,l as PAUSED,k as WAITING_HOST,s as endGrant,o as grantBrief,u as grantForGuest,e as grantIdOf,n as guestAccess,p as guestTask,g as inviteGuest,i as joinGuest,f as newGrantId,q as pauseGrant,r as resumeGrant,m as settleGrant,t as updateGrant};
2
- //# sourceMappingURL=grants-U2734ZHZ.js.map
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u}from"./chunk-SYIDD7CI.js";import"./chunk-BXK5S2KK.js";import"./chunk-4NZ4T3TQ.js";import"./chunk-7I7IEX4S.js";import"./chunk-VQRY4IDI.js";import"./chunk-QIJLFPWE.js";export{c as DEFAULT_GRANT_DAYS,a as GUEST_SCOPE_PREFIX,b as JOIN_CARD_BY,h as JOIN_FAILED,d as MAX_GRANT_DAYS,j as NO_GRANT,l as PAUSED,k as WAITING_HOST,s as endGrant,o as grantBrief,u as grantForGuest,e as grantIdOf,n as guestAccess,p as guestTask,g as inviteGuest,i as joinGuest,f as newGrantId,q as pauseGrant,r as resumeGrant,m as settleGrant,t as updateGrant};
2
+ //# sourceMappingURL=grants-ZA35QVTX.js.map
@@ -1,2 +1,2 @@
1
- import{a,b}from"./chunk-TFHJT2AZ.js";import"./chunk-JMWPBZLU.js";import"./chunk-T7SD5EVH.js";import"./chunk-WPNRDEHW.js";import"./chunk-OWNQ2FD4.js";import"./chunk-AHWWJ7AF.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-BLKXK27S.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-DCIYOPJF.js";import"./chunk-7I7IEX4S.js";import"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{b as WikiHub,a as existingWikiDir};
2
- //# sourceMappingURL=hub-XFZFHLJK.js.map
1
+ import{a,b}from"./chunk-2REJBHT5.js";import"./chunk-IATCZJP7.js";import"./chunk-AKPLNPUY.js";import"./chunk-WPNRDEHW.js";import"./chunk-OWNQ2FD4.js";import"./chunk-AHWWJ7AF.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-QW5WOBSU.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-DCIYOPJF.js";import"./chunk-7I7IEX4S.js";import"./chunk-JE2EV6NS.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{b as WikiHub,a as existingWikiDir};
2
+ //# sourceMappingURL=hub-3M4HJMYR.js.map
package/dist/index.d.ts CHANGED
@@ -7608,8 +7608,10 @@ declare const daemonConfigSchema: z.ZodObject<{
7608
7608
  * reads it. A firm promise (the agent will do a named thing later, no
7609
7609
  * condition) becomes a promise owned by that agent, owed to whoever
7610
7610
  * asked; a reply that asks the owner leaves its request waiting on
7611
- * them, with the question. Off by default: it spends a model call on
7612
- * most owner-facing replies. Needs `enabled` above. */
7611
+ * them, with the question. On by default since #1806: without it a reply
7612
+ * that asks the owner leaves its request in progress and the settle step
7613
+ * closes it. One small model call per owner-facing reply, bounded by
7614
+ * `dailyCap`. Needs `enabled` above (requests are off by default). */
7613
7615
  catchPromises: z.ZodDefault<z.ZodObject<{
7614
7616
  enabled: z.ZodDefault<z.ZodBoolean>;
7615
7617
  /** Model calls a day (UTC), across all agents. Past it, replies are
@@ -8186,12 +8188,31 @@ declare const daemonConfigSchema: z.ZodObject<{
8186
8188
  items: z.ZodEffects<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>, Record<string, Record<string, unknown>>, Record<string, Record<string, unknown>> | undefined>;
8187
8189
  /** Minutes before a failed read is tried again. */
8188
8190
  retryMinutes: z.ZodDefault<z.ZodNumber>;
8191
+ /** A number that misses its target twice in a row raises one decision
8192
+ * card, raised for its owner agent (src/numbers/review.ts). Off: no card;
8193
+ * the review list still shows it. */
8194
+ missedTwiceCard: z.ZodDefault<z.ZodBoolean>;
8195
+ /** An agent that reviews the owner's follow-up on a missed-twice card:
8196
+ * told when the operator says yes. It gets the card itself when the
8197
+ * number has no owner agent on this node. Unset: the owner alone. */
8198
+ reviewer: z.ZodOptional<z.ZodString>;
8199
+ /** Funnels (#1826 N4) by id: a name and the steps in order, first to last.
8200
+ * A step is a number's id, {number, name?} or {tag, name}: the sum of the
8201
+ * numbers with that tag (src/numbers/funnel.ts). The Hub draws them.
8202
+ * Unset by default: nothing changes until one is set up. */
8203
+ funnels: z.ZodEffects<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>, Record<string, unknown> | undefined, Record<string, unknown> | undefined>;
8189
8204
  }, "strip", z.ZodTypeAny, {
8190
8205
  items: Record<string, Record<string, unknown>>;
8191
8206
  retryMinutes: number;
8207
+ missedTwiceCard: boolean;
8208
+ reviewer?: string | undefined;
8209
+ funnels?: Record<string, unknown> | undefined;
8192
8210
  }, {
8211
+ reviewer?: string | undefined;
8193
8212
  items?: Record<string, Record<string, unknown>> | undefined;
8194
8213
  retryMinutes?: number | undefined;
8214
+ missedTwiceCard?: boolean | undefined;
8215
+ funnels?: Record<string, unknown> | undefined;
8195
8216
  }>>;
8196
8217
  /** Task watchers (src/watchers, #1030): every task start decides whether
8197
8218
  * the task needs a watcher and attaches one. Off by default. */
@@ -9577,10 +9598,14 @@ declare const daemonConfigSchema: z.ZodObject<{
9577
9598
  lead?: string | undefined;
9578
9599
  }>, "many">>;
9579
9600
  contactMap: z.ZodDefault<z.ZodArray<z.ZodObject<{
9601
+ /** Header name -> NAME of an environment variable holding its value
9602
+ * (#1698). Read at connect time; written to .mcp.json only as a
9603
+ * `${NAME}` placeholder, never as the secret. */
9580
9604
  channel: z.ZodOptional<z.ZodString>;
9581
9605
  chatId: z.ZodOptional<z.ZodString>;
9582
9606
  username: z.ZodOptional<z.ZodString>;
9583
- senderId: z.ZodOptional<z.ZodString>;
9607
+ senderId: z.ZodOptional<z.ZodString>; /** Listed tools that only read though their names do not say so; they
9608
+ * skip the write confirmation card (#1736). */
9584
9609
  client: z.ZodString;
9585
9610
  project: z.ZodOptional<z.ZodString>;
9586
9611
  displayName: z.ZodOptional<z.ZodString>;
@@ -12595,6 +12620,9 @@ declare const daemonConfigSchema: z.ZodObject<{
12595
12620
  numbers: {
12596
12621
  items: Record<string, Record<string, unknown>>;
12597
12622
  retryMinutes: number;
12623
+ missedTwiceCard: boolean;
12624
+ reviewer?: string | undefined;
12625
+ funnels?: Record<string, unknown> | undefined;
12598
12626
  };
12599
12627
  requestStatus: {
12600
12628
  channels: string[];
@@ -14111,8 +14139,11 @@ declare const daemonConfigSchema: z.ZodObject<{
14111
14139
  saveBuilderWork?: boolean | undefined;
14112
14140
  } | undefined;
14113
14141
  numbers?: {
14142
+ reviewer?: string | undefined;
14114
14143
  items?: Record<string, Record<string, unknown>> | undefined;
14115
14144
  retryMinutes?: number | undefined;
14145
+ missedTwiceCard?: boolean | undefined;
14146
+ funnels?: Record<string, unknown> | undefined;
14116
14147
  } | undefined;
14117
14148
  requestStatus?: {
14118
14149
  channels?: string[] | undefined;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{Pa as Tt,Qa as Mt,a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,h as bt}from"./chunk-F2XNWKIL.js";import"./chunk-XXFVK5D7.js";import"./chunk-GTJIKXDB.js";import"./chunk-LJUBWMPB.js";import"./chunk-U5DSMDCJ.js";import"./chunk-IMLAPB7G.js";import"./chunk-ZVP6GB4G.js";import"./chunk-6UTOBSEA.js";import"./chunk-PPUN7YHA.js";import"./chunk-VZLIBDLH.js";import"./chunk-EKJG63EJ.js";import"./chunk-IKXDCPXS.js";import"./chunk-3Q6MRG3P.js";import"./chunk-2VDO2HEK.js";import"./chunk-JWDJMFU6.js";import"./chunk-2P5NP4H6.js";import"./chunk-B4KQC3DG.js";import"./chunk-LQE73AZR.js";import"./chunk-2D3RYIDU.js";import"./chunk-2ZNYIHRB.js";import"./chunk-MRIVENBY.js";import"./chunk-A5GYG56I.js";import"./chunk-SZXFWCKA.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-UKUH662W.js";import"./chunk-RX5O5637.js";import"./chunk-5ELIX7BQ.js";import"./chunk-X7UQY7CH.js";import"./chunk-I4E6BH27.js";import"./chunk-3UATFGSB.js";import"./chunk-QPABR72X.js";import"./chunk-IFUAP7UD.js";import"./chunk-KP7KDLZ2.js";import{Ka as yt,r as lt,s as ct,t as dt,u as mt,v as pt}from"./chunk-WLDRIJQX.js";import"./chunk-2KQECT4H.js";import"./chunk-MEFPXHQJ.js";import"./chunk-7AB3QUGH.js";import{a as L}from"./chunk-BAXGL6TY.js";import{A as D,B as z,C as V,a as ye,b as we,c as Se,d as Ae,e as Ie,f as Oe,g as Ne,h as He,i as je,j as Ue,k as _e,l as I,m as q,n as Be,o as qe,p as Ye,q as O,r as ze,s as Ve,t as Xe,u as x,v as Y,w as Qe,x as Ze,y as et,z as wt}from"./chunk-JNBUJKNG.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-6TTGRTDO.js";import"./chunk-F32VADB7.js";import"./chunk-VE3SSOQX.js";import"./chunk-W4YR2RO2.js";import"./chunk-7YOLZGB5.js";import"./chunk-IH65GDJR.js";import{u as ut}from"./chunk-AU7SN4G3.js";import"./chunk-LDSBFDYB.js";import"./chunk-3UOTLMXD.js";import"./chunk-XVV7ZZ77.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-KWWBDLE6.js";import"./chunk-HVMUYEQP.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-SZDACK6O.js";import"./chunk-VWTBHLMX.js";import"./chunk-5SQRJUAK.js";import"./chunk-JTFCU5LH.js";import"./chunk-LUOW2YHY.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-BE64IJWM.js";import"./chunk-5ONH4ITT.js";import"./chunk-JRAG37V5.js";import"./chunk-ILEC3IAV.js";import"./chunk-MYVHVJWZ.js";import"./chunk-M4H2RYP4.js";import"./chunk-OQQTV3OF.js";import"./chunk-4NZ4T3TQ.js";import"./chunk-LY4G7PCW.js";import"./chunk-DPG6VHPX.js";import"./chunk-BERWTVG2.js";import"./chunk-A7JSRDJL.js";import"./chunk-Z5CMA4JN.js";import"./chunk-TFHJT2AZ.js";import{a as ht}from"./chunk-JMWPBZLU.js";import{f as gt,g as ft}from"./chunk-T7SD5EVH.js";import"./chunk-WPNRDEHW.js";import"./chunk-OWNQ2FD4.js";import"./chunk-AHWWJ7AF.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-PA7CP74O.js";import{j as it,k as rt,l as at}from"./chunk-BLKXK27S.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-7IW25T4K.js";import"./chunk-Q3A5P373.js";import"./chunk-JLBRNYKY.js";import"./chunk-BYEL7KKR.js";import"./chunk-QUFIUXMQ.js";import{a as ke,b as ve,c as xe,d as $e,e as Ce,f as Pe,g as be,h as Te,i as Me,j as Re,l as Ee,m as Ge,o as T,p as W}from"./chunk-DCIYOPJF.js";import{a as m,b as G}from"./chunk-7I7IEX4S.js";import{b as Fe,c as Le,d as A,e as De}from"./chunk-JHCI6XCJ.js";import{a as Ke,b as Je,e as We}from"./chunk-DSYKYZMT.js";import{hc as tt,jc as st,mc as ot,tc as nt}from"./chunk-4A6UVU2X.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";W();G();import{execa as Rt}from"execa";import{existsSync as se,promises as X}from"fs";import S from"path";import ie from"node-fetch";async function Et(o,e){let t=o.split("/");if(t.length<2)throw new Error(`Invalid skill package ID: ${o}. Expected format: owner/repo`);let s=t[0],i=t[1],n=t[2];try{let a=n?`${s}/${i}/${n}`:`${s}/${i}`;await Rt("npx",["-y","skills","add",a],{cwd:e,stdio:"pipe"}),m.success(`Installed skill package: ${o}`);let r=S.resolve(e,".skills",`${s}_${i}`);if(se(r))return await ne(r,o);let d=S.resolve(e,".skills");return se(d)?await ne(d,o):[]}catch{return m.info(`Fetching skills directly from GitHub: ${s}/${i}`),await Gt(s,i,n,e)}}async function Gt(o,e,t,s){let i=[];try{let n=`https://api.github.com/repos/${o}/${e}/git/trees/main?recursive=1`,a=await ie(n);if(!a.ok)throw new Error(`GitHub API error: ${a.status}`);let d=(await a.json()).tree.filter(p=>p.type==="blob"&&p.path.endsWith("SKILL.md"));if(t){let p=d.find(f=>f.path.includes(`/${t}/`)||f.path===`${t}/SKILL.md`);if(p){let f=await oe(o,e,p.path,s);f&&i.push(f)}}else for(let p of d){let f=await oe(o,e,p.path,s);f&&i.push(f)}}catch(n){m.error(`Failed to fetch skills from GitHub: ${n.message}`)}return i}async function oe(o,e,t,s){try{let i=`https://raw.githubusercontent.com/${o}/${e}/main/${t}`,n=await ie(i);if(!n.ok)return null;let a=await n.text(),r=A(a);if(r){r.source="remote",r.packageId=`${o}/${e}`;let d=S.dirname(t),p=S.resolve(s,".skills",`${o}_${e}`,d);await X.mkdir(p,{recursive:!0}),await X.writeFile(S.resolve(p,"SKILL.md"),a),r.path=S.resolve(p,"SKILL.md")}return r}catch{return null}}async function ne(o,e){let t=[],{default:s}=await import("fast-glob"),i=await s.glob("**/SKILL.md",{cwd:o,deep:5});for(let n of i)try{let a=S.resolve(o,n),r=await X.readFile(a,"utf8"),d=A(r);d&&(d.source="remote",d.path=a,d.packageId=e,t.push(d))}catch{}return t}async function At(o,e,t,s,i){let n=["---",`name: ${o}`,`description: ${e}`];if(s?.length){n.push("tags:");for(let a of s)n.push(` - ${a}`)}if(i?.length){n.push("globs:");for(let a of i)n.push(` - ${a}`)}return n.push("---"),`${n.join(`
1
+ import{Oa as Tt,Pa as Mt,a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt,h as bt}from"./chunk-FSEJ2LX5.js";import"./chunk-MSOAI54R.js";import"./chunk-GTJIKXDB.js";import"./chunk-NLMQ7ZAE.js";import"./chunk-YB2QYUXG.js";import"./chunk-IMLAPB7G.js";import"./chunk-ZVP6GB4G.js";import"./chunk-SYIDD7CI.js";import"./chunk-PPUN7YHA.js";import"./chunk-VZLIBDLH.js";import"./chunk-EKJG63EJ.js";import"./chunk-WZIFXZZX.js";import"./chunk-3Q6MRG3P.js";import"./chunk-2VDO2HEK.js";import"./chunk-JWDJMFU6.js";import"./chunk-2P5NP4H6.js";import"./chunk-B4KQC3DG.js";import"./chunk-LQE73AZR.js";import"./chunk-2D3RYIDU.js";import"./chunk-ZXABOPXF.js";import"./chunk-MRIVENBY.js";import"./chunk-A5GYG56I.js";import"./chunk-K5VZS747.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-UKUH662W.js";import"./chunk-RX5O5637.js";import"./chunk-5ELIX7BQ.js";import"./chunk-X7UQY7CH.js";import"./chunk-M75VNIVM.js";import"./chunk-B7WQT7GG.js";import"./chunk-QPABR72X.js";import"./chunk-IFUAP7UD.js";import"./chunk-KP7KDLZ2.js";import{Ka as yt,r as lt,s as ct,t as dt,u as mt,v as pt}from"./chunk-FJJ5PVQK.js";import"./chunk-X23I2U26.js";import"./chunk-MEFPXHQJ.js";import"./chunk-7AB3QUGH.js";import{a as L}from"./chunk-BAXGL6TY.js";import{A as D,B as z,C as V,a as ye,b as we,c as Se,d as Ae,e as Ie,f as Oe,g as Ne,h as He,i as je,j as Ue,k as _e,l as I,m as q,n as Be,o as qe,p as Ye,q as O,r as ze,s as Ve,t as Xe,u as x,v as Y,w as Qe,x as Ze,y as et,z as wt}from"./chunk-ETMUGFPI.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-6TTGRTDO.js";import"./chunk-D3HNIOZ7.js";import"./chunk-VE3SSOQX.js";import"./chunk-W4YR2RO2.js";import"./chunk-7YOLZGB5.js";import"./chunk-IH65GDJR.js";import{u as ut}from"./chunk-OQEP2Q32.js";import"./chunk-QAMVAZ67.js";import"./chunk-3UOTLMXD.js";import"./chunk-XVV7ZZ77.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-KWWBDLE6.js";import"./chunk-HVMUYEQP.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-SZDACK6O.js";import"./chunk-VWTBHLMX.js";import"./chunk-YG5GPPGI.js";import"./chunk-JTFCU5LH.js";import"./chunk-LUOW2YHY.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-BE64IJWM.js";import"./chunk-5ONH4ITT.js";import"./chunk-JRAG37V5.js";import"./chunk-ILEC3IAV.js";import"./chunk-MYVHVJWZ.js";import"./chunk-XQH4LCZR.js";import"./chunk-BXK5S2KK.js";import"./chunk-4NZ4T3TQ.js";import"./chunk-LY4G7PCW.js";import"./chunk-DPG6VHPX.js";import"./chunk-BERWTVG2.js";import"./chunk-A7JSRDJL.js";import"./chunk-Z5CMA4JN.js";import"./chunk-2REJBHT5.js";import{a as ht}from"./chunk-IATCZJP7.js";import{f as gt,g as ft}from"./chunk-AKPLNPUY.js";import"./chunk-WPNRDEHW.js";import"./chunk-OWNQ2FD4.js";import"./chunk-AHWWJ7AF.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-CHCAPQ6E.js";import{j as it,k as rt,l as at}from"./chunk-QW5WOBSU.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-7IW25T4K.js";import"./chunk-Q3A5P373.js";import"./chunk-JLBRNYKY.js";import"./chunk-BYEL7KKR.js";import"./chunk-QUFIUXMQ.js";import{a as ke,b as ve,c as xe,d as $e,e as Ce,f as Pe,g as be,h as Te,i as Me,j as Re,l as Ee,m as Ge,o as T,p as W}from"./chunk-DCIYOPJF.js";import{a as m,b as G}from"./chunk-7I7IEX4S.js";import{b as Fe,c as Le,d as A,e as De}from"./chunk-JHCI6XCJ.js";import{a as Ke,b as Je,e as We}from"./chunk-DSYKYZMT.js";import{Bc as nt,pc as tt,rc as st,uc as ot}from"./chunk-JE2EV6NS.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";W();G();import{execa as Rt}from"execa";import{existsSync as se,promises as X}from"fs";import S from"path";import ie from"node-fetch";async function Et(o,e){let t=o.split("/");if(t.length<2)throw new Error(`Invalid skill package ID: ${o}. Expected format: owner/repo`);let s=t[0],i=t[1],n=t[2];try{let a=n?`${s}/${i}/${n}`:`${s}/${i}`;await Rt("npx",["-y","skills","add",a],{cwd:e,stdio:"pipe"}),m.success(`Installed skill package: ${o}`);let r=S.resolve(e,".skills",`${s}_${i}`);if(se(r))return await ne(r,o);let d=S.resolve(e,".skills");return se(d)?await ne(d,o):[]}catch{return m.info(`Fetching skills directly from GitHub: ${s}/${i}`),await Gt(s,i,n,e)}}async function Gt(o,e,t,s){let i=[];try{let n=`https://api.github.com/repos/${o}/${e}/git/trees/main?recursive=1`,a=await ie(n);if(!a.ok)throw new Error(`GitHub API error: ${a.status}`);let d=(await a.json()).tree.filter(p=>p.type==="blob"&&p.path.endsWith("SKILL.md"));if(t){let p=d.find(f=>f.path.includes(`/${t}/`)||f.path===`${t}/SKILL.md`);if(p){let f=await oe(o,e,p.path,s);f&&i.push(f)}}else for(let p of d){let f=await oe(o,e,p.path,s);f&&i.push(f)}}catch(n){m.error(`Failed to fetch skills from GitHub: ${n.message}`)}return i}async function oe(o,e,t,s){try{let i=`https://raw.githubusercontent.com/${o}/${e}/main/${t}`,n=await ie(i);if(!n.ok)return null;let a=await n.text(),r=A(a);if(r){r.source="remote",r.packageId=`${o}/${e}`;let d=S.dirname(t),p=S.resolve(s,".skills",`${o}_${e}`,d);await X.mkdir(p,{recursive:!0}),await X.writeFile(S.resolve(p,"SKILL.md"),a),r.path=S.resolve(p,"SKILL.md")}return r}catch{return null}}async function ne(o,e){let t=[],{default:s}=await import("fast-glob"),i=await s.glob("**/SKILL.md",{cwd:o,deep:5});for(let n of i)try{let a=S.resolve(o,n),r=await X.readFile(a,"utf8"),d=A(r);d&&(d.source="remote",d.path=a,d.packageId=e,t.push(d))}catch{}return t}async function At(o,e,t,s,i){let n=["---",`name: ${o}`,`description: ${e}`];if(s?.length){n.push("tags:");for(let a of s)n.push(` - ${a}`)}if(i?.length){n.push("globs:");for(let a of i)n.push(` - ${a}`)}return n.push("---"),`${n.join(`
2
2
  `)}
3
3
 
4
4
  ${t}`}async function It(o){let{loadLocalSkills:e}=await import("./loader-YFVSSYSL.js");return e(o)}async function Ot(o,e,t,s,i){let a=[{role:"system",content:`You are a skill author for the Agent Skills ecosystem (skills.sh).
@@ -0,0 +1,2 @@
1
+ import{d}from"./chunk-GMQLDXEM.js";import{b as c}from"./chunk-IFUAP7UD.js";import"./chunk-KP7KDLZ2.js";import"./chunk-D3HNIOZ7.js";import"./chunk-OQEP2Q32.js";import"./chunk-QAMVAZ67.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-JE2EV6NS.js";import"./chunk-KEUW6YLL.js";import"./chunk-N47Y5ADQ.js";import"./chunk-VQRY4IDI.js";import"./chunk-YSCT6DPR.js";import"./chunk-QIJLFPWE.js";var u=new Set(["cron","heartbeat","api","a2a","mesh","approvals","requests"]);function p(n){return typeof n=="string"?n.trim():""}async function y(n,o){let i=o.fetch??fetch,h=o.daemonUrl.replace(/\/$/,""),a=o.env??process.env,s=(p(n.action)||"show").toLowerCase();if(s==="show")try{let e=await i(`${h}/api/org`,{headers:c(a),signal:AbortSignal.timeout(1e4)}),r=await e.json().catch(()=>({}));return e.ok?String(r.text??""):`Error: ${r?.error||`HTTP ${e.status}`}`}catch(e){return`Error: couldn't reach the daemon (${e?.message??e}).`}if(s!=="propose")return`Error: unknown action "${s}". Use show or propose.`;let t=d(n,a);if(!t)return"Error: couldn't tell which agent you are. Pass callerAgentId.";let l=t.channel&&t.chatId&&!u.has(t.channel)?{channel:t.channel,chatId:t.chatId,...t.accountId?{accountId:t.accountId}:{}}:void 0;try{let e=await i(`${h}/api/org/proposals`,{method:"POST",headers:{"Content-Type":"application/json",...c(a)},body:JSON.stringify({changes:n.changes,newAgent:n.newAgent,why:n.why,raised_by:t.agentId,...l?{reply:l}:{}}),signal:AbortSignal.timeout(1e4)}),r=await e.json().catch(()=>({}));return e.ok?[`Card ${r.card.id} is in the owner's Approvals inbox: "${r.text}"`,"Nothing is changed yet. On the owner's yes the daemon applies it and you get a message with the result; do not edit the org chart yourself.","Tell the owner it is waiting for their yes."].join(" "):`Not proposed: ${r?.error||`HTTP ${e.status}`}`}catch(e){return`Error: couldn't reach the daemon (${e?.message??e}).`}}export{y as runOrgTool};
2
+ //# sourceMappingURL=org-tool-JS4WKB35.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/business/org-tool.ts"],"sourcesContent":["import { resolveScheduleCaller } from \"@/crons/schedule-tool\"\nimport { callerHeaders } from \"@/calls/service\"\n\n// --- Agent-facing `agentx_org` tool (#1678 point 5) ---\n//\n// The owner asks in chat for a change to the org chart. The agent reads the\n// chart with `show`, maps the names it heard to member refs, and sends the\n// changes with `propose`. The tool never writes: the daemon checks every\n// change (POST /api/org/proposals, org-proposals.ts) and raises one\n// Approvals card; on the owner's yes the daemon applies it, not the agent.\n\nexport interface OrgToolDeps {\n daemonUrl: string\n fetch?: typeof fetch\n env?: NodeJS.ProcessEnv\n}\n\nconst NON_CHAT_CHANNELS = new Set([\"cron\", \"heartbeat\", \"api\", \"a2a\", \"mesh\", \"approvals\", \"requests\"])\n\nfunction str(v: unknown): string {\n return typeof v === \"string\" ? v.trim() : \"\"\n}\n\n/** Returns the text the agent sees. Every refusal is text, never a throw. */\nexport async function runOrgTool(args: Record<string, unknown>, deps: OrgToolDeps): Promise<string> {\n const doFetch = deps.fetch ?? fetch\n const base = deps.daemonUrl.replace(/\\/$/, \"\")\n const env = deps.env ?? process.env\n const action = (str(args.action) || \"show\").toLowerCase()\n\n if (action === \"show\") {\n try {\n const res = await doFetch(`${base}/api/org`, { headers: callerHeaders(env), signal: AbortSignal.timeout(10_000) })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n return String(data.text ?? \"\")\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n }\n\n if (action !== \"propose\") return `Error: unknown action \"${action}\". Use show or propose.`\n const caller = resolveScheduleCaller(args, env)\n if (!caller) return \"Error: couldn't tell which agent you are. Pass callerAgentId.\"\n const reply = caller.channel && caller.chatId && !NON_CHAT_CHANNELS.has(caller.channel)\n ? { channel: caller.channel, chatId: caller.chatId, ...(caller.accountId ? { accountId: caller.accountId } : {}) }\n : undefined\n try {\n const res = await doFetch(`${base}/api/org/proposals`, {\n method: \"POST\",\n // The headers name this run: the daemon checks that the owner started it.\n headers: { \"Content-Type\": \"application/json\", ...callerHeaders(env) },\n body: JSON.stringify({ changes: args.changes, newAgent: args.newAgent, why: args.why, raised_by: caller.agentId, ...(reply ? { reply } : {}) }),\n signal: AbortSignal.timeout(10_000),\n })\n const data = await res.json().catch(() => ({})) as any\n // A refusal is a plain sentence: say it to the owner as it is.\n if (!res.ok) return `Not proposed: ${data?.error || `HTTP ${res.status}`}`\n return [\n `Card ${data.card.id} is in the owner's Approvals inbox: \"${data.text}\"`,\n \"Nothing is changed yet. On the owner's yes the daemon applies it and you get a message with the result; do not edit the org chart yourself.\",\n \"Tell the owner it is waiting for their yes.\",\n ].join(\" \")\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n}\n"],"mappings":"wdAiBA,IAAMA,EAAoB,IAAI,IAAI,CAAC,OAAQ,YAAa,MAAO,MAAO,OAAQ,YAAa,UAAU,CAAC,EAEt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EAAI,CAAC,CAAG,CAAC,EAC9I,OAAQ,YAAY,QAAQ,GAAM,CACpC,CAAC,EACKH,EAAO,MAAMF,EAAI,KAAK,EAAE,MAAM,KAAO,CAAC,EAAE,EAE9C,OAAKA,EAAI,GACF,CACL,QAAQE,EAAK,KAAK,0CAA0CA,EAAK,QACjE,8IACA,6CACF,EAAE,KAAK,GAAG,EALU,iBAAiBA,GAAM,OAAS,QAAQF,EAAI,UAMlE,OAAS,EAAP,CACA,MAAO,qCAAqC,GAAG,SAAW,KAC5D,CACF","names":["NON_CHAT_CHANNELS","str","v","runOrgTool","args","deps","doFetch","base","env","action","res","callerHeaders","data","caller","resolveScheduleCaller","reply"]}
1
+ {"version":3,"sources":["../src/business/org-tool.ts"],"sourcesContent":["import { resolveScheduleCaller } from \"@/crons/schedule-tool\"\nimport { callerHeaders } from \"@/calls/service\"\n\n// --- Agent-facing `agentx_org` tool (#1678 point 5) ---\n//\n// The owner asks in chat for a change to the org chart. The agent reads the\n// chart with `show`, maps the names it heard to member refs, and sends the\n// changes with `propose`. The tool never writes: the daemon checks every\n// change (POST /api/org/proposals, org-proposals.ts) and raises one\n// Approvals card; on the owner's yes the daemon applies it, not the agent.\n\nexport interface OrgToolDeps {\n daemonUrl: string\n fetch?: typeof fetch\n env?: NodeJS.ProcessEnv\n}\n\nconst NON_CHAT_CHANNELS = new Set([\"cron\", \"heartbeat\", \"api\", \"a2a\", \"mesh\", \"approvals\", \"requests\"])\n\nfunction str(v: unknown): string {\n return typeof v === \"string\" ? v.trim() : \"\"\n}\n\n/** Returns the text the agent sees. Every refusal is text, never a throw. */\nexport async function runOrgTool(args: Record<string, unknown>, deps: OrgToolDeps): Promise<string> {\n const doFetch = deps.fetch ?? fetch\n const base = deps.daemonUrl.replace(/\\/$/, \"\")\n const env = deps.env ?? process.env\n const action = (str(args.action) || \"show\").toLowerCase()\n\n if (action === \"show\") {\n try {\n const res = await doFetch(`${base}/api/org`, { headers: callerHeaders(env), signal: AbortSignal.timeout(10_000) })\n const data = await res.json().catch(() => ({})) as any\n if (!res.ok) return `Error: ${data?.error || `HTTP ${res.status}`}`\n return String(data.text ?? \"\")\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n }\n\n if (action !== \"propose\") return `Error: unknown action \"${action}\". Use show or propose.`\n const caller = resolveScheduleCaller(args, env)\n if (!caller) return \"Error: couldn't tell which agent you are. Pass callerAgentId.\"\n const reply = caller.channel && caller.chatId && !NON_CHAT_CHANNELS.has(caller.channel)\n ? { channel: caller.channel, chatId: caller.chatId, ...(caller.accountId ? { accountId: caller.accountId } : {}) }\n : undefined\n try {\n const res = await doFetch(`${base}/api/org/proposals`, {\n method: \"POST\",\n // The headers name this run: the daemon checks that the owner started it.\n headers: { \"Content-Type\": \"application/json\", ...callerHeaders(env) },\n body: JSON.stringify({ changes: args.changes, newAgent: args.newAgent, why: args.why, raised_by: caller.agentId, ...(reply ? { reply } : {}) }),\n signal: AbortSignal.timeout(10_000),\n })\n const data = await res.json().catch(() => ({})) as any\n // A refusal is a plain sentence: say it to the owner as it is.\n if (!res.ok) return `Not proposed: ${data?.error || `HTTP ${res.status}`}`\n return [\n `Card ${data.card.id} is in the owner's Approvals inbox: \"${data.text}\"`,\n \"Nothing is changed yet. On the owner's yes the daemon applies it and you get a message with the result; do not edit the org chart yourself.\",\n \"Tell the owner it is waiting for their yes.\",\n ].join(\" \")\n } catch (e: any) {\n return `Error: couldn't reach the daemon (${e?.message ?? e}).`\n }\n}\n"],"mappings":"ubAiBA,IAAMA,EAAoB,IAAI,IAAI,CAAC,OAAQ,YAAa,MAAO,MAAO,OAAQ,YAAa,UAAU,CAAC,EAEtG,SAASC,EAAIC,EAAoB,CAC/B,OAAO,OAAOA,GAAM,SAAWA,EAAE,KAAK,EAAI,EAC5C,CAGA,eAAsBC,EAAWC,EAA+BC,EAAoC,CAClG,IAAMC,EAAUD,EAAK,OAAS,MACxBE,EAAOF,EAAK,UAAU,QAAQ,MAAO,EAAE,E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jE,8IACA,6CACF,EAAE,KAAK,GAAG,EALU,iBAAiBA,GAAM,OAAS,QAAQF,EAAI,UAMlE,OAAS,EAAP,CACA,MAAO,qCAAqC,GAAG,SAAW,KAC5D,CACF","names":["NON_CHAT_CHANNELS","str","v","runOrgTool","args","deps","doFetch","base","env","action","res","callerHeaders","data","caller","resolveScheduleCaller","reply"]}