agentix-cli 0.206.1 → 0.207.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 (141) hide show
  1. package/dist/{App-IEUOKINQ.js → App-64NXDO3Q.js} +2 -2
  2. package/dist/{ChatApp-CCDBG6YZ.js → ChatApp-LZSQ4233.js} +2 -2
  3. package/dist/{absorb-eval-IIF7CY3Q.js → absorb-eval-XG6QUTN6.js} +2 -2
  4. package/dist/{adapter-LTHULD3D.js → adapter-SDLSX2ZH.js} +2 -2
  5. package/dist/{agent-TZ3GGNS5.js → agent-TYURILCF.js} +2 -2
  6. package/dist/{board-dashboard-JS6OJDH6.js → board-dashboard-MLNL4EZ7.js} +21 -6
  7. package/dist/board-dashboard-MLNL4EZ7.js.map +1 -0
  8. package/dist/{chunk-E2MW5OCE.js → chunk-2GAMPUOB.js} +2 -2
  9. package/dist/{chunk-6U34GZ7U.js → chunk-2W23ZJCP.js} +2 -2
  10. package/dist/{chunk-Z6J3RTYJ.js → chunk-3ALELN73.js} +2 -2
  11. package/dist/{chunk-JDU4CXGC.js → chunk-3FUW6RXU.js} +2 -2
  12. package/dist/{chunk-KXMC7Z5X.js → chunk-3MUWPMC2.js} +2 -2
  13. package/dist/{chunk-I4753XPP.js → chunk-5YJ5GQCJ.js} +2 -2
  14. package/dist/{chunk-M37WJANA.js → chunk-6TZQZGRI.js} +65 -65
  15. package/dist/chunk-6TZQZGRI.js.map +1 -0
  16. package/dist/{chunk-K435U2FC.js → chunk-7MRDQLOS.js} +2 -2
  17. package/dist/{chunk-ZOK6VMEP.js → chunk-AECUZTRB.js} +2 -2
  18. package/dist/{chunk-U3OJO7B7.js → chunk-B34OLAAC.js} +36 -36
  19. package/dist/chunk-B34OLAAC.js.map +1 -0
  20. package/dist/{chunk-WI7J22NL.js → chunk-BBMGXNHU.js} +2 -2
  21. package/dist/{chunk-UN7D7HWU.js → chunk-CRSHJYZQ.js} +2 -2
  22. package/dist/{chunk-I74PTSUQ.js → chunk-DH7Z3HRC.js} +2 -2
  23. package/dist/{chunk-RRLQTU3X.js → chunk-EOQNFLFJ.js} +2 -2
  24. package/dist/{chunk-GCBFLU64.js → chunk-LTLH2CHG.js} +12 -6
  25. package/dist/chunk-LTLH2CHG.js.map +1 -0
  26. package/dist/{chunk-7JHB3X5N.js → chunk-NKSQNQ5V.js} +60 -60
  27. package/dist/chunk-NKSQNQ5V.js.map +1 -0
  28. package/dist/{chunk-WTCMJZW3.js → chunk-PSLSU6HC.js} +2 -2
  29. package/dist/{chunk-VALKXSXZ.js → chunk-RHXBLKBW.js} +2 -2
  30. package/dist/{chunk-R6XJWFMC.js → chunk-RWZGW2GQ.js} +2 -2
  31. package/dist/{chunk-7GD5GTWC.js → chunk-TYKEHZZA.js} +2 -2
  32. package/dist/{chunk-37EABHYL.js → chunk-UF3D5LFH.js} +2 -2
  33. package/dist/{chunk-XTIPWYW5.js → chunk-VIWN3CXS.js} +3 -3
  34. package/dist/chunk-VIWN3CXS.js.map +1 -0
  35. package/dist/{chunk-RPL2P7EP.js → chunk-VKEL4XNO.js} +2 -2
  36. package/dist/{chunk-FXA2WIIP.js → chunk-XEMW37IV.js} +2 -2
  37. package/dist/{chunk-6ZVVAGTR.js → chunk-XGCSWSVD.js} +2 -2
  38. package/dist/{chunk-CARVBJB7.js → chunk-YLKEUO6K.js} +2 -2
  39. package/dist/{chunk-CARVBJB7.js.map → chunk-YLKEUO6K.js.map} +1 -1
  40. package/dist/{chunk-TLRTJV2U.js → chunk-ZEJ2ZG6K.js} +290 -290
  41. package/dist/chunk-ZEJ2ZG6K.js.map +1 -0
  42. package/dist/{chunk-A2K6C6W3.js → chunk-ZJXJN6GM.js} +3 -3
  43. package/dist/{chunk-B35GIWMR.js → chunk-ZT32DUC7.js} +2 -2
  44. package/dist/cli.js +1 -1
  45. package/dist/{client-NPC2JAWL.js → client-HC5UIRHC.js} +2 -2
  46. package/dist/{config-TIMTRSFH.js → config-FUB5TUCM.js} +2 -2
  47. package/dist/{config-mutate-V3DRUCK4.js → config-mutate-5WSQJAJO.js} +2 -2
  48. package/dist/{config-mutator-HOYYIPNW.js → config-mutator-RALUVF77.js} +2 -2
  49. package/dist/{contributions-TYVRQG7F.js → contributions-SSQ2H2H6.js} +2 -2
  50. package/dist/{doctor-TNQ4Q2OS.js → doctor-FAC34AQ6.js} +2 -2
  51. package/dist/{follow-up-tool-3P2YCRBL.js → follow-up-tool-JCJSBAJF.js} +2 -2
  52. package/dist/{hub-GVTRKPAU.js → hub-YAEE5GFW.js} +2 -2
  53. package/dist/index.d.ts +79 -1
  54. package/dist/index.js +1 -1
  55. package/dist/{org-tool-EKO7GCPL.js → org-tool-YP256FUE.js} +2 -2
  56. package/dist/{program-Y55FFHIJ.js → program-3I7GFFDP.js} +23 -23
  57. package/dist/{promote-JYYV44FK.js → promote-NJWI2KUT.js} +2 -2
  58. package/dist/{query-PUWWCFET.js → query-O5EWN3YT.js} +2 -2
  59. package/dist/{query-settings-IJPG3N6D.js → query-settings-VKOJGJGC.js} +2 -2
  60. package/dist/{registry-QJGTPSK2.js → registry-W77Q7ZGZ.js} +2 -2
  61. package/dist/{request-planner-HHJXCWCG.js → request-planner-UY46HBKG.js} +2 -2
  62. package/dist/{review-candidates-XZUQELL5.js → review-candidates-A4BTJYML.js} +2 -2
  63. package/dist/{routing-HWZHJ4LZ.js → routing-THT4U4KK.js} +2 -2
  64. package/dist/schedule-tool-FVBUHIDC.js +2 -0
  65. package/dist/{scheduler-WG3KXJIH.js → scheduler-MHTDA3ZS.js} +2 -2
  66. package/dist/{seat-5BOBWKBX.js → seat-NW3JTDGK.js} +2 -2
  67. package/dist/{select-FIHHBFNR.js → select-4DILJ2XW.js} +2 -2
  68. package/dist/{set-enabled-K7OM7PSO.js → set-enabled-DKQTH2PC.js} +2 -2
  69. package/dist/{sprint-tool-O6TTSWJN.js → sprint-tool-43TSRPK4.js} +2 -2
  70. package/dist/{tool-HTUSCV22.js → tool-7MI3GK2K.js} +2 -2
  71. package/dist/{tool-BYU6EZKM.js → tool-JYSRWVNB.js} +2 -2
  72. package/dist/{tool-HVCLZGYE.js → tool-NA7ZOWD5.js} +2 -2
  73. package/dist/{tool-4KVS2JWC.js → tool-PQZ7NURW.js} +2 -2
  74. package/dist/{wiki-ZMEMGR7R.js → wiki-NR2KS3AT.js} +2 -2
  75. package/dist/wiki-enrich-EB2EOVDJ.js +2 -0
  76. package/package.json +1 -1
  77. package/dist/board-dashboard-JS6OJDH6.js.map +0 -1
  78. package/dist/chunk-7JHB3X5N.js.map +0 -1
  79. package/dist/chunk-GCBFLU64.js.map +0 -1
  80. package/dist/chunk-M37WJANA.js.map +0 -1
  81. package/dist/chunk-TLRTJV2U.js.map +0 -1
  82. package/dist/chunk-U3OJO7B7.js.map +0 -1
  83. package/dist/chunk-XTIPWYW5.js.map +0 -1
  84. package/dist/schedule-tool-7W5CRUN4.js +0 -2
  85. package/dist/wiki-enrich-QZHQV7VZ.js +0 -2
  86. /package/dist/{App-IEUOKINQ.js.map → App-64NXDO3Q.js.map} +0 -0
  87. /package/dist/{ChatApp-CCDBG6YZ.js.map → ChatApp-LZSQ4233.js.map} +0 -0
  88. /package/dist/{absorb-eval-IIF7CY3Q.js.map → absorb-eval-XG6QUTN6.js.map} +0 -0
  89. /package/dist/{adapter-LTHULD3D.js.map → adapter-SDLSX2ZH.js.map} +0 -0
  90. /package/dist/{agent-TZ3GGNS5.js.map → agent-TYURILCF.js.map} +0 -0
  91. /package/dist/{chunk-E2MW5OCE.js.map → chunk-2GAMPUOB.js.map} +0 -0
  92. /package/dist/{chunk-6U34GZ7U.js.map → chunk-2W23ZJCP.js.map} +0 -0
  93. /package/dist/{chunk-Z6J3RTYJ.js.map → chunk-3ALELN73.js.map} +0 -0
  94. /package/dist/{chunk-JDU4CXGC.js.map → chunk-3FUW6RXU.js.map} +0 -0
  95. /package/dist/{chunk-KXMC7Z5X.js.map → chunk-3MUWPMC2.js.map} +0 -0
  96. /package/dist/{chunk-I4753XPP.js.map → chunk-5YJ5GQCJ.js.map} +0 -0
  97. /package/dist/{chunk-K435U2FC.js.map → chunk-7MRDQLOS.js.map} +0 -0
  98. /package/dist/{chunk-ZOK6VMEP.js.map → chunk-AECUZTRB.js.map} +0 -0
  99. /package/dist/{chunk-WI7J22NL.js.map → chunk-BBMGXNHU.js.map} +0 -0
  100. /package/dist/{chunk-UN7D7HWU.js.map → chunk-CRSHJYZQ.js.map} +0 -0
  101. /package/dist/{chunk-I74PTSUQ.js.map → chunk-DH7Z3HRC.js.map} +0 -0
  102. /package/dist/{chunk-RRLQTU3X.js.map → chunk-EOQNFLFJ.js.map} +0 -0
  103. /package/dist/{chunk-WTCMJZW3.js.map → chunk-PSLSU6HC.js.map} +0 -0
  104. /package/dist/{chunk-VALKXSXZ.js.map → chunk-RHXBLKBW.js.map} +0 -0
  105. /package/dist/{chunk-R6XJWFMC.js.map → chunk-RWZGW2GQ.js.map} +0 -0
  106. /package/dist/{chunk-7GD5GTWC.js.map → chunk-TYKEHZZA.js.map} +0 -0
  107. /package/dist/{chunk-37EABHYL.js.map → chunk-UF3D5LFH.js.map} +0 -0
  108. /package/dist/{chunk-RPL2P7EP.js.map → chunk-VKEL4XNO.js.map} +0 -0
  109. /package/dist/{chunk-FXA2WIIP.js.map → chunk-XEMW37IV.js.map} +0 -0
  110. /package/dist/{chunk-6ZVVAGTR.js.map → chunk-XGCSWSVD.js.map} +0 -0
  111. /package/dist/{chunk-A2K6C6W3.js.map → chunk-ZJXJN6GM.js.map} +0 -0
  112. /package/dist/{chunk-B35GIWMR.js.map → chunk-ZT32DUC7.js.map} +0 -0
  113. /package/dist/{client-NPC2JAWL.js.map → client-HC5UIRHC.js.map} +0 -0
  114. /package/dist/{config-TIMTRSFH.js.map → config-FUB5TUCM.js.map} +0 -0
  115. /package/dist/{config-mutate-V3DRUCK4.js.map → config-mutate-5WSQJAJO.js.map} +0 -0
  116. /package/dist/{config-mutator-HOYYIPNW.js.map → config-mutator-RALUVF77.js.map} +0 -0
  117. /package/dist/{contributions-TYVRQG7F.js.map → contributions-SSQ2H2H6.js.map} +0 -0
  118. /package/dist/{doctor-TNQ4Q2OS.js.map → doctor-FAC34AQ6.js.map} +0 -0
  119. /package/dist/{follow-up-tool-3P2YCRBL.js.map → follow-up-tool-JCJSBAJF.js.map} +0 -0
  120. /package/dist/{hub-GVTRKPAU.js.map → hub-YAEE5GFW.js.map} +0 -0
  121. /package/dist/{org-tool-EKO7GCPL.js.map → org-tool-YP256FUE.js.map} +0 -0
  122. /package/dist/{program-Y55FFHIJ.js.map → program-3I7GFFDP.js.map} +0 -0
  123. /package/dist/{promote-JYYV44FK.js.map → promote-NJWI2KUT.js.map} +0 -0
  124. /package/dist/{query-PUWWCFET.js.map → query-O5EWN3YT.js.map} +0 -0
  125. /package/dist/{query-settings-IJPG3N6D.js.map → query-settings-VKOJGJGC.js.map} +0 -0
  126. /package/dist/{registry-QJGTPSK2.js.map → registry-W77Q7ZGZ.js.map} +0 -0
  127. /package/dist/{request-planner-HHJXCWCG.js.map → request-planner-UY46HBKG.js.map} +0 -0
  128. /package/dist/{review-candidates-XZUQELL5.js.map → review-candidates-A4BTJYML.js.map} +0 -0
  129. /package/dist/{routing-HWZHJ4LZ.js.map → routing-THT4U4KK.js.map} +0 -0
  130. /package/dist/{schedule-tool-7W5CRUN4.js.map → schedule-tool-FVBUHIDC.js.map} +0 -0
  131. /package/dist/{scheduler-WG3KXJIH.js.map → scheduler-MHTDA3ZS.js.map} +0 -0
  132. /package/dist/{seat-5BOBWKBX.js.map → seat-NW3JTDGK.js.map} +0 -0
  133. /package/dist/{select-FIHHBFNR.js.map → select-4DILJ2XW.js.map} +0 -0
  134. /package/dist/{set-enabled-K7OM7PSO.js.map → set-enabled-DKQTH2PC.js.map} +0 -0
  135. /package/dist/{sprint-tool-O6TTSWJN.js.map → sprint-tool-43TSRPK4.js.map} +0 -0
  136. /package/dist/{tool-HTUSCV22.js.map → tool-7MI3GK2K.js.map} +0 -0
  137. /package/dist/{tool-BYU6EZKM.js.map → tool-JYSRWVNB.js.map} +0 -0
  138. /package/dist/{tool-HVCLZGYE.js.map → tool-NA7ZOWD5.js.map} +0 -0
  139. /package/dist/{tool-4KVS2JWC.js.map → tool-PQZ7NURW.js.map} +0 -0
  140. /package/dist/{wiki-ZMEMGR7R.js.map → wiki-NR2KS3AT.js.map} +0 -0
  141. /package/dist/{wiki-enrich-QZHQV7VZ.js.map → wiki-enrich-EB2EOVDJ.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as h}from"./chunk-WI7J22NL.js";import{resolve as n}from"path";import{existsSync as c,readdirSync as u,mkdirSync as l,readFileSync as p,writeFileSync as f,renameSync as S}from"fs";var m=class{baseDir;agentsDir;mode;sharedStore;agentStores=new Map;log;constructor(e=n(process.cwd(),".agentx/wiki"),r=console.error.bind(console,"[wiki-hub]"),t="graph"){this.baseDir=e,this.agentsDir=n(e,"agents"),this.mode=t,this.log=r,l(this.agentsDir,{recursive:!0}),this.sharedStore=new h(e,r)}getMode(){return this.mode}getAgentWiki(e){let r=`${e}:${this.mode}`;if(this.agentStores.has(r))return this.agentStores.get(r);let t=n(this.agentsDir,e,this.mode),s=new h(t,this.log);return this.agentStores.set(r,s),s}getBaseDir(){return this.baseDir}getSharedStore(){return this.sharedStore}sharedScope(e){return[...this.listAgentDirs().filter(t=>t!==e).map(t=>({id:t,store:this.getAgentWiki(t)})),{id:"shared",store:this.sharedStore,skip:t=>t.startsWith("agents/")}]}listAgentDirs(){return c(this.agentsDir)?u(this.agentsDir).filter(e=>!e.startsWith("_")&&!e.startsWith(".")&&c(n(this.agentsDir,e,this.mode))).sort():[]}listAgents(e=this.sharedStore.listEntries()){let r=new Set;for(let t of e)r.add(t.agentId);if(c(this.agentsDir))for(let t of u(this.agentsDir))!t.startsWith("_")&&!t.startsWith(".")&&r.add(t);return[...r].sort()}getAgentEntries(e){return this.sharedStore.listEntries({agentId:e})}getUnabsorbedEntries(e){return this.classifyEntries(e).pending}markProcessed(e,r,t){let s=new Set(t),g=this.readLedger(e),d=new Date().toISOString();for(let i of r)g.entries[i]={at:d,cited:s.has(i)};let o=this.ledgerPath(e);l(n(o,".."),{recursive:!0});let a=`${o}.tmp`;f(a,`${JSON.stringify(g,null,2)}
1
+ import{a as h}from"./chunk-BBMGXNHU.js";import{resolve as n}from"path";import{existsSync as c,readdirSync as u,mkdirSync as l,readFileSync as p,writeFileSync as f,renameSync as S}from"fs";var m=class{baseDir;agentsDir;mode;sharedStore;agentStores=new Map;log;constructor(e=n(process.cwd(),".agentx/wiki"),r=console.error.bind(console,"[wiki-hub]"),t="graph"){this.baseDir=e,this.agentsDir=n(e,"agents"),this.mode=t,this.log=r,l(this.agentsDir,{recursive:!0}),this.sharedStore=new h(e,r)}getMode(){return this.mode}getAgentWiki(e){let r=`${e}:${this.mode}`;if(this.agentStores.has(r))return this.agentStores.get(r);let t=n(this.agentsDir,e,this.mode),s=new h(t,this.log);return this.agentStores.set(r,s),s}getBaseDir(){return this.baseDir}getSharedStore(){return this.sharedStore}sharedScope(e){return[...this.listAgentDirs().filter(t=>t!==e).map(t=>({id:t,store:this.getAgentWiki(t)})),{id:"shared",store:this.sharedStore,skip:t=>t.startsWith("agents/")}]}listAgentDirs(){return c(this.agentsDir)?u(this.agentsDir).filter(e=>!e.startsWith("_")&&!e.startsWith(".")&&c(n(this.agentsDir,e,this.mode))).sort():[]}listAgents(e=this.sharedStore.listEntries()){let r=new Set;for(let t of e)r.add(t.agentId);if(c(this.agentsDir))for(let t of u(this.agentsDir))!t.startsWith("_")&&!t.startsWith(".")&&r.add(t);return[...r].sort()}getAgentEntries(e){return this.sharedStore.listEntries({agentId:e})}getUnabsorbedEntries(e){return this.classifyEntries(e).pending}markProcessed(e,r,t){let s=new Set(t),g=this.readLedger(e),d=new Date().toISOString();for(let i of r)g.entries[i]={at:d,cited:s.has(i)};let o=this.ledgerPath(e);l(n(o,".."),{recursive:!0});let a=`${o}.tmp`;f(a,`${JSON.stringify(g,null,2)}
2
2
  `),S(a,o)}summary(){let e=this.sharedStore.listEntries(),r=new Map;for(let t of e){let s=r.get(t.agentId);s?s.push(t):r.set(t.agentId,[t])}return this.listAgents(e).map(t=>{let{all:s,cited:g,read:d,pending:o,articles:a}=this.classifyEntries(t,r.get(t)??[]);return{agentId:t,totalEntries:s.length,totalArticles:a.length,cited:g.length,readNotCited:d.length,unabsorbed:o.length,articles:a}})}classifyEntries(e,r=this.getAgentEntries(e)){let t=this.getAgentWiki(e).rebuildIndex().articles,s=new Set;for(let i of t)if(i.sources)for(let y of i.sources)s.add(y);let g=this.readLedger(e).entries,d=[],o=[],a=[];for(let i of r)s.has(i.id)?d.push(i):g[i.id]?o.push(i):a.push(i);return{all:r,cited:d,read:o,pending:a,articles:t}}syncedFrom(e){let r=n(this.agentsDir,e,"_synced.json");if(!c(r))return null;try{return JSON.parse(p(r,"utf-8"))}catch(t){return this.log(`synced marker ${r} is not valid JSON: ${t.message}`),{node:"unknown",peerUrl:"",at:""}}}markSynced(e,r){let t=n(this.agentsDir,e,"_synced.json");l(n(t,".."),{recursive:!0});let s=`${t}.tmp`;f(s,`${JSON.stringify(r,null,2)}
3
3
  `),S(s,t)}ledgerPath(e){return n(this.agentsDir,e,"_absorbed.json")}readLedger(e){let r=this.ledgerPath(e);if(!c(r))return{entries:{}};try{return{entries:JSON.parse(p(r,"utf-8")).entries??{}}}catch(t){throw new Error(`absorb ledger ${r} is not valid JSON: ${t.message}`)}}};export{m as a};
4
- //# sourceMappingURL=chunk-WTCMJZW3.js.map
4
+ //# sourceMappingURL=chunk-PSLSU6HC.js.map
@@ -1,7 +1,7 @@
1
- import{Fb as b,Gb as k,Jb as x,Rb as S}from"./chunk-CARVBJB7.js";S();import{readFileSync as w,writeFileSync as v,existsSync as P}from"fs";import{resolve as d}from"path";function O(r){if(r)return d(r);let e=[d(process.cwd(),"agentx.json"),d(process.cwd(),".agentx/config.json")];for(let n of e)if(P(n))return n;return e[0]}function R(r){return JSON.parse(JSON.stringify(r))}async function C(r){try{let e=await fetch(`${r.replace(/\/$/,"")}/reload`,{method:"POST",signal:AbortSignal.timeout(3e3)});return e.ok?{ok:!0}:{ok:!1,reason:`HTTP ${e.status}`}}catch(e){return{ok:!1,reason:e?.cause?.code||e?.message||"unreachable"}}}async function N(r,e={}){let{validate:n=!0,dryRun:t=!1,reload:s=!0,configPath:l,daemonUrl:c}=e,o=O(l);if(!P(o))return{success:!1,path:o,error:`Config not found at ${o}. Run \`agentx init\` first.`};let g;try{g=w(o,"utf-8")}catch(a){return{success:!1,path:o,error:`Cannot read ${o}: ${a.message}`}}let p;try{p=JSON.parse(g)}catch(a){return{success:!1,path:o,error:`Invalid JSON in ${o}: ${a.message}`}}let i=R(p);try{await r(i)}catch(a){return{success:!1,path:o,error:`Mutator threw: ${a.message}`}}if(n){let a=k(i),u=b.safeParse(a);if(!u.success){let f=u.error.issues.map($=>` ${$.path.join(".")||"<root>"}: ${$.message}`).join(`
1
+ import{Fb as b,Gb as k,Jb as x,Rb as S}from"./chunk-YLKEUO6K.js";S();import{readFileSync as w,writeFileSync as v,existsSync as P}from"fs";import{resolve as d}from"path";function O(r){if(r)return d(r);let e=[d(process.cwd(),"agentx.json"),d(process.cwd(),".agentx/config.json")];for(let n of e)if(P(n))return n;return e[0]}function R(r){return JSON.parse(JSON.stringify(r))}async function C(r){try{let e=await fetch(`${r.replace(/\/$/,"")}/reload`,{method:"POST",signal:AbortSignal.timeout(3e3)});return e.ok?{ok:!0}:{ok:!1,reason:`HTTP ${e.status}`}}catch(e){return{ok:!1,reason:e?.cause?.code||e?.message||"unreachable"}}}async function N(r,e={}){let{validate:n=!0,dryRun:t=!1,reload:s=!0,configPath:l,daemonUrl:c}=e,o=O(l);if(!P(o))return{success:!1,path:o,error:`Config not found at ${o}. Run \`agentx init\` first.`};let g;try{g=w(o,"utf-8")}catch(a){return{success:!1,path:o,error:`Cannot read ${o}: ${a.message}`}}let p;try{p=JSON.parse(g)}catch(a){return{success:!1,path:o,error:`Invalid JSON in ${o}: ${a.message}`}}let i=R(p);try{await r(i)}catch(a){return{success:!1,path:o,error:`Mutator threw: ${a.message}`}}if(n){let a=k(i),u=b.safeParse(a);if(!u.success){let f=u.error.issues.map($=>` ${$.path.join(".")||"<root>"}: ${$.message}`).join(`
2
2
  `);return{success:!1,path:o,error:`Validation failed:
3
3
  ${f}`,after:i}}let m=x(u.data);if(m.length)return{success:!1,path:o,error:`Validation failed:
4
4
  ${m.map(f=>` ${f}`).join(`
5
5
  `)}`,after:i}}if(t)return{success:!0,path:o,after:i,dryRun:!0};try{v(o,JSON.stringify(i,null,2)+`
6
6
  `)}catch(a){return{success:!1,path:o,error:`Write failed: ${a.message}`,after:i}}let h=!1,y;if(s){let a=c||M(i),u=await C(a);u.ok?h=!0:y=u.reason}return{success:!0,path:o,after:i,reloaded:h,reloadSkipped:y}}function M(r){let e=r?.node?.bind;if(!e)return"http://127.0.0.1:18800";let[n,t]=e.split(":");return`http://${n==="0.0.0.0"||n==="::"?"127.0.0.1":n}:${t}`}function A(r,e,n){let t=e.split("."),s=r;for(let l=0;l<t.length-1;l++){let c=t[l];(s[c]===void 0||s[c]===null)&&(s[c]={}),s=s[c]}s[t[t.length-1]]=n}function F(r,e){let n=e.split("."),t=r;for(let s of n){if(t==null)return;t=t[s]}return t}function U(r,e){let n=e.split("."),t=r;for(let s=0;s<n.length-1;s++){if(t==null)return;t=t[n[s]]}t!=null&&delete t[n[n.length-1]]}export{O as a,N as b,A as c,F as d,U as e};
7
- //# sourceMappingURL=chunk-VALKXSXZ.js.map
7
+ //# sourceMappingURL=chunk-RHXBLKBW.js.map
@@ -1,4 +1,4 @@
1
- import{_ as y,aa as v,ga as w,ha as C,ja as E,ka as R,la as I}from"./chunk-CARVBJB7.js";I();v();var L=1e4,T=["issues","prs","all"],W=/^[\w.-]+(?:\/[\w.-]+)+$/,m=e=>typeof e=="string"?e.trim():"";function f(e){let t=m(e.provider).toLowerCase();if(t!=="github"&&t!=="gitlab")return"count.provider must be github or gitlab";let r=m(e.project),n=r.split("/");if(!W.test(r)||n.some(o=>o==="."||o==="..")||t==="github"&&n.length!==2)return t==="github"?'count.project must be "owner/repo"':'count.project must be "group/project"';let s=(m(e.what)||"issues").toLowerCase();if(!T.includes(s))return`count.what must be one of ${T.join(", ")}`;let i=e.max===void 0||e.max===null||e.max===""?0:Number(e.max);return!Number.isInteger(i)||i<0?"count.max must be a whole number, 0 or more":{provider:t,project:r,what:s,max:i}}function S(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let r=f(t);return typeof r=="string"?null:r}catch{return null}}var _=e=>e==="issues"?"open issues":e==="prs"?"open pull requests":"open issues and pull requests";function $(e){return`${_(e.what)} in ${e.provider} ${e.project} \u2264 ${e.max}`}async function Y(e,t){if(!t)return{verdict:"unverifiable",detail:`no ${e.provider} connector on this node`};try{let r=e.what==="all"?["issues","prs"]:[e.what],n=0;for(let i of r){let o=await t(e.provider,e.project,i);if(typeof o!="number")return{verdict:"unverifiable",detail:`${e.project}: ${o.error}`};n+=o}let s=`${n} ${_(e.what)} in ${e.project}`;return{verdict:n<=e.max?"met":"not_met",detail:s,count:n}}catch(r){return{verdict:"unverifiable",detail:`the count check failed: ${String(r?.message??r).slice(0,200)}`}}}function B(e,t=fetch){return async(r,n,s)=>{let i;if(r==="github"){let a=e.github;if(!a)return{error:"no github connector on this node (channels.github or requests.checkers.github)"};let d=encodeURIComponent(`repo:${n} is:open is:${s==="prs"?"pr":"issue"}`);i=`${a.apiUrl.replace(/\/$/,"")}/search/issues?q=${d}&per_page=1`}else{let a=e.gitlab;if(!a)return{error:"no gitlab connector on this node (channels.gitlab or requests.checkers.gitlab)"};i=`${a.url.replace(/\/$/,"")}/api/v4/projects/${encodeURIComponent(n)}/${s==="prs"?"merge_requests":"issues"}?state=opened&per_page=1`}let o;try{o=await t(i,{headers:y(r,e),signal:AbortSignal.timeout(L)})}catch(a){return{error:`could not be reached: ${String(a?.message??a).slice(0,200)}`}}if(!o.ok)return{error:o.status===404?"not found (or not visible to the connector)":`HTTP ${o.status}`};if(r==="gitlab"){let a=Number(o.headers.get("x-total"));return Number.isInteger(a)&&a>=0?a:{error:"no X-Total in the answer"}}let c=await o.json().catch(()=>null),l=Number(c?.total_count);return Number.isInteger(l)&&l>=0?l:{error:"no total_count in the answer"}}}var F=["active","done","dropped"],Q=300,A=500;function ee(e,t=w,r=Date.now()){if(e&&typeof e=="object"&&!Array.isArray(e)&&String(e.kind).trim().toLowerCase()==="count"){let s=f(e);return typeof s=="string"?s:{kind:"count",...s}}let n=C(e,t,r);return typeof n!="string"?n:/^closeWhen(\.kind)? must be/.test(n)?"check must be an object with a kind: url, issue, git-ancestor, reply or count":n.replace(/^closeWhen/,"check")}function U(e){if(!e)return null;try{if(JSON.parse(e)?.kind==="count"){let t=S(e);return t?{kind:"count",...t}:null}}catch{return null}return R(e)}function j(e){return e.kind==="count"?$(e):E(e)}function k(e){return{id:e.id,title:e.title,ownerAgent:e.owner_agent??null,state:e.state,doneWhen:e.done_when??null,check:U(e.check_spec),evidence:e.evidence??null,lastCheck:e.last_check??null,lastCheckAt:e.last_check_at??null,createdAt:e.created_at,updatedAt:e.updated_at,closedAt:e.closed_at??null}}var N=class{constructor(t){this.db=t;t.exec(`
1
+ import{_ as y,aa as v,ga as w,ha as C,ja as E,ka as R,la as I}from"./chunk-YLKEUO6K.js";I();v();var L=1e4,T=["issues","prs","all"],W=/^[\w.-]+(?:\/[\w.-]+)+$/,m=e=>typeof e=="string"?e.trim():"";function f(e){let t=m(e.provider).toLowerCase();if(t!=="github"&&t!=="gitlab")return"count.provider must be github or gitlab";let r=m(e.project),n=r.split("/");if(!W.test(r)||n.some(o=>o==="."||o==="..")||t==="github"&&n.length!==2)return t==="github"?'count.project must be "owner/repo"':'count.project must be "group/project"';let s=(m(e.what)||"issues").toLowerCase();if(!T.includes(s))return`count.what must be one of ${T.join(", ")}`;let i=e.max===void 0||e.max===null||e.max===""?0:Number(e.max);return!Number.isInteger(i)||i<0?"count.max must be a whole number, 0 or more":{provider:t,project:r,what:s,max:i}}function S(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let r=f(t);return typeof r=="string"?null:r}catch{return null}}var _=e=>e==="issues"?"open issues":e==="prs"?"open pull requests":"open issues and pull requests";function $(e){return`${_(e.what)} in ${e.provider} ${e.project} \u2264 ${e.max}`}async function Y(e,t){if(!t)return{verdict:"unverifiable",detail:`no ${e.provider} connector on this node`};try{let r=e.what==="all"?["issues","prs"]:[e.what],n=0;for(let i of r){let o=await t(e.provider,e.project,i);if(typeof o!="number")return{verdict:"unverifiable",detail:`${e.project}: ${o.error}`};n+=o}let s=`${n} ${_(e.what)} in ${e.project}`;return{verdict:n<=e.max?"met":"not_met",detail:s,count:n}}catch(r){return{verdict:"unverifiable",detail:`the count check failed: ${String(r?.message??r).slice(0,200)}`}}}function B(e,t=fetch){return async(r,n,s)=>{let i;if(r==="github"){let a=e.github;if(!a)return{error:"no github connector on this node (channels.github or requests.checkers.github)"};let d=encodeURIComponent(`repo:${n} is:open is:${s==="prs"?"pr":"issue"}`);i=`${a.apiUrl.replace(/\/$/,"")}/search/issues?q=${d}&per_page=1`}else{let a=e.gitlab;if(!a)return{error:"no gitlab connector on this node (channels.gitlab or requests.checkers.gitlab)"};i=`${a.url.replace(/\/$/,"")}/api/v4/projects/${encodeURIComponent(n)}/${s==="prs"?"merge_requests":"issues"}?state=opened&per_page=1`}let o;try{o=await t(i,{headers:y(r,e),signal:AbortSignal.timeout(L)})}catch(a){return{error:`could not be reached: ${String(a?.message??a).slice(0,200)}`}}if(!o.ok)return{error:o.status===404?"not found (or not visible to the connector)":`HTTP ${o.status}`};if(r==="gitlab"){let a=Number(o.headers.get("x-total"));return Number.isInteger(a)&&a>=0?a:{error:"no X-Total in the answer"}}let c=await o.json().catch(()=>null),l=Number(c?.total_count);return Number.isInteger(l)&&l>=0?l:{error:"no total_count in the answer"}}}var F=["active","done","dropped"],Q=300,A=500;function ee(e,t=w,r=Date.now()){if(e&&typeof e=="object"&&!Array.isArray(e)&&String(e.kind).trim().toLowerCase()==="count"){let s=f(e);return typeof s=="string"?s:{kind:"count",...s}}let n=C(e,t,r);return typeof n!="string"?n:/^closeWhen(\.kind)? must be/.test(n)?"check must be an object with a kind: url, issue, git-ancestor, reply or count":n.replace(/^closeWhen/,"check")}function U(e){if(!e)return null;try{if(JSON.parse(e)?.kind==="count"){let t=S(e);return t?{kind:"count",...t}:null}}catch{return null}return R(e)}function j(e){return e.kind==="count"?$(e):E(e)}function k(e){return{id:e.id,title:e.title,ownerAgent:e.owner_agent??null,state:e.state,doneWhen:e.done_when??null,check:U(e.check_spec),evidence:e.evidence??null,lastCheck:e.last_check??null,lastCheckAt:e.last_check_at??null,createdAt:e.created_at,updatedAt:e.updated_at,closedAt:e.closed_at??null}}var N=class{constructor(t){this.db=t;t.exec(`
2
2
  CREATE TABLE IF NOT EXISTS goals (
3
3
  id TEXT PRIMARY KEY,
4
4
  title TEXT NOT NULL,
@@ -17,4 +17,4 @@ import{_ as y,aa as v,ga as w,ha as C,ja as E,ka as R,la as I}from"./chunk-CARVB
17
17
  `)}get(t){let r=this.db.prepare("SELECT * FROM goals WHERE id = ?").get(t);return r?k(r):null}list(t=F,r=200){let n=t.map(()=>"?").join(", ");return this.db.prepare(`SELECT * FROM goals WHERE state IN (${n}) ORDER BY updated_at DESC, rowid DESC LIMIT ?`).all(...t,r).map(k)}ensure(t,r,n){return this.db.prepare("INSERT INTO goals (id, title, owner_agent, state, created_at, updated_at) VALUES (?, ?, ?, 'active', ?, ?) ON CONFLICT(id) DO NOTHING").run(t.id,t.title,r,n,n),this.get(t.id)}upsert(t,r){let n=this.get(t.id);return n?this.db.prepare("UPDATE goals SET title = ?, owner_agent = ?, done_when = ?, check_spec = ?, updated_at = ? WHERE id = ?").run(t.title||n.title,t.ownerAgent!==void 0?t.ownerAgent:n.ownerAgent,t.doneWhen!==void 0?t.doneWhen:n.doneWhen,t.check!==void 0?t.check?JSON.stringify(t.check):null:n.check?JSON.stringify(n.check):null,r,t.id):this.db.prepare("INSERT INTO goals (id, title, owner_agent, state, done_when, check_spec, created_at, updated_at) VALUES (?, ?, ?, 'active', ?, ?, ?, ?)").run(t.id,t.title,t.ownerAgent??null,t.doneWhen??null,t.check?JSON.stringify(t.check):null,r,r),this.get(t.id)}close(t,r,n,s){return this.db.prepare("UPDATE goals SET state = ?, evidence = ?, closed_at = ?, updated_at = ? WHERE id = ? AND state = 'active'").run(r,n?n.slice(0,A):null,s,s,t).changes>0}markChecked(t,r,n){this.db.prepare("UPDATE goals SET last_check = ?, last_check_at = ? WHERE id = ?").run(r.slice(0,A),n,t)}dueChecks(t){return this.db.prepare("SELECT * FROM goals WHERE state = 'active' AND check_spec IS NOT NULL AND (last_check_at IS NULL OR last_check_at <= ?) ORDER BY last_check_at ASC LIMIT 50").all(t).map(k)}};async function te(e,t,r,n,s=()=>{}){let i=[];for(let o of e.dueChecks(n-r*6e4)){let c;try{c=await t(o.check)}catch(l){c={verdict:"unverifiable",detail:String(l?.message??l)}}e.markChecked(o.id,c.detail,n),c.verdict==="met"&&e.close(o.id,"done",`check: ${c.detail}`,n)?(i.push(o.id),s(`[goals] ${o.id} done: ${c.detail}`)):c.verdict==="unverifiable"&&s(`[goals] ${o.id}: check failed: ${c.detail}`)}return i}function ne(e,t){let r=[`[Goal] ${e.title} (${e.id}): ${e.state}${e.ownerAgent?`, owner ${e.ownerAgent}`:""}.`];return e.doneWhen&&r.push(`Done when: ${e.doneWhen}`),e.check&&r.push(`Check: ${j(e.check)}${e.lastCheck?`; last seen: ${e.lastCheck}${e.lastCheckAt?` (${new Date(e.lastCheckAt).toISOString().slice(0,16).replace("T"," ")} UTC)`:""}`:""}`),t&&r.push(`Requests under it: ${t.open} open, ${t.done} done.`),r.join(`
18
18
  `)}var g="Africa/Tunis";function b(e,t=g){let r=Object.fromEntries(new Intl.DateTimeFormat("en-GB",{timeZone:t,hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(new Date(e)).map(s=>[s.type,s.value])),n=(Number(r.hour)%24*3600+Number(r.minute)*60+Number(r.second))*1e3+e%1e3;return e-n}var M=(e,t)=>new Intl.DateTimeFormat("en-GB",{timeZone:t,hour12:!1,hour:"2-digit",minute:"2-digit"}).format(new Date(e));function q(e,t=10){let r=e.replace(/\s+/g," ").trim().split(" ");return r.slice(0,t).join(" ")+(r.length>t?" \u2026":"")}var H=new Set(["issue","idea","approval","erp","card"]);function oe(e,t={}){let r=e.map(n=>{let s=[],i=(o,c)=>{s.some(l=>l.kind===o&&l.ref===c)||s.push({kind:o,ref:c})};for(let o of n.links??[])H.has(o.kind)&&i(o.kind,o.ref);return n.home&&i(n.home.kind,n.home.link),t.hasPlan?.(n.id)&&i("plan",n.id),n.evidence&&i("evidence",n.evidence),{id:n.id,time:M(n.createdAt,t.zone??g),words:q(n.text),state:n.state,owner:n.agentId,landed:s,noHome:s.length===0&&n.state!=="declined"&&n.state!=="dropped"}});return[...r.filter(n=>n.noHome),...r.filter(n=>!n.noHome)]}var x={timeZone:g,days:7},X=90,D=5,G=120,P=(e,t)=>new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).format(new Date(e));function Z(e,t){return{day:P(e,t),start:e,asked:0,done:0,dropped:0,moving:0,waiting:0,stuck:0,rate:null,dropReasons:[],moreReasons:0,resent:0,resentDone:0}}function ie(e,t={}){let r=t.zone??x.timeZone,n=Math.min(Math.max(Math.floor(t.days??x.days),1),X),s=t.now??Date.now(),i=[b(s,r)];for(;i.length<n;)i.unshift(b(i[0]-1,r));let o=i.map(a=>Z(a,r)),c=o.map(()=>new Map),l=0;for(let a of e.flowRows(i[0])){for(;l+1<o.length&&a.createdAt>=o[l+1].start;)l++;let d=o[l];if(d.asked++,a.state==="done")d.done++;else if(a.state==="declined"||a.state==="dropped"){d.dropped++;let p=(a.closeReason??"").replace(/\s+/g," ").trim(),u=p.length>G?`${p.slice(0,G-1)}\u2026`:p||"no reason given";c[l].set(u,(c[l].get(u)??0)+1)}else a.state==="in_progress"||a.state==="waiting_other"?d.moving++:a.state==="waiting_owner"?d.waiting++:a.state==="needs_attention"&&d.stuck++;a.resentAt!==null&&(d.resent++,a.state==="done"&&d.resentDone++)}return o.forEach((a,d)=>{a.rate=a.asked?(a.done+a.dropped)/a.asked:null;let p=[...c[d]].sort((u,h)=>h[1]-u[1]);a.dropReasons=p.slice(0,D).map(([u,h])=>({reason:u,count:h})),a.moreReasons=p.slice(D).reduce((u,[,h])=>u+h,0)}),{zone:r,days:o,today:o[o.length-1]}}var O=e=>e===null?"\u2013":`${Math.round(e*100)}%`;function ce(e){let t=e.today,r=[`Today (${t.day}, ${e.zone}): ${t.asked?`${t.done+t.dropped} of ${t.asked} closed, ${O(t.rate)}`:"nothing asked yet"}.`,` ${t.done} done, ${t.dropped} dropped, ${t.moving} moving, ${t.waiting} waiting on the owner, ${t.stuck} stuck.`+(t.resent?` ${t.resent} resent once on its own, ${t.resentDone} of them done.`:"")];if(t.dropReasons.length){r.push(" Dropped because:");for(let n of t.dropReasons)r.push(` ${n.count} \xD7 ${n.reason}`);t.moreReasons&&r.push(` ${t.moreReasons} more`)}if(e.days.length>1){r.push("","Day asked done dropped moving waiting stuck rate");for(let n of e.days){let s=[n.asked,n.done,n.dropped,n.moving,n.waiting,n.stuck].map(String);r.push(`${n.day} ${s[0].padStart(5)} ${s[1].padStart(4)} ${s[2].padStart(7)} ${s[3].padStart(6)} ${s[4].padStart(7)} ${s[5].padStart(5)} ${O(n.rate).padStart(4)}`)}}return r.join(`
19
19
  `)}export{f as a,S as b,$ as c,Y as d,B as e,Q as f,A as g,ee as h,j as i,N as j,te as k,ne as l,b as m,oe as n,x as o,X as p,ie as q,ce as r};
20
- //# sourceMappingURL=chunk-R6XJWFMC.js.map
20
+ //# sourceMappingURL=chunk-RWZGW2GQ.js.map
@@ -1,4 +1,4 @@
1
- import{Hb as l,Rb as m}from"./chunk-CARVBJB7.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{Hb as l,Rb as m}from"./chunk-YLKEUO6K.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-7GD5GTWC.js.map
4
+ //# sourceMappingURL=chunk-TYKEHZZA.js.map
@@ -1,7 +1,7 @@
1
- import{a as q}from"./chunk-2LJZHKTY.js";import{a as D,b as F}from"./chunk-2YDG5CSS.js";import{A as S,G as H,I as b,K as _,N as M,q as A,x as W}from"./chunk-6ZVVAGTR.js";import{c as P}from"./chunk-LY4G7PCW.js";import{a as L}from"./chunk-OSH2PEBH.js";import{Hb as T,Rb as K,mb as E}from"./chunk-CARVBJB7.js";K();import{Command as V}from"commander";import f from"chalk";import{execFileSync as m}from"child_process";import{accessSync as z,constants as G,existsSync as k,readFileSync as $,readdirSync as N,statSync as Q}from"fs";import{join as B,resolve as w}from"path";import{homedir as Y}from"os";import{createRequire as ee}from"module";var C='run agentx notify "Hello" --title "Test"';function U(t,n){return t==="windows"?{fallback:"Windows PowerShell, and show its name",settings:"Open Settings \u203A System \u203A Notifications, turn notifications on, then turn on AgentX Helper and its banners.",missingFix:`${A(n)} Then ${C}.`,updateFix:`${A(n).replace(/^Put /,"Put a newer ")}`,osName:"Windows"}:{fallback:"Script Editor and show its icon",settings:"Open System Settings \u203A Notifications \u203A AgentX Helper, turn on Allow notifications and choose Banners.",missingFix:`Run agentx desktop install, then ${C} and click Allow.`,updateFix:"Run agentx desktop install to update it.",osName:"macOS"}}async function X(t={}){let n=t.platform??process.platform,e=t.helper===void 0?H():t.helper,i=b({},{platform:n,io:{capture:t.run,helper:e}}),s=i.banner;if(!s)return{state:"unsupported",message:"Desktop banners are only shown on macOS and Windows."};let o=U(i.os,n),a=await s.status();return a==="missing"?{state:"missing",message:`AgentX Helper is not installed, so banners come from ${o.fallback}.`,fix:o.missingFix}:a==="outdated"?{state:"outdated",path:e,message:"AgentX Helper is too old to report whether it may notify.",fix:o.updateFix}:a==="not-asked"?{state:"not-asked",path:e,message:`${o.osName} has not asked yet whether AgentX Helper may notify; banners come from ${o.fallback} until it does.`,fix:`${C[0].toUpperCase()}${C.slice(1)} and click Allow when ${o.osName} asks.`}:a==="not-allowed"?{state:"not-allowed",path:e,message:`${o.osName} does not allow AgentX Helper to notify, so banners come from ${o.fallback}.`,fix:o.settings}:a==="hidden"?{state:"hidden",path:e,message:"AgentX Helper may notify, but its banner style is None, so nothing appears on screen.",fix:o.settings}:{state:"ready",path:e,message:"AgentX Helper posts banners with the AgentX icon."}}async function te(t={}){let n=[];await re(n),ae(n);let e=le(n);return e&&ce(n,e),e&&fe(n,e),e&&he(n,e),e&&me(n,e),e&&ue(n,e),e&&n.push(...ge(e)),e&&we(n,e),e&&await ne(n,e),e&&oe(n,e),e&&await ie(n,e),e&&se(n,e),t.running!==!1&&e&&await ve(n,e),{checks:n,summary:J(n)}}var qe=new V().name("doctor").description("pre-flight health check: Node, config, credentials, daemon").option("--no-running","skip the live daemon probe").option("--json","emit machine-readable JSON (stable shape for CI)").action(async t=>{let{checks:n,summary:e}=await te({running:t.running!==!1});t.json?process.stdout.write(JSON.stringify({checks:n,summary:e},null,2)+`
1
+ import{a as q}from"./chunk-2LJZHKTY.js";import{a as D,b as F}from"./chunk-2YDG5CSS.js";import{A as S,G as H,I as b,K as _,N as M,q as A,x as W}from"./chunk-XGCSWSVD.js";import{c as P}from"./chunk-LY4G7PCW.js";import{a as L}from"./chunk-OSH2PEBH.js";import{Hb as T,Rb as K,mb as E}from"./chunk-YLKEUO6K.js";K();import{Command as V}from"commander";import f from"chalk";import{execFileSync as m}from"child_process";import{accessSync as z,constants as G,existsSync as k,readFileSync as $,readdirSync as N,statSync as Q}from"fs";import{join as B,resolve as w}from"path";import{homedir as Y}from"os";import{createRequire as ee}from"module";var C='run agentx notify "Hello" --title "Test"';function U(t,n){return t==="windows"?{fallback:"Windows PowerShell, and show its name",settings:"Open Settings \u203A System \u203A Notifications, turn notifications on, then turn on AgentX Helper and its banners.",missingFix:`${A(n)} Then ${C}.`,updateFix:`${A(n).replace(/^Put /,"Put a newer ")}`,osName:"Windows"}:{fallback:"Script Editor and show its icon",settings:"Open System Settings \u203A Notifications \u203A AgentX Helper, turn on Allow notifications and choose Banners.",missingFix:`Run agentx desktop install, then ${C} and click Allow.`,updateFix:"Run agentx desktop install to update it.",osName:"macOS"}}async function X(t={}){let n=t.platform??process.platform,e=t.helper===void 0?H():t.helper,i=b({},{platform:n,io:{capture:t.run,helper:e}}),s=i.banner;if(!s)return{state:"unsupported",message:"Desktop banners are only shown on macOS and Windows."};let o=U(i.os,n),a=await s.status();return a==="missing"?{state:"missing",message:`AgentX Helper is not installed, so banners come from ${o.fallback}.`,fix:o.missingFix}:a==="outdated"?{state:"outdated",path:e,message:"AgentX Helper is too old to report whether it may notify.",fix:o.updateFix}:a==="not-asked"?{state:"not-asked",path:e,message:`${o.osName} has not asked yet whether AgentX Helper may notify; banners come from ${o.fallback} until it does.`,fix:`${C[0].toUpperCase()}${C.slice(1)} and click Allow when ${o.osName} asks.`}:a==="not-allowed"?{state:"not-allowed",path:e,message:`${o.osName} does not allow AgentX Helper to notify, so banners come from ${o.fallback}.`,fix:o.settings}:a==="hidden"?{state:"hidden",path:e,message:"AgentX Helper may notify, but its banner style is None, so nothing appears on screen.",fix:o.settings}:{state:"ready",path:e,message:"AgentX Helper posts banners with the AgentX icon."}}async function te(t={}){let n=[];await re(n),ae(n);let e=le(n);return e&&ce(n,e),e&&fe(n,e),e&&he(n,e),e&&me(n,e),e&&ue(n,e),e&&n.push(...ge(e)),e&&we(n,e),e&&await ne(n,e),e&&oe(n,e),e&&await ie(n,e),e&&se(n,e),t.running!==!1&&e&&await ve(n,e),{checks:n,summary:J(n)}}var qe=new V().name("doctor").description("pre-flight health check: Node, config, credentials, daemon").option("--no-running","skip the live daemon probe").option("--json","emit machine-readable JSON (stable shape for CI)").action(async t=>{let{checks:n,summary:e}=await te({running:t.running!==!1});t.json?process.stdout.write(JSON.stringify({checks:n,summary:e},null,2)+`
2
2
  `):ke(n),process.exit(e.errors>0?1:0)});async function ne(t,n,e=X){if(!_(n.notifications?.local).banner)return;let i=await e();i.state!=="unsupported"&&t.push({severity:i.state==="ready"?"ok":"warn",group:"Notifications",title:i.message,detail:i.path,fix:i.fix})}async function ie(t,n,e){let i;try{i=await(e??b(n)).describe()}catch(o){t.push({severity:"warn",group:"Native",title:"Native apps: could not be read",detail:o?.message??String(o)});return}let s=["tasks","notes","banner","sound","focus"].filter(o=>i[o]);t.push({severity:"ok",group:"Native",title:i.os==="none"?"Native apps: none on this machine":`Native apps (${i.os}): ${s.join(", ")||"nothing available"}`,detail:i.problems.join(" ")||void 0})}function se(t,n,e=process.cwd(),i=b(n)){let s=n.native?.mirror;if(!s?.enabled)return;if(!i.tasks){t.push({severity:"warn",group:"Native",title:"Reminders mirror is on, but this machine has no task app",detail:"native.mirror.enabled is set; nothing is mirrored here.",fix:"Turn it on on the machine that holds the owner's cards (the Mac), or set native.mirror.enabled to false here."});return}let o=M(e),a=Object.values(o.items),l=a.filter(g=>g.state==="open").length,p=a.filter(g=>g.state==="failed").length;t.push({severity:o.lastError||p?"warn":"ok",group:"Native",title:`Reminders mirror: ${l} open in "${s.list}"${p?`, ${p} could not be added`:""}`,detail:o.lastError?`Last error ${o.lastError.at}: ${o.lastError.message}`:void 0,fix:o.lastError?"Run remindctl status, and allow Reminders for the app that runs the daemon in System Settings \u203A Privacy & Security \u203A Reminders.":void 0})}function oe(t,n,e=process.platform,i=s=>{try{return z(s,G.X_OK),!0}catch{return!1}}){let s=n.reminders;if(!s?.enabled)return;if(e!=="darwin"){t.push({severity:"warn",group:"Reminders",title:"Reminders hand-back unavailable on this machine",detail:"reminders.enabled is set, but Apple Reminders exists only on macOS. The daemon starts without it.",fix:"Set reminders.enabled to false here, or enable it on the Mac node instead."});return}let o=s.command||"remindctl",a=o.includes("/")?i(o)?o:null:S(o,process.env.PATH||"",i);t.push(a?{severity:"ok",group:"Reminders",title:`Watching ${(s.lists||[]).join(", ")} for due reminders`,detail:a}:{severity:"fail",group:"Reminders",title:`${o} not found`,detail:"The daemon reads Apple Reminders through remindctl.",fix:"brew install steipete/tap/remindctl, or set reminders.command to its full path."})}async function re(t){let n=L(process.versions.node);t.push({severity:n?"ok":"fail",group:"Environment",title:`Node.js ${process.versions.node}`,detail:n?void 0:"AgentX requires Node 22.19 or newer, up to Node 26.",fix:n?void 0:"Install Node 22 (nvm install 22 && nvm use 22)"});let e=l=>{try{return m(process.platform==="win32"?"where":"which",[l],{encoding:"utf-8"}).trim().split(`
3
3
  `)[0]}catch{return null}},i=e("npm");t.push({severity:i?"ok":"fail",group:"Environment",title:i?"npm on PATH":"npm not found",detail:i||void 0});let s=e("claude");if(s){let l;try{l=m("claude",["--version"],{encoding:"utf-8",timeout:3e3}).trim()}catch{}t.push({severity:"ok",group:"Environment",title:`claude CLI ${l||"installed"}`,detail:s})}else t.push({severity:"warn",group:"Environment",title:"claude CLI not on PATH",detail:"Only required for agents on the claude-code tier.",fix:"See https://docs.anthropic.com/en/docs/claude-code"});let o=e("codex");if(o){let l;try{l=m("codex",["--version"],{encoding:"utf-8",timeout:3e3}).trim()}catch{}t.push({severity:"ok",group:"Environment",title:`codex CLI ${l||"installed"}`,detail:o})}else t.push({severity:"warn",group:"Environment",title:"codex CLI not on PATH",detail:"Only required for agents on the codex-cli tier.",fix:"Install with `npm i -g @openai/codex`."});let a=e("opencode");if(a){let l;try{l=m("opencode",["--version"],{encoding:"utf-8",timeout:3e3}).trim()}catch{}t.push({severity:"ok",group:"Environment",title:`opencode CLI ${l||"installed"}`,detail:a})}else t.push({severity:"warn",group:"Environment",title:"opencode CLI not on PATH",detail:"Only required for agents on the opencode tier.",fix:"Install from https://opencode.ai/docs/."});try{ee(import.meta.url)("better-sqlite3"),t.push({severity:"ok",group:"Environment",title:`better-sqlite3 loads for Node ${process.version}`,detail:`NODE_MODULE_VERSION ${process.versions.modules}`})}catch(l){t.push({severity:"fail",group:"Environment",title:"better-sqlite3 native binding does not load",detail:l?.message??String(l),fix:`Run "pnpm rebuild better-sqlite3" with the same Node used by the daemon (${process.version}, modules ${process.versions.modules}).`})}}function ae(t){if(process.platform!=="darwin")return;let n=B(Y(),"Library/LaunchAgents"),e=[];try{e=N(n).filter(s=>/agentx\.voice.*\.plist$/.test(s))}catch{return}let i=s=>{try{return z(s,G.X_OK),!0}catch{return!1}};for(let s of e){let o=W($(B(n,s),"utf-8")),a=S("ffmpeg",o,i);t.push(a?{severity:"ok",group:"Desktop",title:"ffmpeg reachable by the desktop app",detail:`${a} (${s})`}:{severity:"warn",group:"Desktop",title:"ffmpeg not reachable by the desktop app",detail:`Local Whisper transcription fails without it. ${s} sets PATH to ${o}.`,fix:"Install ffmpeg (brew install ffmpeg), then rerun agentx desktop install."})}}function le(t){let n=w(process.cwd(),"agentx.json");if(!k(n))return t.push({severity:"fail",group:"Config",title:"agentx.json not found",detail:`Looked in ${n}`,fix:"Run `agentx setup` to create one via the web wizard."}),null;let e;try{e=JSON.parse($(n,"utf-8"))}catch(a){return t.push({severity:"fail",group:"Config",title:"agentx.json is not valid JSON",detail:a.message}),null}try{T(n),t.push({severity:"ok",group:"Config",title:`agentx.json valid (${Object.keys(e.agents||{}).length} agents, ${Object.keys(e.crons||{}).length} schedules)`})}catch(a){t.push({severity:"fail",group:"Config",title:"agentx.json failed schema validation",detail:a.message,fix:"Open /admin \u2192 Advanced tab to edit and re-save."})}let i=Object.entries(e.agents||{}).filter(([,a])=>a.tier==="claude-code");i.length>0&&((()=>{try{return m(process.platform==="win32"?"where":"which",["claude"],{stdio:"ignore"}),!0}catch{return!1}})()||t.push({severity:"fail",group:"Config",title:`${i.length} agent(s) use claude-code tier but claude CLI is missing`,detail:i.map(([l])=>l).join(", "),fix:"Install Claude Code (https://docs.anthropic.com/en/docs/claude-code) or switch these agents to tier=sdk."}));let s=Object.entries(e.agents||{}).filter(([,a])=>a.tier==="codex-cli");s.length>0&&((()=>{try{return m(process.platform==="win32"?"where":"which",["codex"],{stdio:"ignore"}),!0}catch{return!1}})()||t.push({severity:"fail",group:"Config",title:`${s.length} agent(s) use codex-cli tier but codex CLI is missing`,detail:s.map(([l])=>l).join(", "),fix:"Install Codex CLI with `npm i -g @openai/codex` or switch these agents to tier=claude-code."}));let o=Object.entries(e.agents||{}).filter(([,a])=>a.tier==="opencode");return o.length>0&&((()=>{try{return m(process.platform==="win32"?"where":"which",["opencode"],{stdio:"ignore"}),!0}catch{return!1}})()||t.push({severity:"fail",group:"Config",title:`${o.length} agent(s) use opencode tier but OpenCode CLI is missing`,detail:o.map(([l])=>l).join(", "),fix:"Install OpenCode from https://opencode.ai/docs/ or switch these agents to another tier."})),e}function ce(t,n){let e=new Set;if(j(n,e),e.size===0){t.push({severity:"ok",group:"Secrets",title:"No ${VAR} references in agentx.json"});return}let i=R(),s=[],o=[];for(let a of e){let l=process.env[a]??i[a];l===void 0?s.push(a):(!l.trim()||/^["']?\s*["']?$/.test(l))&&o.push(a)}s.length===0&&o.length===0?t.push({severity:"ok",group:"Secrets",title:`${e.size} env reference(s) resolved`}):(s.length>0&&t.push({severity:"fail",group:"Secrets",title:`${s.length} env var(s) referenced in agentx.json but missing`,detail:s.join(", "),fix:`Add to .env \u2014 e.g. ${s[0]}=<value>`}),o.length>0&&t.push({severity:"warn",group:"Secrets",title:`${o.length} env var(s) set but empty`,detail:o.join(", ")}))}function R(){let t=w(process.cwd(),".env"),n={};if(k(t))for(let e of $(t,"utf-8").split(/\r?\n/)){let i=e.match(/^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*)$/i);i&&(n[i[1]]=i[2])}return n}function de(t,n){let e="With a shared token this node cannot tell which peer is calling. For example, closing an approval card forwarded from that peer is refused, and its stop/resume signals are judged as the owner's.",i="Give this pair a token of its own: set the same new value as mesh.peers[].token here and on the peer.",s=[];for(let o of t){let a=(o.token??"").trim();a?n&&a===n&&s.push({severity:"warn",group:"Mesh",title:`mesh peer "${o.name}" uses this node's own MESH_TOKEN`,detail:e,fix:i}):s.push({severity:"warn",group:"Mesh",title:`mesh peer "${o.name}" has no token; calls to it use the shared MESH_TOKEN`,detail:e,fix:i})}return t.length>0&&s.length===0&&s.push({severity:"ok",group:"Mesh",title:`${t.length} mesh peer(s), each with a token of its own`}),s}function ue(t,n){t.push(...pe(n))}function pe(t,n=process.env,e=R()){let i=a=>(n[a]||e[a]||"").trim(),s=a=>typeof a=="string"?a.replace(/\$\{([A-Z_][A-Z0-9_]*)\}/gi,(l,p)=>i(p)):void 0,o=(t.mesh?.peers??[]).filter(a=>typeof a?.name=="string").map(a=>({name:a.name,token:s(a.token)}));return de(o,i("MESH_TOKEN")||void 0)}function ge(t,n=process.env,e=R()){let i=[],s=0;for(let[o,a]of Object.entries(t.agents||{}))for(let[l,p]of Object.entries(a?.mcp||{})){let g=P(p??{});if(g.length===0)continue;s++;let y=g.filter(r=>!(n[r]||e[r]||"").trim());y.length>0&&i.push({severity:"fail",group:"Secrets",title:`MCP server "${l}" of ${o}: header variable(s) not set`,detail:y.join(", "),fix:`Add to .env \u2014 e.g. ${y[0]}=<value>, then restart the daemon`})}return s>0&&i.length===0&&i.push({severity:"ok",group:"Secrets",title:`${s} MCP server(s) with header variables, all set`}),i}function j(t,n){if(typeof t=="string")for(let e of t.matchAll(/\$\{([A-Z_][A-Z0-9_]*)\}/g))n.add(e[1]);else if(Array.isArray(t))for(let e of t)j(e,n);else if(t&&typeof t=="object")for(let e of Object.values(t))j(e,n)}function fe(t,n){let e=[];for(let[i,s]of Object.entries(n.agents||{})){if(!s.workspace)continue;let o=s.workspace.startsWith("/")?s.workspace:w(process.cwd(),s.workspace);try{Q(o).isDirectory()||e.push(`${i}: ${o} (exists but not a directory)`)}catch{e.push(`${i}: ${o}`)}}e.length===0?t.push({severity:"ok",group:"Workspaces",title:"All agent workspace folders exist"}):t.push({severity:"warn",group:"Workspaces",title:`${e.length} agent workspace(s) missing`,detail:e.join(`
4
4
  `),fix:"The daemon will create missing folders on first task, but you won't see CLAUDE.md / skills until you populate them."})}function he(t,n){let e=/\$\{[A-Za-z_][A-Za-z0-9_]*\}/g,i=[];for(let[s,o]of Object.entries(n.agents||{})){if(!o.workspace)continue;let a=o.workspace.startsWith("/")?o.workspace:w(process.cwd(),o.workspace);for(let l of["settings.json","settings.local.json"]){let p=w(a,".claude",l);if(!k(p))continue;let g;try{g=JSON.parse($(p,"utf-8"))}catch(u){i.push({severity:"fail",agent:s,msg:`${l}: JSON parse error \u2014 ${u.message}`});continue}let y=g.env||{};for(let[u,h]of Object.entries(y)){if(typeof h!="string")continue;let c=h.match(e);c&&i.push({severity:"fail",agent:s,msg:`${l} env.${u} contains unexpanded ${[...new Set(c)].join(",")} \u2014 Claude Code does NOT expand \${VAR} in settings.json (use a fully-literal value)`})}let r=y.PATH;if(typeof r=="string"){let u=r.split(":").filter(Boolean);u.includes("/usr/bin")||i.push({severity:"fail",agent:s,msg:`${l} env.PATH missing /usr/bin \u2014 cat/head/sh/which will fail`}),u.includes("/bin")||i.push({severity:"fail",agent:s,msg:`${l} env.PATH missing /bin \u2014 ls/cp/mv will fail`})}let d=g.permissions;if(d&&typeof d=="object"&&"allow"in d){let u=d.allow,h=d.deny;Array.isArray(u)&&u.length===0&&Array.isArray(h)&&h.length>0&&i.push({severity:"warn",agent:s,msg:`${l} permissions.allow is explicitly [] with ${h.length} deny rules \u2014 agent may be locked out (omit the key to use defaults instead)`})}}}if(i.length===0){t.push({severity:"ok",group:"Workspace settings",title:`All ${Object.keys(n.agents||{}).length} agent .claude/settings.json files clean`});return}for(let s of i)t.push({severity:s.severity,group:"Workspace settings",title:`${s.agent}: ${s.msg}`,fix:s.severity==="fail"?"Edit .claude/settings.json \u2014 replace ${VAR} with the literal value or omit the key to inherit.":"Either remove the empty allow list or populate it."})}function me(t,n){let e=n.webhooks??[],i=[],s=w(process.cwd(),n.workflows?.dir||".agentx/workflows"),o=new Set;try{if(k(s))for(let r of N(s))r.endsWith(".json")&&!r.startsWith("_")&&!r.endsWith(".disabled.json")&&o.add(r.replace(/\.json$/,""))}catch{}let a=new Set(["github","gitlab"]);for(let r of e){if(!r.enabled||!a.has(r.source))continue;!(r.triggers&&Object.keys(r.triggers).length>0)&&!r.defaultWorkflow&&i.push({severity:"warn",title:`webhook "${r.id}" (${r.source} -> ${r.agentId}) has no triggers map; every event-type collapses to the bound agent`,fix:'Add a triggers map: { "issues.opened": "wf-id", "pull_request.synchronize": "wf-id" } \u2014 or set defaultWorkflow.'})}for(let r of e)if(!(!r.enabled||!r.triggers)){for(let[d,u]of Object.entries(r.triggers))o.size>0&&!o.has(u)&&i.push({severity:"fail",title:`webhook "${r.id}".triggers["${d}"] -> "${u}" \u2014 no such workflow under ${n.workflows?.dir||".agentx/workflows"}`,fix:"Create the workflow file or fix the id in agentx.json"});r.defaultWorkflow&&o.size>0&&!o.has(r.defaultWorkflow)&&i.push({severity:"fail",title:`webhook "${r.id}".defaultWorkflow -> "${r.defaultWorkflow}" \u2014 no such workflow`,fix:"Create the workflow file or fix the id in agentx.json"})}try{if(k(s)){for(let r of N(s))if(!(!r.endsWith(".json")||r.startsWith("_")||r.endsWith(".disabled.json")))try{let d=JSON.parse($(w(s,r),"utf-8"));d?.status==="active"&&d?.state==="quarantined"&&i.push({severity:"warn",title:`workflow "${d.id??r}" is status=active but state=quarantined \u2014 it looks live but will never dispatch`,fix:'Resolve the conflict the detector flagged, then set state back to "active" (or set status to "review" while parked).'})}catch{}}}catch{}let l=new Set((n.mesh?.peers??[]).map(r=>r.name));for(let r of e)!r.enabled||!r.node||l.has(r.node)||i.push({severity:"fail",title:`webhook "${r.id}" routes to mesh peer "${r.node}" which is not in mesh.peers`,fix:"Add the peer to mesh.peers or remove the node field on the webhook."});let p=new Map;for(let r of e){if(!r.enabled)continue;let d=`${r.source}:${r.agentId}`,u=p.get(d);u?i.push({severity:"warn",title:`webhook entries "${u}" and "${r.id}" both enabled for ${r.source} -> ${r.agentId}; only the first is dispatched`,fix:"Disable one entry, or merge their triggers maps into a single entry."}):p.set(d,r.id)}let g=new Set(Object.keys(n.agents??{}));for(let r of n.channels?.gitlab?.agentMappings??[])if(r?.agentId){if(r.node){l.has(r.node)||i.push({severity:"fail",title:`gitlab.agentMappings entry agentId="${r.agentId}" routes to mesh peer "${r.node}" which is not in mesh.peers`,fix:"Add the peer to mesh.peers or drop the node field on the mapping."});continue}g.has(r.agentId)||i.push({severity:"warn",title:`gitlab.agentMappings entry agentId="${r.agentId}" \u2014 no such agent in agents.* (and no node field, so it's not a cross-mesh route)`,fix:'Add the agent to agents.*, set node:"<peer>" if the agent lives remotely, or remove the mapping.'})}for(let[r,d]of Object.entries(n.channels?.telegram?.accounts??{}))d.agentBinding?g.has(d.agentBinding)||i.push({severity:"fail",title:`telegram account "${r}".agentBinding -> "${d.agentBinding}" \u2014 no such agent in agents.*`,fix:"Fix the agentBinding or define the agent in agents.*."}):i.push({severity:"fail",title:`telegram account "${r}" has no agentBinding; every DM to this bot will drop`,fix:"Set agentBinding to a valid agent id."});let y=new Set(["telegram-bot","whatsapp","slack-bot","discord-bot","gitlab-user","github-user","gmail","hotmail","smtp","hubspot","salesforce","pipedrive","odoo","trello","linear","asana","jira","notion","stripe","sentry","vercel","twilio","custom",...E,...Object.keys(D)]);for(let[r,d]of Object.entries(n.agents??{})){let u=d.integrations??[];if(!u.length)continue;let h=new Set;for(let c of u){let O=`${c.kind}::${c.label}`;h.has(O)&&i.push({severity:"warn",title:`agents.${r}.integrations: duplicate (${c.kind}, ${c.label})`,fix:"Remove the duplicate or rename one. (kind, label) must be unique per agent."}),h.add(O),y.has(c.kind)||i.push({severity:"warn",title:`agents.${r}.integrations: unknown kind "${c.kind}" on integration "${c.label}"`,fix:'Use a canonical kind from INTEGRATION_KINDS, or "custom" for ad-hoc services.'});let Z=c.credentials||{};for(let[x,v]of Object.entries(Z))typeof v=="string"&&/^[A-Z][A-Z0-9_]*$/.test(v)&&!process.env[v]&&i.push({severity:"warn",title:`agents.${r}.integrations[${c.kind}/${c.label}].${x} -> $${v} but env var is unset (in this shell)`,fix:`Set ${v} on the daemon environment. The daemon's process.env is what matters; this warning fires from your local shell.`});let I=c.enabled===!1?null:F(c.kind);if(I){let x=q(r,c,I);for(let v of x.problems)/env var .* is unset/.test(v)||i.push({severity:"warn",title:`agents.${r}.integrations[${c.kind}/${c.label}]: ${v}`,fix:x.connected?`Run agentx agent integrations status ${r} for details.`:`Run agentx agent integrations connect ${r} ${c.kind}${c.label!==c.kind?` --label "${c.label}"`:""}.`})}}}if(i.length===0){t.push({severity:"ok",group:"Routing",title:`${e.length} webhook(s), ${Object.keys(n.channels?.telegram?.accounts??{}).length} telegram account(s) \u2014 all routing references resolve`});return}for(let r of i)t.push({severity:r.severity,group:"Routing",title:r.title,fix:r.fix})}function ye(t){return typeof t?.canMeasure!="boolean"?null:t.canMeasure?{severity:"ok",group:"Runtime",title:"Daemon finds ffmpeg to measure phone recordings"}:{severity:"warn",group:"Runtime",title:t.allowUnmeasured?"Daemon can't find ffmpeg: phone recordings go unmeasured (voice.allowUnmeasured)":"Daemon can't find ffmpeg: phone voice input is refused",fix:"Install ffmpeg (brew install ffmpeg / sudo apt install ffmpeg), or set AGENTX_FFMPEG in the service's environment. The daemon's PATH is shorter than your shell's."}}async function ve(t,n){let e=n.dashboard?.daemonUrl?.replace(/\/+$/,"")||"http://127.0.0.1:18800",i={};n.dashboard?.token&&(i.Authorization=`Bearer ${n.dashboard.token}`);try{let s=new AbortController,o=setTimeout(()=>s.abort(),2e3),a=await fetch(e+"/health",{headers:i,signal:s.signal});if(clearTimeout(o),!a.ok){t.push({severity:"warn",group:"Runtime",title:`Daemon responded ${a.status}`,detail:e});return}let l=await a.json();t.push({severity:"ok",group:"Runtime",title:`Daemon healthy \u2014 ${l.agents?.length??0} agents live, uptime ${Math.round((l.uptime??0)/60)}m`,detail:e});let p=ye(l.voice);p&&t.push(p)}catch{t.push({severity:"warn",group:"Runtime",title:"Daemon not reachable (not running?)",detail:e,fix:"Run `agentx daemon start`. Skip this check with `agentx doctor --no-running`."})}}function we(t,n){let e=Object.entries(n.agents||{}).filter(([,s])=>s?.codegraph===!0&&(s.tier==="claude-code"||s.tier==="codex-cli"));if(e.length===0)return;let i=null;try{i=m(process.platform==="win32"?"where":"which",["codegraph"],{encoding:"utf-8"}).trim().split(`
5
5
  `)[0]||null}catch{i=null}if(i){let s;try{s=m("codegraph",["--version"],{encoding:"utf-8",timeout:3e3}).trim()}catch{}t.push({severity:"ok",group:"CodeGraph",title:`codegraph CLI ${s||"installed"}`,detail:i})}else t.push({severity:"fail",group:"CodeGraph",title:"codegraph CLI not on PATH",detail:`${e.length} agent(s) have codegraph:true but the binary isn't available.`,fix:"Install with `npm i -g @colbymchenry/codegraph`."});for(let[s,o]of e){if(!o.workspace||!k(o.workspace)){t.push({severity:"warn",group:"CodeGraph",title:`${s}: workspace missing`,detail:`Workspace path ${o.workspace} does not exist \u2014 codegraph will skip this agent.`});continue}let a=w(o.workspace,".codegraph","codegraph.db");k(a)?t.push({severity:"ok",group:"CodeGraph",title:`${s}: index present`,detail:a}):t.push({severity:"warn",group:"CodeGraph",title:`${s}: index not built yet`,detail:".codegraph/ missing \u2014 daemon will background-index this workspace on next boot.",fix:`Run \`codegraph init --index ${o.workspace}\` to build it now.`})}}function J(t){return{errors:t.filter(n=>n.severity==="fail").length,warnings:t.filter(n=>n.severity==="warn").length,ok:t.filter(n=>n.severity==="ok").length}}function ke(t){console.log(),console.log(f.bold(" agentx doctor")),console.log();let n=new Map;for(let i of t)n.has(i.group)||n.set(i.group,[]),n.get(i.group).push(i);for(let[i,s]of n){console.log(f.bold(" "+i));for(let o of s){let a=o.severity==="ok"?f.green("\u2713"):o.severity==="warn"?f.yellow("!"):f.red("\u2717");console.log(` ${a} ${o.title}`),o.detail&&console.log(f.dim(" "+o.detail.replace(/\n/g,`
6
6
  `))),o.fix&&console.log(f.dim(" \u2192 "+o.fix))}console.log()}let e=J(t);e.errors>0?console.log(f.red.bold(` ${e.errors} error${e.errors===1?"":"s"}`)+(e.warnings?f.yellow(`, ${e.warnings} warning${e.warnings===1?"":"s"}`):"")+`. Fix the error${e.errors===1?"":"s"} and rerun.`):e.warnings>0?console.log(f.yellow.bold(` ${e.warnings} warning${e.warnings===1?"":"s"}.`)+f.dim(" Review but not blocking.")):console.log(f.green.bold(` All checks passed (${e.ok}).`)),console.log()}export{X as a,te as b,qe as c,ne as d,ie as e,se as f,oe as g,de as h,pe as i,ge as j,ye as k};
7
- //# sourceMappingURL=chunk-37EABHYL.js.map
7
+ //# sourceMappingURL=chunk-UF3D5LFH.js.map
@@ -1,4 +1,4 @@
1
- import{b as W,c as K}from"./chunk-VALKXSXZ.js";import{h as z,j as Z}from"./chunk-3UOTLMXD.js";import{a as I,b as V}from"./chunk-FCPTN6NF.js";import{a as H,b as De}from"./chunk-7I7IEX4S.js";import{d as Y}from"./chunk-QIJLFPWE.js";import{execFile as tt}from"child_process";import{writeFileSync as Ee,mkdirSync as P,existsSync as D,readFileSync as nt}from"fs";import{resolve as _}from"path";var Ne=["off","shadow","authoritative"],xe={telegram:"INTENT_LEDGER_MODE_TELEGRAM",slack:"INTENT_LEDGER_MODE_SLACK",whatsapp:"INTENT_LEDGER_MODE_WHATSAPP",discord:"INTENT_LEDGER_MODE_DISCORD",gitlab:"INTENT_LEDGER_MODE_GITLAB",github:"INTENT_LEDGER_MODE_GITHUB",workflow:"INTENT_LEDGER_MODE_WORKFLOW",cron:"INTENT_LEDGER_MODE_CRON",mesh:"INTENT_LEDGER_MODE_MESH"},Se="INTENT_LEDGER_MODE";function q(n,e=process.env){let t=Q(e[xe[n]]);if(t)return t;let r=Q(e[Se]);return r||"off"}function Q(n){if(typeof n!="string")return null;let e=n.trim().toLowerCase();return Ne.includes(e)?e:null}V();import we from"better-sqlite3";import{existsSync as ut,mkdirSync as $e}from"fs";import{dirname as Oe,resolve as Le}from"path";var T=class{db;path;constructor(e={}){this.path=Le(process.cwd(),e.path??".agentx/intent/ledger.sqlite"),$e(Oe(this.path),{recursive:!0}),this.db=new we(this.path),this.db.pragma("journal_mode = WAL"),this.db.pragma("synchronous = NORMAL"),this.db.pragma("foreign_keys = ON"),Ce(this.db)}close(){this.db.close()}schemaVersion(){return this.db.prepare("SELECT MAX(v) AS v FROM schema_version").get().v??0}recordEvent(e){if(e.sourceEventId!==null){let r=this.findEventBySourceId(e.source,e.sourceEventId);if(r)return r}let t={id:e.id??I(e.ts),ts:e.ts,source:e.source,sourceEventId:e.sourceEventId,project:e.project,subject:e.subject,intent:e.intent,rawJson:e.rawJson};return this.db.prepare(`INSERT INTO intent_events (id, ts, source, source_event_id, project, subject, intent, raw_json)
1
+ import{b as W,c as K}from"./chunk-RHXBLKBW.js";import{h as z,j as Z}from"./chunk-3UOTLMXD.js";import{a as I,b as V}from"./chunk-FCPTN6NF.js";import{a as H,b as De}from"./chunk-7I7IEX4S.js";import{d as Y}from"./chunk-QIJLFPWE.js";import{execFile as tt}from"child_process";import{writeFileSync as Ee,mkdirSync as P,existsSync as D,readFileSync as nt}from"fs";import{resolve as _}from"path";var Ne=["off","shadow","authoritative"],xe={telegram:"INTENT_LEDGER_MODE_TELEGRAM",slack:"INTENT_LEDGER_MODE_SLACK",whatsapp:"INTENT_LEDGER_MODE_WHATSAPP",discord:"INTENT_LEDGER_MODE_DISCORD",gitlab:"INTENT_LEDGER_MODE_GITLAB",github:"INTENT_LEDGER_MODE_GITHUB",workflow:"INTENT_LEDGER_MODE_WORKFLOW",cron:"INTENT_LEDGER_MODE_CRON",mesh:"INTENT_LEDGER_MODE_MESH"},Se="INTENT_LEDGER_MODE";function q(n,e=process.env){let t=Q(e[xe[n]]);if(t)return t;let r=Q(e[Se]);return r||"off"}function Q(n){if(typeof n!="string")return null;let e=n.trim().toLowerCase();return Ne.includes(e)?e:null}V();import we from"better-sqlite3";import{existsSync as ut,mkdirSync as $e}from"fs";import{dirname as Oe,resolve as Le}from"path";var T=class{db;path;constructor(e={}){this.path=Le(process.cwd(),e.path??".agentx/intent/ledger.sqlite"),$e(Oe(this.path),{recursive:!0}),this.db=new we(this.path),this.db.pragma("journal_mode = WAL"),this.db.pragma("synchronous = NORMAL"),this.db.pragma("foreign_keys = ON"),Ce(this.db)}close(){this.db.close()}schemaVersion(){return this.db.prepare("SELECT MAX(v) AS v FROM schema_version").get().v??0}recordEvent(e){if(e.sourceEventId!==null){let r=this.findEventBySourceId(e.source,e.sourceEventId);if(r)return r}let t={id:e.id??I(e.ts),ts:e.ts,source:e.source,sourceEventId:e.sourceEventId,project:e.project,subject:e.subject,intent:e.intent,rawJson:e.rawJson};return this.db.prepare(`INSERT INTO intent_events (id, ts, source, source_event_id, project, subject, intent, raw_json)
2
2
  VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(t.id,t.ts,t.source,t.sourceEventId,t.project,t.subject,t.intent,t.rawJson),t}findEventBySourceId(e,t){let r=this.db.prepare(`SELECT id, ts, source, source_event_id, project, subject, intent, raw_json
3
3
  FROM intent_events WHERE source = ? AND source_event_id = ?`).get(e,t);return r?j(r):null}getEventById(e){let t=this.db.prepare(`SELECT id, ts, source, source_event_id, project, subject, intent, raw_json
4
4
  FROM intent_events WHERE id = ?`).get(e);return t?j(t):null}recordDecision(e){this.db.prepare(`INSERT INTO intent_decisions (event_id, decided_at, decided_by, agent_id, outcome, reason)
@@ -138,8 +138,8 @@ ${e}`:e}function X(n,e){return L(n.report,n.expectExitZero?A(e):e)}var it=2*60*6
138
138
  ${l}`:""}`,rt),a=f===0,a||(g=`exit ${f}${c?`
139
139
  ${c}`:""}`)}catch(u){g=u?.message??String(u)}let d={jobId:e.id,startedAt:t,completedAt:new Date,success:a,response:c||void 0,error:g,duration:Date.now()-t.getTime(),isRetry:r,retryAttempt:i,...o?{fired:!0}:{},...a&&L(e.report,c)?{quiet:!0}:{}};if(!a){await this.recordFailure(e,g??"command failed","Command job"),this.logRun(d),o||this.scheduleRetry(e.id,i);return}e.consecutiveErrors>0&&this.log(`Job "${e.id}" recovered after ${e.consecutiveErrors} failure(s)`),e.consecutiveErrors=0,e.lastSuccess=new Date,e.lastError=void 0,e.retryPending=!1,this.log(`Command job "${e.id}" completed in ${d.duration}ms`),this.logRun(d),await this.deliverResult(e,c,t),o||this.scheduleNext(e.id)}async executeJob(e,t=0,r){let i=this.jobs.get(e);if(!i||!this.running)return;let o=t>0,s=r?.firedAt??new Date;if(this.hooks?.has("pre:cron-run")){let u=await this.hooks.execute("pre:cron-run",{event:"pre:cron-run",jobId:e,agent:i.agent,prompt:i.prompt});if(u.blocked){this.log(`Job "${e}" blocked by hook: ${u.message}`),this.recordCronDecisionInLedger(e,i.agent,s,{agentId:null,outcome:"halted",reason:`pre-hook blocked: ${u.message??""}`.trim()}),r||this.scheduleNext(e);return}}let a=this.goalGate(i);if(a.skip){this.recordGoalHalt(i,s),r||this.scheduleNext(e);return}this.log((r?"[fired] ":"")+(i.command?.trim()?`${o?`[retry ${t}] `:""}Executing job "${e}" -> command`:`${o?`[retry ${t}] `:""}Executing job "${e}" -> agent "${i.agent}"`));let c=s;if(i.lastRun=c,i.totalRuns++,i.command?.trim()){await this.executeCommandJob(i,c,o,t,r);return}let g=this.recordCronDecisionInLedger(e,i.agent,s,{agentId:i.agent,outcome:"dispatched",reason:r?"fired on demand":o?`retry ${t}`:null}),d=Ie(i.timeout);try{let u=this.wikiNotesInbox(i,c),h={message:_e(k(O(ye(u.block,F(a.brief,r?le(i.prompt,r.payload):i.prompt)),i.report),i.expectExitZero),i.maxOutputTokens),agentId:i.agent,model:i.model,autonomy:i.autonomy,timeoutMinutes:d/60,intentRef:g,context:ve(e,i)},l=await this.registry.execute(h),f=l.error||C(i.expectExitZero,l.content),m={jobId:e,startedAt:c,completedAt:new Date,success:!f,response:l.content,error:f,duration:l.duration||Date.now()-c.getTime(),isRetry:o,retryAttempt:t,timeout:d,...r?{fired:!0}:{},...u.ids.length?{wikiNotes:u.ids}:{},...Te(h,l),...l.autonomy?{autonomy:l.autonomy}:{},...l.autonomyBlocks?.length?{autonomyBlocks:l.autonomyBlocks}:{},...!f&&X(i,l.content)?{quiet:!0}:{}};if(m.autonomyBlocks&&this.log(`Job "${e}" (autonomy ${m.autonomy}): ${m.autonomyBlocks.length} action(s) blocked: ${m.autonomyBlocks.map(E=>E.ruleId).join(", ")}`),f){await this.recordFailure(i,f),this.logRun(m),r||this.scheduleRetry(e,t);return}else i.consecutiveErrors>0&&this.log(`Job "${e}" recovered after ${i.consecutiveErrors} failure(s)`),i.consecutiveErrors=0,i.lastSuccess=new Date,i.lastError=void 0,i.retryPending=!1,this.log(`Job "${e}" completed in ${m.duration}ms`);let p=i.expectExitZero?A(l.content):l.content,v=i.requireSources&&p&&!m.quiet?he(p):void 0;v?.unsourced&&(m.unsourced=v.unsourced,this.log(`Job "${e}": ${v.unsourced} answer line(s) without a source`)),this.logRun(m),await this.deliverResult(i,v?.text??p,c),this.hooks?.has("post:cron-run")&&await this.hooks.execute("post:cron-run",{event:"post:cron-run",jobId:e,success:m.success,duration:m.duration,error:m.error?new Error(m.error):void 0})}catch(u){i.consecutiveErrors++,i.totalFailures++,i.lastError=u.message,this.log(`Job "${e}" threw: ${u.message}`),await this.notifyFailure(i,u.message),r||this.scheduleRetry(e,t);return}this.saveLastRuns(),r||this.scheduleNext(e)}detectMissedRuns(){let e=[],t=this.loadLastRuns();if(!t)return e;for(let[r,i]of this.jobs){if(!i.enabled)continue;let o=t[r];if(!o)continue;let s=new Date(o);try{let a=Re(i.schedule,s,i.timezone);a.getTime()<Date.now()&&e.push({jobId:r,missedAt:a})}catch{}}return e}async executeMissedRuns(e){for(let{jobId:t,missedAt:r}of e){let i=this.jobs.get(t);if(!i||!i.enabled)continue;let o=this.goalGate(i);if(o.skip){this.recordGoalHalt(i,r);continue}this.log(`Running missed job "${t}" (was due at ${r.toISOString()})`);let s=Ie(i.timeout),a=new Date;try{let c=this.wikiNotesInbox(i,a),g={message:_e(`[MISSED RUN \u2014 was scheduled for ${r.toISOString()}]
140
140
 
141
- ${k(O(ye(c.block,F(o.brief,i.prompt)),i.report),i.expectExitZero)}`,i.maxOutputTokens),agentId:i.agent,autonomy:i.autonomy,timeoutMinutes:s/60,context:ve(t,i)},d=await this.registry.execute(g),u=d.error||C(i.expectExitZero,d.content),h={jobId:t,startedAt:a,completedAt:new Date,success:!u,response:d.content,error:u,duration:d.duration||0,isRetry:!1,timeout:s,...c.ids.length?{wikiNotes:c.ids}:{},...Te(g,d),...d.autonomy?{autonomy:d.autonomy}:{},...d.autonomyBlocks?.length?{autonomyBlocks:d.autonomyBlocks}:{},...!u&&X(i,d.content)?{quiet:!0}:{}};this.logRun(h),i.lastRun=new Date,i.totalRuns++,u?await this.recordFailure(i,u,"Missed job"):(this.log(`Missed job "${t}" completed`),i.consecutiveErrors=0,i.lastSuccess=new Date,i.lastError=void 0)}catch(c){this.log(`Missed job "${t}" threw: ${c.message}`),i.consecutiveErrors++,i.totalFailures++,i.lastError=c.message,await this.notifyFailure(i,c.message)}}this.saveLastRuns()}async recordFailure(e,t,r="Job"){if(e.consecutiveErrors++,e.totalFailures++,e.lastError=t,this.log(`${r} "${e.id}" failed (${e.consecutiveErrors} consecutive): ${t}`),await this.notifyFailure(e,t),e.onError.includes("disable")&&e.consecutiveErrors>=3){e.enabled=!1,this.log(`Job "${e.id}" disabled after ${e.consecutiveErrors} consecutive errors`);try{let i=await W(o=>K(o,`crons.${e.id}.enabled`,!1),{reload:!1});i.success||this.log(`Failed to persist disable for "${e.id}": ${i.error}`)}catch(i){this.log(`Failed to persist disable for "${e.id}": ${i.message}`)}await this.notifyDisabled(e)}}async deliverResult(e,t,r){if(!(!e.deliverResult||!t?.trim())){if(X(e,t)){this.log(`Job "${e.id}" had nothing to report; nothing sent`);return}if(!this.deliverCallback){this.log(`Job "${e.id}" result not delivered: no delivery path in this context`);return}try{await this.deliverCallback(e.id,e.agent,t,B(e.id,r))}catch(i){this.log(`Job "${e.id}" result delivery failed: ${i?.message??i}`)}}}async notifyFailure(e,t){if(!(!e.onError.includes("notify")&&e.consecutiveErrors<2)){if(!this.notifyCallback){this.log(`[ALERT] Cron "${e.id}" failed (${e.consecutiveErrors}x): ${t.slice(0,200)}`);return}try{await this.notifyCallback(e.id,e.agent,t,e.consecutiveErrors)}catch{}}}async notifyDisabled(e){if(!this.notifyCallback){this.log(`[ALERT] Cron "${e.id}" has been DISABLED after ${e.consecutiveErrors} consecutive failures`);return}try{await this.notifyCallback(e.id,e.agent,`AUTO-DISABLED after ${e.consecutiveErrors} consecutive failures. Last error: ${e.lastError||"unknown"}`,e.consecutiveErrors)}catch{}}saveLastRuns(){try{let e={};for(let[r,i]of this.jobs)i.lastRun&&(e[r]=i.lastRun.toISOString());let t=_(process.cwd(),".agentx/cron");D(t)||P(t,{recursive:!0}),Ee(this.lastRunFile,JSON.stringify(e,null,2))}catch{}}loadLastRuns(){try{return D(this.lastRunFile)?JSON.parse(nt(this.lastRunFile,"utf-8")):null}catch{return null}}wikiNotesInbox(e,t){let r=this.wikiNotes,i={block:"",ids:[]};if(!r?.enabled||!r.inbox||!r.crons.includes(e.id))return i;if(e.agent!==r.inbox)return this.log(`Job "${e.id}" is listed under wikiNotes.crons but runs as "${e.agent}", not the inbox agent "${r.inbox}"; no notes given`),i;try{let o=this.registry.getWikiHub?.()?.getBaseDir?.();if(!o)return i;let s=B(e.id,t),a=new z(o).takeForRun(r.inbox,s,r.maxNotesPerRun,r.maxDeferrals);if(a.length===0)return i;let c=process.argv[1]||"dist/cli.js",g=Z(a,{runId:s,handleCommand:`node ${c} wiki notes handle --dir ${o} --by ${e.agent}`});return this.log(`Job "${e.id}": ${a.length} wiki note(s) given as input`),{block:g,ids:a.map(d=>d.id)}}catch(o){return this.log(`Job "${e.id}": wiki notes inbox unavailable: ${o?.message??o}`),i}}logRun(e){try{let t=_(this.runsDir,e.jobId);D(t)||P(t,{recursive:!0});let r=`${e.startedAt.toISOString().replace(/[:.]/g,"-")}.json`;Ee(_(t,r),JSON.stringify(e,null,2))}catch{}}list(){return Array.from(this.jobs.values())}health(){let e=Array.from(this.jobs.values()),t=this.detectMissedRuns();return{healthy:e.filter(r=>r.enabled&&r.consecutiveErrors===0).length,failing:e.filter(r=>r.enabled&&r.consecutiveErrors>0).length,disabled:e.filter(r=>!r.enabled).length,missed:t.length,jobs:e.map(r=>({id:r.id,status:r.enabled?r.retryPending?"retrying":r.consecutiveErrors>0?"failing":"healthy":"disabled",consecutiveErrors:r.consecutiveErrors,lastError:r.lastError}))}}},U=N;Y(U,"MAX_TIMEOUT_MS",2147483647);var rt=20;function ot(n,e){let t=n.replace(/\s+$/,"").split(`
141
+ ${k(O(ye(c.block,F(o.brief,i.prompt)),i.report),i.expectExitZero)}`,i.maxOutputTokens),agentId:i.agent,autonomy:i.autonomy,timeoutMinutes:s/60,context:ve(t,i)},d=await this.registry.execute(g),u=d.error||C(i.expectExitZero,d.content),h={jobId:t,startedAt:a,completedAt:new Date,success:!u,response:d.content,error:u,duration:d.duration||0,isRetry:!1,timeout:s,...c.ids.length?{wikiNotes:c.ids}:{},...Te(g,d),...d.autonomy?{autonomy:d.autonomy}:{},...d.autonomyBlocks?.length?{autonomyBlocks:d.autonomyBlocks}:{},...!u&&X(i,d.content)?{quiet:!0}:{}};this.logRun(h),i.lastRun=new Date,i.totalRuns++,u?await this.recordFailure(i,u,"Missed job"):(this.log(`Missed job "${t}" completed`),i.consecutiveErrors=0,i.lastSuccess=new Date,i.lastError=void 0)}catch(c){this.log(`Missed job "${t}" threw: ${c.message}`),i.consecutiveErrors++,i.totalFailures++,i.lastError=c.message,await this.notifyFailure(i,c.message)}}this.saveLastRuns()}async recordFailure(e,t,r="Job"){if(e.consecutiveErrors++,e.totalFailures++,e.lastError=t,this.log(`${r} "${e.id}" failed (${e.consecutiveErrors} consecutive): ${t}`),await this.notifyFailure(e,t),e.onError.includes("disable")&&e.consecutiveErrors>=3){e.enabled=!1,this.log(`Job "${e.id}" disabled after ${e.consecutiveErrors} consecutive errors`);try{let i=await W(o=>K(o,`crons.${e.id}.enabled`,!1),{reload:!1});i.success||this.log(`Failed to persist disable for "${e.id}": ${i.error}`)}catch(i){this.log(`Failed to persist disable for "${e.id}": ${i.message}`)}await this.notifyDisabled(e)}}async deliverResult(e,t,r){if(!(!e.deliverResult||!t?.trim())){if(X(e,t)){this.log(`Job "${e.id}" had nothing to report; nothing sent`);return}if(!this.deliverCallback){this.log(`Job "${e.id}" result not delivered: no delivery path in this context`);return}try{await this.deliverCallback(e.id,e.agent,t,B(e.id,r))}catch(i){this.log(`Job "${e.id}" result delivery failed: ${i?.message??i}`)}}}async notifyFailure(e,t){if(!(!e.onError.includes("notify")&&e.consecutiveErrors<2)){if(!this.notifyCallback){this.log(`[ALERT] Cron "${e.id}" failed (${e.consecutiveErrors}x): ${t.slice(0,200)}`);return}try{await this.notifyCallback(e.id,e.agent,t,e.consecutiveErrors)}catch{}}}async notifyDisabled(e){if(!this.notifyCallback){this.log(`[ALERT] Cron "${e.id}" has been DISABLED after ${e.consecutiveErrors} consecutive failures`);return}try{await this.notifyCallback(e.id,e.agent,`AUTO-DISABLED after ${e.consecutiveErrors} consecutive failures. Last error: ${e.lastError||"unknown"}`,e.consecutiveErrors)}catch{}}saveLastRuns(){try{let e=this.loadLastRuns()??{},t={};for(let[i,o]of this.jobs)o.lastRun?t[i]=o.lastRun.toISOString():typeof e[i]=="string"&&(t[i]=e[i]);let r=_(process.cwd(),".agentx/cron");D(r)||P(r,{recursive:!0}),Ee(this.lastRunFile,JSON.stringify(t,null,2))}catch{}}loadLastRuns(){try{return D(this.lastRunFile)?JSON.parse(nt(this.lastRunFile,"utf-8")):null}catch{return null}}wikiNotesInbox(e,t){let r=this.wikiNotes,i={block:"",ids:[]};if(!r?.enabled||!r.inbox||!r.crons.includes(e.id))return i;if(e.agent!==r.inbox)return this.log(`Job "${e.id}" is listed under wikiNotes.crons but runs as "${e.agent}", not the inbox agent "${r.inbox}"; no notes given`),i;try{let o=this.registry.getWikiHub?.()?.getBaseDir?.();if(!o)return i;let s=B(e.id,t),a=new z(o).takeForRun(r.inbox,s,r.maxNotesPerRun,r.maxDeferrals);if(a.length===0)return i;let c=process.argv[1]||"dist/cli.js",g=Z(a,{runId:s,handleCommand:`node ${c} wiki notes handle --dir ${o} --by ${e.agent}`});return this.log(`Job "${e.id}": ${a.length} wiki note(s) given as input`),{block:g,ids:a.map(d=>d.id)}}catch(o){return this.log(`Job "${e.id}": wiki notes inbox unavailable: ${o?.message??o}`),i}}logRun(e){try{let t=_(this.runsDir,e.jobId);D(t)||P(t,{recursive:!0});let r=`${e.startedAt.toISOString().replace(/[:.]/g,"-")}.json`;Ee(_(t,r),JSON.stringify(e,null,2))}catch{}}list(){return Array.from(this.jobs.values())}health(){let e=Array.from(this.jobs.values()),t=this.detectMissedRuns();return{healthy:e.filter(r=>r.enabled&&r.consecutiveErrors===0).length,failing:e.filter(r=>r.enabled&&r.consecutiveErrors>0).length,disabled:e.filter(r=>!r.enabled).length,missed:t.length,jobs:e.map(r=>({id:r.id,status:r.enabled?r.retryPending?"retrying":r.consecutiveErrors>0?"failing":"healthy":"disabled",consecutiveErrors:r.consecutiveErrors,lastError:r.lastError}))}}},U=N;Y(U,"MAX_TIMEOUT_MS",2147483647);var rt=20;function ot(n,e){let t=n.replace(/\s+$/,"").split(`
142
142
  `);return t.length<=e?t.join(`
143
143
  `):t.slice(-e).join(`
144
144
  `)}function st(n,e,t){return new Promise((r,i)=>{tt("/bin/sh",["-c",n],{timeout:e,maxBuffer:8*1024*1024,...t?{env:t}:{}},(o,s,a)=>{if(o&&o.killed){i(new Error(`command timed out after ${Math.round(e/1e3)}s`));return}r({stdout:String(s??""),stderr:String(a??""),code:o?typeof o.code=="number"?o.code:1:0})})})}export{T as a,te as b,St as c,wt as d,Ye as e,$t as f,Ot as g,w as h,de as i,q as j,pt as k,re as l,se as m,At as n,et as o,it as p,Ie as q,Te as r,Re as s,B as t,U as u};
145
- //# sourceMappingURL=chunk-XTIPWYW5.js.map
145
+ //# sourceMappingURL=chunk-VIWN3CXS.js.map