@easbot/memory 0.3.16 → 0.3.17
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 +99 -19
- package/README.md +99 -19
- package/dist/chunks/chunk-BSKFK4RC.mjs +1 -0
- package/dist/chunks/chunk-CPRDIUQ4.cjs +1 -0
- package/dist/chunks/{chunk-5W4K5UKV.mjs → chunk-DFWC6WII.mjs} +3 -3
- package/dist/chunks/chunk-DXU5WPK3.cjs +42 -0
- package/dist/chunks/chunk-EECBJNZI.mjs +59 -0
- package/dist/chunks/chunk-FMEXQ5YE.cjs +59 -0
- package/dist/chunks/chunk-HQBRVVXS.mjs +1 -0
- package/dist/chunks/chunk-HSK27DQ7.cjs +1 -0
- package/dist/chunks/chunk-I6XVFDN2.mjs +42 -0
- package/dist/chunks/{chunk-FNT7WEHL.mjs → chunk-MWRDF6VN.mjs} +1 -1
- package/dist/chunks/chunk-NVGACA7W.cjs +1 -0
- package/dist/chunks/{chunk-Q2MKNRER.cjs → chunk-OIUUTVLL.cjs} +3 -3
- package/dist/chunks/{chunk-NJVXQ7TV.cjs → chunk-QNDG7BTB.cjs} +1 -1
- package/dist/chunks/chunk-RSJ2KT6X.cjs +1 -0
- package/dist/chunks/{chunk-FEMOFIOS.mjs → chunk-TPSRK4M3.mjs} +1 -1
- package/dist/chunks/{chunk-YHOJKRHE.mjs → chunk-WDVDYZ25.mjs} +1 -1
- package/dist/chunks/cli-handler-6VTKYXXM.mjs +1 -0
- package/dist/chunks/cli-handler-HNPA3STD.cjs +1 -0
- package/dist/chunks/{config-M2KZYVRZ.mjs → config-2SQJYVTO.mjs} +1 -1
- package/dist/chunks/{config-BFJFRX2C.cjs → config-RPPQ73HK.cjs} +1 -1
- package/dist/chunks/consolidate-6P7LUPPL.cjs +2 -0
- package/dist/chunks/consolidate-NYH4IKJK.mjs +2 -0
- package/dist/chunks/doctor-IJJ5UYGT.cjs +2 -0
- package/dist/chunks/doctor-MZSZGVRL.mjs +2 -0
- package/dist/chunks/extract-6B7OD3VK.mjs +2 -0
- package/dist/chunks/extract-ERTOHQV6.cjs +2 -0
- package/dist/chunks/forget-A4UJI3LE.mjs +3 -0
- package/dist/chunks/forget-KLFM5SBQ.cjs +3 -0
- package/dist/chunks/graph-P5ZHB4ZM.cjs +3 -0
- package/dist/chunks/graph-XZ46LEO7.mjs +3 -0
- package/dist/chunks/init-CCOSHE3F.cjs +3 -0
- package/dist/chunks/init-WEPU32KF.mjs +3 -0
- package/dist/chunks/{interfaces-VBO3Z6QF.mjs → interfaces-LPJU4KS3.mjs} +1 -1
- package/dist/chunks/interfaces-XWE45ENK.cjs +1 -0
- package/dist/chunks/mcp-BOD4ZOZS.mjs +1 -0
- package/dist/chunks/mcp-BXVXTUJK.cjs +1 -0
- package/dist/chunks/recall-BV4Z7HUJ.mjs +2 -0
- package/dist/chunks/recall-FEINUJKO.cjs +2 -0
- package/dist/chunks/remember-ESVRA73C.mjs +2 -0
- package/dist/chunks/remember-YNSY2JJB.cjs +2 -0
- package/dist/chunks/status-KVM7I6YC.cjs +2 -0
- package/dist/chunks/status-QQZS3ZCN.mjs +2 -0
- package/dist/chunks/stdio-server-MQKTUGNG.cjs +1 -0
- package/dist/chunks/stdio-server-ZLMSUTC5.mjs +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +56 -7
- package/dist/index.d.ts +56 -7
- package/dist/index.mjs +3 -3
- package/package.json +9 -9
- package/dist/chunks/chunk-3HTZTI7U.cjs +0 -1
- package/dist/chunks/chunk-7XEOH55R.cjs +0 -1
- package/dist/chunks/chunk-BWPPLYIF.cjs +0 -1
- package/dist/chunks/chunk-I5YWAJHW.cjs +0 -32
- package/dist/chunks/chunk-JGXW3E73.mjs +0 -59
- package/dist/chunks/chunk-MQ72K25M.cjs +0 -59
- package/dist/chunks/chunk-OWLFPNZG.cjs +0 -1
- package/dist/chunks/chunk-PWLSQFYA.mjs +0 -32
- package/dist/chunks/chunk-WQGSYA5D.mjs +0 -1
- package/dist/chunks/chunk-Z3NQERNT.mjs +0 -1
- package/dist/chunks/cli-handler-57MKQCNO.cjs +0 -1
- package/dist/chunks/cli-handler-WW3I2YV4.mjs +0 -1
- package/dist/chunks/consolidate-YQ3H643L.cjs +0 -2
- package/dist/chunks/consolidate-ZCFRYIWV.mjs +0 -2
- package/dist/chunks/doctor-GVSMK4HL.cjs +0 -2
- package/dist/chunks/doctor-SPJ64FW3.mjs +0 -2
- package/dist/chunks/extract-5VSCY754.mjs +0 -2
- package/dist/chunks/extract-E54PPHMQ.cjs +0 -2
- package/dist/chunks/forget-AALO5DL5.mjs +0 -3
- package/dist/chunks/forget-GEAEUNRH.cjs +0 -3
- package/dist/chunks/graph-HSYCZI7R.mjs +0 -3
- package/dist/chunks/graph-QEGKUROQ.cjs +0 -3
- package/dist/chunks/init-2GZLH6RB.cjs +0 -2
- package/dist/chunks/init-U7XRD4MW.mjs +0 -2
- package/dist/chunks/interfaces-KNVKCV3Q.cjs +0 -1
- package/dist/chunks/mcp-WE7TV32J.cjs +0 -1
- package/dist/chunks/mcp-XPTJOCQA.mjs +0 -1
- package/dist/chunks/recall-JI2NYDLH.cjs +0 -2
- package/dist/chunks/recall-M6SAHHZX.mjs +0 -2
- package/dist/chunks/remember-FR5QGXFT.mjs +0 -2
- package/dist/chunks/remember-X33PMYA5.cjs +0 -2
- package/dist/chunks/status-6XW6Q3TT.mjs +0 -2
- package/dist/chunks/status-CPB6XZNU.cjs +0 -2
- package/dist/chunks/stdio-server-5LE3HFKN.mjs +0 -1
- package/dist/chunks/stdio-server-6PUOFDLR.cjs +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {a,b,c}from'./chunk-MWRDF6VN.mjs';import'./chunk-BSKFK4RC.mjs';import {u,w}from'./chunk-I6XVFDN2.mjs';import'./chunk-DFWC6WII.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-HQBRVVXS.mjs';async function p(n){let e=n.agentId?.trim()||"default",t=n.workspaceDir??process.cwd();return u("forget",{factId:n.factId,category:n.category,fromTime:n.fromTime,toTime:n.toTime,maxDelete:n.maxDelete??1e3,dryRun:n.dryRun??false},w(e,t))}function y(n){let e=n,t=[];if(e.deletedCount===0&&e.deletedIds.length===0)return t.push(a("forget","(no records to delete)")),t.join(`
|
|
2
|
+
`);t.push(b("forget",{deletedCount:e.deletedCount,dryRun:String(e.dryRun)},e.dryRun?"[DRY RUN] Would delete {{deletedCount}}":"Deleted {{deletedCount}}")),e.truncatedCount>0&&t.push(`(truncated: ${e.truncatedCount} more)`);for(let r of e.deletedIds)t.push(c("forget",{id:r}," - {{id}}"));return t.join(`
|
|
3
|
+
`)}function x(n){let e={};for(let t=0;t<n.length;t++){let r=n[t];if(r===void 0)continue;let o=n[t+1];r==="--agent"?(e.agentId=o,t++):r==="--fact-id"?(e.factId=o,t++):r==="--category"?(e.category=o,t++):r==="--from"?(e.fromTime=o,t++):r==="--to"?(e.toTime=o,t++):r==="--max-delete"?(e.maxDelete=Number(o),t++):r==="--dry-run"?e.dryRun=true:r==="--json"?e.json=true:(r==="--help"||r==="-h")&&(e.help=true);}return e}export{y as formatForgetText,x as parseForgetOptions,p as runForget};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var chunkHSK27DQ7_cjs=require('./chunk-HSK27DQ7.cjs');require('./chunk-RSJ2KT6X.cjs');var chunkDXU5WPK3_cjs=require('./chunk-DXU5WPK3.cjs');require('./chunk-OIUUTVLL.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-NVGACA7W.cjs');async function g(n){let e=n.agentId?.trim()||"default",t=n.workspaceDir??process.cwd();return chunkDXU5WPK3_cjs.u("forget",{factId:n.factId,category:n.category,fromTime:n.fromTime,toTime:n.toTime,maxDelete:n.maxDelete??1e3,dryRun:n.dryRun??false},chunkDXU5WPK3_cjs.w(e,t))}function p(n){let e=n,t=[];if(e.deletedCount===0&&e.deletedIds.length===0)return t.push(chunkHSK27DQ7_cjs.a("forget","(no records to delete)")),t.join(`
|
|
2
|
+
`);t.push(chunkHSK27DQ7_cjs.b("forget",{deletedCount:e.deletedCount,dryRun:String(e.dryRun)},e.dryRun?"[DRY RUN] Would delete {{deletedCount}}":"Deleted {{deletedCount}}")),e.truncatedCount>0&&t.push(`(truncated: ${e.truncatedCount} more)`);for(let r of e.deletedIds)t.push(chunkHSK27DQ7_cjs.c("forget",{id:r}," - {{id}}"));return t.join(`
|
|
3
|
+
`)}function y(n){let e={};for(let t=0;t<n.length;t++){let r=n[t];if(r===void 0)continue;let o=n[t+1];r==="--agent"?(e.agentId=o,t++):r==="--fact-id"?(e.factId=o,t++):r==="--category"?(e.category=o,t++):r==="--from"?(e.fromTime=o,t++):r==="--to"?(e.toTime=o,t++):r==="--max-delete"?(e.maxDelete=Number(o),t++):r==="--dry-run"?e.dryRun=true:r==="--json"?e.json=true:(r==="--help"||r==="-h")&&(e.help=true);}return e}exports.formatForgetText=p;exports.parseForgetOptions=y;exports.runForget=g;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var chunkHSK27DQ7_cjs=require('./chunk-HSK27DQ7.cjs');require('./chunk-RSJ2KT6X.cjs');var chunkDXU5WPK3_cjs=require('./chunk-DXU5WPK3.cjs');require('./chunk-OIUUTVLL.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-NVGACA7W.cjs');async function l(t){let r=t.agentId?.trim()||"default",n=t.workspaceDir??process.cwd();return chunkDXU5WPK3_cjs.u("graph_query",{kind:t.kind??"nodes",query:t.query,startNodeId:t.startNodeId,depth:t.depth,maxNodes:t.maxNodes,scope:t.scope??"agent_only"},chunkDXU5WPK3_cjs.w(r,n))}function c(t){let r=t,n=[chunkHSK27DQ7_cjs.b("graph",{totalNodes:r.totalNodes??r.nodes.length},"KG query (scope={{scope}}, {{totalNodes}} node(s)):")];if(r.nodes.length===0)return n.push(chunkHSK27DQ7_cjs.a("graph","(no nodes matched)")),n.join(`
|
|
2
|
+
`);n.push(`nodes (${r.nodes.length}):`);for(let e of r.nodes){e.ownerAgentId?` [owner=${e.ownerAgentId}]`:" [shared]";n.push(chunkHSK27DQ7_cjs.c("graph",{id:String(e.id),name:e.name,type:e.type}," - #{{id}} {{name}} ({{type}})"));}n.push(`edges (${r.edges.length}):`);for(let e of r.edges)n.push(` - #${e.id} ${e.source} --${e.relation}--> ${e.target}`);return n.join(`
|
|
3
|
+
`)}function f(t){let r={};for(let n=0;n<t.length;n++){let e=t[n];if(e===void 0)continue;let o=t[n+1];e==="--agent"?(r.agentId=o,n++):e==="--kind"?(r.kind=o,n++):e==="--query"?(r.query=o,n++):e==="--start-node"?(r.startNodeId=Number(o),n++):e==="--depth"?(r.depth=Number(o),n++):e==="--max-nodes"?(r.maxNodes=Number(o),n++):e==="--scope"?(r.scope=o,n++):e==="--json"?r.json=true:(e==="--help"||e==="-h")&&(r.help=true);}return r}exports.formatGraphText=c;exports.parseGraphOptions=f;exports.runGraph=l;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {b,a,c as c$1}from'./chunk-MWRDF6VN.mjs';import'./chunk-BSKFK4RC.mjs';import {u,w}from'./chunk-I6XVFDN2.mjs';import'./chunk-DFWC6WII.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-HQBRVVXS.mjs';async function c(t){let r=t.agentId?.trim()||"default",n=t.workspaceDir??process.cwd();return u("graph_query",{kind:t.kind??"nodes",query:t.query,startNodeId:t.startNodeId,depth:t.depth,maxNodes:t.maxNodes,scope:t.scope??"agent_only"},w(r,n))}function f(t){let r=t,n=[b("graph",{totalNodes:r.totalNodes??r.nodes.length},"KG query (scope={{scope}}, {{totalNodes}} node(s)):")];if(r.nodes.length===0)return n.push(a("graph","(no nodes matched)")),n.join(`
|
|
2
|
+
`);n.push(`nodes (${r.nodes.length}):`);for(let e of r.nodes){e.ownerAgentId?` [owner=${e.ownerAgentId}]`:" [shared]";n.push(c$1("graph",{id:String(e.id),name:e.name,type:e.type}," - #{{id}} {{name}} ({{type}})"));}n.push(`edges (${r.edges.length}):`);for(let e of r.edges)n.push(` - #${e.id} ${e.source} --${e.relation}--> ${e.target}`);return n.join(`
|
|
3
|
+
`)}function y(t){let r={};for(let n=0;n<t.length;n++){let e=t[n];if(e===void 0)continue;let o=t[n+1];e==="--agent"?(r.agentId=o,n++):e==="--kind"?(r.kind=o,n++):e==="--query"?(r.query=o,n++):e==="--start-node"?(r.startNodeId=Number(o),n++):e==="--depth"?(r.depth=Number(o),n++):e==="--max-nodes"?(r.maxNodes=Number(o),n++):e==="--scope"?(r.scope=o,n++):e==="--json"?r.json=true:(e==="--help"||e==="-h")&&(r.help=true);}return r}export{f as formatGraphText,y as parseGraphOptions,c as runGraph};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var chunkHSK27DQ7_cjs=require('./chunk-HSK27DQ7.cjs');require('./chunk-RSJ2KT6X.cjs');var chunkDXU5WPK3_cjs=require('./chunk-DXU5WPK3.cjs');require('./chunk-OIUUTVLL.cjs');var chunkCPRDIUQ4_cjs=require('./chunk-CPRDIUQ4.cjs');require('./chunk-NVGACA7W.cjs');async function u(i){if(!i.workspaceDir?.trim())throw new Error("init: --workspace-dir is required");let t=i.agentId??"",e=i.ctxWorkspaceDir??process.cwd();return chunkDXU5WPK3_cjs.u("init",{workspaceDir:i.workspaceDir,dbPath:chunkCPRDIUQ4_cjs.j(e),force:i.force??false},chunkDXU5WPK3_cjs.w(t,e))}function b(i){let t=i;return [chunkHSK27DQ7_cjs.b("init",{},"Initialization complete:"),chunkHSK27DQ7_cjs.c("init",{dbPath:t.dbPath,migrationsApplied:String(t.migrationsApplied),tablesCreated:String(t.tablesCreated),...t.configPath?{configPath:`${t.configPath} (${t.configCreated?"created":"exists"})`}:{}}," - db={{dbPath}}, migrations={{migrationsApplied}}, tables={{tablesCreated}}"+(t.configPath?`
|
|
2
|
+
- config: {{configPath}}`:"")),` - workspace: ${t.workspaceDir}, duration: ${t.durationMs}ms`].join(`
|
|
3
|
+
`)}function h(i){let t={};for(let e=0;e<i.length;e++){let n=i[e];if(n===void 0)continue;let r=i[e+1];n==="--workspace-dir"?(t.workspaceDir=r,e++):n==="--agent"?(t.agentId=r,e++):n==="--force"?t.force=true:n==="--json"?t.json=true:(n==="--help"||n==="-h")&&(t.help=true);}return t}exports.formatInitText=b;exports.parseInitOptions=h;exports.runInit=u;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {b as b$1,c}from'./chunk-MWRDF6VN.mjs';import'./chunk-BSKFK4RC.mjs';import {u,w}from'./chunk-I6XVFDN2.mjs';import'./chunk-DFWC6WII.mjs';import {j}from'./chunk-WDVDYZ25.mjs';import'./chunk-HQBRVVXS.mjs';async function b(i){if(!i.workspaceDir?.trim())throw new Error("init: --workspace-dir is required");let t=i.agentId??"",e=i.ctxWorkspaceDir??process.cwd();return u("init",{workspaceDir:i.workspaceDir,dbPath:j(e),force:i.force??false},w(t,e))}function h(i){let t=i;return [b$1("init",{},"Initialization complete:"),c("init",{dbPath:t.dbPath,migrationsApplied:String(t.migrationsApplied),tablesCreated:String(t.tablesCreated),...t.configPath?{configPath:`${t.configPath} (${t.configCreated?"created":"exists"})`}:{}}," - db={{dbPath}}, migrations={{migrationsApplied}}, tables={{tablesCreated}}"+(t.configPath?`
|
|
2
|
+
- config: {{configPath}}`:"")),` - workspace: ${t.workspaceDir}, duration: ${t.durationMs}ms`].join(`
|
|
3
|
+
`)}function k(i){let t={};for(let e=0;e<i.length;e++){let n=i[e];if(n===void 0)continue;let r=i[e+1];n==="--workspace-dir"?(t.workspaceDir=r,e++):n==="--agent"?(t.agentId=r,e++):n==="--force"?t.force=true:n==="--json"?t.json=true:(n==="--help"||n==="-h")&&(t.help=true);}return t}export{h as formatInitText,k as parseInitOptions,b as runInit};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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'./chunk-
|
|
1
|
+
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'./chunk-WDVDYZ25.mjs';import'./chunk-HQBRVVXS.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkCPRDIUQ4_cjs=require('./chunk-CPRDIUQ4.cjs');require('./chunk-NVGACA7W.cjs');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}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import'./chunk-QF5S5MG7.mjs';import {e}from'./chunk-DFWC6WII.mjs';import {f,j}from'./chunk-WDVDYZ25.mjs';import'./chunk-HQBRVVXS.mjs';import {isAbsolute,join,dirname}from'path';import {readFileSync}from'fs';import {fileURLToPath}from'url';import {ServerTransportType}from'@easbot/mcp';import {Filesystem}from'@easbot/utils';function E(e){let t={},o=[];for(let i=0;i<e.length;i++){let r=e[i];r!==void 0&&(r==="--help"||r==="-h"?t.help=true:r==="--json"?t.json=true:r.startsWith("-")||o.push(r));}return t.dir=o[0],t}async function B(e$1){let t=e$1.dir?isAbsolute(e$1.dir)?e$1.dir:join(f().worktree,e$1.dir):f().worktree,o=j(t),i="0.0.0";try{let n=dirname(fileURLToPath(import.meta.url));for(let s=0;s<8;s++){try{let p=JSON.parse(readFileSync(join(n,"package.json"),"utf-8"));if(p?.name==="@easbot/memory"&&typeof p.version=="string"){i=p.version;break}}catch{}let a=dirname(n);if(a===n||a==="."||s===7)break;n=a;}}catch{}let r={id:"easbot-memory-mcp",name:"EASBot Memory MCP",version:i,transportType:ServerTransportType.STDIO};await Filesystem.mkdir(dirname(o));let f$1=new e(o);await f$1.initialize(),f$1.close();let{MemoryStdioServer:g}=await import('./stdio-server-ZLMSUTC5.mjs'),y=process.env.EASBOT_AGENT_ID?.trim()||"default",h=await g.start(r,{agentId:y,dbPath:o,workspaceDir:t,isRemote:false});return {rootDir:t,tools:h.tools}}export{E as parseMcpOptions,B as runMcp};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';require('./chunk-URADAZYW.cjs');var chunkOIUUTVLL_cjs=require('./chunk-OIUUTVLL.cjs'),chunkCPRDIUQ4_cjs=require('./chunk-CPRDIUQ4.cjs'),chunkNVGACA7W_cjs=require('./chunk-NVGACA7W.cjs'),path=require('path'),fs=require('fs'),url=require('url'),mcp=require('@easbot/mcp'),utils=require('@easbot/utils');function C(r){let t={},o=[];for(let i=0;i<r.length;i++){let e=r[i];e!==void 0&&(e==="--help"||e==="-h"?t.help=true:e==="--json"?t.json=true:e.startsWith("-")||o.push(e));}return t.dir=o[0],t}async function E(r){let t=r.dir?path.isAbsolute(r.dir)?r.dir:path.join(chunkCPRDIUQ4_cjs.f().worktree,r.dir):chunkCPRDIUQ4_cjs.f().worktree,o=chunkCPRDIUQ4_cjs.j(t),i="0.0.0";try{let n=path.dirname(url.fileURLToPath(chunkNVGACA7W_cjs.b));for(let s=0;s<8;s++){try{let p=JSON.parse(fs.readFileSync(path.join(n,"package.json"),"utf-8"));if(p?.name==="@easbot/memory"&&typeof p.version=="string"){i=p.version;break}}catch{}let a=path.dirname(n);if(a===n||a==="."||s===7)break;n=a;}}catch{}let e={id:"easbot-memory-mcp",name:"EASBot Memory MCP",version:i,transportType:mcp.ServerTransportType.STDIO};await utils.Filesystem.mkdir(path.dirname(o));let f=new chunkOIUUTVLL_cjs.e(o);await f.initialize(),f.close();let{MemoryStdioServer:y}=await import('./stdio-server-MQKTUGNG.cjs'),h=process.env.EASBOT_AGENT_ID?.trim()||"default",M=await y.start(e,{agentId:h,dbPath:o,workspaceDir:t,isRemote:false});return {rootDir:t,tools:M.tools}}exports.parseMcpOptions=C;exports.runMcp=E;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a}from'./chunk-BSKFK4RC.mjs';import {u,w}from'./chunk-I6XVFDN2.mjs';import'./chunk-DFWC6WII.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-HQBRVVXS.mjs';async function f(n){if(!n.query?.trim())throw new Error("recall: --query is required");let e=n.agentId?.trim()||"default",t=n.workspaceDir??process.cwd();return u("recall",{query:n.query,maxResults:n.limit??10,category:n.category,minImportance:n.minImportance},w(e,t))}function g(n){let e=n;if(e.total===0)return a("memory.recall.empty",{fallback:"(no facts)"});let t=[a("memory.recall.summary",{vars:{total:e.total},fallback:`Found ${e.total} fact(s):`})];for(let r of e.hits)t.push(a("memory.recall.item",{vars:{id:r.memoryId,category:r.category,importance:String(r.importance),score:r.score.toFixed(3),content:r.snippet},fallback:" - {{id}} [{{category}}/imp={{importance}}/score={{score}}] {{content}}"}));return t.join(`
|
|
2
|
+
`)}function y(n){let e={};for(let t=0;t<n.length;t++){let r=n[t];if(r===void 0)continue;let o=n[t+1];r==="--agent"?(e.agentId=o,t++):r==="--query"?(e.query=o,t++):r==="--limit"?(e.limit=Number(o),t++):r==="--category"?(e.category=o,t++):r==="--min-importance"?(e.minImportance=Number(o),t++):r==="--json"?e.json=true:(r==="--help"||r==="-h")&&(e.help=true);}return e}export{g as formatRecallText,y as parseRecallOptions,f as runRecall};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkRSJ2KT6X_cjs=require('./chunk-RSJ2KT6X.cjs'),chunkDXU5WPK3_cjs=require('./chunk-DXU5WPK3.cjs');require('./chunk-OIUUTVLL.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-NVGACA7W.cjs');async function p(n){if(!n.query?.trim())throw new Error("recall: --query is required");let e=n.agentId?.trim()||"default",t=n.workspaceDir??process.cwd();return chunkDXU5WPK3_cjs.u("recall",{query:n.query,maxResults:n.limit??10,category:n.category,minImportance:n.minImportance},chunkDXU5WPK3_cjs.w(e,t))}function f(n){let e=n;if(e.total===0)return chunkRSJ2KT6X_cjs.a("memory.recall.empty",{fallback:"(no facts)"});let t=[chunkRSJ2KT6X_cjs.a("memory.recall.summary",{vars:{total:e.total},fallback:`Found ${e.total} fact(s):`})];for(let r of e.hits)t.push(chunkRSJ2KT6X_cjs.a("memory.recall.item",{vars:{id:r.memoryId,category:r.category,importance:String(r.importance),score:r.score.toFixed(3),content:r.snippet},fallback:" - {{id}} [{{category}}/imp={{importance}}/score={{score}}] {{content}}"}));return t.join(`
|
|
2
|
+
`)}function g(n){let e={};for(let t=0;t<n.length;t++){let r=n[t];if(r===void 0)continue;let o=n[t+1];r==="--agent"?(e.agentId=o,t++):r==="--query"?(e.query=o,t++):r==="--limit"?(e.limit=Number(o),t++):r==="--category"?(e.category=o,t++):r==="--min-importance"?(e.minImportance=Number(o),t++):r==="--json"?e.json=true:(r==="--help"||r==="-h")&&(e.help=true);}return e}exports.formatRecallText=f;exports.parseRecallOptions=g;exports.runRecall=p;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b as b$1,c}from'./chunk-MWRDF6VN.mjs';import'./chunk-BSKFK4RC.mjs';import {u,w}from'./chunk-I6XVFDN2.mjs';import'./chunk-DFWC6WII.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-HQBRVVXS.mjs';async function p(r){if(!r.content?.trim())throw new Error("remember: --content is required");if(!r.category?.trim())throw new Error("remember: --category is required");if(r.importance===void 0)throw new Error("remember: --importance is required (1-10)");let e=r.agentId?.trim()||"default",t=r.workspaceDir??process.cwd();return u("remember",{content:r.content,category:r.category,importance:r.importance,tags:r.tags,sessionId:r.sessionId},w(e,t))}function l(r){let e=r,t=[b$1("remember",{},"Memory persisted:"),c("remember",{id:e.fact.id,category:e.fact.category,importance:String(e.fact.importance??5)}," - id={{id}} category={{category}} importance={{importance}}"),` - createdAt: ${e.fact.createdAt}`];return e.deduplicated&&t.push(" - (deduplicated; no new fact inserted)"),t.join(`
|
|
2
|
+
`)}function b(r){let e={};for(let t=0;t<r.length;t++){let i=r[t];if(i===void 0)continue;let n=r[t+1];i==="--agent"&&n!==void 0?(e.agentId=n,t++):i==="--content"&&n!==void 0?(e.content=n,t++):i==="--category"&&n!==void 0?(e.category=n,t++):i==="--importance"&&n!==void 0?(e.importance=Number(n),t++):i==="--tag"&&n!==void 0?(e.tags=[...e.tags??[],n],t++):i==="--session"&&n!==void 0?(e.sessionId=n,t++):i==="--json"?e.json=true:(i==="--help"||i==="-h")&&(e.help=true);}return e}export{l as formatRememberText,b as parseRememberOptions,p as runRemember};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkHSK27DQ7_cjs=require('./chunk-HSK27DQ7.cjs');require('./chunk-RSJ2KT6X.cjs');var chunkDXU5WPK3_cjs=require('./chunk-DXU5WPK3.cjs');require('./chunk-OIUUTVLL.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-NVGACA7W.cjs');async function u(r){if(!r.content?.trim())throw new Error("remember: --content is required");if(!r.category?.trim())throw new Error("remember: --category is required");if(r.importance===void 0)throw new Error("remember: --importance is required (1-10)");let e=r.agentId?.trim()||"default",t=r.workspaceDir??process.cwd();return chunkDXU5WPK3_cjs.u("remember",{content:r.content,category:r.category,importance:r.importance,tags:r.tags,sessionId:r.sessionId},chunkDXU5WPK3_cjs.w(e,t))}function p(r){let e=r,t=[chunkHSK27DQ7_cjs.b("remember",{},"Memory persisted:"),chunkHSK27DQ7_cjs.c("remember",{id:e.fact.id,category:e.fact.category,importance:String(e.fact.importance??5)}," - id={{id}} category={{category}} importance={{importance}}"),` - createdAt: ${e.fact.createdAt}`];return e.deduplicated&&t.push(" - (deduplicated; no new fact inserted)"),t.join(`
|
|
2
|
+
`)}function l(r){let e={};for(let t=0;t<r.length;t++){let i=r[t];if(i===void 0)continue;let n=r[t+1];i==="--agent"&&n!==void 0?(e.agentId=n,t++):i==="--content"&&n!==void 0?(e.content=n,t++):i==="--category"&&n!==void 0?(e.category=n,t++):i==="--importance"&&n!==void 0?(e.importance=Number(n),t++):i==="--tag"&&n!==void 0?(e.tags=[...e.tags??[],n],t++):i==="--session"&&n!==void 0?(e.sessionId=n,t++):i==="--json"?e.json=true:(i==="--help"||i==="-h")&&(e.help=true);}return e}exports.formatRememberText=p;exports.parseRememberOptions=l;exports.runRemember=u;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkHSK27DQ7_cjs=require('./chunk-HSK27DQ7.cjs');require('./chunk-RSJ2KT6X.cjs');var chunkDXU5WPK3_cjs=require('./chunk-DXU5WPK3.cjs');require('./chunk-OIUUTVLL.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-NVGACA7W.cjs');async function b(n){let t=n.agentId,e=n.workspaceDir??process.cwd();return chunkDXU5WPK3_cjs.u("status",{agentId:t},chunkDXU5WPK3_cjs.w(t,e))}function d(n){let t=n,e=[];e.push(chunkHSK27DQ7_cjs.b("status",{},"Memory status:"));let o=[["dbPath",t.dbPath??""],["workspaceDir",t.workspaceDir??""],["factsCount",String(t.factsCount??0)],["nodesCount",String(t.nodesCount??0)],["edgesCount",String(t.edgesCount??0)],["ftsAvailable",t.ftsAvailable?"yes":"no"],["vectorEnabled",t.vectorEnabled?"yes":"no"],["kgScopeEnabled",t.kgScopeEnabled?"yes":"no"],["healthy",t.healthy?"yes":"no"]];for(let[s,r]of o)e.push(chunkHSK27DQ7_cjs.c("status",{key:s,value:r}," - {{key}}: {{value}}"));e.push(""),e.push(" - factsByCategory:");for(let[s,r]of Object.entries(t.factsByCategory))e.push(chunkHSK27DQ7_cjs.c("status",{key:s,value:String(r)}," - {{key}}: {{value}}"));return e.join(`
|
|
2
|
+
`)}function y(n){let t={};for(let e=0;e<n.length;e++){let o=n[e];if(o===void 0)continue;let s=n[e+1];o==="--agent"?(t.agentId=s,e++):o==="--json"?t.json=true:(o==="--help"||o==="-h")&&(t.help=true);}return t}exports.formatStatusText=d;exports.parseStatusOptions=y;exports.runStatus=b;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b,c}from'./chunk-MWRDF6VN.mjs';import'./chunk-BSKFK4RC.mjs';import {u,w}from'./chunk-I6XVFDN2.mjs';import'./chunk-DFWC6WII.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-HQBRVVXS.mjs';async function d(n){let t=n.agentId,e=n.workspaceDir??process.cwd();return u("status",{agentId:t},w(t,e))}function y(n){let t=n,e=[];e.push(b("status",{},"Memory status:"));let o=[["dbPath",t.dbPath??""],["workspaceDir",t.workspaceDir??""],["factsCount",String(t.factsCount??0)],["nodesCount",String(t.nodesCount??0)],["edgesCount",String(t.edgesCount??0)],["ftsAvailable",t.ftsAvailable?"yes":"no"],["vectorEnabled",t.vectorEnabled?"yes":"no"],["kgScopeEnabled",t.kgScopeEnabled?"yes":"no"],["healthy",t.healthy?"yes":"no"]];for(let[s,r]of o)e.push(c("status",{key:s,value:r}," - {{key}}: {{value}}"));e.push(""),e.push(" - factsByCategory:");for(let[s,r]of Object.entries(t.factsByCategory))e.push(c("status",{key:s,value:String(r)}," - {{key}}: {{value}}"));return e.join(`
|
|
2
|
+
`)}function h(n){let t={};for(let e=0;e<n.length;e++){let o=n[e];if(o===void 0)continue;let s=n[e+1];o==="--agent"?(t.agentId=s,e++):o==="--json"?t.json=true:(o==="--help"||o==="-h")&&(t.help=true);}return t}export{y as formatStatusText,h as parseStatusOptions,d as runStatus};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkFMEXQ5YE_cjs=require('./chunk-FMEXQ5YE.cjs');require('./chunk-DXU5WPK3.cjs'),require('./chunk-OIUUTVLL.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-NVGACA7W.cjs');Object.defineProperty(exports,"MemoryStdioServer",{enumerable:true,get:function(){return chunkFMEXQ5YE_cjs.b}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{b as MemoryStdioServer}from'./chunk-EECBJNZI.mjs';import'./chunk-I6XVFDN2.mjs';import'./chunk-DFWC6WII.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-HQBRVVXS.mjs';
|
package/dist/cli.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';var
|
|
2
|
+
'use strict';var chunkNVGACA7W_cjs=require('./chunks/chunk-NVGACA7W.cjs'),fs=require('fs'),path=require('path'),url=require('url'),terminal=require('@easbot/terminal');var O=path.dirname(url.fileURLToPath(chunkNVGACA7W_cjs.b));function b(){try{let e=path.join(O,"..","package.json");return JSON.parse(fs.readFileSync(e,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var p=new Set(["DEBUG","INFO","WARN","ERROR"]);function E(e){let s={logLevel:"INFO",printLogs:false,debug:false};for(let n=0;n<e.length;n++){let t=e[n];if(t)if(t==="--cwd"&&n+1<e.length){let o=e[n+1];o&&!o.startsWith("-")&&(s.cwd=o,n++);}else if(t.startsWith("--cwd="))s.cwd=t.slice(6);else if(t==="--config"&&n+1<e.length){let o=e[n+1];o&&!o.startsWith("-")&&(s.configPath=o,n++);}else if(t.startsWith("--config="))s.configPath=t.slice(9);else if(t==="--log-level"&&n+1<e.length){let o=e[n+1];if(o&&!o.startsWith("-")){let i=o.toUpperCase();p.has(i)&&(s.logLevel=i,n++);}}else if(t.startsWith("--log-level=")){let o=t.slice(12).toUpperCase();p.has(o)&&(s.logLevel=o);}else t==="--print-logs"?s.printLogs=true:t==="--debug"&&(s.debug=true);}return s}async function G(){let e=process.argv.slice(2),s=b(),{loadEnv:n}=await import('@easbot/utils');n(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let t=E(e),{Log:o}=await import('@easbot/utils'),{getXdgData:i}=await import('./chunks/interfaces-XWE45ENK.cjs'),f=path.join(i(),"memory","log");if(await o.init({logDir:f,print:t.printLogs,dev:t.debug||false,level:t.logLevel}),e.length===0){let{renderBanner:l}=await import('./chunks/cli-handler-HNPA3STD.cjs');l();return}if(e[0]==="--help"||e[0]==="-h"){let{renderHelp:l}=await import('./chunks/cli-handler-HNPA3STD.cjs');l();return}if(e[0]==="--version"||e[0]==="-v"){terminal.printHuman([terminal.formatInfo(s)]);return}let r=t.cwd??process.cwd(),{handleMemoryCli:d}=await import('./chunks/cli-handler-HNPA3STD.cjs'),{setInstanceAdapter:m}=await import('./chunks/interfaces-XWE45ENK.cjs');m({directory:r,worktree:r});let c=await d(e,{version:s,cwd:r});c.code!==0&&(process.exitCode=c.code);}G().catch(e=>{console.error(e),process.exitCode=1;}).finally(async()=>{try{let{Log:e}=await import('@easbot/utils');await e.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 v=dirname(fileURLToPath(import.meta.url));function O(){try{let e=join(v,"..","package.json");return JSON.parse(readFileSync(e,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var a=new Set(["DEBUG","INFO","WARN","ERROR"]);function b(e){let s={logLevel:"INFO",printLogs:false,debug:false};for(let n=0;n<e.length;n++){let t=e[n];if(t)if(t==="--cwd"&&n+1<e.length){let o=e[n+1];o&&!o.startsWith("-")&&(s.cwd=o,n++);}else if(t.startsWith("--cwd="))s.cwd=t.slice(6);else if(t==="--config"&&n+1<e.length){let o=e[n+1];o&&!o.startsWith("-")&&(s.configPath=o,n++);}else if(t.startsWith("--config="))s.configPath=t.slice(9);else if(t==="--log-level"&&n+1<e.length){let o=e[n+1];if(o&&!o.startsWith("-")){let i=o.toUpperCase();a.has(i)&&(s.logLevel=i,n++);}}else if(t.startsWith("--log-level=")){let o=t.slice(12).toUpperCase();a.has(o)&&(s.logLevel=o);}else t==="--print-logs"?s.printLogs=true:t==="--debug"&&(s.debug=true);}return s}async function E(){let e=process.argv.slice(2),s=O(),{loadEnv:n}=await import('@easbot/utils');n(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let t=b(e),{Log:o}=await import('@easbot/utils'),{getXdgData:i}=await import('./chunks/interfaces-
|
|
2
|
+
import {readFileSync}from'fs';import {dirname,join}from'path';import {fileURLToPath}from'url';import {printHuman,formatInfo}from'@easbot/terminal';var v=dirname(fileURLToPath(import.meta.url));function O(){try{let e=join(v,"..","package.json");return JSON.parse(readFileSync(e,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var a=new Set(["DEBUG","INFO","WARN","ERROR"]);function b(e){let s={logLevel:"INFO",printLogs:false,debug:false};for(let n=0;n<e.length;n++){let t=e[n];if(t)if(t==="--cwd"&&n+1<e.length){let o=e[n+1];o&&!o.startsWith("-")&&(s.cwd=o,n++);}else if(t.startsWith("--cwd="))s.cwd=t.slice(6);else if(t==="--config"&&n+1<e.length){let o=e[n+1];o&&!o.startsWith("-")&&(s.configPath=o,n++);}else if(t.startsWith("--config="))s.configPath=t.slice(9);else if(t==="--log-level"&&n+1<e.length){let o=e[n+1];if(o&&!o.startsWith("-")){let i=o.toUpperCase();a.has(i)&&(s.logLevel=i,n++);}}else if(t.startsWith("--log-level=")){let o=t.slice(12).toUpperCase();a.has(o)&&(s.logLevel=o);}else t==="--print-logs"?s.printLogs=true:t==="--debug"&&(s.debug=true);}return s}async function E(){let e=process.argv.slice(2),s=O(),{loadEnv:n}=await import('@easbot/utils');n(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let t=b(e),{Log:o}=await import('@easbot/utils'),{getXdgData:i}=await import('./chunks/interfaces-LPJU4KS3.mjs'),g=join(i(),"memory","log");if(await o.init({logDir:g,print:t.printLogs,dev:t.debug||false,level:t.logLevel}),e.length===0){let{renderBanner:l}=await import('./chunks/cli-handler-6VTKYXXM.mjs');l();return}if(e[0]==="--help"||e[0]==="-h"){let{renderHelp:l}=await import('./chunks/cli-handler-6VTKYXXM.mjs');l();return}if(e[0]==="--version"||e[0]==="-v"){printHuman([formatInfo(s)]);return}let r=t.cwd??process.cwd(),{handleMemoryCli:f}=await import('./chunks/cli-handler-6VTKYXXM.mjs'),{setInstanceAdapter:d}=await import('./chunks/interfaces-LPJU4KS3.mjs');d({directory:r,worktree:r});let c=await f(e,{version:s,cwd:r});c.code!==0&&(process.exitCode=c.code);}E().catch(e=>{console.error(e),process.exitCode=1;}).finally(async()=>{try{let{Log:e}=await import('@easbot/utils');await e.close();}catch{}process.exit(process.exitCode??0);});
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkFMEXQ5YE_cjs=require('./chunks/chunk-FMEXQ5YE.cjs');require('./chunks/chunk-URADAZYW.cjs');var chunkQNDG7BTB_cjs=require('./chunks/chunk-QNDG7BTB.cjs'),chunkDXU5WPK3_cjs=require('./chunks/chunk-DXU5WPK3.cjs'),chunkOIUUTVLL_cjs=require('./chunks/chunk-OIUUTVLL.cjs'),chunkCPRDIUQ4_cjs=require('./chunks/chunk-CPRDIUQ4.cjs'),chunkNVGACA7W_cjs=require('./chunks/chunk-NVGACA7W.cjs'),types=require('@easbot/types'),d=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 d__namespace=/*#__PURE__*/_interopNamespace(d);var _e=["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});chunkNVGACA7W_cjs.a(this,"code",o);chunkNVGACA7W_cjs.a(this,"cause",n);this.name="MemoryError";}},C=class extends p{constructor(r,t){super(r,"MEMORY_VALIDATION_ERROR",t),this.name="MemoryValidationError";}},P=class extends p{constructor(r){super(`Memory not found: ${r}`,"MEMORY_NOT_FOUND"),this.name="MemoryNotFoundError";}},N=class extends p{constructor(r){super(r,"MEMORY_PERMISSION_ERROR"),this.name="MemoryPermissionError";}},D=class extends p{constructor(r,t){super(r,"MEMORY_DATABASE_ERROR",t),this.name="MemoryDatabaseError";}},T=class extends p{constructor(r,t){super(r,"MEMORY_FILE_ERROR",t),this.name="MemoryFileError";}},v=class extends p{constructor(r,t){super(r,"MEMORY_SEARCH_ERROR",t),this.name="MemorySearchError";}},F=class extends p{constructor(r,t){super(r,"MEMORY_EMBEDDING_ERROR",t),this.name="MemoryEmbeddingError";}},de=(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))(de||{});var s=utils.Log.create({service:"memory.tokenizer"}),l=false,fe=utils.loadTextFile("./assets/jieba_dict.txt",chunkNVGACA7W_cjs.b);async function Te(e){if(!l)try{s.debug("Initializing jieba tokenizer");let r=fe();if(d__namespace.with_dict(r),s.debug("Built-in dictionary loaded"),e?.dictPath&&e.dictPath.length>0)for(let t of e.dictPath)await ye(t);l=!0,s.debug("Jieba tokenizer initialized successfully");}catch(r){s.error("Failed to initialize jieba tokenizer",{error:String(r)}),s.warn("Using fallback tokenization (space-based)");}}async function ye(e){if(!l)throw new Error("Tokenizer not initialized");try{let r=await utils.Filesystem.readText(e);s.debug("Loading custom dictionary",{dictPath:e}),d__namespace.with_dict(r),s.debug("Custom dictionary loaded successfully",{dictPath:e});}catch(r){s.warn("Failed to load custom dictionary",{dictPath:e,error:String(r)});}}function Re(e){if(!l)return e.split(/\s+/).filter(Boolean);try{return d__namespace.cut(e)}catch(r){return s.warn("Tokenization failed, using fallback",{error:String(r)}),e.split(/\s+/).filter(Boolean)}}function ke(e){if(!l)return e.split(/\s+/).filter(Boolean);try{return d__namespace.cut_for_search(e)}catch(r){return s.warn("Tokenization for search failed, using fallback",{error:String(r)}),e.split(/\s+/).filter(Boolean)}}function ve(e,r,t){if(l)try{d__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:String(o)});}}function Fe(){return l}async function Le(){l=false,s.debug("Tokenizer closed");}function $e(e){if(!l)return e.split(/\s+/).filter(Boolean).join(" ");try{return Re(e).join(" ")}catch(r){return s.warn("Tokenization failed, using fallback",{error:String(r)}),e.split(/\s+/).filter(Boolean).join(" ")}}function je(e){if(!l)return e.split(/\s+/).filter(Boolean).join(" ");try{return ke(e).join(" ")}catch(r){return s.warn("Tokenization for search failed, using fallback",{error:String(r)}),e.split(/\s+/).filter(Boolean).join(" ")}}function m(e){let r=chunkCPRDIUQ4_cjs.f().worktree,t=chunkCPRDIUQ4_cjs.j(r);return {agentId:e,isTrustedLocal:true,remote:false,locale:"en-US",dbPath:t,workspaceDir:r,rootDir:r,config:chunkDXU5WPK3_cjs.v({agentId:e,dbPath:t,workspaceDir:r})}}var L=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 chunkDXU5WPK3_cjs.u("recall",{query:t,maxResults:r},m(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(y=>`- [${y.category}/imp=${y.importance}] ${y.snippet.slice(0,200)}`);return {ok:!0,injected:`[memory:session-start recall top-${o.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:o instanceof Error?o.message:String(o)}}};var
|
|
3
|
+
`)}`,logLine:`session-start: injected ${o.hits.length} facts into context (agent=${e.agentId})`}}catch(o){return {ok:false,error:o instanceof Error?o.message:String(o)}}};var $=async e=>{if(!e.agentId?.trim())return {ok:false,error:"session-end: agentId is required in ctx"};let r=e.extras?.windowDays??1;try{let t=await chunkDXU5WPK3_cjs.u("consolidate",{windowDays:r},m(e.agentId));return {ok:!0,logLine:`session-end: 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 j=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 chunkDXU5WPK3_cjs.u("recall",{query:t,maxResults:o,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
4
|
${H.join(`
|
|
5
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 z=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
|
|
6
|
+
`);try{return {ok:!0,logLine:`post-tool-failure: wrote error_pattern fact ${(await chunkDXU5WPK3_cjs.u("remember",{content:o,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 t={name:e,handler:r,registeredAt:new Date().toISOString()},o=g.get(e);g.set(e,t),o?u.info("Hook overwritten",{name:e,prevRegisteredAt:o.registeredAt,newRegisteredAt:t.registeredAt}):u.info("Hook registered",{name:e,registeredAt:t.registeredAt});}function he(e){return g.delete(e)}function Ee(){return Array.from(g.values()).map(e=>({name:e.name,handler:e.handler,registeredAt:e.registeredAt}))}function be(){f("session-start",L),f("session-end",$),f("pre-compact",j),f("post-tool-failure",z);}function Ie(){g.clear(),u.debug("All hooks cleared");}async function Me(e,r){let t=g.get(e);if(!t)return u.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&&u.debug("dispatchHook: ok",{name:e,logLine:o.logLine}):u.warn("dispatchHook: handler returned failure",{name:e,agentId:r.agentId,error:o.error}),o}catch(o){let n=o instanceof Error?o.message:String(o);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,"MemoryStdioServer",{enumerable:true,get:function(){return chunkFMEXQ5YE_cjs.b}});Object.defineProperty(exports,"renderOperationMarkdown",{enumerable:true,get:function(){return chunkFMEXQ5YE_cjs.a}});Object.defineProperty(exports,"COMMANDS_HELP",{enumerable:true,get:function(){return chunkQNDG7BTB_cjs.a}});Object.defineProperty(exports,"handleMemoryCli",{enumerable:true,get:function(){return chunkQNDG7BTB_cjs.d}});Object.defineProperty(exports,"renderBanner",{enumerable:true,get:function(){return chunkQNDG7BTB_cjs.b}});Object.defineProperty(exports,"renderHelp",{enumerable:true,get:function(){return chunkQNDG7BTB_cjs.c}});Object.defineProperty(exports,"ALL_OPS",{enumerable:true,get:function(){return chunkDXU5WPK3_cjs.t}});Object.defineProperty(exports,"GraphStore",{enumerable:true,get:function(){return chunkDXU5WPK3_cjs.a}});Object.defineProperty(exports,"Llm",{enumerable:true,get:function(){return chunkDXU5WPK3_cjs.b}});Object.defineProperty(exports,"OP_REGISTRY",{enumerable:true,get:function(){return chunkDXU5WPK3_cjs.s}});Object.defineProperty(exports,"consolidate",{enumerable:true,get:function(){return chunkDXU5WPK3_cjs.n}});Object.defineProperty(exports,"doctor",{enumerable:true,get:function(){return chunkDXU5WPK3_cjs.q}});Object.defineProperty(exports,"executeOp",{enumerable:true,get:function(){return chunkDXU5WPK3_cjs.u}});Object.defineProperty(exports,"extract",{enumerable:true,get:function(){return chunkDXU5WPK3_cjs.m}});Object.defineProperty(exports,"forget",{enumerable:true,get:function(){return chunkDXU5WPK3_cjs.l}});Object.defineProperty(exports,"graphQuery",{enumerable:true,get:function(){return chunkDXU5WPK3_cjs.o}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunkDXU5WPK3_cjs.r}});Object.defineProperty(exports,"recall",{enumerable:true,get:function(){return chunkDXU5WPK3_cjs.c}});Object.defineProperty(exports,"remember",{enumerable:true,get:function(){return chunkDXU5WPK3_cjs.k}});Object.defineProperty(exports,"status",{enumerable:true,get:function(){return chunkDXU5WPK3_cjs.p}});Object.defineProperty(exports,"LATEST_SCHEMA_VERSION",{enumerable:true,get:function(){return chunkOIUUTVLL_cjs.a}});Object.defineProperty(exports,"MIGRATIONS",{enumerable:true,get:function(){return chunkOIUUTVLL_cjs.b}});Object.defineProperty(exports,"MemoryDatabaseManager",{enumerable:true,get:function(){return chunkOIUUTVLL_cjs.e}});Object.defineProperty(exports,"readCurrentSchemaVersion",{enumerable:true,get:function(){return chunkOIUUTVLL_cjs.d}});Object.defineProperty(exports,"runMigrations",{enumerable:true,get:function(){return chunkOIUUTVLL_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,"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=_e;exports.MemoryDatabaseError=D;exports.MemoryEmbeddingError=F;exports.MemoryError=p;exports.MemoryErrorCode=de;exports.MemoryFileError=T;exports.MemoryNotFoundError=P;exports.MemoryPermissionError=N;exports.MemorySearchError=v;exports.MemoryValidationError=C;exports.addWord=ve;exports.clearAllHooks=Ie;exports.closeTokenizer=Le;exports.dispatchHook=Me;exports.initTokenizer=Te;exports.isInitialized=Fe;exports.listHooks=Ee;exports.loadCustomDict=ye;exports.registerAllDefaultHooks=be;exports.registerHook=f;exports.toFtsTokens=$e;exports.toFtsTokensForSearch=je;exports.tokenize=Re;exports.tokenizeForSearch=ke;exports.unregisterHook=he;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { KnowledgeSearchOptions, MemoryKnowledgeConfigWithModels, IGlobal, IInstance } from '@easbot/types';
|
|
2
2
|
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 { BuildPromptOptions } from '@easbot/utils';
|
|
3
6
|
import { ZodTypeAny } from 'zod';
|
|
4
7
|
import { StdioServerConfig } from '@easbot/mcp';
|
|
5
8
|
import { SyncSqliteConnection } from '@easbot/database';
|
|
6
|
-
export { EmbeddingModel, LanguageModel } from 'ai';
|
|
7
9
|
|
|
8
10
|
type MemoryCategory = 'user_preference' | 'task_context' | 'technical_fact' | 'decision' | 'relationship' | 'reminder' | 'error_pattern' | 'workflow' | 'exploration_finding' | 'experience_summary' | 'tool_usage' | 'skill_creation' | 'test' | 'other';
|
|
9
11
|
declare const MEMORY_CATEGORIES: MemoryCategory[];
|
|
@@ -152,16 +154,51 @@ declare function closeTokenizer(): Promise<void>;
|
|
|
152
154
|
declare function toFtsTokens(text: string): string;
|
|
153
155
|
declare function toFtsTokensForSearch(text: string): string;
|
|
154
156
|
|
|
155
|
-
interface
|
|
157
|
+
interface LlmModels {
|
|
158
|
+
embeddingLlm?: EmbeddingModel;
|
|
159
|
+
graphLlm?: LanguageModel;
|
|
160
|
+
}
|
|
161
|
+
interface LlmOptions {
|
|
162
|
+
maxOutputTokens?: number;
|
|
163
|
+
temperature?: number;
|
|
164
|
+
}
|
|
165
|
+
interface LlmInitConfig {
|
|
166
|
+
models: LlmModels;
|
|
167
|
+
options?: {
|
|
168
|
+
graph?: LlmOptions;
|
|
169
|
+
embedding?: LlmOptions;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
declare namespace Llm {
|
|
173
|
+
function init(config: LlmInitConfig): void;
|
|
174
|
+
function isInitialized(): boolean;
|
|
175
|
+
function reset(): void;
|
|
176
|
+
function capabilities(): {
|
|
177
|
+
embedding: boolean;
|
|
178
|
+
graph: boolean;
|
|
179
|
+
};
|
|
180
|
+
function embedText(value: string): Promise<Float32Array>;
|
|
181
|
+
function embedTexts(values: string[]): Promise<Float32Array[]>;
|
|
182
|
+
function generateGraph(chunks: string[], entityTypes: ReadonlyArray<{
|
|
183
|
+
type: string;
|
|
184
|
+
rule: string;
|
|
185
|
+
}>, relationTypes: ReadonlyArray<{
|
|
186
|
+
type: string;
|
|
187
|
+
rule: string;
|
|
188
|
+
}>, options?: BuildPromptOptions & LlmOptions): Promise<string>;
|
|
189
|
+
function generate(prompt: string, options?: LlmOptions): Promise<string>;
|
|
190
|
+
const embed: typeof embedText;
|
|
191
|
+
const embedMany: typeof embedTexts;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
interface MemoryServiceContext {
|
|
156
195
|
workspaceDir: string;
|
|
157
196
|
rootDir: string;
|
|
158
|
-
}
|
|
159
|
-
interface MemoryServiceContext extends BaseServiceContext {
|
|
160
197
|
dbPath: string;
|
|
161
198
|
locale: 'zh-CN' | 'en-US';
|
|
162
199
|
remote: boolean;
|
|
163
200
|
config?: MemoryKnowledgeConfigWithModels;
|
|
164
|
-
agentId
|
|
201
|
+
agentId?: string;
|
|
165
202
|
}
|
|
166
203
|
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';
|
|
167
204
|
type KGScope = 'agent_only' | 'shared_only' | 'both';
|
|
@@ -204,6 +241,8 @@ interface RememberResult {
|
|
|
204
241
|
filePath: string;
|
|
205
242
|
deduplicated: boolean;
|
|
206
243
|
nodeIds?: number[];
|
|
244
|
+
vectorsWritten: number;
|
|
245
|
+
vectorDims: number;
|
|
207
246
|
}
|
|
208
247
|
interface ForgetParams {
|
|
209
248
|
factId?: string;
|
|
@@ -297,6 +336,7 @@ interface DoctorResult {
|
|
|
297
336
|
passed: boolean;
|
|
298
337
|
message: string;
|
|
299
338
|
details?: Record<string, unknown>;
|
|
339
|
+
severity?: 'error' | 'info';
|
|
300
340
|
}>;
|
|
301
341
|
}
|
|
302
342
|
interface InitParams {
|
|
@@ -308,10 +348,12 @@ interface InitParams {
|
|
|
308
348
|
interface InitResult {
|
|
309
349
|
initialized: boolean;
|
|
310
350
|
dbPath: string;
|
|
351
|
+
configPath: string;
|
|
311
352
|
workspaceDir: string;
|
|
312
353
|
tablesCreated: number;
|
|
313
354
|
migrationsApplied: number;
|
|
314
355
|
durationMs: number;
|
|
356
|
+
configCreated: boolean;
|
|
315
357
|
}
|
|
316
358
|
|
|
317
359
|
declare function recall(ctx: MemoryServiceContext, params: RecallParams): Promise<RecallResult>;
|
|
@@ -432,7 +474,10 @@ declare function getInstance(): IInstance;
|
|
|
432
474
|
declare function getHomeDir(): string;
|
|
433
475
|
declare function getXdgData(): string;
|
|
434
476
|
declare function getMemoryDir(): string;
|
|
435
|
-
declare function getMemoryDbPath(
|
|
477
|
+
declare function getMemoryDbPath(input?: string | {
|
|
478
|
+
dir?: string;
|
|
479
|
+
workspaceDir?: string;
|
|
480
|
+
}): string;
|
|
436
481
|
|
|
437
482
|
type MigrationDb = SyncSqliteConnection;
|
|
438
483
|
declare const LATEST_SCHEMA_VERSION = 2;
|
|
@@ -471,6 +516,10 @@ declare class MemoryDatabaseManager {
|
|
|
471
516
|
private applyPragmas;
|
|
472
517
|
private runAllMigrations;
|
|
473
518
|
query<T>(sql: string, params?: unknown[]): T[];
|
|
519
|
+
agentFilter(agentId: string | null | undefined): {
|
|
520
|
+
where: string;
|
|
521
|
+
params: string[];
|
|
522
|
+
};
|
|
474
523
|
run(sql: string, params?: unknown[]): {
|
|
475
524
|
lastID: number;
|
|
476
525
|
changes: number;
|
|
@@ -532,4 +581,4 @@ declare function registerAllDefaultHooks(): void;
|
|
|
532
581
|
declare function clearAllHooks(): void;
|
|
533
582
|
declare function dispatchHook(name: HookName, ctx: HookContext): Promise<HookResult>;
|
|
534
583
|
|
|
535
|
-
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, 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, 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, toFtsTokens, toFtsTokensForSearch, tokenize, tokenizeForSearch, unregisterHook };
|
|
584
|
+
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, type LlmOptions, 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, 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, toFtsTokens, toFtsTokensForSearch, tokenize, tokenizeForSearch, unregisterHook };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { KnowledgeSearchOptions, MemoryKnowledgeConfigWithModels, IGlobal, IInstance } from '@easbot/types';
|
|
2
2
|
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 { BuildPromptOptions } from '@easbot/utils';
|
|
3
6
|
import { ZodTypeAny } from 'zod';
|
|
4
7
|
import { StdioServerConfig } from '@easbot/mcp';
|
|
5
8
|
import { SyncSqliteConnection } from '@easbot/database';
|
|
6
|
-
export { EmbeddingModel, LanguageModel } from 'ai';
|
|
7
9
|
|
|
8
10
|
type MemoryCategory = 'user_preference' | 'task_context' | 'technical_fact' | 'decision' | 'relationship' | 'reminder' | 'error_pattern' | 'workflow' | 'exploration_finding' | 'experience_summary' | 'tool_usage' | 'skill_creation' | 'test' | 'other';
|
|
9
11
|
declare const MEMORY_CATEGORIES: MemoryCategory[];
|
|
@@ -152,16 +154,51 @@ declare function closeTokenizer(): Promise<void>;
|
|
|
152
154
|
declare function toFtsTokens(text: string): string;
|
|
153
155
|
declare function toFtsTokensForSearch(text: string): string;
|
|
154
156
|
|
|
155
|
-
interface
|
|
157
|
+
interface LlmModels {
|
|
158
|
+
embeddingLlm?: EmbeddingModel;
|
|
159
|
+
graphLlm?: LanguageModel;
|
|
160
|
+
}
|
|
161
|
+
interface LlmOptions {
|
|
162
|
+
maxOutputTokens?: number;
|
|
163
|
+
temperature?: number;
|
|
164
|
+
}
|
|
165
|
+
interface LlmInitConfig {
|
|
166
|
+
models: LlmModels;
|
|
167
|
+
options?: {
|
|
168
|
+
graph?: LlmOptions;
|
|
169
|
+
embedding?: LlmOptions;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
declare namespace Llm {
|
|
173
|
+
function init(config: LlmInitConfig): void;
|
|
174
|
+
function isInitialized(): boolean;
|
|
175
|
+
function reset(): void;
|
|
176
|
+
function capabilities(): {
|
|
177
|
+
embedding: boolean;
|
|
178
|
+
graph: boolean;
|
|
179
|
+
};
|
|
180
|
+
function embedText(value: string): Promise<Float32Array>;
|
|
181
|
+
function embedTexts(values: string[]): Promise<Float32Array[]>;
|
|
182
|
+
function generateGraph(chunks: string[], entityTypes: ReadonlyArray<{
|
|
183
|
+
type: string;
|
|
184
|
+
rule: string;
|
|
185
|
+
}>, relationTypes: ReadonlyArray<{
|
|
186
|
+
type: string;
|
|
187
|
+
rule: string;
|
|
188
|
+
}>, options?: BuildPromptOptions & LlmOptions): Promise<string>;
|
|
189
|
+
function generate(prompt: string, options?: LlmOptions): Promise<string>;
|
|
190
|
+
const embed: typeof embedText;
|
|
191
|
+
const embedMany: typeof embedTexts;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
interface MemoryServiceContext {
|
|
156
195
|
workspaceDir: string;
|
|
157
196
|
rootDir: string;
|
|
158
|
-
}
|
|
159
|
-
interface MemoryServiceContext extends BaseServiceContext {
|
|
160
197
|
dbPath: string;
|
|
161
198
|
locale: 'zh-CN' | 'en-US';
|
|
162
199
|
remote: boolean;
|
|
163
200
|
config?: MemoryKnowledgeConfigWithModels;
|
|
164
|
-
agentId
|
|
201
|
+
agentId?: string;
|
|
165
202
|
}
|
|
166
203
|
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';
|
|
167
204
|
type KGScope = 'agent_only' | 'shared_only' | 'both';
|
|
@@ -204,6 +241,8 @@ interface RememberResult {
|
|
|
204
241
|
filePath: string;
|
|
205
242
|
deduplicated: boolean;
|
|
206
243
|
nodeIds?: number[];
|
|
244
|
+
vectorsWritten: number;
|
|
245
|
+
vectorDims: number;
|
|
207
246
|
}
|
|
208
247
|
interface ForgetParams {
|
|
209
248
|
factId?: string;
|
|
@@ -297,6 +336,7 @@ interface DoctorResult {
|
|
|
297
336
|
passed: boolean;
|
|
298
337
|
message: string;
|
|
299
338
|
details?: Record<string, unknown>;
|
|
339
|
+
severity?: 'error' | 'info';
|
|
300
340
|
}>;
|
|
301
341
|
}
|
|
302
342
|
interface InitParams {
|
|
@@ -308,10 +348,12 @@ interface InitParams {
|
|
|
308
348
|
interface InitResult {
|
|
309
349
|
initialized: boolean;
|
|
310
350
|
dbPath: string;
|
|
351
|
+
configPath: string;
|
|
311
352
|
workspaceDir: string;
|
|
312
353
|
tablesCreated: number;
|
|
313
354
|
migrationsApplied: number;
|
|
314
355
|
durationMs: number;
|
|
356
|
+
configCreated: boolean;
|
|
315
357
|
}
|
|
316
358
|
|
|
317
359
|
declare function recall(ctx: MemoryServiceContext, params: RecallParams): Promise<RecallResult>;
|
|
@@ -432,7 +474,10 @@ declare function getInstance(): IInstance;
|
|
|
432
474
|
declare function getHomeDir(): string;
|
|
433
475
|
declare function getXdgData(): string;
|
|
434
476
|
declare function getMemoryDir(): string;
|
|
435
|
-
declare function getMemoryDbPath(
|
|
477
|
+
declare function getMemoryDbPath(input?: string | {
|
|
478
|
+
dir?: string;
|
|
479
|
+
workspaceDir?: string;
|
|
480
|
+
}): string;
|
|
436
481
|
|
|
437
482
|
type MigrationDb = SyncSqliteConnection;
|
|
438
483
|
declare const LATEST_SCHEMA_VERSION = 2;
|
|
@@ -471,6 +516,10 @@ declare class MemoryDatabaseManager {
|
|
|
471
516
|
private applyPragmas;
|
|
472
517
|
private runAllMigrations;
|
|
473
518
|
query<T>(sql: string, params?: unknown[]): T[];
|
|
519
|
+
agentFilter(agentId: string | null | undefined): {
|
|
520
|
+
where: string;
|
|
521
|
+
params: string[];
|
|
522
|
+
};
|
|
474
523
|
run(sql: string, params?: unknown[]): {
|
|
475
524
|
lastID: number;
|
|
476
525
|
changes: number;
|
|
@@ -532,4 +581,4 @@ declare function registerAllDefaultHooks(): void;
|
|
|
532
581
|
declare function clearAllHooks(): void;
|
|
533
582
|
declare function dispatchHook(name: HookName, ctx: HookContext): Promise<HookResult>;
|
|
534
583
|
|
|
535
|
-
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, 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, 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, toFtsTokens, toFtsTokensForSearch, tokenize, tokenizeForSearch, unregisterHook };
|
|
584
|
+
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, type LlmOptions, 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, 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, toFtsTokens, toFtsTokensForSearch, tokenize, tokenizeForSearch, unregisterHook };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export{b as MemoryStdioServer,a as renderOperationMarkdown}from'./chunks/chunk-
|
|
1
|
+
export{b as MemoryStdioServer,a as renderOperationMarkdown}from'./chunks/chunk-EECBJNZI.mjs';import'./chunks/chunk-QF5S5MG7.mjs';export{a as COMMANDS_HELP,d as handleMemoryCli,b as renderBanner,c as renderHelp}from'./chunks/chunk-TPSRK4M3.mjs';import {u as u$1,v as v$1}from'./chunks/chunk-I6XVFDN2.mjs';export{t as ALL_OPS,a as GraphStore,b as Llm,s as OP_REGISTRY,n as consolidate,q as doctor,u as executeOp,m as extract,l as forget,o as graphQuery,r as init,c as recall,k as remember,p as status}from'./chunks/chunk-I6XVFDN2.mjs';export{a as LATEST_SCHEMA_VERSION,b as MIGRATIONS,e as MemoryDatabaseManager,d as readCurrentSchemaVersion,c as runMigrations}from'./chunks/chunk-DFWC6WII.mjs';import {f as f$1,j as j$1}from'./chunks/chunk-WDVDYZ25.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-WDVDYZ25.mjs';import {a}from'./chunks/chunk-HQBRVVXS.mjs';export{GRAPH_ENTITY_TYPE_DEFINITIONS,GRAPH_RELATION_TYPE_DEFINITIONS}from'@easbot/types';import*as m from'jieba-wasm';import {Log,loadTextFile,Filesystem}from'@easbot/utils';import {createHash}from'crypto';var Oe=["user_preference","task_context","technical_fact","decision","relationship","reminder","error_pattern","workflow","exploration_finding","experience_summary","tool_usage","skill_creation","test","other"],d=class extends Error{constructor(t,o,n){super(t,{cause:n});a(this,"code",o);a(this,"cause",n);this.name="MemoryError";}},P=class extends d{constructor(r,t){super(r,"MEMORY_VALIDATION_ERROR",t),this.name="MemoryValidationError";}},N=class extends d{constructor(r){super(`Memory not found: ${r}`,"MEMORY_NOT_FOUND"),this.name="MemoryNotFoundError";}},D=class extends d{constructor(r){super(r,"MEMORY_PERMISSION_ERROR"),this.name="MemoryPermissionError";}},T=class extends d{constructor(r,t){super(r,"MEMORY_DATABASE_ERROR",t),this.name="MemoryDatabaseError";}},v=class extends d{constructor(r,t){super(r,"MEMORY_FILE_ERROR",t),this.name="MemoryFileError";}},F=class extends d{constructor(r,t){super(r,"MEMORY_SEARCH_ERROR",t),this.name="MemorySearchError";}},L=class extends d{constructor(r,t){super(r,"MEMORY_EMBEDDING_ERROR",t),this.name="MemoryEmbeddingError";}},me=(i=>(i.VALIDATION_ERROR="MEMORY_VALIDATION_ERROR",i.NOT_FOUND="MEMORY_NOT_FOUND",i.PERMISSION_ERROR="MEMORY_PERMISSION_ERROR",i.DATABASE_ERROR="MEMORY_DATABASE_ERROR",i.FILE_ERROR="MEMORY_FILE_ERROR",i.SEARCH_ERROR="MEMORY_SEARCH_ERROR",i.EMBEDDING_ERROR="MEMORY_EMBEDDING_ERROR",i))(me||{});var s=Log.create({service:"memory.tokenizer"}),c=false,ye=loadTextFile("./assets/jieba_dict.txt",import.meta.url);async function ve(e){if(!c)try{s.debug("Initializing jieba tokenizer");let r=ye();if(m.with_dict(r),s.debug("Built-in dictionary loaded"),e?.dictPath&&e.dictPath.length>0)for(let t of e.dictPath)await Re(t);c=!0,s.debug("Jieba tokenizer initialized successfully");}catch(r){s.error("Failed to initialize jieba tokenizer",{error:String(r)}),s.warn("Using fallback tokenization (space-based)");}}async function Re(e){if(!c)throw new Error("Tokenizer not initialized");try{let r=await Filesystem.readText(e);s.debug("Loading custom dictionary",{dictPath:e}),m.with_dict(r),s.debug("Custom dictionary loaded successfully",{dictPath:e});}catch(r){s.warn("Failed to load custom dictionary",{dictPath:e,error:String(r)});}}function ke(e){if(!c)return e.split(/\s+/).filter(Boolean);try{return m.cut(e)}catch(r){return s.warn("Tokenization failed, using fallback",{error:String(r)}),e.split(/\s+/).filter(Boolean)}}function xe(e){if(!c)return e.split(/\s+/).filter(Boolean);try{return m.cut_for_search(e)}catch(r){return s.warn("Tokenization for search failed, using fallback",{error:String(r)}),e.split(/\s+/).filter(Boolean)}}function Fe(e,r,t){if(c)try{m.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:String(o)});}}function Le(){return c}async function $e(){c=false,s.debug("Tokenizer closed");}function je(e){if(!c)return e.split(/\s+/).filter(Boolean).join(" ");try{return ke(e).join(" ")}catch(r){return s.warn("Tokenization failed, using fallback",{error:String(r)}),e.split(/\s+/).filter(Boolean).join(" ")}}function ze(e){if(!c)return e.split(/\s+/).filter(Boolean).join(" ");try{return xe(e).join(" ")}catch(r){return s.warn("Tokenization for search failed, using fallback",{error:String(r)}),e.split(/\s+/).filter(Boolean).join(" ")}}function u(e){let r=f$1().worktree,t=j$1(r);return {agentId:e,isTrustedLocal:true,remote:false,locale:"en-US",dbPath:t,workspaceDir:r,rootDir:r,config:v$1({agentId:e,dbPath:t,workspaceDir:r})}}var $=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 u$1("recall",{query:t,maxResults:r},u(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}]
|
|
2
2
|
${n.join(`
|
|
3
|
-
`)}`,logLine:`session-start: injected ${o.hits.length} facts into context (agent=${e.agentId})`}}catch(o){return {ok:false,error:o instanceof Error?o.message:String(o)}}};var
|
|
3
|
+
`)}`,logLine:`session-start: injected ${o.hits.length} facts into context (agent=${e.agentId})`}}catch(o){return {ok:false,error:o instanceof Error?o.message:String(o)}}};var j=async e=>{if(!e.agentId?.trim())return {ok:false,error:"session-end: agentId is required in ctx"};let r=e.extras?.windowDays??1;try{let t=await u$1("consolidate",{windowDays:r},u(e.agentId));return {ok:!0,logLine:`session-end: 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 z=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 u$1("recall",{query:t,maxResults:o,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
4
|
${h.join(`
|
|
5
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 Y=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),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
|
|
6
|
+
`);try{return {ok:!0,logLine:`post-tool-failure: wrote error_pattern fact ${(await u$1("remember",{content:o,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 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 Ee(e){return f.delete(e)}function be(){return Array.from(f.values()).map(e=>({name:e.name,handler:e.handler,registeredAt:e.registeredAt}))}function Ie(){y("session-start",$),y("session-end",j),y("pre-compact",z),y("post-tool-failure",Y);}function Me(){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=o instanceof Error?o.message:String(o);return g.warn("dispatchHook: handler threw, caught and converted to failure result",{name:e,agentId:r.agentId,error:n}),{ok:false,error:n}}}export{Oe as MEMORY_CATEGORIES,T as MemoryDatabaseError,L as MemoryEmbeddingError,d as MemoryError,me as MemoryErrorCode,v as MemoryFileError,N as MemoryNotFoundError,D as MemoryPermissionError,F as MemorySearchError,P as MemoryValidationError,Fe as addWord,Me as clearAllHooks,$e as closeTokenizer,_e as dispatchHook,ve as initTokenizer,Le as isInitialized,be as listHooks,Re as loadCustomDict,Ie as registerAllDefaultHooks,y as registerHook,je as toFtsTokens,ze as toFtsTokensForSearch,ke as tokenize,xe as tokenizeForSearch,Ee as unregisterHook};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easbot/memory",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.17",
|
|
4
4
|
"description": "Memory management library for EASBOT ecosystem - 智能记忆管理库,支持混合搜索、中英文分词、增量索引",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -48,19 +48,19 @@
|
|
|
48
48
|
"zod": "^4.4.3",
|
|
49
49
|
"@ai-sdk/provider": "^3.0.15",
|
|
50
50
|
"@ai-sdk/provider-utils": "^4.0.45",
|
|
51
|
-
"@ai-sdk/openai-compatible": "
|
|
51
|
+
"@ai-sdk/openai-compatible": "2.0.70",
|
|
52
52
|
"@ai-sdk/anthropic": "3.0.110",
|
|
53
53
|
"ai": "^6.0.253",
|
|
54
54
|
"better-sqlite3": "^13.0.3",
|
|
55
55
|
"jieba-wasm": "^2.4.0",
|
|
56
56
|
"xdg-basedir": "^5.1.0",
|
|
57
|
-
"@easbot/database": "0.3.
|
|
58
|
-
"@easbot/mcp": "0.3.
|
|
59
|
-
"@easbot/terminal": "0.3.
|
|
60
|
-
"@easbot/
|
|
61
|
-
"@easbot/
|
|
62
|
-
"@easbot/local-model-sdk": "0.3.
|
|
63
|
-
"@easbot/ollama-sdk": "0.3.
|
|
57
|
+
"@easbot/database": "0.3.17",
|
|
58
|
+
"@easbot/mcp": "0.3.17",
|
|
59
|
+
"@easbot/terminal": "0.3.17",
|
|
60
|
+
"@easbot/utils": "0.3.17",
|
|
61
|
+
"@easbot/types": "0.3.17",
|
|
62
|
+
"@easbot/local-model-sdk": "0.3.17",
|
|
63
|
+
"@easbot/ollama-sdk": "0.3.17"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/node": "^25.9.5",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var os=require('os'),path=require('path'),xdgBasedir=require('xdg-basedir');var r=null,n=null;function d(t){r=t;}function f(){r=null;}function s(){if(r)return r;let t=os.homedir();return {Path:{home:t,data:process.env.EASBOT_DATA_PATH?.trim()||path.join(xdgBasedir.xdgData??path.join(t,".local","share"),"easbot"),config:process.env.EASBOT_CONFIG_PATH?.trim()||path.join(t,".config","easbot"),state:process.env.EASBOT_STATE_PATH?.trim()||path.join(xdgBasedir.xdgData??path.join(t,".local","share"),"easbot","state"),cache:process.env.EASBOT_CACHE_PATH?.trim()||path.join(t,".cache","easbot"),log:process.env.EASBOT_LOG_PATH?.trim()||path.join(xdgBasedir.xdgData??path.join(t,".local","share"),"easbot","log"),bin:process.env.EASBOT_BIN_PATH?.trim()||path.join(t,".local","bin")}}}function A(t){n=t;}function I(){n=null;}function g(){if(n)return n;let t=process.cwd();return {directory:t,worktree:t}}function l(){return s().Path.home||os.homedir()}function c(){let t=s().Path.data;return t||(xdgBasedir.xdgData??path.join(l(),".local","share"))}function i(){return path.join(c(),"memory")}function T(){return path.join(i(),"memory.db")}exports.a=d;exports.b=f;exports.c=s;exports.d=A;exports.e=I;exports.f=g;exports.g=l;exports.h=c;exports.i=i;exports.j=T;
|