@easbot/memory 0.3.29 → 0.3.36

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 (101) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +70 -8
  3. package/dist/assets/txt/src/plugin/tool/description.txt +12 -0
  4. package/dist/assets/txt/src/plugin/tool/memory.txt +231 -0
  5. package/dist/chunks/cache-IS6GEN55.cjs +1 -0
  6. package/dist/chunks/cache-U5YYUDWO.mjs +1 -0
  7. package/dist/chunks/chunk-4G4FSAFY.cjs +1 -0
  8. package/dist/chunks/chunk-AEAMQDNV.mjs +67 -0
  9. package/dist/chunks/chunk-EKSLNNMF.cjs +1 -0
  10. package/dist/chunks/{chunk-NWY7CUSL.mjs → chunk-FZ3RTYIJ.mjs} +3 -3
  11. package/dist/chunks/chunk-GCVKM3RJ.cjs +1 -0
  12. package/dist/chunks/chunk-HH7EA2UE.mjs +1 -0
  13. package/dist/chunks/chunk-HX3TV7FD.mjs +1 -0
  14. package/dist/chunks/chunk-IP7VEKQY.cjs +77 -0
  15. package/dist/chunks/{chunk-DVZOWMF5.cjs → chunk-ISYAE6B7.cjs} +5 -5
  16. package/dist/chunks/chunk-NHRRIJFK.cjs +1 -0
  17. package/dist/chunks/chunk-QAEIHJOF.cjs +67 -0
  18. package/dist/chunks/chunk-R32346OA.cjs +1 -0
  19. package/dist/chunks/chunk-S4DPVKMV.mjs +1 -0
  20. package/dist/chunks/chunk-SE3F5YQE.mjs +1 -0
  21. package/dist/chunks/chunk-YJLHS7JB.mjs +77 -0
  22. package/dist/chunks/chunk-YUWHNHAY.mjs +1 -0
  23. package/dist/chunks/cli-handler-JHSDGJHK.mjs +1 -0
  24. package/dist/chunks/cli-handler-USK4CPAU.cjs +1 -0
  25. package/dist/chunks/{config-I2I6U4XM.cjs → config-5OTOQBQN.cjs} +1 -1
  26. package/dist/chunks/{config-2SQJYVTO.mjs → config-5P7O45FH.mjs} +1 -1
  27. package/dist/chunks/consolidate-IKQVVWIQ.cjs +2 -0
  28. package/dist/chunks/consolidate-OOAMW7XW.mjs +2 -0
  29. package/dist/chunks/doctor-N6HHFR6Y.cjs +1 -0
  30. package/dist/chunks/doctor-ZGHICE2Q.mjs +1 -0
  31. package/dist/chunks/extract-7DQ6OV34.cjs +2 -0
  32. package/dist/chunks/extract-AJY2ETKE.mjs +2 -0
  33. package/dist/chunks/forget-4KGLTQ5Q.cjs +3 -0
  34. package/dist/chunks/{forget-PQLRSYOJ.mjs → forget-NIBBY6FG.mjs} +1 -1
  35. package/dist/chunks/{graph-P6LEEEVA.mjs → graph-4K56ZAVL.mjs} +1 -1
  36. package/dist/chunks/graph-OG23VZZM.cjs +3 -0
  37. package/dist/chunks/init-HWR4SD6N.mjs +1 -0
  38. package/dist/chunks/init-UQTPANNI.cjs +1 -0
  39. package/dist/chunks/interfaces-LDOE5ZTS.cjs +1 -0
  40. package/dist/chunks/{interfaces-7TJ645HL.mjs → interfaces-OFM2XGSG.mjs} +1 -1
  41. package/dist/chunks/llm-BRSMYENV.mjs +1 -0
  42. package/dist/chunks/llm-JSVYSX5Y.cjs +1 -0
  43. package/dist/chunks/mcp-ONIMP7FB.cjs +1 -0
  44. package/dist/chunks/mcp-ZWZYH52C.mjs +1 -0
  45. package/dist/chunks/recall-BRXHJPR4.mjs +2 -0
  46. package/dist/chunks/recall-KZRYTTWA.cjs +2 -0
  47. package/dist/chunks/remember-3XSYCWKK.mjs +2 -0
  48. package/dist/chunks/remember-GLOJH457.cjs +2 -0
  49. package/dist/chunks/status-POX2GWSQ.cjs +1 -0
  50. package/dist/chunks/status-SW5BUHJ3.mjs +1 -0
  51. package/dist/chunks/stdio-server-3A3H4YJ7.mjs +1 -0
  52. package/dist/chunks/stdio-server-W52CMVJO.cjs +1 -0
  53. package/dist/chunks/sync-EE4ZD3WB.mjs +2 -0
  54. package/dist/chunks/sync-I423W5G7.cjs +2 -0
  55. package/dist/cli.cjs +1 -1
  56. package/dist/cli.mjs +1 -1
  57. package/dist/index.cjs +7 -5
  58. package/dist/index.d.cts +59 -75
  59. package/dist/index.d.ts +59 -75
  60. package/dist/index.mjs +7 -5
  61. package/package.json +12 -12
  62. package/dist/chunks/chunk-3EENVVWK.cjs +0 -67
  63. package/dist/chunks/chunk-BYNUWUL2.cjs +0 -77
  64. package/dist/chunks/chunk-CIXJXCID.mjs +0 -1
  65. package/dist/chunks/chunk-CVS25NBK.mjs +0 -77
  66. package/dist/chunks/chunk-DWGCQLSH.mjs +0 -1
  67. package/dist/chunks/chunk-GHJLFUKH.cjs +0 -1
  68. package/dist/chunks/chunk-HQBRVVXS.mjs +0 -1
  69. package/dist/chunks/chunk-I5SOBIRK.cjs +0 -1
  70. package/dist/chunks/chunk-M2YU5LAI.cjs +0 -1
  71. package/dist/chunks/chunk-OOBYBPIN.mjs +0 -67
  72. package/dist/chunks/chunk-QJTEXVXX.mjs +0 -1
  73. package/dist/chunks/chunk-ZDTPURG4.cjs +0 -1
  74. package/dist/chunks/cli-handler-7KD65K5T.mjs +0 -1
  75. package/dist/chunks/cli-handler-L2HSWA2P.cjs +0 -1
  76. package/dist/chunks/consolidate-ANQFG7QD.mjs +0 -2
  77. package/dist/chunks/consolidate-GJPX4H7R.cjs +0 -2
  78. package/dist/chunks/doctor-4L2KSJXV.cjs +0 -1
  79. package/dist/chunks/doctor-CDS2OUAA.mjs +0 -1
  80. package/dist/chunks/extract-3MLEFVJV.cjs +0 -2
  81. package/dist/chunks/extract-V4BIBFW7.mjs +0 -2
  82. package/dist/chunks/forget-FG7ZFJL7.cjs +0 -3
  83. package/dist/chunks/graph-34HVP7TP.cjs +0 -3
  84. package/dist/chunks/init-7SHKOGVZ.cjs +0 -1
  85. package/dist/chunks/init-TTINBBT4.mjs +0 -1
  86. package/dist/chunks/interfaces-BGC3V4WU.cjs +0 -1
  87. package/dist/chunks/llm-RSSNHF6T.cjs +0 -1
  88. package/dist/chunks/llm-XHWMIOUN.mjs +0 -1
  89. package/dist/chunks/mcp-7TMDANN6.cjs +0 -1
  90. package/dist/chunks/mcp-YNGRYILA.mjs +0 -1
  91. package/dist/chunks/recall-JIH4PAR5.mjs +0 -2
  92. package/dist/chunks/recall-TA4YPWD2.cjs +0 -2
  93. package/dist/chunks/remember-5JAWVMYX.cjs +0 -2
  94. package/dist/chunks/remember-KY4HDAE4.mjs +0 -2
  95. package/dist/chunks/status-QZ27UQJG.mjs +0 -1
  96. package/dist/chunks/status-YGRSKKZZ.cjs +0 -1
  97. package/dist/chunks/stdio-server-KEBLOUB2.cjs +0 -1
  98. package/dist/chunks/stdio-server-RTY5WYTU.mjs +0 -1
  99. package/dist/chunks/sync-D44EAJLK.mjs +0 -2
  100. package/dist/chunks/sync-SJI7PENR.cjs +0 -2
  101. /package/dist/assets/txt/{assets → src/assets}/jieba_dict.txt +0 -0
