@easbot/memory 0.3.17 → 0.3.20
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 +101 -0
- package/README.md +116 -11
- package/dist/chunks/chunk-4GSXSIV5.cjs +1 -0
- package/dist/chunks/chunk-6CQMBEIQ.mjs +1 -0
- package/dist/chunks/chunk-AYGZUNFR.cjs +1 -0
- package/dist/chunks/{chunk-OIUUTVLL.cjs → chunk-EGWJG65Q.cjs} +22 -4
- package/dist/chunks/chunk-J5XF2W4Z.cjs +1 -0
- package/dist/chunks/chunk-JDPZ5U53.mjs +71 -0
- package/dist/chunks/chunk-N5YRDTEH.mjs +60 -0
- package/dist/chunks/{chunk-MWRDF6VN.mjs → chunk-QYBWHFOX.mjs} +1 -1
- package/dist/chunks/chunk-S6S35LDL.cjs +60 -0
- package/dist/chunks/chunk-SWYQLQ7Z.mjs +1 -0
- package/dist/chunks/chunk-TIZCWDJ7.mjs +1 -0
- package/dist/chunks/chunk-UF2Y2Q4L.mjs +50 -0
- package/dist/chunks/chunk-WQB4D6DZ.cjs +1 -0
- package/dist/chunks/chunk-Z5E4HBGK.cjs +50 -0
- package/dist/chunks/cli-handler-2IPBL45N.cjs +1 -0
- package/dist/chunks/cli-handler-5YNHYDSM.mjs +1 -0
- package/dist/chunks/consolidate-G4YJV756.cjs +2 -0
- package/dist/chunks/consolidate-MSPLH3T6.mjs +2 -0
- package/dist/chunks/doctor-GKMREWZN.mjs +1 -0
- package/dist/chunks/doctor-YTUQCHFJ.cjs +1 -0
- package/dist/chunks/extract-3C4QFS7E.mjs +2 -0
- package/dist/chunks/extract-YKDPZ7GA.cjs +2 -0
- package/dist/chunks/forget-GNIJL2DU.cjs +3 -0
- package/dist/chunks/{forget-A4UJI3LE.mjs → forget-VQB5DUJ3.mjs} +1 -1
- package/dist/chunks/{graph-XZ46LEO7.mjs → graph-4W63TU2D.mjs} +1 -1
- package/dist/chunks/graph-GTYUNUJE.cjs +3 -0
- package/dist/chunks/init-DGMGRNCG.cjs +1 -0
- package/dist/chunks/init-G2WTR477.mjs +1 -0
- package/dist/chunks/llm-RMPVWEVP.cjs +1 -0
- package/dist/chunks/llm-UHTBU2HA.mjs +1 -0
- package/dist/chunks/{mcp-BXVXTUJK.cjs → mcp-EHUKGJRB.cjs} +1 -1
- package/dist/chunks/{mcp-BOD4ZOZS.mjs → mcp-QQBHEZFY.mjs} +1 -1
- package/dist/chunks/recall-SGA2DITO.mjs +2 -0
- package/dist/chunks/recall-ZENMAOMJ.cjs +2 -0
- package/dist/chunks/remember-3ZY66RJQ.cjs +2 -0
- package/dist/chunks/remember-P3G7WWYB.mjs +2 -0
- package/dist/chunks/status-JYI52QKB.mjs +1 -0
- package/dist/chunks/status-UEKBJVCI.cjs +1 -0
- package/dist/chunks/stdio-server-2PWTBTDJ.mjs +1 -0
- package/dist/chunks/stdio-server-JL4XNUHH.cjs +1 -0
- package/dist/chunks/sync-64JINCSC.cjs +2 -0
- package/dist/chunks/sync-ZPRCA4MO.mjs +2 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +87 -38
- package/dist/index.d.ts +87 -38
- package/dist/index.mjs +4 -4
- package/package.json +9 -8
- package/dist/chunks/chunk-BSKFK4RC.mjs +0 -1
- package/dist/chunks/chunk-DFWC6WII.mjs +0 -53
- package/dist/chunks/chunk-DXU5WPK3.cjs +0 -42
- package/dist/chunks/chunk-EECBJNZI.mjs +0 -59
- package/dist/chunks/chunk-FMEXQ5YE.cjs +0 -59
- package/dist/chunks/chunk-HSK27DQ7.cjs +0 -1
- package/dist/chunks/chunk-I6XVFDN2.mjs +0 -42
- package/dist/chunks/chunk-QNDG7BTB.cjs +0 -1
- package/dist/chunks/chunk-RSJ2KT6X.cjs +0 -1
- package/dist/chunks/chunk-TPSRK4M3.mjs +0 -1
- package/dist/chunks/cli-handler-6VTKYXXM.mjs +0 -1
- package/dist/chunks/cli-handler-HNPA3STD.cjs +0 -1
- package/dist/chunks/consolidate-6P7LUPPL.cjs +0 -2
- package/dist/chunks/consolidate-NYH4IKJK.mjs +0 -2
- package/dist/chunks/doctor-IJJ5UYGT.cjs +0 -2
- package/dist/chunks/doctor-MZSZGVRL.mjs +0 -2
- package/dist/chunks/extract-6B7OD3VK.mjs +0 -2
- package/dist/chunks/extract-ERTOHQV6.cjs +0 -2
- package/dist/chunks/forget-KLFM5SBQ.cjs +0 -3
- package/dist/chunks/graph-P5ZHB4ZM.cjs +0 -3
- package/dist/chunks/init-CCOSHE3F.cjs +0 -3
- package/dist/chunks/init-WEPU32KF.mjs +0 -3
- package/dist/chunks/recall-BV4Z7HUJ.mjs +0 -2
- package/dist/chunks/recall-FEINUJKO.cjs +0 -2
- package/dist/chunks/remember-ESVRA73C.mjs +0 -2
- package/dist/chunks/remember-YNSY2JJB.cjs +0 -2
- package/dist/chunks/status-KVM7I6YC.cjs +0 -2
- package/dist/chunks/status-QQZS3ZCN.mjs +0 -2
- package/dist/chunks/stdio-server-MQKTUGNG.cjs +0 -1
- package/dist/chunks/stdio-server-ZLMSUTC5.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {v,x}from'./chunk-UF2Y2Q4L.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function u(o){let r=o.agentId,t=o.workspaceDir??process.cwd();return v("doctor",{repair:o.repair??false},x(r,t))}function f(o){return ""}function l(o){let r={};for(let t=0;t<o.length;t++){let e=o[t];e!==void 0&&(e==="--repair"?r.repair=true:e==="--json"?r.json=true:(e==="--help"||e==="-h")&&(r.help=true));}return r}export{f as formatDoctorText,l as parseDoctorOptions,u as runDoctor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkZ5E4HBGK_cjs=require('./chunk-Z5E4HBGK.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function a(o){let r=o.agentId,t=o.workspaceDir??process.cwd();return chunkZ5E4HBGK_cjs.v("doctor",{repair:o.repair??false},chunkZ5E4HBGK_cjs.x(r,t))}function u(o){return ""}function f(o){let r={};for(let t=0;t<o.length;t++){let e=o[t];e!==void 0&&(e==="--repair"?r.repair=true:e==="--json"?r.json=true:(e==="--help"||e==="-h")&&(r.help=true));}return r}exports.formatDoctorText=u;exports.parseDoctorOptions=f;exports.runDoctor=a;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x as x$1}from'./chunk-UF2Y2Q4L.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function m(r){if(!r.sessionId?.trim())throw new Error("extract: --session is required");let e=r.agentId?.trim()||"default",t=r.workspaceDir??process.cwd();return v("extract",{sessionId:r.sessionId,lastN:r.lastN??10,fromMessageId:r.fromMessageId},x$1(e,t))}function p(r){let e=r,t=[b("extract",{extractedCount:e.extractedCount},"Extracted {{extractedCount}} fact(s) from {{fromMessageId}}..{{toMessageId}}")];for(let s of e.factIds)t.push(c("extract",{id:s}," - {{id}}"));if(e.entities&&e.entities.length>0){t.push(""),t.push("entities:");for(let s of e.entities)t.push(` - ${s.name} (${s.type})`);}if(e.relations&&e.relations.length>0){t.push(""),t.push("relations:");for(let s of e.relations)t.push(` - ${s.source} --${s.relation}--> ${s.target}`);}return t.join(`
|
|
2
|
+
`)}function x(r){let e={};for(let t=0;t<r.length;t++){let s=r[t];if(s===void 0)continue;let n=r[t+1];s==="--agent"?(e.agentId=n,t++):s==="--session"?(e.sessionId=n,t++):s==="--last-n"?(e.lastN=Number(n),t++):s==="--from-msg"?(e.fromMessageId=n,t++):s==="--json"?e.json=true:(s==="--help"||s==="-h")&&(e.help=true);}return e}export{p as formatExtractText,x as parseExtractOptions,m as runExtract};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunkZ5E4HBGK_cjs=require('./chunk-Z5E4HBGK.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function l(r){if(!r.sessionId?.trim())throw new Error("extract: --session is required");let e=r.agentId?.trim()||"default",t=r.workspaceDir??process.cwd();return chunkZ5E4HBGK_cjs.v("extract",{sessionId:r.sessionId,lastN:r.lastN??10,fromMessageId:r.fromMessageId},chunkZ5E4HBGK_cjs.x(e,t))}function m(r){let e=r,t=[chunk4GSXSIV5_cjs.b("extract",{extractedCount:e.extractedCount},"Extracted {{extractedCount}} fact(s) from {{fromMessageId}}..{{toMessageId}}")];for(let s of e.factIds)t.push(chunk4GSXSIV5_cjs.c("extract",{id:s}," - {{id}}"));if(e.entities&&e.entities.length>0){t.push(""),t.push("entities:");for(let s of e.entities)t.push(` - ${s.name} (${s.type})`);}if(e.relations&&e.relations.length>0){t.push(""),t.push("relations:");for(let s of e.relations)t.push(` - ${s.source} --${s.relation}--> ${s.target}`);}return t.join(`
|
|
2
|
+
`)}function p(r){let e={};for(let t=0;t<r.length;t++){let s=r[t];if(s===void 0)continue;let n=r[t+1];s==="--agent"?(e.agentId=n,t++):s==="--session"?(e.sessionId=n,t++):s==="--last-n"?(e.lastN=Number(n),t++):s==="--from-msg"?(e.fromMessageId=n,t++):s==="--json"?e.json=true:(s==="--help"||s==="-h")&&(e.help=true);}return e}exports.formatExtractText=m;exports.parseExtractOptions=p;exports.runExtract=l;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunkZ5E4HBGK_cjs=require('./chunk-Z5E4HBGK.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function g(n){let e=n.agentId?.trim()||"default",t=n.workspaceDir??process.cwd();return chunkZ5E4HBGK_cjs.v("forget",{factId:n.factId,category:n.category,fromTime:n.fromTime,toTime:n.toTime,maxDelete:n.maxDelete??1e3,dryRun:n.dryRun??false},chunkZ5E4HBGK_cjs.x(e,t))}function p(n){let e=n,t=[];if(e.deletedCount===0&&e.deletedIds.length===0)return t.push(chunk4GSXSIV5_cjs.a("forget","(no records to delete)")),t.join(`
|
|
2
|
+
`);t.push(chunk4GSXSIV5_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(chunk4GSXSIV5_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;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {a,b,c}from'./chunk-
|
|
1
|
+
import {a,b,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x as x$1}from'./chunk-UF2Y2Q4L.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function p(n){let e=n.agentId?.trim()||"default",t=n.workspaceDir??process.cwd();return v("forget",{factId:n.factId,category:n.category,fromTime:n.fromTime,toTime:n.toTime,maxDelete:n.maxDelete??1e3,dryRun:n.dryRun??false},x$1(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
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
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};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {b,a,c as c$1}from'./chunk-
|
|
1
|
+
import {b,a,c as c$1}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x}from'./chunk-UF2Y2Q4L.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function c(t){let r=t.agentId?.trim()||"default",n=t.workspaceDir??process.cwd();return v("graph_query",{kind:t.kind??"nodes",query:t.query,startNodeId:t.startNodeId,depth:t.depth,maxNodes:t.maxNodes,scope:t.scope??"agent_only"},x(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
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
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 chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunkZ5E4HBGK_cjs=require('./chunk-Z5E4HBGK.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function l(t){let r=t.agentId?.trim()||"default",n=t.workspaceDir??process.cwd();return chunkZ5E4HBGK_cjs.v("graph_query",{kind:t.kind??"nodes",query:t.query,startNodeId:t.startNodeId,depth:t.depth,maxNodes:t.maxNodes,scope:t.scope??"agent_only"},chunkZ5E4HBGK_cjs.x(r,n))}function c(t){let r=t,n=[chunk4GSXSIV5_cjs.b("graph",{totalNodes:r.totalNodes??r.nodes.length},"KG query (scope={{scope}}, {{totalNodes}} node(s)):")];if(r.nodes.length===0)return n.push(chunk4GSXSIV5_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(chunk4GSXSIV5_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 @@
|
|
|
1
|
+
'use strict';var chunkZ5E4HBGK_cjs=require('./chunk-Z5E4HBGK.cjs');require('./chunk-EGWJG65Q.cjs');var chunkCPRDIUQ4_cjs=require('./chunk-CPRDIUQ4.cjs');require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function g(t){let e=t.workspaceDir?.trim()||t.ctxWorkspaceDir?.trim()||process.cwd(),i=t.agentId??"",n=t.ctxWorkspaceDir?.trim()||e;return chunkZ5E4HBGK_cjs.v("init",{workspaceDir:e,dbPath:chunkCPRDIUQ4_cjs.j(n),force:t.force??false},chunkZ5E4HBGK_cjs.x(i,n))}function m(t){let e={},i=[];for(let n=0;n<t.length;n++){let r=t[n];if(r===void 0)continue;let p=t[n+1];r==="--agent"?(e.agentId=p,n++):r==="--force"?e.force=true:r==="--json"?e.json=true:r==="--help"||r==="-h"?e.help=true:r.startsWith("-")||i.push(r);}return e.workspaceDir=i[0],e}exports.parseInitOptions=m;exports.runInit=g;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {v,x as x$1}from'./chunk-UF2Y2Q4L.mjs';import'./chunk-JDPZ5U53.mjs';import {j}from'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function m(t){let e=t.workspaceDir?.trim()||t.ctxWorkspaceDir?.trim()||process.cwd(),i=t.agentId??"",n=t.ctxWorkspaceDir?.trim()||e;return v("init",{workspaceDir:e,dbPath:j(n),force:t.force??false},x$1(i,n))}function x(t){let e={},i=[];for(let n=0;n<t.length;n++){let r=t[n];if(r===void 0)continue;let p=t[n+1];r==="--agent"?(e.agentId=p,n++):r==="--force"?e.force=true:r==="--json"?e.json=true:r==="--help"||r==="-h"?e.help=true:r.startsWith("-")||i.push(r);}return e.workspaceDir=i[0],e}export{x as parseInitOptions,m as runInit};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkJ5XF2W4Z_cjs=require('./chunk-J5XF2W4Z.cjs');require('./chunk-NVGACA7W.cjs');Object.defineProperty(exports,"Llm",{enumerable:true,get:function(){return chunkJ5XF2W4Z_cjs.a}});Object.defineProperty(exports,"llm",{enumerable:true,get:function(){return chunkJ5XF2W4Z_cjs.b}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as Llm,b as llm}from'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';require('./chunk-URADAZYW.cjs');var
|
|
1
|
+
'use strict';require('./chunk-URADAZYW.cjs');var chunkEGWJG65Q_cjs=require('./chunk-EGWJG65Q.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 chunkEGWJG65Q_cjs.e(o);await f.initialize(),f.close();let{MemoryStdioServer:y}=await import('./stdio-server-JL4XNUHH.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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import'./chunk-QF5S5MG7.mjs';import {e}from'./chunk-
|
|
1
|
+
import'./chunk-QF5S5MG7.mjs';import {e}from'./chunk-JDPZ5U53.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-2PWTBTDJ.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,2 @@
|
|
|
1
|
+
import {a}from'./chunk-SWYQLQ7Z.mjs';import {v,x}from'./chunk-UF2Y2Q4L.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.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 v("recall",{query:n.query,maxResults:n.limit??10,category:n.category,minImportance:n.minImportance},x(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 chunkWQB4D6DZ_cjs=require('./chunk-WQB4D6DZ.cjs'),chunkZ5E4HBGK_cjs=require('./chunk-Z5E4HBGK.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.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 chunkZ5E4HBGK_cjs.v("recall",{query:n.query,maxResults:n.limit??10,category:n.category,minImportance:n.minImportance},chunkZ5E4HBGK_cjs.x(e,t))}function f(n){let e=n;if(e.total===0)return chunkWQB4D6DZ_cjs.a("memory.recall.empty",{fallback:"(no facts)"});let t=[chunkWQB4D6DZ_cjs.a("memory.recall.summary",{vars:{total:e.total},fallback:`Found ${e.total} fact(s):`})];for(let r of e.hits)t.push(chunkWQB4D6DZ_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
|
+
'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunkZ5E4HBGK_cjs=require('./chunk-Z5E4HBGK.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.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 chunkZ5E4HBGK_cjs.v("remember",{content:r.content,category:r.category,importance:r.importance,tags:r.tags,sessionId:r.sessionId},chunkZ5E4HBGK_cjs.x(e,t))}function p(r){let e=r,t=[chunk4GSXSIV5_cjs.b("remember",{},"Memory persisted:"),chunk4GSXSIV5_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
|
+
import {b as b$1,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x}from'./chunk-UF2Y2Q4L.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.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 v("remember",{content:r.content,category:r.category,importance:r.importance,tags:r.tags,sessionId:r.sessionId},x(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 @@
|
|
|
1
|
+
import {v,x}from'./chunk-UF2Y2Q4L.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function f(t){let n=t.agentId,e=t.workspaceDir??process.cwd();return v("status",{agentId:n},x(n,e))}function l(t){return ""}function g(t){let n={};for(let e=0;e<t.length;e++){let o=t[e];if(o===void 0)continue;let i=t[e+1];o==="--agent"?(n.agentId=i,e++):o==="--json"?n.json=true:(o==="--help"||o==="-h")&&(n.help=true);}return n}export{l as formatStatusText,g as parseStatusOptions,f as runStatus};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkZ5E4HBGK_cjs=require('./chunk-Z5E4HBGK.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function c(t){let n=t.agentId,e=t.workspaceDir??process.cwd();return chunkZ5E4HBGK_cjs.v("status",{agentId:n},chunkZ5E4HBGK_cjs.x(n,e))}function f(t){return ""}function l(t){let n={};for(let e=0;e<t.length;e++){let o=t[e];if(o===void 0)continue;let i=t[e+1];o==="--agent"?(n.agentId=i,e++):o==="--json"?n.json=true:(o==="--help"||o==="-h")&&(n.help=true);}return n}exports.formatStatusText=f;exports.parseStatusOptions=l;exports.runStatus=c;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{b as MemoryStdioServer}from'./chunk-N5YRDTEH.mjs';import'./chunk-UF2Y2Q4L.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkS6S35LDL_cjs=require('./chunk-S6S35LDL.cjs');require('./chunk-Z5E4HBGK.cjs'),require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');Object.defineProperty(exports,"MemoryStdioServer",{enumerable:true,get:function(){return chunkS6S35LDL_cjs.b}});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunkZ5E4HBGK_cjs=require('./chunk-Z5E4HBGK.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function w(e){let n=e.agentId?.trim()||"default",r=e.workspaceDir??process.cwd();return chunkZ5E4HBGK_cjs.v("sync",{windowDays:e.windowDays,dryRun:e.dryRun??false},chunkZ5E4HBGK_cjs.x(n,r))}function m(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 f(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")n.agentId=i,r++;else if(t==="--window-days"){let o=Number(i);if(Number.isNaN(o)||o<1||o>3650)throw new Error(`--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=m;exports.parseSyncOptions=f;exports.runSync=w;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x}from'./chunk-UF2Y2Q4L.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function m(e){let n=e.agentId?.trim()||"default",r=e.workspaceDir??process.cwd();return v("sync",{windowDays:e.windowDays,dryRun:e.dryRun??false},x(n,r))}function f(e){let n=e;return [b("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 h(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")n.agentId=i,r++;else if(t==="--window-days"){let o=Number(i);if(Number.isNaN(o)||o<1||o>3650)throw new Error(`--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{f as formatSyncText,h as parseSyncOptions,m as runSync};
|
package/dist/cli.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
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
|
|
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 E=path.dirname(url.fileURLToPath(chunkNVGACA7W_cjs.b));function A(){try{let t=path.join(E,"..","package.json");return JSON.parse(fs.readFileSync(t,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var f=new Set(["DEBUG","INFO","WARN","ERROR"]);function N(t){let n={logLevel:"INFO",printLogs:false,debug:false};for(let i=0;i<t.length;i++){let e=t[i];if(e)if(e==="--cwd"&&i+1<t.length){let o=t[i+1];o&&!o.startsWith("-")&&(n.cwd=o,i++);}else if(e.startsWith("--cwd="))n.cwd=e.slice(6);else if(e==="--config"&&i+1<t.length){let o=t[i+1];o&&!o.startsWith("-")&&(n.configPath=o,i++);}else if(e.startsWith("--config="))n.configPath=e.slice(9);else if(e==="--log-level"&&i+1<t.length){let o=t[i+1];if(o&&!o.startsWith("-")){let r=o.toUpperCase();f.has(r)&&(n.logLevel=r,i++);}}else if(e.startsWith("--log-level=")){let o=e.slice(12).toUpperCase();f.has(o)&&(n.logLevel=o);}else e==="--print-logs"?n.printLogs=true:e==="--debug"&&(n.debug=true);}return n}async function R(){let t=process.argv.slice(2),n=A(),{loadEnv:i}=await import('@easbot/utils');i(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let e=N(t),{Log:o}=await import('@easbot/utils'),{getXdgData:r}=await import('./chunks/interfaces-XWE45ENK.cjs'),h=path.join(r(),"memory","log");if(await o.init({logDir:h,print:e.printLogs,dev:e.debug||false,level:e.logLevel}),t.length===0){let{renderBanner:l}=await import('./chunks/cli-handler-2IPBL45N.cjs');l();return}if(t[0]==="--help"||t[0]==="-h"){let{renderHelp:l}=await import('./chunks/cli-handler-2IPBL45N.cjs');l();return}if(t[0]==="--version"||t[0]==="-v"){terminal.printHuman([terminal.formatInfo(n)]);return}let a=e.cwd??process.cwd(),{handleMemoryCli:m}=await import('./chunks/cli-handler-2IPBL45N.cjs'),{setInstanceAdapter:u}=await import('./chunks/interfaces-XWE45ENK.cjs');u({directory:a,worktree:a});let{Llm:w}=await import('./chunks/llm-RMPVWEVP.cjs'),{bootstrapLlm:L,setAdapterRegistry:b}=await import('@easbot/llm'),{getGlobal:s,getInstance:c}=await import('./chunks/interfaces-XWE45ENK.cjs');b({config:void 0,instance:{getDirectory:()=>c().directory,getWorktree:()=>c().worktree},global:{home:s().Path.home,data:s().Path.data,cache:s().Path.cache,config:s().Path.config,state:s().Path.state,log:s().Path.log,bin:s().Path.bin},installation:{getVersion:()=>n,getChannel:()=>"local",getUserAgent:()=>`easbot-memory/${n}`}}),await L({target:w,cwd:a,subConfigPath:".easbot/memory.json",embedding:true,graph:true});let g=await m(t,{version:n,cwd:a});g.code!==0&&(process.exitCode=g.code);}R().catch(t=>{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 G=dirname(fileURLToPath(import.meta.url));function E(){try{let t=join(G,"..","package.json");return JSON.parse(readFileSync(t,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var p=new Set(["DEBUG","INFO","WARN","ERROR"]);function A(t){let n={logLevel:"INFO",printLogs:false,debug:false};for(let i=0;i<t.length;i++){let e=t[i];if(e)if(e==="--cwd"&&i+1<t.length){let o=t[i+1];o&&!o.startsWith("-")&&(n.cwd=o,i++);}else if(e.startsWith("--cwd="))n.cwd=e.slice(6);else if(e==="--config"&&i+1<t.length){let o=t[i+1];o&&!o.startsWith("-")&&(n.configPath=o,i++);}else if(e.startsWith("--config="))n.configPath=e.slice(9);else if(e==="--log-level"&&i+1<t.length){let o=t[i+1];if(o&&!o.startsWith("-")){let r=o.toUpperCase();p.has(r)&&(n.logLevel=r,i++);}}else if(e.startsWith("--log-level=")){let o=e.slice(12).toUpperCase();p.has(o)&&(n.logLevel=o);}else e==="--print-logs"?n.printLogs=true:e==="--debug"&&(n.debug=true);}return n}async function N(){let t=process.argv.slice(2),n=E(),{loadEnv:i}=await import('@easbot/utils');i(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let e=A(t),{Log:o}=await import('@easbot/utils'),{getXdgData:r}=await import('./chunks/interfaces-LPJU4KS3.mjs'),d=join(r(),"memory","log");if(await o.init({logDir:d,print:e.printLogs,dev:e.debug||false,level:e.logLevel}),t.length===0){let{renderBanner:l}=await import('./chunks/cli-handler-5YNHYDSM.mjs');l();return}if(t[0]==="--help"||t[0]==="-h"){let{renderHelp:l}=await import('./chunks/cli-handler-5YNHYDSM.mjs');l();return}if(t[0]==="--version"||t[0]==="-v"){printHuman([formatInfo(n)]);return}let a=e.cwd??process.cwd(),{handleMemoryCli:m}=await import('./chunks/cli-handler-5YNHYDSM.mjs'),{setInstanceAdapter:h}=await import('./chunks/interfaces-LPJU4KS3.mjs');h({directory:a,worktree:a});let{Llm:u}=await import('./chunks/llm-UHTBU2HA.mjs'),{bootstrapLlm:w,setAdapterRegistry:L}=await import('@easbot/llm'),{getGlobal:s,getInstance:c}=await import('./chunks/interfaces-LPJU4KS3.mjs');L({config:void 0,instance:{getDirectory:()=>c().directory,getWorktree:()=>c().worktree},global:{home:s().Path.home,data:s().Path.data,cache:s().Path.cache,config:s().Path.config,state:s().Path.state,log:s().Path.log,bin:s().Path.bin},installation:{getVersion:()=>n,getChannel:()=>"local",getUserAgent:()=>`easbot-memory/${n}`}}),await w({target:u,cwd:a,subConfigPath:".easbot/memory.json",embedding:true,graph:true});let g=await m(t,{version:n,cwd:a});g.code!==0&&(process.exitCode=g.code);}N().catch(t=>{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,6 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use strict';require('./chunks/chunk-URADAZYW.cjs');var chunkAYGZUNFR_cjs=require('./chunks/chunk-AYGZUNFR.cjs'),chunkS6S35LDL_cjs=require('./chunks/chunk-S6S35LDL.cjs'),chunkZ5E4HBGK_cjs=require('./chunks/chunk-Z5E4HBGK.cjs'),chunkEGWJG65Q_cjs=require('./chunks/chunk-EGWJG65Q.cjs'),chunkCPRDIUQ4_cjs=require('./chunks/chunk-CPRDIUQ4.cjs'),chunkJ5XF2W4Z_cjs=require('./chunks/chunk-J5XF2W4Z.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 Oe=["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";}},P=class extends p{constructor(r,t){super(r,"MEMORY_VALIDATION_ERROR",t),this.name="MemoryValidationError";}},N=class extends p{constructor(r){super(`Memory not found: ${r}`,"MEMORY_NOT_FOUND"),this.name="MemoryNotFoundError";}},D=class extends p{constructor(r){super(r,"MEMORY_PERMISSION_ERROR"),this.name="MemoryPermissionError";}},T=class extends p{constructor(r,t){super(r,"MEMORY_DATABASE_ERROR",t),this.name="MemoryDatabaseError";}},v=class extends p{constructor(r,t){super(r,"MEMORY_FILE_ERROR",t),this.name="MemoryFileError";}},F=class extends p{constructor(r,t){super(r,"MEMORY_SEARCH_ERROR",t),this.name="MemorySearchError";}},L=class extends p{constructor(r,t){super(r,"MEMORY_EMBEDDING_ERROR",t),this.name="MemoryEmbeddingError";}},me=(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))(me||{});var s=utils.Log.create({service:"memory.tokenizer"}),l=false,ye=utils.loadTextFile("./assets/jieba_dict.txt",chunkNVGACA7W_cjs.b);async function ve(e){if(!l)try{s.debug("Initializing jieba tokenizer");let r=ye();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 Re(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 Re(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 ke(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 xe(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 Fe(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 Le(){return l}async function $e(){l=false,s.debug("Tokenizer closed");}function je(e){if(!l)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(!l)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 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:chunkZ5E4HBGK_cjs.w({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 chunkZ5E4HBGK_cjs.v("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 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 chunkZ5E4HBGK_cjs.v("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 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 chunkZ5E4HBGK_cjs.v("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
|
-
`)}`,logLine:`pre-compact: injected ${n.hits.length} facts before compaction`}}catch(n){return {ok:false,error:n instanceof Error?n.message:String(n)}}};var
|
|
6
|
-
`);try{return {ok:!0,logLine:`post-tool-failure: wrote error_pattern fact ${(await
|
|
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=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 chunkZ5E4HBGK_cjs.v("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 Ee(e){return g.delete(e)}function be(){return Array.from(g.values()).map(e=>({name:e.name,handler:e.handler,registeredAt:e.registeredAt}))}function Ie(){f("session-start",$),f("session-end",j),f("pre-compact",z),f("post-tool-failure",Y);}function Me(){g.clear(),u.debug("All hooks cleared");}async function _e(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,"COMMANDS_HELP",{enumerable:true,get:function(){return chunkAYGZUNFR_cjs.a}});Object.defineProperty(exports,"handleMemoryCli",{enumerable:true,get:function(){return chunkAYGZUNFR_cjs.d}});Object.defineProperty(exports,"renderBanner",{enumerable:true,get:function(){return chunkAYGZUNFR_cjs.b}});Object.defineProperty(exports,"renderHelp",{enumerable:true,get:function(){return chunkAYGZUNFR_cjs.c}});Object.defineProperty(exports,"MemoryStdioServer",{enumerable:true,get:function(){return chunkS6S35LDL_cjs.b}});Object.defineProperty(exports,"renderOperationMarkdown",{enumerable:true,get:function(){return chunkS6S35LDL_cjs.a}});Object.defineProperty(exports,"ALL_OPS",{enumerable:true,get:function(){return chunkZ5E4HBGK_cjs.u}});Object.defineProperty(exports,"GraphStore",{enumerable:true,get:function(){return chunkZ5E4HBGK_cjs.a}});Object.defineProperty(exports,"OP_REGISTRY",{enumerable:true,get:function(){return chunkZ5E4HBGK_cjs.t}});Object.defineProperty(exports,"consolidate",{enumerable:true,get:function(){return chunkZ5E4HBGK_cjs.n}});Object.defineProperty(exports,"doctor",{enumerable:true,get:function(){return chunkZ5E4HBGK_cjs.s}});Object.defineProperty(exports,"executeOp",{enumerable:true,get:function(){return chunkZ5E4HBGK_cjs.v}});Object.defineProperty(exports,"extract",{enumerable:true,get:function(){return chunkZ5E4HBGK_cjs.m}});Object.defineProperty(exports,"forget",{enumerable:true,get:function(){return chunkZ5E4HBGK_cjs.l}});Object.defineProperty(exports,"graphQuery",{enumerable:true,get:function(){return chunkZ5E4HBGK_cjs.p}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunkZ5E4HBGK_cjs.q}});Object.defineProperty(exports,"recall",{enumerable:true,get:function(){return chunkZ5E4HBGK_cjs.b}});Object.defineProperty(exports,"remember",{enumerable:true,get:function(){return chunkZ5E4HBGK_cjs.k}});Object.defineProperty(exports,"status",{enumerable:true,get:function(){return chunkZ5E4HBGK_cjs.r}});Object.defineProperty(exports,"sync",{enumerable:true,get:function(){return chunkZ5E4HBGK_cjs.o}});Object.defineProperty(exports,"LATEST_SCHEMA_VERSION",{enumerable:true,get:function(){return chunkEGWJG65Q_cjs.a}});Object.defineProperty(exports,"MIGRATIONS",{enumerable:true,get:function(){return chunkEGWJG65Q_cjs.b}});Object.defineProperty(exports,"MemoryDatabaseManager",{enumerable:true,get:function(){return chunkEGWJG65Q_cjs.e}});Object.defineProperty(exports,"readCurrentSchemaVersion",{enumerable:true,get:function(){return chunkEGWJG65Q_cjs.d}});Object.defineProperty(exports,"runMigrations",{enumerable:true,get:function(){return chunkEGWJG65Q_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=Oe;exports.MemoryDatabaseError=T;exports.MemoryEmbeddingError=L;exports.MemoryError=p;exports.MemoryErrorCode=me;exports.MemoryFileError=v;exports.MemoryNotFoundError=N;exports.MemoryPermissionError=D;exports.MemorySearchError=F;exports.MemoryValidationError=P;exports.addWord=Fe;exports.clearAllHooks=Me;exports.closeTokenizer=$e;exports.dispatchHook=_e;exports.initTokenizer=ve;exports.isInitialized=Le;exports.listHooks=be;exports.loadCustomDict=Re;exports.registerAllDefaultHooks=Ie;exports.registerHook=f;exports.toFtsTokens=je;exports.toFtsTokensForSearch=ze;exports.tokenize=ke;exports.tokenizeForSearch=xe;exports.unregisterHook=Ee;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { KnowledgeSearchOptions, MemoryKnowledgeConfigWithModels, IGlobal, IInstance } from '@easbot/types';
|
|
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
3
|
import { EmbeddingModel, LanguageModel } from 'ai';
|
|
4
4
|
export { EmbeddingModel, LanguageModel } from 'ai';
|
|
5
|
-
import {
|
|
5
|
+
import { ILLMInitConfig, ILLMCapabilities } from '@easbot/llm';
|
|
6
6
|
import { ZodTypeAny } from 'zod';
|
|
7
7
|
import { StdioServerConfig } from '@easbot/mcp';
|
|
8
8
|
import { SyncSqliteConnection } from '@easbot/database';
|
|
@@ -158,35 +158,27 @@ interface LlmModels {
|
|
|
158
158
|
embeddingLlm?: EmbeddingModel;
|
|
159
159
|
graphLlm?: LanguageModel;
|
|
160
160
|
}
|
|
161
|
-
interface
|
|
162
|
-
maxOutputTokens?: number;
|
|
163
|
-
temperature?: number;
|
|
164
|
-
}
|
|
165
|
-
interface LlmInitConfig {
|
|
166
|
-
models: LlmModels;
|
|
161
|
+
interface LlmInitConfig extends ILLMInitConfig {
|
|
167
162
|
options?: {
|
|
168
|
-
graph?:
|
|
169
|
-
|
|
163
|
+
graph?: {
|
|
164
|
+
maxOutputTokens?: number;
|
|
165
|
+
temperature?: number;
|
|
166
|
+
};
|
|
167
|
+
embedding?: {
|
|
168
|
+
maxOutputTokens?: number;
|
|
169
|
+
temperature?: number;
|
|
170
|
+
};
|
|
170
171
|
};
|
|
171
172
|
}
|
|
172
173
|
declare namespace Llm {
|
|
173
|
-
function init(config:
|
|
174
|
+
function init(config: ILLMInitConfig): void;
|
|
174
175
|
function isInitialized(): boolean;
|
|
175
176
|
function reset(): void;
|
|
176
|
-
function capabilities():
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
};
|
|
177
|
+
function capabilities(): ILLMCapabilities;
|
|
178
|
+
function getEmbeddingLlm(): EmbeddingModel | undefined;
|
|
179
|
+
function getGraphLlm(): LanguageModel | undefined;
|
|
180
180
|
function embedText(value: string): Promise<Float32Array>;
|
|
181
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
182
|
const embed: typeof embedText;
|
|
191
183
|
const embedMany: typeof embedTexts;
|
|
192
184
|
}
|
|
@@ -243,6 +235,8 @@ interface RememberResult {
|
|
|
243
235
|
nodeIds?: number[];
|
|
244
236
|
vectorsWritten: number;
|
|
245
237
|
vectorDims: number;
|
|
238
|
+
entitiesExtracted: number;
|
|
239
|
+
relationsExtracted: number;
|
|
246
240
|
}
|
|
247
241
|
interface ForgetParams {
|
|
248
242
|
factId?: string;
|
|
@@ -315,29 +309,37 @@ interface GraphQueryResult {
|
|
|
315
309
|
durationMs: number;
|
|
316
310
|
}
|
|
317
311
|
type StatusParams = {};
|
|
318
|
-
interface StatusResult {
|
|
319
|
-
dbPath: string;
|
|
320
|
-
workspaceDir: string;
|
|
312
|
+
interface StatusResult extends MemoryStatus {
|
|
321
313
|
factsCount: number;
|
|
322
314
|
nodesCount: number;
|
|
323
315
|
edgesCount: number;
|
|
324
316
|
factsByCategory: Record<MemoryCategory, number>;
|
|
325
317
|
ftsAvailable: boolean;
|
|
326
|
-
vectorEnabled: boolean;
|
|
327
|
-
kgScopeEnabled: boolean;
|
|
328
|
-
healthy: boolean;
|
|
329
|
-
meta: Record<string, string>;
|
|
330
318
|
}
|
|
331
319
|
type DoctorParams = {};
|
|
332
|
-
interface DoctorResult {
|
|
333
|
-
|
|
334
|
-
checks: Array<{
|
|
320
|
+
interface DoctorResult extends KnowledgeDoctorResult {
|
|
321
|
+
legacyChecks: Array<{
|
|
335
322
|
name: string;
|
|
336
323
|
passed: boolean;
|
|
337
324
|
message: string;
|
|
338
325
|
details?: Record<string, unknown>;
|
|
339
|
-
severity?: 'error' | 'info';
|
|
326
|
+
severity?: 'error' | 'info' | 'warn' | 'ok';
|
|
340
327
|
}>;
|
|
328
|
+
integrityStats?: {
|
|
329
|
+
memory_facts: number;
|
|
330
|
+
memory_vectors: number;
|
|
331
|
+
embedding_cache: number;
|
|
332
|
+
memory_facts_fts: number;
|
|
333
|
+
nodes: number;
|
|
334
|
+
edges: number;
|
|
335
|
+
meta: number;
|
|
336
|
+
schema_migrations: number;
|
|
337
|
+
};
|
|
338
|
+
backendAvailable?: {
|
|
339
|
+
'better-sqlite3': boolean;
|
|
340
|
+
'node:sqlite': boolean;
|
|
341
|
+
'@tursodatabase/database': boolean;
|
|
342
|
+
};
|
|
341
343
|
}
|
|
342
344
|
interface InitParams {
|
|
343
345
|
dbPath?: string;
|
|
@@ -349,12 +351,33 @@ interface InitResult {
|
|
|
349
351
|
initialized: boolean;
|
|
350
352
|
dbPath: string;
|
|
351
353
|
configPath: string;
|
|
354
|
+
schemaVersion: number;
|
|
352
355
|
workspaceDir: string;
|
|
353
356
|
tablesCreated: number;
|
|
354
357
|
migrationsApplied: number;
|
|
355
358
|
durationMs: number;
|
|
356
359
|
configCreated: boolean;
|
|
357
360
|
}
|
|
361
|
+
interface SyncParams {
|
|
362
|
+
windowDays?: number;
|
|
363
|
+
dryRun?: boolean;
|
|
364
|
+
}
|
|
365
|
+
interface SyncResult {
|
|
366
|
+
generatedCount: number;
|
|
367
|
+
skippedCount: number;
|
|
368
|
+
failedGenerateCount: number;
|
|
369
|
+
archivedCount: number;
|
|
370
|
+
archiveThreshold: string;
|
|
371
|
+
archivedRecords: Array<{
|
|
372
|
+
source: string;
|
|
373
|
+
target: string;
|
|
374
|
+
firstCreatedAt: string;
|
|
375
|
+
firstFactId: string;
|
|
376
|
+
}>;
|
|
377
|
+
windowDays: number;
|
|
378
|
+
dryRun: boolean;
|
|
379
|
+
durationMs: number;
|
|
380
|
+
}
|
|
358
381
|
|
|
359
382
|
declare function recall(ctx: MemoryServiceContext, params: RecallParams): Promise<RecallResult>;
|
|
360
383
|
|
|
@@ -366,11 +389,21 @@ declare function extract(ctx: MemoryServiceContext, params: ExtractParams): Prom
|
|
|
366
389
|
|
|
367
390
|
declare function consolidate(ctx: MemoryServiceContext, params?: ConsolidateParams): Promise<ConsolidateResult>;
|
|
368
391
|
|
|
392
|
+
declare function sync(ctx: MemoryServiceContext, params?: SyncParams): Promise<SyncResult>;
|
|
393
|
+
|
|
369
394
|
declare function graphQuery(ctx: MemoryServiceContext, params: GraphQueryParams): Promise<GraphQueryResult>;
|
|
370
395
|
|
|
371
|
-
|
|
396
|
+
interface StatusOptions {
|
|
397
|
+
skipEmbeddingProbe?: boolean;
|
|
398
|
+
skipLlm?: boolean;
|
|
399
|
+
}
|
|
400
|
+
declare function status(ctx: MemoryServiceContext, _params?: StatusParams, options?: StatusOptions): Promise<StatusResult>;
|
|
372
401
|
|
|
373
|
-
|
|
402
|
+
interface DoctorOptions {
|
|
403
|
+
skipEmbeddingProbe?: boolean;
|
|
404
|
+
skipLlm?: boolean;
|
|
405
|
+
}
|
|
406
|
+
declare function doctor(ctx: MemoryServiceContext, _params?: DoctorParams, options?: DoctorOptions): Promise<DoctorResult>;
|
|
374
407
|
|
|
375
408
|
declare function init(ctx: MemoryServiceContext, params?: InitParams): Promise<InitResult>;
|
|
376
409
|
|
|
@@ -480,7 +513,7 @@ declare function getMemoryDbPath(input?: string | {
|
|
|
480
513
|
}): string;
|
|
481
514
|
|
|
482
515
|
type MigrationDb = SyncSqliteConnection;
|
|
483
|
-
declare const LATEST_SCHEMA_VERSION =
|
|
516
|
+
declare const LATEST_SCHEMA_VERSION = 1;
|
|
484
517
|
interface SchemaMigration {
|
|
485
518
|
id: number;
|
|
486
519
|
description: string;
|
|
@@ -532,6 +565,22 @@ declare class MemoryDatabaseManager {
|
|
|
532
565
|
getSchemaVersion(): number;
|
|
533
566
|
close(): void;
|
|
534
567
|
healthCheck(): boolean;
|
|
568
|
+
checkIntegrity(): {
|
|
569
|
+
issues: Array<{
|
|
570
|
+
severity: 'error' | 'warn' | 'info';
|
|
571
|
+
message: string;
|
|
572
|
+
}>;
|
|
573
|
+
stats: {
|
|
574
|
+
memory_facts: number;
|
|
575
|
+
memory_vectors: number;
|
|
576
|
+
embedding_cache: number;
|
|
577
|
+
memory_facts_fts: number;
|
|
578
|
+
nodes: number;
|
|
579
|
+
edges: number;
|
|
580
|
+
meta: number;
|
|
581
|
+
schema_migrations: number;
|
|
582
|
+
};
|
|
583
|
+
};
|
|
535
584
|
getMeta(key: string): string | null;
|
|
536
585
|
setMeta(key: string, value: string): void;
|
|
537
586
|
}
|
|
@@ -581,4 +630,4 @@ declare function registerAllDefaultHooks(): void;
|
|
|
581
630
|
declare function clearAllHooks(): void;
|
|
582
631
|
declare function dispatchHook(name: HookName, ctx: HookContext): Promise<HookResult>;
|
|
583
632
|
|
|
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,
|
|
633
|
+
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, 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 };
|