@easbot/memory 0.3.17 → 0.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +101 -0
- package/README.md +116 -11
- package/dist/chunks/chunk-4GSXSIV5.cjs +1 -0
- package/dist/chunks/chunk-5Q6SIVSP.cjs +50 -0
- package/dist/chunks/chunk-6CQMBEIQ.mjs +1 -0
- package/dist/chunks/chunk-746FKSL5.mjs +50 -0
- package/dist/chunks/chunk-ARA4LMAI.mjs +1 -0
- package/dist/chunks/chunk-CN6WBJLX.mjs +60 -0
- package/dist/chunks/{chunk-OIUUTVLL.cjs → chunk-EGWJG65Q.cjs} +22 -4
- package/dist/chunks/chunk-J5XF2W4Z.cjs +1 -0
- package/dist/chunks/chunk-JDPZ5U53.mjs +71 -0
- package/dist/chunks/chunk-QHPGDNEG.cjs +1 -0
- package/dist/chunks/{chunk-MWRDF6VN.mjs → chunk-QYBWHFOX.mjs} +1 -1
- package/dist/chunks/chunk-SWYQLQ7Z.mjs +1 -0
- package/dist/chunks/chunk-WQB4D6DZ.cjs +1 -0
- package/dist/chunks/chunk-X66LENNV.cjs +60 -0
- package/dist/chunks/cli-handler-CN4Q7BCY.mjs +1 -0
- package/dist/chunks/cli-handler-IRPYADZF.cjs +1 -0
- package/dist/chunks/consolidate-PUOAAQN3.cjs +2 -0
- package/dist/chunks/consolidate-UEYNLKQN.mjs +2 -0
- package/dist/chunks/doctor-KPAZWVVZ.mjs +1 -0
- package/dist/chunks/doctor-U4HOSXGW.cjs +1 -0
- package/dist/chunks/extract-7FFIDVG3.cjs +2 -0
- package/dist/chunks/extract-EOZJMLTP.mjs +2 -0
- package/dist/chunks/{forget-A4UJI3LE.mjs → forget-5AXV3GHW.mjs} +1 -1
- package/dist/chunks/forget-GBMYCUPJ.cjs +3 -0
- package/dist/chunks/graph-KOJYJTA4.cjs +3 -0
- package/dist/chunks/{graph-XZ46LEO7.mjs → graph-Y6AYRFCN.mjs} +1 -1
- package/dist/chunks/init-B24TNUSD.cjs +1 -0
- package/dist/chunks/init-HGEBZTJW.mjs +1 -0
- package/dist/chunks/llm-RMPVWEVP.cjs +1 -0
- package/dist/chunks/llm-UHTBU2HA.mjs +1 -0
- package/dist/chunks/{mcp-BOD4ZOZS.mjs → mcp-BMAB3TT7.mjs} +1 -1
- package/dist/chunks/{mcp-BXVXTUJK.cjs → mcp-BS6XHEBR.cjs} +1 -1
- package/dist/chunks/recall-LKETADTB.cjs +2 -0
- package/dist/chunks/recall-UPGGKBNX.mjs +2 -0
- package/dist/chunks/remember-KCQN2UWN.mjs +2 -0
- package/dist/chunks/remember-VZF4O7ZF.cjs +2 -0
- package/dist/chunks/status-2BFVXY5J.cjs +1 -0
- package/dist/chunks/status-HGN2YLKJ.mjs +1 -0
- package/dist/chunks/stdio-server-GABA2MLR.cjs +1 -0
- package/dist/chunks/stdio-server-JPMLMEWY.mjs +1 -0
- package/dist/chunks/sync-7Y2DEDDW.mjs +2 -0
- package/dist/chunks/sync-W5A2O5TS.cjs +2 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +87 -38
- package/dist/index.d.ts +87 -38
- package/dist/index.mjs +4 -4
- package/package.json +9 -8
- package/dist/chunks/chunk-BSKFK4RC.mjs +0 -1
- package/dist/chunks/chunk-DFWC6WII.mjs +0 -53
- package/dist/chunks/chunk-DXU5WPK3.cjs +0 -42
- package/dist/chunks/chunk-EECBJNZI.mjs +0 -59
- package/dist/chunks/chunk-FMEXQ5YE.cjs +0 -59
- package/dist/chunks/chunk-HSK27DQ7.cjs +0 -1
- package/dist/chunks/chunk-I6XVFDN2.mjs +0 -42
- package/dist/chunks/chunk-QNDG7BTB.cjs +0 -1
- package/dist/chunks/chunk-RSJ2KT6X.cjs +0 -1
- package/dist/chunks/chunk-TPSRK4M3.mjs +0 -1
- package/dist/chunks/cli-handler-6VTKYXXM.mjs +0 -1
- package/dist/chunks/cli-handler-HNPA3STD.cjs +0 -1
- package/dist/chunks/consolidate-6P7LUPPL.cjs +0 -2
- package/dist/chunks/consolidate-NYH4IKJK.mjs +0 -2
- package/dist/chunks/doctor-IJJ5UYGT.cjs +0 -2
- package/dist/chunks/doctor-MZSZGVRL.mjs +0 -2
- package/dist/chunks/extract-6B7OD3VK.mjs +0 -2
- package/dist/chunks/extract-ERTOHQV6.cjs +0 -2
- package/dist/chunks/forget-KLFM5SBQ.cjs +0 -3
- package/dist/chunks/graph-P5ZHB4ZM.cjs +0 -3
- package/dist/chunks/init-CCOSHE3F.cjs +0 -3
- package/dist/chunks/init-WEPU32KF.mjs +0 -3
- package/dist/chunks/recall-BV4Z7HUJ.mjs +0 -2
- package/dist/chunks/recall-FEINUJKO.cjs +0 -2
- package/dist/chunks/remember-ESVRA73C.mjs +0 -2
- package/dist/chunks/remember-YNSY2JJB.cjs +0 -2
- package/dist/chunks/status-KVM7I6YC.cjs +0 -2
- package/dist/chunks/status-QQZS3ZCN.mjs +0 -2
- package/dist/chunks/stdio-server-MQKTUGNG.cjs +0 -1
- package/dist/chunks/stdio-server-ZLMSUTC5.mjs +0 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.cjs'),mcp=require('@easbot/mcp'),utils=require('@easbot/utils');var ee=utils.Log.create({service:"memory-format-truncate"}),U="**`";var Q=24e3,z=25e3;async function f(e,n={}){let r=n.softLimit??Q,s=n.hardCeiling??z,o=n.toolName??"memory",c=n.writeToDisk!==false;if(e.length<=r)return {content:e,truncated:false};let i=e.slice(0,s),t=i.lastIndexOf(`
|
|
2
|
+
${U}`),a=i.lastIndexOf(`
|
|
3
|
+
`),u;t>s*.5?u=t:a>0?u=a:u=-1;let d=u>0?i.slice(0,u):i,l=d+"\n\n... (output truncated to budget; the source above is complete and verbatim \u2014 treat it as already Read. For any area not covered, make ANOTHER `<tool>` targeting those names \u2014 do NOT Read these files.)";if(!c)return {content:l,truncated:true,outputPath:"",hint:"Make another recall / graph_query with narrower scope.",info:`... ${e.length-d.length}/${e.length} characters truncated ...`};try{let g=await utils.TruncateContent.truncate(e,{maxChars:d.length,direction:"head",label:`${o}-output`});return g.truncated?{content:l,truncated:!0,outputPath:g.outputPath,hint:utils.TruncateContent.formatHint(g),info:`... ${g.removedLength}/${g.originalLength} characters truncated ...`}:{content:l,truncated:!0,outputPath:"",hint:"Make another recall / graph_query with narrower scope.",info:`... ${e.length-d.length}/${e.length} characters truncated ...`}}catch(g){return ee.warn("TruncateContent.truncate failed, returning without disk hint",{error:g instanceof Error?g.message:String(g)}),{content:l,truncated:true,outputPath:"",hint:"Make another recall / graph_query with narrower scope.",info:`... ${e.length-d.length}/${e.length} characters truncated ...`}}}function $(e,n={}){let r=n.softLimit??Q,s=n.hardCeiling??z;if(e.length<=r)return {content:e,truncated:false};let o=e.slice(0,s),c=o.lastIndexOf(`
|
|
4
|
+
${U}`),i=o.lastIndexOf(`
|
|
5
|
+
`),t;c>s*.5?t=c:i>0?t=i:t=-1;let a=t>0?o.slice(0,t):o;return {content:a+`
|
|
6
|
+
|
|
7
|
+
... (output truncated; tail dropped at section boundary)`,truncated:true,outputPath:"",hint:"",info:`... ${e.length-a.length}/${e.length} characters truncated ...`}}function te(e,n){if(!e||e.length===0)return null;let r=e.filter(o=>n.has(o.path));return r.length===0?null:`\u26A0\uFE0F Index may be stale for: ${r.map(o=>`${o.path} (edited pending)`).join(", ")}
|
|
8
|
+
|
|
9
|
+
`}function I(e,n,r={}){return (J[e]??J.default).replace(/<(\w+)>/g,(o,c)=>c==="tool"?n:r[c]??`<${c}>`)}var J={recall:"If you need more facts, make ANOTHER `<tool>` query with a different scope / interval.\nIf you have enough context, proceed with the current task. Do NOT call `<tool>` again for the same query.",remember:"Memory persisted. To recall it later, use `<tool>` with the same query.\nDo NOT call `<tool>` again to verify \u2014 the fact is already in the database.",forget:"Memory deleted. To verify, run `<tool>` with the same filter (no results expected).\nIf you deleted too much, the data is gone (no auto-restore).",graph_query:"If you need to explore further, make ANOTHER `<tool>` from a different start node or depth.\nOtherwise, the graph is complete for this scope.",status:"Status snapshot. To inspect a specific fact, use `<tool>` (recall) with its id.\nOtherwise, this is a complete read.",consolidate:"Consolidation done. To inspect the new facts, use `<tool>` with the same agentId.\nIf you want to undo, archives are in <archive_dir>.",doctor:"Doctor report. To fix a failing check, run with `repair=true`.\nRe-run after fix to confirm.",default:"If you need more, make ANOTHER `<tool>` with refined parameters.\nOtherwise, this is a complete read."};function X(e,n,r,s){let o=e.tags&&e.tags.length>0?`
|
|
10
|
+
- tags: ${e.tags.join(", ")}`:"",c=e.sessionId?`
|
|
11
|
+
- session: ${e.sessionId}`:"",i=e.msgId?`
|
|
12
|
+
- msg: ${e.msgId}`:"",t=typeof n=="number"?`
|
|
13
|
+
- score: ${n.toFixed(3)}${r?` (${r})`:""}`:"",a=e.truncated?" [truncated]":"",u="";if(s&&s.length>0){let d=[];for(let m of s){let l=[];if(m.edges&&m.edges.length>0)for(let y of m.edges){let b=y.direction??(y.source===m.id?"out":"in"),R=y.targetNode?.name??String(y.target),C=y.targetNode?.type??"node";l.push(` --[${b}] ${y.relation}--> ${R} (${C})`);}let g=l.length>0?l.join(`
|
|
14
|
+
`):" (no relations)";d.push(` - Node: ${m.name} (${m.type})
|
|
15
|
+
${g}`);}u=`
|
|
16
|
+
- linked KG nodes (${s.length}):
|
|
17
|
+
${d.join(`
|
|
18
|
+
`)}`;}return [`### \`${e.id}\`${a}`,` - agentId: ${e.agentId}`,` - category: ${e.category}`,` - importance: ${e.importance}`,` - createdAt: ${e.createdAt}`,` - updatedAt: ${e.updatedAt}`,` - source: ${e.source}${t}${o}${c}${i}${u}`,"",e.content,""].join(`
|
|
19
|
+
`)}async function S(e,n){let r=n.toolName??"memory_recall",s=`**\`memory_recall:${n.query.slice(0,40).replace(/[^a-zA-Z0-9_]/g,"_")}\`**`,o=te(n.pendingFiles,new Set),i=[`Found ${e.total} fact(s) for query "${n.query}" (agentId=${n.agentId}, scope=${n.scope}):`,"",o??"",s].join(`
|
|
20
|
+
`),t=new Map;for(let m of e.hits){let l=m.fact.category;t.has(l)||t.set(l,[]),t.get(l).push(m);}let a=Array.from(t.entries()).map(([m,l])=>{let g=`**\`category:${m}\`**`,y=l.map(b=>X(b.fact,b.score,b.source,b.nodes)).join(`
|
|
21
|
+
`);return `${g}
|
|
22
|
+
|
|
23
|
+
${y}`}).join(`
|
|
24
|
+
`),u=e.warnings&&e.warnings.length>0?`
|
|
25
|
+
|
|
26
|
+
\u26A0\uFE0F warnings:
|
|
27
|
+
${e.warnings.map(m=>` - ${m}`).join(`
|
|
28
|
+
`)}
|
|
29
|
+
`:"",d=`${i}
|
|
30
|
+
|
|
31
|
+
${a}${u}
|
|
32
|
+
|
|
33
|
+
${I("recall",r)}`;return n.sync?$(d,{}).content:(await f(d,{toolName:r,writeToDisk:n.writeToDisk})).content}async function v(e,n={}){let r=n.toolName??"memory_remember",s=`**\`memory_remember:${e.fact.id}\`**`,o=X(e.fact),c=e.nodeIds??[],i=c.length>0?`
|
|
34
|
+
- linked KG nodes: ${c.join(", ")}
|
|
35
|
+
`:"",t=`${s}
|
|
36
|
+
|
|
37
|
+
${o}${i}
|
|
38
|
+
|
|
39
|
+
${I("remember",r)}`;return n.sync?$(t,{}).content:(await f(t,{toolName:r,writeToDisk:n.writeToDisk})).content}async function x(e,n={}){let r=n.toolName??"memory_forget",s="**`memory_forget:result`**",o=e.dryRun?"**DRY RUN** \u2014 no facts were actually deleted. Run again without dryRun to execute.":`Deleted ${e.deletedCount} fact(s).`,c=e.truncatedCount>0?` (truncated: ${e.truncatedCount} more, re-run with narrower filter)`:"",i=[s,"",o+c,"",e.deletedIds.length>0?`deleted ids:
|
|
40
|
+
${e.deletedIds.map(t=>` - ${t}`).join(`
|
|
41
|
+
`)}`:"(no ids to show)","",I("forget",r)].join(`
|
|
42
|
+
`);return n.sync?$(i,{}).content:(await f(i,{toolName:r,writeToDisk:n.writeToDisk})).content}async function N(e,n={}){let r=n.toolName??"memory_graph_query",s=`**\`memory_graph_query:scope=${e.scope}\`**`,o=e.nodes.map(t=>` - node #${t.id}: ${t.name} (${t.type})${t.ownerAgentId?` [owner=${t.ownerAgentId}]`:" [shared]"}`).join(`
|
|
43
|
+
`),c=e.edges.map(t=>` - edge #${t.id}: ${t.source} --${t.relation}--> ${t.target}`).join(`
|
|
44
|
+
`),i=[s,"",`nodes (${e.nodes.length}${e.truncated?` / total ${e.totalNodes}`:""}):`,o||" (none)","",`edges (${e.edges.length}${e.truncated?` / total ${e.totalEdges}`:""}):`,c||" (none)","",I("graph_query",r)].join(`
|
|
45
|
+
`);return n.sync?$(i,{}).content:(await f(i,{toolName:r,writeToDisk:n.writeToDisk})).content}async function M(e,n={}){let r=n.toolName??"memory_status",c=["**`memory_status`**","",`dbPath: ${e.dbPath}`,`workspaceDir: ${e.workspaceDir}`,`factsCount: ${e.factsCount}`,`nodesCount: ${e.nodesCount} (KG nodes)`,`edgesCount: ${e.edgesCount} (KG edges)`,`ftsAvailable: ${e.ftsAvailable?"yes":"no"}`,`vectorEnabled: ${e.vectorEnabled?"yes":"no"}`,`kgScopeEnabled: ${e.kgScopeEnabled?"yes":"no"}`,`healthy: ${e.healthy?"yes":"no"}`,"","factsByCategory:",...Object.entries(e.factsByCategory).map(([i,t])=>` - ${i}: ${t}`),"","meta:",...Object.entries(e.meta).map(([i,t])=>` - ${i}: ${t}`),"",I("status",r)].join(`
|
|
46
|
+
`);return n.sync?$(c,{}).content:(await f(c,{toolName:r,writeToDisk:n.writeToDisk})).content}async function A(e,n={}){let r=n.toolName??"memory_consolidate",o=["**`memory_consolidate:result`**","",`total facts scanned: ${e.totalFacts}`,`deduped (merged): ${e.dedupedCount}`,`compressed: ${e.compressedCount}`,`archived to archive/: ${e.archivedCount}`,`skipped (no change): ${e.skippedCount}`,`duration: ${e.durationMs}ms`,"",I("consolidate",r)].join(`
|
|
47
|
+
`);return n.sync?$(o,{}).content:(await f(o,{toolName:r,writeToDisk:n.writeToDisk})).content}var E=20;async function _(e,n={}){let r=n.toolName??"memory_sync",o=[`**\`memory_sync:${e.dryRun?"DRY_RUN":"OK"}\`**`,"",`windowDays: ${e.windowDays} (threshold: ${e.archiveThreshold})`,"","## Stage A (db \u2192 .md)",`- generated: ${e.generatedCount}`,`- skipped (idempotent): ${e.skippedCount}`,`- failed (best-effort): ${e.failedGenerateCount}`,"","## Stage B (active/ \u2192 archive/)",`- ${e.dryRun?"would archive":"archived"}: ${e.archivedCount}`];if(e.archivedRecords.length>0){o.push("","### Archived records:");let i=e.archivedRecords.slice(0,E);for(let t of i)o.push(`- ${t.firstFactId} (${t.firstCreatedAt})`),o.push(` - source: \`${t.source}\``),o.push(` - target: \`${t.target}\``);e.archivedRecords.length>E&&o.push(`... and ${e.archivedRecords.length-E} more (use --json for full list)`);}o.push("",`duration: ${e.durationMs}ms`,"",I("sync",r));let c=o.join(`
|
|
48
|
+
`);return n.sync?$(c,{}).content:(await f(c,{toolName:r,writeToDisk:n.writeToDisk})).content}async function O(e,n={}){let r=n.toolName??"memory_doctor",s=`**\`memory_doctor:${e.healthy?"OK":"ISSUES"}\`**`,o=t=>t?"\u2705":"\u274C",c=e.checks.map(t=>`${o(t.passed)} ${t.name}: ${t.message}`).join(`
|
|
49
|
+
`),i=[s,"",c,"",I("doctor",r)].join(`
|
|
50
|
+
`);return n.sync?$(i,{}).content:(await f(i,{toolName:r,writeToDisk:n.writeToDisk})).content}async function w(e,n,r={}){let s=n,o=typeof s.kind=="string";switch((o?s:{kind:e}).kind){case "recall":{let i=o?{hits:s.hits,total:s.totalCount??s.total??0,truncated:s.truncated??false}:n;return S(i,{...r,query:s.query??r.query??"",agentId:s.agentId??r.agentId??"",scope:s.scope??r.scope??"agent_only"})}case "remember":{let i=o?{fact:s.fact,nodeIds:s.nodeIds}:n;return v(i,r)}case "forget":return x(o?s:n,r);case "graph_query":return N(o?s:n,r);case "status":return M(o?s:n,r);case "consolidate":return A(o?s:n,r);case "sync":return _(o?s:n,r);case "doctor":return O(o?s:n,r);default:throw new Error(`renderOperationMarkdown: unsupported op "${e}"`)}}var D=utils.Log.create({service:"memory-mcp-stdio"});function he(e){let n=new Map,r=e.isRemote??true,s=!r;function o(t){let a=utils.Locale.resolveLocaleLang();return {agentId:t.agentId??e.agentId,isTrustedLocal:t.isTrustedLocal??s,remote:r,locale:a,dbPath:e.dbPath,workspaceDir:e.workspaceDir,rootDir:e.workspaceDir,config:chunk5Q6SIVSP_cjs.w({agentId:e.agentId,dbPath:e.dbPath})}}function c(t,a){return {content:[{type:"text",text:t}],isError:a}}function i(t){return mcp.formatFailClosed(t,s)}return n.set("recall",async t=>{try{let a=t,u=o({agentId:a.agentId}),d=await chunk5Q6SIVSP_cjs.v("recall",t,u);return {content:[{type:"text",text:await w("recall",d,{toolName:"memory_recall",query:a.query,agentId:a.agentId??e.agentId,scope:a.scope??"agent_only"})}]}}catch(a){return c(i(a),true)}}),n.set("remember",async t=>{try{let u=o({agentId:t.agentId}),d=await chunk5Q6SIVSP_cjs.v("remember",t,u);return {content:[{type:"text",text:await w("remember",d,{toolName:"memory_remember"})}]}}catch(a){return c(i(a),true)}}),n.set("forget",async t=>{try{let u=o({agentId:t.agentId}),d=await chunk5Q6SIVSP_cjs.v("forget",t,u);return {content:[{type:"text",text:await w("forget",d,{toolName:"memory_forget"})}]}}catch(a){return c(i(a),true)}}),n.set("extract",async t=>{try{let u=o({agentId:t.agentId}),m=await chunk5Q6SIVSP_cjs.v("extract",t,u);return {content:[{type:"text",text:`Extract completed.
|
|
51
|
+
sessionId: ${t.sessionId??"(unknown)"}
|
|
52
|
+
extractedCount: ${m.extractedCount}
|
|
53
|
+
factIds: ${m.factIds.length>0?m.factIds.join(", "):"(none)"}
|
|
54
|
+
messageRange: ${m.messageRange.fromMessageId} -> ${m.messageRange.toMessageId}
|
|
55
|
+
`}]}}catch(a){return c(i(a),true)}}),n.set("consolidate",async t=>{try{let u=o({agentId:t.agentId,isTrustedLocal:!0}),d=await chunk5Q6SIVSP_cjs.v("consolidate",t,u);return {content:[{type:"text",text:await w("consolidate",d,{toolName:"memory_consolidate"})}]}}catch(a){return c(i(a),true)}}),n.set("sync",async t=>{try{let u=t.agentId?.trim();if(!u)return c(i(new Error("memory_sync: agentId is required (sync requires agentId, see ADR 0069)")),!0);let d=o({agentId:u,isTrustedLocal:!0}),m=await chunk5Q6SIVSP_cjs.v("sync",t,d);return {content:[{type:"text",text:await w("sync",m,{toolName:"memory_sync"})}]}}catch(a){return c(i(a),true)}}),n.set("graph_query",async t=>{try{let a=t,u=o({agentId:a.agentId}),d=await chunk5Q6SIVSP_cjs.v("graph_query",t,u);return {content:[{type:"text",text:await w("graph_query",d,{toolName:"memory_graph_query",scope:a.scope??"agent_only"})}]}}catch(a){return c(i(a),true)}}),n.set("status",async t=>{try{let u=o({agentId:(t??{}).agentId}),d=await chunk5Q6SIVSP_cjs.v("status",t,u);return {content:[{type:"text",text:await w("status",d,{toolName:"memory_status"})}]}}catch(a){return c(i(a),true)}}),n.set("doctor",async t=>{try{let u=o({agentId:(t??{}).agentId,isTrustedLocal:!0}),d=await chunk5Q6SIVSP_cjs.v("doctor",t,u);return {content:[{type:"text",text:await w("doctor",d,{toolName:"memory_doctor"})}]}}catch(a){return c(i(a),true)}}),n.set("init",async t=>{try{let a=o({isTrustedLocal:!0}),d=await chunk5Q6SIVSP_cjs.v("init",t,a);return {content:[{type:"text",text:`Init complete.
|
|
56
|
+
dbPath: ${d.dbPath}
|
|
57
|
+
tablesCreated: ${d.tablesCreated}
|
|
58
|
+
migrationsApplied: ${d.migrationsApplied}
|
|
59
|
+
durationMs: ${d.durationMs}
|
|
60
|
+
`}]}}catch(a){return c(i(a),true)}}),n}var ye={recall:chunk5Q6SIVSP_cjs.c,remember:chunk5Q6SIVSP_cjs.d,forget:chunk5Q6SIVSP_cjs.e,extract:chunk5Q6SIVSP_cjs.f,consolidate:chunk5Q6SIVSP_cjs.g,sync:chunk5Q6SIVSP_cjs.j,graph_query:chunk5Q6SIVSP_cjs.h,init:chunk5Q6SIVSP_cjs.i};function fe(e,n){let r=chunk5Q6SIVSP_cjs.t[e],s={title:r?.annotations?.defaultDescription??e,readOnlyHint:r?.annotations?.readOnlyHint??false,destructiveHint:r?.annotations?.destructiveHint??false,idempotentHint:r?.annotations?.idempotentHint??true,openWorldHint:false},o=ye[e];return {name:e,description:r?.annotations?.defaultDescription??`memory op: ${e}`,inputSchema:o??{type:"object",properties:{},required:[]},annotations:s,handler:n}}exports.b=void 0;(r=>{async function e(s,o){let{getMemoryDbPath:c,getInstance:i}=await import('./interfaces-XWE45ENK.cjs'),a=o!==null&&typeof o=="object"&&"agentId"in o&&"dbPath"in o?o:{agentId:process.env.EASBOT_AGENT_ID??"default",dbPath:c(),workspaceDir:i().worktree,isRemote:false},u=new mcp.ToolRegistry,d=he(a),m=Object.keys(chunk5Q6SIVSP_cjs.t);for(let p of m){let P=d.get(p);if(!P)throw new Error(`MemoryStdioServer.start: missing handler for tool "${p}"`);u.register(fe(p,P));}D.info("starting memory MCP stdio server",{id:s.id,name:s.name,toolCount:m.length,isRemote:a.isRemote??true});let l=await mcp.createAndStartStdioServer(s,u),g=null,y=new Promise(p=>{g=p;}),b=p=>{D.info("received signal, stopping MCP server",{signal:p}),g?.();},R=()=>b("SIGINT"),C=()=>b("SIGTERM");process.on("SIGINT",R),process.on("SIGTERM",C);try{await y;}finally{try{process.off("SIGINT",R),process.off("SIGTERM",C);}catch(p){D.warn("failed to remove signal handlers",{error:p instanceof Error?p.message:String(p)});}try{await l.stop();}catch(p){D.warn("server.stop failed during cleanup",{error:p instanceof Error?p.message:String(p)});}}return {id:s.id,name:s.name,version:s.version,tools:m}}r.start=e;function n(){return Object.keys(chunk5Q6SIVSP_cjs.t)}r.getToolNames=n;})(exports.b||(exports.b={}));exports.a=w;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as COMMANDS_HELP,d as handleMemoryCli,b as renderBanner,c as renderHelp}from'./chunk-ARA4LMAI.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-HQBRVVXS.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkQHPGDNEG_cjs=require('./chunk-QHPGDNEG.cjs');require('./chunk-CPRDIUQ4.cjs'),require('./chunk-NVGACA7W.cjs');Object.defineProperty(exports,"COMMANDS_HELP",{enumerable:true,get:function(){return chunkQHPGDNEG_cjs.a}});Object.defineProperty(exports,"handleMemoryCli",{enumerable:true,get:function(){return chunkQHPGDNEG_cjs.d}});Object.defineProperty(exports,"renderBanner",{enumerable:true,get:function(){return chunkQHPGDNEG_cjs.b}});Object.defineProperty(exports,"renderHelp",{enumerable:true,get:function(){return chunkQHPGDNEG_cjs.c}});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function m(t){let n=t.agentId?.trim()||"default",o=t.workspaceDir??process.cwd();return chunk5Q6SIVSP_cjs.v("consolidate",{windowDays:t.windowDays??30,dryRun:false},chunk5Q6SIVSP_cjs.x(n,o))}function C(t){let n=t;return [chunk4GSXSIV5_cjs.b("consolidate",{},"Consolidation complete ({{totalFacts}} total / deduped {{dedupedCount}} / archived {{archivedCount}}):"),chunk4GSXSIV5_cjs.c("consolidate",{totalFacts:String(n.totalFacts),dedupedCount:String(n.dedupedCount),archivedCount:String(n.archivedCount)}," - total: {{totalFacts}}, deduped: {{dedupedCount}}, archived: {{archivedCount}}"),` - skipped: ${n.skippedCount}, duration: ${n.durationMs}ms`].join(`
|
|
2
|
+
`)}function f(t){let n={};for(let o=0;o<t.length;o++){let e=t[o];if(e===void 0)continue;let i=t[o+1];e==="--agent"?(n.agentId=i,o++):e==="--window-days"?(n.windowDays=Number(i),o++):e==="--json"?n.json=true:(e==="--help"||e==="-h")&&(n.help=true);}return n}exports.formatConsolidateText=C;exports.parseConsolidateOptions=f;exports.runConsolidate=m;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x}from'./chunk-746FKSL5.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function C(t){let n=t.agentId?.trim()||"default",o=t.workspaceDir??process.cwd();return v("consolidate",{windowDays:t.windowDays??30,dryRun:false},x(n,o))}function f(t){let n=t;return [b("consolidate",{},"Consolidation complete ({{totalFacts}} total / deduped {{dedupedCount}} / archived {{archivedCount}}):"),c("consolidate",{totalFacts:String(n.totalFacts),dedupedCount:String(n.dedupedCount),archivedCount:String(n.archivedCount)}," - total: {{totalFacts}}, deduped: {{dedupedCount}}, archived: {{archivedCount}}"),` - skipped: ${n.skippedCount}, duration: ${n.durationMs}ms`].join(`
|
|
2
|
+
`)}function w(t){let n={};for(let o=0;o<t.length;o++){let e=t[o];if(e===void 0)continue;let i=t[o+1];e==="--agent"?(n.agentId=i,o++):e==="--window-days"?(n.windowDays=Number(i),o++):e==="--json"?n.json=true:(e==="--help"||e==="-h")&&(n.help=true);}return n}export{f as formatConsolidateText,w as parseConsolidateOptions,C as runConsolidate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {v,x}from'./chunk-746FKSL5.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function u(o){let r=o.agentId,t=o.workspaceDir??process.cwd();return v("doctor",{repair:o.repair??false},x(r,t))}function f(o){return ""}function l(o){let r={};for(let t=0;t<o.length;t++){let e=o[t];e!==void 0&&(e==="--repair"?r.repair=true:e==="--json"?r.json=true:(e==="--help"||e==="-h")&&(r.help=true));}return r}export{f as formatDoctorText,l as parseDoctorOptions,u as runDoctor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function a(o){let r=o.agentId,t=o.workspaceDir??process.cwd();return chunk5Q6SIVSP_cjs.v("doctor",{repair:o.repair??false},chunk5Q6SIVSP_cjs.x(r,t))}function u(o){return ""}function f(o){let r={};for(let t=0;t<o.length;t++){let e=o[t];e!==void 0&&(e==="--repair"?r.repair=true:e==="--json"?r.json=true:(e==="--help"||e==="-h")&&(r.help=true));}return r}exports.formatDoctorText=u;exports.parseDoctorOptions=f;exports.runDoctor=a;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function l(r){if(!r.sessionId?.trim())throw new Error("extract: --session is required");let e=r.agentId?.trim()||"default",t=r.workspaceDir??process.cwd();return chunk5Q6SIVSP_cjs.v("extract",{sessionId:r.sessionId,lastN:r.lastN??10,fromMessageId:r.fromMessageId},chunk5Q6SIVSP_cjs.x(e,t))}function m(r){let e=r,t=[chunk4GSXSIV5_cjs.b("extract",{extractedCount:e.extractedCount},"Extracted {{extractedCount}} fact(s) from {{fromMessageId}}..{{toMessageId}}")];for(let s of e.factIds)t.push(chunk4GSXSIV5_cjs.c("extract",{id:s}," - {{id}}"));if(e.entities&&e.entities.length>0){t.push(""),t.push("entities:");for(let s of e.entities)t.push(` - ${s.name} (${s.type})`);}if(e.relations&&e.relations.length>0){t.push(""),t.push("relations:");for(let s of e.relations)t.push(` - ${s.source} --${s.relation}--> ${s.target}`);}return t.join(`
|
|
2
|
+
`)}function p(r){let e={};for(let t=0;t<r.length;t++){let s=r[t];if(s===void 0)continue;let n=r[t+1];s==="--agent"?(e.agentId=n,t++):s==="--session"?(e.sessionId=n,t++):s==="--last-n"?(e.lastN=Number(n),t++):s==="--from-msg"?(e.fromMessageId=n,t++):s==="--json"?e.json=true:(s==="--help"||s==="-h")&&(e.help=true);}return e}exports.formatExtractText=m;exports.parseExtractOptions=p;exports.runExtract=l;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x as x$1}from'./chunk-746FKSL5.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function m(r){if(!r.sessionId?.trim())throw new Error("extract: --session is required");let e=r.agentId?.trim()||"default",t=r.workspaceDir??process.cwd();return v("extract",{sessionId:r.sessionId,lastN:r.lastN??10,fromMessageId:r.fromMessageId},x$1(e,t))}function p(r){let e=r,t=[b("extract",{extractedCount:e.extractedCount},"Extracted {{extractedCount}} fact(s) from {{fromMessageId}}..{{toMessageId}}")];for(let s of e.factIds)t.push(c("extract",{id:s}," - {{id}}"));if(e.entities&&e.entities.length>0){t.push(""),t.push("entities:");for(let s of e.entities)t.push(` - ${s.name} (${s.type})`);}if(e.relations&&e.relations.length>0){t.push(""),t.push("relations:");for(let s of e.relations)t.push(` - ${s.source} --${s.relation}--> ${s.target}`);}return t.join(`
|
|
2
|
+
`)}function x(r){let e={};for(let t=0;t<r.length;t++){let s=r[t];if(s===void 0)continue;let n=r[t+1];s==="--agent"?(e.agentId=n,t++):s==="--session"?(e.sessionId=n,t++):s==="--last-n"?(e.lastN=Number(n),t++):s==="--from-msg"?(e.fromMessageId=n,t++):s==="--json"?e.json=true:(s==="--help"||s==="-h")&&(e.help=true);}return e}export{p as formatExtractText,x as parseExtractOptions,m as runExtract};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {a,b,c}from'./chunk-
|
|
1
|
+
import {a,b,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x as x$1}from'./chunk-746FKSL5.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function p(n){let e=n.agentId?.trim()||"default",t=n.workspaceDir??process.cwd();return v("forget",{factId:n.factId,category:n.category,fromTime:n.fromTime,toTime:n.toTime,maxDelete:n.maxDelete??1e3,dryRun:n.dryRun??false},x$1(e,t))}function y(n){let e=n,t=[];if(e.deletedCount===0&&e.deletedIds.length===0)return t.push(a("forget","(no records to delete)")),t.join(`
|
|
2
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};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function g(n){let e=n.agentId?.trim()||"default",t=n.workspaceDir??process.cwd();return chunk5Q6SIVSP_cjs.v("forget",{factId:n.factId,category:n.category,fromTime:n.fromTime,toTime:n.toTime,maxDelete:n.maxDelete??1e3,dryRun:n.dryRun??false},chunk5Q6SIVSP_cjs.x(e,t))}function p(n){let e=n,t=[];if(e.deletedCount===0&&e.deletedIds.length===0)return t.push(chunk4GSXSIV5_cjs.a("forget","(no records to delete)")),t.join(`
|
|
2
|
+
`);t.push(chunk4GSXSIV5_cjs.b("forget",{deletedCount:e.deletedCount,dryRun:String(e.dryRun)},e.dryRun?"[DRY RUN] Would delete {{deletedCount}}":"Deleted {{deletedCount}}")),e.truncatedCount>0&&t.push(`(truncated: ${e.truncatedCount} more)`);for(let r of e.deletedIds)t.push(chunk4GSXSIV5_cjs.c("forget",{id:r}," - {{id}}"));return t.join(`
|
|
3
|
+
`)}function y(n){let e={};for(let t=0;t<n.length;t++){let r=n[t];if(r===void 0)continue;let o=n[t+1];r==="--agent"?(e.agentId=o,t++):r==="--fact-id"?(e.factId=o,t++):r==="--category"?(e.category=o,t++):r==="--from"?(e.fromTime=o,t++):r==="--to"?(e.toTime=o,t++):r==="--max-delete"?(e.maxDelete=Number(o),t++):r==="--dry-run"?e.dryRun=true:r==="--json"?e.json=true:(r==="--help"||r==="-h")&&(e.help=true);}return e}exports.formatForgetText=p;exports.parseForgetOptions=y;exports.runForget=g;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function l(t){let r=t.agentId?.trim()||"default",n=t.workspaceDir??process.cwd();return chunk5Q6SIVSP_cjs.v("graph_query",{kind:t.kind??"nodes",query:t.query,startNodeId:t.startNodeId,depth:t.depth,maxNodes:t.maxNodes,scope:t.scope??"agent_only"},chunk5Q6SIVSP_cjs.x(r,n))}function c(t){let r=t,n=[chunk4GSXSIV5_cjs.b("graph",{totalNodes:r.totalNodes??r.nodes.length},"KG query (scope={{scope}}, {{totalNodes}} node(s)):")];if(r.nodes.length===0)return n.push(chunk4GSXSIV5_cjs.a("graph","(no nodes matched)")),n.join(`
|
|
2
|
+
`);n.push(`nodes (${r.nodes.length}):`);for(let e of r.nodes){e.ownerAgentId?` [owner=${e.ownerAgentId}]`:" [shared]";n.push(chunk4GSXSIV5_cjs.c("graph",{id:String(e.id),name:e.name,type:e.type}," - #{{id}} {{name}} ({{type}})"));}n.push(`edges (${r.edges.length}):`);for(let e of r.edges)n.push(` - #${e.id} ${e.source} --${e.relation}--> ${e.target}`);return n.join(`
|
|
3
|
+
`)}function f(t){let r={};for(let n=0;n<t.length;n++){let e=t[n];if(e===void 0)continue;let o=t[n+1];e==="--agent"?(r.agentId=o,n++):e==="--kind"?(r.kind=o,n++):e==="--query"?(r.query=o,n++):e==="--start-node"?(r.startNodeId=Number(o),n++):e==="--depth"?(r.depth=Number(o),n++):e==="--max-nodes"?(r.maxNodes=Number(o),n++):e==="--scope"?(r.scope=o,n++):e==="--json"?r.json=true:(e==="--help"||e==="-h")&&(r.help=true);}return r}exports.formatGraphText=c;exports.parseGraphOptions=f;exports.runGraph=l;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {b,a,c as c$1}from'./chunk-
|
|
1
|
+
import {b,a,c as c$1}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x}from'./chunk-746FKSL5.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function c(t){let r=t.agentId?.trim()||"default",n=t.workspaceDir??process.cwd();return v("graph_query",{kind:t.kind??"nodes",query:t.query,startNodeId:t.startNodeId,depth:t.depth,maxNodes:t.maxNodes,scope:t.scope??"agent_only"},x(r,n))}function f(t){let r=t,n=[b("graph",{totalNodes:r.totalNodes??r.nodes.length},"KG query (scope={{scope}}, {{totalNodes}} node(s)):")];if(r.nodes.length===0)return n.push(a("graph","(no nodes matched)")),n.join(`
|
|
2
2
|
`);n.push(`nodes (${r.nodes.length}):`);for(let e of r.nodes){e.ownerAgentId?` [owner=${e.ownerAgentId}]`:" [shared]";n.push(c$1("graph",{id:String(e.id),name:e.name,type:e.type}," - #{{id}} {{name}} ({{type}})"));}n.push(`edges (${r.edges.length}):`);for(let e of r.edges)n.push(` - #${e.id} ${e.source} --${e.relation}--> ${e.target}`);return n.join(`
|
|
3
3
|
`)}function y(t){let r={};for(let n=0;n<t.length;n++){let e=t[n];if(e===void 0)continue;let o=t[n+1];e==="--agent"?(r.agentId=o,n++):e==="--kind"?(r.kind=o,n++):e==="--query"?(r.query=o,n++):e==="--start-node"?(r.startNodeId=Number(o),n++):e==="--depth"?(r.depth=Number(o),n++):e==="--max-nodes"?(r.maxNodes=Number(o),n++):e==="--scope"?(r.scope=o,n++):e==="--json"?r.json=true:(e==="--help"||e==="-h")&&(r.help=true);}return r}export{f as formatGraphText,y as parseGraphOptions,c as runGraph};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.cjs');require('./chunk-EGWJG65Q.cjs');var chunkCPRDIUQ4_cjs=require('./chunk-CPRDIUQ4.cjs');require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function g(t){let e=t.workspaceDir?.trim()||t.ctxWorkspaceDir?.trim()||process.cwd(),i=t.agentId??"",n=t.ctxWorkspaceDir?.trim()||e;return chunk5Q6SIVSP_cjs.v("init",{workspaceDir:e,dbPath:chunkCPRDIUQ4_cjs.j(n),force:t.force??false},chunk5Q6SIVSP_cjs.x(i,n))}function m(t){let e={},i=[];for(let n=0;n<t.length;n++){let r=t[n];if(r===void 0)continue;let p=t[n+1];r==="--agent"?(e.agentId=p,n++):r==="--force"?e.force=true:r==="--json"?e.json=true:r==="--help"||r==="-h"?e.help=true:r.startsWith("-")||i.push(r);}return e.workspaceDir=i[0],e}exports.parseInitOptions=m;exports.runInit=g;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {v,x as x$1}from'./chunk-746FKSL5.mjs';import'./chunk-JDPZ5U53.mjs';import {j}from'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function m(t){let e=t.workspaceDir?.trim()||t.ctxWorkspaceDir?.trim()||process.cwd(),i=t.agentId??"",n=t.ctxWorkspaceDir?.trim()||e;return v("init",{workspaceDir:e,dbPath:j(n),force:t.force??false},x$1(i,n))}function x(t){let e={},i=[];for(let n=0;n<t.length;n++){let r=t[n];if(r===void 0)continue;let p=t[n+1];r==="--agent"?(e.agentId=p,n++):r==="--force"?e.force=true:r==="--json"?e.json=true:r==="--help"||r==="-h"?e.help=true:r.startsWith("-")||i.push(r);}return e.workspaceDir=i[0],e}export{x as parseInitOptions,m as runInit};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkJ5XF2W4Z_cjs=require('./chunk-J5XF2W4Z.cjs');require('./chunk-NVGACA7W.cjs');Object.defineProperty(exports,"Llm",{enumerable:true,get:function(){return chunkJ5XF2W4Z_cjs.a}});Object.defineProperty(exports,"llm",{enumerable:true,get:function(){return chunkJ5XF2W4Z_cjs.b}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as Llm,b as llm}from'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import'./chunk-QF5S5MG7.mjs';import {e}from'./chunk-
|
|
1
|
+
import'./chunk-QF5S5MG7.mjs';import {e}from'./chunk-JDPZ5U53.mjs';import {f,j}from'./chunk-WDVDYZ25.mjs';import'./chunk-HQBRVVXS.mjs';import {isAbsolute,join,dirname}from'path';import {readFileSync}from'fs';import {fileURLToPath}from'url';import {ServerTransportType}from'@easbot/mcp';import {Filesystem}from'@easbot/utils';function E(e){let t={},o=[];for(let i=0;i<e.length;i++){let r=e[i];r!==void 0&&(r==="--help"||r==="-h"?t.help=true:r==="--json"?t.json=true:r.startsWith("-")||o.push(r));}return t.dir=o[0],t}async function B(e$1){let t=e$1.dir?isAbsolute(e$1.dir)?e$1.dir:join(f().worktree,e$1.dir):f().worktree,o=j(t),i="0.0.0";try{let n=dirname(fileURLToPath(import.meta.url));for(let s=0;s<8;s++){try{let p=JSON.parse(readFileSync(join(n,"package.json"),"utf-8"));if(p?.name==="@easbot/memory"&&typeof p.version=="string"){i=p.version;break}}catch{}let a=dirname(n);if(a===n||a==="."||s===7)break;n=a;}}catch{}let r={id:"easbot-memory-mcp",name:"EASBot Memory MCP",version:i,transportType:ServerTransportType.STDIO};await Filesystem.mkdir(dirname(o));let f$1=new e(o);await f$1.initialize(),f$1.close();let{MemoryStdioServer:g}=await import('./stdio-server-JPMLMEWY.mjs'),y=process.env.EASBOT_AGENT_ID?.trim()||"default",h=await g.start(r,{agentId:y,dbPath:o,workspaceDir:t,isRemote:false});return {rootDir:t,tools:h.tools}}export{E as parseMcpOptions,B as runMcp};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';require('./chunk-URADAZYW.cjs');var
|
|
1
|
+
'use strict';require('./chunk-URADAZYW.cjs');var chunkEGWJG65Q_cjs=require('./chunk-EGWJG65Q.cjs'),chunkCPRDIUQ4_cjs=require('./chunk-CPRDIUQ4.cjs'),chunkNVGACA7W_cjs=require('./chunk-NVGACA7W.cjs'),path=require('path'),fs=require('fs'),url=require('url'),mcp=require('@easbot/mcp'),utils=require('@easbot/utils');function C(r){let t={},o=[];for(let i=0;i<r.length;i++){let e=r[i];e!==void 0&&(e==="--help"||e==="-h"?t.help=true:e==="--json"?t.json=true:e.startsWith("-")||o.push(e));}return t.dir=o[0],t}async function E(r){let t=r.dir?path.isAbsolute(r.dir)?r.dir:path.join(chunkCPRDIUQ4_cjs.f().worktree,r.dir):chunkCPRDIUQ4_cjs.f().worktree,o=chunkCPRDIUQ4_cjs.j(t),i="0.0.0";try{let n=path.dirname(url.fileURLToPath(chunkNVGACA7W_cjs.b));for(let s=0;s<8;s++){try{let p=JSON.parse(fs.readFileSync(path.join(n,"package.json"),"utf-8"));if(p?.name==="@easbot/memory"&&typeof p.version=="string"){i=p.version;break}}catch{}let a=path.dirname(n);if(a===n||a==="."||s===7)break;n=a;}}catch{}let e={id:"easbot-memory-mcp",name:"EASBot Memory MCP",version:i,transportType:mcp.ServerTransportType.STDIO};await utils.Filesystem.mkdir(path.dirname(o));let f=new chunkEGWJG65Q_cjs.e(o);await f.initialize(),f.close();let{MemoryStdioServer:y}=await import('./stdio-server-GABA2MLR.cjs'),h=process.env.EASBOT_AGENT_ID?.trim()||"default",M=await y.start(e,{agentId:h,dbPath:o,workspaceDir:t,isRemote:false});return {rootDir:t,tools:M.tools}}exports.parseMcpOptions=C;exports.runMcp=E;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkWQB4D6DZ_cjs=require('./chunk-WQB4D6DZ.cjs'),chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function p(n){if(!n.query?.trim())throw new Error("recall: --query is required");let e=n.agentId?.trim()||"default",t=n.workspaceDir??process.cwd();return chunk5Q6SIVSP_cjs.v("recall",{query:n.query,maxResults:n.limit??10,category:n.category,minImportance:n.minImportance},chunk5Q6SIVSP_cjs.x(e,t))}function f(n){let e=n;if(e.total===0)return chunkWQB4D6DZ_cjs.a("memory.recall.empty",{fallback:"(no facts)"});let t=[chunkWQB4D6DZ_cjs.a("memory.recall.summary",{vars:{total:e.total},fallback:`Found ${e.total} fact(s):`})];for(let r of e.hits)t.push(chunkWQB4D6DZ_cjs.a("memory.recall.item",{vars:{id:r.memoryId,category:r.category,importance:String(r.importance),score:r.score.toFixed(3),content:r.snippet},fallback:" - {{id}} [{{category}}/imp={{importance}}/score={{score}}] {{content}}"}));return t.join(`
|
|
2
|
+
`)}function g(n){let e={};for(let t=0;t<n.length;t++){let r=n[t];if(r===void 0)continue;let o=n[t+1];r==="--agent"?(e.agentId=o,t++):r==="--query"?(e.query=o,t++):r==="--limit"?(e.limit=Number(o),t++):r==="--category"?(e.category=o,t++):r==="--min-importance"?(e.minImportance=Number(o),t++):r==="--json"?e.json=true:(r==="--help"||r==="-h")&&(e.help=true);}return e}exports.formatRecallText=f;exports.parseRecallOptions=g;exports.runRecall=p;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a}from'./chunk-SWYQLQ7Z.mjs';import {v,x}from'./chunk-746FKSL5.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function f(n){if(!n.query?.trim())throw new Error("recall: --query is required");let e=n.agentId?.trim()||"default",t=n.workspaceDir??process.cwd();return v("recall",{query:n.query,maxResults:n.limit??10,category:n.category,minImportance:n.minImportance},x(e,t))}function g(n){let e=n;if(e.total===0)return a("memory.recall.empty",{fallback:"(no facts)"});let t=[a("memory.recall.summary",{vars:{total:e.total},fallback:`Found ${e.total} fact(s):`})];for(let r of e.hits)t.push(a("memory.recall.item",{vars:{id:r.memoryId,category:r.category,importance:String(r.importance),score:r.score.toFixed(3),content:r.snippet},fallback:" - {{id}} [{{category}}/imp={{importance}}/score={{score}}] {{content}}"}));return t.join(`
|
|
2
|
+
`)}function y(n){let e={};for(let t=0;t<n.length;t++){let r=n[t];if(r===void 0)continue;let o=n[t+1];r==="--agent"?(e.agentId=o,t++):r==="--query"?(e.query=o,t++):r==="--limit"?(e.limit=Number(o),t++):r==="--category"?(e.category=o,t++):r==="--min-importance"?(e.minImportance=Number(o),t++):r==="--json"?e.json=true:(r==="--help"||r==="-h")&&(e.help=true);}return e}export{g as formatRecallText,y as parseRecallOptions,f as runRecall};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b as b$1,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x}from'./chunk-746FKSL5.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function p(r){if(!r.content?.trim())throw new Error("remember: --content is required");if(!r.category?.trim())throw new Error("remember: --category is required");if(r.importance===void 0)throw new Error("remember: --importance is required (1-10)");let e=r.agentId?.trim()||"default",t=r.workspaceDir??process.cwd();return v("remember",{content:r.content,category:r.category,importance:r.importance,tags:r.tags,sessionId:r.sessionId},x(e,t))}function l(r){let e=r,t=[b$1("remember",{},"Memory persisted:"),c("remember",{id:e.fact.id,category:e.fact.category,importance:String(e.fact.importance??5)}," - id={{id}} category={{category}} importance={{importance}}"),` - createdAt: ${e.fact.createdAt}`];return e.deduplicated&&t.push(" - (deduplicated; no new fact inserted)"),t.join(`
|
|
2
|
+
`)}function b(r){let e={};for(let t=0;t<r.length;t++){let i=r[t];if(i===void 0)continue;let n=r[t+1];i==="--agent"&&n!==void 0?(e.agentId=n,t++):i==="--content"&&n!==void 0?(e.content=n,t++):i==="--category"&&n!==void 0?(e.category=n,t++):i==="--importance"&&n!==void 0?(e.importance=Number(n),t++):i==="--tag"&&n!==void 0?(e.tags=[...e.tags??[],n],t++):i==="--session"&&n!==void 0?(e.sessionId=n,t++):i==="--json"?e.json=true:(i==="--help"||i==="-h")&&(e.help=true);}return e}export{l as formatRememberText,b as parseRememberOptions,p as runRemember};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function u(r){if(!r.content?.trim())throw new Error("remember: --content is required");if(!r.category?.trim())throw new Error("remember: --category is required");if(r.importance===void 0)throw new Error("remember: --importance is required (1-10)");let e=r.agentId?.trim()||"default",t=r.workspaceDir??process.cwd();return chunk5Q6SIVSP_cjs.v("remember",{content:r.content,category:r.category,importance:r.importance,tags:r.tags,sessionId:r.sessionId},chunk5Q6SIVSP_cjs.x(e,t))}function p(r){let e=r,t=[chunk4GSXSIV5_cjs.b("remember",{},"Memory persisted:"),chunk4GSXSIV5_cjs.c("remember",{id:e.fact.id,category:e.fact.category,importance:String(e.fact.importance??5)}," - id={{id}} category={{category}} importance={{importance}}"),` - createdAt: ${e.fact.createdAt}`];return e.deduplicated&&t.push(" - (deduplicated; no new fact inserted)"),t.join(`
|
|
2
|
+
`)}function l(r){let e={};for(let t=0;t<r.length;t++){let i=r[t];if(i===void 0)continue;let n=r[t+1];i==="--agent"&&n!==void 0?(e.agentId=n,t++):i==="--content"&&n!==void 0?(e.content=n,t++):i==="--category"&&n!==void 0?(e.category=n,t++):i==="--importance"&&n!==void 0?(e.importance=Number(n),t++):i==="--tag"&&n!==void 0?(e.tags=[...e.tags??[],n],t++):i==="--session"&&n!==void 0?(e.sessionId=n,t++):i==="--json"?e.json=true:(i==="--help"||i==="-h")&&(e.help=true);}return e}exports.formatRememberText=p;exports.parseRememberOptions=l;exports.runRemember=u;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function c(t){let n=t.agentId,e=t.workspaceDir??process.cwd();return chunk5Q6SIVSP_cjs.v("status",{agentId:n},chunk5Q6SIVSP_cjs.x(n,e))}function f(t){return ""}function l(t){let n={};for(let e=0;e<t.length;e++){let o=t[e];if(o===void 0)continue;let i=t[e+1];o==="--agent"?(n.agentId=i,e++):o==="--json"?n.json=true:(o==="--help"||o==="-h")&&(n.help=true);}return n}exports.formatStatusText=f;exports.parseStatusOptions=l;exports.runStatus=c;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {v,x}from'./chunk-746FKSL5.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function f(t){let n=t.agentId,e=t.workspaceDir??process.cwd();return v("status",{agentId:n},x(n,e))}function l(t){return ""}function g(t){let n={};for(let e=0;e<t.length;e++){let o=t[e];if(o===void 0)continue;let i=t[e+1];o==="--agent"?(n.agentId=i,e++):o==="--json"?n.json=true:(o==="--help"||o==="-h")&&(n.help=true);}return n}export{l as formatStatusText,g as parseStatusOptions,f as runStatus};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkX66LENNV_cjs=require('./chunk-X66LENNV.cjs');require('./chunk-5Q6SIVSP.cjs'),require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');Object.defineProperty(exports,"MemoryStdioServer",{enumerable:true,get:function(){return chunkX66LENNV_cjs.b}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{b as MemoryStdioServer}from'./chunk-CN6WBJLX.mjs';import'./chunk-746FKSL5.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b,c}from'./chunk-QYBWHFOX.mjs';import'./chunk-SWYQLQ7Z.mjs';import {v,x}from'./chunk-746FKSL5.mjs';import'./chunk-JDPZ5U53.mjs';import'./chunk-WDVDYZ25.mjs';import'./chunk-6CQMBEIQ.mjs';import'./chunk-HQBRVVXS.mjs';async function m(e){let n=e.agentId?.trim()||"default",r=e.workspaceDir??process.cwd();return v("sync",{windowDays:e.windowDays,dryRun:e.dryRun??false},x(n,r))}function f(e){let n=e;return [b("sync",{windowDays:String(n.windowDays),dryRun:String(n.dryRun)},"sync complete (windowDays={{windowDays}}, dryRun={{dryRun}}):"),c("sync",{generatedCount:String(n.generatedCount),skippedCount:String(n.skippedCount),failedGenerateCount:String(n.failedGenerateCount),archivedCount:String(n.archivedCount),archiveThreshold:n.archiveThreshold}," - generated: {{generatedCount}}, skipped: {{skippedCount}}, failed: {{failedGenerateCount}}, archived: {{archivedCount}} (threshold: {{archiveThreshold}})"),` - duration: ${n.durationMs}ms`].join(`
|
|
2
|
+
`)}function h(e){let n={};for(let r=0;r<e.length;r++){let t=e[r];if(t===void 0)continue;let i=e[r+1];if(t==="--agent")n.agentId=i,r++;else if(t==="--window-days"){let o=Number(i);if(Number.isNaN(o)||o<1||o>3650)throw new Error(`--window-days must be an integer in [1, 3650], got: ${i??"(empty)"}`);n.windowDays=o,r++;}else t==="--dry-run"?n.dryRun=true:t==="--json"?n.json=true:(t==="--help"||t==="-h")&&(n.help=true);}return n}export{f as formatSyncText,h as parseSyncOptions,m as runSync};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunk4GSXSIV5_cjs=require('./chunk-4GSXSIV5.cjs');require('./chunk-WQB4D6DZ.cjs');var chunk5Q6SIVSP_cjs=require('./chunk-5Q6SIVSP.cjs');require('./chunk-EGWJG65Q.cjs'),require('./chunk-CPRDIUQ4.cjs'),require('./chunk-J5XF2W4Z.cjs'),require('./chunk-NVGACA7W.cjs');async function w(e){let n=e.agentId?.trim()||"default",r=e.workspaceDir??process.cwd();return chunk5Q6SIVSP_cjs.v("sync",{windowDays:e.windowDays,dryRun:e.dryRun??false},chunk5Q6SIVSP_cjs.x(n,r))}function m(e){let n=e;return [chunk4GSXSIV5_cjs.b("sync",{windowDays:String(n.windowDays),dryRun:String(n.dryRun)},"sync complete (windowDays={{windowDays}}, dryRun={{dryRun}}):"),chunk4GSXSIV5_cjs.c("sync",{generatedCount:String(n.generatedCount),skippedCount:String(n.skippedCount),failedGenerateCount:String(n.failedGenerateCount),archivedCount:String(n.archivedCount),archiveThreshold:n.archiveThreshold}," - generated: {{generatedCount}}, skipped: {{skippedCount}}, failed: {{failedGenerateCount}}, archived: {{archivedCount}} (threshold: {{archiveThreshold}})"),` - duration: ${n.durationMs}ms`].join(`
|
|
2
|
+
`)}function f(e){let n={};for(let r=0;r<e.length;r++){let t=e[r];if(t===void 0)continue;let i=e[r+1];if(t==="--agent")n.agentId=i,r++;else if(t==="--window-days"){let o=Number(i);if(Number.isNaN(o)||o<1||o>3650)throw new Error(`--window-days must be an integer in [1, 3650], got: ${i??"(empty)"}`);n.windowDays=o,r++;}else t==="--dry-run"?n.dryRun=true:t==="--json"?n.json=true:(t==="--help"||t==="-h")&&(n.help=true);}return n}exports.formatSyncText=m;exports.parseSyncOptions=f;exports.runSync=w;
|
package/dist/cli.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';var chunkNVGACA7W_cjs=require('./chunks/chunk-NVGACA7W.cjs'),fs=require('fs'),path=require('path'),url=require('url'),terminal=require('@easbot/terminal');var
|
|
2
|
+
'use strict';var chunkNVGACA7W_cjs=require('./chunks/chunk-NVGACA7W.cjs'),fs=require('fs'),path=require('path'),url=require('url'),terminal=require('@easbot/terminal');var E=path.dirname(url.fileURLToPath(chunkNVGACA7W_cjs.b));function A(){try{let t=path.join(E,"..","package.json");return JSON.parse(fs.readFileSync(t,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var f=new Set(["DEBUG","INFO","WARN","ERROR"]);function N(t){let n={logLevel:"INFO",printLogs:false,debug:false};for(let i=0;i<t.length;i++){let e=t[i];if(e)if(e==="--cwd"&&i+1<t.length){let o=t[i+1];o&&!o.startsWith("-")&&(n.cwd=o,i++);}else if(e.startsWith("--cwd="))n.cwd=e.slice(6);else if(e==="--config"&&i+1<t.length){let o=t[i+1];o&&!o.startsWith("-")&&(n.configPath=o,i++);}else if(e.startsWith("--config="))n.configPath=e.slice(9);else if(e==="--log-level"&&i+1<t.length){let o=t[i+1];if(o&&!o.startsWith("-")){let r=o.toUpperCase();f.has(r)&&(n.logLevel=r,i++);}}else if(e.startsWith("--log-level=")){let o=e.slice(12).toUpperCase();f.has(o)&&(n.logLevel=o);}else e==="--print-logs"?n.printLogs=true:e==="--debug"&&(n.debug=true);}return n}async function R(){let t=process.argv.slice(2),n=A(),{loadEnv:i}=await import('@easbot/utils');i(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let e=N(t),{Log:o}=await import('@easbot/utils'),{getXdgData:r}=await import('./chunks/interfaces-XWE45ENK.cjs'),h=path.join(r(),"memory","log");if(await o.init({logDir:h,print:e.printLogs,dev:e.debug||false,level:e.logLevel}),t.length===0){let{renderBanner:l}=await import('./chunks/cli-handler-IRPYADZF.cjs');l();return}if(t[0]==="--help"||t[0]==="-h"){let{renderHelp:l}=await import('./chunks/cli-handler-IRPYADZF.cjs');l();return}if(t[0]==="--version"||t[0]==="-v"){terminal.printHuman([terminal.formatInfo(n)]);return}let a=e.cwd??process.cwd(),{handleMemoryCli:m}=await import('./chunks/cli-handler-IRPYADZF.cjs'),{setInstanceAdapter:u}=await import('./chunks/interfaces-XWE45ENK.cjs');u({directory:a,worktree:a});let{Llm:w}=await import('./chunks/llm-RMPVWEVP.cjs'),{bootstrapLlm:L,setAdapterRegistry:b}=await import('@easbot/llm'),{getGlobal:s,getInstance:c}=await import('./chunks/interfaces-XWE45ENK.cjs');b({config:void 0,instance:{getDirectory:()=>c().directory,getWorktree:()=>c().worktree},global:{home:s().Path.home,data:s().Path.data,cache:s().Path.cache,config:s().Path.config,state:s().Path.state,log:s().Path.log,bin:s().Path.bin},installation:{getVersion:()=>n,getChannel:()=>"local",getUserAgent:()=>`easbot-memory/${n}`}}),await L({target:w,cwd:a,subConfigPath:".easbot/memory.json",embedding:true,graph:true});let g=await m(t,{version:n,cwd:a});g.code!==0&&(process.exitCode=g.code);}R().catch(t=>{console.error(t),process.exitCode=1;}).finally(async()=>{try{let{Log:t}=await import('@easbot/utils');await t.close();}catch{}process.exit(process.exitCode??0);});
|
package/dist/cli.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {readFileSync}from'fs';import {dirname,join}from'path';import {fileURLToPath}from'url';import {printHuman,formatInfo}from'@easbot/terminal';var
|
|
2
|
+
import {readFileSync}from'fs';import {dirname,join}from'path';import {fileURLToPath}from'url';import {printHuman,formatInfo}from'@easbot/terminal';var G=dirname(fileURLToPath(import.meta.url));function E(){try{let t=join(G,"..","package.json");return JSON.parse(readFileSync(t,"utf-8")).version??"0.0.0"}catch{return "0.0.0"}}var p=new Set(["DEBUG","INFO","WARN","ERROR"]);function A(t){let n={logLevel:"INFO",printLogs:false,debug:false};for(let i=0;i<t.length;i++){let e=t[i];if(e)if(e==="--cwd"&&i+1<t.length){let o=t[i+1];o&&!o.startsWith("-")&&(n.cwd=o,i++);}else if(e.startsWith("--cwd="))n.cwd=e.slice(6);else if(e==="--config"&&i+1<t.length){let o=t[i+1];o&&!o.startsWith("-")&&(n.configPath=o,i++);}else if(e.startsWith("--config="))n.configPath=e.slice(9);else if(e==="--log-level"&&i+1<t.length){let o=t[i+1];if(o&&!o.startsWith("-")){let r=o.toUpperCase();p.has(r)&&(n.logLevel=r,i++);}}else if(e.startsWith("--log-level=")){let o=e.slice(12).toUpperCase();p.has(o)&&(n.logLevel=o);}else e==="--print-logs"?n.printLogs=true:e==="--debug"&&(n.debug=true);}return n}async function N(){let t=process.argv.slice(2),n=E(),{loadEnv:i}=await import('@easbot/utils');i(),process.env.EASBOT_LANG||(process.env.EASBOT_LANG="en-US");let e=A(t),{Log:o}=await import('@easbot/utils'),{getXdgData:r}=await import('./chunks/interfaces-LPJU4KS3.mjs'),d=join(r(),"memory","log");if(await o.init({logDir:d,print:e.printLogs,dev:e.debug||false,level:e.logLevel}),t.length===0){let{renderBanner:l}=await import('./chunks/cli-handler-CN4Q7BCY.mjs');l();return}if(t[0]==="--help"||t[0]==="-h"){let{renderHelp:l}=await import('./chunks/cli-handler-CN4Q7BCY.mjs');l();return}if(t[0]==="--version"||t[0]==="-v"){printHuman([formatInfo(n)]);return}let a=e.cwd??process.cwd(),{handleMemoryCli:m}=await import('./chunks/cli-handler-CN4Q7BCY.mjs'),{setInstanceAdapter:h}=await import('./chunks/interfaces-LPJU4KS3.mjs');h({directory:a,worktree:a});let{Llm:u}=await import('./chunks/llm-UHTBU2HA.mjs'),{bootstrapLlm:w,setAdapterRegistry:L}=await import('@easbot/llm'),{getGlobal:s,getInstance:c}=await import('./chunks/interfaces-LPJU4KS3.mjs');L({config:void 0,instance:{getDirectory:()=>c().directory,getWorktree:()=>c().worktree},global:{home:s().Path.home,data:s().Path.data,cache:s().Path.cache,config:s().Path.config,state:s().Path.state,log:s().Path.log,bin:s().Path.bin},installation:{getVersion:()=>n,getChannel:()=>"local",getUserAgent:()=>`easbot-memory/${n}`}}),await w({target:u,cwd:a,subConfigPath:".easbot/memory.json",embedding:true,graph:true});let g=await m(t,{version:n,cwd:a});g.code!==0&&(process.exitCode=g.code);}N().catch(t=>{console.error(t),process.exitCode=1;}).finally(async()=>{try{let{Log:t}=await import('@easbot/utils');await t.close();}catch{}process.exit(process.exitCode??0);});
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use strict';require('./chunks/chunk-URADAZYW.cjs');var chunkQHPGDNEG_cjs=require('./chunks/chunk-QHPGDNEG.cjs'),chunkX66LENNV_cjs=require('./chunks/chunk-X66LENNV.cjs'),chunk5Q6SIVSP_cjs=require('./chunks/chunk-5Q6SIVSP.cjs'),chunkEGWJG65Q_cjs=require('./chunks/chunk-EGWJG65Q.cjs'),chunkCPRDIUQ4_cjs=require('./chunks/chunk-CPRDIUQ4.cjs'),chunkJ5XF2W4Z_cjs=require('./chunks/chunk-J5XF2W4Z.cjs'),chunkNVGACA7W_cjs=require('./chunks/chunk-NVGACA7W.cjs'),types=require('@easbot/types'),d=require('jieba-wasm'),utils=require('@easbot/utils'),crypto=require('crypto');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var d__namespace=/*#__PURE__*/_interopNamespace(d);var Oe=["user_preference","task_context","technical_fact","decision","relationship","reminder","error_pattern","workflow","exploration_finding","experience_summary","tool_usage","skill_creation","test","other"],p=class extends Error{constructor(t,o,n){super(t,{cause:n});chunkNVGACA7W_cjs.a(this,"code",o);chunkNVGACA7W_cjs.a(this,"cause",n);this.name="MemoryError";}},P=class extends p{constructor(r,t){super(r,"MEMORY_VALIDATION_ERROR",t),this.name="MemoryValidationError";}},N=class extends p{constructor(r){super(`Memory not found: ${r}`,"MEMORY_NOT_FOUND"),this.name="MemoryNotFoundError";}},D=class extends p{constructor(r){super(r,"MEMORY_PERMISSION_ERROR"),this.name="MemoryPermissionError";}},T=class extends p{constructor(r,t){super(r,"MEMORY_DATABASE_ERROR",t),this.name="MemoryDatabaseError";}},v=class extends p{constructor(r,t){super(r,"MEMORY_FILE_ERROR",t),this.name="MemoryFileError";}},F=class extends p{constructor(r,t){super(r,"MEMORY_SEARCH_ERROR",t),this.name="MemorySearchError";}},L=class extends p{constructor(r,t){super(r,"MEMORY_EMBEDDING_ERROR",t),this.name="MemoryEmbeddingError";}},me=(a=>(a.VALIDATION_ERROR="MEMORY_VALIDATION_ERROR",a.NOT_FOUND="MEMORY_NOT_FOUND",a.PERMISSION_ERROR="MEMORY_PERMISSION_ERROR",a.DATABASE_ERROR="MEMORY_DATABASE_ERROR",a.FILE_ERROR="MEMORY_FILE_ERROR",a.SEARCH_ERROR="MEMORY_SEARCH_ERROR",a.EMBEDDING_ERROR="MEMORY_EMBEDDING_ERROR",a))(me||{});var s=utils.Log.create({service:"memory.tokenizer"}),l=false,ye=utils.loadTextFile("./assets/jieba_dict.txt",chunkNVGACA7W_cjs.b);async function ve(e){if(!l)try{s.debug("Initializing jieba tokenizer");let r=ye();if(d__namespace.with_dict(r),s.debug("Built-in dictionary loaded"),e?.dictPath&&e.dictPath.length>0)for(let t of e.dictPath)await Re(t);l=!0,s.debug("Jieba tokenizer initialized successfully");}catch(r){s.error("Failed to initialize jieba tokenizer",{error:String(r)}),s.warn("Using fallback tokenization (space-based)");}}async function Re(e){if(!l)throw new Error("Tokenizer not initialized");try{let r=await utils.Filesystem.readText(e);s.debug("Loading custom dictionary",{dictPath:e}),d__namespace.with_dict(r),s.debug("Custom dictionary loaded successfully",{dictPath:e});}catch(r){s.warn("Failed to load custom dictionary",{dictPath:e,error:String(r)});}}function ke(e){if(!l)return e.split(/\s+/).filter(Boolean);try{return d__namespace.cut(e)}catch(r){return s.warn("Tokenization failed, using fallback",{error:String(r)}),e.split(/\s+/).filter(Boolean)}}function xe(e){if(!l)return e.split(/\s+/).filter(Boolean);try{return d__namespace.cut_for_search(e)}catch(r){return s.warn("Tokenization for search failed, using fallback",{error:String(r)}),e.split(/\s+/).filter(Boolean)}}function Fe(e,r,t){if(l)try{d__namespace.add_word(e,r,t),s.debug("Word added to dictionary",{word:e,freq:r,tag:t});}catch(o){s.warn("Failed to add word",{word:e,error:String(o)});}}function Le(){return l}async function $e(){l=false,s.debug("Tokenizer closed");}function je(e){if(!l)return e.split(/\s+/).filter(Boolean).join(" ");try{return ke(e).join(" ")}catch(r){return s.warn("Tokenization failed, using fallback",{error:String(r)}),e.split(/\s+/).filter(Boolean).join(" ")}}function ze(e){if(!l)return e.split(/\s+/).filter(Boolean).join(" ");try{return xe(e).join(" ")}catch(r){return s.warn("Tokenization for search failed, using fallback",{error:String(r)}),e.split(/\s+/).filter(Boolean).join(" ")}}function m(e){let r=chunkCPRDIUQ4_cjs.f().worktree,t=chunkCPRDIUQ4_cjs.j(r);return {agentId:e,isTrustedLocal:true,remote:false,locale:"en-US",dbPath:t,workspaceDir:r,rootDir:r,config:chunk5Q6SIVSP_cjs.w({agentId:e,dbPath:t,workspaceDir:r})}}var $=async e=>{if(!e.agentId?.trim())return {ok:false,error:"session-start: agentId is required in ctx"};let r=e.extras?.topK??5,t=e.extras?.query??"";try{let o=await chunk5Q6SIVSP_cjs.v("recall",{query:t,maxResults:r},m(e.agentId));if(o.hits.length===0)return {ok:!0,injected:"",logLine:"session-start: no facts found for agent; skipping context injection"};let n=o.hits.map(y=>`- [${y.category}/imp=${y.importance}] ${y.snippet.slice(0,200)}`);return {ok:!0,injected:`[memory:session-start recall top-${o.hits.length}]
|
|
2
2
|
${n.join(`
|
|
3
|
-
`)}`,logLine:`session-start: injected ${o.hits.length} facts into context (agent=${e.agentId})`}}catch(o){return {ok:false,error:o instanceof Error?o.message:String(o)}}};var
|
|
3
|
+
`)}`,logLine:`session-start: injected ${o.hits.length} facts into context (agent=${e.agentId})`}}catch(o){return {ok:false,error:o instanceof Error?o.message:String(o)}}};var j=async e=>{if(!e.agentId?.trim())return {ok:false,error:"session-end: agentId is required in ctx"};let r=e.extras?.windowDays??1;try{let t=await chunk5Q6SIVSP_cjs.v("consolidate",{windowDays:r},m(e.agentId));return {ok:!0,logLine:`session-end: total=${t.totalFacts}, deduped=${t.dedupedCount}, archived=${t.archivedCount}, skipped=${t.skippedCount}`}}catch(t){return {ok:false,error:t instanceof Error?t.message:String(t)}}};var z=async e=>{if(!e.agentId?.trim())return {ok:false,error:"pre-compact: agentId is required in ctx"};let t=(e.contextPreview??e.messagePreview??"").slice(0,200).replace(/\s+/g," ").trim(),o=e.extras?.topK??3;if(!t)return {ok:true,injected:"",logLine:"pre-compact: empty contextPreview; skipping recall injection"};try{let n=await chunk5Q6SIVSP_cjs.v("recall",{query:t,maxResults:o,minImportance:5},m(e.agentId));if(n.hits.length===0)return {ok:!0,injected:"",logLine:`pre-compact: no facts matched query for agent=${e.agentId}`};let H=n.hits.map(a=>`- [${a.category}/imp=${a.importance}] ${a.snippet.slice(0,150)}`);return {ok:!0,injected:`[memory:pre-compact recall top-${n.hits.length} (imp>=5)]
|
|
4
4
|
${H.join(`
|
|
5
|
-
`)}`,logLine:`pre-compact: injected ${n.hits.length} facts before compaction`}}catch(n){return {ok:false,error:n instanceof Error?n.message:String(n)}}};var
|
|
6
|
-
`);try{return {ok:!0,logLine:`post-tool-failure: wrote error_pattern fact ${(await
|
|
5
|
+
`)}`,logLine:`pre-compact: injected ${n.hits.length} facts before compaction`}}catch(n){return {ok:false,error:n instanceof Error?n.message:String(n)}}};var Y=async e=>{if(!e.agentId?.trim())return {ok:false,error:"post-tool-failure: agentId is required in ctx"};if(!e.toolName?.trim()||!e.error?.trim())return {ok:false,error:"post-tool-failure: toolName and error are required in ctx"};let r=crypto.createHash("sha256").update(`${e.toolName}:${e.error}`).digest("hex").slice(0,8),t=e.messagePreview?e.messagePreview.slice(0,200).replace(/\s+/g," ").trim():"",o=[`[error_pattern] tool=${e.toolName}`,`[error] ${e.error}`,t?`[preview] ${t}`:"",`[errHash] ${r}`].filter(Boolean).join(`
|
|
6
|
+
`);try{return {ok:!0,logLine:`post-tool-failure: wrote error_pattern fact ${(await chunk5Q6SIVSP_cjs.v("remember",{content:o,category:"error_pattern",importance:6,tags:["post-tool-failure",`tool:${e.toolName}`,`err:${r}`],sessionId:e.sessionId,msgId:e.extras?.msgId},m(e.agentId))).fact.id} (tool=${e.toolName}, errHash=${r})`}}catch(n){return {ok:false,error:n instanceof Error?n.message:String(n)}}};var u=utils.Log.create({service:"memory.hooks"}),g=new Map;function f(e,r){let t={name:e,handler:r,registeredAt:new Date().toISOString()},o=g.get(e);g.set(e,t),o?u.info("Hook overwritten",{name:e,prevRegisteredAt:o.registeredAt,newRegisteredAt:t.registeredAt}):u.info("Hook registered",{name:e,registeredAt:t.registeredAt});}function Ee(e){return g.delete(e)}function be(){return Array.from(g.values()).map(e=>({name:e.name,handler:e.handler,registeredAt:e.registeredAt}))}function Ie(){f("session-start",$),f("session-end",j),f("pre-compact",z),f("post-tool-failure",Y);}function Me(){g.clear(),u.debug("All hooks cleared");}async function _e(e,r){let t=g.get(e);if(!t)return u.debug("dispatchHook: no handler registered; noop",{name:e}),{ok:true,logLine:`hook ${e} not registered; noop`};try{let o=await t.handler(r);return o.ok?o.logLine&&u.debug("dispatchHook: ok",{name:e,logLine:o.logLine}):u.warn("dispatchHook: handler returned failure",{name:e,agentId:r.agentId,error:o.error}),o}catch(o){let n=o instanceof Error?o.message:String(o);return u.warn("dispatchHook: handler threw, caught and converted to failure result",{name:e,agentId:r.agentId,error:n}),{ok:false,error:n}}}Object.defineProperty(exports,"COMMANDS_HELP",{enumerable:true,get:function(){return chunkQHPGDNEG_cjs.a}});Object.defineProperty(exports,"handleMemoryCli",{enumerable:true,get:function(){return chunkQHPGDNEG_cjs.d}});Object.defineProperty(exports,"renderBanner",{enumerable:true,get:function(){return chunkQHPGDNEG_cjs.b}});Object.defineProperty(exports,"renderHelp",{enumerable:true,get:function(){return chunkQHPGDNEG_cjs.c}});Object.defineProperty(exports,"MemoryStdioServer",{enumerable:true,get:function(){return chunkX66LENNV_cjs.b}});Object.defineProperty(exports,"renderOperationMarkdown",{enumerable:true,get:function(){return chunkX66LENNV_cjs.a}});Object.defineProperty(exports,"ALL_OPS",{enumerable:true,get:function(){return chunk5Q6SIVSP_cjs.u}});Object.defineProperty(exports,"GraphStore",{enumerable:true,get:function(){return chunk5Q6SIVSP_cjs.a}});Object.defineProperty(exports,"OP_REGISTRY",{enumerable:true,get:function(){return chunk5Q6SIVSP_cjs.t}});Object.defineProperty(exports,"consolidate",{enumerable:true,get:function(){return chunk5Q6SIVSP_cjs.n}});Object.defineProperty(exports,"doctor",{enumerable:true,get:function(){return chunk5Q6SIVSP_cjs.s}});Object.defineProperty(exports,"executeOp",{enumerable:true,get:function(){return chunk5Q6SIVSP_cjs.v}});Object.defineProperty(exports,"extract",{enumerable:true,get:function(){return chunk5Q6SIVSP_cjs.m}});Object.defineProperty(exports,"forget",{enumerable:true,get:function(){return chunk5Q6SIVSP_cjs.l}});Object.defineProperty(exports,"graphQuery",{enumerable:true,get:function(){return chunk5Q6SIVSP_cjs.p}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunk5Q6SIVSP_cjs.q}});Object.defineProperty(exports,"recall",{enumerable:true,get:function(){return chunk5Q6SIVSP_cjs.b}});Object.defineProperty(exports,"remember",{enumerable:true,get:function(){return chunk5Q6SIVSP_cjs.k}});Object.defineProperty(exports,"status",{enumerable:true,get:function(){return chunk5Q6SIVSP_cjs.r}});Object.defineProperty(exports,"sync",{enumerable:true,get:function(){return chunk5Q6SIVSP_cjs.o}});Object.defineProperty(exports,"LATEST_SCHEMA_VERSION",{enumerable:true,get:function(){return chunkEGWJG65Q_cjs.a}});Object.defineProperty(exports,"MIGRATIONS",{enumerable:true,get:function(){return chunkEGWJG65Q_cjs.b}});Object.defineProperty(exports,"MemoryDatabaseManager",{enumerable:true,get:function(){return chunkEGWJG65Q_cjs.e}});Object.defineProperty(exports,"readCurrentSchemaVersion",{enumerable:true,get:function(){return chunkEGWJG65Q_cjs.d}});Object.defineProperty(exports,"runMigrations",{enumerable:true,get:function(){return chunkEGWJG65Q_cjs.c}});Object.defineProperty(exports,"getGlobal",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.c}});Object.defineProperty(exports,"getHomeDir",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.g}});Object.defineProperty(exports,"getInstance",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.f}});Object.defineProperty(exports,"getMemoryDbPath",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.j}});Object.defineProperty(exports,"getMemoryDir",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.i}});Object.defineProperty(exports,"getXdgData",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.h}});Object.defineProperty(exports,"resetGlobalAdapter",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.b}});Object.defineProperty(exports,"resetInstanceAdapter",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.e}});Object.defineProperty(exports,"setGlobalAdapter",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.a}});Object.defineProperty(exports,"setInstanceAdapter",{enumerable:true,get:function(){return chunkCPRDIUQ4_cjs.d}});Object.defineProperty(exports,"Llm",{enumerable:true,get:function(){return chunkJ5XF2W4Z_cjs.a}});Object.defineProperty(exports,"GRAPH_ENTITY_TYPE_DEFINITIONS",{enumerable:true,get:function(){return types.GRAPH_ENTITY_TYPE_DEFINITIONS}});Object.defineProperty(exports,"GRAPH_RELATION_TYPE_DEFINITIONS",{enumerable:true,get:function(){return types.GRAPH_RELATION_TYPE_DEFINITIONS}});exports.MEMORY_CATEGORIES=Oe;exports.MemoryDatabaseError=T;exports.MemoryEmbeddingError=L;exports.MemoryError=p;exports.MemoryErrorCode=me;exports.MemoryFileError=v;exports.MemoryNotFoundError=N;exports.MemoryPermissionError=D;exports.MemorySearchError=F;exports.MemoryValidationError=P;exports.addWord=Fe;exports.clearAllHooks=Me;exports.closeTokenizer=$e;exports.dispatchHook=_e;exports.initTokenizer=ve;exports.isInitialized=Le;exports.listHooks=be;exports.loadCustomDict=Re;exports.registerAllDefaultHooks=Ie;exports.registerHook=f;exports.toFtsTokens=je;exports.toFtsTokensForSearch=ze;exports.tokenize=ke;exports.tokenizeForSearch=xe;exports.unregisterHook=Ee;
|