agentix-cli 0.140.0 → 0.141.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 (127) hide show
  1. package/dist/{App-RJRJLBCF.js → App-A6YSBIEL.js} +2 -2
  2. package/dist/{ChatApp-YTGLBN47.js → ChatApp-Q7UHDR5P.js} +2 -2
  3. package/dist/{absorb-eval-DZ6SCGT7.js → absorb-eval-WTKVCJXT.js} +2 -2
  4. package/dist/{agent-G32GSRUE.js → agent-DHCLFYIQ.js} +2 -2
  5. package/dist/{board-dashboard-HOZVSYMJ.js → board-dashboard-6K34ZQB5.js} +4 -4
  6. package/dist/{chunk-EBYG3NS3.js → chunk-27UKZZTZ.js} +2 -2
  7. package/dist/{chunk-GPDVETDE.js → chunk-6DZSDM35.js} +2 -2
  8. package/dist/{chunk-FUGDD6UW.js → chunk-6MARQ33D.js} +2 -2
  9. package/dist/chunk-CELYB3UW.js +174 -0
  10. package/dist/chunk-CELYB3UW.js.map +1 -0
  11. package/dist/{chunk-4ZKXEUQP.js → chunk-COWWOA7H.js} +2 -2
  12. package/dist/{chunk-IOT5REOO.js → chunk-CV7ISZKU.js} +2 -2
  13. package/dist/{chunk-BGKIKZMZ.js → chunk-HPGMY6YB.js} +2 -2
  14. package/dist/chunk-HW5FTKTU.js +54 -0
  15. package/dist/{chunk-TF5356HW.js.map → chunk-HW5FTKTU.js.map} +1 -1
  16. package/dist/{chunk-2JQSWX7U.js → chunk-HYOXWAQP.js} +3 -3
  17. package/dist/chunk-HYOXWAQP.js.map +1 -0
  18. package/dist/{chunk-O6KRXVN7.js → chunk-I6P3BKWJ.js} +2 -2
  19. package/dist/{chunk-ZKNSNSV2.js → chunk-JLM6CXIH.js} +2 -2
  20. package/dist/{chunk-HYVRS3G3.js → chunk-L7OTWV5X.js} +282 -272
  21. package/dist/chunk-L7OTWV5X.js.map +1 -0
  22. package/dist/{chunk-2NTRAVHC.js → chunk-LYSCMFAM.js} +2 -2
  23. package/dist/{chunk-PILE2SH3.js → chunk-MSRFTAWH.js} +2 -2
  24. package/dist/{chunk-EVQQZNZY.js → chunk-MT5QTEUL.js} +2 -2
  25. package/dist/{chunk-P5G6EYBL.js → chunk-MWB33O72.js} +2 -2
  26. package/dist/{chunk-C5ABUPRU.js → chunk-NJHNV4QP.js} +2 -2
  27. package/dist/{chunk-YVRQ7KWB.js → chunk-OG44FK7T.js} +2 -2
  28. package/dist/{chunk-GG6K5ZL6.js → chunk-OW2AND54.js} +2 -2
  29. package/dist/{chunk-OCTWRSOI.js → chunk-S5DS2V3X.js} +2 -2
  30. package/dist/{chunk-PPT2MXQY.js → chunk-T7LDVJMP.js} +3 -3
  31. package/dist/{chunk-Z46SZWMO.js → chunk-UJRJUSDY.js} +2 -2
  32. package/dist/{chunk-E47LEY5I.js → chunk-UVJUURNO.js} +2 -2
  33. package/dist/{chunk-QHXKELKQ.js → chunk-VJC372D6.js} +2 -2
  34. package/dist/{chunk-U72JN4YF.js → chunk-W4JLZJHU.js} +2 -2
  35. package/dist/{chunk-QSQWVQLD.js → chunk-YDPXS6T4.js} +2 -2
  36. package/dist/cli.js +1 -1
  37. package/dist/{client-B275LQZY.js → client-T5BDAOBA.js} +2 -2
  38. package/dist/config-PCTNYBE3.js +2 -0
  39. package/dist/{config-mutate-BYRF4RJT.js → config-mutate-2WZOX6Y6.js} +2 -2
  40. package/dist/config-mutator-M65NF7SF.js +2 -0
  41. package/dist/{contributions-SQVBSENQ.js → contributions-HVCHGNPO.js} +2 -2
  42. package/dist/{doctor-L6XMYZPY.js → doctor-NHEMFVQG.js} +2 -2
  43. package/dist/{follow-up-tool-C72BXO4B.js → follow-up-tool-7ENUC5TI.js} +2 -2
  44. package/dist/{hub-5OSJMIOO.js → hub-KTS6KFMG.js} +2 -2
  45. package/dist/index.d.ts +317 -0
  46. package/dist/index.js +1 -1
  47. package/dist/{program-QJKOF3OJ.js → program-QQ6N3PVM.js} +241 -236
  48. package/dist/program-QQ6N3PVM.js.map +1 -0
  49. package/dist/{promote-C65WVH5K.js → promote-CGF5G6PE.js} +2 -2
  50. package/dist/{query-3LO5OP6O.js → query-AJVLRTTT.js} +2 -2
  51. package/dist/{query-settings-TWT6XZNV.js → query-settings-GF3CRGHA.js} +2 -2
  52. package/dist/registry-HYQ3N4B6.js +2 -0
  53. package/dist/{request-planner-D6XVDOJN.js → request-planner-4KQSVQHO.js} +2 -2
  54. package/dist/{review-candidates-6BQ25RIY.js → review-candidates-KC3AJDAL.js} +2 -2
  55. package/dist/{routing-KBNYAPTC.js → routing-5VGAZXNZ.js} +2 -2
  56. package/dist/schedule-tool-XETP3D45.js +2 -0
  57. package/dist/{scheduler-R6N7FT27.js → scheduler-UZNAC46U.js} +2 -2
  58. package/dist/{seat-5AF4CN52.js → seat-BTSSQDZX.js} +2 -2
  59. package/dist/{select-TJZXA74W.js → select-MYLQ3QGJ.js} +2 -2
  60. package/dist/{set-enabled-RQPZBVZP.js → set-enabled-QJ4GM624.js} +2 -2
  61. package/dist/{tool-2RJYOQE7.js → tool-HTPNTSCA.js} +2 -2
  62. package/dist/{tool-C7Z56DOT.js → tool-HZHMB5Q3.js} +2 -2
  63. package/dist/{wiki-3DX53GJ4.js → wiki-ZWFSQ5SL.js} +2 -2
  64. package/dist/wiki-enrich-HQCWHX6Z.js +2 -0
  65. package/package.json +1 -1
  66. package/dist/chunk-2JQSWX7U.js.map +0 -1
  67. package/dist/chunk-GQOMV52Y.js +0 -160
  68. package/dist/chunk-GQOMV52Y.js.map +0 -1
  69. package/dist/chunk-HYVRS3G3.js.map +0 -1
  70. package/dist/chunk-TF5356HW.js +0 -54
  71. package/dist/config-PYDMLFAM.js +0 -2
  72. package/dist/config-mutator-LZSY6S4H.js +0 -2
  73. package/dist/program-QJKOF3OJ.js.map +0 -1
  74. package/dist/registry-YI7NLDAL.js +0 -2
  75. package/dist/schedule-tool-GDUREPVN.js +0 -2
  76. package/dist/wiki-enrich-KQNC45FM.js +0 -2
  77. /package/dist/{App-RJRJLBCF.js.map → App-A6YSBIEL.js.map} +0 -0
  78. /package/dist/{ChatApp-YTGLBN47.js.map → ChatApp-Q7UHDR5P.js.map} +0 -0
  79. /package/dist/{absorb-eval-DZ6SCGT7.js.map → absorb-eval-WTKVCJXT.js.map} +0 -0
  80. /package/dist/{agent-G32GSRUE.js.map → agent-DHCLFYIQ.js.map} +0 -0
  81. /package/dist/{board-dashboard-HOZVSYMJ.js.map → board-dashboard-6K34ZQB5.js.map} +0 -0
  82. /package/dist/{chunk-EBYG3NS3.js.map → chunk-27UKZZTZ.js.map} +0 -0
  83. /package/dist/{chunk-GPDVETDE.js.map → chunk-6DZSDM35.js.map} +0 -0
  84. /package/dist/{chunk-FUGDD6UW.js.map → chunk-6MARQ33D.js.map} +0 -0
  85. /package/dist/{chunk-4ZKXEUQP.js.map → chunk-COWWOA7H.js.map} +0 -0
  86. /package/dist/{chunk-IOT5REOO.js.map → chunk-CV7ISZKU.js.map} +0 -0
  87. /package/dist/{chunk-BGKIKZMZ.js.map → chunk-HPGMY6YB.js.map} +0 -0
  88. /package/dist/{chunk-O6KRXVN7.js.map → chunk-I6P3BKWJ.js.map} +0 -0
  89. /package/dist/{chunk-ZKNSNSV2.js.map → chunk-JLM6CXIH.js.map} +0 -0
  90. /package/dist/{chunk-2NTRAVHC.js.map → chunk-LYSCMFAM.js.map} +0 -0
  91. /package/dist/{chunk-PILE2SH3.js.map → chunk-MSRFTAWH.js.map} +0 -0
  92. /package/dist/{chunk-EVQQZNZY.js.map → chunk-MT5QTEUL.js.map} +0 -0
  93. /package/dist/{chunk-P5G6EYBL.js.map → chunk-MWB33O72.js.map} +0 -0
  94. /package/dist/{chunk-C5ABUPRU.js.map → chunk-NJHNV4QP.js.map} +0 -0
  95. /package/dist/{chunk-YVRQ7KWB.js.map → chunk-OG44FK7T.js.map} +0 -0
  96. /package/dist/{chunk-GG6K5ZL6.js.map → chunk-OW2AND54.js.map} +0 -0
  97. /package/dist/{chunk-OCTWRSOI.js.map → chunk-S5DS2V3X.js.map} +0 -0
  98. /package/dist/{chunk-PPT2MXQY.js.map → chunk-T7LDVJMP.js.map} +0 -0
  99. /package/dist/{chunk-Z46SZWMO.js.map → chunk-UJRJUSDY.js.map} +0 -0
  100. /package/dist/{chunk-E47LEY5I.js.map → chunk-UVJUURNO.js.map} +0 -0
  101. /package/dist/{chunk-QHXKELKQ.js.map → chunk-VJC372D6.js.map} +0 -0
  102. /package/dist/{chunk-U72JN4YF.js.map → chunk-W4JLZJHU.js.map} +0 -0
  103. /package/dist/{chunk-QSQWVQLD.js.map → chunk-YDPXS6T4.js.map} +0 -0
  104. /package/dist/{client-B275LQZY.js.map → client-T5BDAOBA.js.map} +0 -0
  105. /package/dist/{config-PYDMLFAM.js.map → config-PCTNYBE3.js.map} +0 -0
  106. /package/dist/{config-mutate-BYRF4RJT.js.map → config-mutate-2WZOX6Y6.js.map} +0 -0
  107. /package/dist/{config-mutator-LZSY6S4H.js.map → config-mutator-M65NF7SF.js.map} +0 -0
  108. /package/dist/{contributions-SQVBSENQ.js.map → contributions-HVCHGNPO.js.map} +0 -0
  109. /package/dist/{doctor-L6XMYZPY.js.map → doctor-NHEMFVQG.js.map} +0 -0
  110. /package/dist/{follow-up-tool-C72BXO4B.js.map → follow-up-tool-7ENUC5TI.js.map} +0 -0
  111. /package/dist/{hub-5OSJMIOO.js.map → hub-KTS6KFMG.js.map} +0 -0
  112. /package/dist/{promote-C65WVH5K.js.map → promote-CGF5G6PE.js.map} +0 -0
  113. /package/dist/{query-3LO5OP6O.js.map → query-AJVLRTTT.js.map} +0 -0
  114. /package/dist/{query-settings-TWT6XZNV.js.map → query-settings-GF3CRGHA.js.map} +0 -0
  115. /package/dist/{registry-YI7NLDAL.js.map → registry-HYQ3N4B6.js.map} +0 -0
  116. /package/dist/{request-planner-D6XVDOJN.js.map → request-planner-4KQSVQHO.js.map} +0 -0
  117. /package/dist/{review-candidates-6BQ25RIY.js.map → review-candidates-KC3AJDAL.js.map} +0 -0
  118. /package/dist/{routing-KBNYAPTC.js.map → routing-5VGAZXNZ.js.map} +0 -0
  119. /package/dist/{schedule-tool-GDUREPVN.js.map → schedule-tool-XETP3D45.js.map} +0 -0
  120. /package/dist/{scheduler-R6N7FT27.js.map → scheduler-UZNAC46U.js.map} +0 -0
  121. /package/dist/{seat-5AF4CN52.js.map → seat-BTSSQDZX.js.map} +0 -0
  122. /package/dist/{select-TJZXA74W.js.map → select-MYLQ3QGJ.js.map} +0 -0
  123. /package/dist/{set-enabled-RQPZBVZP.js.map → set-enabled-QJ4GM624.js.map} +0 -0
  124. /package/dist/{tool-2RJYOQE7.js.map → tool-HTPNTSCA.js.map} +0 -0
  125. /package/dist/{tool-C7Z56DOT.js.map → tool-HZHMB5Q3.js.map} +0 -0
  126. /package/dist/{wiki-3DX53GJ4.js.map → wiki-ZWFSQ5SL.js.map} +0 -0
  127. /package/dist/{wiki-enrich-KQNC45FM.js.map → wiki-enrich-HQCWHX6Z.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{b as St,c as At}from"./chunk-QSKG754X.js";import{c as bt}from"./chunk-SZDACK6O.js";import{b as xe}from"./chunk-AFRHKA7B.js";import{b as ht,e as wt,f as yt,i as It,k as vt,l as $t,q as Rt}from"./chunk-GPDVETDE.js";import{b as ft,d as gt,e as mt}from"./chunk-PE5V2LI7.js";import{e as ut,g as ct,h as pt,i as Re}from"./chunk-GQ76J72O.js";import{a as kt}from"./chunk-GV7S5BAX.js";import{y as at,z as Bn}from"./chunk-PILE2SH3.js";import{b as st,f as Kn}from"./chunk-72SZI2UW.js";import{a as dt,b as $e,c as Se,d as lt,e as Ae}from"./chunk-QD6IICK7.js";import{c as ot,d as it}from"./chunk-QOYAX2FT.js";import{f as ve,n as Hn}from"./chunk-UIBUZ2N3.js";import{existsSync as qn,mkdirSync as xt,readFileSync as zn,writeFileSync as Jn,renameSync as Yn}from"fs";import{resolve as Pt,dirname as Gn}from"path";var Tt=class{filePath;log;constructor(e={}){let t=e.baseDir??Pt(process.cwd(),".agentx");this.filePath=Pt(t,"handover.json"),this.log=e.log??console.error.bind(console,"[handover]"),xt(t,{recursive:!0})}key(e,t,r){return`${e}::${t}::${r||"-"}`}load(){if(!qn(this.filePath))return{version:1,overrides:{}};try{let e=zn(this.filePath,"utf-8"),t=JSON.parse(e);return!t||typeof t!="object"?{version:1,overrides:{}}:(t.overrides||(t.overrides={}),t)}catch(e){return this.log(`load failed, starting empty: ${e?.message||e}`),{version:1,overrides:{}}}}save(e){xt(Gn(this.filePath),{recursive:!0});let t=`${this.filePath}.tmp-${process.pid}`;Jn(t,JSON.stringify(e,null,2)),Yn(t,this.filePath)}get(e,t,r){let s=this.load().overrides[this.key(e,t,r)];if(s&&!(s.expiresAt&&Date.parse(s.expiresAt)<Date.now()))return s}set(e){if(!e.channel||!e.chatId||!e.toAgent)throw new Error("channel, chatId and toAgent are required");let t=this.load(),r={...e,createdAt:e.createdAt??new Date().toISOString()};return t.overrides[this.key(r.channel,r.chatId,r.accountId)]=r,this.save(t),r}remove(e,t,r){let o=this.load(),s=this.key(e,t,r);return s in o.overrides?(delete o.overrides[s],this.save(o),!0):!1}consumeSummary(e,t,r){let o=this.load(),s=o.overrides[this.key(e,t,r)];if(!s||!s.summary||s.summaryConsumedAt)return;let a=s.summary;return s.summaryConsumedAt=new Date().toISOString(),this.save(o),a}listActive(){let e=this.load(),t=Date.now();return Object.values(e.overrides).filter(r=>!r.expiresAt||Date.parse(r.expiresAt)>=t)}listByAgent(e){let t=this.listActive();return{incoming:t.filter(r=>r.toAgent===e),outgoing:t.filter(r=>r.fromAgent===e)}}};import{readFileSync as Et,writeFileSync as Pe,appendFileSync as Xn,mkdirSync as er,existsSync as Mt,statSync as tr}from"fs";import{resolve as ne}from"path";var Wt="[Agent Memory \u2014 persistent facts from past conversations]",Vn=2400;function Nt(n,e){return n?`UNVERIFIED (${e===null?"age unknown":`${e}d old`}) `:""}function Qn(n,e=Date.now()){let t=gt(n,e),r=n.undated?"UNVERIFIED (never checked) ":Nt(t,ut(n.verifiedAt,e));return{line:`- [wiki ${n.id}] ${r}${n.subject} \xB7 ${n.attribute}: ${n.value} (${n.source}, checked ${n.verifiedAt.slice(0,10)} by ${n.verifiedBy})`,unverified:t}}function Zn(n,e){let r=!n.source.chatId.startsWith("-")&&/^\d+$/.test(n.source.chatId)?"DM":n.source.chatId,o=pt(n,e);return{line:`- [${n.category}] ${Nt(o,ct(n,e))}${n.content} (${r}, ${n.source.date})`,unverified:o}}function Dt(n,e=[],t=Date.now()){let r=[],o=new Set,s=Wt.length,a=!1;for(let i of n){let d=e.length>0?mt(i.content,e):null,l,p,c=d&&Date.parse(i.createdAt)>Date.parse(d.verifiedAt)&&!i.content.toLowerCase().includes(d.value.toLowerCase());if(d&&!c){if(o.has(d.id))continue;o.add(d.id),l=Qn(d,t),p=d.id}else l=Zn(i,t),d&&(l.line+=` [differs from wiki ${d.id}]`);let f=l.unverified&&!a?Re.length:0;if(s+f+l.line.length>Vn)break;r.push({fact:i,...l,...p?{wikiRef:p}:{}}),s+=f+l.line.length,f&&(a=!0)}return r}function Ot(n){if(n.length===0)return"";let e=n.some(t=>t.unverified)?[Re]:[];return[Wt,...e,...n.map(t=>t.line),"[End Memory]"].join(`
1
+ import{b as St,c as At}from"./chunk-QSKG754X.js";import{c as bt}from"./chunk-SZDACK6O.js";import{b as xe}from"./chunk-AFRHKA7B.js";import{b as ht,e as wt,f as yt,i as It,k as vt,l as $t,q as Rt}from"./chunk-6DZSDM35.js";import{b as ft,d as gt,e as mt}from"./chunk-PE5V2LI7.js";import{e as ut,g as ct,h as pt,i as Re}from"./chunk-GQ76J72O.js";import{a as kt}from"./chunk-GV7S5BAX.js";import{y as at,z as Bn}from"./chunk-MSRFTAWH.js";import{b as st,f as Kn}from"./chunk-72SZI2UW.js";import{a as dt,b as $e,c as Se,d as lt,e as Ae}from"./chunk-QD6IICK7.js";import{c as ot,d as it}from"./chunk-QOYAX2FT.js";import{f as ve,n as Hn}from"./chunk-UIBUZ2N3.js";import{existsSync as qn,mkdirSync as xt,readFileSync as zn,writeFileSync as Jn,renameSync as Yn}from"fs";import{resolve as Pt,dirname as Gn}from"path";var Tt=class{filePath;log;constructor(e={}){let t=e.baseDir??Pt(process.cwd(),".agentx");this.filePath=Pt(t,"handover.json"),this.log=e.log??console.error.bind(console,"[handover]"),xt(t,{recursive:!0})}key(e,t,r){return`${e}::${t}::${r||"-"}`}load(){if(!qn(this.filePath))return{version:1,overrides:{}};try{let e=zn(this.filePath,"utf-8"),t=JSON.parse(e);return!t||typeof t!="object"?{version:1,overrides:{}}:(t.overrides||(t.overrides={}),t)}catch(e){return this.log(`load failed, starting empty: ${e?.message||e}`),{version:1,overrides:{}}}}save(e){xt(Gn(this.filePath),{recursive:!0});let t=`${this.filePath}.tmp-${process.pid}`;Jn(t,JSON.stringify(e,null,2)),Yn(t,this.filePath)}get(e,t,r){let s=this.load().overrides[this.key(e,t,r)];if(s&&!(s.expiresAt&&Date.parse(s.expiresAt)<Date.now()))return s}set(e){if(!e.channel||!e.chatId||!e.toAgent)throw new Error("channel, chatId and toAgent are required");let t=this.load(),r={...e,createdAt:e.createdAt??new Date().toISOString()};return t.overrides[this.key(r.channel,r.chatId,r.accountId)]=r,this.save(t),r}remove(e,t,r){let o=this.load(),s=this.key(e,t,r);return s in o.overrides?(delete o.overrides[s],this.save(o),!0):!1}consumeSummary(e,t,r){let o=this.load(),s=o.overrides[this.key(e,t,r)];if(!s||!s.summary||s.summaryConsumedAt)return;let a=s.summary;return s.summaryConsumedAt=new Date().toISOString(),this.save(o),a}listActive(){let e=this.load(),t=Date.now();return Object.values(e.overrides).filter(r=>!r.expiresAt||Date.parse(r.expiresAt)>=t)}listByAgent(e){let t=this.listActive();return{incoming:t.filter(r=>r.toAgent===e),outgoing:t.filter(r=>r.fromAgent===e)}}};import{readFileSync as Et,writeFileSync as Pe,appendFileSync as Xn,mkdirSync as er,existsSync as Mt,statSync as tr}from"fs";import{resolve as ne}from"path";var Wt="[Agent Memory \u2014 persistent facts from past conversations]",Vn=2400;function Nt(n,e){return n?`UNVERIFIED (${e===null?"age unknown":`${e}d old`}) `:""}function Qn(n,e=Date.now()){let t=gt(n,e),r=n.undated?"UNVERIFIED (never checked) ":Nt(t,ut(n.verifiedAt,e));return{line:`- [wiki ${n.id}] ${r}${n.subject} \xB7 ${n.attribute}: ${n.value} (${n.source}, checked ${n.verifiedAt.slice(0,10)} by ${n.verifiedBy})`,unverified:t}}function Zn(n,e){let r=!n.source.chatId.startsWith("-")&&/^\d+$/.test(n.source.chatId)?"DM":n.source.chatId,o=pt(n,e);return{line:`- [${n.category}] ${Nt(o,ct(n,e))}${n.content} (${r}, ${n.source.date})`,unverified:o}}function Dt(n,e=[],t=Date.now()){let r=[],o=new Set,s=Wt.length,a=!1;for(let i of n){let d=e.length>0?mt(i.content,e):null,l,p,c=d&&Date.parse(i.createdAt)>Date.parse(d.verifiedAt)&&!i.content.toLowerCase().includes(d.value.toLowerCase());if(d&&!c){if(o.has(d.id))continue;o.add(d.id),l=Qn(d,t),p=d.id}else l=Zn(i,t),d&&(l.line+=` [differs from wiki ${d.id}]`);let f=l.unverified&&!a?Re.length:0;if(s+f+l.line.length>Vn)break;r.push({fact:i,...l,...p?{wikiRef:p}:{}}),s+=f+l.line.length,f&&(a=!0)}return r}function Ot(n){if(n.length===0)return"";let e=n.some(t=>t.unverified)?[Re]:[];return[Wt,...e,...n.map(t=>t.line),"[End Memory]"].join(`
2
2
  `)}var Ft=200,nr=7,jt=class{memoryDir;ledger;constructor(e=process.cwd()){this.memoryDir=ne(e,".agentx/memory"),this.ledger=new ft(ne(e,".agentx/wiki")),Mt(this.memoryDir)||er(this.memoryDir,{recursive:!0})}filePath(e){return ne(this.memoryDir,`${e}.jsonl`)}addMemory(e,t){if(t.category==="secret"||$e(t.content))return!1;let r=t.source.trust??dt(t.source.channel),o=t.review??lt(r),s={...t,source:{...t.source,trust:r},...o?{review:o}:{},id:`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,createdAt:new Date().toISOString()};return Xn(this.filePath(e),JSON.stringify(s)+`
3
3
  `),!0}parsedCache=new Map;getAll(e){let t=this.filePath(e);if(!Mt(t))return[];try{let{mtimeMs:r,size:o}=tr(t),s=this.parsedCache.get(t);if(s&&s.mtimeMs===r&&s.size===o)return s.facts.slice();let i=Et(t,"utf-8").split(`
4
4
  `).filter(d=>d.trim()).map(d=>{try{return JSON.parse(d)}catch{return null}}).filter(d=>d!==null);return this.parsedCache.set(t,{mtimeMs:r,size:o,facts:i}),i.slice()}catch{return[]}}findRelevant(e,t,r=8){let o=this.getAll(t).filter(Ae);if(o.length===0)return[];let s=o.map(g=>`${g.keywords.join(" ")} ${g.content}`),a=ne(this.memoryDir,`${t}_bm25_cache.json`),i=it(s,a),d=ot(e,i),l=new Map(d.map(g=>[g.docIndex,g.score])),c=o.map((g,m)=>{let y=l.get(m)??0;return g.category==="commitment"&&(y+=1),{memory:g,score:y}}).filter(g=>g.score>0);if(c.length===0)return o.slice(-r);let f=c.sort((g,m)=>m.score-g.score).slice(0,r).map(g=>g.memory);if(f.length>0)try{this.recordAccess(t,f.map(g=>g.id))}catch{}return f}buildContext(e){return Ot(this.contextLines(e))}contextFacts(e){return this.contextLines(e).map(t=>t.fact)}contextLines(e){let t=[];try{t=this.ledger.list()}catch{}return Dt(e,t)}recordAccess(e,t){if(t.length===0)return;let r=this.getAll(e),o=new Set(t),s=!1;for(let a of r)if(o.has(a.id)){a.accessCount=(a.accessCount||0)+1,a.lastAccessed=new Date().toISOString();let i=a.intervalDays||1;a.intervalDays=Math.min(i*2,30),a.nextReview=new Date(Date.now()+a.intervalDays*864e5).toISOString(),s=!0}s&&Pe(this.filePath(e),r.map(a=>JSON.stringify(a)).join(`
@@ -38,4 +38,4 @@ ${n.text}`}async function me(n,e){let t=n.channels[e.channel],r={channel:e.chann
38
38
  `).filter(Boolean),o=[];for(let s=r.length-1;s>=0&&o.length<t;s--)try{let a=JSON.parse(r[s]);(!e||a.person===e)&&o.push(a)}catch{}return o}load(){if(Xe(this.file))try{let e=JSON.parse(et(this.file,"utf-8"));if(e&&Array.isArray(e.devices))return e}catch{}return{devices:[]}}save(e){Sn(xn(this.file),{recursive:!0});let t=`${this.file}.${process.pid}.${Tn(4).toString("hex")}.tmp`;Rn(t,JSON.stringify(e,null,2)+`
39
39
  `,{encoding:"utf-8",mode:384}),An(t,this.file)}};import{extname as li}from"path";var Nn=/<agentx-artifact>([\s\S]*?)<\/agentx-artifact>/gi,Dn=/<agentx-artifact>[\s\S]*$/i;function ld(n,e=1/0,t=!1){let r=[],o=String(n??"");if(!/<agentx-artifact>/i.test(o))return{text:o,artifacts:r};let s=o.replace(Nn,(a,i)=>{try{let d=JSON.parse(i.trim());if(d&&typeof d.filename=="string"&&typeof d.mime=="string"&&r.length<e){let l=d.mime,p=l.startsWith("image/")?"image":l==="application/pdf"?"pdf":l.startsWith("text/")?"text":"file";r.push({type:p,filename:d.filename,mime:l})}}catch{}return""});return{text:(t?s.replace(Dn,""):s).trim(),artifacts:r}}function ud(n,e=!1){let t=String(n??""),r=t;if(/<agentx-artifact>/i.test(t)){let o=t.replace(Nn,(s,a)=>{try{let i=JSON.parse(a.trim());return i&&typeof i.filename=="string"?i.filename:""}catch{return""}});r=(e?o.replace(Dn,""):o).trim()}return r.replace(/```[\s\S]*?```|`[^`\n]*`|!\[([^\]\n]*)\]\(([^)\s]+)\)/g,(o,s,a)=>s===void 0||a===void 0?o:`[${s||a}](${a})`)}var ui={".png":{mime:"image/png",kind:"image"},".jpg":{mime:"image/jpeg",kind:"image"},".jpeg":{mime:"image/jpeg",kind:"image"},".gif":{mime:"image/gif",kind:"image"},".webp":{mime:"image/webp",kind:"image"},".svg":{mime:"image/svg+xml",kind:"file"},".pdf":{mime:"application/pdf",kind:"file"},".txt":{mime:"text/plain; charset=utf-8",kind:"file"},".md":{mime:"text/markdown; charset=utf-8",kind:"file"},".csv":{mime:"text/csv; charset=utf-8",kind:"file"},".json":{mime:"application/json",kind:"file"},".mp3":{mime:"audio/mpeg",kind:"audio"},".m4a":{mime:"audio/mp4",kind:"audio"},".wav":{mime:"audio/wav",kind:"audio"},".mp4":{mime:"video/mp4",kind:"video"},".webm":{mime:"video/webm",kind:"video"}},cd={bytes:20*1024*1024,perMessage:20,pathChars:512};function pd(n){return ui[li(n).toLowerCase()]??null}var ci=["[Phone app: showing files]","To show the owner a file you created (a chart, a screenshot, a PDF, a recording), save or copy it into .agentx/outbox/ in your workspace and end your reply with one line per file:",'<agentx-artifact>{"filename":".agentx/outbox/<name.ext>","mime":"<mime/type>"}</agentx-artifact>',"Files outside your workspace (/tmp, your home folder) are refused. Outbox files are removed after 7 days.","The line is removed from the text. Images show in the reply, audio and video get a player, other files an Open link. Allowed: png, jpg, gif, webp, svg, pdf, txt, md, csv, json, mp3, m4a, wav, mp4, webm; up to 20 MB and 20 files per reply.","A picture already on the web can go inline as ![what it shows](https://...)."].join(`
40
40
  `);function fd(n,e,t){return n==="app"&&e&&t!==!1?ci:void 0}import{lstatSync as nt,mkdirSync as pi,readdirSync as fi,realpathSync as tt,unlinkSync as gi}from"fs";import{join as be,resolve as On}from"path";var En=".agentx/outbox",mi=7*24*60*60*1e3;function hi(n,e){try{let t=tt(On(e,n)),r=be(t,En);return tt(r)===r&&nt(r).isDirectory()?r:null}catch{return null}}function wd(n,e={}){let t=e.cwd??process.cwd();if(e.create!==!1)try{let o=tt(On(t,n));nt(be(o,".agentx"),{throwIfNoEntry:!1})?.isSymbolicLink()||pi(be(o,En),{recursive:!0})}catch{return 0}let r=hi(n,t);return r?Mn(r,(e.now??Date.now())-(e.maxAgeMs??mi)):0}function Mn(n,e){let t=0;for(let r of fi(n)){let o=be(n,r);try{let s=nt(o);s.isDirectory()?t+=Mn(o,e):Math.max(s.mtimeMs,s.ctimeMs)<e&&(gi(o),t++)}catch{}}return t}export{Tt as a,jt as b,Ct as c,Di as d,ir as e,Oi as f,T as g,z as h,S as i,oe as j,Ir as k,Oe as l,F as m,Fe as n,Ce as o,Ge as p,To as q,Mo as r,Qe as s,_r as t,Go as u,Na as v,Da as w,Oa as x,Ea as y,Ma as z,Vo as A,Qo as B,Fa as C,ja as D,Ca as E,_a as F,Ha as G,Ka as H,Ba as I,qa as J,za as K,Ja as L,Ya as M,Ga as N,Va as O,Qa as P,Za as Q,ri as R,Xa as S,ed as T,td as U,nd as V,Wn as W,ld as X,ud as Y,cd as Z,pd as _,fd as $,En as aa,wd as ba};
41
- //# sourceMappingURL=chunk-O6KRXVN7.js.map
41
+ //# sourceMappingURL=chunk-I6P3BKWJ.js.map
@@ -1,8 +1,8 @@
1
- import{a as D,b as _}from"./chunk-RKPAVWXF.js";import{a as R,b as q,c as O,d as B,f as k,g as v,h as E,i as w,j as y}from"./chunk-GG6K5ZL6.js";import{a as T,b as C,c as I,d as x,e as P}from"./chunk-QHXKELKQ.js";import{existsSync as X,readFileSync as F}from"fs";var J=new Set(["cron","heartbeat","api","a2a","mesh"]),M=160;function s(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function S(n,e=M){let t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function V(n){let e=T(n);if(!X(e))throw new Error(`config not found at ${e}`);return JSON.parse(F(e,"utf-8"))}function W(n,e){return n?.agents?.[e]?.admin===!0}function Y(n,e,t){return W(n,t.agentId)||e?.createdBy===t.agentId}function Z(n,e){let t=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${t}. Agents manage only schedules they created (unless configured admin).`}function K(n,e){let t=s(n.notify);if(t!=="none"){if(t&&t!=="here"){let r=t.split(":");return r.length<2||!r[0]||!r[1]?"invalid":{channel:r[0],chatId:r.slice(1).join(":")}}if(e.channel&&e.chatId&&!J.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function Q(n,e,t){let r=e.timezone||"UTC",d=e.enabled&&!y(e)?w(E(e.schedule,r,t),r):"\u2014",h=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",f=[`- ${n} [${h}] ${e.schedule} \u2014 ${v(e.schedule)} (${r})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${d}`];return e.notify&&f.push(` notify: ${e.notify.channel} ${e.notify.chatId}${e.deliverResult===!1?" (failures only)":" (results and failures)"}`),e.command?f.push(` command: ${S(String(e.command))}`):e.prompt&&f.push(` prompt: ${S(String(e.prompt))}`),f.join(`
1
+ import{a as D,b as _}from"./chunk-RKPAVWXF.js";import{a as R,b as q,c as O,d as B,f as k,g as v,h as E,i as w,j as y}from"./chunk-OW2AND54.js";import{a as T,b as C,c as I,d as x,e as P}from"./chunk-VJC372D6.js";import{existsSync as X,readFileSync as F}from"fs";var J=new Set(["cron","heartbeat","api","a2a","mesh"]),M=160;function s(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function S(n,e=M){let t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function V(n){let e=T(n);if(!X(e))throw new Error(`config not found at ${e}`);return JSON.parse(F(e,"utf-8"))}function W(n,e){return n?.agents?.[e]?.admin===!0}function Y(n,e,t){return W(n,t.agentId)||e?.createdBy===t.agentId}function Z(n,e){let t=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${t}. Agents manage only schedules they created (unless configured admin).`}function K(n,e){let t=s(n.notify);if(t!=="none"){if(t&&t!=="here"){let r=t.split(":");return r.length<2||!r[0]||!r[1]?"invalid":{channel:r[0],chatId:r.slice(1).join(":")}}if(e.channel&&e.chatId&&!J.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function Q(n,e,t){let r=e.timezone||"UTC",d=e.enabled&&!y(e)?w(E(e.schedule,r,t),r):"\u2014",h=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",f=[`- ${n} [${h}] ${e.schedule} \u2014 ${v(e.schedule)} (${r})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${d}`];return e.notify&&f.push(` notify: ${e.notify.channel} ${e.notify.chatId}${e.deliverResult===!1?" (failures only)":" (results and failures)"}`),e.command?f.push(` command: ${S(String(e.command))}`):e.prompt&&f.push(` prompt: ${S(String(e.prompt))}`),f.join(`
2
2
  `)}async function b(n,e,t){let r=n?.notifications?.destination;if(!r?.channel||!r?.chatId)return"No operator notification destination is configured (notifications.destination); the operator must check `agentx schedule list`.";if(!e.notifyOperator)return"Operator notification is unavailable in this context.";try{return await e.notifyOperator({channel:r.channel,chatId:r.chatId,accountId:r.accountId},t),"The operator has been notified."}catch(d){return`Could not notify the operator (${d?.message??d}); the request is still recorded.`}}async function re(n,e,t={}){let r=(s(n.action)||"list").toLowerCase(),d=t.now?t.now():new Date,h;try{h=V(t.configPath)}catch(a){return`Error: ${a.message}`}let f=h.crons||{};if(r==="list"){let a=n.mine===!0,l=Object.entries(f).filter(([,i])=>!a||e&&i?.createdBy===e.agentId);return l.length?l.map(([i,p])=>Q(i,p,d)).join(`
3
3
  `):a?"You have no schedules.":"No schedules."}if(!e?.agentId)return"Error: caller agent is unknown (AGENTX_AGENT_ID not set). Pass callerAgentId.";if(!h.agents?.[e.agentId])return`Error: caller "${e.agentId}" is not an agent on this node.`;let o=s(n.id),m=a=>C(a,{configPath:t.configPath,reload:t.reload});if(r==="create"){let a=s(n.when),l=s(n.prompt);if(!a||!l)return"Error: create needs `when` (plain English) and `prompt`.";let i=D(a);if(!i)return`Error: couldn't parse "${a}". ${q}.`;let p=s(n.agent)||e.agentId;if(!h.agents?.[p])return`Error: agent "${p}" not found on this node.`;let g=s(n.timezone)||R;if(!B(g))return`Error: unknown timezone "${g}".`;let u=o||_(i.matched,p);if(!O(u))return`Error: invalid id "${u}" (letters, digits, "-" and "_" only).`;if(f[u])return`Error: a schedule "${u}" already exists. Pick another \`id\`.`;let $=K(n,e);if($==="invalid")return'Error: `notify` must be "here", "none", or "channel:chatId".';let z={action:"create",requestedBy:e.agentId,requestedAt:d.toISOString()},L=k({parsed:i,agent:p,prompt:l,timezone:g,notify:$,enabled:!1,createdBy:e.agentId,approval:z}),A=await m(U=>I(U,`crons.${u}`,L));if(!A.success)return`Error: ${A.error}`;let N=w(E(i.cron,g,d),g),G=[`Schedule approval requested by ${e.agentId}`,`Create: ${u}`,`When: ${i.human} \u2014 cron \`${i.cron}\` (${g})`,`Next fire: ${N}`,`Agent: ${p}`,$?`Results and failures go to: ${$.channel} ${$.chatId}${$.channel==="voice"?" (as a push notification)":""}`:"Results go to: run log only (no chat)",`Prompt: ${S(l,400)}`,"",`Approve: agentx schedule approve ${u}`,`Reject: agentx schedule reject ${u}`].join(`
4
4
  `),H=await b(h,t,G);return[`Requested schedule "${u}": ${i.human} (cron ${i.cron}, ${g}); next fire would be ${N}.`,"It is saved DISABLED and will not run until the operator approves it.",H].join(`
5
5
  `)}if(!o)return`Error: ${r} needs \`id\`.`;let c=f[o];if(!c)return`Error: schedule "${o}" not found.`;if(!Y(h,c,e))return Z(o,c);if(r==="pause"||r==="resume"){let a=r==="resume";if(a&&y(c))return`"${o}" is still awaiting operator approval; it can't be resumed until approved.`;if(c.enabled===a)return`"${o}" is already ${a?"active":"paused"}.`;let l=await m(i=>I(i,`crons.${o}.enabled`,a));return l.success?`"${o}" ${a?"resumed":"paused"}.`:`Error: ${l.error}`}if(r==="delete"){if(y(c)&&c.approval.requestedBy===e.agentId){let u=await m($=>P($,`crons.${o}`));return u.success?`Withdrew the pending request "${o}".`:`Error: ${u.error}`}if(y(c))return`"${o}" is a creation request still awaiting approval; only its requester or the operator (\`agentx schedule reject ${o}\`) can drop it.`;if(c.approval?.action==="delete")return`Deletion of "${o}" is already awaiting approval.`;let a={action:"delete",requestedBy:e.agentId,requestedAt:d.toISOString()},l=await m(u=>{if(!x(u,`crons.${o}`))throw new Error(`schedule "${o}" not found`);I(u,`crons.${o}.approval`,a)});if(!l.success)return`Error: ${l.error}`;let i=c.timezone||"UTC",p=[`Schedule approval requested by ${e.agentId}`,`Delete: ${o}`,`When: ${v(c.schedule)} \u2014 cron \`${c.schedule}\` (${i})`,`Next fire: ${c.enabled?w(E(c.schedule,i,d),i):"\u2014 (paused)"}`,`Agent: ${c.agent}`,"",`Approve: agentx schedule approve ${o}`,`Reject: agentx schedule reject ${o}`].join(`
6
6
  `),g=await b(h,t,p);return[`Deletion of "${o}" requested. It keeps its current state until the operator approves.`,g].join(`
7
7
  `)}return`Error: unknown action "${r}". Use list, create, pause, resume or delete.`}function oe(n,e=process.env){let t=s(e.AGENTX_AGENT_ID)||s(n.callerAgentId);if(!t)return null;let r=!!(s(e.AGENTX_CHANNEL)&&s(e.AGENTX_CHAT_ID)),d=s(r?e.AGENTX_CHANNEL:n.channel),h=s(r?e.AGENTX_CHAT_ID:n.chatId),f=s(n.accountId);return{agentId:t,channel:d,chatId:h,...f?{accountId:f}:{}}}export{re as a,oe as b};
8
- //# sourceMappingURL=chunk-ZKNSNSV2.js.map
8
+ //# sourceMappingURL=chunk-JLM6CXIH.js.map