@easbot/memory 0.3.28 → 0.3.32
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.
- package/README.en.md +1 -1
- package/README.md +21 -1
- package/dist/chunks/cache-IGJVAUPS.cjs +1 -0
- package/dist/chunks/cache-U5YYUDWO.mjs +1 -0
- package/dist/chunks/chunk-6H5PTRZL.cjs +1 -0
- package/dist/chunks/chunk-7C2J2PDC.cjs +77 -0
- package/dist/chunks/chunk-AEAMQDNV.mjs +67 -0
- package/dist/chunks/chunk-AJDMZTCQ.mjs +1 -0
- package/dist/chunks/chunk-AVECFV5K.cjs +1 -0
- package/dist/chunks/{chunk-P45OBSAC.cjs → chunk-DYD3SEPC.cjs} +19 -19
- package/dist/chunks/chunk-EKSLNNMF.cjs +1 -0
- package/dist/chunks/{chunk-I5YSX4DQ.mjs → chunk-FZ3RTYIJ.mjs} +19 -19
- package/dist/chunks/chunk-GCVKM3RJ.cjs +1 -0
- package/dist/chunks/chunk-HH7EA2UE.mjs +1 -0
- package/dist/chunks/chunk-HX3TV7FD.mjs +1 -0
- package/dist/chunks/chunk-KFESJR3T.cjs +1 -0
- package/dist/chunks/chunk-NHRRIJFK.cjs +1 -0
- package/dist/chunks/chunk-S4DPVKMV.mjs +1 -0
- package/dist/chunks/chunk-SE3F5YQE.mjs +1 -0
- package/dist/chunks/chunk-YAF6HMAE.cjs +67 -0
- package/dist/chunks/chunk-YJLHS7JB.mjs +77 -0
- package/dist/chunks/chunk-YUWHNHAY.mjs +1 -0
- package/dist/chunks/cli-handler-IXFJAQFB.cjs +1 -0
- package/dist/chunks/cli-handler-JHSDGJHK.mjs +1 -0
- package/dist/chunks/{config-2SQJYVTO.mjs → config-5P7O45FH.mjs} +1 -1
- package/dist/chunks/{config-I2I6U4XM.cjs → config-KFPQDFJR.cjs} +1 -1
- package/dist/chunks/consolidate-KZAYROKJ.cjs +2 -0
- package/dist/chunks/consolidate-OOAMW7XW.mjs +2 -0
- package/dist/chunks/doctor-OAWL5FMH.cjs +1 -0
- package/dist/chunks/doctor-ZGHICE2Q.mjs +1 -0
- package/dist/chunks/extract-AJY2ETKE.mjs +2 -0
- package/dist/chunks/extract-BS6HOLXU.cjs +2 -0
- package/dist/chunks/forget-NIBBY6FG.mjs +3 -0
- package/dist/chunks/forget-Q6UN6GSW.cjs +3 -0
- package/dist/chunks/graph-4K56ZAVL.mjs +3 -0
- package/dist/chunks/graph-4KBXGMOL.cjs +3 -0
- package/dist/chunks/init-EBA3ZGC6.cjs +1 -0
- package/dist/chunks/init-HWR4SD6N.mjs +1 -0
- package/dist/chunks/{interfaces-LPJU4KS3.mjs → interfaces-OFM2XGSG.mjs} +1 -1
- package/dist/chunks/interfaces-TGSOKRFI.cjs +1 -0
- package/dist/chunks/llm-BRSMYENV.mjs +1 -0
- package/dist/chunks/llm-TQXCNG4J.cjs +1 -0
- package/dist/chunks/mcp-PH3CLOYP.cjs +1 -0
- package/dist/chunks/mcp-ZWZYH52C.mjs +1 -0
- package/dist/chunks/{recall-UQSG6ECA.mjs → recall-BRXHJPR4.mjs} +2 -2
- package/dist/chunks/recall-SBUTMJPU.cjs +2 -0
- package/dist/chunks/remember-3XSYCWKK.mjs +2 -0
- package/dist/chunks/remember-FXMXYHLK.cjs +2 -0
- package/dist/chunks/status-H4UKSZAH.cjs +1 -0
- package/dist/chunks/status-SW5BUHJ3.mjs +1 -0
- package/dist/chunks/stdio-server-3A3H4YJ7.mjs +1 -0
- package/dist/chunks/stdio-server-CWA2HGXA.cjs +1 -0
- package/dist/chunks/sync-EE4ZD3WB.mjs +2 -0
- package/dist/chunks/sync-FTZT6MWJ.cjs +2 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +1 -6
- package/dist/index.d.cts +50 -78
- package/dist/index.d.ts +50 -78
- package/dist/index.mjs +1 -6
- package/package.json +9 -10
- package/dist/chunks/chunk-4YADRVIU.mjs +0 -1
- package/dist/chunks/chunk-6CQMBEIQ.mjs +0 -1
- package/dist/chunks/chunk-CPRDIUQ4.cjs +0 -1
- package/dist/chunks/chunk-DW3CJUBO.cjs +0 -1
- package/dist/chunks/chunk-FY4ILCIM.mjs +0 -77
- package/dist/chunks/chunk-HQBRVVXS.mjs +0 -1
- package/dist/chunks/chunk-HY2LFKG7.cjs +0 -67
- package/dist/chunks/chunk-J5XF2W4Z.cjs +0 -1
- package/dist/chunks/chunk-LYBUZDJK.cjs +0 -77
- package/dist/chunks/chunk-M2YU5LAI.cjs +0 -1
- package/dist/chunks/chunk-WDVDYZ25.mjs +0 -1
- package/dist/chunks/chunk-X7P7ZFZF.mjs +0 -67
- package/dist/chunks/cli-handler-ETHJPZPG.mjs +0 -1
- package/dist/chunks/cli-handler-PG4IBTY2.cjs +0 -1
- package/dist/chunks/consolidate-7GFUFPLX.cjs +0 -2
- package/dist/chunks/consolidate-BGMXJUQX.mjs +0 -2
- package/dist/chunks/doctor-C2FWFUDO.mjs +0 -1
- package/dist/chunks/doctor-SCXUJRSG.cjs +0 -1
- package/dist/chunks/extract-O4IOL6BZ.cjs +0 -2
- package/dist/chunks/extract-RBBSVK2S.mjs +0 -2
- package/dist/chunks/forget-JTACRG7Y.mjs +0 -3
- package/dist/chunks/forget-M4I6GVWI.cjs +0 -3
- package/dist/chunks/graph-AOMDJ6YA.cjs +0 -3
- package/dist/chunks/graph-VBVVRV6V.mjs +0 -3
- package/dist/chunks/init-2SBK7ZWO.mjs +0 -1
- package/dist/chunks/init-VTPJR56L.cjs +0 -1
- package/dist/chunks/interfaces-Q5OGU5EK.cjs +0 -1
- package/dist/chunks/llm-7LQGYSUE.cjs +0 -1
- package/dist/chunks/llm-UHTBU2HA.mjs +0 -1
- package/dist/chunks/mcp-VIOHPDO5.cjs +0 -1
- package/dist/chunks/mcp-ZQCLVZIR.mjs +0 -1
- package/dist/chunks/recall-JSTQDGGZ.cjs +0 -2
- package/dist/chunks/remember-GVQJ5G7Z.mjs +0 -2
- package/dist/chunks/remember-Z4UJJN62.cjs +0 -2
- package/dist/chunks/status-DH33MQZV.cjs +0 -1
- package/dist/chunks/status-VZ5EBAOY.mjs +0 -1
- package/dist/chunks/stdio-server-JC53PUET.mjs +0 -1
- package/dist/chunks/stdio-server-OUZAN4IM.cjs +0 -1
- package/dist/chunks/sync-6I2ZJUH6.cjs +0 -2
- package/dist/chunks/sync-UT4D32ML.mjs +0 -2
|
@@ -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 chunkYAF6HMAE_cjs=require('./chunk-YAF6HMAE.cjs');require('./chunk-7C2J2PDC.cjs'),require('./chunk-EKSLNNMF.cjs'),require('./chunk-AVECFV5K.cjs');var chunkNHRRIJFK_cjs=require('./chunk-NHRRIJFK.cjs');require('./chunk-GCVKM3RJ.cjs'),require('./chunk-KFESJR3T.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 chunkYAF6HMAE_cjs.z("sync",{windowDays:e.windowDays,dryRun:e.dryRun??false},chunkYAF6HMAE_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
|
|
2
|
+
'use strict';var chunkKFESJR3T_cjs=require('./chunks/chunk-KFESJR3T.cjs'),fs=require('fs'),path=require('path'),url=require('url'),terminal=require('@easbot/terminal');var N=path.dirname(url.fileURLToPath(chunkKFESJR3T_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-TGSOKRFI.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-IXFJAQFB.cjs');a();return}if(t[0]==="--help"||t[0]==="-h"){let{renderHelp:a}=await import('./chunks/cli-handler-IXFJAQFB.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-IXFJAQFB.cjs'),{setInstanceAdapter:v}=await import('./chunks/interfaces-TGSOKRFI.cjs');v({directory:i,worktree:i});let{setAdapterRegistry:y}=await import('@easbot/llm'),{getGlobal:r,getInstance:p}=await import('./chunks/interfaces-TGSOKRFI.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
|
|
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 @@
|
|
|
1
|
-
'use strict';require('./chunks/chunk-URADAZYW.cjs');var
|
|
2
|
-
${n.join(`
|
|
3
|
-
`)}`,logLine:`session-start: injected ${t.hits.length} facts into context (agent=${e.agentId})`}}catch(t){return {ok:false,error:t instanceof Error?t.message:String(t)}}};var he=3600*1e3,z=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:he,o=e.extras?.fromTime??new Date(Date.now()-r).toISOString();try{let t=await chunkHY2LFKG7_cjs.z("consolidate",{fromTime:o},m(e.agentId));return {ok:!0,logLine:`session-end: lookback=${r}ms, total=${t.totalFacts}, deduped=${t.dedupedCount}, archived=${t.archivedCount}, skipped=${t.skippedCount}`}}catch(t){return {ok:false,error:t instanceof Error?t.message:String(t)}}};var Y=async e=>{if(!e.agentId?.trim())return {ok:false,error:"pre-compact: agentId is required in ctx"};let o=(e.contextPreview??e.messagePreview??"").slice(0,200).replace(/\s+/g," ").trim(),t=e.extras?.topK??3;if(!o)return {ok:true,injected:"",logLine:"pre-compact: empty contextPreview; skipping recall injection"};try{let n=await chunkHY2LFKG7_cjs.z("recall",{query:o,maxResults:t,minImportance:5},m(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:n instanceof Error?n.message:String(n)}}};var B=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),o=e.messagePreview?e.messagePreview.slice(0,200).replace(/\s+/g," ").trim():"",t=[`[error_pattern] tool=${e.toolName}`,`[error] ${e.error}`,o?`[preview] ${o}`:"",`[errHash] ${r}`].filter(Boolean).join(`
|
|
6
|
-
`);try{return {ok:!0,logLine:`post-tool-failure: wrote error_pattern fact ${(await chunkHY2LFKG7_cjs.z("remember",{content:t,category:"error_pattern",importance:6,tags:["post-tool-failure",`tool:${e.toolName}`,`err:${r}`],sessionId:e.sessionId,msgId:e.extras?.msgId},m(e.agentId))).fact.id} (tool=${e.toolName}, errHash=${r})`}}catch(n){return {ok:false,error:n instanceof Error?n.message:String(n)}}};var u=utils.Log.create({service:"memory.hooks"}),g=new Map;function f(e,r){let o={name:e,handler:r,registeredAt:new Date().toISOString()},t=g.get(e);g.set(e,o),t?u.info("Hook overwritten",{name:e,prevRegisteredAt:t.registeredAt,newRegisteredAt:o.registeredAt}):u.info("Hook registered",{name:e,registeredAt:o.registeredAt});}function Ie(e){return g.delete(e)}function Me(){return Array.from(g.values()).map(e=>({name:e.name,handler:e.handler,registeredAt:e.registeredAt}))}function _e(){f("session-start",j),f("session-end",z),f("pre-compact",Y),f("post-tool-failure",B);}function Se(){g.clear(),u.debug("All hooks cleared");}async function Oe(e,r){let o=g.get(e);if(!o)return u.debug("dispatchHook: no handler registered; noop",{name:e}),{ok:true,logLine:`hook ${e} not registered; noop`};try{let t=await o.handler(r);return t.ok?t.logLine&&u.debug("dispatchHook: ok",{name:e,logLine:t.logLine}):u.warn("dispatchHook: handler returned failure",{name:e,agentId:r.agentId,error:t.error}),t}catch(t){let n=t instanceof Error?t.message:String(t);return u.warn("dispatchHook: handler threw, caught and converted to failure result",{name:e,agentId:r.agentId,error:n}),{ok:false,error:n}}}Object.defineProperty(exports,"COMMANDS_HELP",{enumerable:true,get:function(){return chunkDW3CJUBO_cjs.a}});Object.defineProperty(exports,"handleMemoryCli",{enumerable:true,get:function(){return chunkDW3CJUBO_cjs.d}});Object.defineProperty(exports,"renderBanner",{enumerable:true,get:function(){return chunkDW3CJUBO_cjs.b}});Object.defineProperty(exports,"renderHelp",{enumerable:true,get:function(){return chunkDW3CJUBO_cjs.c}});Object.defineProperty(exports,"MemoryStdioServer",{enumerable:true,get:function(){return chunkP45OBSAC_cjs.b}});Object.defineProperty(exports,"renderOperationMarkdown",{enumerable:true,get:function(){return chunkP45OBSAC_cjs.a}});Object.defineProperty(exports,"ALL_OPS",{enumerable:true,get:function(){return chunkHY2LFKG7_cjs.y}});Object.defineProperty(exports,"GraphStore",{enumerable:true,get:function(){return chunkHY2LFKG7_cjs.a}});Object.defineProperty(exports,"OP_REGISTRY",{enumerable:true,get:function(){return chunkHY2LFKG7_cjs.x}});Object.defineProperty(exports,"consolidate",{enumerable:true,get:function(){return chunkHY2LFKG7_cjs.r}});Object.defineProperty(exports,"doctor",{enumerable:true,get:function(){return chunkHY2LFKG7_cjs.w}});Object.defineProperty(exports,"executeOp",{enumerable:true,get:function(){return chunkHY2LFKG7_cjs.z}});Object.defineProperty(exports,"extract",{enumerable:true,get:function(){return chunkHY2LFKG7_cjs.q}});Object.defineProperty(exports,"forget",{enumerable:true,get:function(){return chunkHY2LFKG7_cjs.p}});Object.defineProperty(exports,"graphQuery",{enumerable:true,get:function(){return chunkHY2LFKG7_cjs.t}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunkHY2LFKG7_cjs.u}});Object.defineProperty(exports,"recall",{enumerable:true,get:function(){return chunkHY2LFKG7_cjs.b}});Object.defineProperty(exports,"remember",{enumerable:true,get:function(){return chunkHY2LFKG7_cjs.n}});Object.defineProperty(exports,"status",{enumerable:true,get:function(){return chunkHY2LFKG7_cjs.v}});Object.defineProperty(exports,"sync",{enumerable:true,get:function(){return chunkHY2LFKG7_cjs.s}});Object.defineProperty(exports,"update",{enumerable:true,get:function(){return chunkHY2LFKG7_cjs.o}});Object.defineProperty(exports,"LATEST_SCHEMA_VERSION",{enumerable:true,get:function(){return chunkLYBUZDJK_cjs.a}});Object.defineProperty(exports,"MIGRATIONS",{enumerable:true,get:function(){return chunkLYBUZDJK_cjs.b}});Object.defineProperty(exports,"MemoryDatabaseManager",{enumerable:true,get:function(){return chunkLYBUZDJK_cjs.e}});Object.defineProperty(exports,"readCurrentSchemaVersion",{enumerable:true,get:function(){return chunkLYBUZDJK_cjs.d}});Object.defineProperty(exports,"runMigrations",{enumerable:true,get:function(){return chunkLYBUZDJK_cjs.c}});Object.defineProperty(exports,"getGlobal",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.c}});Object.defineProperty(exports,"getHomeDir",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.g}});Object.defineProperty(exports,"getInstance",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.f}});Object.defineProperty(exports,"getMemoryDbPath",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.j}});Object.defineProperty(exports,"getMemoryDir",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.i}});Object.defineProperty(exports,"getXdgData",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.h}});Object.defineProperty(exports,"resetGlobalAdapter",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.b}});Object.defineProperty(exports,"resetInstanceAdapter",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.e}});Object.defineProperty(exports,"setGlobalAdapter",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.a}});Object.defineProperty(exports,"setInstanceAdapter",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.d}});Object.defineProperty(exports,"Llm",{enumerable:true,get:function(){return chunkJ5XF2W4Z_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=Ae;exports.MemoryDatabaseError=v;exports.MemoryEmbeddingError=$;exports.MemoryError=p;exports.MemoryErrorCode=ue;exports.MemoryFileError=F;exports.MemoryNotFoundError=D;exports.MemoryPermissionError=T;exports.MemorySearchError=L;exports.MemoryValidationError=N;exports.addWord=$e;exports.clearAllHooks=Se;exports.closeTokenizer=ze;exports.dispatchHook=Oe;exports.initTokenizer=Le;exports.isInitialized=je;exports.listHooks=Me;exports.loadCustomDict=ke;exports.registerAllDefaultHooks=_e;exports.registerHook=f;exports.toFtsTokens=Ye;exports.toFtsTokensForSearch=Be;exports.tokenize=xe;exports.tokenizeForSearch=He;exports.unregisterHook=Ie;
|
|
1
|
+
'use strict';var chunkDYD3SEPC_cjs=require('./chunks/chunk-DYD3SEPC.cjs');require('./chunks/chunk-URADAZYW.cjs');var chunk6H5PTRZL_cjs=require('./chunks/chunk-6H5PTRZL.cjs'),chunkYAF6HMAE_cjs=require('./chunks/chunk-YAF6HMAE.cjs'),chunk7C2J2PDC_cjs=require('./chunks/chunk-7C2J2PDC.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'),chunkKFESJR3T_cjs=require('./chunks/chunk-KFESJR3T.cjs'),types=require('@easbot/types'),n=require('jieba-wasm'),utils=require('@easbot/utils');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 n__namespace=/*#__PURE__*/_interopNamespace(n);var ne=["user_preference","task_context","technical_fact","decision","relationship","reminder","error_pattern","workflow","exploration_finding","experience_summary","tool_usage","skill_creation","test","other"];var t=utils.Log.create({service:"memory.tokenizer"}),o=false,ee=utils.loadTextFile("./assets/jieba_dict.txt",chunkKFESJR3T_cjs.d);async function ue(e){if(!o)try{t.debug("Initializing jieba tokenizer");let r=ee();if(n__namespace.with_dict(r),t.debug("Built-in dictionary loaded"),e?.dictPath&&e.dictPath.length>0)for(let s of e.dictPath)await re(s);o=!0,t.debug("Jieba tokenizer initialized successfully");}catch(r){t.error("Failed to initialize jieba tokenizer",{error:utils.errorMeta(r)}),t.warn("Using fallback tokenization (space-based)");}}async function re(e){if(!o)throw new chunkAVECFV5K_cjs.a.TokenizerNotInitializedError({message:"Tokenizer not initialized"});try{let r=await utils.Filesystem.readText(e);t.debug("Loading custom dictionary",{dictPath:e}),n__namespace.with_dict(r),t.debug("Custom dictionary loaded successfully",{dictPath:e});}catch(r){t.warn("Failed to load custom dictionary",{dictPath:e,error:utils.errorMeta(r)});}}function te(e){if(!o)return e.split(/\s+/).filter(Boolean);try{return n__namespace.cut(e)}catch(r){return t.warn("Tokenization failed, using fallback",{error:utils.errorMeta(r)}),e.split(/\s+/).filter(Boolean)}}function oe(e){if(!o)return e.split(/\s+/).filter(Boolean);try{return n__namespace.cut_for_search(e)}catch(r){return t.warn("Tokenization for search failed, using fallback",{error:utils.errorMeta(r)}),e.split(/\s+/).filter(Boolean)}}function ge(e,r,s){if(o)try{n__namespace.add_word(e,r,s),t.debug("Word added to dictionary",{word:e,freq:r,tag:s});}catch(S){t.warn("Failed to add word",{word:e,error:utils.errorMeta(S)});}}function ye(){return o}async function fe(){o=false,t.debug("Tokenizer closed");}function xe(e){if(!o)return e.split(/\s+/).filter(Boolean).join(" ");try{return te(e).join(" ")}catch(r){return t.warn("Tokenization failed, using fallback",{error:utils.errorMeta(r)}),e.split(/\s+/).filter(Boolean).join(" ")}}function Me(e){if(!o)return e.split(/\s+/).filter(Boolean).join(" ");try{return oe(e).join(" ")}catch(r){return t.warn("Tokenization for search failed, using fallback",{error:utils.errorMeta(r)}),e.split(/\s+/).filter(Boolean).join(" ")}}Object.defineProperty(exports,"MemoryStdioServer",{enumerable:true,get:function(){return chunkDYD3SEPC_cjs.b}});Object.defineProperty(exports,"renderOperationMarkdown",{enumerable:true,get:function(){return chunkDYD3SEPC_cjs.a}});Object.defineProperty(exports,"COMMANDS_HELP",{enumerable:true,get:function(){return chunk6H5PTRZL_cjs.a}});Object.defineProperty(exports,"handleMemoryCli",{enumerable:true,get:function(){return chunk6H5PTRZL_cjs.d}});Object.defineProperty(exports,"renderBanner",{enumerable:true,get:function(){return chunk6H5PTRZL_cjs.b}});Object.defineProperty(exports,"renderHelp",{enumerable:true,get:function(){return chunk6H5PTRZL_cjs.c}});Object.defineProperty(exports,"ALL_OPS",{enumerable:true,get:function(){return chunkYAF6HMAE_cjs.y}});Object.defineProperty(exports,"GraphStore",{enumerable:true,get:function(){return chunkYAF6HMAE_cjs.a}});Object.defineProperty(exports,"OP_REGISTRY",{enumerable:true,get:function(){return chunkYAF6HMAE_cjs.x}});Object.defineProperty(exports,"consolidate",{enumerable:true,get:function(){return chunkYAF6HMAE_cjs.r}});Object.defineProperty(exports,"doctor",{enumerable:true,get:function(){return chunkYAF6HMAE_cjs.v}});Object.defineProperty(exports,"executeOp",{enumerable:true,get:function(){return chunkYAF6HMAE_cjs.z}});Object.defineProperty(exports,"extract",{enumerable:true,get:function(){return chunkYAF6HMAE_cjs.q}});Object.defineProperty(exports,"forget",{enumerable:true,get:function(){return chunkYAF6HMAE_cjs.p}});Object.defineProperty(exports,"graphQuery",{enumerable:true,get:function(){return chunkYAF6HMAE_cjs.t}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunkYAF6HMAE_cjs.w}});Object.defineProperty(exports,"recall",{enumerable:true,get:function(){return chunkYAF6HMAE_cjs.b}});Object.defineProperty(exports,"remember",{enumerable:true,get:function(){return chunkYAF6HMAE_cjs.n}});Object.defineProperty(exports,"status",{enumerable:true,get:function(){return chunkYAF6HMAE_cjs.u}});Object.defineProperty(exports,"sync",{enumerable:true,get:function(){return chunkYAF6HMAE_cjs.s}});Object.defineProperty(exports,"update",{enumerable:true,get:function(){return chunkYAF6HMAE_cjs.o}});Object.defineProperty(exports,"LATEST_SCHEMA_VERSION",{enumerable:true,get:function(){return chunk7C2J2PDC_cjs.a}});Object.defineProperty(exports,"MIGRATIONS",{enumerable:true,get:function(){return chunk7C2J2PDC_cjs.b}});Object.defineProperty(exports,"MemoryDatabaseManager",{enumerable:true,get:function(){return chunk7C2J2PDC_cjs.e}});Object.defineProperty(exports,"readCurrentSchemaVersion",{enumerable:true,get:function(){return chunk7C2J2PDC_cjs.d}});Object.defineProperty(exports,"runMigrations",{enumerable:true,get:function(){return chunk7C2J2PDC_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=ne;exports.addWord=ge;exports.closeTokenizer=fe;exports.initTokenizer=ue;exports.isInitialized=ye;exports.loadCustomDict=re;exports.toFtsTokens=xe;exports.toFtsTokensForSearch=Me;exports.tokenize=te;exports.tokenizeForSearch=oe;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import { KnowledgeSearchOptions, MemoryKnowledgeConfigWithModels, KnowledgeDoctorResult, MemoryStatus, IGlobal, IInstance } from '@easbot/types';
|
|
2
2
|
export { GRAPH_ENTITY_TYPE_DEFINITIONS, GRAPH_RELATION_TYPE_DEFINITIONS } from '@easbot/types';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { ILLMInitConfig, ILLMCapabilities } from '@easbot/llm';
|
|
6
|
-
import { ZodTypeAny } from 'zod';
|
|
3
|
+
import { ILLMInitConfig, ILLMCapabilities, EmbeddingModelRef, LanguageModelRef, ExtractedEntity, ExtractedRelation } from '@easbot/llm';
|
|
4
|
+
import { z, ZodTypeAny } from 'zod';
|
|
7
5
|
import { StdioServerConfig } from '@easbot/mcp';
|
|
8
6
|
import { SyncSqliteConnection } from '@easbot/database';
|
|
7
|
+
export { EmbeddingModelV3 as EmbeddingModel, LanguageModelV3 as LanguageModel } from '@ai-sdk/provider';
|
|
8
|
+
|
|
9
|
+
declare const MemoryJsonSchema: z.ZodObject<{
|
|
10
|
+
version: z.ZodOptional<z.ZodLiteral<1>>;
|
|
11
|
+
schema_version: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
extraction_version: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
index_state: z.ZodOptional<z.ZodString>;
|
|
14
|
+
backend: z.ZodOptional<z.ZodString>;
|
|
15
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
16
|
+
embedding_model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
17
|
+
graph_model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
18
|
+
archive_days: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
short_term_max_rounds: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
}, z.core.$loose>;
|
|
21
|
+
type MemoryJson = z.infer<typeof MemoryJsonSchema>;
|
|
22
|
+
declare const DEFAULT_MEMORY_JSON: MemoryJson;
|
|
9
23
|
|
|
10
24
|
type MemoryCategory = 'user_preference' | 'task_context' | 'technical_fact' | 'decision' | 'relationship' | 'reminder' | 'error_pattern' | 'workflow' | 'exploration_finding' | 'experience_summary' | 'tool_usage' | 'skill_creation' | 'test' | 'other';
|
|
11
25
|
declare const MEMORY_CATEGORIES: MemoryCategory[];
|
|
@@ -66,41 +80,6 @@ interface MemoryRecallResult {
|
|
|
66
80
|
updatedAt?: string;
|
|
67
81
|
}
|
|
68
82
|
type MemorySystemConfig = MemoryKnowledgeConfigWithModels;
|
|
69
|
-
declare class MemoryError extends Error {
|
|
70
|
-
readonly code: string;
|
|
71
|
-
cause?: Error | undefined;
|
|
72
|
-
constructor(message: string, code: string, cause?: Error | undefined);
|
|
73
|
-
}
|
|
74
|
-
declare class MemoryValidationError extends MemoryError {
|
|
75
|
-
constructor(message: string, cause?: Error);
|
|
76
|
-
}
|
|
77
|
-
declare class MemoryNotFoundError extends MemoryError {
|
|
78
|
-
constructor(memoryId: string);
|
|
79
|
-
}
|
|
80
|
-
declare class MemoryPermissionError extends MemoryError {
|
|
81
|
-
constructor(message: string);
|
|
82
|
-
}
|
|
83
|
-
declare class MemoryDatabaseError extends MemoryError {
|
|
84
|
-
constructor(message: string, cause?: Error);
|
|
85
|
-
}
|
|
86
|
-
declare class MemoryFileError extends MemoryError {
|
|
87
|
-
constructor(message: string, cause?: Error);
|
|
88
|
-
}
|
|
89
|
-
declare class MemorySearchError extends MemoryError {
|
|
90
|
-
constructor(message: string, cause?: Error);
|
|
91
|
-
}
|
|
92
|
-
declare class MemoryEmbeddingError extends MemoryError {
|
|
93
|
-
constructor(message: string, cause?: Error);
|
|
94
|
-
}
|
|
95
|
-
declare enum MemoryErrorCode {
|
|
96
|
-
VALIDATION_ERROR = "MEMORY_VALIDATION_ERROR",
|
|
97
|
-
NOT_FOUND = "MEMORY_NOT_FOUND",
|
|
98
|
-
PERMISSION_ERROR = "MEMORY_PERMISSION_ERROR",
|
|
99
|
-
DATABASE_ERROR = "MEMORY_DATABASE_ERROR",
|
|
100
|
-
FILE_ERROR = "MEMORY_FILE_ERROR",
|
|
101
|
-
SEARCH_ERROR = "MEMORY_SEARCH_ERROR",
|
|
102
|
-
EMBEDDING_ERROR = "MEMORY_EMBEDDING_ERROR"
|
|
103
|
-
}
|
|
104
83
|
interface MemoryNode {
|
|
105
84
|
id: number;
|
|
106
85
|
name: string;
|
|
@@ -161,8 +140,8 @@ declare function toFtsTokens(text: string): string;
|
|
|
161
140
|
declare function toFtsTokensForSearch(text: string): string;
|
|
162
141
|
|
|
163
142
|
interface LlmModels {
|
|
164
|
-
|
|
165
|
-
|
|
143
|
+
embedding?: EmbeddingModelRef;
|
|
144
|
+
graph?: LanguageModelRef;
|
|
166
145
|
}
|
|
167
146
|
interface LlmInitConfig extends ILLMInitConfig {
|
|
168
147
|
options?: {
|
|
@@ -181,10 +160,20 @@ declare namespace Llm {
|
|
|
181
160
|
function isInitialized(): boolean;
|
|
182
161
|
function reset(): void;
|
|
183
162
|
function capabilities(): ILLMCapabilities;
|
|
184
|
-
function
|
|
185
|
-
function
|
|
163
|
+
function getEmbedding(): EmbeddingModelRef | undefined;
|
|
164
|
+
function getGraph(): LanguageModelRef | undefined;
|
|
186
165
|
function embedText(value: string): Promise<Float32Array>;
|
|
187
166
|
function embedTexts(values: string[]): Promise<Float32Array[]>;
|
|
167
|
+
function probeEmbeddingDims(options?: {
|
|
168
|
+
timeoutMs?: number;
|
|
169
|
+
}): Promise<number | undefined>;
|
|
170
|
+
function generateGraph(chunks: string[], options?: {
|
|
171
|
+
graphLlm?: LanguageModelRef;
|
|
172
|
+
}): Promise<{
|
|
173
|
+
entities: ExtractedEntity[];
|
|
174
|
+
relations: ExtractedRelation[];
|
|
175
|
+
summary: string;
|
|
176
|
+
}>;
|
|
188
177
|
const embed: typeof embedText;
|
|
189
178
|
const embedMany: typeof embedTexts;
|
|
190
179
|
}
|
|
@@ -198,7 +187,6 @@ interface MemoryServiceContext {
|
|
|
198
187
|
config?: MemoryKnowledgeConfigWithModels;
|
|
199
188
|
agentId?: string;
|
|
200
189
|
}
|
|
201
|
-
type ErrorCode = 'AGENT_ID_REQUIRED' | 'SESSION_ID_REQUIRED' | 'CONTENT_REQUIRED' | 'INTERNAL' | 'NOT_FOUND' | 'AMBIGUOUS' | 'NOT_INDEXED' | 'OPTIONAL_DEP_MISSING' | 'TRUST_DENIED' | 'PATH_TRAVERSAL' | 'CATEGORY_REQUIRED' | 'IMPORTANCE_REQUIRED' | 'TIMERANGE_REQUIRED' | 'INGEST_FAILED' | 'UNSUPPORTED_FORMAT' | 'HAS_REFERENCES' | 'DRY_RUN_NO_DELETE' | 'MAX_DELETE_EXCEEDED' | 'JOB_NOT_FOUND' | 'JOB_TIMEOUT' | 'JOB_FAILED';
|
|
202
190
|
type KGScope = 'agent_only' | 'shared_only' | 'both';
|
|
203
191
|
interface RecallParams {
|
|
204
192
|
query: string;
|
|
@@ -212,6 +200,7 @@ interface RecallParams {
|
|
|
212
200
|
maxDepth?: number;
|
|
213
201
|
maxEdgesPerNode?: number;
|
|
214
202
|
includeShared?: boolean;
|
|
203
|
+
snippetMaxChars?: number;
|
|
215
204
|
}
|
|
216
205
|
interface RecallResult {
|
|
217
206
|
hits: MemoryRecallResult[];
|
|
@@ -369,7 +358,6 @@ interface DoctorResult extends KnowledgeDoctorResult {
|
|
|
369
358
|
}
|
|
370
359
|
interface InitParams {
|
|
371
360
|
dbPath?: string;
|
|
372
|
-
workspaceDir?: string;
|
|
373
361
|
archiveDays?: number;
|
|
374
362
|
force?: boolean;
|
|
375
363
|
}
|
|
@@ -537,10 +525,7 @@ declare function getInstance(): IInstance;
|
|
|
537
525
|
declare function getHomeDir(): string;
|
|
538
526
|
declare function getXdgData(): string;
|
|
539
527
|
declare function getMemoryDir(): string;
|
|
540
|
-
declare function getMemoryDbPath(
|
|
541
|
-
dir?: string;
|
|
542
|
-
workspaceDir?: string;
|
|
543
|
-
}): string;
|
|
528
|
+
declare function getMemoryDbPath(workspaceDir: string): string;
|
|
544
529
|
|
|
545
530
|
type MigrationDb = SyncSqliteConnection;
|
|
546
531
|
declare const LATEST_SCHEMA_VERSION = 1;
|
|
@@ -631,34 +616,21 @@ declare class GraphStore {
|
|
|
631
616
|
}): Promise<MemoryNodeWithEdges[]>;
|
|
632
617
|
}
|
|
633
618
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
}
|
|
650
|
-
type HookHandler = (ctx: HookContext) => Promise<HookResult>;
|
|
651
|
-
interface RegisteredHook {
|
|
652
|
-
name: HookName;
|
|
653
|
-
handler: HookHandler;
|
|
654
|
-
registeredAt: string;
|
|
619
|
+
declare const MEMORY_JSON_REL_PATH: readonly [".easbot", "memory.json"];
|
|
620
|
+
type StateResult = {
|
|
621
|
+
memoryJson: MemoryJson | undefined;
|
|
622
|
+
exists: boolean;
|
|
623
|
+
rootDir: string;
|
|
624
|
+
};
|
|
625
|
+
declare namespace MemoryCache {
|
|
626
|
+
function state(): Promise<StateResult>;
|
|
627
|
+
function resetState(writtenPath?: string): void;
|
|
628
|
+
function init(): Promise<void>;
|
|
629
|
+
function getMemoryJson(): Promise<MemoryJson | undefined>;
|
|
630
|
+
function exists(): Promise<boolean>;
|
|
631
|
+
function getRootDir(): Promise<string>;
|
|
632
|
+
function writeMemoryJson(partial: Partial<MemoryJson>): Promise<MemoryJson>;
|
|
633
|
+
function getConfigPath(): Promise<string>;
|
|
655
634
|
}
|
|
656
635
|
|
|
657
|
-
|
|
658
|
-
declare function unregisterHook(name: HookName): boolean;
|
|
659
|
-
declare function listHooks(): readonly RegisteredHook[];
|
|
660
|
-
declare function registerAllDefaultHooks(): void;
|
|
661
|
-
declare function clearAllHooks(): void;
|
|
662
|
-
declare function dispatchHook(name: HookName, ctx: HookContext): Promise<HookResult>;
|
|
663
|
-
|
|
664
|
-
export { ALL_OPS, type ArchiveRecord, type ArchiveResult, COMMANDS_HELP, type CommandHelp, type ConsolidateParams, type ConsolidateResult, type DoctorResult, type EdgeQueryFilter, type ErrorCode, 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, MIGRATIONS, type MemoryCategory, type MemoryCliDeps, type MemoryCliResult, MemoryDatabaseError, MemoryDatabaseManager, type MemoryEdge, MemoryEmbeddingError, MemoryError, MemoryErrorCode, type MemoryFact, MemoryFileError, 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 };
|
|
636
|
+
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_JSON_REL_PATH, MIGRATIONS, MemoryCache, type MemoryCategory, type MemoryCliDeps, type MemoryCliResult, MemoryDatabaseManager, type MemoryEdge, type MemoryFact, type MemoryJson, MemoryJsonSchema, type MemoryNode, type MemoryNodeWithEdges, type MemoryOp, type MemoryQuery, type MemoryRecallResult, type MemorySource, MemoryStdioServer, type MemorySystemConfig, 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, 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,25 @@
|
|
|
1
1
|
import { KnowledgeSearchOptions, MemoryKnowledgeConfigWithModels, KnowledgeDoctorResult, MemoryStatus, IGlobal, IInstance } from '@easbot/types';
|
|
2
2
|
export { GRAPH_ENTITY_TYPE_DEFINITIONS, GRAPH_RELATION_TYPE_DEFINITIONS } from '@easbot/types';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { ILLMInitConfig, ILLMCapabilities } from '@easbot/llm';
|
|
6
|
-
import { ZodTypeAny } from 'zod';
|
|
3
|
+
import { ILLMInitConfig, ILLMCapabilities, EmbeddingModelRef, LanguageModelRef, ExtractedEntity, ExtractedRelation } from '@easbot/llm';
|
|
4
|
+
import { z, ZodTypeAny } from 'zod';
|
|
7
5
|
import { StdioServerConfig } from '@easbot/mcp';
|
|
8
6
|
import { SyncSqliteConnection } from '@easbot/database';
|
|
7
|
+
export { EmbeddingModelV3 as EmbeddingModel, LanguageModelV3 as LanguageModel } from '@ai-sdk/provider';
|
|
8
|
+
|
|
9
|
+
declare const MemoryJsonSchema: z.ZodObject<{
|
|
10
|
+
version: z.ZodOptional<z.ZodLiteral<1>>;
|
|
11
|
+
schema_version: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
extraction_version: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
index_state: z.ZodOptional<z.ZodString>;
|
|
14
|
+
backend: z.ZodOptional<z.ZodString>;
|
|
15
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
16
|
+
embedding_model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
17
|
+
graph_model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
18
|
+
archive_days: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
short_term_max_rounds: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
}, z.core.$loose>;
|
|
21
|
+
type MemoryJson = z.infer<typeof MemoryJsonSchema>;
|
|
22
|
+
declare const DEFAULT_MEMORY_JSON: MemoryJson;
|
|
9
23
|
|
|
10
24
|
type MemoryCategory = 'user_preference' | 'task_context' | 'technical_fact' | 'decision' | 'relationship' | 'reminder' | 'error_pattern' | 'workflow' | 'exploration_finding' | 'experience_summary' | 'tool_usage' | 'skill_creation' | 'test' | 'other';
|
|
11
25
|
declare const MEMORY_CATEGORIES: MemoryCategory[];
|
|
@@ -66,41 +80,6 @@ interface MemoryRecallResult {
|
|
|
66
80
|
updatedAt?: string;
|
|
67
81
|
}
|
|
68
82
|
type MemorySystemConfig = MemoryKnowledgeConfigWithModels;
|
|
69
|
-
declare class MemoryError extends Error {
|
|
70
|
-
readonly code: string;
|
|
71
|
-
cause?: Error | undefined;
|
|
72
|
-
constructor(message: string, code: string, cause?: Error | undefined);
|
|
73
|
-
}
|
|
74
|
-
declare class MemoryValidationError extends MemoryError {
|
|
75
|
-
constructor(message: string, cause?: Error);
|
|
76
|
-
}
|
|
77
|
-
declare class MemoryNotFoundError extends MemoryError {
|
|
78
|
-
constructor(memoryId: string);
|
|
79
|
-
}
|
|
80
|
-
declare class MemoryPermissionError extends MemoryError {
|
|
81
|
-
constructor(message: string);
|
|
82
|
-
}
|
|
83
|
-
declare class MemoryDatabaseError extends MemoryError {
|
|
84
|
-
constructor(message: string, cause?: Error);
|
|
85
|
-
}
|
|
86
|
-
declare class MemoryFileError extends MemoryError {
|
|
87
|
-
constructor(message: string, cause?: Error);
|
|
88
|
-
}
|
|
89
|
-
declare class MemorySearchError extends MemoryError {
|
|
90
|
-
constructor(message: string, cause?: Error);
|
|
91
|
-
}
|
|
92
|
-
declare class MemoryEmbeddingError extends MemoryError {
|
|
93
|
-
constructor(message: string, cause?: Error);
|
|
94
|
-
}
|
|
95
|
-
declare enum MemoryErrorCode {
|
|
96
|
-
VALIDATION_ERROR = "MEMORY_VALIDATION_ERROR",
|
|
97
|
-
NOT_FOUND = "MEMORY_NOT_FOUND",
|
|
98
|
-
PERMISSION_ERROR = "MEMORY_PERMISSION_ERROR",
|
|
99
|
-
DATABASE_ERROR = "MEMORY_DATABASE_ERROR",
|
|
100
|
-
FILE_ERROR = "MEMORY_FILE_ERROR",
|
|
101
|
-
SEARCH_ERROR = "MEMORY_SEARCH_ERROR",
|
|
102
|
-
EMBEDDING_ERROR = "MEMORY_EMBEDDING_ERROR"
|
|
103
|
-
}
|
|
104
83
|
interface MemoryNode {
|
|
105
84
|
id: number;
|
|
106
85
|
name: string;
|
|
@@ -161,8 +140,8 @@ declare function toFtsTokens(text: string): string;
|
|
|
161
140
|
declare function toFtsTokensForSearch(text: string): string;
|
|
162
141
|
|
|
163
142
|
interface LlmModels {
|
|
164
|
-
|
|
165
|
-
|
|
143
|
+
embedding?: EmbeddingModelRef;
|
|
144
|
+
graph?: LanguageModelRef;
|
|
166
145
|
}
|
|
167
146
|
interface LlmInitConfig extends ILLMInitConfig {
|
|
168
147
|
options?: {
|
|
@@ -181,10 +160,20 @@ declare namespace Llm {
|
|
|
181
160
|
function isInitialized(): boolean;
|
|
182
161
|
function reset(): void;
|
|
183
162
|
function capabilities(): ILLMCapabilities;
|
|
184
|
-
function
|
|
185
|
-
function
|
|
163
|
+
function getEmbedding(): EmbeddingModelRef | undefined;
|
|
164
|
+
function getGraph(): LanguageModelRef | undefined;
|
|
186
165
|
function embedText(value: string): Promise<Float32Array>;
|
|
187
166
|
function embedTexts(values: string[]): Promise<Float32Array[]>;
|
|
167
|
+
function probeEmbeddingDims(options?: {
|
|
168
|
+
timeoutMs?: number;
|
|
169
|
+
}): Promise<number | undefined>;
|
|
170
|
+
function generateGraph(chunks: string[], options?: {
|
|
171
|
+
graphLlm?: LanguageModelRef;
|
|
172
|
+
}): Promise<{
|
|
173
|
+
entities: ExtractedEntity[];
|
|
174
|
+
relations: ExtractedRelation[];
|
|
175
|
+
summary: string;
|
|
176
|
+
}>;
|
|
188
177
|
const embed: typeof embedText;
|
|
189
178
|
const embedMany: typeof embedTexts;
|
|
190
179
|
}
|
|
@@ -198,7 +187,6 @@ interface MemoryServiceContext {
|
|
|
198
187
|
config?: MemoryKnowledgeConfigWithModels;
|
|
199
188
|
agentId?: string;
|
|
200
189
|
}
|
|
201
|
-
type ErrorCode = 'AGENT_ID_REQUIRED' | 'SESSION_ID_REQUIRED' | 'CONTENT_REQUIRED' | 'INTERNAL' | 'NOT_FOUND' | 'AMBIGUOUS' | 'NOT_INDEXED' | 'OPTIONAL_DEP_MISSING' | 'TRUST_DENIED' | 'PATH_TRAVERSAL' | 'CATEGORY_REQUIRED' | 'IMPORTANCE_REQUIRED' | 'TIMERANGE_REQUIRED' | 'INGEST_FAILED' | 'UNSUPPORTED_FORMAT' | 'HAS_REFERENCES' | 'DRY_RUN_NO_DELETE' | 'MAX_DELETE_EXCEEDED' | 'JOB_NOT_FOUND' | 'JOB_TIMEOUT' | 'JOB_FAILED';
|
|
202
190
|
type KGScope = 'agent_only' | 'shared_only' | 'both';
|
|
203
191
|
interface RecallParams {
|
|
204
192
|
query: string;
|
|
@@ -212,6 +200,7 @@ interface RecallParams {
|
|
|
212
200
|
maxDepth?: number;
|
|
213
201
|
maxEdgesPerNode?: number;
|
|
214
202
|
includeShared?: boolean;
|
|
203
|
+
snippetMaxChars?: number;
|
|
215
204
|
}
|
|
216
205
|
interface RecallResult {
|
|
217
206
|
hits: MemoryRecallResult[];
|
|
@@ -369,7 +358,6 @@ interface DoctorResult extends KnowledgeDoctorResult {
|
|
|
369
358
|
}
|
|
370
359
|
interface InitParams {
|
|
371
360
|
dbPath?: string;
|
|
372
|
-
workspaceDir?: string;
|
|
373
361
|
archiveDays?: number;
|
|
374
362
|
force?: boolean;
|
|
375
363
|
}
|
|
@@ -537,10 +525,7 @@ declare function getInstance(): IInstance;
|
|
|
537
525
|
declare function getHomeDir(): string;
|
|
538
526
|
declare function getXdgData(): string;
|
|
539
527
|
declare function getMemoryDir(): string;
|
|
540
|
-
declare function getMemoryDbPath(
|
|
541
|
-
dir?: string;
|
|
542
|
-
workspaceDir?: string;
|
|
543
|
-
}): string;
|
|
528
|
+
declare function getMemoryDbPath(workspaceDir: string): string;
|
|
544
529
|
|
|
545
530
|
type MigrationDb = SyncSqliteConnection;
|
|
546
531
|
declare const LATEST_SCHEMA_VERSION = 1;
|
|
@@ -631,34 +616,21 @@ declare class GraphStore {
|
|
|
631
616
|
}): Promise<MemoryNodeWithEdges[]>;
|
|
632
617
|
}
|
|
633
618
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
}
|
|
650
|
-
type HookHandler = (ctx: HookContext) => Promise<HookResult>;
|
|
651
|
-
interface RegisteredHook {
|
|
652
|
-
name: HookName;
|
|
653
|
-
handler: HookHandler;
|
|
654
|
-
registeredAt: string;
|
|
619
|
+
declare const MEMORY_JSON_REL_PATH: readonly [".easbot", "memory.json"];
|
|
620
|
+
type StateResult = {
|
|
621
|
+
memoryJson: MemoryJson | undefined;
|
|
622
|
+
exists: boolean;
|
|
623
|
+
rootDir: string;
|
|
624
|
+
};
|
|
625
|
+
declare namespace MemoryCache {
|
|
626
|
+
function state(): Promise<StateResult>;
|
|
627
|
+
function resetState(writtenPath?: string): void;
|
|
628
|
+
function init(): Promise<void>;
|
|
629
|
+
function getMemoryJson(): Promise<MemoryJson | undefined>;
|
|
630
|
+
function exists(): Promise<boolean>;
|
|
631
|
+
function getRootDir(): Promise<string>;
|
|
632
|
+
function writeMemoryJson(partial: Partial<MemoryJson>): Promise<MemoryJson>;
|
|
633
|
+
function getConfigPath(): Promise<string>;
|
|
655
634
|
}
|
|
656
635
|
|
|
657
|
-
|
|
658
|
-
declare function unregisterHook(name: HookName): boolean;
|
|
659
|
-
declare function listHooks(): readonly RegisteredHook[];
|
|
660
|
-
declare function registerAllDefaultHooks(): void;
|
|
661
|
-
declare function clearAllHooks(): void;
|
|
662
|
-
declare function dispatchHook(name: HookName, ctx: HookContext): Promise<HookResult>;
|
|
663
|
-
|
|
664
|
-
export { ALL_OPS, type ArchiveRecord, type ArchiveResult, COMMANDS_HELP, type CommandHelp, type ConsolidateParams, type ConsolidateResult, type DoctorResult, type EdgeQueryFilter, type ErrorCode, 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, MIGRATIONS, type MemoryCategory, type MemoryCliDeps, type MemoryCliResult, MemoryDatabaseError, MemoryDatabaseManager, type MemoryEdge, MemoryEmbeddingError, MemoryError, MemoryErrorCode, type MemoryFact, MemoryFileError, 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 };
|
|
636
|
+
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_JSON_REL_PATH, MIGRATIONS, MemoryCache, type MemoryCategory, type MemoryCliDeps, type MemoryCliResult, MemoryDatabaseManager, type MemoryEdge, type MemoryFact, type MemoryJson, MemoryJsonSchema, type MemoryNode, type MemoryNodeWithEdges, type MemoryOp, type MemoryQuery, type MemoryRecallResult, type MemorySource, MemoryStdioServer, type MemorySystemConfig, 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, 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.mjs
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import'./chunks/chunk-QF5S5MG7.mjs';export{a as COMMANDS_HELP,d as handleMemoryCli,b as renderBanner,c as renderHelp}from'./chunks/chunk-
|
|
2
|
-
${n.join(`
|
|
3
|
-
`)}`,logLine:`session-start: injected ${t.hits.length} facts into context (agent=${e.agentId})`}}catch(t){return {ok:false,error:t instanceof Error?t.message:String(t)}}};var Ee=3600*1e3,Y=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:Ee,o=e.extras?.fromTime??new Date(Date.now()-r).toISOString();try{let t=await z$1("consolidate",{fromTime:o},u(e.agentId));return {ok:!0,logLine:`session-end: lookback=${r}ms, total=${t.totalFacts}, deduped=${t.dedupedCount}, archived=${t.archivedCount}, skipped=${t.skippedCount}`}}catch(t){return {ok:false,error:t instanceof Error?t.message:String(t)}}};var B=async e=>{if(!e.agentId?.trim())return {ok:false,error:"pre-compact: agentId is required in ctx"};let o=(e.contextPreview??e.messagePreview??"").slice(0,200).replace(/\s+/g," ").trim(),t=e.extras?.topK??3;if(!o)return {ok:true,injected:"",logLine:"pre-compact: empty contextPreview; skipping recall injection"};try{let n=await z$1("recall",{query:o,maxResults:t,minImportance:5},u(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(i=>`- [${i.category}/imp=${i.importance}] ${i.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:n instanceof Error?n.message:String(n)}}};var G=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=createHash("sha256").update(`${e.toolName}:${e.error}`).digest("hex").slice(0,8),o=e.messagePreview?e.messagePreview.slice(0,200).replace(/\s+/g," ").trim():"",t=[`[error_pattern] tool=${e.toolName}`,`[error] ${e.error}`,o?`[preview] ${o}`:"",`[errHash] ${r}`].filter(Boolean).join(`
|
|
6
|
-
`);try{return {ok:!0,logLine:`post-tool-failure: wrote error_pattern fact ${(await z$1("remember",{content:t,category:"error_pattern",importance:6,tags:["post-tool-failure",`tool:${e.toolName}`,`err:${r}`],sessionId:e.sessionId,msgId:e.extras?.msgId},u(e.agentId))).fact.id} (tool=${e.toolName}, errHash=${r})`}}catch(n){return {ok:false,error:n instanceof Error?n.message:String(n)}}};var g=Log.create({service:"memory.hooks"}),f=new Map;function y(e,r){let o={name:e,handler:r,registeredAt:new Date().toISOString()},t=f.get(e);f.set(e,o),t?g.info("Hook overwritten",{name:e,prevRegisteredAt:t.registeredAt,newRegisteredAt:o.registeredAt}):g.info("Hook registered",{name:e,registeredAt:o.registeredAt});}function Me(e){return f.delete(e)}function _e(){return Array.from(f.values()).map(e=>({name:e.name,handler:e.handler,registeredAt:e.registeredAt}))}function Se(){y("session-start",z),y("session-end",Y),y("pre-compact",B),y("post-tool-failure",G);}function Oe(){f.clear(),g.debug("All hooks cleared");}async function Ae(e,r){let o=f.get(e);if(!o)return g.debug("dispatchHook: no handler registered; noop",{name:e}),{ok:true,logLine:`hook ${e} not registered; noop`};try{let t=await o.handler(r);return t.ok?t.logLine&&g.debug("dispatchHook: ok",{name:e,logLine:t.logLine}):g.warn("dispatchHook: handler returned failure",{name:e,agentId:r.agentId,error:t.error}),t}catch(t){let n=t instanceof Error?t.message:String(t);return g.warn("dispatchHook: handler threw, caught and converted to failure result",{name:e,agentId:r.agentId,error:n}),{ok:false,error:n}}}export{we as MEMORY_CATEGORIES,F as MemoryDatabaseError,j as MemoryEmbeddingError,d as MemoryError,ge as MemoryErrorCode,L as MemoryFileError,T as MemoryNotFoundError,v as MemoryPermissionError,$ as MemorySearchError,D as MemoryValidationError,je as addWord,Oe as clearAllHooks,Ye as closeTokenizer,Ae as dispatchHook,$e as initTokenizer,ze as isInitialized,_e as listHooks,xe as loadCustomDict,Se as registerAllDefaultHooks,y as registerHook,Be as toFtsTokens,Ge as toFtsTokensForSearch,He as tokenize,he as tokenizeForSearch,Me as unregisterHook};
|
|
1
|
+
export{b as MemoryStdioServer,a as renderOperationMarkdown}from'./chunks/chunk-FZ3RTYIJ.mjs';import'./chunks/chunk-QF5S5MG7.mjs';export{a as COMMANDS_HELP,d as handleMemoryCli,b as renderBanner,c as renderHelp}from'./chunks/chunk-YUWHNHAY.mjs';export{y as ALL_OPS,a as GraphStore,x as OP_REGISTRY,r as consolidate,v as doctor,z as executeOp,q as extract,p as forget,t as graphQuery,w as init,b as recall,n as remember,u as status,s as sync,o as update}from'./chunks/chunk-AEAMQDNV.mjs';export{a as LATEST_SCHEMA_VERSION,b as MIGRATIONS,e as MemoryDatabaseManager,d as readCurrentSchemaVersion,c as runMigrations}from'./chunks/chunk-YJLHS7JB.mjs';export{a as Llm}from'./chunks/chunk-HH7EA2UE.mjs';import {a}from'./chunks/chunk-AJDMZTCQ.mjs';export{b as DEFAULT_MEMORY_JSON,c as MEMORY_JSON_REL_PATH,d as MemoryCache,a as MemoryJsonSchema}from'./chunks/chunk-SE3F5YQE.mjs';export{c as getGlobal,g as getHomeDir,f as getInstance,j as getMemoryDbPath,i as getMemoryDir,h as getXdgData,b as resetGlobalAdapter,e as resetInstanceAdapter,a as setGlobalAdapter,d as setInstanceAdapter}from'./chunks/chunk-HX3TV7FD.mjs';import'./chunks/chunk-S4DPVKMV.mjs';export{GRAPH_ENTITY_TYPE_DEFINITIONS,GRAPH_RELATION_TYPE_DEFINITIONS}from'@easbot/types';import*as n from'jieba-wasm';import {Log,loadTextFile,errorMeta,Filesystem}from'@easbot/utils';var ie=["user_preference","task_context","technical_fact","decision","relationship","reminder","error_pattern","workflow","exploration_finding","experience_summary","tool_usage","skill_creation","test","other"];var t=Log.create({service:"memory.tokenizer"}),o=false,re=loadTextFile("./assets/jieba_dict.txt",import.meta.url);async function ge(e){if(!o)try{t.debug("Initializing jieba tokenizer");let r=re();if(n.with_dict(r),t.debug("Built-in dictionary loaded"),e?.dictPath&&e.dictPath.length>0)for(let a of e.dictPath)await te(a);o=!0,t.debug("Jieba tokenizer initialized successfully");}catch(r){t.error("Failed to initialize jieba tokenizer",{error:errorMeta(r)}),t.warn("Using fallback tokenization (space-based)");}}async function te(e){if(!o)throw new a.TokenizerNotInitializedError({message:"Tokenizer not initialized"});try{let r=await Filesystem.readText(e);t.debug("Loading custom dictionary",{dictPath:e}),n.with_dict(r),t.debug("Custom dictionary loaded successfully",{dictPath:e});}catch(r){t.warn("Failed to load custom dictionary",{dictPath:e,error:errorMeta(r)});}}function oe(e){if(!o)return e.split(/\s+/).filter(Boolean);try{return n.cut(e)}catch(r){return t.warn("Tokenization failed, using fallback",{error:errorMeta(r)}),e.split(/\s+/).filter(Boolean)}}function ne(e){if(!o)return e.split(/\s+/).filter(Boolean);try{return n.cut_for_search(e)}catch(r){return t.warn("Tokenization for search failed, using fallback",{error:errorMeta(r)}),e.split(/\s+/).filter(Boolean)}}function ye(e,r,a){if(o)try{n.add_word(e,r,a),t.debug("Word added to dictionary",{word:e,freq:r,tag:a});}catch(_){t.warn("Failed to add word",{word:e,error:errorMeta(_)});}}function fe(){return o}async function xe(){o=false,t.debug("Tokenizer closed");}function Me(e){if(!o)return e.split(/\s+/).filter(Boolean).join(" ");try{return oe(e).join(" ")}catch(r){return t.warn("Tokenization failed, using fallback",{error:errorMeta(r)}),e.split(/\s+/).filter(Boolean).join(" ")}}function be(e){if(!o)return e.split(/\s+/).filter(Boolean).join(" ");try{return ne(e).join(" ")}catch(r){return t.warn("Tokenization for search failed, using fallback",{error:errorMeta(r)}),e.split(/\s+/).filter(Boolean).join(" ")}}export{ie as MEMORY_CATEGORIES,ye as addWord,xe as closeTokenizer,ge as initTokenizer,fe as isInitialized,te as loadCustomDict,Me as toFtsTokens,be as toFtsTokensForSearch,oe as tokenize,ne as tokenizeForSearch};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easbot/memory",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.32",
|
|
4
4
|
"description": "Memory management library for EASBOT ecosystem - 智能记忆管理库,支持混合搜索、中英文分词、增量索引",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -53,15 +53,14 @@
|
|
|
53
53
|
"ai": "^6.0.253",
|
|
54
54
|
"better-sqlite3": "^13.0.3",
|
|
55
55
|
"jieba-wasm": "^2.4.0",
|
|
56
|
-
"
|
|
57
|
-
"@easbot/
|
|
58
|
-
"@easbot/
|
|
59
|
-
"@easbot/terminal": "0.3.
|
|
60
|
-
"@easbot/
|
|
61
|
-
"@easbot/
|
|
62
|
-
"@easbot/local-model-sdk": "0.3.
|
|
63
|
-
"@easbot/
|
|
64
|
-
"@easbot/ollama-sdk": "0.3.28"
|
|
56
|
+
"@easbot/database": "0.3.32",
|
|
57
|
+
"@easbot/mcp": "0.3.32",
|
|
58
|
+
"@easbot/types": "0.3.32",
|
|
59
|
+
"@easbot/terminal": "0.3.32",
|
|
60
|
+
"@easbot/utils": "0.3.32",
|
|
61
|
+
"@easbot/llm": "0.3.32",
|
|
62
|
+
"@easbot/local-model-sdk": "0.3.32",
|
|
63
|
+
"@easbot/ollama-sdk": "0.3.32"
|
|
65
64
|
},
|
|
66
65
|
"devDependencies": {
|
|
67
66
|
"@types/node": "^25.9.5",
|