agentix-cli 0.126.2 → 0.128.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 (152) hide show
  1. package/dist/{App-BUYK4EGC.js → App-BOLQUKCN.js} +2 -2
  2. package/dist/{ChatApp-ZS6EPDDK.js → ChatApp-72HXQV24.js} +2 -2
  3. package/dist/absorb-eval-O3HA6XA5.js +2 -0
  4. package/dist/{agent-WJTYM5HR.js → agent-S2DXXALS.js} +2 -2
  5. package/dist/{board-dashboard-DQR2OSV7.js → board-dashboard-ZKXXK5CG.js} +303 -228
  6. package/dist/board-dashboard-ZKXXK5CG.js.map +1 -0
  7. package/dist/chunk-2SV4RKRW.js +128 -0
  8. package/dist/chunk-2SV4RKRW.js.map +1 -0
  9. package/dist/{chunk-WUDVBPQV.js → chunk-4V7SWL2S.js} +2 -2
  10. package/dist/chunk-52SIHG45.js +4 -0
  11. package/dist/chunk-52SIHG45.js.map +1 -0
  12. package/dist/chunk-5DAEJF5S.js +36 -0
  13. package/dist/chunk-5DAEJF5S.js.map +1 -0
  14. package/dist/{chunk-GUQDPA6R.js → chunk-6GGGXCOY.js} +2 -2
  15. package/dist/{chunk-JIXNSA67.js → chunk-6KIUVVKX.js} +2 -2
  16. package/dist/{chunk-O4XEQTEN.js → chunk-C5MTLW7O.js} +3 -3
  17. package/dist/chunk-C5MTLW7O.js.map +1 -0
  18. package/dist/{chunk-FHBPKMCF.js → chunk-D2WX3BET.js} +2 -2
  19. package/dist/chunk-DN3RLR5Z.js +17 -0
  20. package/dist/chunk-DN3RLR5Z.js.map +1 -0
  21. package/dist/{chunk-Z7XXUYBB.js → chunk-DQ2LNQ2D.js} +33 -35
  22. package/dist/chunk-DQ2LNQ2D.js.map +1 -0
  23. package/dist/{chunk-UUVFH7BO.js → chunk-EJT4MA3J.js} +102 -102
  24. package/dist/chunk-EJT4MA3J.js.map +1 -0
  25. package/dist/chunk-FSW4FUMW.js +55 -0
  26. package/dist/chunk-FSW4FUMW.js.map +1 -0
  27. package/dist/chunk-FXBMFGOV.js +6 -0
  28. package/dist/chunk-FXBMFGOV.js.map +1 -0
  29. package/dist/{chunk-WMTGAVPW.js → chunk-HKW56YZK.js} +2 -2
  30. package/dist/{chunk-VXKNB4AW.js → chunk-LDS4SZBU.js} +2 -2
  31. package/dist/chunk-MRYA4J5F.js +54 -0
  32. package/dist/chunk-MRYA4J5F.js.map +1 -0
  33. package/dist/{chunk-LVV7JBHM.js → chunk-O2BS6N3T.js} +2 -2
  34. package/dist/{chunk-ZQWWMAMJ.js → chunk-P4XGM7ZM.js} +2 -2
  35. package/dist/{chunk-D6SWAB5J.js → chunk-QACEFESP.js} +32 -32
  36. package/dist/chunk-QACEFESP.js.map +1 -0
  37. package/dist/{chunk-6GLJIA25.js → chunk-QFZU5CEO.js} +2 -2
  38. package/dist/{chunk-FVG2BADS.js → chunk-QQFURUMS.js} +2 -2
  39. package/dist/chunk-QUXMLLX5.js +2 -0
  40. package/dist/chunk-QUXMLLX5.js.map +1 -0
  41. package/dist/{chunk-CY6ABHF2.js → chunk-TG6CT54D.js} +2 -2
  42. package/dist/chunk-TPNTFCSQ.js +4 -0
  43. package/dist/chunk-TPNTFCSQ.js.map +1 -0
  44. package/dist/{chunk-56KNKUFF.js → chunk-VD7IO653.js} +3 -3
  45. package/dist/{chunk-56KNKUFF.js.map → chunk-VD7IO653.js.map} +1 -1
  46. package/dist/{chunk-JUIL2EW3.js → chunk-YWKLUQDC.js} +2 -2
  47. package/dist/chunk-Z3W7D5RR.js +4 -0
  48. package/dist/chunk-Z3W7D5RR.js.map +1 -0
  49. package/dist/{chunk-QQYXYJOG.js → chunk-ZLC4TSXF.js} +2 -2
  50. package/dist/cli.js +1 -1
  51. package/dist/{client-PO5LDFS4.js → client-VBV7Q43P.js} +2 -2
  52. package/dist/config-52C3DJD2.js +2 -0
  53. package/dist/config-mutate-DKQESY6F.js +2 -0
  54. package/dist/config-mutator-BF4D4QGN.js +2 -0
  55. package/dist/contributions-5OEZWYXI.js +57 -0
  56. package/dist/contributions-5OEZWYXI.js.map +1 -0
  57. package/dist/doctor-VLRC4HW2.js +2 -0
  58. package/dist/{follow-up-tool-AIOLNUF7.js → follow-up-tool-235LDEMP.js} +2 -2
  59. package/dist/{follow-up-tool-AIOLNUF7.js.map → follow-up-tool-235LDEMP.js.map} +1 -1
  60. package/dist/hub-5QK7KYTZ.js +2 -0
  61. package/dist/index.d.ts +339 -50
  62. package/dist/index.js +1 -1
  63. package/dist/index.js.map +1 -1
  64. package/dist/notes-YLTNRMB5.js +2 -0
  65. package/dist/notes-settings-X63D5HPM.js +2 -0
  66. package/dist/{program-LGCT7FFJ.js → program-MVD57PKP.js} +236 -232
  67. package/dist/program-MVD57PKP.js.map +1 -0
  68. package/dist/{promote-MQYJMGGZ.js → promote-UPPQ4BQE.js} +2 -2
  69. package/dist/query-XQS5JN6E.js +2 -0
  70. package/dist/registry-MOMTLJ6R.js +2 -0
  71. package/dist/{request-planner-XYHM26CO.js → request-planner-QGZJEAKY.js} +2 -2
  72. package/dist/{review-candidates-XRBAMRBH.js → review-candidates-PAKF2JQF.js} +2 -2
  73. package/dist/{rotation-memo-6UW6DTBQ.js → rotation-memo-7VLREGS6.js} +2 -2
  74. package/dist/routing-JG3EV4O4.js +2 -0
  75. package/dist/schedule-tool-O7ZZ2A7X.js +2 -0
  76. package/dist/scheduler-LMPBAA34.js +2 -0
  77. package/dist/scheduler-LMPBAA34.js.map +1 -0
  78. package/dist/score-KDNIUTNV.js +3 -0
  79. package/dist/score-KDNIUTNV.js.map +1 -0
  80. package/dist/{seat-LKBZ6SDS.js → seat-JN3IVZ3G.js} +2 -2
  81. package/dist/seat-JN3IVZ3G.js.map +1 -0
  82. package/dist/{select-BSC3TFMZ.js → select-ZMMRFMNO.js} +2 -2
  83. package/dist/{set-enabled-YWXWSKME.js → set-enabled-7Y3TW6Z4.js} +2 -2
  84. package/dist/{tool-FZEC5FQX.js → tool-OCYXCDOK.js} +2 -2
  85. package/dist/{tool-FZEC5FQX.js.map → tool-OCYXCDOK.js.map} +1 -1
  86. package/dist/{tool-5JTCSRTW.js → tool-S7QI6HRA.js} +2 -2
  87. package/dist/{tool-5JTCSRTW.js.map → tool-S7QI6HRA.js.map} +1 -1
  88. package/dist/wiki-OCLFFZG6.js +2 -0
  89. package/dist/wiki-OCLFFZG6.js.map +1 -0
  90. package/package.json +1 -1
  91. package/dist/absorb-eval-5Y5IZWW2.js +0 -2
  92. package/dist/board-dashboard-DQR2OSV7.js.map +0 -1
  93. package/dist/chunk-2C3X6DVD.js +0 -49
  94. package/dist/chunk-2C3X6DVD.js.map +0 -1
  95. package/dist/chunk-2W3X6H7Z.js +0 -51
  96. package/dist/chunk-2W3X6H7Z.js.map +0 -1
  97. package/dist/chunk-46JKX6CT.js +0 -54
  98. package/dist/chunk-46JKX6CT.js.map +0 -1
  99. package/dist/chunk-5DFUUYEA.js +0 -126
  100. package/dist/chunk-5DFUUYEA.js.map +0 -1
  101. package/dist/chunk-D6SWAB5J.js.map +0 -1
  102. package/dist/chunk-O4XEQTEN.js.map +0 -1
  103. package/dist/chunk-UUVFH7BO.js.map +0 -1
  104. package/dist/chunk-YNA5T43U.js +0 -4
  105. package/dist/chunk-YNA5T43U.js.map +0 -1
  106. package/dist/chunk-Z7XXUYBB.js.map +0 -1
  107. package/dist/config-L2RQ6EJX.js +0 -2
  108. package/dist/config-mutator-44OAOZXM.js +0 -2
  109. package/dist/doctor-AU5TCOSG.js +0 -2
  110. package/dist/hub-53YQQCVA.js +0 -2
  111. package/dist/program-LGCT7FFJ.js.map +0 -1
  112. package/dist/query-DNJONEKC.js +0 -2
  113. package/dist/registry-5A3SLBVJ.js +0 -2
  114. package/dist/routing-OMIWZKNC.js +0 -2
  115. package/dist/schedule-tool-YRANRFHO.js +0 -2
  116. package/dist/scheduler-L4P4Z55R.js +0 -2
  117. package/dist/wiki-BT3H2WCD.js +0 -2
  118. /package/dist/{App-BUYK4EGC.js.map → App-BOLQUKCN.js.map} +0 -0
  119. /package/dist/{ChatApp-ZS6EPDDK.js.map → ChatApp-72HXQV24.js.map} +0 -0
  120. /package/dist/{absorb-eval-5Y5IZWW2.js.map → absorb-eval-O3HA6XA5.js.map} +0 -0
  121. /package/dist/{agent-WJTYM5HR.js.map → agent-S2DXXALS.js.map} +0 -0
  122. /package/dist/{chunk-WUDVBPQV.js.map → chunk-4V7SWL2S.js.map} +0 -0
  123. /package/dist/{chunk-GUQDPA6R.js.map → chunk-6GGGXCOY.js.map} +0 -0
  124. /package/dist/{chunk-JIXNSA67.js.map → chunk-6KIUVVKX.js.map} +0 -0
  125. /package/dist/{chunk-FHBPKMCF.js.map → chunk-D2WX3BET.js.map} +0 -0
  126. /package/dist/{chunk-WMTGAVPW.js.map → chunk-HKW56YZK.js.map} +0 -0
  127. /package/dist/{chunk-VXKNB4AW.js.map → chunk-LDS4SZBU.js.map} +0 -0
  128. /package/dist/{chunk-LVV7JBHM.js.map → chunk-O2BS6N3T.js.map} +0 -0
  129. /package/dist/{chunk-ZQWWMAMJ.js.map → chunk-P4XGM7ZM.js.map} +0 -0
  130. /package/dist/{chunk-6GLJIA25.js.map → chunk-QFZU5CEO.js.map} +0 -0
  131. /package/dist/{chunk-FVG2BADS.js.map → chunk-QQFURUMS.js.map} +0 -0
  132. /package/dist/{chunk-CY6ABHF2.js.map → chunk-TG6CT54D.js.map} +0 -0
  133. /package/dist/{chunk-JUIL2EW3.js.map → chunk-YWKLUQDC.js.map} +0 -0
  134. /package/dist/{chunk-QQYXYJOG.js.map → chunk-ZLC4TSXF.js.map} +0 -0
  135. /package/dist/{client-PO5LDFS4.js.map → client-VBV7Q43P.js.map} +0 -0
  136. /package/dist/{config-L2RQ6EJX.js.map → config-52C3DJD2.js.map} +0 -0
  137. /package/dist/{config-mutator-44OAOZXM.js.map → config-mutate-DKQESY6F.js.map} +0 -0
  138. /package/dist/{doctor-AU5TCOSG.js.map → config-mutator-BF4D4QGN.js.map} +0 -0
  139. /package/dist/{hub-53YQQCVA.js.map → doctor-VLRC4HW2.js.map} +0 -0
  140. /package/dist/{promote-MQYJMGGZ.js.map → hub-5QK7KYTZ.js.map} +0 -0
  141. /package/dist/{query-DNJONEKC.js.map → notes-YLTNRMB5.js.map} +0 -0
  142. /package/dist/{registry-5A3SLBVJ.js.map → notes-settings-X63D5HPM.js.map} +0 -0
  143. /package/dist/{routing-OMIWZKNC.js.map → promote-UPPQ4BQE.js.map} +0 -0
  144. /package/dist/{schedule-tool-YRANRFHO.js.map → query-XQS5JN6E.js.map} +0 -0
  145. /package/dist/{scheduler-L4P4Z55R.js.map → registry-MOMTLJ6R.js.map} +0 -0
  146. /package/dist/{request-planner-XYHM26CO.js.map → request-planner-QGZJEAKY.js.map} +0 -0
  147. /package/dist/{review-candidates-XRBAMRBH.js.map → review-candidates-PAKF2JQF.js.map} +0 -0
  148. /package/dist/{rotation-memo-6UW6DTBQ.js.map → rotation-memo-7VLREGS6.js.map} +0 -0
  149. /package/dist/{seat-LKBZ6SDS.js.map → routing-JG3EV4O4.js.map} +0 -0
  150. /package/dist/{wiki-BT3H2WCD.js.map → schedule-tool-O7ZZ2A7X.js.map} +0 -0
  151. /package/dist/{select-BSC3TFMZ.js.map → select-ZMMRFMNO.js.map} +0 -0
  152. /package/dist/{set-enabled-YWXWSKME.js.map → set-enabled-7Y3TW6Z4.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{b as ft,c as gt}from"./chunk-GLQLCBJS.js";import{a as dt}from"./chunk-GV7S5BAX.js";import{c as lt}from"./chunk-SZDACK6O.js";import{b as ye}from"./chunk-AFRHKA7B.js";import{b as it,e as st,f as at,i as ct,k as ut,l as pt,q as mt}from"./chunk-5DFUUYEA.js";import{c as nt,e as rt,f as ot}from"./chunk-KA2UIZXG.js";import{e as Qe,g as et,h as tt,i as we}from"./chunk-GQ76J72O.js";import{y as Ve,z as En}from"./chunk-JUIL2EW3.js";import{b as Ge,f as Dn}from"./chunk-72SZI2UW.js";import{a as Ze,b as ge,c as me,d as Xe,e as he}from"./chunk-QD6IICK7.js";import{c as Je,d as Ye}from"./chunk-QOYAX2FT.js";import{f as fe,n as On}from"./chunk-UIBUZ2N3.js";import{existsSync as Mn,mkdirSync as ht,readFileSync as Fn,writeFileSync as jn,renameSync as Cn}from"fs";import{resolve as wt,dirname as _n}from"path";var yt=class{filePath;log;constructor(e={}){let t=e.baseDir??wt(process.cwd(),".agentx");this.filePath=wt(t,"handover.json"),this.log=e.log??console.error.bind(console,"[handover]"),ht(t,{recursive:!0})}key(e,t,r){return`${e}::${t}::${r||"-"}`}load(){if(!Mn(this.filePath))return{version:1,overrides:{}};try{let e=Fn(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){ht(_n(this.filePath),{recursive:!0});let t=`${this.filePath}.tmp-${process.pid}`;jn(t,JSON.stringify(e,null,2)),Cn(t,this.filePath)}get(e,t,r){let i=this.load().overrides[this.key(e,t,r)];if(i&&!(i.expiresAt&&Date.parse(i.expiresAt)<Date.now()))return i}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(),i=this.key(e,t,r);return i in o.overrides?(delete o.overrides[i],this.save(o),!0):!1}consumeSummary(e,t,r){let o=this.load(),i=o.overrides[this.key(e,t,r)];if(!i||!i.summary||i.summaryConsumedAt)return;let a=i.summary;return i.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 $t,writeFileSync as ke,appendFileSync as Bn,mkdirSync as Kn,existsSync as St,statSync as zn}from"fs";import{resolve as J}from"path";var kt="[Agent Memory \u2014 persistent facts from past conversations]",Ln=2400;function bt(n,e){return n?`UNVERIFIED (${e===null?"age unknown":`${e}d old`}) `:""}function Un(n,e=Date.now()){let t=rt(n,e),r=n.undated?"UNVERIFIED (never checked) ":bt(t,Qe(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 Hn(n,e){let r=!n.source.chatId.startsWith("-")&&/^\d+$/.test(n.source.chatId)?"DM":n.source.chatId,o=tt(n,e);return{line:`- [${n.category}] ${bt(o,et(n,e))}${n.content} (${r}, ${n.source.date})`,unverified:o}}function vt(n,e=[],t=Date.now()){let r=[],o=new Set,i=kt.length,a=!1;for(let s of n){let d=e.length>0?ot(s.content,e):null,l,p,u=d&&Date.parse(s.createdAt)>Date.parse(d.verifiedAt)&&!s.content.toLowerCase().includes(d.value.toLowerCase());if(d&&!u){if(o.has(d.id))continue;o.add(d.id),l=Un(d,t),p=d.id}else l=Hn(s,t),d&&(l.line+=` [differs from wiki ${d.id}]`);let f=l.unverified&&!a?we.length:0;if(i+f+l.line.length>Ln)break;r.push({fact:s,...l,...p?{wikiRef:p}:{}}),i+=f+l.line.length,f&&(a=!0)}return r}function It(n){if(n.length===0)return"";let e=n.some(t=>t.unverified)?[we]:[];return[kt,...e,...n.map(t=>t.line),"[End Memory]"].join(`
1
+ import{b as ft,c as gt}from"./chunk-GLQLCBJS.js";import{b as it,e as st,f as at,i as ct,k as ut,l as pt,q as mt}from"./chunk-2SV4RKRW.js";import{a as dt}from"./chunk-GV7S5BAX.js";import{c as lt}from"./chunk-SZDACK6O.js";import{b as ye}from"./chunk-AFRHKA7B.js";import{c as nt,e as rt,f as ot}from"./chunk-KA2UIZXG.js";import{e as Qe,g as et,h as tt,i as we}from"./chunk-GQ76J72O.js";import{y as Ve,z as En}from"./chunk-YWKLUQDC.js";import{b as Ge,f as Dn}from"./chunk-72SZI2UW.js";import{a as Ze,b as ge,c as me,d as Xe,e as he}from"./chunk-QD6IICK7.js";import{c as Je,d as Ye}from"./chunk-QOYAX2FT.js";import{f as fe,n as On}from"./chunk-UIBUZ2N3.js";import{existsSync as Mn,mkdirSync as ht,readFileSync as Fn,writeFileSync as jn,renameSync as Cn}from"fs";import{resolve as wt,dirname as _n}from"path";var yt=class{filePath;log;constructor(e={}){let t=e.baseDir??wt(process.cwd(),".agentx");this.filePath=wt(t,"handover.json"),this.log=e.log??console.error.bind(console,"[handover]"),ht(t,{recursive:!0})}key(e,t,r){return`${e}::${t}::${r||"-"}`}load(){if(!Mn(this.filePath))return{version:1,overrides:{}};try{let e=Fn(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){ht(_n(this.filePath),{recursive:!0});let t=`${this.filePath}.tmp-${process.pid}`;jn(t,JSON.stringify(e,null,2)),Cn(t,this.filePath)}get(e,t,r){let i=this.load().overrides[this.key(e,t,r)];if(i&&!(i.expiresAt&&Date.parse(i.expiresAt)<Date.now()))return i}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(),i=this.key(e,t,r);return i in o.overrides?(delete o.overrides[i],this.save(o),!0):!1}consumeSummary(e,t,r){let o=this.load(),i=o.overrides[this.key(e,t,r)];if(!i||!i.summary||i.summaryConsumedAt)return;let a=i.summary;return i.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 $t,writeFileSync as ke,appendFileSync as Bn,mkdirSync as Kn,existsSync as St,statSync as zn}from"fs";import{resolve as J}from"path";var kt="[Agent Memory \u2014 persistent facts from past conversations]",Ln=2400;function bt(n,e){return n?`UNVERIFIED (${e===null?"age unknown":`${e}d old`}) `:""}function Un(n,e=Date.now()){let t=rt(n,e),r=n.undated?"UNVERIFIED (never checked) ":bt(t,Qe(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 Hn(n,e){let r=!n.source.chatId.startsWith("-")&&/^\d+$/.test(n.source.chatId)?"DM":n.source.chatId,o=tt(n,e);return{line:`- [${n.category}] ${bt(o,et(n,e))}${n.content} (${r}, ${n.source.date})`,unverified:o}}function vt(n,e=[],t=Date.now()){let r=[],o=new Set,i=kt.length,a=!1;for(let s of n){let d=e.length>0?ot(s.content,e):null,l,p,u=d&&Date.parse(s.createdAt)>Date.parse(d.verifiedAt)&&!s.content.toLowerCase().includes(d.value.toLowerCase());if(d&&!u){if(o.has(d.id))continue;o.add(d.id),l=Un(d,t),p=d.id}else l=Hn(s,t),d&&(l.line+=` [differs from wiki ${d.id}]`);let f=l.unverified&&!a?we.length:0;if(i+f+l.line.length>Ln)break;r.push({fact:s,...l,...p?{wikiRef:p}:{}}),i+=f+l.line.length,f&&(a=!0)}return r}function It(n){if(n.length===0)return"";let e=n.some(t=>t.unverified)?[we]:[];return[kt,...e,...n.map(t=>t.line),"[End Memory]"].join(`
2
2
  `)}var At=200,qn=7,Rt=class{memoryDir;ledger;constructor(e=process.cwd()){this.memoryDir=J(e,".agentx/memory"),this.ledger=new nt(J(e,".agentx/wiki")),St(this.memoryDir)||Kn(this.memoryDir,{recursive:!0})}filePath(e){return J(this.memoryDir,`${e}.jsonl`)}addMemory(e,t){if(t.category==="secret"||ge(t.content))return!1;let r=t.source.trust??Ze(t.source.channel),o=t.review??Xe(r),i={...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 Bn(this.filePath(e),JSON.stringify(i)+`
3
3
  `),!0}parsedCache=new Map;getAll(e){let t=this.filePath(e);if(!St(t))return[];try{let{mtimeMs:r,size:o}=zn(t),i=this.parsedCache.get(t);if(i&&i.mtimeMs===r&&i.size===o)return i.facts.slice();let s=$t(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:s}),s.slice()}catch{return[]}}findRelevant(e,t,r=8){let o=this.getAll(t).filter(he);if(o.length===0)return[];let i=o.map(g=>`${g.keywords.join(" ")} ${g.content}`),a=J(this.memoryDir,`${t}_bm25_cache.json`),s=Ye(i,a),d=Je(e,s),l=new Map(d.map(g=>[g.docIndex,g.score])),u=o.map((g,h)=>{let y=l.get(h)??0;return g.category==="commitment"&&(y+=1),{memory:g,score:y}}).filter(g=>g.score>0);if(u.length===0)return o.slice(-r);let f=u.sort((g,h)=>h.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 It(this.contextLines(e))}contextFacts(e){return this.contextLines(e).map(t=>t.fact)}contextLines(e){let t=[];try{t=this.ledger.list()}catch{}return vt(e,t)}recordAccess(e,t){if(t.length===0)return;let r=this.getAll(e),o=new Set(t),i=!1;for(let a of r)if(o.has(a.id)){a.accessCount=(a.accessCount||0)+1,a.lastAccessed=new Date().toISOString();let s=a.intervalDays||1;a.intervalDays=Math.min(s*2,30),a.nextReview=new Date(Date.now()+a.intervalDays*864e5).toISOString(),i=!0}i&&ke(this.filePath(e),r.map(a=>JSON.stringify(a)).join(`
@@ -34,4 +34,4 @@ ${n.text}`}async function se(n,e){let t=n.channels[e.channel],r={channel:e.chann
34
34
  `).filter(Boolean),o=[];for(let i=r.length-1;i>=0&&o.length<t;i--)try{let a=JSON.parse(r[i]);(!e||a.person===e)&&o.push(a)}catch{}return o}load(){if(He(this.file))try{let e=JSON.parse(Be(this.file,"utf-8"));if(e&&Array.isArray(e.devices))return e}catch{}return{devices:[]}}save(e){gn(wn(this.file),{recursive:!0});let t=`${this.file}.${process.pid}.${kn(4).toString("hex")}.tmp`;hn(t,JSON.stringify(e,null,2)+`
35
35
  `,{encoding:"utf-8",mode:384}),mn(t,this.file)}};import{extname as Uo}from"path";var vn=/<agentx-artifact>([\s\S]*?)<\/agentx-artifact>/gi,In=/<agentx-artifact>[\s\S]*$/i;function Sa(n,e=1/0,t=!1){let r=[],o=String(n??"");if(!/<agentx-artifact>/i.test(o))return{text:o,artifacts:r};let i=o.replace(vn,(a,s)=>{try{let d=JSON.parse(s.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?i.replace(In,""):i).trim(),artifacts:r}}function Aa(n,e=!1){let t=String(n??""),r=t;if(/<agentx-artifact>/i.test(t)){let o=t.replace(vn,(i,a)=>{try{let s=JSON.parse(a.trim());return s&&typeof s.filename=="string"?s.filename:""}catch{return""}});r=(e?o.replace(In,""):o).trim()}return r.replace(/```[\s\S]*?```|`[^`\n]*`|!\[([^\]\n]*)\]\(([^)\s]+)\)/g,(o,i,a)=>i===void 0||a===void 0?o:`[${i||a}](${a})`)}var Ho={".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"}},Ra={bytes:20*1024*1024,perMessage:20,pathChars:512};function xa(n){return Ho[Uo(n).toLowerCase()]??null}var Bo=["[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(`
36
36
  `);function Pa(n,e,t){return n==="app"&&e&&t!==!1?Bo:void 0}import{lstatSync as ze,mkdirSync as Ko,readdirSync as zo,realpathSync as Ke,unlinkSync as qo}from"fs";import{join as ue,resolve as $n}from"path";var Sn=".agentx/outbox",Jo=7*24*60*60*1e3;function Yo(n,e){try{let t=Ke($n(e,n)),r=ue(t,Sn);return Ke(r)===r&&ze(r).isDirectory()?r:null}catch{return null}}function Oa(n,e={}){let t=e.cwd??process.cwd();if(e.create!==!1)try{let o=Ke($n(t,n));ze(ue(o,".agentx"),{throwIfNoEntry:!1})?.isSymbolicLink()||Ko(ue(o,Sn),{recursive:!0})}catch{return 0}let r=Yo(n,t);return r?An(r,(e.now??Date.now())-(e.maxAgeMs??Jo)):0}function An(n,e){let t=0;for(let r of zo(n)){let o=ue(n,r);try{let i=ze(o);i.isDirectory()?t+=An(o,e):Math.max(i.mtimeMs,i.ctimeMs)<e&&(qo(o),t++)}catch{}}return t}export{yt as a,Rt as b,xt as c,ci as d,Gn as e,ui as f,R as g,U as h,I as i,G as j,dr as k,Se as l,Re as m,Pe as n,_e as o,mo as p,vo as q,Ue as r,Rr as s,Mo as t,la as u,ca as v,ua as w,pa as x,fa as y,Fo as z,jo as A,ga as B,ma as C,ha as D,wa as E,bn as F,Sa as G,Aa as H,Ra as I,xa as J,Pa as K,Sn as L,Oa as M};
37
- //# sourceMappingURL=chunk-LVV7JBHM.js.map
37
+ //# sourceMappingURL=chunk-O2BS6N3T.js.map
@@ -1,4 +1,4 @@
1
- import{a as O}from"./chunk-3PGPN323.js";import{a as I,b as R,c as j,d as M,e as E,j as T}from"./chunk-VXKNB4AW.js";import{y as C,z as N}from"./chunk-JUIL2EW3.js";import{c as _,d as x}from"./chunk-QOYAX2FT.js";import{b as L}from"./chunk-4VVHGR7H.js";import{readFileSync as W,writeFileSync as k,appendFileSync as B,existsSync as w,mkdirSync as S,readdirSync as D,statSync as U}from"fs";import{resolve as u,join as K,relative as y,dirname as J}from"path";N();function V(A){return O.includes(A)}function F(A){if(!A)return;let t;try{t=JSON.parse(A)}catch{return}if(!Array.isArray(t))return;let e=t.filter(r=>typeof r=="object"&&r!==null&&typeof r.property=="string"&&r.property!==""&&typeof r.value=="string"&&r.value!=="");return e.length?e:void 0}var P=class{baseDir;rawDir;log;constructor(t=u(process.cwd(),".agentx/wiki"),e=console.error.bind(console,"[wiki]")){this.baseDir=t,this.rawDir=u(t,"raw/entries"),this.log=e,S(this.rawDir,{recursive:!0}),S(u(t,"raw"),{recursive:!0}),this.ensureSchema()}canRead(t,e){return t.access==="public"?!0:e?!!(t.owner===e||t.access==="shared"&&t.sharedWith?.includes(e)):!1}canWrite(t,e){return t.owner===e}addEntry(t){let e=`${t.date}_${t.id}.md`,r=u(this.rawDir,e),n=["---",`id: ${t.id}`,`date: ${t.date}`,`agent: ${t.agentId}`,`source: ${t.source}`];if(t.sourceContext&&n.push(`context: ${t.sourceContext}`),t.meta)for(let[o,s]of Object.entries(t.meta))n.push(`${o}: ${JSON.stringify(s)}`);return n.push("---","",t.content),k(r,n.join(`
1
+ import{a as O}from"./chunk-3PGPN323.js";import{a as I,b as R,c as j,d as M,e as E,j as T}from"./chunk-LDS4SZBU.js";import{y as C,z as N}from"./chunk-YWKLUQDC.js";import{c as _,d as x}from"./chunk-QOYAX2FT.js";import{b as L}from"./chunk-4VVHGR7H.js";import{readFileSync as W,writeFileSync as k,appendFileSync as B,existsSync as w,mkdirSync as S,readdirSync as D,statSync as U}from"fs";import{resolve as u,join as K,relative as y,dirname as J}from"path";N();function V(A){return O.includes(A)}function F(A){if(!A)return;let t;try{t=JSON.parse(A)}catch{return}if(!Array.isArray(t))return;let e=t.filter(r=>typeof r=="object"&&r!==null&&typeof r.property=="string"&&r.property!==""&&typeof r.value=="string"&&r.value!=="");return e.length?e:void 0}var P=class{baseDir;rawDir;log;constructor(t=u(process.cwd(),".agentx/wiki"),e=console.error.bind(console,"[wiki]")){this.baseDir=t,this.rawDir=u(t,"raw/entries"),this.log=e,S(this.rawDir,{recursive:!0}),S(u(t,"raw"),{recursive:!0}),this.ensureSchema()}canRead(t,e){return t.access==="public"?!0:e?!!(t.owner===e||t.access==="shared"&&t.sharedWith?.includes(e)):!1}canWrite(t,e){return t.owner===e}addEntry(t){let e=`${t.date}_${t.id}.md`,r=u(this.rawDir,e),n=["---",`id: ${t.id}`,`date: ${t.date}`,`agent: ${t.agentId}`,`source: ${t.source}`];if(t.sourceContext&&n.push(`context: ${t.sourceContext}`),t.meta)for(let[o,s]of Object.entries(t.meta))n.push(`${o}: ${JSON.stringify(s)}`);return n.push("---","",t.content),k(r,n.join(`
2
2
  `)),this.appendLog("ingest",`${t.id} from ${t.agentId} via ${t.source}`),e}readEntries(t){if(t.length===0||!w(this.rawDir))return[];let e=new Set(t),r=[];for(let n of D(this.rawDir)){let o=n.replace(/\.md$/,"").replace(/^\d{4}-\d{2}-\d{2}_/,"");if(!e.has(o))continue;let s=this.parseEntry(W(u(this.rawDir,n),"utf-8"),n);s&&r.push(s)}return r}listEntries(t){if(!w(this.rawDir))return[];let e=D(this.rawDir).filter(n=>n.endsWith(".md")).sort(),r=[];for(let n of e){let o=W(u(this.rawDir,n),"utf-8"),s=this.parseEntry(o,n);s&&(t?.agentId&&s.agentId!==t.agentId||t?.after&&s.date<t.after||t?.before&&s.date>t.before||r.push(s))}return r}parseEntry(t,e){let r=t.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!r)return null;let n=r[1],o=r[2].trim(),s=c=>n.match(new RegExp(`^${c}:\\s*(.+)$`,"m"))?.[1]?.trim()||"",a=new Set(["id","date","agent","source","context"]),i={};for(let c of n.split(`
3
3
  `)){let l=c.match(/^(\w+):\s*(.+)$/);if(!(!l||a.has(l[1])))try{i[l[1]]=JSON.parse(l[2])}catch{i[l[1]]=l[2].trim()}}return{id:s("id")||e.replace(".md",""),date:s("date"),agentId:s("agent"),source:s("source"),sourceContext:s("context")||void 0,content:o,meta:Object.keys(i).length>0?i:void 0}}writeArticle(t,e,r,n){let o=this.readArticle(t);if(o&&!this.canWrite(o.meta,n))return this.log(`Permission denied: "${n}" cannot write "${t}" (owner: ${o.meta.owner})`),!1;e.type&&!L(e.type)&&(this.log(`Dropping invalid article type "${e.type}" for "${t}" \u2014 enum is [person, project, place, concept, event, decision, pattern]`),e={...e,type:void 0});let s=u(this.baseDir,t);o&&this.saveVersion(t,s),S(J(s),{recursive:!0});let a=["---",`title: "${e.title}"`];e.type&&a.push(`type: ${e.type}`),e.related?.length&&a.push(`related: [${e.related.map(c=>`"${c}"`).join(", ")}]`),a.push(`tags: [${(e.tags||[]).map(c=>`"${c}"`).join(", ")}]`,`owner: ${e.owner}`,`access: ${e.access}`),e.sharedWith?.length&&a.push(`shared_with: [${e.sharedWith.map(c=>`"${c}"`).join(", ")}]`),a.push(`created: ${e.created}`,`last_updated: ${e.lastUpdated}`,`sources: [${e.sources.map(c=>`"${c}"`).join(", ")}]`),e.graphPath?.length&&a.push(`graph_path: [${e.graphPath.map(c=>`"${c}"`).join(", ")}]`),e.class&&a.push(`class: ${e.class}`),e.importance&&a.push(`importance: ${e.importance}`),e.date&&a.push(`date: ${e.date}`),e.rolledUpInto&&a.push(`rolled_up_into: ${JSON.stringify(e.rolledUpInto)}`),e.aliases?.length&&a.push(`aliases: ${JSON.stringify(e.aliases)}`),e.statements?.length&&a.push(`statements: ${JSON.stringify(e.statements)}`),a.push("---","",r),k(s,a.join(`
4
4
  `));let i=o?"update":"create";return this.appendLog(i,`${e.title} [${(e.tags||[]).slice(0,5).join(", ")}] by ${n} at ${t}`),!0}saveVersion(t,e){try{if(!w(e))return;let r=W(e,"utf-8"),n=new Date().toISOString().replace(/[:.]/g,"-"),o=u(this.baseDir,"_versions",t.replace(/\.md$/,""));S(o,{recursive:!0}),k(u(o,`${n}.md`),r)}catch{}}getVersions(t){let e=u(this.baseDir,"_versions",t.replace(/\.md$/,""));if(!w(e))return[];try{return D(e).filter(r=>r.endsWith(".md")).sort().reverse().map(r=>({timestamp:r.replace(/\.md$/,"").replace(/-/g,(n,o)=>o<19?o===10?"T":o===13||o===16?":":"-":n),path:u(e,r)}))}catch{return[]}}restoreVersion(t,e){let n=this.getVersions(t).find(o=>o.timestamp.startsWith(e));if(!n)return!1;try{let o=W(n.path,"utf-8"),s=u(this.baseDir,t);return this.saveVersion(t,s),k(s,o),this.appendLog("restore",`${t} restored to ${e}`),!0}catch{return!1}}readArticle(t){let e=u(this.baseDir,t);if(!w(e))return null;let r=W(e,"utf-8");return this.parseArticle(r,t)}readArticleAs(t,e){let r=this.readArticle(t);return!r||!this.canRead(r.meta,e)?null:r}parseArticle(t,e){let r=t.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!r)return null;let n=r[1],o=r[2].trim(),s=f=>n.match(new RegExp(`^${f}:\\s*(.+)$`,"m"))?.[1]?.trim().replace(/^"(.*)"$/,"$1")||"",a=f=>{let $=n.match(new RegExp(`^${f}:\\s*\\[(.*)\\]$`,"m"));return $?[...$[1].matchAll(/\s*(?:"(.*?)"(?=\s*(?:,|$))|([^,]+))/g)].map(v=>(v[1]??v[2]).trim()).filter(Boolean):[]},i=s("type")||s("kind"),l=new Set(["person","project","place","concept","event","decision","pattern"]).has(i)?i:void 0,g=a("tags").filter((f,$,v)=>f&&v.indexOf(f)===$),d=a("related"),p=a("graph_path"),m=a("aliases"),h=s("importance"),b=s("date");return{meta:{title:s("title"),type:l,related:d.length?d:void 0,tags:g,owner:s("owner"),access:s("access")||"public",sharedWith:a("shared_with"),created:s("created"),lastUpdated:s("last_updated"),sources:a("sources"),graphPath:p.length?p:void 0,class:/^[a-z][a-z0-9_]*$/.test(s("class"))?s("class"):void 0,importance:V(h)?h:void 0,date:/^\d{4}-\d{2}-\d{2}/.test(b)?b.slice(0,10):void 0,rolledUpInto:s("rolled_up_into")||void 0,aliases:m.length?m:void 0,statements:F(s("statements"))},content:o,path:e}}listCache=new Map;listArticles(t){return this.listCached(t)}listAllArticles(){return this.listCached(null)}listCached(t){let e=[],r=[];this.walkDir(this.baseDir,(i,c)=>{if(!i.endsWith(".md"))return;let l=y(this.baseDir,i);l.startsWith("raw/")||l.startsWith("_")||(e.push(l),r.push(`${l}:${c?.mtimeMs??"?"}:${c?.size??"?"}`))});let n=r.join("|"),o=t??"\0all",s=this.listCache.get(o);if(s&&s.signature===n)return s.articles.slice();let a=[];for(let i of e){let c=this.readArticle(i);c&&(t===null||this.canRead(c.meta,t))&&a.push(c)}return this.listCache.set(o,{signature:n,articles:a}),a.slice()}search(t,e,r=10){let n=t.toLowerCase(),o=[];if(this.walkDir(this.baseDir,d=>{if(!d.endsWith(".md"))return;let p=y(this.baseDir,d);if(p.startsWith("raw/")||p.startsWith("_"))return;let m=this.readArticle(p);!m||!this.canRead(m.meta,e)||o.push(m)}),o.length===0)return[];let s=o.map(d=>d.content),a=u(this.baseDir,"_bm25_cache.json"),i=x(s,a),c=_(t,i),l=new Map(c.map(d=>[d.docIndex,d.score]));return o.map((d,p)=>{let m=l.get(p)??0;return d.meta.title.toLowerCase().includes(n)&&(m+=10),d.meta.tags?.some(h=>h.toLowerCase().includes(n))&&(m+=5),{article:d,score:m}}).filter(d=>d.score>0).sort((d,p)=>p.score-d.score).slice(0,r).map(d=>d.article)}async findRelevantReranked(t,e,r=10,n={}){let o=Math.max(r,n.shortlist??R),s=this.findRelevant(t,e,o);if(s.length<2)return s.slice(0,r);let a=s.map((l,g)=>({id:`c${g}`,title:l.meta.title||`(untitled ${g})`,tags:l.meta.tags,excerpt:l.content})),i=await C(I,j({query:t,candidates:a,excerptChars:n.excerptChars}),M(a),{incumbent:{best:a[0].id},features:{agent:e??"unknown"}});return!i||i.mode!=="active"?s.slice(0,r):E(i.answers,a).ranked.map(l=>s[Number(l.slice(1))]).filter(l=>!!l).slice(0,r)}findRelevant(t,e,r=3,n,o={graph:.6,bm25:.4}){let s=[];if(this.walkDir(this.baseDir,h=>{if(!h.endsWith(".md"))return;let b=y(this.baseDir,h);if(b.startsWith("raw/")||b.startsWith("_"))return;let f=this.readArticle(b);!f||!this.canRead(f.meta,e)||s.push(f)}),s.length===0)return[];let a=s.map(h=>`${h.meta.title} ${(h.meta.tags||[]).join(" ")} ${h.content}`),i=u(this.baseDir,"_bm25_relevance_cache.json"),c=x(a,i),l=_(t,c),g=l.reduce((h,b)=>Math.max(h,b.score),0)||1,d=new Map(l.map(h=>[h.docIndex,h.score/g])),p=!!(n&&n.length>0);return s.map((h,b)=>{let f=d.get(b)??0,$=0;p&&h.meta.graphPath?.length&&($=T(n,h.meta.graphPath));let v=p?o.graph*$+o.bm25*f:f;return{article:h,score:v}}).filter(h=>h.score>0).sort((h,b)=>b.score-h.score).slice(0,r).map(h=>h.article)}buildContext(t,e=4e3){if(t.length===0)return"";let r=["[Wiki Knowledge]"],n=0;for(let o of t){let s=`
@@ -102,4 +102,4 @@ We use GitLab for version control.
102
102
  There are ${e.length} unprocessed entries. Read each, understand what it means, and create or update wiki articles.
103
103
 
104
104
  ${r}`}walkDir(t,e){if(w(t))for(let r of D(t)){let n=K(t,r),o=U(n);o.isDirectory()?this.walkDir(n,e):e(n,o)}}};export{P as a};
105
- //# sourceMappingURL=chunk-ZQWWMAMJ.js.map
105
+ //# sourceMappingURL=chunk-P4XGM7ZM.js.map