midas-memory-mcp 0.0.3
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.md +65 -0
- package/dist/bin/midas-mcp.d.ts +2 -0
- package/dist/bin/midas-mcp.js +6 -0
- package/dist/bm25.d.ts +11 -0
- package/dist/bm25.js +55 -0
- package/dist/embeddings.d.ts +14 -0
- package/dist/embeddings.js +62 -0
- package/dist/guard.d.ts +17 -0
- package/dist/guard.js +37 -0
- package/dist/importance.d.ts +6 -0
- package/dist/importance.js +81 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/mcp.d.ts +7 -0
- package/dist/mcp.js +309 -0
- package/dist/memory.d.ts +113 -0
- package/dist/memory.js +472 -0
- package/dist/policy.d.ts +5 -0
- package/dist/policy.js +19 -0
- package/dist/store.d.ts +35 -0
- package/dist/store.js +159 -0
- package/dist/types.d.ts +27 -0
- package/dist/types.js +16 -0
- package/package.json +43 -0
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/** Midas as an MCP server (TypeScript) — same tool surface, env knobs, injected policy, and
|
|
2
|
+
* SQLite schema as the Python `midas.mcp_server`, so the two are interchangeable and can even
|
|
3
|
+
* share one DB file live. No LLM and no network at ingest/query (hashing embedder; a local ONNX
|
|
4
|
+
* semantic embedder is the planned next step — use the Python server when you need bge today). */
|
|
5
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { decideMemoryUse, MEMORY_USES } from "./guard.js";
|
|
9
|
+
import { Memory, DEFAULT_POLICY } from "./memory.js";
|
|
10
|
+
import { structuralImportance } from "./importance.js";
|
|
11
|
+
import { AGENT_MEMORY_INSTRUCTIONS, policySummary } from "./policy.js";
|
|
12
|
+
import { SQLiteStore } from "./store.js";
|
|
13
|
+
import { MEMORY_PROVENANCE } from "./types.js";
|
|
14
|
+
const MAX_RECORDS = Number(process.env.MIDAS_MCP_MAX_RECORDS ?? "0") || null;
|
|
15
|
+
const MIN_IMPORTANCE = Number(process.env.MIDAS_MCP_MIN_IMPORTANCE ?? "2");
|
|
16
|
+
const ACTOR = process.env.MIDAS_MCP_ACTOR ?? "midas-mcp-ts";
|
|
17
|
+
const NAMESPACE = process.env.MIDAS_MCP_NAMESPACE ?? "";
|
|
18
|
+
const SUPERSEDE = process.env.MIDAS_MCP_SUPERSEDE !== "0";
|
|
19
|
+
function buildMemory() {
|
|
20
|
+
let store;
|
|
21
|
+
const db = process.env.MIDAS_MCP_DB;
|
|
22
|
+
if (db) {
|
|
23
|
+
store = new SQLiteStore(db);
|
|
24
|
+
console.error(`[midas-mcp-ts] persisting memory to ${db}`);
|
|
25
|
+
}
|
|
26
|
+
return new Memory({
|
|
27
|
+
store,
|
|
28
|
+
importanceScorer: structuralImportance,
|
|
29
|
+
policy: { ...DEFAULT_POLICY, minImportance: MIN_IMPORTANCE },
|
|
30
|
+
supersede: SUPERSEDE,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const mem = buildMemory();
|
|
34
|
+
function ns(namespace) {
|
|
35
|
+
return namespace || NAMESPACE;
|
|
36
|
+
}
|
|
37
|
+
function nsMetadata(namespace, session) {
|
|
38
|
+
const n = ns(namespace);
|
|
39
|
+
return { session, ...(n ? { namespace: n } : {}) };
|
|
40
|
+
}
|
|
41
|
+
function nsFilter(namespace) {
|
|
42
|
+
const n = ns(namespace);
|
|
43
|
+
return n ? { namespace: n } : null;
|
|
44
|
+
}
|
|
45
|
+
function serializeRecord(record) {
|
|
46
|
+
return {
|
|
47
|
+
id: record.id,
|
|
48
|
+
kind: record.kind,
|
|
49
|
+
importance: record.importance,
|
|
50
|
+
provenance: record.provenance,
|
|
51
|
+
actor: record.actor,
|
|
52
|
+
source: record.source,
|
|
53
|
+
metadata: record.metadata,
|
|
54
|
+
created_at: record.createdAt,
|
|
55
|
+
updated_at: record.updatedAt,
|
|
56
|
+
superseded_by: record.supersededBy,
|
|
57
|
+
content: record.content,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function boundStore() {
|
|
61
|
+
if (MAX_RECORDS && mem.store.all().length > MAX_RECORDS) {
|
|
62
|
+
mem.forgetDecayed({ maxRecords: MAX_RECORDS });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function json(data) {
|
|
66
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
67
|
+
}
|
|
68
|
+
function text(data) {
|
|
69
|
+
return { content: [{ type: "text", text: data }] };
|
|
70
|
+
}
|
|
71
|
+
export function createServer() {
|
|
72
|
+
const server = new McpServer({ name: "midas-memory", version: "0.0.3" }, { instructions: AGENT_MEMORY_INSTRUCTIONS });
|
|
73
|
+
server.registerTool("remember", {
|
|
74
|
+
title: "Remember",
|
|
75
|
+
description: "Store a memory for later recall. kind: note | chat | fact | preference | constraint | mission. " +
|
|
76
|
+
"importance 1-5 (0 = auto-derive from content, no LLM). provenance: planning | action | observation | " +
|
|
77
|
+
"user_confirmation (external actions may rely only on user_confirmation).",
|
|
78
|
+
inputSchema: {
|
|
79
|
+
content: z.string(),
|
|
80
|
+
kind: z.string().default("note"),
|
|
81
|
+
importance: z.number().int().min(0).max(5).default(0),
|
|
82
|
+
session: z.string().default("default"),
|
|
83
|
+
provenance: z.enum(MEMORY_PROVENANCE).default("observation"),
|
|
84
|
+
actor: z.string().default(""),
|
|
85
|
+
namespace: z.string().default(""),
|
|
86
|
+
},
|
|
87
|
+
}, async (args) => {
|
|
88
|
+
const rec = mem.remember(args.content, {
|
|
89
|
+
kind: args.kind,
|
|
90
|
+
importance: args.importance || null,
|
|
91
|
+
source: `mcp:${args.session}`,
|
|
92
|
+
provenance: args.provenance,
|
|
93
|
+
actor: args.actor || ACTOR,
|
|
94
|
+
metadata: nsMetadata(args.namespace, args.session),
|
|
95
|
+
});
|
|
96
|
+
boundStore();
|
|
97
|
+
return text(`remembered (${rec.id})`);
|
|
98
|
+
});
|
|
99
|
+
server.registerTool("capture", {
|
|
100
|
+
title: "Capture turn",
|
|
101
|
+
description: "Offer a turn to memory; Midas decides whether to keep it (no LLM): scores importance, enforces the " +
|
|
102
|
+
"relevance floor, skips duplicates, and says why. kind: note | chat | fact | preference | constraint | mission. " +
|
|
103
|
+
"provenance: planning | action | observation | user_confirmation.",
|
|
104
|
+
inputSchema: {
|
|
105
|
+
content: z.string(),
|
|
106
|
+
kind: z.string().default("chat"),
|
|
107
|
+
session: z.string().default("default"),
|
|
108
|
+
provenance: z.enum(MEMORY_PROVENANCE).default("observation"),
|
|
109
|
+
actor: z.string().default(""),
|
|
110
|
+
namespace: z.string().default(""),
|
|
111
|
+
},
|
|
112
|
+
}, async (args) => {
|
|
113
|
+
const result = mem.capture(args.content, {
|
|
114
|
+
kind: args.kind,
|
|
115
|
+
source: `mcp:${args.session}`,
|
|
116
|
+
provenance: args.provenance,
|
|
117
|
+
actor: args.actor || ACTOR,
|
|
118
|
+
metadata: nsMetadata(args.namespace, args.session),
|
|
119
|
+
});
|
|
120
|
+
if (result.stored)
|
|
121
|
+
boundStore();
|
|
122
|
+
return json({
|
|
123
|
+
stored: result.stored,
|
|
124
|
+
reason: result.reason,
|
|
125
|
+
importance: result.importance,
|
|
126
|
+
id: result.record?.id ?? null,
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
server.registerTool("recall", {
|
|
130
|
+
title: "Recall",
|
|
131
|
+
description: "Retrieve relevant memories with deterministic, source-traceable evidence (exact stored text + " +
|
|
132
|
+
"provenance/source/timestamps + score components). Set hybrid=true for exact-identifier queries.",
|
|
133
|
+
inputSchema: {
|
|
134
|
+
query: z.string(),
|
|
135
|
+
limit: z.number().int().min(1).default(5),
|
|
136
|
+
kind: z.string().default(""),
|
|
137
|
+
min_importance: z.number().int().min(0).default(0),
|
|
138
|
+
hybrid: z.boolean().default(false),
|
|
139
|
+
namespace: z.string().default(""),
|
|
140
|
+
},
|
|
141
|
+
}, async (args) => {
|
|
142
|
+
const hits = mem.recall(args.query, {
|
|
143
|
+
limit: args.limit,
|
|
144
|
+
kind: (args.kind || null),
|
|
145
|
+
minImportance: args.min_importance || null,
|
|
146
|
+
hybrid: args.hybrid,
|
|
147
|
+
metadataFilter: nsFilter(args.namespace),
|
|
148
|
+
});
|
|
149
|
+
return json(hits.map((h) => ({
|
|
150
|
+
...serializeRecord(h.record),
|
|
151
|
+
score: round3(h.score),
|
|
152
|
+
relevance: round3(h.relevance),
|
|
153
|
+
importance_norm: round3(h.importanceNorm),
|
|
154
|
+
recency: round3(h.recency),
|
|
155
|
+
})));
|
|
156
|
+
});
|
|
157
|
+
server.registerTool("inspect_memory", {
|
|
158
|
+
title: "Inspect memory",
|
|
159
|
+
description: "Inspect one stored memory by id without search, mutation, or embedding exposure.",
|
|
160
|
+
inputSchema: { memory_id: z.string() },
|
|
161
|
+
}, async (args) => {
|
|
162
|
+
const record = mem.store.get(args.memory_id);
|
|
163
|
+
return json(record ? { found: true, ...serializeRecord(record) } : { found: false, id: args.memory_id });
|
|
164
|
+
});
|
|
165
|
+
server.registerTool("build_context", {
|
|
166
|
+
title: "Build context",
|
|
167
|
+
description: "Assemble a budgeted, prompt-ready context block (lean dated lines + a 'Today is' anchor). " +
|
|
168
|
+
"Use recall/inspect_memory for full provenance.",
|
|
169
|
+
inputSchema: {
|
|
170
|
+
query: z.string(),
|
|
171
|
+
token_budget: z.number().int().min(16).default(512),
|
|
172
|
+
limit: z.number().int().min(1).default(6),
|
|
173
|
+
hybrid: z.boolean().default(false),
|
|
174
|
+
namespace: z.string().default(""),
|
|
175
|
+
},
|
|
176
|
+
}, async (args) => text(mem.buildContext(args.query, {
|
|
177
|
+
tokenBudget: args.token_budget,
|
|
178
|
+
limit: args.limit,
|
|
179
|
+
hybrid: args.hybrid,
|
|
180
|
+
metadataFilter: nsFilter(args.namespace),
|
|
181
|
+
}).text));
|
|
182
|
+
server.registerTool("memory_policy", {
|
|
183
|
+
title: "Memory policy",
|
|
184
|
+
description: "Return the exact MCP-injected memory policy text and guard parameters.",
|
|
185
|
+
inputSchema: {},
|
|
186
|
+
}, async () => json({
|
|
187
|
+
instructions: AGENT_MEMORY_INSTRUCTIONS,
|
|
188
|
+
relevance_policy: policySummary({ ...DEFAULT_POLICY, minImportance: MIN_IMPORTANCE }),
|
|
189
|
+
provenance: MEMORY_PROVENANCE,
|
|
190
|
+
guard_uses: MEMORY_USES,
|
|
191
|
+
}));
|
|
192
|
+
server.registerTool("check_memory_use", {
|
|
193
|
+
title: "Check memory use",
|
|
194
|
+
description: "Decide whether recalled memory may justify the intended use. intended_use: planning | answer | " +
|
|
195
|
+
"external_action | destructive_action (the last two require user_confirmation provenance).",
|
|
196
|
+
inputSchema: {
|
|
197
|
+
query: z.string(),
|
|
198
|
+
intended_use: z.enum(MEMORY_USES).default("planning"),
|
|
199
|
+
limit: z.number().int().min(1).default(5),
|
|
200
|
+
acting_agent: z.string().default(""),
|
|
201
|
+
namespace: z.string().default(""),
|
|
202
|
+
},
|
|
203
|
+
}, async (args) => {
|
|
204
|
+
const hits = mem.recall(args.query, { limit: args.limit, metadataFilter: nsFilter(args.namespace) });
|
|
205
|
+
return json(decideMemoryUse(hits.map((h) => h.record), {
|
|
206
|
+
intendedUse: args.intended_use,
|
|
207
|
+
actingAgent: args.acting_agent || ACTOR,
|
|
208
|
+
}));
|
|
209
|
+
});
|
|
210
|
+
server.registerTool("forget", {
|
|
211
|
+
title: "Forget memory",
|
|
212
|
+
description: "Delete a single memory by id (supersession chains are relinked, not orphaned).",
|
|
213
|
+
inputSchema: { memory_id: z.string() },
|
|
214
|
+
}, async (args) => text(mem.forget(args.memory_id) ? "forgotten" : `no memory with id ${args.memory_id}`));
|
|
215
|
+
server.registerTool("forget_matching", {
|
|
216
|
+
title: "Forget matching",
|
|
217
|
+
description: "Topic-level erasure with a reviewable audit. DRY RUN by default: returns what WOULD be deleted; " +
|
|
218
|
+
"repeat with dry_run=false to erase. Bypasses durability protections on purpose.",
|
|
219
|
+
inputSchema: {
|
|
220
|
+
query: z.string(),
|
|
221
|
+
min_relevance: z.number().min(0).max(1).default(0.5),
|
|
222
|
+
limit: z.number().int().min(1).default(20),
|
|
223
|
+
dry_run: z.boolean().default(true),
|
|
224
|
+
namespace: z.string().default(""),
|
|
225
|
+
},
|
|
226
|
+
}, async (args) => {
|
|
227
|
+
const matched = mem.forgetMatching(args.query, {
|
|
228
|
+
minRelevance: args.min_relevance,
|
|
229
|
+
limit: args.limit,
|
|
230
|
+
metadataFilter: nsFilter(args.namespace),
|
|
231
|
+
dryRun: args.dry_run,
|
|
232
|
+
});
|
|
233
|
+
return json({
|
|
234
|
+
dry_run: args.dry_run,
|
|
235
|
+
matched: matched.length,
|
|
236
|
+
records: matched.map(serializeRecord),
|
|
237
|
+
note: args.dry_run ? "dry run — nothing deleted; repeat with dry_run=false to erase" : "deleted",
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
server.registerTool("forget_all", {
|
|
241
|
+
title: "Forget all",
|
|
242
|
+
description: "Clear all stored memories (fresh start).",
|
|
243
|
+
inputSchema: {},
|
|
244
|
+
}, async () => {
|
|
245
|
+
const n = mem.store.all().length;
|
|
246
|
+
mem.store.clear();
|
|
247
|
+
return text(`cleared ${n} memories`);
|
|
248
|
+
});
|
|
249
|
+
server.registerTool("maintain", {
|
|
250
|
+
title: "Maintain memory",
|
|
251
|
+
description: "Run a no-LLM memory-maintenance pass (bound to max_records and/or drop below min_value) and return " +
|
|
252
|
+
"the deletion audit. Durable kinds and supersession chains are protected.",
|
|
253
|
+
inputSchema: {
|
|
254
|
+
max_records: z.number().int().min(0).default(0),
|
|
255
|
+
min_value: z.number().min(0).default(0),
|
|
256
|
+
},
|
|
257
|
+
}, async (args) => {
|
|
258
|
+
const before = mem.store.all().length;
|
|
259
|
+
const forgotten = args.max_records || args.min_value
|
|
260
|
+
? mem.forgetDecayed({
|
|
261
|
+
maxRecords: args.max_records || null,
|
|
262
|
+
minValue: args.min_value || null,
|
|
263
|
+
})
|
|
264
|
+
: [];
|
|
265
|
+
return json({
|
|
266
|
+
before,
|
|
267
|
+
remaining: mem.store.all().length,
|
|
268
|
+
forgotten: forgotten.length,
|
|
269
|
+
removed_ids: forgotten,
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
server.registerTool("stats", {
|
|
273
|
+
title: "Memory stats",
|
|
274
|
+
description: "Memory stats: total, by kind/provenance/namespace, and short/medium/long temporal tiers.",
|
|
275
|
+
inputSchema: { namespace: z.string().default("") },
|
|
276
|
+
}, async (args) => {
|
|
277
|
+
const n = ns(args.namespace);
|
|
278
|
+
const byKind = {};
|
|
279
|
+
const byProvenance = {};
|
|
280
|
+
const byTier = { short: 0, medium: 0, long: 0 };
|
|
281
|
+
const byNamespace = {};
|
|
282
|
+
for (const r of mem.store.all()) {
|
|
283
|
+
const rns = r.metadata?.namespace || "(none)";
|
|
284
|
+
byNamespace[rns] = (byNamespace[rns] ?? 0) + 1;
|
|
285
|
+
if (n && r.metadata?.namespace !== n)
|
|
286
|
+
continue;
|
|
287
|
+
byKind[r.kind] = (byKind[r.kind] ?? 0) + 1;
|
|
288
|
+
byProvenance[r.provenance] = (byProvenance[r.provenance] ?? 0) + 1;
|
|
289
|
+
byTier[mem.tier(r)] += 1;
|
|
290
|
+
}
|
|
291
|
+
return json({
|
|
292
|
+
total: Object.values(byKind).reduce((a, b) => a + b, 0),
|
|
293
|
+
namespace: n || null,
|
|
294
|
+
by_kind: byKind,
|
|
295
|
+
by_provenance: byProvenance,
|
|
296
|
+
by_tier: byTier,
|
|
297
|
+
by_namespace: byNamespace,
|
|
298
|
+
guard_uses: MEMORY_USES,
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
return server;
|
|
302
|
+
}
|
|
303
|
+
function round3(x) {
|
|
304
|
+
return Math.round(x * 1000) / 1000;
|
|
305
|
+
}
|
|
306
|
+
export async function main() {
|
|
307
|
+
const server = createServer();
|
|
308
|
+
await server.connect(new StdioServerTransport());
|
|
309
|
+
}
|
package/dist/memory.d.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { type Embedder } from "./embeddings.js";
|
|
2
|
+
import { type ImportanceScorer } from "./importance.js";
|
|
3
|
+
import { InMemoryStore } from "./store.js";
|
|
4
|
+
import type { MemoryKind, MemoryProvenance, MemoryRecord, RecallHit } from "./types.js";
|
|
5
|
+
export declare const RECENCY_HALF_LIFE_DAYS = 30;
|
|
6
|
+
export declare const DEFAULT_RECALL_LIMIT = 6;
|
|
7
|
+
export declare const DURABLE_KINDS: readonly MemoryKind[];
|
|
8
|
+
export interface MemoryPolicy {
|
|
9
|
+
minImportance: number;
|
|
10
|
+
acceptKinds: readonly string[];
|
|
11
|
+
dedupThreshold: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const DEFAULT_POLICY: MemoryPolicy;
|
|
14
|
+
export interface CaptureResult {
|
|
15
|
+
stored: boolean;
|
|
16
|
+
reason: string;
|
|
17
|
+
record: MemoryRecord | null;
|
|
18
|
+
importance: number;
|
|
19
|
+
}
|
|
20
|
+
export interface RememberOptions {
|
|
21
|
+
kind?: MemoryKind;
|
|
22
|
+
importance?: number | null;
|
|
23
|
+
source?: string | null;
|
|
24
|
+
provenance?: MemoryProvenance;
|
|
25
|
+
actor?: string | null;
|
|
26
|
+
metadata?: Record<string, unknown>;
|
|
27
|
+
createdAt?: number | null;
|
|
28
|
+
}
|
|
29
|
+
export interface RecallOptions {
|
|
30
|
+
limit?: number;
|
|
31
|
+
kind?: MemoryKind | null;
|
|
32
|
+
minImportance?: number | null;
|
|
33
|
+
minRelevance?: number | null;
|
|
34
|
+
minRelevanceRatio?: number | null;
|
|
35
|
+
pool?: number | null;
|
|
36
|
+
hybrid?: boolean;
|
|
37
|
+
now?: number | null;
|
|
38
|
+
metadataFilter?: Record<string, unknown> | null;
|
|
39
|
+
}
|
|
40
|
+
export interface ContextBlock {
|
|
41
|
+
text: string;
|
|
42
|
+
records: MemoryRecord[];
|
|
43
|
+
tokens: number;
|
|
44
|
+
}
|
|
45
|
+
export interface MemoryOptions {
|
|
46
|
+
store?: InMemoryStore;
|
|
47
|
+
embedder?: Embedder;
|
|
48
|
+
wRelevance?: number;
|
|
49
|
+
wImportance?: number;
|
|
50
|
+
wRecency?: number;
|
|
51
|
+
supersede?: boolean;
|
|
52
|
+
supersedeThreshold?: number;
|
|
53
|
+
supersedePool?: number;
|
|
54
|
+
supersedeMargin?: number;
|
|
55
|
+
supersedeLowerThreshold?: number;
|
|
56
|
+
minRelevanceRatio?: number;
|
|
57
|
+
importanceScorer?: ImportanceScorer | null;
|
|
58
|
+
policy?: MemoryPolicy;
|
|
59
|
+
now?: () => number;
|
|
60
|
+
}
|
|
61
|
+
export declare class Memory {
|
|
62
|
+
readonly store: InMemoryStore;
|
|
63
|
+
readonly embedder: Embedder;
|
|
64
|
+
private wRelevance;
|
|
65
|
+
private wImportance;
|
|
66
|
+
private wRecency;
|
|
67
|
+
private supersede;
|
|
68
|
+
private supersedeThreshold;
|
|
69
|
+
private supersedePool;
|
|
70
|
+
private supersedeMargin;
|
|
71
|
+
private supersedeLowerThreshold;
|
|
72
|
+
private minRelevanceRatio;
|
|
73
|
+
private importanceScorer;
|
|
74
|
+
private policy;
|
|
75
|
+
private now;
|
|
76
|
+
private bm25Cache;
|
|
77
|
+
constructor(opts?: MemoryOptions);
|
|
78
|
+
remember(content: string, opts?: RememberOptions): MemoryRecord;
|
|
79
|
+
capture(content: string, opts?: RememberOptions): CaptureResult;
|
|
80
|
+
private upgradeProvenance;
|
|
81
|
+
private deriveImportance;
|
|
82
|
+
recall(query: string, opts?: RecallOptions): RecallHit[];
|
|
83
|
+
private hybridCandidates;
|
|
84
|
+
private bm25Index;
|
|
85
|
+
private maybeSupersede;
|
|
86
|
+
resolveHead(record: MemoryRecord): MemoryRecord;
|
|
87
|
+
private resolveCandidates;
|
|
88
|
+
buildContext(query: string, opts?: RecallOptions & {
|
|
89
|
+
tokenBudget?: number;
|
|
90
|
+
header?: boolean;
|
|
91
|
+
maxRecordChars?: number;
|
|
92
|
+
}): ContextBlock;
|
|
93
|
+
forget(recordId: string): boolean;
|
|
94
|
+
forgetMatching(query: string, opts?: {
|
|
95
|
+
minRelevance?: number;
|
|
96
|
+
limit?: number;
|
|
97
|
+
metadataFilter?: Record<string, unknown> | null;
|
|
98
|
+
dryRun?: boolean;
|
|
99
|
+
}): MemoryRecord[];
|
|
100
|
+
memoryValue(record: MemoryRecord, now?: number): number;
|
|
101
|
+
tier(record: MemoryRecord, now?: number): "short" | "medium" | "long";
|
|
102
|
+
forgetDecayed(opts?: {
|
|
103
|
+
maxRecords?: number | null;
|
|
104
|
+
minValue?: number | null;
|
|
105
|
+
protectImportance?: number;
|
|
106
|
+
}): string[];
|
|
107
|
+
}
|
|
108
|
+
export declare function fmtDate(ts: number): string;
|
|
109
|
+
export declare function formatRecord(record: MemoryRecord, opts?: {
|
|
110
|
+
maxChars?: number;
|
|
111
|
+
now?: number | null;
|
|
112
|
+
}): string;
|
|
113
|
+
export declare function approxTokens(text: string): number;
|