@easbot/memory 0.3.23 → 0.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +15 -5
  2. package/dist/chunks/{chunk-OU5TQHJE.cjs → chunk-46Y7MLBE.cjs} +1 -1
  3. package/dist/chunks/chunk-5VZKEZI4.cjs +67 -0
  4. package/dist/chunks/chunk-C3Z455VR.mjs +67 -0
  5. package/dist/chunks/{chunk-PJGILQSZ.mjs → chunk-FY4ILCIM.mjs} +5 -6
  6. package/dist/chunks/chunk-GL5U3MRI.mjs +64 -0
  7. package/dist/chunks/{chunk-EK34SXJ7.cjs → chunk-LYBUZDJK.cjs} +5 -6
  8. package/dist/chunks/chunk-MPGIP3IF.cjs +64 -0
  9. package/dist/chunks/{chunk-3EDNN7MP.mjs → chunk-PGJB2U24.mjs} +1 -1
  10. package/dist/chunks/cli-handler-KTFW5CCH.mjs +1 -0
  11. package/dist/chunks/cli-handler-Y43WWXOO.cjs +1 -0
  12. package/dist/chunks/consolidate-VGPUQRPU.mjs +2 -0
  13. package/dist/chunks/{consolidate-JGLVNSDT.cjs → consolidate-X52RRH2C.cjs} +1 -1
  14. package/dist/chunks/doctor-RNI5F6GO.mjs +1 -0
  15. package/dist/chunks/doctor-SJY3K3DV.cjs +1 -0
  16. package/dist/chunks/{extract-WH4DU4NQ.mjs → extract-ANENWMHZ.mjs} +1 -1
  17. package/dist/chunks/{extract-4ZGVF2DQ.cjs → extract-L2V2RMDQ.cjs} +1 -1
  18. package/dist/chunks/{forget-CRDWG4XE.mjs → forget-QNG6GELC.mjs} +1 -1
  19. package/dist/chunks/{forget-PARGCUIH.cjs → forget-SSGVAE5Y.cjs} +1 -1
  20. package/dist/chunks/graph-KNLZRAPI.mjs +3 -0
  21. package/dist/chunks/graph-WIKKSBLC.cjs +3 -0
  22. package/dist/chunks/{init-2ZTVBJ6N.mjs → init-2UNKNWR5.mjs} +1 -1
  23. package/dist/chunks/{init-EEWFFF4Y.cjs → init-UNDHFDAC.cjs} +1 -1
  24. package/dist/chunks/{mcp-ES7O3UKN.cjs → mcp-PRR2RYOP.cjs} +1 -1
  25. package/dist/chunks/{mcp-OAUOA4PI.mjs → mcp-RMLMXPZ7.mjs} +1 -1
  26. package/dist/chunks/recall-7TPMD7ZE.mjs +2 -0
  27. package/dist/chunks/{recall-LCKRI4TB.cjs → recall-M2EWX25U.cjs} +1 -1
  28. package/dist/chunks/{remember-OZOQ76IA.cjs → remember-BXVUUY5M.cjs} +1 -1
  29. package/dist/chunks/{remember-ZVTM3IP4.mjs → remember-H5CYMLG5.mjs} +1 -1
  30. package/dist/chunks/{status-6R335JGR.cjs → status-A2JC6NFH.cjs} +1 -1
  31. package/dist/chunks/{status-LHXMB3ZY.mjs → status-MJFDNSPW.mjs} +1 -1
  32. package/dist/chunks/stdio-server-43QC3XIS.mjs +1 -0
  33. package/dist/chunks/{stdio-server-IMJF7HB6.cjs → stdio-server-SXDIW3RQ.cjs} +1 -1
  34. package/dist/chunks/{sync-7VBREDVM.cjs → sync-3RWIZYR6.cjs} +1 -1
  35. package/dist/chunks/{sync-KWHUII26.mjs → sync-GPRNZLZA.mjs} +1 -1
  36. package/dist/cli.cjs +1 -1
  37. package/dist/cli.mjs +1 -1
  38. package/dist/index.cjs +4 -4
  39. package/dist/index.d.cts +7 -2
  40. package/dist/index.d.ts +7 -2
  41. package/dist/index.mjs +4 -4
  42. package/package.json +9 -9
  43. package/dist/chunks/chunk-2TBNGTSA.mjs +0 -65
  44. package/dist/chunks/chunk-5YDI4K2F.cjs +0 -65
  45. package/dist/chunks/chunk-K4K3YR6R.mjs +0 -66
  46. package/dist/chunks/chunk-MENFLGGM.cjs +0 -66
  47. package/dist/chunks/cli-handler-7HISH37M.cjs +0 -1
  48. package/dist/chunks/cli-handler-WOX5EG34.mjs +0 -1
  49. package/dist/chunks/consolidate-JBTOQWUX.mjs +0 -2
  50. package/dist/chunks/doctor-C7RIJGYC.cjs +0 -1
  51. package/dist/chunks/doctor-DLQO7QMW.mjs +0 -1
  52. package/dist/chunks/graph-NJJLGDZI.cjs +0 -3
  53. package/dist/chunks/graph-T66JXDLU.mjs +0 -3
  54. package/dist/chunks/recall-VMW7Y55X.mjs +0 -2
  55. package/dist/chunks/stdio-server-SONZIWC4.mjs +0 -1