@@ -0,0 +1 @@
1
+ 'use strict';var chunkQAEIHJOF_cjs=require('./chunk-QAEIHJOF.cjs');require('./chunk-IP7VEKQY.cjs'),require('./chunk-EKSLNNMF.cjs'),require('./chunk-AVECFV5K.cjs');var chunkNHRRIJFK_cjs=require('./chunk-NHRRIJFK.cjs');require('./chunk-GCVKM3RJ.cjs'),require('./chunk-R32346OA.cjs');async function l(n){let e=await chunkNHRRIJFK_cjs.d.getRootDir(),t=n.agentId?.trim()??"default";return chunkQAEIHJOF_cjs.z("status",{},chunkQAEIHJOF_cjs.B(t,e))}function m(n){return ""}function g(n){let e={};for(let t=0;t<n.length;t++){let o=n[t];if(o===void 0)continue;n[t+1];o==="--agent"?t++:o==="--json"?e.json=true:(o==="--help"||o==="-h")&&(e.help=true);}return e}exports.formatStatusText=m;exports.parseStatusOptions=g;exports.runStatus=l;
@@ -0,0 +1 @@
1
+ import {z,B}from'./chunk-AEAMQDNV.mjs';import'./chunk-YJLHS7JB.mjs';import'./chunk-HH7EA2UE.mjs';import'./chunk-AJDMZTCQ.mjs';import {d}from'./chunk-SE3F5YQE.mjs';import'./chunk-HX3TV7FD.mjs';import'./chunk-S4DPVKMV.mjs';async function m(n){let e=await d.getRootDir(),t=n.agentId?.trim()??"default";return z("status",{},B(t,e))}function g(n){return ""}function x(n){let e={};for(let t=0;t<n.length;t++){let o=n[t];if(o===void 0)continue;n[t+1];o==="--agent"?t++:o==="--json"?e.json=true:(o==="--help"||o==="-h")&&(e.help=true);}return e}export{g as formatStatusText,x as parseStatusOptions,m as runStatus};
@@ -0,0 +1 @@
1
+ export{b as MemoryStdioServer}from'./chunk-FZ3RTYIJ.mjs';import'./chunk-AEAMQDNV.mjs';import'./chunk-YJLHS7JB.mjs';import'./chunk-HH7EA2UE.mjs';import'./chunk-AJDMZTCQ.mjs';import'./chunk-SE3F5YQE.mjs';import'./chunk-HX3TV7FD.mjs';import'./chunk-S4DPVKMV.mjs';
@@ -0,0 +1 @@
1
+ 'use strict';var chunkISYAE6B7_cjs=require('./chunk-ISYAE6B7.cjs');require('./chunk-QAEIHJOF.cjs'),require('./chunk-IP7VEKQY.cjs'),require('./chunk-EKSLNNMF.cjs'),require('./chunk-AVECFV5K.cjs'),require('./chunk-NHRRIJFK.cjs'),require('./chunk-GCVKM3RJ.cjs'),require('./chunk-R32346OA.cjs');Object.defineProperty(exports,"MemoryStdioServer",{enumerable:true,get:function(){return chunkISYAE6B7_cjs.b}});
@@ -0,0 +1,2 @@
1
+ import {b as b$1,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {z,B}from'./chunk-AEAMQDNV.mjs';import'./chunk-YJLHS7JB.mjs';import'./chunk-HH7EA2UE.mjs';import'./chunk-AJDMZTCQ.mjs';import {d}from'./chunk-SE3F5YQE.mjs';import'./chunk-HX3TV7FD.mjs';import'./chunk-S4DPVKMV.mjs';import {NameErrors}from'@easbot/utils';async function C(e){let n=e.agentId?.trim();if(!n)throw new NameErrors.MissingFieldError({field:"agentId",message:"sync: agentId is required (ctx environment; agent CLI / standalone CLI must inject)"});let r=await d.getRootDir();return z("sync",{windowDays:e.windowDays,dryRun:e.dryRun??false},B(n,r))}function b(e){let n=e;return [b$1("sync",{windowDays:String(n.windowDays),dryRun:String(n.dryRun)},"sync complete (windowDays={{windowDays}}, dryRun={{dryRun}}):"),c("sync",{generatedCount:String(n.generatedCount),skippedCount:String(n.skippedCount),failedGenerateCount:String(n.failedGenerateCount),archivedCount:String(n.archivedCount),archiveThreshold:n.archiveThreshold}," - generated: {{generatedCount}}, skipped: {{skippedCount}}, failed: {{failedGenerateCount}}, archived: {{archivedCount}} (threshold: {{archiveThreshold}})"),` - duration: ${n.durationMs}ms`].join(`
2
+ `)}function S(e){let n={};for(let r=0;r<e.length;r++){let t=e[r];if(t===void 0)continue;let i=e[r+1];if(t==="--agent")r++;else if(t==="--window-days"){let o=Number(i);if(Number.isNaN(o)||o<1||o>3650)throw new NameErrors.InvalidArgumentError({param:"window-days",message:`--window-days must be an integer in [1, 3650], got: ${i??"(empty)"}`});n.windowDays=o,r++;}else t==="--dry-run"?n.dryRun=true:t==="--json"?n.json=true:(t==="--help"||t==="-h")&&(n.help=true);}return n}export{b as formatSyncText,S as parseSyncOptions,C as runSync};
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunkQAEIHJOF_cjs=require('./chunk-QAEIHJOF.cjs');require('./chunk-IP7VEKQY.cjs'),require('./chunk-EKSLNNMF.cjs'),require('./chunk-AVECFV5K.cjs');var chunkNHRRIJFK_cjs=require('./chunk-NHRRIJFK.cjs');require('./chunk-GCVKM3RJ.cjs'),require('./chunk-R32346OA.cjs');var utils=require('@easbot/utils');async function h(e){let n=e.agentId?.trim();if(!n)throw new utils.NameErrors.MissingFieldError({field:"agentId",message:"sync: agentId is required (ctx environment; agent CLI / standalone CLI must inject)"});let r=await chunkNHRRIJFK_cjs.d.getRootDir();return chunkQAEIHJOF_cjs.z("sync",{windowDays:e.windowDays,dryRun:e.dryRun??false},chunkQAEIHJOF_cjs.B(n,r))}function C(e){let n=e;return [chunk4GSXSIV5_cjs.b("sync",{windowDays:String(n.windowDays),dryRun:String(n.dryRun)},"sync complete (windowDays={{windowDays}}, dryRun={{dryRun}}):"),chunk4GSXSIV5_cjs.c("sync",{generatedCount:String(n.generatedCount),skippedCount:String(n.skippedCount),failedGenerateCount:String(n.failedGenerateCount),archivedCount:String(n.archivedCount),archiveThreshold:n.archiveThreshold}," - generated: {{generatedCount}}, skipped: {{skippedCount}}, failed: {{failedGenerateCount}}, archived: {{archivedCount}} (threshold: {{archiveThreshold}})"),` - duration: ${n.durationMs}ms`].join(`
2
+ `)}function b(e){let n={};for(let r=0;r<e.length;r++){let t=e[r];if(t===void 0)continue;let i=e[r+1];if(t==="--agent")r++;else if(t==="--window-days"){let o=Number(i);if(Number.isNaN(o)||o<1||o>3650)throw new utils.NameErrors.InvalidArgumentError({param:"window-days",message:`--window-days must be an integer in [1, 3650], got: ${i??"(empty)"}`});n.windowDays=o,r++;}else t==="--dry-run"?n.dryRun=true:t==="--json"?n.json=true:(t==="--help"||t==="-h")&&(n.help=true);}return n}exports.formatSyncText=C;exports.parseSyncOptions=b;exports.runSync=h;
package/dist/cli.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';var chunkM2YU5LAI_cjs=require('./chunks/chunk-M2YU5LAI.cjs'),fs=require('fs'),path=require('path'),url=require('url'),terminal=require('@easbot/terminal');var R=path.dirname(url.fileURLToPath(chunkM2YU5LAI_cjs.b));function D(){try{let t=path.join(R,"..","package.json");return JSON.parse(fs.readFileSync(t,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var u=new Set(["DEBUG","INFO","WARN","ERROR"]);function S(t){let o={logLevel:"INFO",printLogs:false,debug:false};for(let s=0;s<t.length;s++){let e=t[s];if(e)if(e==="--cwd"&&s+1<t.length){let n=t[s+1];n&&!n.startsWith("-")&&(o.cwd=n,s++);}else if(e.startsWith("--cwd="))o.cwd=e.slice(6);else if(e==="--config"&&s+1<t.length){let n=t[s+1];n&&!n.startsWith("-")&&(o.configPath=n,s++);}else if(e.startsWith("--config="))o.configPath=e.slice(9);else if(e==="--log-level"&&s+1<t.length){let n=t[s+1];if(n&&!n.startsWith("-")){let c=n.toUpperCase();u.has(c)&&(o.logLevel=c,s++);}}else if(e.startsWith("--log-level=")){let n=e.slice(12).toUpperCase();u.has(n)&&(o.logLevel=n);}else e==="--print-logs"?o.printLogs=true:e==="--debug"&&(o.debug=true);}return o}async function W(){let t=process.argv.slice(2),o=D(),{loadEnv:s}=await import('@easbot/utils');s(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let e=S(t),{Log:n}=await import('@easbot/utils'),{getXdgData:c}=await import('./chunks/interfaces-BGC3V4WU.cjs'),L=path.join(c(),"memory","log");if(await n.init({logDir:L,print:e.printLogs,dev:e.debug||false,level:e.logLevel}),t.length===0){let{renderBanner:a}=await import('./chunks/cli-handler-L2HSWA2P.cjs');a();return}if(t[0]==="--help"||t[0]==="-h"){let{renderHelp:a}=await import('./chunks/cli-handler-L2HSWA2P.cjs');a();return}if(t[0]==="--version"||t[0]==="-v"){terminal.printHuman([terminal.formatInfo(o)]);return}let i=e.cwd??process.cwd(),{handleMemoryCli:b}=await import('./chunks/cli-handler-L2HSWA2P.cjs'),{setInstanceAdapter:y}=await import('./chunks/interfaces-BGC3V4WU.cjs');y({directory:i,worktree:i});let{Llm:v}=await import('./chunks/llm-RSSNHF6T.cjs'),{bootstrapLlm:O,setAdapterRegistry:I}=await import('@easbot/llm'),{getGlobal:r,getInstance:p}=await import('./chunks/interfaces-BGC3V4WU.cjs');I({config:void 0,instance:{getDirectory:()=>p().directory,getWorktree:()=>p().worktree},global:{home:r().Path.home,data:r().Path.data,cache:r().Path.cache,config:r().Path.config,state:r().Path.state,log:r().Path.log,bin:r().Path.bin},installation:{getVersion:()=>o,getChannel:()=>"local",getUserAgent:()=>`easbot-memory/${o}`}}),await O({target:v,cwd:i,subConfigPath:".easbot/memory.json",embedding:true,graph:true});let d=n.create({service:"memory-cli-standalone"}),l;try{let{readFileSync:a}=await import('fs'),{join:g}=await import('path'),f=g(i,".easbot","protocol.json"),P=a(f,"utf-8");l=JSON.parse(P)?.metadata?.agentId?.trim()||void 0,d.debug("standalone CLI: resolved hostAgentId from protocol.json",{hostAgentId:l,protocolPath:f});}catch(a){let{errorMeta:g}=await import('@easbot/utils');d.debug("standalone CLI: read protocol.json failed; hostAgentId stays undefined",{cwd:i,error:g(a)});}let m=await b(t,{version:o,cwd:i,agentId:l});m.code!==0&&(process.exitCode=m.code);}W().catch(async t=>{try{let{Log:o,errorMeta:s}=await import('@easbot/utils');o.create({service:"memory-cli-standalone"}).error("memory CLI crashed",{error:s(t)});}catch{console.error(t);}process.exitCode=1;}).finally(async()=>{try{let{Log:t}=await import('@easbot/utils');await t.close();}catch{}process.exit(process.exitCode??0);});
2
+ 'use strict';var chunkR32346OA_cjs=require('./chunks/chunk-R32346OA.cjs'),fs=require('fs'),path=require('path'),url=require('url'),terminal=require('@easbot/terminal');var N=path.dirname(url.fileURLToPath(chunkR32346OA_cjs.d));function C(){try{let t=path.join(N,"..","package.json");return JSON.parse(fs.readFileSync(t,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var u=new Set(["DEBUG","INFO","WARN","ERROR"]);function D(t){let o={logLevel:"INFO",printLogs:false,debug:false};for(let s=0;s<t.length;s++){let e=t[s];if(e)if(e==="--cwd"&&s+1<t.length){let n=t[s+1];n&&!n.startsWith("-")&&(o.cwd=n,s++);}else if(e.startsWith("--cwd="))o.cwd=e.slice(6);else if(e==="--config"&&s+1<t.length){let n=t[s+1];n&&!n.startsWith("-")&&(o.configPath=n,s++);}else if(e.startsWith("--config="))o.configPath=e.slice(9);else if(e==="--log-level"&&s+1<t.length){let n=t[s+1];if(n&&!n.startsWith("-")){let c=n.toUpperCase();u.has(c)&&(o.logLevel=c,s++);}}else if(e.startsWith("--log-level=")){let n=e.slice(12).toUpperCase();u.has(n)&&(o.logLevel=n);}else e==="--print-logs"?o.printLogs=true:e==="--debug"&&(o.debug=true);}return o}async function R(){let t=process.argv.slice(2),o=C(),{loadEnv:s}=await import('@easbot/utils');s(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let e=D(t),{Log:n}=await import('@easbot/utils'),{getXdgData:c}=await import('./chunks/interfaces-LDOE5ZTS.cjs'),L=path.join(c(),"memory","log");if(await n.init({logDir:L,print:e.printLogs,dev:e.debug||false,level:e.logLevel}),t.length===0){let{renderBanner:a}=await import('./chunks/cli-handler-USK4CPAU.cjs');a();return}if(t[0]==="--help"||t[0]==="-h"){let{renderHelp:a}=await import('./chunks/cli-handler-USK4CPAU.cjs');a();return}if(t[0]==="--version"||t[0]==="-v"){terminal.printHuman([terminal.formatInfo(o)]);return}let i=e.cwd??process.cwd(),{handleMemoryCli:b}=await import('./chunks/cli-handler-USK4CPAU.cjs'),{setInstanceAdapter:v}=await import('./chunks/interfaces-LDOE5ZTS.cjs');v({directory:i,worktree:i});let{setAdapterRegistry:y}=await import('@easbot/llm'),{getGlobal:r,getInstance:p}=await import('./chunks/interfaces-LDOE5ZTS.cjs');y({config:void 0,instance:{getDirectory:()=>p().directory,getWorktree:()=>p().worktree},global:{home:r().Path.home,data:r().Path.data,cache:r().Path.cache,config:r().Path.config,state:r().Path.state,log:r().Path.log,bin:r().Path.bin},installation:{getVersion:()=>o,getChannel:()=>"local",getUserAgent:()=>`easbot-memory/${o}`}});let d=n.create({service:"memory.cli.standalone"}),l;try{let{readFileSync:a}=await import('fs'),{join:g}=await import('path'),m=g(i,".easbot","protocol.json"),O=a(m,"utf-8");l=JSON.parse(O)?.metadata?.agentId?.trim()||void 0,d.debug("standalone CLI: resolved hostAgentId from protocol.json",{hostAgentId:l,protocolPath:m});}catch(a){let{errorMeta:g}=await import('@easbot/utils');d.errorDegradable("standalone CLI: read protocol.json failed; hostAgentId stays undefined",{cwd:i,error:g(a)});}let f=await b(t,{version:o,cwd:i,agentId:l});f.code!==0&&(process.exitCode=f.code);}R().catch(async t=>{try{let{Log:o,errorMeta:s}=await import('@easbot/utils');o.create({service:"memory.cli.standalone"}).error("memory CLI crashed",{error:s(t)});}catch{console.error(t);}process.exitCode=1;}).finally(async()=>{try{let{Log:t}=await import('@easbot/utils');await t.close();}catch{}process.exit(process.exitCode??0);});
package/dist/cli.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import {readFileSync}from'fs';import {dirname,join}from'path';import {fileURLToPath}from'url';import {printHuman,formatInfo}from'@easbot/terminal';var N=dirname(fileURLToPath(import.meta.url));function R(){try{let t=join(N,"..","package.json");return JSON.parse(readFileSync(t,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var h=new Set(["DEBUG","INFO","WARN","ERROR"]);function D(t){let o={logLevel:"INFO",printLogs:false,debug:false};for(let s=0;s<t.length;s++){let e=t[s];if(e)if(e==="--cwd"&&s+1<t.length){let n=t[s+1];n&&!n.startsWith("-")&&(o.cwd=n,s++);}else if(e.startsWith("--cwd="))o.cwd=e.slice(6);else if(e==="--config"&&s+1<t.length){let n=t[s+1];n&&!n.startsWith("-")&&(o.configPath=n,s++);}else if(e.startsWith("--config="))o.configPath=e.slice(9);else if(e==="--log-level"&&s+1<t.length){let n=t[s+1];if(n&&!n.startsWith("-")){let c=n.toUpperCase();h.has(c)&&(o.logLevel=c,s++);}}else if(e.startsWith("--log-level=")){let n=e.slice(12).toUpperCase();h.has(n)&&(o.logLevel=n);}else e==="--print-logs"?o.printLogs=true:e==="--debug"&&(o.debug=true);}return o}async function S(){let t=process.argv.slice(2),o=R(),{loadEnv:s}=await import('@easbot/utils');s(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let e=D(t),{Log:n}=await import('@easbot/utils'),{getXdgData:c}=await import('./chunks/interfaces-7TJ645HL.mjs'),w=join(c(),"memory","log");if(await n.init({logDir:w,print:e.printLogs,dev:e.debug||false,level:e.logLevel}),t.length===0){let{renderBanner:a}=await import('./chunks/cli-handler-7KD65K5T.mjs');a();return}if(t[0]==="--help"||t[0]==="-h"){let{renderHelp:a}=await import('./chunks/cli-handler-7KD65K5T.mjs');a();return}if(t[0]==="--version"||t[0]==="-v"){printHuman([formatInfo(o)]);return}let i=e.cwd??process.cwd(),{handleMemoryCli:L}=await import('./chunks/cli-handler-7KD65K5T.mjs'),{setInstanceAdapter:b}=await import('./chunks/interfaces-7TJ645HL.mjs');b({directory:i,worktree:i});let{Llm:y}=await import('./chunks/llm-XHWMIOUN.mjs'),{bootstrapLlm:v,setAdapterRegistry:O}=await import('@easbot/llm'),{getGlobal:r,getInstance:p}=await import('./chunks/interfaces-7TJ645HL.mjs');O({config:void 0,instance:{getDirectory:()=>p().directory,getWorktree:()=>p().worktree},global:{home:r().Path.home,data:r().Path.data,cache:r().Path.cache,config:r().Path.config,state:r().Path.state,log:r().Path.log,bin:r().Path.bin},installation:{getVersion:()=>o,getChannel:()=>"local",getUserAgent:()=>`easbot-memory/${o}`}}),await v({target:y,cwd:i,subConfigPath:".easbot/memory.json",embedding:true,graph:true});let d=n.create({service:"memory-cli-standalone"}),l;try{let{readFileSync:a}=await import('fs'),{join:g}=await import('path'),f=g(i,".easbot","protocol.json"),I=a(f,"utf-8");l=JSON.parse(I)?.metadata?.agentId?.trim()||void 0,d.debug("standalone CLI: resolved hostAgentId from protocol.json",{hostAgentId:l,protocolPath:f});}catch(a){let{errorMeta:g}=await import('@easbot/utils');d.debug("standalone CLI: read protocol.json failed; hostAgentId stays undefined",{cwd:i,error:g(a)});}let m=await L(t,{version:o,cwd:i,agentId:l});m.code!==0&&(process.exitCode=m.code);}S().catch(async t=>{try{let{Log:o,errorMeta:s}=await import('@easbot/utils');o.create({service:"memory-cli-standalone"}).error("memory CLI crashed",{error:s(t)});}catch{console.error(t);}process.exitCode=1;}).finally(async()=>{try{let{Log:t}=await import('@easbot/utils');await t.close();}catch{}process.exit(process.exitCode??0);});
2
+ import {readFileSync}from'fs';import {dirname,join}from'path';import {fileURLToPath}from'url';import {printHuman,formatInfo}from'@easbot/terminal';var E=dirname(fileURLToPath(import.meta.url));function N(){try{let t=join(E,"..","package.json");return JSON.parse(readFileSync(t,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var h=new Set(["DEBUG","INFO","WARN","ERROR"]);function C(t){let o={logLevel:"INFO",printLogs:false,debug:false};for(let s=0;s<t.length;s++){let e=t[s];if(e)if(e==="--cwd"&&s+1<t.length){let n=t[s+1];n&&!n.startsWith("-")&&(o.cwd=n,s++);}else if(e.startsWith("--cwd="))o.cwd=e.slice(6);else if(e==="--config"&&s+1<t.length){let n=t[s+1];n&&!n.startsWith("-")&&(o.configPath=n,s++);}else if(e.startsWith("--config="))o.configPath=e.slice(9);else if(e==="--log-level"&&s+1<t.length){let n=t[s+1];if(n&&!n.startsWith("-")){let c=n.toUpperCase();h.has(c)&&(o.logLevel=c,s++);}}else if(e.startsWith("--log-level=")){let n=e.slice(12).toUpperCase();h.has(n)&&(o.logLevel=n);}else e==="--print-logs"?o.printLogs=true:e==="--debug"&&(o.debug=true);}return o}async function D(){let t=process.argv.slice(2),o=N(),{loadEnv:s}=await import('@easbot/utils');s(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let e=C(t),{Log:n}=await import('@easbot/utils'),{getXdgData:c}=await import('./chunks/interfaces-OFM2XGSG.mjs'),w=join(c(),"memory","log");if(await n.init({logDir:w,print:e.printLogs,dev:e.debug||false,level:e.logLevel}),t.length===0){let{renderBanner:a}=await import('./chunks/cli-handler-JHSDGJHK.mjs');a();return}if(t[0]==="--help"||t[0]==="-h"){let{renderHelp:a}=await import('./chunks/cli-handler-JHSDGJHK.mjs');a();return}if(t[0]==="--version"||t[0]==="-v"){printHuman([formatInfo(o)]);return}let i=e.cwd??process.cwd(),{handleMemoryCli:L}=await import('./chunks/cli-handler-JHSDGJHK.mjs'),{setInstanceAdapter:b}=await import('./chunks/interfaces-OFM2XGSG.mjs');b({directory:i,worktree:i});let{setAdapterRegistry:v}=await import('@easbot/llm'),{getGlobal:r,getInstance:p}=await import('./chunks/interfaces-OFM2XGSG.mjs');v({config:void 0,instance:{getDirectory:()=>p().directory,getWorktree:()=>p().worktree},global:{home:r().Path.home,data:r().Path.data,cache:r().Path.cache,config:r().Path.config,state:r().Path.state,log:r().Path.log,bin:r().Path.bin},installation:{getVersion:()=>o,getChannel:()=>"local",getUserAgent:()=>`easbot-memory/${o}`}});let d=n.create({service:"memory.cli.standalone"}),l;try{let{readFileSync:a}=await import('fs'),{join:g}=await import('path'),m=g(i,".easbot","protocol.json"),y=a(m,"utf-8");l=JSON.parse(y)?.metadata?.agentId?.trim()||void 0,d.debug("standalone CLI: resolved hostAgentId from protocol.json",{hostAgentId:l,protocolPath:m});}catch(a){let{errorMeta:g}=await import('@easbot/utils');d.errorDegradable("standalone CLI: read protocol.json failed; hostAgentId stays undefined",{cwd:i,error:g(a)});}let f=await L(t,{version:o,cwd:i,agentId:l});f.code!==0&&(process.exitCode=f.code);}D().catch(async t=>{try{let{Log:o,errorMeta:s}=await import('@easbot/utils');o.create({service:"memory.cli.standalone"}).error("memory CLI crashed",{error:s(t)});}catch{console.error(t);}process.exitCode=1;}).finally(async()=>{try{let{Log:t}=await import('@easbot/utils');await t.close();}catch{}process.exit(process.exitCode??0);});
package/dist/index.cjs CHANGED
@@ -1,6 +1,8 @@
1
- 'use strict';require('./chunks/chunk-URADAZYW.cjs');var chunkI5SOBIRK_cjs=require('./chunks/chunk-I5SOBIRK.cjs'),chunkDVZOWMF5_cjs=require('./chunks/chunk-DVZOWMF5.cjs'),chunk3EENVVWK_cjs=require('./chunks/chunk-3EENVVWK.cjs'),chunkBYNUWUL2_cjs=require('./chunks/chunk-BYNUWUL2.cjs'),chunkGHJLFUKH_cjs=require('./chunks/chunk-GHJLFUKH.cjs'),chunkZDTPURG4_cjs=require('./chunks/chunk-ZDTPURG4.cjs'),chunkAVECFV5K_cjs=require('./chunks/chunk-AVECFV5K.cjs'),chunkM2YU5LAI_cjs=require('./chunks/chunk-M2YU5LAI.cjs'),types=require('@easbot/types'),m=require('jieba-wasm'),utils=require('@easbot/utils'),crypto=require('crypto');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var m__namespace=/*#__PURE__*/_interopNamespace(m);var je=["user_preference","task_context","technical_fact","decision","relationship","reminder","error_pattern","workflow","exploration_finding","experience_summary","tool_usage","skill_creation","test","other"],p=class extends Error{constructor(t,o,n){super(t,{cause:n});chunkM2YU5LAI_cjs.a(this,"code",o);chunkM2YU5LAI_cjs.a(this,"cause",n);this.name="MemoryError";}},L=class extends p{constructor(r,t){super(r,"MEMORY_VALIDATION_ERROR",t),this.name="MemoryValidationError";}},F=class extends p{constructor(r){super(`Memory not found: ${r}`,"MEMORY_NOT_FOUND"),this.name="MemoryNotFoundError";}},$=class extends p{constructor(r){super(r,"MEMORY_PERMISSION_ERROR"),this.name="MemoryPermissionError";}},j=class extends p{constructor(r,t){super(r,"MEMORY_DATABASE_ERROR",t),this.name="MemoryDatabaseError";}},Y=class extends p{constructor(r,t){super(r,"MEMORY_FILE_ERROR",t),this.name="MemoryFileError";}},z=class extends p{constructor(r,t){super(r,"MEMORY_SEARCH_ERROR",t),this.name="MemorySearchError";}},B=class extends p{constructor(r,t){super(r,"MEMORY_EMBEDDING_ERROR",t),this.name="MemoryEmbeddingError";}},He=(a=>(a.VALIDATION_ERROR="MEMORY_VALIDATION_ERROR",a.NOT_FOUND="MEMORY_NOT_FOUND",a.PERMISSION_ERROR="MEMORY_PERMISSION_ERROR",a.DATABASE_ERROR="MEMORY_DATABASE_ERROR",a.FILE_ERROR="MEMORY_FILE_ERROR",a.SEARCH_ERROR="MEMORY_SEARCH_ERROR",a.EMBEDDING_ERROR="MEMORY_EMBEDDING_ERROR",a))(He||{});var s=utils.Log.create({service:"memory.tokenizer"}),l=false,Ie=utils.loadTextFile("./assets/jieba_dict.txt",chunkM2YU5LAI_cjs.b);async function We(e){if(!l)try{s.debug("Initializing jieba tokenizer");let r=Ie();if(m__namespace.with_dict(r),s.debug("Built-in dictionary loaded"),e?.dictPath&&e.dictPath.length>0)for(let t of e.dictPath)await _e(t);l=!0,s.debug("Jieba tokenizer initialized successfully");}catch(r){s.error("Failed to initialize jieba tokenizer",{error:utils.errorMeta(r)}),s.warn("Using fallback tokenization (space-based)");}}async function _e(e){if(!l)throw new chunkAVECFV5K_cjs.a.TokenizerNotInitializedError({message:"Tokenizer not initialized"});try{let r=await utils.Filesystem.readText(e);s.debug("Loading custom dictionary",{dictPath:e}),m__namespace.with_dict(r),s.debug("Custom dictionary loaded successfully",{dictPath:e});}catch(r){s.warn("Failed to load custom dictionary",{dictPath:e,error:utils.errorMeta(r)});}}function be(e){if(!l)return e.split(/\s+/).filter(Boolean);try{return m__namespace.cut(e)}catch(r){return s.warn("Tokenization failed, using fallback",{error:utils.errorMeta(r)}),e.split(/\s+/).filter(Boolean)}}function Oe(e){if(!l)return e.split(/\s+/).filter(Boolean);try{return m__namespace.cut_for_search(e)}catch(r){return s.warn("Tokenization for search failed, using fallback",{error:utils.errorMeta(r)}),e.split(/\s+/).filter(Boolean)}}function Ve(e,r,t){if(l)try{m__namespace.add_word(e,r,t),s.debug("Word added to dictionary",{word:e,freq:r,tag:t});}catch(o){s.warn("Failed to add word",{word:e,error:utils.errorMeta(o)});}}function Xe(){return l}async function Ze(){l=false,s.debug("Tokenizer closed");}function er(e){if(!l)return e.split(/\s+/).filter(Boolean).join(" ");try{return be(e).join(" ")}catch(r){return s.warn("Tokenization failed, using fallback",{error:utils.errorMeta(r)}),e.split(/\s+/).filter(Boolean).join(" ")}}function rr(e){if(!l)return e.split(/\s+/).filter(Boolean).join(" ");try{return Oe(e).join(" ")}catch(r){return s.warn("Tokenization for search failed, using fallback",{error:utils.errorMeta(r)}),e.split(/\s+/).filter(Boolean).join(" ")}}function d(e){let r=chunkGHJLFUKH_cjs.f().worktree,t=chunkGHJLFUKH_cjs.j(r);return {agentId:e,isTrustedLocal:true,remote:false,locale:"en-US",dbPath:t,workspaceDir:r,rootDir:r,config:chunk3EENVVWK_cjs.A({agentId:e,dbPath:t,workspaceDir:r})}}var G=async e=>{if(!e.agentId?.trim())return {ok:false,error:"session-start: agentId is required in ctx"};let r=e.extras?.topK??5,t=e.extras?.query??"";try{let o=await chunk3EENVVWK_cjs.z("recall",{query:t,maxResults:r},d(e.agentId));if(o.hits.length===0)return {ok:!0,injected:"",logLine:"session-start: no facts found for agent; skipping context injection"};let n=o.hits.map(R=>`- [${R.category}/imp=${R.importance}] ${R.snippet.slice(0,200)}`);return {ok:!0,injected:`[memory:session-start recall top-${o.hits.length}]
1
+ 'use strict';var chunkISYAE6B7_cjs=require('./chunks/chunk-ISYAE6B7.cjs');require('./chunks/chunk-URADAZYW.cjs');var chunk4G4FSAFY_cjs=require('./chunks/chunk-4G4FSAFY.cjs'),chunkQAEIHJOF_cjs=require('./chunks/chunk-QAEIHJOF.cjs'),chunkIP7VEKQY_cjs=require('./chunks/chunk-IP7VEKQY.cjs'),chunkEKSLNNMF_cjs=require('./chunks/chunk-EKSLNNMF.cjs'),chunkAVECFV5K_cjs=require('./chunks/chunk-AVECFV5K.cjs'),chunkNHRRIJFK_cjs=require('./chunks/chunk-NHRRIJFK.cjs'),chunkGCVKM3RJ_cjs=require('./chunks/chunk-GCVKM3RJ.cjs'),chunkR32346OA_cjs=require('./chunks/chunk-R32346OA.cjs'),types=require('@easbot/types'),y=require('jieba-wasm'),utils=require('@easbot/utils'),plugin=require('@easbot/plugin'),crypto=require('crypto'),w=require('zod');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var y__namespace=/*#__PURE__*/_interopNamespace(y);var w__default=/*#__PURE__*/_interopDefault(w);var po=["user_preference","task_context","technical_fact","decision","relationship","reminder","error_pattern","workflow","exploration_finding","experience_summary","tool_usage","skill_creation","test","other"];var p=utils.Log.create({service:"memory.tokenizer"}),g=false,De=utils.loadTextFile("./assets/jieba_dict.txt",chunkR32346OA_cjs.d);async function xo(e){if(!g)try{p.debug("Initializing jieba tokenizer");let o=De();if(y__namespace.with_dict(o),p.debug("Built-in dictionary loaded"),e?.dictPath&&e.dictPath.length>0)for(let r of e.dictPath)await Fe(r);g=!0,p.debug("Jieba tokenizer initialized successfully");}catch(o){p.error("Failed to initialize jieba tokenizer",{error:utils.errorMeta(o)}),p.warn("Using fallback tokenization (space-based)");}}async function Fe(e){if(!g)throw new chunkAVECFV5K_cjs.a.TokenizerNotInitializedError({message:"Tokenizer not initialized"});try{let o=await utils.Filesystem.readText(e);p.debug("Loading custom dictionary",{dictPath:e}),y__namespace.with_dict(o),p.debug("Custom dictionary loaded successfully",{dictPath:e});}catch(o){p.warn("Failed to load custom dictionary",{dictPath:e,error:utils.errorMeta(o)});}}function Ye(e){if(!g)return e.split(/\s+/).filter(Boolean);try{return y__namespace.cut(e)}catch(o){return p.warn("Tokenization failed, using fallback",{error:utils.errorMeta(o)}),e.split(/\s+/).filter(Boolean)}}function Be(e){if(!g)return e.split(/\s+/).filter(Boolean);try{return y__namespace.cut_for_search(e)}catch(o){return p.warn("Tokenization for search failed, using fallback",{error:utils.errorMeta(o)}),e.split(/\s+/).filter(Boolean)}}function Ho(e,o,r){if(g)try{y__namespace.add_word(e,o,r),p.debug("Word added to dictionary",{word:e,freq:o,tag:r});}catch(t){p.warn("Failed to add word",{word:e,error:utils.errorMeta(t)});}}function ho(){return g}async function Oo(){g=false,p.debug("Tokenizer closed");}function Io(e){if(!g)return e.split(/\s+/).filter(Boolean).join(" ");try{return Ye(e).join(" ")}catch(o){return p.warn("Tokenization failed, using fallback",{error:utils.errorMeta(o)}),e.split(/\s+/).filter(Boolean).join(" ")}}function bo(e){if(!g)return e.split(/\s+/).filter(Boolean).join(" ");try{return Be(e).join(" ")}catch(o){return p.warn("Tokenization for search failed, using fallback",{error:utils.errorMeta(o)}),e.split(/\s+/).filter(Boolean).join(" ")}}var A="memory",D="0.3.34",_={name:A,version:D,description:"EASBot memory plugin: lifecycle hooks and memory tool",entry:"./index.mjs",capabilities:["hooks","tools"]};function l(e,o){if(typeof e!="object"||e===null)return;let r=e;for(let t of o){let c=r[t];if(typeof c=="string"&&c.length>0)return c}}function ee(e){if(typeof e!="object"||e===null)return {};let o=e.extras;return typeof o=="object"&&o!==null&&!Array.isArray(o)?o:{}}function oe(e){if(typeof e!="object"||e===null)return;let o=e.protocolMetadata;if(typeof o!="object"||o===null)return;let r=o.agentId;return typeof r=="string"&&r.length>0?r:void 0}function k(e,o){let r={...ee(e),...ee(o)};return {agentId:l(o,["agentId"])??oe(e)??oe(o)??l(e,["agentId"])??l(o,["agent"])??l(e,["agent"])??"",sessionId:l(o,["sessionId"])??l(e,["sessionId"]),toolName:l(e,["toolName","tool","name"])??l(o,["toolName"]),error:l(e,["error","message"])??l(o,["error"]),messagePreview:l(e,["messagePreview"])??l(o,["messagePreview"]),contextPreview:l(e,["contextPreview","text","prompt"])??l(o,["contextPreview"]),extras:r}}function M(e){let o=chunkGCVKM3RJ_cjs.f().worktree,r=chunkGCVKM3RJ_cjs.j(o),t=e.trim()||"memory-plugin";return {agentId:t,isTrustedLocal:true,remote:false,locale:"en-US",dbPath:r,workspaceDir:o,rootDir:o,config:chunkQAEIHJOF_cjs.A({agentId:t,dbPath:r,workspaceDir:o})}}function a(e,o){return {modified:false,input:e,output:{...o}}}function re(e,o){return {modified:true,input:e,output:{...o}}}function te(e,o){return l(e,[o])}var Ke=utils.Log.create({service:"memory.plugin.hook"}),E=async(e,o)=>{let r=plugin.HookEvent.ContextBuildBefore,t=k(e,o);if(!t.agentId.trim())return a(e,{hook:r,ok:false,error:"context build: agentId is required"});let c=typeof t.extras.topK=="number"?t.extras.topK:5,u=typeof t.extras.query=="string"?t.extras.query:"";try{let s=await chunkQAEIHJOF_cjs.z("recall",{query:u,maxResults:c},M(t.agentId));if(s.hits.length===0)return a(e,{hook:r,ok:!0,context:[],logLine:"context build: no facts found; skipping context injection"});let n=s.hits.map(N=>`- [${N.category}/imp=${N.importance}] ${N.snippet.slice(0,200)}`),m=`[memory:recall top-${s.hits.length}]
2
2
  ${n.join(`
3
- `)}`,logLine:`session-start: injected ${o.hits.length} facts into context (agent=${e.agentId})`}}catch(o){return {ok:false,error:utils.errorMeta(o).message}}};var we=3600*1e3,K=async e=>{if(!e.agentId?.trim())return {ok:false,error:"session-end: agentId is required in ctx"};let r=typeof e.extras?.lookbackMs=="number"&&e.extras.lookbackMs>0?e.extras.lookbackMs:we,t=e.extras?.fromTime??new Date(Date.now()-r).toISOString();try{let o=await chunk3EENVVWK_cjs.z("consolidate",{fromTime:t},d(e.agentId));return {ok:!0,logLine:`session-end: lookback=${r}ms, total=${o.totalFacts}, deduped=${o.dedupedCount}, archived=${o.archivedCount}, skipped=${o.skippedCount}`}}catch(o){return {ok:false,error:utils.errorMeta(o).message}}};var U=async e=>{if(!e.agentId?.trim())return {ok:false,error:"pre-compact: agentId is required in ctx"};let t=(e.contextPreview??e.messagePreview??"").slice(0,200).replace(/\s+/g," ").trim(),o=e.extras?.topK??3;if(!t)return {ok:true,injected:"",logLine:"pre-compact: empty contextPreview; skipping recall injection"};try{let n=await chunk3EENVVWK_cjs.z("recall",{query:t,maxResults:o,minImportance:5},d(e.agentId));if(n.hits.length===0)return {ok:!0,injected:"",logLine:`pre-compact: no facts matched query for agent=${e.agentId}`};let h=n.hits.map(a=>`- [${a.category}/imp=${a.importance}] ${a.snippet.slice(0,150)}`);return {ok:!0,injected:`[memory:pre-compact recall top-${n.hits.length} (imp>=5)]
4
- ${h.join(`
5
- `)}`,logLine:`pre-compact: injected ${n.hits.length} facts before compaction`}}catch(n){return {ok:false,error:utils.errorMeta(n).message}}};var q=async e=>{if(!e.agentId?.trim())return {ok:false,error:"post-tool-failure: agentId is required in ctx"};if(!e.toolName?.trim()||!e.error?.trim())return {ok:false,error:"post-tool-failure: toolName and error are required in ctx"};let r=crypto.createHash("sha256").update(`${e.toolName}:${e.error}`).digest("hex").slice(0,8),t=e.messagePreview?e.messagePreview.slice(0,200).replace(/\s+/g," ").trim():"",o=[`[error_pattern] tool=${e.toolName}`,`[error] ${e.error}`,t?`[preview] ${t}`:"",`[errHash] ${r}`].filter(Boolean).join(`
6
- `);try{return {ok:!0,logLine:`post-tool-failure: wrote error_pattern fact ${(await chunk3EENVVWK_cjs.z("remember",{content:o,category:"error_pattern",importance:6,tags:["post-tool-failure",`tool:${e.toolName}`,`err:${r}`],sessionId:e.sessionId,msgId:e.extras?.msgId},d(e.agentId))).fact.id} (tool=${e.toolName}, errHash=${r})`}}catch(n){return {ok:false,error:utils.errorMeta(n).message}}};var g=utils.Log.create({service:"memory.hooks"}),f=new Map;function y(e,r){let t={name:e,handler:r,registeredAt:new Date().toISOString()},o=f.get(e);f.set(e,t),o?g.info("Hook overwritten",{name:e,prevRegisteredAt:o.registeredAt,newRegisteredAt:t.registeredAt}):g.info("Hook registered",{name:e,registeredAt:t.registeredAt});}function De(e){return f.delete(e)}function ve(){return Array.from(f.values()).map(e=>({name:e.name,handler:e.handler,registeredAt:e.registeredAt}))}function Le(){y("session-start",G),y("session-end",K),y("pre-compact",U),y("post-tool-failure",q);}function Fe(){f.clear(),g.debug("All hooks cleared");}async function $e(e,r){let t=f.get(e);if(!t)return g.debug("dispatchHook: no handler registered; noop",{name:e}),{ok:true,logLine:`hook ${e} not registered; noop`};try{let o=await t.handler(r);return o.ok?o.logLine&&g.debug("dispatchHook: ok",{name:e,logLine:o.logLine}):g.warn("dispatchHook: handler returned failure",{name:e,agentId:r.agentId,error:o.error}),o}catch(o){let n=utils.errorMeta(o).message;return g.warn("dispatchHook: handler threw, caught and converted to failure result",{name:e,agentId:r.agentId,error:utils.errorMeta(o)}),{ok:false,error:n}}}Object.defineProperty(exports,"COMMANDS_HELP",{enumerable:true,get:function(){return chunkI5SOBIRK_cjs.a}});Object.defineProperty(exports,"handleMemoryCli",{enumerable:true,get:function(){return chunkI5SOBIRK_cjs.d}});Object.defineProperty(exports,"renderBanner",{enumerable:true,get:function(){return chunkI5SOBIRK_cjs.b}});Object.defineProperty(exports,"renderHelp",{enumerable:true,get:function(){return chunkI5SOBIRK_cjs.c}});Object.defineProperty(exports,"MemoryStdioServer",{enumerable:true,get:function(){return chunkDVZOWMF5_cjs.b}});Object.defineProperty(exports,"renderOperationMarkdown",{enumerable:true,get:function(){return chunkDVZOWMF5_cjs.a}});Object.defineProperty(exports,"ALL_OPS",{enumerable:true,get:function(){return chunk3EENVVWK_cjs.y}});Object.defineProperty(exports,"GraphStore",{enumerable:true,get:function(){return chunk3EENVVWK_cjs.a}});Object.defineProperty(exports,"OP_REGISTRY",{enumerable:true,get:function(){return chunk3EENVVWK_cjs.x}});Object.defineProperty(exports,"consolidate",{enumerable:true,get:function(){return chunk3EENVVWK_cjs.r}});Object.defineProperty(exports,"doctor",{enumerable:true,get:function(){return chunk3EENVVWK_cjs.v}});Object.defineProperty(exports,"executeOp",{enumerable:true,get:function(){return chunk3EENVVWK_cjs.z}});Object.defineProperty(exports,"extract",{enumerable:true,get:function(){return chunk3EENVVWK_cjs.q}});Object.defineProperty(exports,"forget",{enumerable:true,get:function(){return chunk3EENVVWK_cjs.p}});Object.defineProperty(exports,"graphQuery",{enumerable:true,get:function(){return chunk3EENVVWK_cjs.t}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunk3EENVVWK_cjs.w}});Object.defineProperty(exports,"recall",{enumerable:true,get:function(){return chunk3EENVVWK_cjs.b}});Object.defineProperty(exports,"remember",{enumerable:true,get:function(){return chunk3EENVVWK_cjs.n}});Object.defineProperty(exports,"status",{enumerable:true,get:function(){return chunk3EENVVWK_cjs.u}});Object.defineProperty(exports,"sync",{enumerable:true,get:function(){return chunk3EENVVWK_cjs.s}});Object.defineProperty(exports,"update",{enumerable:true,get:function(){return chunk3EENVVWK_cjs.o}});Object.defineProperty(exports,"DEFAULT_MEMORY_JSON",{enumerable:true,get:function(){return chunkBYNUWUL2_cjs.g}});Object.defineProperty(exports,"LATEST_SCHEMA_VERSION",{enumerable:true,get:function(){return chunkBYNUWUL2_cjs.a}});Object.defineProperty(exports,"MEMORY_JSON_REL_PATH",{enumerable:true,get:function(){return chunkBYNUWUL2_cjs.h}});Object.defineProperty(exports,"MIGRATIONS",{enumerable:true,get:function(){return chunkBYNUWUL2_cjs.b}});Object.defineProperty(exports,"MemoryCache",{enumerable:true,get:function(){return chunkBYNUWUL2_cjs.i}});Object.defineProperty(exports,"MemoryDatabaseManager",{enumerable:true,get:function(){return chunkBYNUWUL2_cjs.e}});Object.defineProperty(exports,"MemoryJsonSchema",{enumerable:true,get:function(){return chunkBYNUWUL2_cjs.f}});Object.defineProperty(exports,"readCurrentSchemaVersion",{enumerable:true,get:function(){return chunkBYNUWUL2_cjs.d}});Object.defineProperty(exports,"runMigrations",{enumerable:true,get:function(){return chunkBYNUWUL2_cjs.c}});Object.defineProperty(exports,"getGlobal",{enumerable:true,get:function(){return chunkGHJLFUKH_cjs.c}});Object.defineProperty(exports,"getHomeDir",{enumerable:true,get:function(){return chunkGHJLFUKH_cjs.g}});Object.defineProperty(exports,"getInstance",{enumerable:true,get:function(){return chunkGHJLFUKH_cjs.f}});Object.defineProperty(exports,"getMemoryDbPath",{enumerable:true,get:function(){return chunkGHJLFUKH_cjs.j}});Object.defineProperty(exports,"getMemoryDir",{enumerable:true,get:function(){return chunkGHJLFUKH_cjs.i}});Object.defineProperty(exports,"getXdgData",{enumerable:true,get:function(){return chunkGHJLFUKH_cjs.h}});Object.defineProperty(exports,"resetGlobalAdapter",{enumerable:true,get:function(){return chunkGHJLFUKH_cjs.b}});Object.defineProperty(exports,"resetInstanceAdapter",{enumerable:true,get:function(){return chunkGHJLFUKH_cjs.e}});Object.defineProperty(exports,"setGlobalAdapter",{enumerable:true,get:function(){return chunkGHJLFUKH_cjs.a}});Object.defineProperty(exports,"setInstanceAdapter",{enumerable:true,get:function(){return chunkGHJLFUKH_cjs.d}});Object.defineProperty(exports,"Llm",{enumerable:true,get:function(){return chunkZDTPURG4_cjs.a}});Object.defineProperty(exports,"GRAPH_ENTITY_TYPE_DEFINITIONS",{enumerable:true,get:function(){return types.GRAPH_ENTITY_TYPE_DEFINITIONS}});Object.defineProperty(exports,"GRAPH_RELATION_TYPE_DEFINITIONS",{enumerable:true,get:function(){return types.GRAPH_RELATION_TYPE_DEFINITIONS}});exports.MEMORY_CATEGORIES=je;exports.MemoryDatabaseError=j;exports.MemoryEmbeddingError=B;exports.MemoryError=p;exports.MemoryErrorCode=He;exports.MemoryFileError=Y;exports.MemoryNotFoundError=F;exports.MemoryPermissionError=$;exports.MemorySearchError=z;exports.MemoryValidationError=L;exports.addWord=Ve;exports.clearAllHooks=Fe;exports.closeTokenizer=Ze;exports.dispatchHook=$e;exports.initTokenizer=We;exports.isInitialized=Xe;exports.listHooks=ve;exports.loadCustomDict=_e;exports.registerAllDefaultHooks=Le;exports.registerHook=y;exports.toFtsTokens=er;exports.toFtsTokensForSearch=rr;exports.tokenize=be;exports.tokenizeForSearch=Oe;exports.unregisterHook=De;
3
+ `)}`,H=te(e,"userMessage");return H===void 0?a(e,{hook:r,ok:!0,context:[m],logLine:`context build: recalled ${s.hits.length} facts (input shape unexpected, not injected)`}):re({...e,userMessage:H?`${m}
4
+
5
+ ${H}`:m},{hook:r,ok:!0,context:[m],logLine:`context build: injected ${s.hits.length} facts`})}catch(s){let n=utils.errorMeta(s);return Ke.warn("memory context build hook failed",{error:n}),a(e,{hook:r,ok:false,error:n.message})}};var qe=utils.Log.create({service:"memory.plugin.hook"}),Ve=200,S=async(e,o)=>{let r=plugin.HookEvent.SessionCompacting,t=k(e,o);if(!t.agentId.trim())return a(e,{hook:r,ok:false,error:"pre compact: agentId is required"});let u=(t.contextPreview??t.messagePreview??"").slice(0,Ve).replace(/\s+/g," ").trim(),s=typeof t.extras.topK=="number"?t.extras.topK:3;if(!u)return a(e,{hook:r,ok:true,context:[],logLine:"pre compact: empty context preview; skipping recall injection"});try{let n=await chunkQAEIHJOF_cjs.z("recall",{query:u,maxResults:s,minImportance:5},M(t.agentId));if(n.hits.length===0)return a(e,{hook:r,ok:!0,context:[],logLine:"pre compact: no facts matched query"});let m=n.hits.map(b=>`- [${b.category}/imp=${b.importance}] ${b.snippet.slice(0,150)}`),H=`[memory:pre-compact recall top-${n.hits.length} (imp>=5)]
6
+ ${m.join(`
7
+ `)}`;return a(e,{hook:r,ok:!0,context:[H],logLine:`pre compact: injected ${n.hits.length} facts before compaction`})}catch(n){let m=utils.errorMeta(n);return qe.warn("memory pre compact hook failed",{error:m}),a(e,{hook:r,ok:false,error:m.message})}};var eo=utils.Log.create({service:"memory.plugin.hook"}),oo=8,P=async(e,o)=>{let r=plugin.HookEvent.ToolFailure,t=k(e,o);if(!t.agentId.trim())return a(e,{hook:r,ok:false,error:"tool failure: agentId is required"});if(!t.toolName?.trim()||!t.error?.trim())return a(e,{hook:r,ok:false,error:"tool failure: toolName and error are required"});let c=crypto.createHash("sha256").update(`${t.toolName}:${t.error}`).digest("hex").slice(0,oo),u=t.messagePreview?t.messagePreview.slice(0,200).replace(/\s+/g," ").trim():"",s=[`[error_pattern] tool=${t.toolName}`,`[error] ${t.error}`,u?`[preview] ${u}`:"",`[errHash] ${c}`].filter(Boolean).join(`
8
+ `);try{let n=await chunkQAEIHJOF_cjs.z("remember",{content:s,category:"error_pattern",importance:6,tags:["post-tool-failure",`tool:${t.toolName}`,`err:${c}`],sessionId:t.sessionId,msgId:typeof t.extras.msgId=="string"?t.extras.msgId:void 0},M(t.agentId));return a(e,{hook:r,ok:!0,logLine:`tool failure: wrote error_pattern fact ${n.fact.id} (tool=${t.toolName}, errHash=${c})`})}catch(n){let m=utils.errorMeta(n);return eo.warn("memory tool failure hook failed",{error:m}),a(e,{hook:r,ok:false,error:m.message})}};var x=[{event:plugin.HookEvent.ContextBuildBefore,handler:E},{event:plugin.HookEvent.SessionCompacting,handler:S},{event:plugin.HookEvent.ToolFailure,handler:P}];function O(){return x.map(({event:e,handler:o})=>({event:e,hooks:[{type:"function",handler:o}]}))}var ae=utils.Log.create({service:"memory.plugin.tool"}),se="memory",Y=["recall","remember","update","forget","extract","graph_query","status"],io=new Set(["recall","remember","forget","graph_query","status"]),ne="Access EASBot long-term memory via `op` and `params`.";function ao(){try{let e=utils.loadTextFile("./description.txt",chunkR32346OA_cjs.d)();return e.trim().length>0?e:ne}catch(e){return ae.warn("memory tool description unavailable, using fallback",{error:utils.errorMeta(e)}),ne}}var C=plugin.createTool({description:ao(),args:{op:w__default.default.enum(Y).describe("Operation name"),params:w__default.default.record(w__default.default.string(),w__default.default.unknown()).optional().describe("Operation arguments as a flat object")},execute:async(e,o)=>{let r=String(e.op),t=e.params??{},c=o.agent||"memory-plugin",u=o.worktree||o.directory;try{let s=chunkGCVKM3RJ_cjs.j(u),n={agentId:c,isTrustedLocal:!0,remote:!1,locale:"en-US",dbPath:s,workspaceDir:u,rootDir:u,config:chunkQAEIHJOF_cjs.A({agentId:c,dbPath:s,workspaceDir:u}),signal:o.abort},m=await chunkQAEIHJOF_cjs.z(r,t,n);return io.has(r)?await chunkISYAE6B7_cjs.a(r,m):JSON.stringify(m??{},null,2)}catch(s){let n=utils.errorMeta(s);return ae.error("memory tool execution failed",{op:r,error:n}),`memory tool failed for op "${r}": ${n.message}`}}});var I=async e=>({hooks:O(),tools:{[_.name]:C}});utils.Log.create({service:"memory.plugin.hook"});var me=[plugin.HookEvent.ContextBuildBefore,plugin.HookEvent.SessionCompacting,plugin.HookEvent.ToolFailure];var pe={name:"memory.plugin",async init(){return {isEnabled:()=>true,handlers:x.map(({event:e,handler:o})=>({name:e,handler:o}))}}};Object.defineProperty(exports,"MemoryStdioServer",{enumerable:true,get:function(){return chunkISYAE6B7_cjs.b}});Object.defineProperty(exports,"renderOperationMarkdown",{enumerable:true,get:function(){return chunkISYAE6B7_cjs.a}});Object.defineProperty(exports,"COMMANDS_HELP",{enumerable:true,get:function(){return chunk4G4FSAFY_cjs.a}});Object.defineProperty(exports,"handleMemoryCli",{enumerable:true,get:function(){return chunk4G4FSAFY_cjs.d}});Object.defineProperty(exports,"renderBanner",{enumerable:true,get:function(){return chunk4G4FSAFY_cjs.b}});Object.defineProperty(exports,"renderHelp",{enumerable:true,get:function(){return chunk4G4FSAFY_cjs.c}});Object.defineProperty(exports,"ALL_OPS",{enumerable:true,get:function(){return chunkQAEIHJOF_cjs.y}});Object.defineProperty(exports,"GraphStore",{enumerable:true,get:function(){return chunkQAEIHJOF_cjs.a}});Object.defineProperty(exports,"OP_REGISTRY",{enumerable:true,get:function(){return chunkQAEIHJOF_cjs.x}});Object.defineProperty(exports,"consolidate",{enumerable:true,get:function(){return chunkQAEIHJOF_cjs.r}});Object.defineProperty(exports,"doctor",{enumerable:true,get:function(){return chunkQAEIHJOF_cjs.v}});Object.defineProperty(exports,"executeOp",{enumerable:true,get:function(){return chunkQAEIHJOF_cjs.z}});Object.defineProperty(exports,"extract",{enumerable:true,get:function(){return chunkQAEIHJOF_cjs.q}});Object.defineProperty(exports,"forget",{enumerable:true,get:function(){return chunkQAEIHJOF_cjs.p}});Object.defineProperty(exports,"graphQuery",{enumerable:true,get:function(){return chunkQAEIHJOF_cjs.t}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunkQAEIHJOF_cjs.w}});Object.defineProperty(exports,"recall",{enumerable:true,get:function(){return chunkQAEIHJOF_cjs.b}});Object.defineProperty(exports,"remember",{enumerable:true,get:function(){return chunkQAEIHJOF_cjs.n}});Object.defineProperty(exports,"status",{enumerable:true,get:function(){return chunkQAEIHJOF_cjs.u}});Object.defineProperty(exports,"sync",{enumerable:true,get:function(){return chunkQAEIHJOF_cjs.s}});Object.defineProperty(exports,"update",{enumerable:true,get:function(){return chunkQAEIHJOF_cjs.o}});Object.defineProperty(exports,"LATEST_SCHEMA_VERSION",{enumerable:true,get:function(){return chunkIP7VEKQY_cjs.a}});Object.defineProperty(exports,"MIGRATIONS",{enumerable:true,get:function(){return chunkIP7VEKQY_cjs.b}});Object.defineProperty(exports,"MemoryDatabaseManager",{enumerable:true,get:function(){return chunkIP7VEKQY_cjs.e}});Object.defineProperty(exports,"readCurrentSchemaVersion",{enumerable:true,get:function(){return chunkIP7VEKQY_cjs.d}});Object.defineProperty(exports,"runMigrations",{enumerable:true,get:function(){return chunkIP7VEKQY_cjs.c}});Object.defineProperty(exports,"Llm",{enumerable:true,get:function(){return chunkEKSLNNMF_cjs.a}});Object.defineProperty(exports,"DEFAULT_MEMORY_JSON",{enumerable:true,get:function(){return chunkNHRRIJFK_cjs.b}});Object.defineProperty(exports,"MEMORY_JSON_REL_PATH",{enumerable:true,get:function(){return chunkNHRRIJFK_cjs.c}});Object.defineProperty(exports,"MemoryCache",{enumerable:true,get:function(){return chunkNHRRIJFK_cjs.d}});Object.defineProperty(exports,"MemoryJsonSchema",{enumerable:true,get:function(){return chunkNHRRIJFK_cjs.a}});Object.defineProperty(exports,"getGlobal",{enumerable:true,get:function(){return chunkGCVKM3RJ_cjs.c}});Object.defineProperty(exports,"getHomeDir",{enumerable:true,get:function(){return chunkGCVKM3RJ_cjs.g}});Object.defineProperty(exports,"getInstance",{enumerable:true,get:function(){return chunkGCVKM3RJ_cjs.f}});Object.defineProperty(exports,"getMemoryDbPath",{enumerable:true,get:function(){return chunkGCVKM3RJ_cjs.j}});Object.defineProperty(exports,"getMemoryDir",{enumerable:true,get:function(){return chunkGCVKM3RJ_cjs.i}});Object.defineProperty(exports,"getXdgData",{enumerable:true,get:function(){return chunkGCVKM3RJ_cjs.h}});Object.defineProperty(exports,"resetGlobalAdapter",{enumerable:true,get:function(){return chunkGCVKM3RJ_cjs.b}});Object.defineProperty(exports,"resetInstanceAdapter",{enumerable:true,get:function(){return chunkGCVKM3RJ_cjs.e}});Object.defineProperty(exports,"setGlobalAdapter",{enumerable:true,get:function(){return chunkGCVKM3RJ_cjs.a}});Object.defineProperty(exports,"setInstanceAdapter",{enumerable:true,get:function(){return chunkGCVKM3RJ_cjs.d}});Object.defineProperty(exports,"GRAPH_ENTITY_TYPE_DEFINITIONS",{enumerable:true,get:function(){return types.GRAPH_ENTITY_TYPE_DEFINITIONS}});Object.defineProperty(exports,"GRAPH_RELATION_TYPE_DEFINITIONS",{enumerable:true,get:function(){return types.GRAPH_RELATION_TYPE_DEFINITIONS}});exports.MEMORY_CATEGORIES=po;exports.MEMORY_HOOK_BINDINGS=x;exports.MEMORY_HOOK_EVENTS=me;exports.MEMORY_PLUGIN_ID=A;exports.MEMORY_PLUGIN_MANIFEST=_;exports.MEMORY_PLUGIN_VERSION=D;exports.MEMORY_TOOL_ID=se;exports.MEMORY_TOOL_OPS=Y;exports.MemoryPlugin=I;exports.MemoryPluginEntry=I;exports.MemoryPluginHook=pe;exports.MemoryTool=C;exports.addWord=Ho;exports.closeTokenizer=Oo;exports.createMemoryHookMatchers=O;exports.initTokenizer=xo;exports.isInitialized=ho;exports.loadCustomDict=Fe;exports.toFtsTokens=Io;exports.toFtsTokensForSearch=bo;exports.tokenize=Ye;exports.tokenizeForSearch=Be;
package/dist/index.d.cts CHANGED
@@ -1,11 +1,12 @@
1
+ import * as _easbot_types from '@easbot/types';
1
2
  import { KnowledgeSearchOptions, MemoryKnowledgeConfigWithModels, KnowledgeDoctorResult, MemoryStatus, IGlobal, IInstance } from '@easbot/types';
2
3
  export { GRAPH_ENTITY_TYPE_DEFINITIONS, GRAPH_RELATION_TYPE_DEFINITIONS } from '@easbot/types';
3
- import { EmbeddingModel, LanguageModel } from 'ai';
4
- export { EmbeddingModel, LanguageModel } from 'ai';
5
- import { ILLMInitConfig, ILLMCapabilities } from '@easbot/llm';
6
- import { z, ZodTypeAny } from 'zod';
4
+ import { ILLMInitConfig, ILLMCapabilities, EmbeddingModelRef, LanguageModelRef, ExtractedEntity, ExtractedRelation } from '@easbot/llm';
5
+ import z$1, { z, ZodTypeAny } from 'zod';
7
6
  import { StdioServerConfig } from '@easbot/mcp';
8
7
  import { SyncSqliteConnection } from '@easbot/database';
8
+ import { Plugin, PluginManifest, HookMatcher, HookHandler, HookInfo } from '@easbot/plugin';
9
+ export { EmbeddingModelV3 as EmbeddingModel, LanguageModelV3 as LanguageModel } from '@ai-sdk/provider';
9
10
 
10
11
  declare const MemoryJsonSchema: z.ZodObject<{
11
12
  version: z.ZodOptional<z.ZodLiteral<1>>;
@@ -81,41 +82,6 @@ interface MemoryRecallResult {
81
82
  updatedAt?: string;
82
83
  }
83
84
  type MemorySystemConfig = MemoryKnowledgeConfigWithModels;
84
- declare class MemoryError extends Error {
85
- readonly code: string;
86
- cause?: Error | undefined;
87
- constructor(message: string, code: string, cause?: Error | undefined);
88
- }
89
- declare class MemoryValidationError extends MemoryError {
90
- constructor(message: string, cause?: Error);
91
- }
92
- declare class MemoryNotFoundError extends MemoryError {
93
- constructor(memoryId: string);
94
- }
95
- declare class MemoryPermissionError extends MemoryError {
96
- constructor(message: string);
97
- }
98
- declare class MemoryDatabaseError extends MemoryError {
99
- constructor(message: string, cause?: Error);
100
- }
101
- declare class MemoryFileError extends MemoryError {
102
- constructor(message: string, cause?: Error);
103
- }
104
- declare class MemorySearchError extends MemoryError {
105
- constructor(message: string, cause?: Error);
106
- }
107
- declare class MemoryEmbeddingError extends MemoryError {
108
- constructor(message: string, cause?: Error);
109
- }
110
- declare enum MemoryErrorCode {
111
- VALIDATION_ERROR = "MEMORY_VALIDATION_ERROR",
112
- NOT_FOUND = "MEMORY_NOT_FOUND",
113
- PERMISSION_ERROR = "MEMORY_PERMISSION_ERROR",
114
- DATABASE_ERROR = "MEMORY_DATABASE_ERROR",
115
- FILE_ERROR = "MEMORY_FILE_ERROR",
116
- SEARCH_ERROR = "MEMORY_SEARCH_ERROR",
117
- EMBEDDING_ERROR = "MEMORY_EMBEDDING_ERROR"
118
- }
119
85
  interface MemoryNode {
120
86
  id: number;
121
87
  name: string;
@@ -176,8 +142,8 @@ declare function toFtsTokens(text: string): string;
176
142
  declare function toFtsTokensForSearch(text: string): string;
177
143
 
178
144
  interface LlmModels {
179
- embeddingLlm?: EmbeddingModel;
180
- graphLlm?: LanguageModel;
145
+ embedding?: EmbeddingModelRef;
146
+ graph?: LanguageModelRef;
181
147
  }
182
148
  interface LlmInitConfig extends ILLMInitConfig {
183
149
  options?: {
@@ -196,10 +162,20 @@ declare namespace Llm {
196
162
  function isInitialized(): boolean;
197
163
  function reset(): void;
198
164
  function capabilities(): ILLMCapabilities;
199
- function getEmbeddingLlm(): EmbeddingModel | undefined;
200
- function getGraphLlm(): LanguageModel | undefined;
165
+ function getEmbedding(): EmbeddingModelRef | undefined;
166
+ function getGraph(): LanguageModelRef | undefined;
201
167
  function embedText(value: string): Promise<Float32Array>;
202
168
  function embedTexts(values: string[]): Promise<Float32Array[]>;
169
+ function probeEmbeddingDims(options?: {
170
+ timeoutMs?: number;
171
+ }): Promise<number | undefined>;
172
+ function generateGraph(chunks: string[], options?: {
173
+ graphLlm?: LanguageModelRef;
174
+ }): Promise<{
175
+ entities: ExtractedEntity[];
176
+ relations: ExtractedRelation[];
177
+ summary: string;
178
+ }>;
203
179
  const embed: typeof embedText;
204
180
  const embedMany: typeof embedTexts;
205
181
  }
@@ -226,6 +202,7 @@ interface RecallParams {
226
202
  maxDepth?: number;
227
203
  maxEdgesPerNode?: number;
228
204
  includeShared?: boolean;
205
+ snippetMaxChars?: number;
229
206
  }
230
207
  interface RecallResult {
231
208
  hits: MemoryRecallResult[];
@@ -641,36 +618,6 @@ declare class GraphStore {
641
618
  }): Promise<MemoryNodeWithEdges[]>;
642
619
  }
643
620
 
644
- type HookName = 'session-start' | 'session-end' | 'pre-compact' | 'post-tool-failure';
645
- interface HookContext {
646
- agentId?: string;
647
- sessionId?: string;
648
- toolName?: string;
649
- error?: string;
650
- messagePreview?: string;
651
- contextPreview?: string;
652
- extras?: Record<string, unknown>;
653
- }
654
- interface HookResult {
655
- ok: boolean;
656
- injected?: string;
657
- logLine?: string;
658
- error?: string;
659
- }
660
- type HookHandler = (ctx: HookContext) => Promise<HookResult>;
661
- interface RegisteredHook {
662
- name: HookName;
663
- handler: HookHandler;
664
- registeredAt: string;
665
- }
666
-
667
- declare function registerHook(name: HookName, handler: HookHandler): void;
668
- declare function unregisterHook(name: HookName): boolean;
669
- declare function listHooks(): readonly RegisteredHook[];
670
- declare function registerAllDefaultHooks(): void;
671
- declare function clearAllHooks(): void;
672
- declare function dispatchHook(name: HookName, ctx: HookContext): Promise<HookResult>;
673
-
674
621
  declare const MEMORY_JSON_REL_PATH: readonly [".easbot", "memory.json"];
675
622
  type StateResult = {
676
623
  memoryJson: MemoryJson | undefined;
@@ -679,7 +626,7 @@ type StateResult = {
679
626
  };
680
627
  declare namespace MemoryCache {
681
628
  function state(): Promise<StateResult>;
682
- function resetState(): void;
629
+ function resetState(writtenPath?: string): void;
683
630
  function init(): Promise<void>;
684
631
  function getMemoryJson(): Promise<MemoryJson | undefined>;
685
632
  function exists(): Promise<boolean>;
@@ -688,4 +635,41 @@ declare namespace MemoryCache {
688
635
  function getConfigPath(): Promise<string>;
689
636
  }
690
637
 
691
- export { ALL_OPS, type ArchiveRecord, type ArchiveResult, COMMANDS_HELP, type CommandHelp, type ConsolidateParams, type ConsolidateResult, DEFAULT_MEMORY_JSON, type DoctorResult, type EdgeQueryFilter, type ExtractParams, type ExtractResult, type ForgetParams, type ForgetResult, type GraphQueryParams, type GraphQueryResult, GraphStore, type HookContext, type HookHandler, type HookName, type HookResult, type InitParams, type InitResult, type KGScope, LATEST_SCHEMA_VERSION, Llm, type LlmInitConfig, type LlmModels, MEMORY_CATEGORIES, MEMORY_JSON_REL_PATH, MIGRATIONS, MemoryCache, type MemoryCategory, type MemoryCliDeps, type MemoryCliResult, MemoryDatabaseError, MemoryDatabaseManager, type MemoryEdge, MemoryEmbeddingError, MemoryError, MemoryErrorCode, type MemoryFact, MemoryFileError, type MemoryJson, MemoryJsonSchema, type MemoryNode, type MemoryNodeWithEdges, MemoryNotFoundError, type MemoryOp, MemoryPermissionError, type MemoryQuery, type MemoryRecallResult, MemorySearchError, type MemorySource, MemoryStdioServer, type MemorySystemConfig, MemoryValidationError, type MemoryVector, type NodeQueryFilter, OP_REGISTRY, type OpAnnotations, type OpHandlerContext, type OpScope, type RecallParams, type RecallResult, type RegisteredHook, type RememberParams, type RememberResult, type StatusResult, type SyncParams, type SyncResult, type UpdateParams, type UpdateResult, addWord, clearAllHooks, closeTokenizer, consolidate, dispatchHook, doctor, executeOp, extract, forget, getGlobal, getHomeDir, getInstance, getMemoryDbPath, getMemoryDir, getXdgData, graphQuery, handleMemoryCli, init, initTokenizer, isInitialized, listHooks, loadCustomDict, readCurrentSchemaVersion, recall, registerAllDefaultHooks, registerHook, remember, renderBanner, renderHelp, renderOperationMarkdown, resetGlobalAdapter, resetInstanceAdapter, runMigrations, setGlobalAdapter, setInstanceAdapter, status, sync, toFtsTokens, toFtsTokensForSearch, tokenize, tokenizeForSearch, unregisterHook, update };
638
+ declare const MemoryPlugin: Plugin;
639
+
640
+ declare const MEMORY_PLUGIN_ID = "memory";
641
+ declare const MEMORY_PLUGIN_VERSION = "0.3.34";
642
+ declare const MEMORY_PLUGIN_MANIFEST: PluginManifest;
643
+
644
+ declare function createMemoryHookMatchers(): HookMatcher[];
645
+
646
+ declare const MEMORY_HOOK_EVENTS: readonly ["context.build.before", "session.compacting", "tool.failure"];
647
+ type MemoryHookEvent = (typeof MEMORY_HOOK_EVENTS)[number];
648
+ type MemoryHookHandler = HookHandler<unknown>;
649
+
650
+ type MemoryHookBinding = {
651
+ event: MemoryHookEvent;
652
+ handler: MemoryHookHandler;
653
+ };
654
+ declare const MEMORY_HOOK_BINDINGS: readonly MemoryHookBinding[];
655
+
656
+ declare const MemoryPluginHook: HookInfo;
657
+
658
+ declare const MEMORY_TOOL_ID = "memory";
659
+ declare const MEMORY_TOOL_OPS: readonly ["recall", "remember", "update", "forget", "extract", "graph_query", "status"];
660
+ declare const MemoryTool: _easbot_types.ToolDefinition & {
661
+ args: {
662
+ op: z$1.ZodEnum<{
663
+ status: "status";
664
+ recall: "recall";
665
+ forget: "forget";
666
+ graph_query: "graph_query";
667
+ remember: "remember";
668
+ update: "update";
669
+ extract: "extract";
670
+ }>;
671
+ params: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
672
+ };
673
+ };
674
+
675
+ export { ALL_OPS, type ArchiveRecord, type ArchiveResult, COMMANDS_HELP, type CommandHelp, type ConsolidateParams, type ConsolidateResult, DEFAULT_MEMORY_JSON, type DoctorResult, type EdgeQueryFilter, type ExtractParams, type ExtractResult, type ForgetParams, type ForgetResult, type GraphQueryParams, type GraphQueryResult, GraphStore, type InitParams, type InitResult, type KGScope, LATEST_SCHEMA_VERSION, Llm, type LlmInitConfig, type LlmModels, MEMORY_CATEGORIES, MEMORY_HOOK_BINDINGS, MEMORY_HOOK_EVENTS, MEMORY_JSON_REL_PATH, MEMORY_PLUGIN_ID, MEMORY_PLUGIN_MANIFEST, MEMORY_PLUGIN_VERSION, MEMORY_TOOL_ID, MEMORY_TOOL_OPS, MIGRATIONS, MemoryCache, type MemoryCategory, type MemoryCliDeps, type MemoryCliResult, MemoryDatabaseManager, type MemoryEdge, type MemoryFact, type MemoryJson, MemoryJsonSchema, type MemoryNode, type MemoryNodeWithEdges, type MemoryOp, MemoryPlugin, MemoryPlugin as MemoryPluginEntry, MemoryPluginHook, type MemoryQuery, type MemoryRecallResult, type MemorySource, MemoryStdioServer, type MemorySystemConfig, MemoryTool, type MemoryVector, type NodeQueryFilter, OP_REGISTRY, type OpAnnotations, type OpHandlerContext, type OpScope, type RecallParams, type RecallResult, type RememberParams, type RememberResult, type StatusResult, type SyncParams, type SyncResult, type UpdateParams, type UpdateResult, addWord, closeTokenizer, consolidate, createMemoryHookMatchers, doctor, executeOp, extract, forget, getGlobal, getHomeDir, getInstance, getMemoryDbPath, getMemoryDir, getXdgData, graphQuery, handleMemoryCli, init, initTokenizer, isInitialized, loadCustomDict, readCurrentSchemaVersion, recall, remember, renderBanner, renderHelp, renderOperationMarkdown, resetGlobalAdapter, resetInstanceAdapter, runMigrations, setGlobalAdapter, setInstanceAdapter, status, sync, toFtsTokens, toFtsTokensForSearch, tokenize, tokenizeForSearch, update };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
+ import * as _easbot_types from '@easbot/types';
1
2
  import { KnowledgeSearchOptions, MemoryKnowledgeConfigWithModels, KnowledgeDoctorResult, MemoryStatus, IGlobal, IInstance } from '@easbot/types';
2
3
  export { GRAPH_ENTITY_TYPE_DEFINITIONS, GRAPH_RELATION_TYPE_DEFINITIONS } from '@easbot/types';
3
- import { EmbeddingModel, LanguageModel } from 'ai';
4
- export { EmbeddingModel, LanguageModel } from 'ai';
5
- import { ILLMInitConfig, ILLMCapabilities } from '@easbot/llm';
6
- import { z, ZodTypeAny } from 'zod';
4
+ import { ILLMInitConfig, ILLMCapabilities, EmbeddingModelRef, LanguageModelRef, ExtractedEntity, ExtractedRelation } from '@easbot/llm';
5
+ import z$1, { z, ZodTypeAny } from 'zod';
7
6
  import { StdioServerConfig } from '@easbot/mcp';
8
7
  import { SyncSqliteConnection } from '@easbot/database';
8
+ import { Plugin, PluginManifest, HookMatcher, HookHandler, HookInfo } from '@easbot/plugin';
9
+ export { EmbeddingModelV3 as EmbeddingModel, LanguageModelV3 as LanguageModel } from '@ai-sdk/provider';
9
10
 
10
11
  declare const MemoryJsonSchema: z.ZodObject<{
11
12
  version: z.ZodOptional<z.ZodLiteral<1>>;
@@ -81,41 +82,6 @@ interface MemoryRecallResult {
81
82
  updatedAt?: string;
82
83
  }
83
84
  type MemorySystemConfig = MemoryKnowledgeConfigWithModels;
84
- declare class MemoryError extends Error {
85
- readonly code: string;
86
- cause?: Error | undefined;
87
- constructor(message: string, code: string, cause?: Error | undefined);
88
- }
89
- declare class MemoryValidationError extends MemoryError {
90
- constructor(message: string, cause?: Error);
91
- }
92
- declare class MemoryNotFoundError extends MemoryError {
93
- constructor(memoryId: string);
94
- }
95
- declare class MemoryPermissionError extends MemoryError {
96
- constructor(message: string);
97
- }
98
- declare class MemoryDatabaseError extends MemoryError {
99
- constructor(message: string, cause?: Error);
100
- }
101
- declare class MemoryFileError extends MemoryError {
102
- constructor(message: string, cause?: Error);
103
- }
104
- declare class MemorySearchError extends MemoryError {
105
- constructor(message: string, cause?: Error);
106
- }
107
- declare class MemoryEmbeddingError extends MemoryError {
108
- constructor(message: string, cause?: Error);
109
- }
110
- declare enum MemoryErrorCode {
111
- VALIDATION_ERROR = "MEMORY_VALIDATION_ERROR",
112
- NOT_FOUND = "MEMORY_NOT_FOUND",
113
- PERMISSION_ERROR = "MEMORY_PERMISSION_ERROR",
114
- DATABASE_ERROR = "MEMORY_DATABASE_ERROR",
115
- FILE_ERROR = "MEMORY_FILE_ERROR",
116
- SEARCH_ERROR = "MEMORY_SEARCH_ERROR",
117
- EMBEDDING_ERROR = "MEMORY_EMBEDDING_ERROR"
118
- }
119
85
  interface MemoryNode {
120
86
  id: number;
121
87
  name: string;
@@ -176,8 +142,8 @@ declare function toFtsTokens(text: string): string;
176
142
  declare function toFtsTokensForSearch(text: string): string;
177
143
 
178
144
  interface LlmModels {
179
- embeddingLlm?: EmbeddingModel;
180
- graphLlm?: LanguageModel;
145
+ embedding?: EmbeddingModelRef;
146
+ graph?: LanguageModelRef;
181
147
  }
182
148
  interface LlmInitConfig extends ILLMInitConfig {
183
149
  options?: {
@@ -196,10 +162,20 @@ declare namespace Llm {
196
162
  function isInitialized(): boolean;
197
163
  function reset(): void;
198
164
  function capabilities(): ILLMCapabilities;
199
- function getEmbeddingLlm(): EmbeddingModel | undefined;
200
- function getGraphLlm(): LanguageModel | undefined;
165
+ function getEmbedding(): EmbeddingModelRef | undefined;
166
+ function getGraph(): LanguageModelRef | undefined;
201
167
  function embedText(value: string): Promise<Float32Array>;
202
168
  function embedTexts(values: string[]): Promise<Float32Array[]>;
169
+ function probeEmbeddingDims(options?: {
170
+ timeoutMs?: number;
171
+ }): Promise<number | undefined>;
172
+ function generateGraph(chunks: string[], options?: {
173
+ graphLlm?: LanguageModelRef;
174
+ }): Promise<{
175
+ entities: ExtractedEntity[];
176
+ relations: ExtractedRelation[];
177
+ summary: string;
178
+ }>;
203
179
  const embed: typeof embedText;
204
180
  const embedMany: typeof embedTexts;
205
181
  }
@@ -226,6 +202,7 @@ interface RecallParams {
226
202
  maxDepth?: number;
227
203
  maxEdgesPerNode?: number;
228
204
  includeShared?: boolean;
205
+ snippetMaxChars?: number;
229
206
  }
230
207
  interface RecallResult {
231
208
  hits: MemoryRecallResult[];
@@ -641,36 +618,6 @@ declare class GraphStore {
641
618
  }): Promise<MemoryNodeWithEdges[]>;
642
619
  }
643
620
 
644
- type HookName = 'session-start' | 'session-end' | 'pre-compact' | 'post-tool-failure';
645
- interface HookContext {
646
- agentId?: string;
647
- sessionId?: string;
648
- toolName?: string;
649
- error?: string;
650
- messagePreview?: string;
651
- contextPreview?: string;
652
- extras?: Record<string, unknown>;
653
- }
654
- interface HookResult {
655
- ok: boolean;
656
- injected?: string;
657
- logLine?: string;
658
- error?: string;
659
- }
660
- type HookHandler = (ctx: HookContext) => Promise<HookResult>;
661
- interface RegisteredHook {
662
- name: HookName;
663
- handler: HookHandler;
664
- registeredAt: string;
665
- }
666
-
667
- declare function registerHook(name: HookName, handler: HookHandler): void;
668
- declare function unregisterHook(name: HookName): boolean;
669
- declare function listHooks(): readonly RegisteredHook[];
670
- declare function registerAllDefaultHooks(): void;
671
- declare function clearAllHooks(): void;
672
- declare function dispatchHook(name: HookName, ctx: HookContext): Promise<HookResult>;
673
-
674
621
  declare const MEMORY_JSON_REL_PATH: readonly [".easbot", "memory.json"];
675
622
  type StateResult = {
676
623
  memoryJson: MemoryJson | undefined;
@@ -679,7 +626,7 @@ type StateResult = {
679
626
  };
680
627
  declare namespace MemoryCache {
681
628
  function state(): Promise<StateResult>;
682
- function resetState(): void;
629
+ function resetState(writtenPath?: string): void;
683
630
  function init(): Promise<void>;
684
631
  function getMemoryJson(): Promise<MemoryJson | undefined>;
685
632
  function exists(): Promise<boolean>;
@@ -688,4 +635,41 @@ declare namespace MemoryCache {
688
635
  function getConfigPath(): Promise<string>;
689
636
  }
690
637
 
691
- export { ALL_OPS, type ArchiveRecord, type ArchiveResult, COMMANDS_HELP, type CommandHelp, type ConsolidateParams, type ConsolidateResult, DEFAULT_MEMORY_JSON, type DoctorResult, type EdgeQueryFilter, type ExtractParams, type ExtractResult, type ForgetParams, type ForgetResult, type GraphQueryParams, type GraphQueryResult, GraphStore, type HookContext, type HookHandler, type HookName, type HookResult, type InitParams, type InitResult, type KGScope, LATEST_SCHEMA_VERSION, Llm, type LlmInitConfig, type LlmModels, MEMORY_CATEGORIES, MEMORY_JSON_REL_PATH, MIGRATIONS, MemoryCache, type MemoryCategory, type MemoryCliDeps, type MemoryCliResult, MemoryDatabaseError, MemoryDatabaseManager, type MemoryEdge, MemoryEmbeddingError, MemoryError, MemoryErrorCode, type MemoryFact, MemoryFileError, type MemoryJson, MemoryJsonSchema, type MemoryNode, type MemoryNodeWithEdges, MemoryNotFoundError, type MemoryOp, MemoryPermissionError, type MemoryQuery, type MemoryRecallResult, MemorySearchError, type MemorySource, MemoryStdioServer, type MemorySystemConfig, MemoryValidationError, type MemoryVector, type NodeQueryFilter, OP_REGISTRY, type OpAnnotations, type OpHandlerContext, type OpScope, type RecallParams, type RecallResult, type RegisteredHook, type RememberParams, type RememberResult, type StatusResult, type SyncParams, type SyncResult, type UpdateParams, type UpdateResult, addWord, clearAllHooks, closeTokenizer, consolidate, dispatchHook, doctor, executeOp, extract, forget, getGlobal, getHomeDir, getInstance, getMemoryDbPath, getMemoryDir, getXdgData, graphQuery, handleMemoryCli, init, initTokenizer, isInitialized, listHooks, loadCustomDict, readCurrentSchemaVersion, recall, registerAllDefaultHooks, registerHook, remember, renderBanner, renderHelp, renderOperationMarkdown, resetGlobalAdapter, resetInstanceAdapter, runMigrations, setGlobalAdapter, setInstanceAdapter, status, sync, toFtsTokens, toFtsTokensForSearch, tokenize, tokenizeForSearch, unregisterHook, update };
638
+ declare const MemoryPlugin: Plugin;
639
+
640
+ declare const MEMORY_PLUGIN_ID = "memory";
641
+ declare const MEMORY_PLUGIN_VERSION = "0.3.34";
642
+ declare const MEMORY_PLUGIN_MANIFEST: PluginManifest;
643
+
644
+ declare function createMemoryHookMatchers(): HookMatcher[];
645
+
646
+ declare const MEMORY_HOOK_EVENTS: readonly ["context.build.before", "session.compacting", "tool.failure"];
647
+ type MemoryHookEvent = (typeof MEMORY_HOOK_EVENTS)[number];
648
+ type MemoryHookHandler = HookHandler<unknown>;
649
+
650
+ type MemoryHookBinding = {
651
+ event: MemoryHookEvent;
652
+ handler: MemoryHookHandler;
653
+ };
654
+ declare const MEMORY_HOOK_BINDINGS: readonly MemoryHookBinding[];
655
+
656
+ declare const MemoryPluginHook: HookInfo;
657
+
658
+ declare const MEMORY_TOOL_ID = "memory";
659
+ declare const MEMORY_TOOL_OPS: readonly ["recall", "remember", "update", "forget", "extract", "graph_query", "status"];
660
+ declare const MemoryTool: _easbot_types.ToolDefinition & {
661
+ args: {
662
+ op: z$1.ZodEnum<{
663
+ status: "status";
664
+ recall: "recall";
665
+ forget: "forget";
666
+ graph_query: "graph_query";
667
+ remember: "remember";
668
+ update: "update";
669
+ extract: "extract";
670
+ }>;
671
+ params: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
672
+ };
673
+ };
674
+
675
+ export { ALL_OPS, type ArchiveRecord, type ArchiveResult, COMMANDS_HELP, type CommandHelp, type ConsolidateParams, type ConsolidateResult, DEFAULT_MEMORY_JSON, type DoctorResult, type EdgeQueryFilter, type ExtractParams, type ExtractResult, type ForgetParams, type ForgetResult, type GraphQueryParams, type GraphQueryResult, GraphStore, type InitParams, type InitResult, type KGScope, LATEST_SCHEMA_VERSION, Llm, type LlmInitConfig, type LlmModels, MEMORY_CATEGORIES, MEMORY_HOOK_BINDINGS, MEMORY_HOOK_EVENTS, MEMORY_JSON_REL_PATH, MEMORY_PLUGIN_ID, MEMORY_PLUGIN_MANIFEST, MEMORY_PLUGIN_VERSION, MEMORY_TOOL_ID, MEMORY_TOOL_OPS, MIGRATIONS, MemoryCache, type MemoryCategory, type MemoryCliDeps, type MemoryCliResult, MemoryDatabaseManager, type MemoryEdge, type MemoryFact, type MemoryJson, MemoryJsonSchema, type MemoryNode, type MemoryNodeWithEdges, type MemoryOp, MemoryPlugin, MemoryPlugin as MemoryPluginEntry, MemoryPluginHook, type MemoryQuery, type MemoryRecallResult, type MemorySource, MemoryStdioServer, type MemorySystemConfig, MemoryTool, type MemoryVector, type NodeQueryFilter, OP_REGISTRY, type OpAnnotations, type OpHandlerContext, type OpScope, type RecallParams, type RecallResult, type RememberParams, type RememberResult, type StatusResult, type SyncParams, type SyncResult, type UpdateParams, type UpdateResult, addWord, closeTokenizer, consolidate, createMemoryHookMatchers, doctor, executeOp, extract, forget, getGlobal, getHomeDir, getInstance, getMemoryDbPath, getMemoryDir, getXdgData, graphQuery, handleMemoryCli, init, initTokenizer, isInitialized, loadCustomDict, readCurrentSchemaVersion, recall, remember, renderBanner, renderHelp, renderOperationMarkdown, resetGlobalAdapter, resetInstanceAdapter, runMigrations, setGlobalAdapter, setInstanceAdapter, status, sync, toFtsTokens, toFtsTokensForSearch, tokenize, tokenizeForSearch, update };