@easbot/memory 0.3.16 → 0.3.19
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 +200 -19
- package/README.md +210 -25
- package/dist/chunks/chunk-4GSXSIV5.cjs +1 -0
- package/dist/chunks/chunk-5Q6SIVSP.cjs +50 -0
- package/dist/chunks/chunk-6CQMBEIQ.mjs +1 -0
- package/dist/chunks/chunk-746FKSL5.mjs +50 -0
- package/dist/chunks/chunk-ARA4LMAI.mjs +1 -0
- package/dist/chunks/chunk-CN6WBJLX.mjs +60 -0
- package/dist/chunks/chunk-CPRDIUQ4.cjs +1 -0
- package/dist/chunks/chunk-EGWJG65Q.cjs +71 -0
- package/dist/chunks/chunk-HQBRVVXS.mjs +1 -0
- package/dist/chunks/chunk-J5XF2W4Z.cjs +1 -0
- package/dist/chunks/chunk-JDPZ5U53.mjs +71 -0
- package/dist/chunks/chunk-NVGACA7W.cjs +1 -0
- package/dist/chunks/chunk-QHPGDNEG.cjs +1 -0
- package/dist/chunks/{chunk-FNT7WEHL.mjs → chunk-QYBWHFOX.mjs} +1 -1
- package/dist/chunks/chunk-SWYQLQ7Z.mjs +1 -0
- package/dist/chunks/{chunk-YHOJKRHE.mjs → chunk-WDVDYZ25.mjs} +1 -1
- package/dist/chunks/chunk-WQB4D6DZ.cjs +1 -0
- package/dist/chunks/chunk-X66LENNV.cjs +60 -0
- package/dist/chunks/cli-handler-CN4Q7BCY.mjs +1 -0
- package/dist/chunks/cli-handler-IRPYADZF.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-PUOAAQN3.cjs +2 -0
- package/dist/chunks/consolidate-UEYNLKQN.mjs +2 -0
- package/dist/chunks/doctor-KPAZWVVZ.mjs +1 -0
- package/dist/chunks/doctor-U4HOSXGW.cjs +1 -0
- package/dist/chunks/extract-7FFIDVG3.cjs +2 -0
- package/dist/chunks/extract-EOZJMLTP.mjs +2 -0
- package/dist/chunks/forget-5AXV3GHW.mjs +3 -0
- package/dist/chunks/forget-GBMYCUPJ.cjs +3 -0
- package/dist/chunks/graph-KOJYJTA4.cjs +3 -0
- package/dist/chunks/graph-Y6AYRFCN.mjs +3 -0
- package/dist/chunks/init-B24TNUSD.cjs +1 -0
- package/dist/chunks/init-HGEBZTJW.mjs +1 -0
- package/dist/chunks/{interfaces-VBO3Z6QF.mjs → interfaces-LPJU4KS3.mjs} +1 -1
- package/dist/chunks/interfaces-XWE45ENK.cjs +1 -0
- package/dist/chunks/llm-RMPVWEVP.cjs +1 -0
- package/dist/chunks/llm-UHTBU2HA.mjs +1 -0
- package/dist/chunks/mcp-BMAB3TT7.mjs +1 -0
- package/dist/chunks/mcp-BS6XHEBR.cjs +1 -0
- package/dist/chunks/recall-LKETADTB.cjs +2 -0
- package/dist/chunks/recall-UPGGKBNX.mjs +2 -0
- package/dist/chunks/remember-KCQN2UWN.mjs +2 -0
- package/dist/chunks/remember-VZF4O7ZF.cjs +2 -0
- package/dist/chunks/status-2BFVXY5J.cjs +1 -0
- package/dist/chunks/status-HGN2YLKJ.mjs +1 -0
- package/dist/chunks/stdio-server-GABA2MLR.cjs +1 -0
- package/dist/chunks/stdio-server-JPMLMEWY.mjs +1 -0
- package/dist/chunks/sync-7Y2DEDDW.mjs +2 -0
- package/dist/chunks/sync-W5A2O5TS.cjs +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 +119 -21
- package/dist/index.d.ts +119 -21
- package/dist/index.mjs +4 -4
- package/package.json +10 -9
- package/dist/chunks/chunk-3HTZTI7U.cjs +0 -1
- package/dist/chunks/chunk-5W4K5UKV.mjs +0 -53
- package/dist/chunks/chunk-7XEOH55R.cjs +0 -1
- package/dist/chunks/chunk-BWPPLYIF.cjs +0 -1
- package/dist/chunks/chunk-FEMOFIOS.mjs +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-NJVXQ7TV.cjs +0 -1
- package/dist/chunks/chunk-OWLFPNZG.cjs +0 -1
- package/dist/chunks/chunk-PWLSQFYA.mjs +0 -32
- package/dist/chunks/chunk-Q2MKNRER.cjs +0 -53
- 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,71 @@
|
|
|
1
|
+
'use strict';var chunkNVGACA7W_cjs=require('./chunk-NVGACA7W.cjs'),utils=require('@easbot/utils'),database=require('@easbot/database');var T=utils.Log.create({service:"memory-schema-migrations"}),m=1,f=[{id:1,description:"v1 baseline: memory_facts / memory_vectors / embedding_cache / memory_facts_fts / nodes / edges / meta\uFF08\u4E0E v0.3.x createTables \u8F93\u51FA\u5BF9\u9F50\uFF0C\u8001 db \u8DD1\u8BE5\u8FC1\u79FB\u4E0D\u7834\u574F\u73B0\u6709\u8868\uFF09",up:[`CREATE TABLE IF NOT EXISTS memory_facts (
|
|
2
|
+
id TEXT PRIMARY KEY,
|
|
3
|
+
agent_id TEXT NOT NULL,
|
|
4
|
+
session_id TEXT,
|
|
5
|
+
msg_id TEXT,
|
|
6
|
+
parent_msg_id TEXT,
|
|
7
|
+
content TEXT NOT NULL,
|
|
8
|
+
category TEXT NOT NULL,
|
|
9
|
+
importance INTEGER NOT NULL CHECK(importance >= 1 AND importance <= 10),
|
|
10
|
+
source TEXT NOT NULL CHECK(source IN ('session_self_write', 'historical')),
|
|
11
|
+
tags TEXT,
|
|
12
|
+
node_ids TEXT,
|
|
13
|
+
file_path TEXT,
|
|
14
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
15
|
+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
16
|
+
UNIQUE(session_id, msg_id)
|
|
17
|
+
)`,"CREATE INDEX IF NOT EXISTS idx_memory_facts_agent_id ON memory_facts(agent_id)","CREATE INDEX IF NOT EXISTS idx_memory_facts_agent_category ON memory_facts(agent_id, category)","CREATE INDEX IF NOT EXISTS idx_memory_facts_agent_importance ON memory_facts(agent_id, importance DESC)","CREATE INDEX IF NOT EXISTS idx_memory_facts_created_at ON memory_facts(created_at)",`CREATE TABLE IF NOT EXISTS memory_vectors (
|
|
18
|
+
fact_id TEXT PRIMARY KEY,
|
|
19
|
+
embedding BLOB NOT NULL,
|
|
20
|
+
FOREIGN KEY (fact_id) REFERENCES memory_facts(id) ON DELETE CASCADE
|
|
21
|
+
)`,`CREATE TABLE IF NOT EXISTS embedding_cache (
|
|
22
|
+
content_hash TEXT PRIMARY KEY,
|
|
23
|
+
embedding BLOB NOT NULL,
|
|
24
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
25
|
+
)`,`CREATE VIRTUAL TABLE IF NOT EXISTS memory_facts_fts USING fts5(
|
|
26
|
+
fact_id UNINDEXED,
|
|
27
|
+
agent_id UNINDEXED,
|
|
28
|
+
content,
|
|
29
|
+
tags,
|
|
30
|
+
tokenize='porter unicode61'
|
|
31
|
+
)`,`CREATE TABLE IF NOT EXISTS nodes (
|
|
32
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
33
|
+
name TEXT NOT NULL,
|
|
34
|
+
type TEXT NOT NULL,
|
|
35
|
+
owner_agent_id TEXT,
|
|
36
|
+
properties TEXT,
|
|
37
|
+
createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
38
|
+
updatedAt DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
39
|
+
)`,"CREATE INDEX IF NOT EXISTS idx_nodes_name ON nodes(name)","CREATE INDEX IF NOT EXISTS idx_nodes_type ON nodes(type)","CREATE INDEX IF NOT EXISTS idx_nodes_owner_agent_id ON nodes(owner_agent_id)","CREATE UNIQUE INDEX IF NOT EXISTS idx_nodes_name_type ON nodes(name, type)",`CREATE TABLE IF NOT EXISTS edges (
|
|
40
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
41
|
+
source INTEGER NOT NULL,
|
|
42
|
+
target INTEGER NOT NULL,
|
|
43
|
+
relation TEXT NOT NULL,
|
|
44
|
+
properties TEXT,
|
|
45
|
+
createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
46
|
+
FOREIGN KEY (source) REFERENCES nodes(id) ON DELETE CASCADE,
|
|
47
|
+
FOREIGN KEY (target) REFERENCES nodes(id) ON DELETE CASCADE
|
|
48
|
+
)`,"CREATE INDEX IF NOT EXISTS idx_edges_source ON edges(source)","CREATE INDEX IF NOT EXISTS idx_edges_target ON edges(target)","CREATE INDEX IF NOT EXISTS idx_edges_relation ON edges(relation)","CREATE UNIQUE INDEX IF NOT EXISTS idx_edges_unique ON edges(source, target, relation)",`CREATE TABLE IF NOT EXISTS meta (
|
|
49
|
+
key TEXT PRIMARY KEY,
|
|
50
|
+
value TEXT
|
|
51
|
+
)`]}];function p(n,e=m,t={}){n.exec(`CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
52
|
+
id INTEGER PRIMARY KEY,
|
|
53
|
+
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
54
|
+
)`);let r=n.prepare("SELECT id FROM schema_migrations").all(),s=new Set(r.map(i=>i.id)),a={applied:[],pending:[],errors:[],currentVersion:r.length===0?0:Math.max(...r.map(i=>i.id)),targetVersion:e};for(let i of f){if(i.id>e)break;if(s.has(i.id)){a.pending.push(i.id);continue}if(t.dryRun){a.applied.push(i.id);continue}try{R(n,i.up),n.prepare("INSERT INTO schema_migrations (id) VALUES (?)").run(i.id),s.add(i.id),a.applied.push(i.id),T.info("migration applied",{id:i.id,description:i.description});}catch(o){let d=o instanceof Error?o.message:String(o),c=i.up[0]??"";a.errors.push({migrationId:i.id,sql:c,error:d}),T.warn("migration step failed",{id:i.id,error:d,sqlCount:i.up.length});}}return a}function R(n,e){for(let t of e)try{n.exec(t);}catch(r){let s=r instanceof Error?r.message:String(r);if(C(s)){T.debug("migration: column already exists, skipping",{sql:t.slice(0,80)});continue}throw r}}function C(n){return /duplicate column name/i.test(n)}function u(n){try{let e=n.prepare("SELECT id FROM schema_migrations").all();return e.length===0?0:Math.max(...e.map(t=>t.id))}catch{return 0}}var l=utils.Log.create({service:"memory-database"}),h=class{constructor(e){chunkNVGACA7W_cjs.a(this,"db",null);chunkNVGACA7W_cjs.a(this,"storagePath");chunkNVGACA7W_cjs.a(this,"backend","better-sqlite3");chunkNVGACA7W_cjs.a(this,"initialized",false);chunkNVGACA7W_cjs.a(this,"initPromise",null);this.storagePath=e===":memory:"?e:utils.Filesystem.normalize(e);}async initialize(){if(!this.initialized){if(this.initPromise){await this.initPromise;return}this.initPromise=this.doInitialize();try{await this.initPromise,this.initialized=!0;}catch(e){try{this.db&&this.db.close();}catch{}throw this.db=null,this.initPromise=null,e}}}async doInitialize(){try{let e=this.openConnection();e.initialize(),this.db=e,this.applyPragmas(),this.runAllMigrations();}catch(e){let t=e instanceof Error?e.message:String(e);throw l.error("Database initialization failed",{error:t}),e}}openConnection(){return database.createSyncSqliteConnection({path:this.storagePath,backend:this.backend,walMode:true,foreignKeys:true,busyTimeoutMs:5e3})}applyPragmas(){if(this.db)try{this.db.pragma("synchronous = NORMAL"),this.db.pragma("cache_size = -64000"),this.db.pragma("temp_store = MEMORY"),this.db.pragma("foreign_keys = ON");}catch(e){l.warn("Failed to apply memory PRAGMAs",{error:String(e)});}}runAllMigrations(){if(!this.db)throw new Error("Database not initialized");let e=p(this.db,m);if(e.errors.length>0){let t=e.errors.map(r=>`migration ${r.migrationId}: ${r.error}`).join("; ");throw new Error(`Some migrations failed: ${t}`)}}query(e,t){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");try{let r=this.db.prepare(e);return t?r.all(...t):r.all()}catch(r){throw new Error(`Query failed: ${r.message}`)}}agentFilter(e){return typeof e=="string"&&e.trim().length>0?{where:"WHERE agent_id = ?",params:[e.trim()]}:{where:"",params:[]}}run(e,t){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");try{let r=this.db.prepare(e),s=t?r.run(...t):r.run();return {lastID:Number(s.lastInsertRowid),changes:s.changes}}catch(r){throw new Error(`Write failed: ${r.message}`)}}transaction(e){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");return this.db.transaction(e)()}prepare(e){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");return this.db.prepare(e)}exec(e){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");this.db.exec(e);}getDb(){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");return this.db}getPath(){return this.storagePath}getSchemaVersion(){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");return u(this.db)}close(){if(this.db){try{this.db.close();}catch(e){l.warn("Failed to close memory database",{error:String(e)});}this.db=null,this.initialized=false,this.initPromise=null;}}healthCheck(){try{return this.db?(this.db.exec("SELECT 1"),!0):!1}catch{return false}}checkIntegrity(){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");let e=N=>this.db.prepare(N).get().c,t={memory_facts:e("SELECT COUNT(*) as c FROM memory_facts"),memory_vectors:e("SELECT COUNT(*) as c FROM memory_vectors"),embedding_cache:e("SELECT COUNT(*) as c FROM embedding_cache"),memory_facts_fts:e("SELECT COUNT(*) as c FROM memory_facts_fts"),nodes:e("SELECT COUNT(*) as c FROM nodes"),edges:e("SELECT COUNT(*) as c FROM edges"),meta:e("SELECT COUNT(*) as c FROM meta"),schema_migrations:e("SELECT COUNT(*) as c FROM schema_migrations")},r=[],s=e(`
|
|
55
|
+
SELECT COUNT(*) as c FROM (
|
|
56
|
+
SELECT mf.id, JSON_EACH.value AS node_id
|
|
57
|
+
FROM memory_facts mf, JSON_EACH(mf.node_ids)
|
|
58
|
+
WHERE mf.node_ids IS NOT NULL
|
|
59
|
+
) LEFT JOIN nodes n ON n.id = CAST(node_id AS INTEGER)
|
|
60
|
+
WHERE n.id IS NULL
|
|
61
|
+
`);s>0&&r.push({severity:"error",message:`orphan node references (fact.nodeIds): ${s}`});let a=e(`
|
|
62
|
+
SELECT COUNT(*) as c FROM edges e WHERE NOT EXISTS (SELECT 1 FROM nodes n WHERE n.id = e.source)
|
|
63
|
+
`);a>0&&r.push({severity:"error",message:`orphan edges (source): ${a}`});let i=e(`
|
|
64
|
+
SELECT COUNT(*) as c FROM edges e WHERE NOT EXISTS (SELECT 1 FROM nodes n WHERE n.id = e.target)
|
|
65
|
+
`);i>0&&r.push({severity:"error",message:`orphan edges (target): ${i}`});let o=e("SELECT COUNT(*) as c FROM edges WHERE source = target");o>0&&r.push({severity:"warn",message:`self-loop edges: ${o}`});let d=e(`
|
|
66
|
+
SELECT COUNT(*) as c FROM (
|
|
67
|
+
SELECT fact_id FROM memory_facts_fts
|
|
68
|
+
EXCEPT
|
|
69
|
+
SELECT id FROM memory_facts
|
|
70
|
+
)
|
|
71
|
+
`);d>0&&r.push({severity:"warn",message:`FTS out of sync (orphan entries): ${d}`});let c=e("SELECT COUNT(*) as c FROM (SELECT id, COUNT(*) as c FROM memory_facts GROUP BY id HAVING c > 1)");c>0&&r.push({severity:"error",message:`duplicate fact ids: ${c}`});let g=e("SELECT COUNT(*) as c FROM memory_facts WHERE content IS NULL OR content = ''");return g>0&&r.push({severity:"error",message:`memory_facts with null/empty content: ${g}`}),{issues:r,stats:t}}getMeta(e){if(!this.db)throw new Error("Database not initialized");return this.db.prepare("SELECT value FROM meta WHERE key = ?").get(e)?.value??null}setMeta(e,t){if(!this.db)throw new Error("Database not initialized");this.db.prepare("INSERT OR REPLACE INTO meta (key, value) VALUES (?, ?)").run(e,t);}};exports.a=m;exports.b=f;exports.c=p;exports.d=u;exports.e=h;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.defineProperty;var e=(b,a,c)=>a in b?d(b,a,{enumerable:true,configurable:true,writable:true,value:c}):b[a]=c;var f=(b,a,c)=>e(b,typeof a!="symbol"?a+"":a,c);export{f as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var ai=require('ai'),utils=require('@easbot/utils');exports.a=void 0;(a=>{let s=utils.Log.create({service:"memory-llm"}),e=null;function f(n){if(g())return;let r=n;e={models:r.models,options:r.options??{}},s.debug("Llm initialized",{embeddingConfigured:!!r.models.embeddingLlm,graphConfigured:!!r.models.graphLlm});}a.init=f;function g(){return e!==null}a.isInitialized=g;function y(){e=null;}a.reset=y;function x(){return e?{embedding:!!e.models.embeddingLlm,graphLlm:!!e.models.graphLlm}:{embedding:false,graphLlm:false}}a.capabilities=x;function w(){return e?.models.embeddingLlm}a.getEmbeddingLlm=w;function I(){return e?.models.graphLlm}a.getGraphLlm=I;async function u(n){let t=l().models.embeddingLlm;if(!t)throw new Error("embeddingLlm model is not configured.");try{let o=await ai.embed({model:t,value:n});return new Float32Array(o.embedding)}catch(o){let i=t.doEmbed;if(typeof i!="function")throw new Error("embeddingLlm model does not support embedding generation.",{cause:o});let d=(await i({values:[n]}))?.embeddings?.[0];if(!d||!Array.isArray(d))throw new Error("embeddingLlm model returned invalid embedding result.",{cause:o});return new Float32Array(d)}}a.embedText=u;async function b(n){let t=l().models.embeddingLlm;if(!t)throw new Error("embeddingLlm model is not configured.");try{return (await ai.embedMany({model:t,values:n})).embeddings.map(i=>new Float32Array(i))}catch{return ((await t.doEmbed?.({values:n}))?.embeddings??[]).map(i=>new Float32Array(i))}}a.embedTexts=b;let l=()=>{if(!e)throw new Error("Llm is not initialized. Please call Llm.init() first.");return e};a.embed=u,a.embedMany=b;})(exports.a||(exports.a={}));var P=exports.a;exports.b=P;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {a}from'./chunk-HQBRVVXS.mjs';import {Log,Filesystem}from'@easbot/utils';import {createSyncSqliteConnection}from'@easbot/database';var T=Log.create({service:"memory-schema-migrations"}),m=1,R=[{id:1,description:"v1 baseline: memory_facts / memory_vectors / embedding_cache / memory_facts_fts / nodes / edges / meta\uFF08\u4E0E v0.3.x createTables \u8F93\u51FA\u5BF9\u9F50\uFF0C\u8001 db \u8DD1\u8BE5\u8FC1\u79FB\u4E0D\u7834\u574F\u73B0\u6709\u8868\uFF09",up:[`CREATE TABLE IF NOT EXISTS memory_facts (
|
|
2
|
+
id TEXT PRIMARY KEY,
|
|
3
|
+
agent_id TEXT NOT NULL,
|
|
4
|
+
session_id TEXT,
|
|
5
|
+
msg_id TEXT,
|
|
6
|
+
parent_msg_id TEXT,
|
|
7
|
+
content TEXT NOT NULL,
|
|
8
|
+
category TEXT NOT NULL,
|
|
9
|
+
importance INTEGER NOT NULL CHECK(importance >= 1 AND importance <= 10),
|
|
10
|
+
source TEXT NOT NULL CHECK(source IN ('session_self_write', 'historical')),
|
|
11
|
+
tags TEXT,
|
|
12
|
+
node_ids TEXT,
|
|
13
|
+
file_path TEXT,
|
|
14
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
15
|
+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
16
|
+
UNIQUE(session_id, msg_id)
|
|
17
|
+
)`,"CREATE INDEX IF NOT EXISTS idx_memory_facts_agent_id ON memory_facts(agent_id)","CREATE INDEX IF NOT EXISTS idx_memory_facts_agent_category ON memory_facts(agent_id, category)","CREATE INDEX IF NOT EXISTS idx_memory_facts_agent_importance ON memory_facts(agent_id, importance DESC)","CREATE INDEX IF NOT EXISTS idx_memory_facts_created_at ON memory_facts(created_at)",`CREATE TABLE IF NOT EXISTS memory_vectors (
|
|
18
|
+
fact_id TEXT PRIMARY KEY,
|
|
19
|
+
embedding BLOB NOT NULL,
|
|
20
|
+
FOREIGN KEY (fact_id) REFERENCES memory_facts(id) ON DELETE CASCADE
|
|
21
|
+
)`,`CREATE TABLE IF NOT EXISTS embedding_cache (
|
|
22
|
+
content_hash TEXT PRIMARY KEY,
|
|
23
|
+
embedding BLOB NOT NULL,
|
|
24
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
25
|
+
)`,`CREATE VIRTUAL TABLE IF NOT EXISTS memory_facts_fts USING fts5(
|
|
26
|
+
fact_id UNINDEXED,
|
|
27
|
+
agent_id UNINDEXED,
|
|
28
|
+
content,
|
|
29
|
+
tags,
|
|
30
|
+
tokenize='porter unicode61'
|
|
31
|
+
)`,`CREATE TABLE IF NOT EXISTS nodes (
|
|
32
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
33
|
+
name TEXT NOT NULL,
|
|
34
|
+
type TEXT NOT NULL,
|
|
35
|
+
owner_agent_id TEXT,
|
|
36
|
+
properties TEXT,
|
|
37
|
+
createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
38
|
+
updatedAt DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
39
|
+
)`,"CREATE INDEX IF NOT EXISTS idx_nodes_name ON nodes(name)","CREATE INDEX IF NOT EXISTS idx_nodes_type ON nodes(type)","CREATE INDEX IF NOT EXISTS idx_nodes_owner_agent_id ON nodes(owner_agent_id)","CREATE UNIQUE INDEX IF NOT EXISTS idx_nodes_name_type ON nodes(name, type)",`CREATE TABLE IF NOT EXISTS edges (
|
|
40
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
41
|
+
source INTEGER NOT NULL,
|
|
42
|
+
target INTEGER NOT NULL,
|
|
43
|
+
relation TEXT NOT NULL,
|
|
44
|
+
properties TEXT,
|
|
45
|
+
createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
46
|
+
FOREIGN KEY (source) REFERENCES nodes(id) ON DELETE CASCADE,
|
|
47
|
+
FOREIGN KEY (target) REFERENCES nodes(id) ON DELETE CASCADE
|
|
48
|
+
)`,"CREATE INDEX IF NOT EXISTS idx_edges_source ON edges(source)","CREATE INDEX IF NOT EXISTS idx_edges_target ON edges(target)","CREATE INDEX IF NOT EXISTS idx_edges_relation ON edges(relation)","CREATE UNIQUE INDEX IF NOT EXISTS idx_edges_unique ON edges(source, target, relation)",`CREATE TABLE IF NOT EXISTS meta (
|
|
49
|
+
key TEXT PRIMARY KEY,
|
|
50
|
+
value TEXT
|
|
51
|
+
)`]}];function p(n,e=m,t={}){n.exec(`CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
52
|
+
id INTEGER PRIMARY KEY,
|
|
53
|
+
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
54
|
+
)`);let r=n.prepare("SELECT id FROM schema_migrations").all(),s=new Set(r.map(i=>i.id)),a={applied:[],pending:[],errors:[],currentVersion:r.length===0?0:Math.max(...r.map(i=>i.id)),targetVersion:e};for(let i of R){if(i.id>e)break;if(s.has(i.id)){a.pending.push(i.id);continue}if(t.dryRun){a.applied.push(i.id);continue}try{C(n,i.up),n.prepare("INSERT INTO schema_migrations (id) VALUES (?)").run(i.id),s.add(i.id),a.applied.push(i.id),T.info("migration applied",{id:i.id,description:i.description});}catch(o){let d=o instanceof Error?o.message:String(o),c=i.up[0]??"";a.errors.push({migrationId:i.id,sql:c,error:d}),T.warn("migration step failed",{id:i.id,error:d,sqlCount:i.up.length});}}return a}function C(n,e){for(let t of e)try{n.exec(t);}catch(r){let s=r instanceof Error?r.message:String(r);if(I(s)){T.debug("migration: column already exists, skipping",{sql:t.slice(0,80)});continue}throw r}}function I(n){return /duplicate column name/i.test(n)}function u(n){try{let e=n.prepare("SELECT id FROM schema_migrations").all();return e.length===0?0:Math.max(...e.map(t=>t.id))}catch{return 0}}var l=Log.create({service:"memory-database"}),h=class{constructor(e){a(this,"db",null);a(this,"storagePath");a(this,"backend","better-sqlite3");a(this,"initialized",false);a(this,"initPromise",null);this.storagePath=e===":memory:"?e:Filesystem.normalize(e);}async initialize(){if(!this.initialized){if(this.initPromise){await this.initPromise;return}this.initPromise=this.doInitialize();try{await this.initPromise,this.initialized=!0;}catch(e){try{this.db&&this.db.close();}catch{}throw this.db=null,this.initPromise=null,e}}}async doInitialize(){try{let e=this.openConnection();e.initialize(),this.db=e,this.applyPragmas(),this.runAllMigrations();}catch(e){let t=e instanceof Error?e.message:String(e);throw l.error("Database initialization failed",{error:t}),e}}openConnection(){return createSyncSqliteConnection({path:this.storagePath,backend:this.backend,walMode:true,foreignKeys:true,busyTimeoutMs:5e3})}applyPragmas(){if(this.db)try{this.db.pragma("synchronous = NORMAL"),this.db.pragma("cache_size = -64000"),this.db.pragma("temp_store = MEMORY"),this.db.pragma("foreign_keys = ON");}catch(e){l.warn("Failed to apply memory PRAGMAs",{error:String(e)});}}runAllMigrations(){if(!this.db)throw new Error("Database not initialized");let e=p(this.db,m);if(e.errors.length>0){let t=e.errors.map(r=>`migration ${r.migrationId}: ${r.error}`).join("; ");throw new Error(`Some migrations failed: ${t}`)}}query(e,t){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");try{let r=this.db.prepare(e);return t?r.all(...t):r.all()}catch(r){throw new Error(`Query failed: ${r.message}`)}}agentFilter(e){return typeof e=="string"&&e.trim().length>0?{where:"WHERE agent_id = ?",params:[e.trim()]}:{where:"",params:[]}}run(e,t){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");try{let r=this.db.prepare(e),s=t?r.run(...t):r.run();return {lastID:Number(s.lastInsertRowid),changes:s.changes}}catch(r){throw new Error(`Write failed: ${r.message}`)}}transaction(e){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");return this.db.transaction(e)()}prepare(e){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");return this.db.prepare(e)}exec(e){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");this.db.exec(e);}getDb(){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");return this.db}getPath(){return this.storagePath}getSchemaVersion(){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");return u(this.db)}close(){if(this.db){try{this.db.close();}catch(e){l.warn("Failed to close memory database",{error:String(e)});}this.db=null,this.initialized=false,this.initPromise=null;}}healthCheck(){try{return this.db?(this.db.exec("SELECT 1"),!0):!1}catch{return false}}checkIntegrity(){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");let e=N=>this.db.prepare(N).get().c,t={memory_facts:e("SELECT COUNT(*) as c FROM memory_facts"),memory_vectors:e("SELECT COUNT(*) as c FROM memory_vectors"),embedding_cache:e("SELECT COUNT(*) as c FROM embedding_cache"),memory_facts_fts:e("SELECT COUNT(*) as c FROM memory_facts_fts"),nodes:e("SELECT COUNT(*) as c FROM nodes"),edges:e("SELECT COUNT(*) as c FROM edges"),meta:e("SELECT COUNT(*) as c FROM meta"),schema_migrations:e("SELECT COUNT(*) as c FROM schema_migrations")},r=[],s=e(`
|
|
55
|
+
SELECT COUNT(*) as c FROM (
|
|
56
|
+
SELECT mf.id, JSON_EACH.value AS node_id
|
|
57
|
+
FROM memory_facts mf, JSON_EACH(mf.node_ids)
|
|
58
|
+
WHERE mf.node_ids IS NOT NULL
|
|
59
|
+
) LEFT JOIN nodes n ON n.id = CAST(node_id AS INTEGER)
|
|
60
|
+
WHERE n.id IS NULL
|
|
61
|
+
`);s>0&&r.push({severity:"error",message:`orphan node references (fact.nodeIds): ${s}`});let a=e(`
|
|
62
|
+
SELECT COUNT(*) as c FROM edges e WHERE NOT EXISTS (SELECT 1 FROM nodes n WHERE n.id = e.source)
|
|
63
|
+
`);a>0&&r.push({severity:"error",message:`orphan edges (source): ${a}`});let i=e(`
|
|
64
|
+
SELECT COUNT(*) as c FROM edges e WHERE NOT EXISTS (SELECT 1 FROM nodes n WHERE n.id = e.target)
|
|
65
|
+
`);i>0&&r.push({severity:"error",message:`orphan edges (target): ${i}`});let o=e("SELECT COUNT(*) as c FROM edges WHERE source = target");o>0&&r.push({severity:"warn",message:`self-loop edges: ${o}`});let d=e(`
|
|
66
|
+
SELECT COUNT(*) as c FROM (
|
|
67
|
+
SELECT fact_id FROM memory_facts_fts
|
|
68
|
+
EXCEPT
|
|
69
|
+
SELECT id FROM memory_facts
|
|
70
|
+
)
|
|
71
|
+
`);d>0&&r.push({severity:"warn",message:`FTS out of sync (orphan entries): ${d}`});let c=e("SELECT COUNT(*) as c FROM (SELECT id, COUNT(*) as c FROM memory_facts GROUP BY id HAVING c > 1)");c>0&&r.push({severity:"error",message:`duplicate fact ids: ${c}`});let g=e("SELECT COUNT(*) as c FROM memory_facts WHERE content IS NULL OR content = ''");return g>0&&r.push({severity:"error",message:`memory_facts with null/empty content: ${g}`}),{issues:r,stats:t}}getMeta(e){if(!this.db)throw new Error("Database not initialized");return this.db.prepare("SELECT value FROM meta WHERE key = ?").get(e)?.value??null}setMeta(e,t){if(!this.db)throw new Error("Database not initialized");this.db.prepare("INSERT OR REPLACE INTO meta (key, value) VALUES (?, ?)").run(e,t);}};export{m as a,R as b,p as c,u as d,h as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var n=Object.defineProperty;var c=(t,e,r)=>e in t?n(t,e,{enumerable:true,configurable:true,writable:true,value:r}):t[e]=r;var m=(t,e,r)=>c(t,typeof e!="symbol"?e+"":e,r);var o=()=>typeof document>"u"?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"?document.currentScript.src:new URL("main.js",document.baseURI).href,u=o();exports.a=m;exports.b=u;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkCPRDIUQ4_cjs=require('./chunk-CPRDIUQ4.cjs'),utils=require('@easbot/utils'),terminal=require('@easbot/terminal');var y=utils.Log.create({service:"memory-cli"}),S=[{i18nKey:"cli.cmd.init.description",name:"init",description:"Initialize memory workspace (.easbot/memory.db)",group:"lifecycle"},{i18nKey:"cli.cmd.status.description",name:"status",description:"Show memory state / db stats / facts by category",group:"lifecycle"},{i18nKey:"cli.cmd.doctor.description",name:"doctor",description:"Run health checks (backend, FTS, schema, lock)",group:"lifecycle"},{i18nKey:"cli.cmd.recall.description",name:"recall",description:"Hybrid search (FTS + vector) over memory facts",group:"memory"},{i18nKey:"cli.cmd.remember.description",name:"remember",description:"Persist a new memory fact (with dedup + KG extraction)",group:"memory"},{i18nKey:"cli.cmd.forget.description",name:"forget",description:"Delete memory facts (factId / category / timeRange / dryRun)",group:"memory"},{i18nKey:"cli.cmd.sync.description",name:"sync",description:"Sync facts to .md files (idempotent) and archive expired active files (default 30 days)",group:"memory"},{i18nKey:"cli.cmd.extract.description",name:"extract",description:"Extract facts from a session (sessionId + lastN)",group:"session"},{i18nKey:"cli.cmd.consolidate.description",name:"consolidate",description:"Run consolidation pipeline (extract \u2192 dedup \u2192 archive)",group:"session"},{i18nKey:"cli.cmd.graph.description",name:"graph",description:"KG query (nodes / edges / neighbors with scope \u4E09\u6863)",group:"graph"},{i18nKey:"cli.cmd.config.description",name:"config",description:"Show / validate memory configuration (dry-read)",group:"external"},{i18nKey:"cli.cmd.mcp.description",name:"mcp",description:"Start stdio MCP server (exposes 10 memory tools)",group:"external"}];function u(m,t){let e=S.filter(a=>a.group===m);return terminal.renderLines({title:t,flat:e.map(a=>`$ easbot-memory ${a.name.padEnd(14)} ${a.description}`)})}function v(){let m=[terminal.renderLines({title:"easbot-memory \xB7 Memory & Knowledge Module for EASBot",flat:["Usage: easbot-memory <command> [options]"]}),"",u("lifecycle","Commands (lifecycle):"),"",u("memory","Commands (memory):"),"",u("session","Commands (session):"),"",u("graph","Commands (graph query):"),"",u("external","External:")];terminal.printHuman(m);}function C(){v(),terminal.printHuman(["",terminal.renderLines({title:"Global flags & invocation",flat:["--cwd <dir> --config <path> --log-level <L> --print-logs --debug","Standalone CLI: easbot-memory <command>","Agent CLI: easbot memory <command>"]})]);}async function j(m){try{let{bootstrapLlm:t}=await import('@easbot/llm'),{Llm:e}=await import('./llm-RMPVWEVP.cjs');await t({target:e,cwd:m,subConfigPath:".easbot/memory.json",embedding:!0,graph:!0});}catch(t){y.warn("bootstrapLlm failed; Llm-related features will be disabled",{error:t instanceof Error?t.message:String(t)});}}async function E(m,t){let[e,...a]=m,c=t?.cwd??process.cwd();if(!e)return C(),{code:0,handled:true,command:null};await j(c);try{switch(e){case "init":{let{parseInitOptions:r,runInit:n}=await import('./init-B24TNUSD.cjs'),s=r(a);if(s.help)return console.log("Usage: easbot-memory init [dir] [--agent <id>] [--force] [--json]"),{code:0,handled:!0,command:e};let o=s.workspaceDir?.trim()??c,i=await n({...s,ctxWorkspaceDir:o});if(s.json)terminal.emitJsonOk(i,{command:e});else {let p=i;terminal.printHuman([terminal.formatKnowledgeInit({packageName:"memory",configPath:p.configPath??p.dbPath,backend:"better-sqlite3",schemaVersion:p.schemaVersion,extras:{dbPath:p.dbPath,migrationsApplied:p.migrationsApplied,tablesCreated:p.tablesCreated,durationMs:`${p.durationMs}ms`}})],{title:"init memory workspace",boxed:!0});}return {code:0,handled:!0,command:e}}case "recall":{let{parseRecallOptions:r,runRecall:n,formatRecallText:s}=await import('./recall-LKETADTB.cjs'),o=r(a);if(o.help)return console.log("Usage: easbot-memory recall --query <q> [--agent <id>] [--limit <n>] [--category <c>] [--min-importance <n>] [--json]"),{code:0,handled:!0,command:e};let i=await n({...o,workspaceDir:c});return o.json?terminal.emitJsonOk(i,{command:e}):terminal.printHuman([s(i)],{title:`recall (agentId=${o.agentId??"default"})`}),{code:0,handled:!0,command:e}}case "remember":{let{parseRememberOptions:r,runRemember:n,formatRememberText:s}=await import('./remember-VZF4O7ZF.cjs'),o=r(a);if(o.help)return console.log("Usage: easbot-memory remember --content <text> --category <c> --importance <1-10> [--agent <id>] [--tag <t>] [--session <s>] [--json]"),{code:0,handled:!0,command:e};let i=await n({...o,workspaceDir:c});return o.json?terminal.emitJsonOk(i,{command:e}):terminal.printHuman([s(i)],{title:"remember (persist fact)"}),{code:0,handled:!0,command:e}}case "forget":{let{parseForgetOptions:r,runForget:n,formatForgetText:s}=await import('./forget-GBMYCUPJ.cjs'),o=r(a);if(o.help)return console.log("Usage: easbot-memory forget [--agent <id>] (--fact-id <id> | --category <c> | --from <ISO> --to <ISO>) [--max-delete <n>] [--dry-run] [--json]"),{code:0,handled:!0,command:e};let i=await n({...o,workspaceDir:c});return o.json?terminal.emitJsonOk(i,{command:e}):terminal.printHuman([s(i)],{title:"forget (delete facts)"}),{code:0,handled:!0,command:e}}case "extract":{let{parseExtractOptions:r,runExtract:n,formatExtractText:s}=await import('./extract-7FFIDVG3.cjs'),o=r(a);if(o.help)return console.log("Usage: easbot-memory extract --session <sessionId> [--agent <id>] [--last-n <n>] [--from-msg <id>] [--json]"),{code:0,handled:!0,command:e};let i=await n({...o,workspaceDir:c});return o.json?terminal.emitJsonOk(i,{command:e}):terminal.printHuman([s(i)],{title:"extract (from session)"}),{code:0,handled:!0,command:e}}case "consolidate":{let{parseConsolidateOptions:r,runConsolidate:n,formatConsolidateText:s}=await import('./consolidate-PUOAAQN3.cjs'),o=r(a);if(o.help)return console.log("Usage: easbot-memory consolidate [--agent <id>] [--window-days <n>] [--json]"),{code:0,handled:!0,command:e};let i=await n({...o,workspaceDir:c});return o.json?terminal.emitJsonOk(i,{command:e}):terminal.printHuman([s(i)],{title:"consolidate (pipeline)"}),{code:0,handled:!0,command:e}}case "sync":{let{parseSyncOptions:r,runSync:n,formatSyncText:s}=await import('./sync-W5A2O5TS.cjs'),o=r(a);if(o.help)return console.log("Usage: easbot-memory sync [--agent <id>] [--window-days <n>] [--dry-run] [--json]"),console.log("Two-stage pipeline: (A) db \u2192 .md (idempotent skip on existing), (B) archive active/ files older than windowDays."),{code:0,handled:!0,command:e};let i=await n({...o,workspaceDir:c});return o.json?terminal.emitJsonOk(i,{command:e}):terminal.printHuman([s(i)],{title:"sync (db \u2192 .md + archive)"}),{code:0,handled:!0,command:e}}case "graph":{let{parseGraphOptions:r,runGraph:n,formatGraphText:s}=await import('./graph-KOJYJTA4.cjs'),o=r(a);if(o.help)return console.log("Usage: easbot-memory graph [--agent <id>] --kind <nodes|edges|neighbors> [--query <q>] [--start-node <id>] [--depth <n>] [--max-nodes <n>] [--scope <agent_only|shared_only|both>] [--json]"),{code:0,handled:!0,command:e};let i=await n({...o,workspaceDir:c});return o.json?terminal.emitJsonOk(i,{command:e}):terminal.printHuman([s(i)],{title:`graph_query (scope=${o.scope??"agent_only"})`}),{code:0,handled:!0,command:e}}case "status":{let{parseStatusOptions:r,runStatus:n}=await import('./status-2BFVXY5J.cjs'),s=r(a);if(s.help)return console.log("Usage: easbot-memory status [--agent <id>] [--json]"),{code:0,handled:!0,command:e};let o=await n({...s,workspaceDir:c});return s.json?terminal.emitJsonOk(o,{command:e}):terminal.printHuman([terminal.formatKnowledgeStatus(I(o))],{title:"memory status",boxed:!0}),{code:0,handled:!0,command:e}}case "doctor":{let{parseDoctorOptions:r,runDoctor:n}=await import('./doctor-U4HOSXGW.cjs'),s=r(a);if(s.help)return console.log("Usage: easbot-memory doctor [--repair] [--json]"),{code:0,handled:!0,command:e};let o=await n({...s,workspaceDir:c});return s.json?terminal.emitJsonOk(o,{command:e}):terminal.printHuman([terminal.formatKnowledgeDoctor(K(o))],{title:"memory doctor",boxed:!0}),{code:0,handled:!0,command:e}}case "config":{let{parseConfigOptions:r,runConfig:n,formatConfigText:s}=await import('./config-RPPQ73HK.cjs'),o=r(a);if(o.help)return console.log("Usage: easbot-memory config [--json]"),{code:0,handled:!0,command:e};let i=n(o);return o.json?terminal.emitJsonOk(i,{command:e}):terminal.printHuman([s(i)],{title:"memory config"}),{code:0,handled:!0,command:e}}case "mcp":{let{parseMcpOptions:r,runMcp:n}=await import('./mcp-BS6XHEBR.cjs'),s=r(a);if(s.help)return console.log("Usage: easbot-memory mcp [start]"),console.log("Start a stdio MCP server exposing 10 memory tools:"),console.log(" recall / remember / forget / extract / consolidate"),console.log(" graph_query / status / doctor / init / sync"),{code:0,handled:!0,command:e};let o=await n(s);return s.json?terminal.emitJsonOk(o,{command:e}):terminal.printHuman([`memory mcp started (tools: ${o.tools.length})`],{title:"memory mcp server"}),{code:0,handled:!0,command:e}}default:return console.error(`Unknown command: ${e}`),console.error("Run `easbot-memory --help` for available commands."),{code:2,handled:!1,command:null}}}catch(r){let n=r instanceof Error?r.message:String(r);y.error("memory CLI command failed",{command:e,error:n,stack:r instanceof Error?r.stack:void 0});let s=t?.cwd??chunkCPRDIUQ4_cjs.f().worktree;return console.error(`[memory] ${s} :: ${e} failed: ${n}`),terminal.emitJsonError(e,n),{code:1,handled:true,command:e}}}function I(m){let t=m;return {packageName:"memory",rootDir:t.workspaceDir??"",configPath:t.configPath??"",configExists:true,dbPath:t.dbPath??"",dbExists:true,dbSize:typeof t.dbSize=="number"?t.dbSize:void 0,indexState:t.indexState,schemaVersion:typeof t.schemaVersion=="number"?t.schemaVersion:void 0,extractionVersion:typeof t.extractionVersion=="number"?t.extractionVersion:void 0,lastSyncAt:t.lastSyncAt,vectorEnabled:typeof t.vectorEnabled=="boolean"?t.vectorEnabled:void 0,embeddingDims:typeof t.embeddingDims=="number"?t.embeddingDims:void 0,llm:t.llm??{initialized:false,capabilities:{}},backend:t.backend,counts:t.counts??{},healthy:typeof t.healthy=="boolean"?t.healthy:true,recommendation:t.recommendation,extras:(()=>{let e={};if(typeof t.agentId=="string"&&(e.agent_id=t.agentId),typeof t.ftsAvailable=="boolean"&&(e.fts_available=t.ftsAvailable?"yes":"no"),typeof t.kgScopeEnabled=="boolean"&&(e.kg_scope_enabled=t.kgScopeEnabled?"yes":"no"),t.factsByCategory&&typeof t.factsByCategory=="object"){let a=t.factsByCategory;for(let[c,r]of Object.entries(a))typeof r=="number"&&r>0&&(e[`facts/${c}`]=r);}return Object.keys(e).length>0?e:void 0})()}}function K(m){let t=m,e=Array.isArray(t.checks)?t.checks:[],a=t.integrityStats,c=t.backendAvailable,r=a?{nodes:a.nodes??0,edges:a.edges??0,file_hashes:0,fts:a.memory_facts_fts??0,node_embeddings:a.memory_vectors??0,embedding_cache:a.embedding_cache??0,parse_errors:0,unresolved_refs:0,name_segment_vocab:0,project_metadata:0,meta:a.meta??0}:void 0;return {packageName:"memory",healthy:typeof t.healthy=="boolean"?t.healthy:false,durationMs:typeof t.durationMs=="number"?t.durationMs:0,checks:e.map(n=>({code:typeof n.code=="string"?n.code:"",severity:n.severity??"info",name:typeof n.name=="string"?n.name:"",message:typeof n.message=="string"?n.message:"",durationMs:typeof n.durationMs=="number"?n.durationMs:void 0,details:n.details})),dbStats:r,backendAvailable:c}}exports.a=S;exports.b=v;exports.c=C;exports.d=E;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a}from'./chunk-
|
|
1
|
+
import {a}from'./chunk-SWYQLQ7Z.mjs';function s(r,t){return a(`memory.${r}.empty`,{fallback:t})}function g(r,t,m){return a(`memory.${r}.summary`,{vars:t,fallback:m})}function u(r,t,m){return a(`memory.${r}.item`,{vars:t,fallback:m})}export{s as a,g as b,u as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f={languages:[{value:"zh-CN",name:"\u7B80\u4F53\u4E2D\u6587",example:"\u4F60\u597D\uFF0CEASBOT\uFF01",supported:true},{value:"en-US",name:"English (United States)",example:"Hello, EASBOT!",supported:true}]};var b=f.languages,v=b.filter(e=>e.supported).map(e=>e.value),a={defaultLocale:"zh-CN",locales:v},m={},p=(e,t)=>{let r=m[e]||{translation:{}};return m[e]={translation:{...r.translation,...t.translation}},m[e]},u=(e=a.defaultLocale)=>(m[e]||p(e,{translation:{}}),{locale:e,resources:m[e]||{translation:{}}});var L={translation:{"cli.cmd.init.description":"\u521D\u59CB\u5316\u8BB0\u5FC6 workspace\uFF08.easbot/memory.db\uFF09","cli.cmd.recall.description":"\u6DF7\u5408\u641C\u7D22\uFF08FTS + \u5411\u91CF\uFF09\u67E5\u8BE2\u8BB0\u5FC6","cli.cmd.remember.description":"\u5199\u5165\u4E00\u6761\u65B0\u8BB0\u5FC6\uFF08\u81EA\u5E26 dedup + \u77E5\u8BC6\u56FE\u8C31\u62BD\u53D6\uFF09","cli.cmd.forget.description":"\u5220\u9664\u8BB0\u5FC6\uFF08factId / category / \u65F6\u95F4\u7A97 / \u8BD5\u8FD0\u884C\uFF09","cli.cmd.sync.description":"\u540C\u6B65 facts \u5230 .md\uFF08\u5E42\u7B49\u8DF3\u8FC7\uFF09\u5E76\u5F52\u6863\u8FC7\u671F active \u6587\u4EF6\uFF08\u9ED8\u8BA4 30 \u5929\uFF09","cli.cmd.extract.description":"\u4ECE session \u62BD\u53D6 facts\uFF08sessionId + lastN\uFF09","cli.cmd.consolidate.description":"\u8FD0\u884C consolidation \u6D41\u6C34\u7EBF\uFF08extract \u2192 dedup \u2192 archive\uFF09","cli.cmd.graph.description":"\u77E5\u8BC6\u56FE\u8C31\u67E5\u8BE2\uFF08nodes / edges / neighbors\uFF0Cscope \u4E09\u6863\uFF09","cli.cmd.status.description":"\u663E\u793A\u8BB0\u5FC6\u72B6\u6001 / \u6570\u636E\u5E93\u7EDF\u8BA1 / \u5404\u7C7B\u522B\u8BA1\u6570","cli.cmd.doctor.description":"\u8FD0\u884C\u5065\u5EB7\u68C0\u67E5\uFF08\u540E\u7AEF / FTS / schema / \u9501\uFF09","cli.cmd.config.description":"\u67E5\u770B / \u6821\u9A8C\u8BB0\u5FC6\u914D\u7F6E\uFF08dry-read\uFF09","cli.cmd.mcp.description":"\u542F\u52A8 stdio MCP \u670D\u52A1\u5668\uFF08\u66B4\u9732 10 \u4E2A memory \u5DE5\u5177\uFF09","memory.recall.empty":"\uFF08\u65E0\u5339\u914D\u8BB0\u5FC6\uFF09","memory.recall.summary":"\u5171\u5339\u914D {{total}} \u6761\u8BB0\u5FC6\uFF1A","memory.recall.item":" - {{id}} [{{category}}/\u91CD\u8981\u6027={{importance}}/\u5206\u6570={{score}}] {{content}}","memory.forget.empty":"\uFF08\u672A\u547D\u4E2D\u53EF\u5220\u9664\u7684\u8BB0\u5F55\uFF09\uFF09","memory.forget.summary":"\u5220\u9664 {{deletedCount}} \u6761\u8BB0\u5FC6\uFF08dryRun={{dryRun}}\uFF09\uFF1A","memory.forget.item":" - {{id}}","memory.remember.summary":"\u8BB0\u5FC6\u5DF2\u5199\u5165\uFF1A","memory.remember.item":" - id={{id}} \u7C7B\u522B={{category}} \u91CD\u8981\u6027={{importance}}","memory.consolidate.summary":"consolidation \u5B8C\u6210\uFF1A","memory.consolidate.item":" - \u603B\u8BA1 {{totalFacts}} \u53BB\u91CD {{dedupedCount}} \u5F52\u6863 {{archivedCount}}","memory.sync.summary":"sync \u5B8C\u6210\uFF08windowDays={{windowDays}}, dryRun={{dryRun}}\uFF09\uFF1A","memory.sync.item":" - \u751F\u6210 {{generatedCount}} \u8DF3\u8FC7 {{skippedCount}} \u5931\u8D25 {{failedGenerateCount}} \u5F52\u6863 {{archivedCount}}\uFF08\u9608\u503C {{archiveThreshold}}\uFF09","memory.status.empty":"\uFF08\u6682\u65E0\u6570\u636E\uFF09","memory.status.summary":"\u8BB0\u5FC6\u72B6\u6001\uFF1A","memory.status.item":" - {{key}}: {{value}}","memory.doctor.empty":"\uFF08\u65E0\u68C0\u67E5\u9879\uFF09","memory.doctor.summary":"\u5065\u5EB7\u68C0\u67E5\uFF1A{{status}}","memory.doctor.item":" - {{name}}: {{message}}","memory.graph.empty":"\uFF08\u65E0\u8282\u70B9\u547D\u4E2D\uFF09","memory.graph.summary":"\u77E5\u8BC6\u56FE\u8C31\u67E5\u8BE2\uFF08\u5171 {{totalNodes}} \u8282\u70B9\uFF09\uFF1A","memory.graph.item":" - {{id}} {{name}} [{{type}}]","memory.extract.summary":"\u62BD\u53D6 {{extractedCount}} \u6761 facts\uFF1A","memory.extract.item":" - {{id}}","memory.init.summary":"\u521D\u59CB\u5316\u5B8C\u6210\uFF1A","memory.init.item":" - db={{dbPath}} \u8FC1\u79FB={{migrationsApplied}} \u8868={{tablesCreated}}"}},h=L;var S={translation:{"cli.cmd.init.description":"Initialize memory workspace (.easbot/memory.db)","cli.cmd.recall.description":"Hybrid search (FTS + vector) over memory facts","cli.cmd.remember.description":"Persist a new memory fact (with dedup + KG extraction)","cli.cmd.forget.description":"Delete memory facts (factId / category / timeRange / dryRun)","cli.cmd.sync.description":"Sync facts to .md (idempotent skip) and archive expired active files (default 30 days)","cli.cmd.extract.description":"Extract facts from a session (sessionId + lastN)","cli.cmd.consolidate.description":"Run consolidation pipeline (extract \u2192 dedup \u2192 archive)","cli.cmd.graph.description":"KG query (nodes / edges / neighbors with scope \u4E09\u6863)","cli.cmd.status.description":"Show memory state / db stats / facts by category","cli.cmd.doctor.description":"Run health checks (backend, FTS, schema, lock)","cli.cmd.config.description":"Show / validate memory configuration (dry-read)","cli.cmd.mcp.description":"Start stdio MCP server (exposes 10 memory tools)","memory.recall.empty":"(no matching facts)","memory.recall.summary":"Found {{total}} fact(s):","memory.recall.item":" - {{id}} [{{category}}/imp={{importance}}/score={{score}}] {{content}}","memory.forget.empty":"(no records to delete)","memory.forget.summary":"Deleted {{deletedCount}} fact(s) (dryRun={{dryRun}}):","memory.forget.item":" - {{id}}","memory.remember.summary":"Memory persisted:","memory.remember.item":" - id={{id}} category={{category}} importance={{importance}}","memory.consolidate.summary":"Consolidation complete:","memory.consolidate.item":" - total {{totalFacts}} deduped {{dedupedCount}} archived {{archivedCount}}","memory.sync.summary":"Sync complete (windowDays={{windowDays}}, dryRun={{dryRun}}):","memory.sync.item":" - generated {{generatedCount}} skipped {{skippedCount}} failed {{failedGenerateCount}} archived {{archivedCount}} (threshold {{archiveThreshold}})","memory.status.empty":"(no data)","memory.status.summary":"Memory status:","memory.status.item":" - {{key}}: {{value}}","memory.doctor.empty":"(no checks)","memory.doctor.summary":"Health check: {{status}}","memory.doctor.item":" - {{name}}: {{message}}","memory.graph.empty":"(no nodes matched)","memory.graph.summary":"KG query ({{totalNodes}} node(s)):","memory.graph.item":" - {{id}} {{name}} [{{type}}]","memory.extract.summary":"Extracted {{extractedCount}} fact(s):","memory.extract.item":" - {{id}}","memory.init.summary":"Initialization complete:","memory.init.item":" - db={{dbPath}} migrations={{migrationsApplied}} tables={{tablesCreated}}"}},x=S;var w=()=>{u("zh-CN"),u("en-US"),p("zh-CN",h),p("en-US",x);};w();var y=new Map;var g=new Map;var k=e=>{if(g.has(e))return g.get(e);let t=/{{\s*(\w+)\s*}}/g,r=[],o;for(;(o=t.exec(e))!==null;){let n=o[1];n&&!r.includes(n)&&r.push(n);}let i=new RegExp("{{\\s*("+r.join("|")+")\\s*}}","g"),s={keys:r,regex:i};return g.set(e,s),s},R=(e,t)=>{if(!e||typeof e!="string")return "";if(!t||Object.keys(t).length===0)return e;let{regex:r,keys:o}=k(e);return o.length===0||!o.some(s=>s in t)?e:e.replace(r,(s,n)=>{let c=t[n];return c==null?"":String(c)})},I=e=>{if(e&&a.locales.includes(e))return e;let t=process.env.EASBOT_LANG?.trim()||process.env.LANG?.trim();if(t){let r=t.replace(/_/g,"-");if(a.locales.includes(r))return r;let o=r.split("-")[0];if(o==="zh")return "zh-CN";if(o==="en")return "en-US"}return a.defaultLocale},T=e=>{if(!y.has(e)){let{resources:t}=u(e);y.set(e,t);}return y.get(e)},N=(e,t={})=>{let r=I(t.locale),i=T(r)?.translation[e];if(i&&typeof i=="string"){let s=R(i,t.vars);return s!=null?String(s):String(e)}if(r!==a.defaultLocale){let n=T(a.defaultLocale)?.translation[e];if(n&&typeof n=="string"){let c=R(n,t.vars);return c!=null?String(c):String(e)}}return String(t.fallback??e)},_=N;export{_ as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {homedir}from'os';import {join}from'path';import {xdgData}from'xdg-basedir';var
|
|
1
|
+
import {homedir}from'os';import {join}from'path';import {xdgData}from'xdg-basedir';var o=null,n=null;function f(t){o=t;}function g(){o=null;}function a(){if(o)return o;let t=homedir();return {Path:{home:t,data:process.env.EASBOT_DATA_PATH?.trim()||join(xdgData??join(t,".local","share"),"easbot"),config:process.env.EASBOT_CONFIG_PATH?.trim()||join(t,".config","easbot"),state:process.env.EASBOT_STATE_PATH?.trim()||join(xdgData??join(t,".local","share"),"easbot","state"),cache:process.env.EASBOT_CACHE_PATH?.trim()||join(t,".cache","easbot"),log:process.env.EASBOT_LOG_PATH?.trim()||join(xdgData??join(t,".local","share"),"easbot","log"),bin:process.env.EASBOT_BIN_PATH?.trim()||join(t,".local","bin")}}}function A(t){n=t;}function I(){n=null;}function T(){if(n)return n;let t=process.cwd();return {directory:t,worktree:t}}function c(){return a().Path.home||homedir()}function l(){let t=a().Path.data;return t||(xdgData??join(c(),".local","share"))}function _(){return join(l(),"memory")}function h(t){let i=typeof t=="string"?t:t?.dir??t?.workspaceDir??process.cwd();return join(i,".easbot","db","memory.db")}export{f as a,g as b,a as c,A as d,I as e,T as f,c as g,l as h,_ as i,h as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var g={languages:[{value:"zh-CN",name:"\u7B80\u4F53\u4E2D\u6587",example:"\u4F60\u597D\uFF0CEASBOT\uFF01",supported:true},{value:"en-US",name:"English (United States)",example:"Hello, EASBOT!",supported:true}]};var C=g.languages,b=C.filter(e=>e.supported).map(e=>e.value),a={defaultLocale:"zh-CN",locales:b},m={},l=(e,t)=>{let r=m[e]||{translation:{}};return m[e]={translation:{...r.translation,...t.translation}},m[e]},p=(e=a.defaultLocale)=>(m[e]||l(e,{translation:{}}),{locale:e,resources:m[e]||{translation:{}}});var v={translation:{"cli.cmd.init.description":"\u521D\u59CB\u5316\u8BB0\u5FC6 workspace\uFF08.easbot/memory.db\uFF09","cli.cmd.recall.description":"\u6DF7\u5408\u641C\u7D22\uFF08FTS + \u5411\u91CF\uFF09\u67E5\u8BE2\u8BB0\u5FC6","cli.cmd.remember.description":"\u5199\u5165\u4E00\u6761\u65B0\u8BB0\u5FC6\uFF08\u81EA\u5E26 dedup + \u77E5\u8BC6\u56FE\u8C31\u62BD\u53D6\uFF09","cli.cmd.forget.description":"\u5220\u9664\u8BB0\u5FC6\uFF08factId / category / \u65F6\u95F4\u7A97 / \u8BD5\u8FD0\u884C\uFF09","cli.cmd.sync.description":"\u540C\u6B65 facts \u5230 .md\uFF08\u5E42\u7B49\u8DF3\u8FC7\uFF09\u5E76\u5F52\u6863\u8FC7\u671F active \u6587\u4EF6\uFF08\u9ED8\u8BA4 30 \u5929\uFF09","cli.cmd.extract.description":"\u4ECE session \u62BD\u53D6 facts\uFF08sessionId + lastN\uFF09","cli.cmd.consolidate.description":"\u8FD0\u884C consolidation \u6D41\u6C34\u7EBF\uFF08extract \u2192 dedup \u2192 archive\uFF09","cli.cmd.graph.description":"\u77E5\u8BC6\u56FE\u8C31\u67E5\u8BE2\uFF08nodes / edges / neighbors\uFF0Cscope \u4E09\u6863\uFF09","cli.cmd.status.description":"\u663E\u793A\u8BB0\u5FC6\u72B6\u6001 / \u6570\u636E\u5E93\u7EDF\u8BA1 / \u5404\u7C7B\u522B\u8BA1\u6570","cli.cmd.doctor.description":"\u8FD0\u884C\u5065\u5EB7\u68C0\u67E5\uFF08\u540E\u7AEF / FTS / schema / \u9501\uFF09","cli.cmd.config.description":"\u67E5\u770B / \u6821\u9A8C\u8BB0\u5FC6\u914D\u7F6E\uFF08dry-read\uFF09","cli.cmd.mcp.description":"\u542F\u52A8 stdio MCP \u670D\u52A1\u5668\uFF08\u66B4\u9732 10 \u4E2A memory \u5DE5\u5177\uFF09","memory.recall.empty":"\uFF08\u65E0\u5339\u914D\u8BB0\u5FC6\uFF09","memory.recall.summary":"\u5171\u5339\u914D {{total}} \u6761\u8BB0\u5FC6\uFF1A","memory.recall.item":" - {{id}} [{{category}}/\u91CD\u8981\u6027={{importance}}/\u5206\u6570={{score}}] {{content}}","memory.forget.empty":"\uFF08\u672A\u547D\u4E2D\u53EF\u5220\u9664\u7684\u8BB0\u5F55\uFF09\uFF09","memory.forget.summary":"\u5220\u9664 {{deletedCount}} \u6761\u8BB0\u5FC6\uFF08dryRun={{dryRun}}\uFF09\uFF1A","memory.forget.item":" - {{id}}","memory.remember.summary":"\u8BB0\u5FC6\u5DF2\u5199\u5165\uFF1A","memory.remember.item":" - id={{id}} \u7C7B\u522B={{category}} \u91CD\u8981\u6027={{importance}}","memory.consolidate.summary":"consolidation \u5B8C\u6210\uFF1A","memory.consolidate.item":" - \u603B\u8BA1 {{totalFacts}} \u53BB\u91CD {{dedupedCount}} \u5F52\u6863 {{archivedCount}}","memory.sync.summary":"sync \u5B8C\u6210\uFF08windowDays={{windowDays}}, dryRun={{dryRun}}\uFF09\uFF1A","memory.sync.item":" - \u751F\u6210 {{generatedCount}} \u8DF3\u8FC7 {{skippedCount}} \u5931\u8D25 {{failedGenerateCount}} \u5F52\u6863 {{archivedCount}}\uFF08\u9608\u503C {{archiveThreshold}}\uFF09","memory.status.empty":"\uFF08\u6682\u65E0\u6570\u636E\uFF09","memory.status.summary":"\u8BB0\u5FC6\u72B6\u6001\uFF1A","memory.status.item":" - {{key}}: {{value}}","memory.doctor.empty":"\uFF08\u65E0\u68C0\u67E5\u9879\uFF09","memory.doctor.summary":"\u5065\u5EB7\u68C0\u67E5\uFF1A{{status}}","memory.doctor.item":" - {{name}}: {{message}}","memory.graph.empty":"\uFF08\u65E0\u8282\u70B9\u547D\u4E2D\uFF09","memory.graph.summary":"\u77E5\u8BC6\u56FE\u8C31\u67E5\u8BE2\uFF08\u5171 {{totalNodes}} \u8282\u70B9\uFF09\uFF1A","memory.graph.item":" - {{id}} {{name}} [{{type}}]","memory.extract.summary":"\u62BD\u53D6 {{extractedCount}} \u6761 facts\uFF1A","memory.extract.item":" - {{id}}","memory.init.summary":"\u521D\u59CB\u5316\u5B8C\u6210\uFF1A","memory.init.item":" - db={{dbPath}} \u8FC1\u79FB={{migrationsApplied}} \u8868={{tablesCreated}}"}},f=v;var L={translation:{"cli.cmd.init.description":"Initialize memory workspace (.easbot/memory.db)","cli.cmd.recall.description":"Hybrid search (FTS + vector) over memory facts","cli.cmd.remember.description":"Persist a new memory fact (with dedup + KG extraction)","cli.cmd.forget.description":"Delete memory facts (factId / category / timeRange / dryRun)","cli.cmd.sync.description":"Sync facts to .md (idempotent skip) and archive expired active files (default 30 days)","cli.cmd.extract.description":"Extract facts from a session (sessionId + lastN)","cli.cmd.consolidate.description":"Run consolidation pipeline (extract \u2192 dedup \u2192 archive)","cli.cmd.graph.description":"KG query (nodes / edges / neighbors with scope \u4E09\u6863)","cli.cmd.status.description":"Show memory state / db stats / facts by category","cli.cmd.doctor.description":"Run health checks (backend, FTS, schema, lock)","cli.cmd.config.description":"Show / validate memory configuration (dry-read)","cli.cmd.mcp.description":"Start stdio MCP server (exposes 10 memory tools)","memory.recall.empty":"(no matching facts)","memory.recall.summary":"Found {{total}} fact(s):","memory.recall.item":" - {{id}} [{{category}}/imp={{importance}}/score={{score}}] {{content}}","memory.forget.empty":"(no records to delete)","memory.forget.summary":"Deleted {{deletedCount}} fact(s) (dryRun={{dryRun}}):","memory.forget.item":" - {{id}}","memory.remember.summary":"Memory persisted:","memory.remember.item":" - id={{id}} category={{category}} importance={{importance}}","memory.consolidate.summary":"Consolidation complete:","memory.consolidate.item":" - total {{totalFacts}} deduped {{dedupedCount}} archived {{archivedCount}}","memory.sync.summary":"Sync complete (windowDays={{windowDays}}, dryRun={{dryRun}}):","memory.sync.item":" - generated {{generatedCount}} skipped {{skippedCount}} failed {{failedGenerateCount}} archived {{archivedCount}} (threshold {{archiveThreshold}})","memory.status.empty":"(no data)","memory.status.summary":"Memory status:","memory.status.item":" - {{key}}: {{value}}","memory.doctor.empty":"(no checks)","memory.doctor.summary":"Health check: {{status}}","memory.doctor.item":" - {{name}}: {{message}}","memory.graph.empty":"(no nodes matched)","memory.graph.summary":"KG query ({{totalNodes}} node(s)):","memory.graph.item":" - {{id}} {{name}} [{{type}}]","memory.extract.summary":"Extracted {{extractedCount}} fact(s):","memory.extract.item":" - {{id}}","memory.init.summary":"Initialization complete:","memory.init.item":" - db={{dbPath}} migrations={{migrationsApplied}} tables={{tablesCreated}}"}},h=L;var S=()=>{p("zh-CN"),p("en-US"),l("zh-CN",f),l("en-US",h);};S();var u=new Map;var y=new Map;var w=e=>{if(y.has(e))return y.get(e);let t=/{{\s*(\w+)\s*}}/g,r=[],o;for(;(o=t.exec(e))!==null;){let n=o[1];n&&!r.includes(n)&&r.push(n);}let i=new RegExp("{{\\s*("+r.join("|")+")\\s*}}","g"),s={keys:r,regex:i};return y.set(e,s),s},x=(e,t)=>{if(!e||typeof e!="string")return "";if(!t||Object.keys(t).length===0)return e;let{regex:r,keys:o}=w(e);return o.length===0||!o.some(s=>s in t)?e:e.replace(r,(s,n)=>{let c=t[n];return c==null?"":String(c)})},k=e=>{if(e&&a.locales.includes(e))return e;let t=process.env.EASBOT_LANG?.trim()||process.env.LANG?.trim();if(t){let r=t.replace(/_/g,"-");if(a.locales.includes(r))return r;let o=r.split("-")[0];if(o==="zh")return "zh-CN";if(o==="en")return "en-US"}return a.defaultLocale},R=e=>{if(!u.has(e)){let{resources:t}=p(e);u.set(e,t);}return u.get(e)},I=(e,t={})=>{let r=k(t.locale),i=R(r)?.translation[e];if(i&&typeof i=="string"){let s=x(i,t.vars);return s!=null?String(s):String(e)}if(r!==a.defaultLocale){let n=R(a.defaultLocale)?.translation[e];if(n&&typeof n=="string"){let c=x(n,t.vars);return c!=null?String(c):String(e)}}return String(t.fallback??e)},P=I;exports.a=P;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.cjs'),mcp=require('@easbot/mcp'),utils=require('@easbot/utils');var ee=utils.Log.create({service:"memory-format-truncate"}),U="**`";var Q=24e3,z=25e3;async function f(e,n={}){let r=n.softLimit??Q,s=n.hardCeiling??z,o=n.toolName??"memory",c=n.writeToDisk!==false;if(e.length<=r)return {content:e,truncated:false};let i=e.slice(0,s),t=i.lastIndexOf(`
|
|
2
|
+
${U}`),a=i.lastIndexOf(`
|
|
3
|
+
`),u;t>s*.5?u=t:a>0?u=a:u=-1;let d=u>0?i.slice(0,u):i,l=d+"\n\n... (output truncated to budget; the source above is complete and verbatim \u2014 treat it as already Read. For any area not covered, make ANOTHER `<tool>` targeting those names \u2014 do NOT Read these files.)";if(!c)return {content:l,truncated:true,outputPath:"",hint:"Make another recall / graph_query with narrower scope.",info:`... ${e.length-d.length}/${e.length} characters truncated ...`};try{let g=await utils.TruncateContent.truncate(e,{maxChars:d.length,direction:"head",label:`${o}-output`});return g.truncated?{content:l,truncated:!0,outputPath:g.outputPath,hint:utils.TruncateContent.formatHint(g),info:`... ${g.removedLength}/${g.originalLength} characters truncated ...`}:{content:l,truncated:!0,outputPath:"",hint:"Make another recall / graph_query with narrower scope.",info:`... ${e.length-d.length}/${e.length} characters truncated ...`}}catch(g){return ee.warn("TruncateContent.truncate failed, returning without disk hint",{error:g instanceof Error?g.message:String(g)}),{content:l,truncated:true,outputPath:"",hint:"Make another recall / graph_query with narrower scope.",info:`... ${e.length-d.length}/${e.length} characters truncated ...`}}}function $(e,n={}){let r=n.softLimit??Q,s=n.hardCeiling??z;if(e.length<=r)return {content:e,truncated:false};let o=e.slice(0,s),c=o.lastIndexOf(`
|
|
4
|
+
${U}`),i=o.lastIndexOf(`
|
|
5
|
+
`),t;c>s*.5?t=c:i>0?t=i:t=-1;let a=t>0?o.slice(0,t):o;return {content:a+`
|
|
6
|
+
|
|
7
|
+
... (output truncated; tail dropped at section boundary)`,truncated:true,outputPath:"",hint:"",info:`... ${e.length-a.length}/${e.length} characters truncated ...`}}function te(e,n){if(!e||e.length===0)return null;let r=e.filter(o=>n.has(o.path));return r.length===0?null:`\u26A0\uFE0F Index may be stale for: ${r.map(o=>`${o.path} (edited pending)`).join(", ")}
|
|
8
|
+
|
|
9
|
+
`}function I(e,n,r={}){return (J[e]??J.default).replace(/<(\w+)>/g,(o,c)=>c==="tool"?n:r[c]??`<${c}>`)}var J={recall:"If you need more facts, make ANOTHER `<tool>` query with a different scope / interval.\nIf you have enough context, proceed with the current task. Do NOT call `<tool>` again for the same query.",remember:"Memory persisted. To recall it later, use `<tool>` with the same query.\nDo NOT call `<tool>` again to verify \u2014 the fact is already in the database.",forget:"Memory deleted. To verify, run `<tool>` with the same filter (no results expected).\nIf you deleted too much, the data is gone (no auto-restore).",graph_query:"If you need to explore further, make ANOTHER `<tool>` from a different start node or depth.\nOtherwise, the graph is complete for this scope.",status:"Status snapshot. To inspect a specific fact, use `<tool>` (recall) with its id.\nOtherwise, this is a complete read.",consolidate:"Consolidation done. To inspect the new facts, use `<tool>` with the same agentId.\nIf you want to undo, archives are in <archive_dir>.",doctor:"Doctor report. To fix a failing check, run with `repair=true`.\nRe-run after fix to confirm.",default:"If you need more, make ANOTHER `<tool>` with refined parameters.\nOtherwise, this is a complete read."};function X(e,n,r,s){let o=e.tags&&e.tags.length>0?`
|
|
10
|
+
- tags: ${e.tags.join(", ")}`:"",c=e.sessionId?`
|
|
11
|
+
- session: ${e.sessionId}`:"",i=e.msgId?`
|
|
12
|
+
- msg: ${e.msgId}`:"",t=typeof n=="number"?`
|
|
13
|
+
- score: ${n.toFixed(3)}${r?` (${r})`:""}`:"",a=e.truncated?" [truncated]":"",u="";if(s&&s.length>0){let d=[];for(let m of s){let l=[];if(m.edges&&m.edges.length>0)for(let y of m.edges){let b=y.direction??(y.source===m.id?"out":"in"),R=y.targetNode?.name??String(y.target),C=y.targetNode?.type??"node";l.push(` --[${b}] ${y.relation}--> ${R} (${C})`);}let g=l.length>0?l.join(`
|
|
14
|
+
`):" (no relations)";d.push(` - Node: ${m.name} (${m.type})
|
|
15
|
+
${g}`);}u=`
|
|
16
|
+
- linked KG nodes (${s.length}):
|
|
17
|
+
${d.join(`
|
|
18
|
+
`)}`;}return [`### \`${e.id}\`${a}`,` - agentId: ${e.agentId}`,` - category: ${e.category}`,` - importance: ${e.importance}`,` - createdAt: ${e.createdAt}`,` - updatedAt: ${e.updatedAt}`,` - source: ${e.source}${t}${o}${c}${i}${u}`,"",e.content,""].join(`
|
|
19
|
+
`)}async function S(e,n){let r=n.toolName??"memory_recall",s=`**\`memory_recall:${n.query.slice(0,40).replace(/[^a-zA-Z0-9_]/g,"_")}\`**`,o=te(n.pendingFiles,new Set),i=[`Found ${e.total} fact(s) for query "${n.query}" (agentId=${n.agentId}, scope=${n.scope}):`,"",o??"",s].join(`
|
|
20
|
+
`),t=new Map;for(let m of e.hits){let l=m.fact.category;t.has(l)||t.set(l,[]),t.get(l).push(m);}let a=Array.from(t.entries()).map(([m,l])=>{let g=`**\`category:${m}\`**`,y=l.map(b=>X(b.fact,b.score,b.source,b.nodes)).join(`
|
|
21
|
+
`);return `${g}
|
|
22
|
+
|
|
23
|
+
${y}`}).join(`
|
|
24
|
+
`),u=e.warnings&&e.warnings.length>0?`
|
|
25
|
+
|
|
26
|
+
\u26A0\uFE0F warnings:
|
|
27
|
+
${e.warnings.map(m=>` - ${m}`).join(`
|
|
28
|
+
`)}
|
|
29
|
+
`:"",d=`${i}
|
|
30
|
+
|
|
31
|
+
${a}${u}
|
|
32
|
+
|
|
33
|
+
${I("recall",r)}`;return n.sync?$(d,{}).content:(await f(d,{toolName:r,writeToDisk:n.writeToDisk})).content}async function v(e,n={}){let r=n.toolName??"memory_remember",s=`**\`memory_remember:${e.fact.id}\`**`,o=X(e.fact),c=e.nodeIds??[],i=c.length>0?`
|
|
34
|
+
- linked KG nodes: ${c.join(", ")}
|
|
35
|
+
`:"",t=`${s}
|
|
36
|
+
|
|
37
|
+
${o}${i}
|
|
38
|
+
|
|
39
|
+
${I("remember",r)}`;return n.sync?$(t,{}).content:(await f(t,{toolName:r,writeToDisk:n.writeToDisk})).content}async function x(e,n={}){let r=n.toolName??"memory_forget",s="**`memory_forget:result`**",o=e.dryRun?"**DRY RUN** \u2014 no facts were actually deleted. Run again without dryRun to execute.":`Deleted ${e.deletedCount} fact(s).`,c=e.truncatedCount>0?` (truncated: ${e.truncatedCount} more, re-run with narrower filter)`:"",i=[s,"",o+c,"",e.deletedIds.length>0?`deleted ids:
|
|
40
|
+
${e.deletedIds.map(t=>` - ${t}`).join(`
|
|
41
|
+
`)}`:"(no ids to show)","",I("forget",r)].join(`
|
|
42
|
+
`);return n.sync?$(i,{}).content:(await f(i,{toolName:r,writeToDisk:n.writeToDisk})).content}async function N(e,n={}){let r=n.toolName??"memory_graph_query",s=`**\`memory_graph_query:scope=${e.scope}\`**`,o=e.nodes.map(t=>` - node #${t.id}: ${t.name} (${t.type})${t.ownerAgentId?` [owner=${t.ownerAgentId}]`:" [shared]"}`).join(`
|
|
43
|
+
`),c=e.edges.map(t=>` - edge #${t.id}: ${t.source} --${t.relation}--> ${t.target}`).join(`
|
|
44
|
+
`),i=[s,"",`nodes (${e.nodes.length}${e.truncated?` / total ${e.totalNodes}`:""}):`,o||" (none)","",`edges (${e.edges.length}${e.truncated?` / total ${e.totalEdges}`:""}):`,c||" (none)","",I("graph_query",r)].join(`
|
|
45
|
+
`);return n.sync?$(i,{}).content:(await f(i,{toolName:r,writeToDisk:n.writeToDisk})).content}async function M(e,n={}){let r=n.toolName??"memory_status",c=["**`memory_status`**","",`dbPath: ${e.dbPath}`,`workspaceDir: ${e.workspaceDir}`,`factsCount: ${e.factsCount}`,`nodesCount: ${e.nodesCount} (KG nodes)`,`edgesCount: ${e.edgesCount} (KG edges)`,`ftsAvailable: ${e.ftsAvailable?"yes":"no"}`,`vectorEnabled: ${e.vectorEnabled?"yes":"no"}`,`kgScopeEnabled: ${e.kgScopeEnabled?"yes":"no"}`,`healthy: ${e.healthy?"yes":"no"}`,"","factsByCategory:",...Object.entries(e.factsByCategory).map(([i,t])=>` - ${i}: ${t}`),"","meta:",...Object.entries(e.meta).map(([i,t])=>` - ${i}: ${t}`),"",I("status",r)].join(`
|
|
46
|
+
`);return n.sync?$(c,{}).content:(await f(c,{toolName:r,writeToDisk:n.writeToDisk})).content}async function A(e,n={}){let r=n.toolName??"memory_consolidate",o=["**`memory_consolidate:result`**","",`total facts scanned: ${e.totalFacts}`,`deduped (merged): ${e.dedupedCount}`,`compressed: ${e.compressedCount}`,`archived to archive/: ${e.archivedCount}`,`skipped (no change): ${e.skippedCount}`,`duration: ${e.durationMs}ms`,"",I("consolidate",r)].join(`
|
|
47
|
+
`);return n.sync?$(o,{}).content:(await f(o,{toolName:r,writeToDisk:n.writeToDisk})).content}var E=20;async function _(e,n={}){let r=n.toolName??"memory_sync",o=[`**\`memory_sync:${e.dryRun?"DRY_RUN":"OK"}\`**`,"",`windowDays: ${e.windowDays} (threshold: ${e.archiveThreshold})`,"","## Stage A (db \u2192 .md)",`- generated: ${e.generatedCount}`,`- skipped (idempotent): ${e.skippedCount}`,`- failed (best-effort): ${e.failedGenerateCount}`,"","## Stage B (active/ \u2192 archive/)",`- ${e.dryRun?"would archive":"archived"}: ${e.archivedCount}`];if(e.archivedRecords.length>0){o.push("","### Archived records:");let i=e.archivedRecords.slice(0,E);for(let t of i)o.push(`- ${t.firstFactId} (${t.firstCreatedAt})`),o.push(` - source: \`${t.source}\``),o.push(` - target: \`${t.target}\``);e.archivedRecords.length>E&&o.push(`... and ${e.archivedRecords.length-E} more (use --json for full list)`);}o.push("",`duration: ${e.durationMs}ms`,"",I("sync",r));let c=o.join(`
|
|
48
|
+
`);return n.sync?$(c,{}).content:(await f(c,{toolName:r,writeToDisk:n.writeToDisk})).content}async function O(e,n={}){let r=n.toolName??"memory_doctor",s=`**\`memory_doctor:${e.healthy?"OK":"ISSUES"}\`**`,o=t=>t?"\u2705":"\u274C",c=e.checks.map(t=>`${o(t.passed)} ${t.name}: ${t.message}`).join(`
|
|
49
|
+
`),i=[s,"",c,"",I("doctor",r)].join(`
|
|
50
|
+
`);return n.sync?$(i,{}).content:(await f(i,{toolName:r,writeToDisk:n.writeToDisk})).content}async function w(e,n,r={}){let s=n,o=typeof s.kind=="string";switch((o?s:{kind:e}).kind){case "recall":{let i=o?{hits:s.hits,total:s.totalCount??s.total??0,truncated:s.truncated??false}:n;return S(i,{...r,query:s.query??r.query??"",agentId:s.agentId??r.agentId??"",scope:s.scope??r.scope??"agent_only"})}case "remember":{let i=o?{fact:s.fact,nodeIds:s.nodeIds}:n;return v(i,r)}case "forget":return x(o?s:n,r);case "graph_query":return N(o?s:n,r);case "status":return M(o?s:n,r);case "consolidate":return A(o?s:n,r);case "sync":return _(o?s:n,r);case "doctor":return O(o?s:n,r);default:throw new Error(`renderOperationMarkdown: unsupported op "${e}"`)}}var D=utils.Log.create({service:"memory-mcp-stdio"});function he(e){let n=new Map,r=e.isRemote??true,s=!r;function o(t){let a=utils.Locale.resolveLocaleLang();return {agentId:t.agentId??e.agentId,isTrustedLocal:t.isTrustedLocal??s,remote:r,locale:a,dbPath:e.dbPath,workspaceDir:e.workspaceDir,rootDir:e.workspaceDir,config:chunk5Q6SIVSP_cjs.w({agentId:e.agentId,dbPath:e.dbPath})}}function c(t,a){return {content:[{type:"text",text:t}],isError:a}}function i(t){return mcp.formatFailClosed(t,s)}return n.set("recall",async t=>{try{let a=t,u=o({agentId:a.agentId}),d=await chunk5Q6SIVSP_cjs.v("recall",t,u);return {content:[{type:"text",text:await w("recall",d,{toolName:"memory_recall",query:a.query,agentId:a.agentId??e.agentId,scope:a.scope??"agent_only"})}]}}catch(a){return c(i(a),true)}}),n.set("remember",async t=>{try{let u=o({agentId:t.agentId}),d=await chunk5Q6SIVSP_cjs.v("remember",t,u);return {content:[{type:"text",text:await w("remember",d,{toolName:"memory_remember"})}]}}catch(a){return c(i(a),true)}}),n.set("forget",async t=>{try{let u=o({agentId:t.agentId}),d=await chunk5Q6SIVSP_cjs.v("forget",t,u);return {content:[{type:"text",text:await w("forget",d,{toolName:"memory_forget"})}]}}catch(a){return c(i(a),true)}}),n.set("extract",async t=>{try{let u=o({agentId:t.agentId}),m=await chunk5Q6SIVSP_cjs.v("extract",t,u);return {content:[{type:"text",text:`Extract completed.
|
|
51
|
+
sessionId: ${t.sessionId??"(unknown)"}
|
|
52
|
+
extractedCount: ${m.extractedCount}
|
|
53
|
+
factIds: ${m.factIds.length>0?m.factIds.join(", "):"(none)"}
|
|
54
|
+
messageRange: ${m.messageRange.fromMessageId} -> ${m.messageRange.toMessageId}
|
|
55
|
+
`}]}}catch(a){return c(i(a),true)}}),n.set("consolidate",async t=>{try{let u=o({agentId:t.agentId,isTrustedLocal:!0}),d=await chunk5Q6SIVSP_cjs.v("consolidate",t,u);return {content:[{type:"text",text:await w("consolidate",d,{toolName:"memory_consolidate"})}]}}catch(a){return c(i(a),true)}}),n.set("sync",async t=>{try{let u=t.agentId?.trim();if(!u)return c(i(new Error("memory_sync: agentId is required (sync requires agentId, see ADR 0069)")),!0);let d=o({agentId:u,isTrustedLocal:!0}),m=await chunk5Q6SIVSP_cjs.v("sync",t,d);return {content:[{type:"text",text:await w("sync",m,{toolName:"memory_sync"})}]}}catch(a){return c(i(a),true)}}),n.set("graph_query",async t=>{try{let a=t,u=o({agentId:a.agentId}),d=await chunk5Q6SIVSP_cjs.v("graph_query",t,u);return {content:[{type:"text",text:await w("graph_query",d,{toolName:"memory_graph_query",scope:a.scope??"agent_only"})}]}}catch(a){return c(i(a),true)}}),n.set("status",async t=>{try{let u=o({agentId:(t??{}).agentId}),d=await chunk5Q6SIVSP_cjs.v("status",t,u);return {content:[{type:"text",text:await w("status",d,{toolName:"memory_status"})}]}}catch(a){return c(i(a),true)}}),n.set("doctor",async t=>{try{let u=o({agentId:(t??{}).agentId,isTrustedLocal:!0}),d=await chunk5Q6SIVSP_cjs.v("doctor",t,u);return {content:[{type:"text",text:await w("doctor",d,{toolName:"memory_doctor"})}]}}catch(a){return c(i(a),true)}}),n.set("init",async t=>{try{let a=o({isTrustedLocal:!0}),d=await chunk5Q6SIVSP_cjs.v("init",t,a);return {content:[{type:"text",text:`Init complete.
|
|
56
|
+
dbPath: ${d.dbPath}
|
|
57
|
+
tablesCreated: ${d.tablesCreated}
|
|
58
|
+
migrationsApplied: ${d.migrationsApplied}
|
|
59
|
+
durationMs: ${d.durationMs}
|
|
60
|
+
`}]}}catch(a){return c(i(a),true)}}),n}var ye={recall:chunk5Q6SIVSP_cjs.c,remember:chunk5Q6SIVSP_cjs.d,forget:chunk5Q6SIVSP_cjs.e,extract:chunk5Q6SIVSP_cjs.f,consolidate:chunk5Q6SIVSP_cjs.g,sync:chunk5Q6SIVSP_cjs.j,graph_query:chunk5Q6SIVSP_cjs.h,init:chunk5Q6SIVSP_cjs.i};function fe(e,n){let r=chunk5Q6SIVSP_cjs.t[e],s={title:r?.annotations?.defaultDescription??e,readOnlyHint:r?.annotations?.readOnlyHint??false,destructiveHint:r?.annotations?.destructiveHint??false,idempotentHint:r?.annotations?.idempotentHint??true,openWorldHint:false},o=ye[e];return {name:e,description:r?.annotations?.defaultDescription??`memory op: ${e}`,inputSchema:o??{type:"object",properties:{},required:[]},annotations:s,handler:n}}exports.b=void 0;(r=>{async function e(s,o){let{getMemoryDbPath:c,getInstance:i}=await import('./interfaces-XWE45ENK.cjs'),a=o!==null&&typeof o=="object"&&"agentId"in o&&"dbPath"in o?o:{agentId:process.env.EASBOT_AGENT_ID??"default",dbPath:c(),workspaceDir:i().worktree,isRemote:false},u=new mcp.ToolRegistry,d=he(a),m=Object.keys(chunk5Q6SIVSP_cjs.t);for(let p of m){let P=d.get(p);if(!P)throw new Error(`MemoryStdioServer.start: missing handler for tool "${p}"`);u.register(fe(p,P));}D.info("starting memory MCP stdio server",{id:s.id,name:s.name,toolCount:m.length,isRemote:a.isRemote??true});let l=await mcp.createAndStartStdioServer(s,u),g=null,y=new Promise(p=>{g=p;}),b=p=>{D.info("received signal, stopping MCP server",{signal:p}),g?.();},R=()=>b("SIGINT"),C=()=>b("SIGTERM");process.on("SIGINT",R),process.on("SIGTERM",C);try{await y;}finally{try{process.off("SIGINT",R),process.off("SIGTERM",C);}catch(p){D.warn("failed to remove signal handlers",{error:p instanceof Error?p.message:String(p)});}try{await l.stop();}catch(p){D.warn("server.stop failed during cleanup",{error:p instanceof Error?p.message:String(p)});}}return {id:s.id,name:s.name,version:s.version,tools:m}}r.start=e;function n(){return Object.keys(chunk5Q6SIVSP_cjs.t)}r.getToolNames=n;})(exports.b||(exports.b={}));exports.a=w;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as COMMANDS_HELP,d as handleMemoryCli,b as renderBanner,c as renderHelp}from'./chunk-ARA4LMAI.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-HQBRVVXS.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkQHPGDNEG_cjs=require('./chunk-QHPGDNEG.cjs');require('./chunk-CPRDIUQ4.cjs'),require('./chunk-NVGACA7W.cjs');Object.defineProperty(exports,"COMMANDS_HELP",{enumerable:true,get:function(){return chunkQHPGDNEG_cjs.a}});Object.defineProperty(exports,"handleMemoryCli",{enumerable:true,get:function(){return chunkQHPGDNEG_cjs.d}});Object.defineProperty(exports,"renderBanner",{enumerable:true,get:function(){return chunkQHPGDNEG_cjs.b}});Object.defineProperty(exports,"renderHelp",{enumerable:true,get:function(){return chunkQHPGDNEG_cjs.c}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import'./chunk-
|
|
1
|
+
import'./chunk-HQBRVVXS.mjs';function r(o){return {ok:true,message:"memory config: OK (placeholder; v0.4 stage 5 will fully implement)"}}function g(o){return o.message}function f(o){let e={};for(let n=0;n<o.length;n++){let t=o[n];t==="--json"?e.json=true:(t==="--help"||t==="-h")&&(e.help=true);}return e}export{g as formatConfigText,f as parseConfigOptions,r as runConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';require('./chunk-
|
|
1
|
+
'use strict';require('./chunk-NVGACA7W.cjs');function s(o){return {ok:true,message:"memory config: OK (placeholder; v0.4 stage 5 will fully implement)"}}function r(o){return o.message}function g(o){let e={};for(let n=0;n<o.length;n++){let t=o[n];t==="--json"?e.json=true:(t==="--help"||t==="-h")&&(e.help=true);}return e}exports.formatConfigText=r;exports.parseConfigOptions=g;exports.runConfig=s;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function m(t){let n=t.agentId?.trim()||"default",o=t.workspaceDir??process.cwd();return chunk5Q6SIVSP_cjs.v("consolidate",{windowDays:t.windowDays??30,dryRun:false},chunk5Q6SIVSP_cjs.x(n,o))}function C(t){let n=t;return [chunk4GSXSIV5_cjs.b("consolidate",{},"Consolidation complete ({{totalFacts}} total / deduped {{dedupedCount}} / archived {{archivedCount}}):"),chunk4GSXSIV5_cjs.c("consolidate",{totalFacts:String(n.totalFacts),dedupedCount:String(n.dedupedCount),archivedCount:String(n.archivedCount)}," - total: {{totalFacts}}, deduped: {{dedupedCount}}, archived: {{archivedCount}}"),` - skipped: ${n.skippedCount}, duration: ${n.durationMs}ms`].join(`
|
|
2
|
+
`)}function f(t){let n={};for(let o=0;o<t.length;o++){let e=t[o];if(e===void 0)continue;let i=t[o+1];e==="--agent"?(n.agentId=i,o++):e==="--window-days"?(n.windowDays=Number(i),o++):e==="--json"?n.json=true:(e==="--help"||e==="-h")&&(n.help=true);}return n}exports.formatConsolidateText=C;exports.parseConsolidateOptions=f;exports.runConsolidate=m;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x}from'./chunk-746FKSL5.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function C(t){let n=t.agentId?.trim()||"default",o=t.workspaceDir??process.cwd();return v("consolidate",{windowDays:t.windowDays??30,dryRun:false},x(n,o))}function f(t){let n=t;return [b("consolidate",{},"Consolidation complete ({{totalFacts}} total / deduped {{dedupedCount}} / archived {{archivedCount}}):"),c("consolidate",{totalFacts:String(n.totalFacts),dedupedCount:String(n.dedupedCount),archivedCount:String(n.archivedCount)}," - total: {{totalFacts}}, deduped: {{dedupedCount}}, archived: {{archivedCount}}"),` - skipped: ${n.skippedCount}, duration: ${n.durationMs}ms`].join(`
|
|
2
|
+
`)}function w(t){let n={};for(let o=0;o<t.length;o++){let e=t[o];if(e===void 0)continue;let i=t[o+1];e==="--agent"?(n.agentId=i,o++):e==="--window-days"?(n.windowDays=Number(i),o++):e==="--json"?n.json=true:(e==="--help"||e==="-h")&&(n.help=true);}return n}export{f as formatConsolidateText,w as parseConsolidateOptions,C as runConsolidate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {v,x}from'./chunk-746FKSL5.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 chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.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 chunk5Q6SIVSP_cjs.v("doctor",{repair:o.repair??false},chunk5Q6SIVSP_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
|
+
'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.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 chunk5Q6SIVSP_cjs.v("extract",{sessionId:r.sessionId,lastN:r.lastN??10,fromMessageId:r.fromMessageId},chunk5Q6SIVSP_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,2 @@
|
|
|
1
|
+
import {b,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x as x$1}from'./chunk-746FKSL5.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,3 @@
|
|
|
1
|
+
import {a,b,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x as x$1}from'./chunk-746FKSL5.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
|
+
`);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 chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.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 chunk5Q6SIVSP_cjs.v("forget",{factId:n.factId,category:n.category,fromTime:n.fromTime,toTime:n.toTime,maxDelete:n.maxDelete??1e3,dryRun:n.dryRun??false},chunk5Q6SIVSP_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;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.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 chunk5Q6SIVSP_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"},chunk5Q6SIVSP_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,3 @@
|
|
|
1
|
+
import {b,a,c as c$1}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x}from'./chunk-746FKSL5.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
|
+
`);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 @@
|
|
|
1
|
+
'use strict';var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.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 chunk5Q6SIVSP_cjs.v("init",{workspaceDir:e,dbPath:chunkCPRDIUQ4_cjs.j(n),force:t.force??false},chunk5Q6SIVSP_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-746FKSL5.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};
|
|
@@ -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
|
+
'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';
|
|
@@ -0,0 +1 @@
|
|
|
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-JPMLMEWY.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 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-GABA2MLR.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
|
+
'use strict';var chunkWQB4D6DZ_cjs=require('./chunk-WQB4D6DZ.cjs'),chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.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 chunk5Q6SIVSP_cjs.v("recall",{query:n.query,maxResults:n.limit??10,category:n.category,minImportance:n.minImportance},chunk5Q6SIVSP_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
|
+
import {a}from'./chunk-SWYQLQ7Z.mjs';import {v,x}from'./chunk-746FKSL5.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
|
+
import {b as b$1,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x}from'./chunk-746FKSL5.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,2 @@
|
|
|
1
|
+
'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.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 chunk5Q6SIVSP_cjs.v("remember",{content:r.content,category:r.category,importance:r.importance,tags:r.tags,sessionId:r.sessionId},chunk5Q6SIVSP_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 @@
|
|
|
1
|
+
'use strict';var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.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 chunk5Q6SIVSP_cjs.v("status",{agentId:n},chunk5Q6SIVSP_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
|
+
import {v,x}from'./chunk-746FKSL5.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 chunkX66LENNV_cjs=require('./chunk-X66LENNV.cjs');require('./chunk-5Q6SIVSP.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 chunkX66LENNV_cjs.b}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{b as MemoryStdioServer}from'./chunk-CN6WBJLX.mjs';import'./chunk-746FKSL5.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x}from'./chunk-746FKSL5.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.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 chunk5Q6SIVSP_cjs.v("sync",{windowDays:e.windowDays,dryRun:e.dryRun??false},chunk5Q6SIVSP_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;
|