@@ -1,4 +1,4 @@
1
- import {a}from'./chunk-HQBRVVXS.mjs';import {Log,Filesystem}from'@easbot/utils';import {createSyncSqliteConnection}from'@easbot/database';var c=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 (
1
+ import {a}from'./chunk-HQBRVVXS.mjs';import {Log,Filesystem}from'@easbot/utils';import {createSyncSqliteConnection}from'@easbot/database';var c=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
2
  id TEXT PRIMARY KEY,
3
3
  agent_id TEXT NOT NULL,
4
4
  session_id TEXT,
@@ -32,12 +32,11 @@ import {a}from'./chunk-HQBRVVXS.mjs';import {Log,Filesystem}from'@easbot/utils';
32
32
  id INTEGER PRIMARY KEY AUTOINCREMENT,
33
33
  name TEXT NOT NULL,
34
34
  type TEXT NOT NULL,
35
- owner_agent_id TEXT,
36
35
  properties TEXT,
37
36
  embedding BLOB,
38
37
  createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
39
38
  updatedAt DATETIME DEFAULT CURRENT_TIMESTAMP
40
- )`,"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 INDEX IF NOT EXISTS idx_nodes_embedding ON nodes(embedding) WHERE embedding IS NOT NULL","CREATE UNIQUE INDEX IF NOT EXISTS idx_nodes_name_type ON nodes(name, type)",`CREATE TABLE IF NOT EXISTS fact_nodes (
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_embedding ON nodes(embedding) WHERE embedding IS NOT NULL","CREATE UNIQUE INDEX IF NOT EXISTS idx_nodes_name_type ON nodes(name, type)",`CREATE TABLE IF NOT EXISTS fact_nodes (
41
40
  fact_id TEXT NOT NULL,
42
41
  node_id INTEGER NOT NULL,
43
42
  source TEXT NOT NULL DEFAULT 'kg_extract',
@@ -58,10 +57,10 @@ import {a}from'./chunk-HQBRVVXS.mjs';import {Log,Filesystem}from'@easbot/utils';
58
57
  )`,"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 (
59
58
  key TEXT PRIMARY KEY,
60
59
  value TEXT
61
- )`,"ALTER TABLE nodes ADD COLUMN embedding BLOB","CREATE INDEX IF NOT EXISTS idx_nodes_embedding ON nodes(embedding) WHERE embedding IS NOT NULL"]}];function l(n,e=m,r={}){n.exec(`CREATE TABLE IF NOT EXISTS schema_migrations (
60
+ )`,"ALTER TABLE nodes ADD COLUMN embedding BLOB","CREATE INDEX IF NOT EXISTS idx_nodes_embedding ON nodes(embedding) WHERE embedding IS NOT NULL"]}];function g(n,e=m,r={}){n.exec(`CREATE TABLE IF NOT EXISTS schema_migrations (
62
61
  id INTEGER PRIMARY KEY,
63
62
  applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
64
- )`);let t=n.prepare("SELECT id FROM schema_migrations").all(),s=new Set(t.map(i=>i.id)),a={applied:[],pending:[],errors:[],currentVersion:t.length===0?0:Math.max(...t.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(r.dryRun){a.applied.push(i.id);continue}try{f(n,i.up),n.prepare("INSERT INTO schema_migrations (id) VALUES (?)").run(i.id),s.add(i.id),a.applied.push(i.id),c.info("migration applied",{id:i.id,description:i.description});}catch(o){let d=o instanceof Error?o.message:String(o),T=i.up[0]??"";a.errors.push({migrationId:i.id,sql:T,error:d}),c.warn("migration step failed",{id:i.id,error:d,sqlCount:i.up.length});}}return a}function f(n,e){for(let r of e)try{n.exec(r);}catch(t){let s=t instanceof Error?t.message:String(t);if(O(s)){c.debug("migration: column already exists, skipping",{sql:r.slice(0,80)});continue}throw t}}function O(n){return /duplicate column name/i.test(n)}function _(n){try{let e=n.prepare("SELECT id FROM schema_migrations").all();return e.length===0?0:Math.max(...e.map(r=>r.id))}catch{return 0}}var N=Log.create({service:"memory-database"}),u=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 r=e instanceof Error?e.message:String(e);throw N.error("Database initialization failed",{error:r}),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){N.warn("Failed to apply memory PRAGMAs",{error:String(e)});}}runAllMigrations(){if(!this.db)throw new Error("Database not initialized");let e=l(this.db,m);if(e.errors.length>0){let r=e.errors.map(t=>`migration ${t.migrationId}: ${t.error}`).join("; ");throw new Error(`Some migrations failed: ${r}`)}}query(e,r){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");try{let t=this.db.prepare(e);return r?t.all(...r):t.all()}catch(t){throw new Error(`Query failed: ${t.message}`)}}agentFilter(e){return typeof e=="string"&&e.trim().length>0?{where:"WHERE agent_id = ?",params:[e.trim()]}:{where:"",params:[]}}run(e,r){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");try{let t=this.db.prepare(e),s=r?t.run(...r):t.run();return {lastID:Number(s.lastInsertRowid),changes:s.changes}}catch(t){throw new Error(`Write failed: ${t.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 _(this.db)}close(){if(this.db){try{this.db.close();}catch(e){N.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=S=>this.db.prepare(S).get().c,r={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"),fact_nodes:e("SELECT COUNT(*) as c FROM fact_nodes"),meta:e("SELECT COUNT(*) as c FROM meta"),schema_migrations:e("SELECT COUNT(*) as c FROM schema_migrations")},t=[],s=e(`
63
+ )`);let t=n.prepare("SELECT id FROM schema_migrations").all(),s=new Set(t.map(i=>i.id)),a={applied:[],pending:[],errors:[],currentVersion:t.length===0?0:Math.max(...t.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(r.dryRun){a.applied.push(i.id);continue}try{I(n,i.up),n.prepare("INSERT INTO schema_migrations (id) VALUES (?)").run(i.id),s.add(i.id),a.applied.push(i.id),c.info("migration applied",{id:i.id,description:i.description});}catch(o){let d=o instanceof Error?o.message:String(o),T=i.up[0]??"";a.errors.push({migrationId:i.id,sql:T,error:d}),c.warn("migration step failed",{id:i.id,error:d,sqlCount:i.up.length});}}return a}function I(n,e){for(let r of e)try{n.exec(r);}catch(t){let s=t instanceof Error?t.message:String(t);if(O(s)){c.debug("migration: column already exists, skipping",{sql:r.slice(0,80)});continue}throw t}}function O(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(r=>r.id))}catch{return 0}}var N=Log.create({service:"memory-database"}),_=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 r=e instanceof Error?e.message:String(e);throw N.error("Database initialization failed",{error:r}),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){N.warn("Failed to apply memory PRAGMAs",{error:String(e)});}}runAllMigrations(){if(!this.db)throw new Error("Database not initialized");let e=g(this.db,m);if(e.errors.length>0){let r=e.errors.map(t=>`migration ${t.migrationId}: ${t.error}`).join("; ");throw new Error(`Some migrations failed: ${r}`)}}query(e,r){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");try{let t=this.db.prepare(e);return r?t.all(...r):t.all()}catch(t){throw new Error(`Query failed: ${t.message}`)}}agentFilter(e){return typeof e=="string"&&e.trim().length>0?{where:"WHERE agent_id = ?",params:[e.trim()]}:{where:"",params:[]}}run(e,r){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");try{let t=this.db.prepare(e),s=r?t.run(...r):t.run();return {lastID:Number(s.lastInsertRowid),changes:s.changes}}catch(t){throw new Error(`Write failed: ${t.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){N.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=p=>this.db.prepare(p).get().c,r={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"),fact_nodes:e("SELECT COUNT(*) as c FROM fact_nodes"),meta:e("SELECT COUNT(*) as c FROM meta"),schema_migrations:e("SELECT COUNT(*) as c FROM schema_migrations")},t=[],s=e(`
65
64
  SELECT COUNT(*) as c FROM fact_nodes fn
66
65
  LEFT JOIN nodes n ON n.id = fn.node_id
67
66
  WHERE n.id IS NULL
@@ -75,4 +74,4 @@ import {a}from'./chunk-HQBRVVXS.mjs';import {Log,Filesystem}from'@easbot/utils';
75
74
  EXCEPT
76
75
  SELECT id FROM memory_facts
77
76
  )
78
- `);d>0&&t.push({severity:"warn",message:`FTS out of sync (orphan entries): ${d}`});let T=e("SELECT COUNT(*) as c FROM (SELECT id, COUNT(*) as c FROM memory_facts GROUP BY id HAVING c > 1)");T>0&&t.push({severity:"error",message:`duplicate fact ids: ${T}`});let g=e("SELECT COUNT(*) as c FROM memory_facts WHERE content IS NULL OR content = ''");return g>0&&t.push({severity:"error",message:`memory_facts with null/empty content: ${g}`}),{issues:t,stats:r}}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,r){if(!this.db)throw new Error("Database not initialized");this.db.prepare("INSERT OR REPLACE INTO meta (key, value) VALUES (?, ?)").run(e,r);}};export{m as a,R as b,l as c,_ as d,u as e};
77
+ `);d>0&&t.push({severity:"warn",message:`FTS out of sync (orphan entries): ${d}`});let T=e("SELECT COUNT(*) as c FROM (SELECT id, COUNT(*) as c FROM memory_facts GROUP BY id HAVING c > 1)");T>0&&t.push({severity:"error",message:`duplicate fact ids: ${T}`});let l=e("SELECT COUNT(*) as c FROM memory_facts WHERE content IS NULL OR content = ''");return l>0&&t.push({severity:"error",message:`memory_facts with null/empty content: ${l}`}),{issues:t,stats:r}}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,r){if(!this.db)throw new Error("Database not initialized");this.db.prepare("INSERT OR REPLACE INTO meta (key, value) VALUES (?, ?)").run(e,r);}};export{m as a,f as b,g as c,u as d,_ as e};
@@ -0,0 +1,64 @@
1
+ import {x as x$1,z,l,k,j,i,m,h,g,f as f$1,e,d,c,A as A$1}from'./chunk-C3Z455VR.mjs';import {extendKnownErrorCodes,ToolRegistry,createAndStartStdioServer,formatFailClosed}from'@easbot/mcp';import {Log,Locale,TruncateContent}from'@easbot/utils';var ae=Log.create({service:"memory-format-truncate"}),Z="**`";var V=24e3,ee=25e3;async function y(e,n={}){let r=n.softLimit??V,s=n.hardCeiling??ee,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
+ ${Z}`),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,g=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:g,truncated:true,outputPath:"",hint:"Make another recall / graph_query with narrower scope.",info:`... ${e.length-d.length}/${e.length} characters truncated ...`};try{let p=await TruncateContent.truncate(e,{maxChars:d.length,direction:"head",label:`${o}-output`});return p.truncated?{content:g,truncated:!0,outputPath:p.outputPath,hint:TruncateContent.formatHint(p),info:`... ${p.removedLength}/${p.originalLength} characters truncated ...`}:{content:g,truncated:!0,outputPath:"",hint:"Make another recall / graph_query with narrower scope.",info:`... ${e.length-d.length}/${e.length} characters truncated ...`}}catch(p){return ae.warn("TruncateContent.truncate failed, returning without disk hint",{error:p instanceof Error?p.message:String(p)}),{content:g,truncated:true,outputPath:"",hint:"Make another recall / graph_query with narrower scope.",info:`... ${e.length-d.length}/${e.length} characters truncated ...`}}}function f(e,n={}){let r=n.softLimit??V,s=n.hardCeiling??ee;if(e.length<=r)return {content:e,truncated:false};let o=e.slice(0,s),c=o.lastIndexOf(`
4
+ ${Z}`),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 se(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 b(e,n,r={}){return (te[e]??te.default).replace(/<(\w+)>/g,(o,c)=>c==="tool"?n:r[c]??`<${c}>`)}var te={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 ie(e){let n=Array.isArray(e.edges)?e.edges.length:0;return ` - node #${e.id}: ${e.name} (${e.type}) [edges: ${n}]`}function ne(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=s.map(ie);u=`
14
+ - linked KG nodes (${s.length}) \u2014 use \`graph_query(nodeId=<id>)\` for full relation graph:
15
+ ${d.join(`
16
+ `)}`;}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(`
17
+ `)}async function v(e,n){let r=n.toolName??"memory_recall",s=`**\`memory_recall:${n.query.slice(0,40).replace(/[^a-zA-Z0-9_]/g,"_")}\`**`,o=se(n.pendingFiles,new Set),i=[`Found ${e.total} fact(s) for query "${n.query}" (agentId=${n.agentId}, scope=${n.scope}):`,"",o??"",s].join(`
18
+ `),t=new Map;for(let m of e.hits){let g=m.fact.category;t.has(g)||t.set(g,[]),t.get(g).push(m);}let a=Array.from(t.entries()).map(([m,g])=>{let p=`**\`category:${m}\`**`,D=g.map(w=>ne(w.fact,w.score,w.source,w.nodes)).join(`
19
+ `);return `${p}
20
+
21
+ ${D}`}).join(`
22
+ `),u=e.warnings&&e.warnings.length>0?`
23
+
24
+ \u26A0\uFE0F warnings:
25
+ ${e.warnings.map(m=>` - ${m}`).join(`
26
+ `)}
27
+ `:"",d=`${i}
28
+
29
+ ${a}${u}
30
+
31
+ ${b("recall",r)}`;return n.sync?f(d,{}).content:(await y(d,{toolName:r,writeToDisk:n.writeToDisk})).content}async function N(e,n={}){let r=n.toolName??"memory_remember",s=`**\`memory_remember:${e.fact.id}\`**`,o=ne(e.fact),c=e.nodeIds??[],i=c.length>0?`
32
+ - linked KG nodes: ${c.join(", ")}
33
+ `:"",t=`${s}
34
+
35
+ ${o}${i}
36
+
37
+ ${b("remember",r)}`;return n.sync?f(t,{}).content:(await y(t,{toolName:r,writeToDisk:n.writeToDisk})).content}async function _(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:
38
+ ${e.deletedIds.map(t=>` - ${t}`).join(`
39
+ `)}`:"(no ids to show)","",b("forget",r)].join(`
40
+ `);return n.sync?f(i,{}).content:(await y(i,{toolName:r,writeToDisk:n.writeToDisk})).content}async function A(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(`
41
+ `),c=e.edges.map(t=>` - edge #${t.id}: ${t.source} --${t.relation}--> ${t.target}`).join(`
42
+ `),i=[s,"",`nodes (${e.nodes.length}${e.truncated?` / total ${e.totalNodes}`:""}):`,o||" (none)","",`edges (${e.edges.length}${e.truncated?` / total ${e.totalEdges}`:""}):`,c||" (none)","",b("graph_query",r)].join(`
43
+ `);return n.sync?f(i,{}).content:(await y(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}`),"",b("status",r)].join(`
44
+ `);return n.sync?f(c,{}).content:(await y(c,{toolName:r,writeToDisk:n.writeToDisk})).content}async function O(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`,"",b("consolidate",r)].join(`
45
+ `);return n.sync?f(o,{}).content:(await y(o,{toolName:r,writeToDisk:n.writeToDisk})).content}var x=20;async function P(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,x);for(let t of i)o.push(`- ${t.firstFactId} (${t.firstCreatedAt})`),o.push(` - source: \`${t.source}\``),o.push(` - target: \`${t.target}\``);e.archivedRecords.length>x&&o.push(`... and ${e.archivedRecords.length-x} more (use --json for full list)`);}o.push("",`duration: ${e.durationMs}ms`,"",b("sync",r));let c=o.join(`
46
+ `);return n.sync?f(c,{}).content:(await y(c,{toolName:r,writeToDisk:n.writeToDisk})).content}async function L(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(`
47
+ `),i=[s,"",c,"",b("doctor",r)].join(`
48
+ `);return n.sync?f(i,{}).content:(await y(i,{toolName:r,writeToDisk:n.writeToDisk})).content}async function $(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 v(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 N(i,r)}case "forget":return _(o?s:n,r);case "graph_query":return A(o?s:n,r);case "status":return M(o?s:n,r);case "consolidate":return O(o?s:n,r);case "sync":return P(o?s:n,r);case "doctor":return L(o?s:n,r);default:throw new Error(`renderOperationMarkdown: unsupported op "${e}"`)}}var E=Log.create({service:"memory-mcp-stdio"});function Re(e){let n=new Map,r=e.isRemote??true,s=!r;function o(t){let a=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:A$1({agentId:e.agentId,dbPath:e.dbPath})}}function c(t,a){return {content:[{type:"text",text:t}],isError:a}}function i(t){return formatFailClosed(t,s)}return n.set("recall",async t=>{try{let a=t,u=o({agentId:a.agentId}),d=await z("recall",t,u);return {content:[{type:"text",text:await $("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 z("remember",t,u);return {content:[{type:"text",text:await $("remember",d,{toolName:"memory_remember"})}]}}catch(a){return c(i(a),true)}}),n.set("update",async t=>{try{let u=o({agentId:t.agentId}),d=await z("update",t,u),m=d.fieldsUpdated.length>0?d.fieldsUpdated.join(", "):"(no-op)",g=d.contentChanged?" (embedding rewritten)":"";return {content:[{type:"text",text:`Memory updated.
49
+ id: ${d.fact.id}
50
+ category: ${d.fact.category}
51
+ importance: ${d.fact.importance}
52
+ fields updated: ${m}${g}
53
+ updated_at: ${d.fact.updatedAt}
54
+ `}]}}catch(a){return c(i(a),true)}}),n.set("forget",async t=>{try{let u=o({agentId:t.agentId}),d=await z("forget",t,u);return {content:[{type:"text",text:await $("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 z("extract",t,u);return {content:[{type:"text",text:`Extract completed.
55
+ sessionId: ${t.sessionId??"(unknown)"}
56
+ extractedCount: ${m.extractedCount}
57
+ factIds: ${m.factIds.length>0?m.factIds.join(", "):"(none)"}
58
+ messageRange: ${m.messageRange.fromMessageId} -> ${m.messageRange.toMessageId}
59
+ `}]}}catch(a){return c(i(a),true)}}),n.set("consolidate",async t=>{try{let u=o({agentId:t.agentId,isTrustedLocal:!0}),d=await z("consolidate",t,u);return {content:[{type:"text",text:await $("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 z("sync",t,d);return {content:[{type:"text",text:await $("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 z("graph_query",t,u);return {content:[{type:"text",text:await $("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 z("status",t,u);return {content:[{type:"text",text:await $("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 z("doctor",t,u);return {content:[{type:"text",text:await $("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 z("init",t,a);return {content:[{type:"text",text:`Init complete.
60
+ dbPath: ${d.dbPath}
61
+ tablesCreated: ${d.tablesCreated}
62
+ migrationsApplied: ${d.migrationsApplied}
63
+ durationMs: ${d.durationMs}
64
+ `}]}}catch(a){return c(i(a),true)}}),n}var Ce={recall:c,remember:d,update:e,forget:f$1,extract:g,consolidate:h,sync:m,graph_query:i,status:j,doctor:k,init:l};function Te(e,n){let r=x$1[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=Ce[e];return {name:e,description:r?.annotations?.defaultDescription??`memory op: ${e}`,inputSchema:o??{type:"object",properties:{},required:[],additionalProperties:false},annotations:s,handler:n}}var re;(r=>{async function e(s,o){let{getMemoryDbPath:c,getInstance:i}=await import('./interfaces-LPJU4KS3.mjs'),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};extendKnownErrorCodes(["AGENT_ID_REQUIRED","SESSION_ID_REQUIRED","CATEGORY_REQUIRED","IMPORTANCE_REQUIRED","TIMERANGE_REQUIRED","DRY_RUN_NO_DELETE"]);let u=new ToolRegistry,d=Re(a),m=Object.keys(x$1);for(let l of m){let I=d.get(l);if(!I)throw new Error(`MemoryStdioServer.start: missing handler for tool "${l}"`);u.register(Te(l,I));}E.info("starting memory MCP stdio server",{id:s.id,name:s.name,toolCount:m.length,isRemote:a.isRemote??true});let g=await createAndStartStdioServer(s,u),p=null,D=new Promise(l=>{p=l;}),w=l=>{E.info("received signal, stopping MCP server",{signal:l}),p?.();},k=()=>w("SIGINT"),S=()=>w("SIGTERM"),F=(l,I)=>process.listeners(l).includes(I);F("SIGINT",k)||process.on("SIGINT",k),F("SIGTERM",S)||process.on("SIGTERM",S);try{await D;}finally{try{process.off("SIGINT",k),process.off("SIGTERM",S);}catch(l){E.warn("failed to remove signal handlers",{error:l instanceof Error?l.message:String(l)});}try{await g.stop();}catch(l){E.warn("server.stop failed during cleanup",{error:l instanceof Error?l.message:String(l)});}}return {id:s.id,name:s.name,version:s.version,tools:m}}r.start=e;function n(){return Object.keys(x$1)}r.getToolNames=n;})(re||(re={}));export{$ as a,re as b};
@@ -1,4 +1,4 @@
1
- 'use strict';var chunkM2YU5LAI_cjs=require('./chunk-M2YU5LAI.cjs'),utils=require('@easbot/utils'),database=require('@easbot/database');var c=utils.Log.create({service:"memory-schema-migrations"}),m=1,I=[{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 (
1
+ 'use strict';var chunkM2YU5LAI_cjs=require('./chunk-M2YU5LAI.cjs'),utils=require('@easbot/utils'),database=require('@easbot/database');var c=utils.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
2
  id TEXT PRIMARY KEY,
3
3
  agent_id TEXT NOT NULL,
4
4
  session_id TEXT,
@@ -32,12 +32,11 @@
32
32
  id INTEGER PRIMARY KEY AUTOINCREMENT,
33
33
  name TEXT NOT NULL,
34
34
  type TEXT NOT NULL,
35
- owner_agent_id TEXT,
36
35
  properties TEXT,
37
36
  embedding BLOB,
38
37
  createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
39
38
  updatedAt DATETIME DEFAULT CURRENT_TIMESTAMP
40
- )`,"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 INDEX IF NOT EXISTS idx_nodes_embedding ON nodes(embedding) WHERE embedding IS NOT NULL","CREATE UNIQUE INDEX IF NOT EXISTS idx_nodes_name_type ON nodes(name, type)",`CREATE TABLE IF NOT EXISTS fact_nodes (
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_embedding ON nodes(embedding) WHERE embedding IS NOT NULL","CREATE UNIQUE INDEX IF NOT EXISTS idx_nodes_name_type ON nodes(name, type)",`CREATE TABLE IF NOT EXISTS fact_nodes (
41
40
  fact_id TEXT NOT NULL,
42
41
  node_id INTEGER NOT NULL,
43
42
  source TEXT NOT NULL DEFAULT 'kg_extract',
@@ -58,10 +57,10 @@
58
57
  )`,"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 (
59
58
  key TEXT PRIMARY KEY,
60
59
  value TEXT
61
- )`,"ALTER TABLE nodes ADD COLUMN embedding BLOB","CREATE INDEX IF NOT EXISTS idx_nodes_embedding ON nodes(embedding) WHERE embedding IS NOT NULL"]}];function l(n,e=m,r={}){n.exec(`CREATE TABLE IF NOT EXISTS schema_migrations (
60
+ )`,"ALTER TABLE nodes ADD COLUMN embedding BLOB","CREATE INDEX IF NOT EXISTS idx_nodes_embedding ON nodes(embedding) WHERE embedding IS NOT NULL"]}];function g(n,e=m,r={}){n.exec(`CREATE TABLE IF NOT EXISTS schema_migrations (
62
61
  id INTEGER PRIMARY KEY,
63
62
  applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
64
- )`);let t=n.prepare("SELECT id FROM schema_migrations").all(),s=new Set(t.map(i=>i.id)),a={applied:[],pending:[],errors:[],currentVersion:t.length===0?0:Math.max(...t.map(i=>i.id)),targetVersion:e};for(let i of I){if(i.id>e)break;if(s.has(i.id)){a.pending.push(i.id);continue}if(r.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),c.info("migration applied",{id:i.id,description:i.description});}catch(o){let d=o instanceof Error?o.message:String(o),T=i.up[0]??"";a.errors.push({migrationId:i.id,sql:T,error:d}),c.warn("migration step failed",{id:i.id,error:d,sqlCount:i.up.length});}}return a}function R(n,e){for(let r of e)try{n.exec(r);}catch(t){let s=t instanceof Error?t.message:String(t);if(f(s)){c.debug("migration: column already exists, skipping",{sql:r.slice(0,80)});continue}throw t}}function f(n){return /duplicate column name/i.test(n)}function _(n){try{let e=n.prepare("SELECT id FROM schema_migrations").all();return e.length===0?0:Math.max(...e.map(r=>r.id))}catch{return 0}}var N=utils.Log.create({service:"memory-database"}),u=class{constructor(e){chunkM2YU5LAI_cjs.a(this,"db",null);chunkM2YU5LAI_cjs.a(this,"storagePath");chunkM2YU5LAI_cjs.a(this,"backend","better-sqlite3");chunkM2YU5LAI_cjs.a(this,"initialized",false);chunkM2YU5LAI_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 r=e instanceof Error?e.message:String(e);throw N.error("Database initialization failed",{error:r}),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){N.warn("Failed to apply memory PRAGMAs",{error:String(e)});}}runAllMigrations(){if(!this.db)throw new Error("Database not initialized");let e=l(this.db,m);if(e.errors.length>0){let r=e.errors.map(t=>`migration ${t.migrationId}: ${t.error}`).join("; ");throw new Error(`Some migrations failed: ${r}`)}}query(e,r){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");try{let t=this.db.prepare(e);return r?t.all(...r):t.all()}catch(t){throw new Error(`Query failed: ${t.message}`)}}agentFilter(e){return typeof e=="string"&&e.trim().length>0?{where:"WHERE agent_id = ?",params:[e.trim()]}:{where:"",params:[]}}run(e,r){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");try{let t=this.db.prepare(e),s=r?t.run(...r):t.run();return {lastID:Number(s.lastInsertRowid),changes:s.changes}}catch(t){throw new Error(`Write failed: ${t.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 _(this.db)}close(){if(this.db){try{this.db.close();}catch(e){N.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=S=>this.db.prepare(S).get().c,r={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"),fact_nodes:e("SELECT COUNT(*) as c FROM fact_nodes"),meta:e("SELECT COUNT(*) as c FROM meta"),schema_migrations:e("SELECT COUNT(*) as c FROM schema_migrations")},t=[],s=e(`
63
+ )`);let t=n.prepare("SELECT id FROM schema_migrations").all(),s=new Set(t.map(i=>i.id)),a={applied:[],pending:[],errors:[],currentVersion:t.length===0?0:Math.max(...t.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(r.dryRun){a.applied.push(i.id);continue}try{f(n,i.up),n.prepare("INSERT INTO schema_migrations (id) VALUES (?)").run(i.id),s.add(i.id),a.applied.push(i.id),c.info("migration applied",{id:i.id,description:i.description});}catch(o){let d=o instanceof Error?o.message:String(o),T=i.up[0]??"";a.errors.push({migrationId:i.id,sql:T,error:d}),c.warn("migration step failed",{id:i.id,error:d,sqlCount:i.up.length});}}return a}function f(n,e){for(let r of e)try{n.exec(r);}catch(t){let s=t instanceof Error?t.message:String(t);if(I(s)){c.debug("migration: column already exists, skipping",{sql:r.slice(0,80)});continue}throw t}}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(r=>r.id))}catch{return 0}}var N=utils.Log.create({service:"memory-database"}),_=class{constructor(e){chunkM2YU5LAI_cjs.a(this,"db",null);chunkM2YU5LAI_cjs.a(this,"storagePath");chunkM2YU5LAI_cjs.a(this,"backend","better-sqlite3");chunkM2YU5LAI_cjs.a(this,"initialized",false);chunkM2YU5LAI_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 r=e instanceof Error?e.message:String(e);throw N.error("Database initialization failed",{error:r}),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){N.warn("Failed to apply memory PRAGMAs",{error:String(e)});}}runAllMigrations(){if(!this.db)throw new Error("Database not initialized");let e=g(this.db,m);if(e.errors.length>0){let r=e.errors.map(t=>`migration ${t.migrationId}: ${t.error}`).join("; ");throw new Error(`Some migrations failed: ${r}`)}}query(e,r){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");try{let t=this.db.prepare(e);return r?t.all(...r):t.all()}catch(t){throw new Error(`Query failed: ${t.message}`)}}agentFilter(e){return typeof e=="string"&&e.trim().length>0?{where:"WHERE agent_id = ?",params:[e.trim()]}:{where:"",params:[]}}run(e,r){if(!this.db)throw new Error("Database not initialized. Call initialize() first.");try{let t=this.db.prepare(e),s=r?t.run(...r):t.run();return {lastID:Number(s.lastInsertRowid),changes:s.changes}}catch(t){throw new Error(`Write failed: ${t.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){N.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=p=>this.db.prepare(p).get().c,r={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"),fact_nodes:e("SELECT COUNT(*) as c FROM fact_nodes"),meta:e("SELECT COUNT(*) as c FROM meta"),schema_migrations:e("SELECT COUNT(*) as c FROM schema_migrations")},t=[],s=e(`
65
64
  SELECT COUNT(*) as c FROM fact_nodes fn
66
65
  LEFT JOIN nodes n ON n.id = fn.node_id
67
66
  WHERE n.id IS NULL
@@ -75,4 +74,4 @@
75
74
  EXCEPT
76
75
  SELECT id FROM memory_facts
77
76
  )
78
- `);d>0&&t.push({severity:"warn",message:`FTS out of sync (orphan entries): ${d}`});let T=e("SELECT COUNT(*) as c FROM (SELECT id, COUNT(*) as c FROM memory_facts GROUP BY id HAVING c > 1)");T>0&&t.push({severity:"error",message:`duplicate fact ids: ${T}`});let g=e("SELECT COUNT(*) as c FROM memory_facts WHERE content IS NULL OR content = ''");return g>0&&t.push({severity:"error",message:`memory_facts with null/empty content: ${g}`}),{issues:t,stats:r}}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,r){if(!this.db)throw new Error("Database not initialized");this.db.prepare("INSERT OR REPLACE INTO meta (key, value) VALUES (?, ?)").run(e,r);}};exports.a=m;exports.b=I;exports.c=l;exports.d=_;exports.e=u;
77
+ `);d>0&&t.push({severity:"warn",message:`FTS out of sync (orphan entries): ${d}`});let T=e("SELECT COUNT(*) as c FROM (SELECT id, COUNT(*) as c FROM memory_facts GROUP BY id HAVING c > 1)");T>0&&t.push({severity:"error",message:`duplicate fact ids: ${T}`});let l=e("SELECT COUNT(*) as c FROM memory_facts WHERE content IS NULL OR content = ''");return l>0&&t.push({severity:"error",message:`memory_facts with null/empty content: ${l}`}),{issues:t,stats:r}}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,r){if(!this.db)throw new Error("Database not initialized");this.db.prepare("INSERT OR REPLACE INTO meta (key, value) VALUES (?, ?)").run(e,r);}};exports.a=m;exports.b=R;exports.c=g;exports.d=u;exports.e=_;
@@ -0,0 +1,64 @@
1
+ 'use strict';var chunk5VZKEZI4_cjs=require('./chunk-5VZKEZI4.cjs'),mcp=require('@easbot/mcp'),utils=require('@easbot/utils');var oe=utils.Log.create({service:"memory-format-truncate"}),X="**`";var Z=24e3,V=25e3;async function y(e,n={}){let r=n.softLimit??Z,s=n.hardCeiling??V,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
+ ${X}`),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,g=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:g,truncated:true,outputPath:"",hint:"Make another recall / graph_query with narrower scope.",info:`... ${e.length-d.length}/${e.length} characters truncated ...`};try{let p=await utils.TruncateContent.truncate(e,{maxChars:d.length,direction:"head",label:`${o}-output`});return p.truncated?{content:g,truncated:!0,outputPath:p.outputPath,hint:utils.TruncateContent.formatHint(p),info:`... ${p.removedLength}/${p.originalLength} characters truncated ...`}:{content:g,truncated:!0,outputPath:"",hint:"Make another recall / graph_query with narrower scope.",info:`... ${e.length-d.length}/${e.length} characters truncated ...`}}catch(p){return oe.warn("TruncateContent.truncate failed, returning without disk hint",{error:p instanceof Error?p.message:String(p)}),{content:g,truncated:true,outputPath:"",hint:"Make another recall / graph_query with narrower scope.",info:`... ${e.length-d.length}/${e.length} characters truncated ...`}}}function f(e,n={}){let r=n.softLimit??Z,s=n.hardCeiling??V;if(e.length<=r)return {content:e,truncated:false};let o=e.slice(0,s),c=o.lastIndexOf(`
4
+ ${X}`),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 ae(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 b(e,n,r={}){return (ee[e]??ee.default).replace(/<(\w+)>/g,(o,c)=>c==="tool"?n:r[c]??`<${c}>`)}var ee={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 se(e){let n=Array.isArray(e.edges)?e.edges.length:0;return ` - node #${e.id}: ${e.name} (${e.type}) [edges: ${n}]`}function te(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=s.map(se);u=`
14
+ - linked KG nodes (${s.length}) \u2014 use \`graph_query(nodeId=<id>)\` for full relation graph:
15
+ ${d.join(`
16
+ `)}`;}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(`
17
+ `)}async function x(e,n){let r=n.toolName??"memory_recall",s=`**\`memory_recall:${n.query.slice(0,40).replace(/[^a-zA-Z0-9_]/g,"_")}\`**`,o=ae(n.pendingFiles,new Set),i=[`Found ${e.total} fact(s) for query "${n.query}" (agentId=${n.agentId}, scope=${n.scope}):`,"",o??"",s].join(`
18
+ `),t=new Map;for(let m of e.hits){let g=m.fact.category;t.has(g)||t.set(g,[]),t.get(g).push(m);}let a=Array.from(t.entries()).map(([m,g])=>{let p=`**\`category:${m}\`**`,E=g.map(w=>te(w.fact,w.score,w.source,w.nodes)).join(`
19
+ `);return `${p}
20
+
21
+ ${E}`}).join(`
22
+ `),u=e.warnings&&e.warnings.length>0?`
23
+
24
+ \u26A0\uFE0F warnings:
25
+ ${e.warnings.map(m=>` - ${m}`).join(`
26
+ `)}
27
+ `:"",d=`${i}
28
+
29
+ ${a}${u}
30
+
31
+ ${b("recall",r)}`;return n.sync?f(d,{}).content:(await y(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=te(e.fact),c=e.nodeIds??[],i=c.length>0?`
32
+ - linked KG nodes: ${c.join(", ")}
33
+ `:"",t=`${s}
34
+
35
+ ${o}${i}
36
+
37
+ ${b("remember",r)}`;return n.sync?f(t,{}).content:(await y(t,{toolName:r,writeToDisk:n.writeToDisk})).content}async function N(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:
38
+ ${e.deletedIds.map(t=>` - ${t}`).join(`
39
+ `)}`:"(no ids to show)","",b("forget",r)].join(`
40
+ `);return n.sync?f(i,{}).content:(await y(i,{toolName:r,writeToDisk:n.writeToDisk})).content}async function _(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(`
41
+ `),c=e.edges.map(t=>` - edge #${t.id}: ${t.source} --${t.relation}--> ${t.target}`).join(`
42
+ `),i=[s,"",`nodes (${e.nodes.length}${e.truncated?` / total ${e.totalNodes}`:""}):`,o||" (none)","",`edges (${e.edges.length}${e.truncated?` / total ${e.totalEdges}`:""}):`,c||" (none)","",b("graph_query",r)].join(`
43
+ `);return n.sync?f(i,{}).content:(await y(i,{toolName:r,writeToDisk:n.writeToDisk})).content}async function A(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}`),"",b("status",r)].join(`
44
+ `);return n.sync?f(c,{}).content:(await y(c,{toolName:r,writeToDisk:n.writeToDisk})).content}async function M(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`,"",b("consolidate",r)].join(`
45
+ `);return n.sync?f(o,{}).content:(await y(o,{toolName:r,writeToDisk:n.writeToDisk})).content}var S=20;async function O(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,S);for(let t of i)o.push(`- ${t.firstFactId} (${t.firstCreatedAt})`),o.push(` - source: \`${t.source}\``),o.push(` - target: \`${t.target}\``);e.archivedRecords.length>S&&o.push(`... and ${e.archivedRecords.length-S} more (use --json for full list)`);}o.push("",`duration: ${e.durationMs}ms`,"",b("sync",r));let c=o.join(`
46
+ `);return n.sync?f(c,{}).content:(await y(c,{toolName:r,writeToDisk:n.writeToDisk})).content}async function P(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(`
47
+ `),i=[s,"",c,"",b("doctor",r)].join(`
48
+ `);return n.sync?f(i,{}).content:(await y(i,{toolName:r,writeToDisk:n.writeToDisk})).content}async function $(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 x(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 N(o?s:n,r);case "graph_query":return _(o?s:n,r);case "status":return A(o?s:n,r);case "consolidate":return M(o?s:n,r);case "sync":return O(o?s:n,r);case "doctor":return P(o?s:n,r);default:throw new Error(`renderOperationMarkdown: unsupported op "${e}"`)}}var T=utils.Log.create({service:"memory-mcp-stdio"});function Ie(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:chunk5VZKEZI4_cjs.A({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 chunk5VZKEZI4_cjs.z("recall",t,u);return {content:[{type:"text",text:await $("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 chunk5VZKEZI4_cjs.z("remember",t,u);return {content:[{type:"text",text:await $("remember",d,{toolName:"memory_remember"})}]}}catch(a){return c(i(a),true)}}),n.set("update",async t=>{try{let u=o({agentId:t.agentId}),d=await chunk5VZKEZI4_cjs.z("update",t,u),m=d.fieldsUpdated.length>0?d.fieldsUpdated.join(", "):"(no-op)",g=d.contentChanged?" (embedding rewritten)":"";return {content:[{type:"text",text:`Memory updated.
49
+ id: ${d.fact.id}
50
+ category: ${d.fact.category}
51
+ importance: ${d.fact.importance}
52
+ fields updated: ${m}${g}
53
+ updated_at: ${d.fact.updatedAt}
54
+ `}]}}catch(a){return c(i(a),true)}}),n.set("forget",async t=>{try{let u=o({agentId:t.agentId}),d=await chunk5VZKEZI4_cjs.z("forget",t,u);return {content:[{type:"text",text:await $("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 chunk5VZKEZI4_cjs.z("extract",t,u);return {content:[{type:"text",text:`Extract completed.
55
+ sessionId: ${t.sessionId??"(unknown)"}
56
+ extractedCount: ${m.extractedCount}
57
+ factIds: ${m.factIds.length>0?m.factIds.join(", "):"(none)"}
58
+ messageRange: ${m.messageRange.fromMessageId} -> ${m.messageRange.toMessageId}
59
+ `}]}}catch(a){return c(i(a),true)}}),n.set("consolidate",async t=>{try{let u=o({agentId:t.agentId,isTrustedLocal:!0}),d=await chunk5VZKEZI4_cjs.z("consolidate",t,u);return {content:[{type:"text",text:await $("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 chunk5VZKEZI4_cjs.z("sync",t,d);return {content:[{type:"text",text:await $("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 chunk5VZKEZI4_cjs.z("graph_query",t,u);return {content:[{type:"text",text:await $("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 chunk5VZKEZI4_cjs.z("status",t,u);return {content:[{type:"text",text:await $("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 chunk5VZKEZI4_cjs.z("doctor",t,u);return {content:[{type:"text",text:await $("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 chunk5VZKEZI4_cjs.z("init",t,a);return {content:[{type:"text",text:`Init complete.
60
+ dbPath: ${d.dbPath}
61
+ tablesCreated: ${d.tablesCreated}
62
+ migrationsApplied: ${d.migrationsApplied}
63
+ durationMs: ${d.durationMs}
64
+ `}]}}catch(a){return c(i(a),true)}}),n}var Re={recall:chunk5VZKEZI4_cjs.c,remember:chunk5VZKEZI4_cjs.d,update:chunk5VZKEZI4_cjs.e,forget:chunk5VZKEZI4_cjs.f,extract:chunk5VZKEZI4_cjs.g,consolidate:chunk5VZKEZI4_cjs.h,sync:chunk5VZKEZI4_cjs.m,graph_query:chunk5VZKEZI4_cjs.i,status:chunk5VZKEZI4_cjs.j,doctor:chunk5VZKEZI4_cjs.k,init:chunk5VZKEZI4_cjs.l};function Ce(e,n){let r=chunk5VZKEZI4_cjs.x[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=Re[e];return {name:e,description:r?.annotations?.defaultDescription??`memory op: ${e}`,inputSchema:o??{type:"object",properties:{},required:[],additionalProperties:false},annotations:s,handler:n}}exports.b=void 0;(r=>{async function e(s,o){let{getMemoryDbPath:c,getInstance:i}=await import('./interfaces-Q5OGU5EK.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};mcp.extendKnownErrorCodes(["AGENT_ID_REQUIRED","SESSION_ID_REQUIRED","CATEGORY_REQUIRED","IMPORTANCE_REQUIRED","TIMERANGE_REQUIRED","DRY_RUN_NO_DELETE"]);let u=new mcp.ToolRegistry,d=Ie(a),m=Object.keys(chunk5VZKEZI4_cjs.x);for(let l of m){let I=d.get(l);if(!I)throw new Error(`MemoryStdioServer.start: missing handler for tool "${l}"`);u.register(Ce(l,I));}T.info("starting memory MCP stdio server",{id:s.id,name:s.name,toolCount:m.length,isRemote:a.isRemote??true});let g=await mcp.createAndStartStdioServer(s,u),p=null,E=new Promise(l=>{p=l;}),w=l=>{T.info("received signal, stopping MCP server",{signal:l}),p?.();},D=()=>w("SIGINT"),k=()=>w("SIGTERM"),L=(l,I)=>process.listeners(l).includes(I);L("SIGINT",D)||process.on("SIGINT",D),L("SIGTERM",k)||process.on("SIGTERM",k);try{await E;}finally{try{process.off("SIGINT",D),process.off("SIGTERM",k);}catch(l){T.warn("failed to remove signal handlers",{error:l instanceof Error?l.message:String(l)});}try{await g.stop();}catch(l){T.warn("server.stop failed during cleanup",{error:l instanceof Error?l.message:String(l)});}}return {id:s.id,name:s.name,version:s.version,tools:m}}r.start=e;function n(){return Object.keys(chunk5VZKEZI4_cjs.x)}r.getToolNames=n;})(exports.b||(exports.b={}));exports.a=$;
@@ -1 +1 @@
1
- import {f}from'./chunk-WDVDYZ25.mjs';import {Log}from'@easbot/utils';import {renderLines,printHuman,emitJsonOk,formatKnowledgeDoctor,formatKnowledgeStatus,formatKnowledgeInit,emitJsonError}from'@easbot/terminal';var y=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(i=>i.group===m);return renderLines({title:t,flat:e.map(i=>`$ easbot-memory ${i.name.padEnd(14)} ${i.description}`)})}function v(){let m=[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:")];printHuman(m);}function C(){v(),printHuman(["",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 I(m){try{let{bootstrapLlm:t}=await import('@easbot/llm'),{Llm:e}=await import('./llm-UHTBU2HA.mjs');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 O(m,t){let[e,...i]=m,c=t?.cwd??process.cwd();if(!e)return C(),{code:0,handled:true,command:null};await I(c);try{switch(e){case "init":{let{parseInitOptions:r,runInit:n}=await import('./init-2ZTVBJ6N.mjs'),s=r(i);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,a=await n({...s,ctxWorkspaceDir:o});if(s.json)emitJsonOk(a,{command:e});else {let p=a;printHuman([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-VMW7Y55X.mjs'),o=r(i);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 a=await n({...o,workspaceDir:c});return o.json?emitJsonOk(a,{command:e}):printHuman([s(a)],{title:`recall (agentId=${o.agentId??"default"})`}),{code:0,handled:!0,command:e}}case "remember":{let{parseRememberOptions:r,runRemember:n,formatRememberText:s}=await import('./remember-ZVTM3IP4.mjs'),o=r(i);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 a=await n({...o,workspaceDir:c});return o.json?emitJsonOk(a,{command:e}):printHuman([s(a)],{title:"remember (persist fact)"}),{code:0,handled:!0,command:e}}case "forget":{let{parseForgetOptions:r,runForget:n,formatForgetText:s}=await import('./forget-CRDWG4XE.mjs'),o=r(i);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 a=await n({...o,workspaceDir:c});return o.json?emitJsonOk(a,{command:e}):printHuman([s(a)],{title:"forget (delete facts)"}),{code:0,handled:!0,command:e}}case "extract":{let{parseExtractOptions:r,runExtract:n,formatExtractText:s}=await import('./extract-WH4DU4NQ.mjs'),o=r(i);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 a=await n({...o,workspaceDir:c});return o.json?emitJsonOk(a,{command:e}):printHuman([s(a)],{title:"extract (from session)"}),{code:0,handled:!0,command:e}}case "consolidate":{let{parseConsolidateOptions:r,runConsolidate:n,formatConsolidateText:s}=await import('./consolidate-JBTOQWUX.mjs'),o=r(i);if(o.help)return console.log("Usage: easbot-memory consolidate [--agent <id>] [--window-days <n>] [--json]"),{code:0,handled:!0,command:e};let a=await n({...o,workspaceDir:c});return o.json?emitJsonOk(a,{command:e}):printHuman([s(a)],{title:"consolidate (pipeline)"}),{code:0,handled:!0,command:e}}case "sync":{let{parseSyncOptions:r,runSync:n,formatSyncText:s}=await import('./sync-KWHUII26.mjs'),o=r(i);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 a=await n({...o,workspaceDir:c});return o.json?emitJsonOk(a,{command:e}):printHuman([s(a)],{title:"sync (db \u2192 .md + archive)"}),{code:0,handled:!0,command:e}}case "graph":{let{parseGraphOptions:r,runGraph:n,formatGraphText:s}=await import('./graph-T66JXDLU.mjs'),o=r(i);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 a=await n({...o,workspaceDir:c});return o.json?emitJsonOk(a,{command:e}):printHuman([s(a)],{title:`graph_query (scope=${o.scope??"agent_only"})`}),{code:0,handled:!0,command:e}}case "status":{let{parseStatusOptions:r,runStatus:n}=await import('./status-LHXMB3ZY.mjs'),s=r(i);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?emitJsonOk(o,{command:e}):printHuman([formatKnowledgeStatus(K(o))],{title:"memory status",boxed:!0}),{code:0,handled:!0,command:e}}case "doctor":{let{parseDoctorOptions:r,runDoctor:n}=await import('./doctor-DLQO7QMW.mjs'),s=r(i);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?emitJsonOk(o,{command:e}):printHuman([formatKnowledgeDoctor(j(o))],{title:"memory doctor",boxed:!0}),{code:0,handled:!0,command:e}}case "config":{let{parseConfigOptions:r,runConfig:n,formatConfigText:s}=await import('./config-2SQJYVTO.mjs'),o=r(i);if(o.help)return console.log("Usage: easbot-memory config [--json]"),{code:0,handled:!0,command:e};let a=n(o);return o.json?emitJsonOk(a,{command:e}):printHuman([s(a)],{title:"memory config"}),{code:0,handled:!0,command:e}}case "mcp":{let{parseMcpOptions:r,runMcp:n}=await import('./mcp-OAUOA4PI.mjs'),s=r(i);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?emitJsonOk(o,{command:e}):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??f().worktree;return console.error(`[memory] ${s} :: ${e} failed: ${n}`),emitJsonError(e,n),{code:1,handled:true,command:e}}}function K(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 i=t.factsByCategory;for(let[c,r]of Object.entries(i))typeof r=="number"&&r>0&&(e[`facts/${c}`]=r);}return Object.keys(e).length>0?e:void 0})()}}function j(m){let t=m,e=Array.isArray(t.checks)?t.checks:[],i=t.integrityStats,c=t.backendAvailable,r=i?{...i}: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}}export{S as a,v as b,C as c,O as d,j as e};
1
+ import {f}from'./chunk-WDVDYZ25.mjs';import {Log}from'@easbot/utils';import {renderLines,printHuman,emitJsonOk,formatKnowledgeDoctor,formatKnowledgeStatus,formatKnowledgeInit,emitJsonError}from'@easbot/terminal';var y=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(i=>i.group===m);return renderLines({title:t,flat:e.map(i=>`$ easbot-memory ${i.name.padEnd(14)} ${i.description}`)})}function v(){let m=[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:")];printHuman(m);}function C(){v(),printHuman(["",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 I(m){try{let{bootstrapLlm:t}=await import('@easbot/llm'),{Llm:e}=await import('./llm-UHTBU2HA.mjs');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 O(m,t){let[e,...i]=m,c=t?.cwd??process.cwd();if(!e)return C(),{code:0,handled:true,command:null};await I(c);try{switch(e){case "init":{let{parseInitOptions:r,runInit:n}=await import('./init-2UNKNWR5.mjs'),s=r(i);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,a=await n({...s,ctxWorkspaceDir:o});if(s.json)emitJsonOk(a,{command:e});else {let p=a;printHuman([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-7TPMD7ZE.mjs'),o=r(i);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 a=await n({...o,workspaceDir:c});return o.json?emitJsonOk(a,{command:e}):printHuman([s(a)],{title:`recall (agentId=${o.agentId??"default"})`}),{code:0,handled:!0,command:e}}case "remember":{let{parseRememberOptions:r,runRemember:n,formatRememberText:s}=await import('./remember-H5CYMLG5.mjs'),o=r(i);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 a=await n({...o,workspaceDir:c});return o.json?emitJsonOk(a,{command:e}):printHuman([s(a)],{title:"remember (persist fact)"}),{code:0,handled:!0,command:e}}case "forget":{let{parseForgetOptions:r,runForget:n,formatForgetText:s}=await import('./forget-QNG6GELC.mjs'),o=r(i);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 a=await n({...o,workspaceDir:c});return o.json?emitJsonOk(a,{command:e}):printHuman([s(a)],{title:"forget (delete facts)"}),{code:0,handled:!0,command:e}}case "extract":{let{parseExtractOptions:r,runExtract:n,formatExtractText:s}=await import('./extract-ANENWMHZ.mjs'),o=r(i);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 a=await n({...o,workspaceDir:c});return o.json?emitJsonOk(a,{command:e}):printHuman([s(a)],{title:"extract (from session)"}),{code:0,handled:!0,command:e}}case "consolidate":{let{parseConsolidateOptions:r,runConsolidate:n,formatConsolidateText:s}=await import('./consolidate-VGPUQRPU.mjs'),o=r(i);if(o.help)return console.log("Usage: easbot-memory consolidate [--agent <id>] [--window-days <n>] [--json]"),{code:0,handled:!0,command:e};let a=await n({...o,workspaceDir:c});return o.json?emitJsonOk(a,{command:e}):printHuman([s(a)],{title:"consolidate (pipeline)"}),{code:0,handled:!0,command:e}}case "sync":{let{parseSyncOptions:r,runSync:n,formatSyncText:s}=await import('./sync-GPRNZLZA.mjs'),o=r(i);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 a=await n({...o,workspaceDir:c});return o.json?emitJsonOk(a,{command:e}):printHuman([s(a)],{title:"sync (db \u2192 .md + archive)"}),{code:0,handled:!0,command:e}}case "graph":{let{parseGraphOptions:r,runGraph:n,formatGraphText:s}=await import('./graph-KNLZRAPI.mjs'),o=r(i);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 a=await n({...o,workspaceDir:c});return o.json?emitJsonOk(a,{command:e}):printHuman([s(a)],{title:`graph_query (scope=${o.scope??"agent_only"})`}),{code:0,handled:!0,command:e}}case "status":{let{parseStatusOptions:r,runStatus:n}=await import('./status-MJFDNSPW.mjs'),s=r(i);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?emitJsonOk(o,{command:e}):printHuman([formatKnowledgeStatus(K(o))],{title:"memory status",boxed:!0}),{code:0,handled:!0,command:e}}case "doctor":{let{parseDoctorOptions:r,runDoctor:n}=await import('./doctor-RNI5F6GO.mjs'),s=r(i);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?emitJsonOk(o,{command:e}):printHuman([formatKnowledgeDoctor(j(o))],{title:"memory doctor",boxed:!0}),{code:0,handled:!0,command:e}}case "config":{let{parseConfigOptions:r,runConfig:n,formatConfigText:s}=await import('./config-2SQJYVTO.mjs'),o=r(i);if(o.help)return console.log("Usage: easbot-memory config [--json]"),{code:0,handled:!0,command:e};let a=n(o);return o.json?emitJsonOk(a,{command:e}):printHuman([s(a)],{title:"memory config"}),{code:0,handled:!0,command:e}}case "mcp":{let{parseMcpOptions:r,runMcp:n}=await import('./mcp-RMLMXPZ7.mjs'),s=r(i);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?emitJsonOk(o,{command:e}):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??f().worktree;return console.error(`[memory] ${s} :: ${e} failed: ${n}`),emitJsonError(e,n),{code:1,handled:true,command:e}}}function K(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 i=t.factsByCategory;for(let[c,r]of Object.entries(i))typeof r=="number"&&r>0&&(e[`facts/${c}`]=r);}return Object.keys(e).length>0?e:void 0})()}}function j(m){let t=m,e=Array.isArray(t.checks)?t.checks:[],i=t.integrityStats,c=t.backendAvailable,r=i?{...i}: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}}export{S as a,v as b,C as c,O as d,j as e};
@@ -0,0 +1 @@
1
+ export{a as COMMANDS_HELP,d as handleMemoryCli,e as mapMemoryDoctor,b as renderBanner,c as renderHelp}from'./chunk-PGJB2U24.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-HQBRVVXS.mjs';
@@ -0,0 +1 @@
1
+ 'use strict';var chunk46Y7MLBE_cjs=require('./chunk-46Y7MLBE.cjs');require('./chunk-CPRDIUQ4.cjs'),require('./chunk-M2YU5LAI.cjs');Object.defineProperty(exports,"COMMANDS_HELP",{enumerable:true,get:function(){return chunk46Y7MLBE_cjs.a}});Object.defineProperty(exports,"handleMemoryCli",{enumerable:true,get:function(){return chunk46Y7MLBE_cjs.d}});Object.defineProperty(exports,"mapMemoryDoctor",{enumerable:true,get:function(){return chunk46Y7MLBE_cjs.e}});Object.defineProperty(exports,"renderBanner",{enumerable:true,get:function(){return chunk46Y7MLBE_cjs.b}});Object.defineProperty(exports,"renderHelp",{enumerable:true,get:function(){return chunk46Y7MLBE_cjs.c}});
@@ -0,0 +1,2 @@
1
+ import {b,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {z,B}from'./chunk-C3Z455VR.mjs';import'./chunk-FY4ILCIM.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 z("consolidate",{windowDays:t.windowDays??30,dryRun:false},B(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};
@@ -1,2 +1,2 @@
1
- 'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5YDI4K2F_cjs=require('./chunk-5YDI4K2F.cjs');require('./chunk-EK34SXJ7.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-M2YU5LAI.cjs');async function m(t){let n=t.agentId?.trim()||"default",o=t.workspaceDir??process.cwd();return chunk5YDI4K2F_cjs.w("consolidate",{windowDays:t.windowDays??30,dryRun:false},chunk5YDI4K2F_cjs.y(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(`
1
+ 'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5VZKEZI4_cjs=require('./chunk-5VZKEZI4.cjs');require('./chunk-LYBUZDJK.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-M2YU5LAI.cjs');async function m(t){let n=t.agentId?.trim()||"default",o=t.workspaceDir??process.cwd();return chunk5VZKEZI4_cjs.z("consolidate",{windowDays:t.windowDays??30,dryRun:false},chunk5VZKEZI4_cjs.B(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
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 @@
1
+ import {z,B}from'./chunk-C3Z455VR.mjs';import'./chunk-FY4ILCIM.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 z("doctor",{},B(r,t))}function f(o){return ""}function l(o){let r={};for(let t=0;t<o.length;t++){let n=o[t];n!==void 0&&(n==="--repair"?r.repair=true:n==="--json"?r.json=true:(n==="--help"||n==="-h")&&(r.help=true));}return r}export{f as formatDoctorText,l as parseDoctorOptions,u as runDoctor};
@@ -0,0 +1 @@
1
+ 'use strict';var chunk5VZKEZI4_cjs=require('./chunk-5VZKEZI4.cjs');require('./chunk-LYBUZDJK.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-M2YU5LAI.cjs');async function a(o){let r=o.agentId,t=o.workspaceDir??process.cwd();return chunk5VZKEZI4_cjs.z("doctor",{},chunk5VZKEZI4_cjs.B(r,t))}function u(o){return ""}function f(o){let r={};for(let t=0;t<o.length;t++){let n=o[t];n!==void 0&&(n==="--repair"?r.repair=true:n==="--json"?r.json=true:(n==="--help"||n==="-h")&&(r.help=true));}return r}exports.formatDoctorText=u;exports.parseDoctorOptions=f;exports.runDoctor=a;
@@ -1,2 +1,2 @@
1
- import {b,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {w,y}from'./chunk-2TBNGTSA.mjs';import'./chunk-PJGILQSZ.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 w("extract",{sessionId:r.sessionId,lastN:r.lastN??10,fromMessageId:r.fromMessageId},y(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(`
1
+ import {b,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {z,B}from'./chunk-C3Z455VR.mjs';import'./chunk-FY4ILCIM.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 z("extract",{sessionId:r.sessionId,lastN:r.lastN??10,fromMessageId:r.fromMessageId},B(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
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};
@@ -1,2 +1,2 @@
1
- 'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5YDI4K2F_cjs=require('./chunk-5YDI4K2F.cjs');require('./chunk-EK34SXJ7.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-M2YU5LAI.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 chunk5YDI4K2F_cjs.w("extract",{sessionId:r.sessionId,lastN:r.lastN??10,fromMessageId:r.fromMessageId},chunk5YDI4K2F_cjs.y(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(`
1
+ 'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5VZKEZI4_cjs=require('./chunk-5VZKEZI4.cjs');require('./chunk-LYBUZDJK.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-M2YU5LAI.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 chunk5VZKEZI4_cjs.z("extract",{sessionId:r.sessionId,lastN:r.lastN??10,fromMessageId:r.fromMessageId},chunk5VZKEZI4_cjs.B(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
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;
@@ -1,3 +1,3 @@
1
- import {a,b,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {w,y as y$1}from'./chunk-2TBNGTSA.mjs';import'./chunk-PJGILQSZ.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 w("forget",{factId:n.factId,category:n.category,fromTime:n.fromTime,toTime:n.toTime,maxDelete:n.maxDelete??1e3,dryRun:n.dryRun??false},y$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(`
1
+ import {a,b,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {z,B}from'./chunk-C3Z455VR.mjs';import'./chunk-FY4ILCIM.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 z("forget",{factId:n.factId,category:n.category,fromTime:n.fromTime,toTime:n.toTime,maxDelete:n.maxDelete??1e3,dryRun:n.dryRun??false},B(e,t))}function y(n){let e=n,t=[];if(e.deletedCount===0&&e.deletedIds.length===0)return t.push(a("forget","(no records to delete)")),t.join(`
2
2
  `);t.push(b("forget",{deletedCount:e.deletedCount,dryRun:String(e.dryRun)},e.dryRun?"[DRY RUN] Would delete {{deletedCount}}":"Deleted {{deletedCount}}")),e.truncatedCount>0&&t.push(`(truncated: ${e.truncatedCount} more)`);for(let r of e.deletedIds)t.push(c("forget",{id:r}," - {{id}}"));return t.join(`
3
3
  `)}function x(n){let e={};for(let t=0;t<n.length;t++){let r=n[t];if(r===void 0)continue;let o=n[t+1];r==="--agent"?(e.agentId=o,t++):r==="--fact-id"?(e.factId=o,t++):r==="--category"?(e.category=o,t++):r==="--from"?(e.fromTime=o,t++):r==="--to"?(e.toTime=o,t++):r==="--max-delete"?(e.maxDelete=Number(o),t++):r==="--dry-run"?e.dryRun=true:r==="--json"?e.json=true:(r==="--help"||r==="-h")&&(e.help=true);}return e}export{y as formatForgetText,x as parseForgetOptions,p as runForget};
@@ -1,3 +1,3 @@
1
- 'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5YDI4K2F_cjs=require('./chunk-5YDI4K2F.cjs');require('./chunk-EK34SXJ7.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-M2YU5LAI.cjs');async function g(n){let e=n.agentId?.trim()||"default",t=n.workspaceDir??process.cwd();return chunk5YDI4K2F_cjs.w("forget",{factId:n.factId,category:n.category,fromTime:n.fromTime,toTime:n.toTime,maxDelete:n.maxDelete??1e3,dryRun:n.dryRun??false},chunk5YDI4K2F_cjs.y(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(`
1
+ 'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5VZKEZI4_cjs=require('./chunk-5VZKEZI4.cjs');require('./chunk-LYBUZDJK.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-M2YU5LAI.cjs');async function g(n){let e=n.agentId?.trim()||"default",t=n.workspaceDir??process.cwd();return chunk5VZKEZI4_cjs.z("forget",{factId:n.factId,category:n.category,fromTime:n.fromTime,toTime:n.toTime,maxDelete:n.maxDelete??1e3,dryRun:n.dryRun??false},chunk5VZKEZI4_cjs.B(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
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
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
+ import {b,a,c as c$1}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {z,B}from'./chunk-C3Z455VR.mjs';import'./chunk-FY4ILCIM.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function c(e){let t=e.agentId?.trim()||"default",r=e.workspaceDir??process.cwd();return z("graph_query",{...e.query?{query:e.query}:{},...e.startNodeId?{nodeId:e.startNodeId}:{},...e.type?{type:e.type}:{},...e.depth?{depth:e.depth}:{},...e.maxNodes?{maxNodes:e.maxNodes}:{},...e.scope?{scope:e.scope}:{},...e.relation?{relation:e.relation}:{}},B(t,r))}function f(e){let t=e,r=[b("graph",{totalNodes:t.totalNodes??t.nodes.length},"KG query (scope={{scope}}, {{totalNodes}} node(s)):")];if(t.nodes.length===0)return r.push(a("graph","(no nodes matched)")),r.join(`
2
+ `);r.push(`nodes (${t.nodes.length}):`);for(let n of t.nodes){n.ownerAgentId?` [owner=${n.ownerAgentId}]`:" [shared]";r.push(c$1("graph",{id:String(n.id),name:n.name,type:n.type}," - #{{id}} {{name}} ({{type}})"));}r.push(`edges (${t.edges.length}):`);for(let n of t.edges)r.push(` - #${n.id} ${n.source} --${n.relation}--> ${n.target}`);return r.join(`
3
+ `)}function y(e){let t={};for(let r=0;r<e.length;r++){let n=e[r];if(n===void 0)continue;let o=e[r+1];n==="--agent"?(t.agentId=o,r++):n==="--kind"?(t.kind=o,r++):n==="--query"?(t.query=o,r++):n==="--start-node"?(t.startNodeId=Number(o),r++):n==="--depth"?(t.depth=Number(o),r++):n==="--max-nodes"?(t.maxNodes=Number(o),r++):n==="--scope"?(t.scope=o,r++):n==="--json"?t.json=true:(n==="--help"||n==="-h")&&(t.help=true);}return t}export{f as formatGraphText,y as parseGraphOptions,c as runGraph};
@@ -0,0 +1,3 @@
1
+ 'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5VZKEZI4_cjs=require('./chunk-5VZKEZI4.cjs');require('./chunk-LYBUZDJK.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-M2YU5LAI.cjs');async function l(e){let t=e.agentId?.trim()||"default",r=e.workspaceDir??process.cwd();return chunk5VZKEZI4_cjs.z("graph_query",{...e.query?{query:e.query}:{},...e.startNodeId?{nodeId:e.startNodeId}:{},...e.type?{type:e.type}:{},...e.depth?{depth:e.depth}:{},...e.maxNodes?{maxNodes:e.maxNodes}:{},...e.scope?{scope:e.scope}:{},...e.relation?{relation:e.relation}:{}},chunk5VZKEZI4_cjs.B(t,r))}function c(e){let t=e,r=[chunk4GSXSIV5_cjs.b("graph",{totalNodes:t.totalNodes??t.nodes.length},"KG query (scope={{scope}}, {{totalNodes}} node(s)):")];if(t.nodes.length===0)return r.push(chunk4GSXSIV5_cjs.a("graph","(no nodes matched)")),r.join(`
2
+ `);r.push(`nodes (${t.nodes.length}):`);for(let n of t.nodes){n.ownerAgentId?` [owner=${n.ownerAgentId}]`:" [shared]";r.push(chunk4GSXSIV5_cjs.c("graph",{id:String(n.id),name:n.name,type:n.type}," - #{{id}} {{name}} ({{type}})"));}r.push(`edges (${t.edges.length}):`);for(let n of t.edges)r.push(` - #${n.id} ${n.source} --${n.relation}--> ${n.target}`);return r.join(`
3
+ `)}function f(e){let t={};for(let r=0;r<e.length;r++){let n=e[r];if(n===void 0)continue;let o=e[r+1];n==="--agent"?(t.agentId=o,r++):n==="--kind"?(t.kind=o,r++):n==="--query"?(t.query=o,r++):n==="--start-node"?(t.startNodeId=Number(o),r++):n==="--depth"?(t.depth=Number(o),r++):n==="--max-nodes"?(t.maxNodes=Number(o),r++):n==="--scope"?(t.scope=o,r++):n==="--json"?t.json=true:(n==="--help"||n==="-h")&&(t.help=true);}return t}exports.formatGraphText=c;exports.parseGraphOptions=f;exports.runGraph=l;
@@ -1 +1 @@
1
- import {w,y}from'./chunk-2TBNGTSA.mjs';import'./chunk-PJGILQSZ.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 w("init",{workspaceDir:e,dbPath:j(n),force:t.force??false},y(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
+ import {z,B}from'./chunk-C3Z455VR.mjs';import'./chunk-FY4ILCIM.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 z("init",{workspaceDir:e,dbPath:j(n),force:t.force??false},B(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
- 'use strict';var chunk5YDI4K2F_cjs=require('./chunk-5YDI4K2F.cjs');require('./chunk-EK34SXJ7.cjs');var chunkCPRDIUQ4_cjs=require('./chunk-CPRDIUQ4.cjs');require('./chunk-J5XF2W4Z.cjs'),require('./chunk-M2YU5LAI.cjs');async function g(t){let e=t.workspaceDir?.trim()||t.ctxWorkspaceDir?.trim()||process.cwd(),i=t.agentId??"",n=t.ctxWorkspaceDir?.trim()||e;return chunk5YDI4K2F_cjs.w("init",{workspaceDir:e,dbPath:chunkCPRDIUQ4_cjs.j(n),force:t.force??false},chunk5YDI4K2F_cjs.y(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;
1
+ 'use strict';var chunk5VZKEZI4_cjs=require('./chunk-5VZKEZI4.cjs');require('./chunk-LYBUZDJK.cjs');var chunkCPRDIUQ4_cjs=require('./chunk-CPRDIUQ4.cjs');require('./chunk-J5XF2W4Z.cjs'),require('./chunk-M2YU5LAI.cjs');async function g(t){let e=t.workspaceDir?.trim()||t.ctxWorkspaceDir?.trim()||process.cwd(),i=t.agentId??"",n=t.ctxWorkspaceDir?.trim()||e;return chunk5VZKEZI4_cjs.z("init",{workspaceDir:e,dbPath:chunkCPRDIUQ4_cjs.j(n),force:t.force??false},chunk5VZKEZI4_cjs.B(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;
@@ -1 +1 @@
1
- 'use strict';require('./chunk-URADAZYW.cjs');var chunkEK34SXJ7_cjs=require('./chunk-EK34SXJ7.cjs'),chunkCPRDIUQ4_cjs=require('./chunk-CPRDIUQ4.cjs'),chunkM2YU5LAI_cjs=require('./chunk-M2YU5LAI.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(chunkM2YU5LAI_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 chunkEK34SXJ7_cjs.e(o);await f.initialize(),f.close();let{MemoryStdioServer:y}=await import('./stdio-server-IMJF7HB6.cjs'),h=process.env.EASBOT_AGENT_ID?.trim()||"default",M=await y.start(e,{agentId:h,dbPath:o,workspaceDir:t,isRemote:false});return {rootDir:t,tools:M.tools}}exports.parseMcpOptions=C;exports.runMcp=E;
1
+ 'use strict';require('./chunk-URADAZYW.cjs');var chunkLYBUZDJK_cjs=require('./chunk-LYBUZDJK.cjs'),chunkCPRDIUQ4_cjs=require('./chunk-CPRDIUQ4.cjs'),chunkM2YU5LAI_cjs=require('./chunk-M2YU5LAI.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(chunkM2YU5LAI_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 chunkLYBUZDJK_cjs.e(o);await f.initialize(),f.close();let{MemoryStdioServer:y}=await import('./stdio-server-SXDIW3RQ.cjs'),h=process.env.EASBOT_AGENT_ID?.trim()||"default",M=await y.start(e,{agentId:h,dbPath:o,workspaceDir:t,isRemote:false});return {rootDir:t,tools:M.tools}}exports.parseMcpOptions=C;exports.runMcp=E;
@@ -1 +1 @@
1
- import'./chunk-QF5S5MG7.mjs';import {e}from'./chunk-PJGILQSZ.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-SONZIWC4.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};
1
+ import'./chunk-QF5S5MG7.mjs';import {e}from'./chunk-FY4ILCIM.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-43QC3XIS.mjs'),y=process.env.EASBOT_AGENT_ID?.trim()||"default",h=await g.start(r,{agentId:y,dbPath:o,workspaceDir:t,isRemote:false});return {rootDir:t,tools:h.tools}}export{E as parseMcpOptions,B as runMcp};
@@ -0,0 +1,2 @@
1
+ import {a}from'./chunk-SWYQLQ7Z.mjs';import {z,B}from'./chunk-C3Z455VR.mjs';import'./chunk-FY4ILCIM.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 z("recall",{query:n.query,maxResults:n.limit??10,category:n.category,minImportance:n.minImportance},B(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};
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkWQB4D6DZ_cjs=require('./chunk-WQB4D6DZ.cjs'),chunk5YDI4K2F_cjs=require('./chunk-5YDI4K2F.cjs');require('./chunk-EK34SXJ7.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-M2YU5LAI.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 chunk5YDI4K2F_cjs.w("recall",{query:n.query,maxResults:n.limit??10,category:n.category,minImportance:n.minImportance},chunk5YDI4K2F_cjs.y(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(`
1
+ 'use strict';var chunkWQB4D6DZ_cjs=require('./chunk-WQB4D6DZ.cjs'),chunk5VZKEZI4_cjs=require('./chunk-5VZKEZI4.cjs');require('./chunk-LYBUZDJK.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-M2YU5LAI.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 chunk5VZKEZI4_cjs.z("recall",{query:n.query,maxResults:n.limit??10,category:n.category,minImportance:n.minImportance},chunk5VZKEZI4_cjs.B(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
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;
@@ -1,2 +1,2 @@
1
- 'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5YDI4K2F_cjs=require('./chunk-5YDI4K2F.cjs');require('./chunk-EK34SXJ7.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-M2YU5LAI.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 chunk5YDI4K2F_cjs.w("remember",{content:r.content,category:r.category,importance:r.importance,tags:r.tags,sessionId:r.sessionId},chunk5YDI4K2F_cjs.y(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(`
1
+ 'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5VZKEZI4_cjs=require('./chunk-5VZKEZI4.cjs');require('./chunk-LYBUZDJK.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-M2YU5LAI.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 chunk5VZKEZI4_cjs.z("remember",{content:r.content,category:r.category,importance:r.importance,tags:r.tags,sessionId:r.sessionId},chunk5VZKEZI4_cjs.B(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
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;
@@ -1,2 +1,2 @@
1
- import {b as b$1,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {w,y}from'./chunk-2TBNGTSA.mjs';import'./chunk-PJGILQSZ.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 w("remember",{content:r.content,category:r.category,importance:r.importance,tags:r.tags,sessionId:r.sessionId},y(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(`
1
+ import {b as b$1,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {z,B}from'./chunk-C3Z455VR.mjs';import'./chunk-FY4ILCIM.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 z("remember",{content:r.content,category:r.category,importance:r.importance,tags:r.tags,sessionId:r.sessionId},B(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
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};
@@ -1 +1 @@
1
- 'use strict';var chunk5YDI4K2F_cjs=require('./chunk-5YDI4K2F.cjs');require('./chunk-EK34SXJ7.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-M2YU5LAI.cjs');async function c(t){let n=t.agentId,e=t.workspaceDir??process.cwd();return chunk5YDI4K2F_cjs.w("status",{agentId:n},chunk5YDI4K2F_cjs.y(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;
1
+ 'use strict';var chunk5VZKEZI4_cjs=require('./chunk-5VZKEZI4.cjs');require('./chunk-LYBUZDJK.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-M2YU5LAI.cjs');async function c(t){let n=t.agentId,e=t.workspaceDir??process.cwd();return chunk5VZKEZI4_cjs.z("status",{agentId:n},chunk5VZKEZI4_cjs.B(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;
@@ -1 +1 @@
1
- import {w,y}from'./chunk-2TBNGTSA.mjs';import'./chunk-PJGILQSZ.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 w("status",{agentId:n},y(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};
1
+ import {z,B}from'./chunk-C3Z455VR.mjs';import'./chunk-FY4ILCIM.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 z("status",{agentId:n},B(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};