@agent-custody/state 0.8.0 → 0.9.0
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 +87 -9
- package/dist/case-file.d.ts +56 -0
- package/dist/case-file.js +258 -0
- package/dist/cli.js +78 -20
- package/dist/index.d.ts +9 -5
- package/dist/index.js +5 -3
- package/dist/ledger.d.ts +34 -1
- package/dist/ledger.js +41 -1
- package/dist/review.d.ts +22 -4
- package/dist/review.js +165 -31
- package/dist/search.d.ts +28 -0
- package/dist/search.js +177 -0
- package/dist/server.d.ts +6 -1
- package/dist/server.js +124 -30
- package/dist/stores.d.ts +86 -7
- package/dist/stores.js +167 -23
- package/dist/verify-web.d.ts +91 -0
- package/dist/verify-web.js +856 -0
- package/package.json +2 -2
package/dist/server.js
CHANGED
|
@@ -9,6 +9,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
9
9
|
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
import { signResult } from "@agent-custody/receipts";
|
|
12
|
+
import { entryOf } from "./stores.js";
|
|
12
13
|
export const SERVER_VERSION = "0.1.0";
|
|
13
14
|
/** The same keys the receipts gateway sets on the upstream call. Duplicated here so this package needs no runtime import from receipts. */
|
|
14
15
|
export const RECEIPT_META_KEY = "agent-custody/receipt";
|
|
@@ -39,6 +40,7 @@ const Get = z.object({ factId: z.string().min(1) });
|
|
|
39
40
|
const Forget = z.object({ factId: z.string().min(1), reason: z.string().min(1), keepDigest: z.boolean().optional() });
|
|
40
41
|
const Hold = z.object({ factId: z.string().min(1), reason: z.string().min(1) });
|
|
41
42
|
const Sweep = z.object({ before: iso.optional(), space: z.string().min(1).optional(), reason: z.string().min(1), keepDigest: z.boolean().optional() });
|
|
43
|
+
const Repair = z.object({ reason: z.string().min(1), before: iso.optional() });
|
|
42
44
|
const str = { type: "string" };
|
|
43
45
|
const isoStr = { type: "string", description: "an ISO 8601 date-time with a UTC offset, for example 2026-10-15T09:00:00Z" };
|
|
44
46
|
const actorStr = { type: "string", description: "who acts; ignored behind the gateway, which records the agent named in the signed grant" };
|
|
@@ -83,6 +85,11 @@ export const TOOLS = [
|
|
|
83
85
|
description: "Retention: forget every fact the ledger learned of before an instant, in one space or all, skipping held facts, and remove each from every store. Without `before`, the server's configured retention windows decide per space. The receipt is the record of the sweep.",
|
|
84
86
|
inputSchema: { type: "object", properties: { before: isoStr, space: str, reason: str, keepDigest: { type: "boolean" } }, required: ["reason"] },
|
|
85
87
|
},
|
|
88
|
+
{
|
|
89
|
+
name: "memory.repair",
|
|
90
|
+
description: "Find and remove store entries that the ledger has no fact for. A write reaches the stores before the ledger, so a failed ledger append leaves such an entry. For each store that can list its entries: every entry with custody metadata, stored more than ten minutes ago, whose fact id the ledger does not know is removed, a repair event is recorded under that fact id first, and then the removal is made and verified. A write that is still in progress then fails at its ledger append. A repair of an entry that has a repair event adds no second event. `before` can only move the cutoff earlier. Returns { before, repaired, unlisted, stillHeld, unrecorded }: the cutoff, what was removed with the store's answer, the stores that cannot list, the removals and listings that failed, and the entries that stay because the ledger did not take the repair event.",
|
|
91
|
+
inputSchema: { type: "object", properties: { reason: str, before: isoStr }, required: ["reason"] },
|
|
92
|
+
},
|
|
86
93
|
{
|
|
87
94
|
name: "memory.get",
|
|
88
95
|
description: "One fact by id, whatever its state: its space, actor, provenance, source receipt, validity. Meant for the gateway's fact lookups, so policy can decide on the fact a write supersedes or a retraction targets.",
|
|
@@ -111,12 +118,22 @@ export function retentionCutoff(retention, space, now) {
|
|
|
111
118
|
}
|
|
112
119
|
return null;
|
|
113
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* How old a store entry must be before repair may remove it. A write whose stores take more than half of it fails
|
|
123
|
+
* before its ledger append, so the entry of a write in progress is never this old.
|
|
124
|
+
*/
|
|
125
|
+
export const REPAIR_MIN_AGE_MS = 10 * 60_000;
|
|
114
126
|
const json = (v) => ({ content: [{ type: "text", text: JSON.stringify(v) }] });
|
|
115
127
|
const fail = (msg) => ({ isError: true, content: [{ type: "text", text: msg }] });
|
|
116
128
|
export function createMemoryServer(ledger, opts = {}) {
|
|
117
129
|
const server = new Server({ name: "agent-custody-memory", version: SERVER_VERSION }, { capabilities: { tools: {} } });
|
|
118
130
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
|
|
119
131
|
const trustMeta = opts.trustMeta ?? opts.requireGateway !== false;
|
|
132
|
+
// A store written for remove(externalId, fact) and verifyRemoved would get an entry where it expects an id, and its
|
|
133
|
+
// check could then report an entry as gone that is still there: a false erasure certificate. Refuse it.
|
|
134
|
+
for (const store of opts.stores ?? [])
|
|
135
|
+
if (typeof store.delete !== "function")
|
|
136
|
+
throw new Error(`store ${store.name} has no delete(entry); remove(externalId, fact) and verifyRemoved are now delete(entry) and verifyDeleted(entry)`);
|
|
120
137
|
server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
121
138
|
// A caller that is not the gateway gets no say in who it is or what was observed: its _meta is dropped whole.
|
|
122
139
|
const meta = trustMeta ? (req.params._meta ?? {}) : {};
|
|
@@ -125,55 +142,121 @@ export function createMemoryServer(ledger, opts = {}) {
|
|
|
125
142
|
return opts.identity && receiptId ? signResult(result, opts.identity, receiptId, req.params.name) : result;
|
|
126
143
|
});
|
|
127
144
|
/**
|
|
128
|
-
* Removes
|
|
129
|
-
*
|
|
145
|
+
* Removes one entry from a store, then asks the store's search whether it is really gone. The outcome is what the
|
|
146
|
+
* receipt records: verified, stillIndexed, unverified (the store cannot say), or failed, with the store's error.
|
|
130
147
|
*/
|
|
148
|
+
async function removeEntry(store, entry) {
|
|
149
|
+
try {
|
|
150
|
+
await store.delete(entry);
|
|
151
|
+
}
|
|
152
|
+
catch (e) {
|
|
153
|
+
return { outcome: "failed", error: `${store.name}: ${e instanceof Error ? e.message : String(e)}` };
|
|
154
|
+
}
|
|
155
|
+
return { outcome: await verifyEntry(store, entry) };
|
|
156
|
+
}
|
|
157
|
+
/** Asks the store's search whether a deleted entry is gone. A store without a check cannot say. */
|
|
158
|
+
async function verifyEntry(store, entry) {
|
|
159
|
+
if (!store.verifyDeleted)
|
|
160
|
+
return "unverified";
|
|
161
|
+
const attempts = Math.max(1, opts.verify?.attempts ?? 3);
|
|
162
|
+
const delayMs = opts.verify?.delayMs ?? 200;
|
|
163
|
+
for (let i = 0; i < attempts; i++) {
|
|
164
|
+
if (i > 0)
|
|
165
|
+
await new Promise((r) => setTimeout(r, delayMs * 2 ** (i - 1)));
|
|
166
|
+
try {
|
|
167
|
+
if (await store.verifyDeleted(entry))
|
|
168
|
+
return "verified";
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
// The store could not be asked; that is not the same as the value being gone.
|
|
172
|
+
return "unverified";
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return "stillIndexed";
|
|
176
|
+
}
|
|
177
|
+
/** Removes a fact from every store it was written to. */
|
|
131
178
|
async function removeFromStores(fact) {
|
|
132
179
|
const removedFrom = [];
|
|
133
180
|
const stillHeld = [];
|
|
134
181
|
const verification = {};
|
|
135
|
-
const attempts = Math.max(1, opts.verify?.attempts ?? 3);
|
|
136
|
-
const delayMs = opts.verify?.delayMs ?? 200;
|
|
137
182
|
for (const store of opts.stores ?? []) {
|
|
138
183
|
const id = fact?.external?.[store.name];
|
|
139
184
|
if (!id)
|
|
140
185
|
continue;
|
|
141
|
-
|
|
142
|
-
|
|
186
|
+
const { outcome, error } = await removeEntry(store, entryOf(fact, id));
|
|
187
|
+
verification[store.name] = outcome;
|
|
188
|
+
if (error)
|
|
189
|
+
stillHeld.push(error);
|
|
190
|
+
else
|
|
143
191
|
removedFrom.push(store.name);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
192
|
+
}
|
|
193
|
+
return { removedFrom, stillHeld, verification };
|
|
194
|
+
}
|
|
195
|
+
async function forgetOne(factId, reason, who, keepDigest, compact = true) {
|
|
196
|
+
const fact = await ledger.get(factId);
|
|
197
|
+
const ev = await ledger.forget({ factId, actor: who.actor, reason, source: { receiptId: who.receiptId }, ...(keepDigest === undefined ? {} : { keepDigest }), compact });
|
|
198
|
+
const { removedFrom, stillHeld, verification } = await removeFromStores(fact);
|
|
199
|
+
return { factId: ev.factId, valueDigest: ev.valueDigest, digestKind: ev.digestKind, txTime: ev.txTime, actor: ev.actor, reason: ev.reason, source: ev.source, erasedFromLedger: true, removedFrom, stillHeld, verification };
|
|
200
|
+
}
|
|
201
|
+
/** The tail of the sweeps queued in this process. */
|
|
202
|
+
let repairTurn = Promise.resolve();
|
|
203
|
+
async function repairSweep(a, who) {
|
|
204
|
+
// `before` can only move the cutoff earlier: a later one would reach the entries of a write in progress.
|
|
205
|
+
const cutoff = Math.min(a.before ? Date.parse(a.before) : Infinity, Date.now() - REPAIR_MIN_AGE_MS);
|
|
206
|
+
const repaired = [];
|
|
207
|
+
const unrecorded = [];
|
|
208
|
+
const unlisted = [];
|
|
209
|
+
const stillHeld = [];
|
|
210
|
+
for (const store of opts.stores ?? []) {
|
|
211
|
+
if (!store.list) {
|
|
212
|
+
unlisted.push(store.name);
|
|
148
213
|
continue;
|
|
149
214
|
}
|
|
150
|
-
|
|
151
|
-
|
|
215
|
+
let entries;
|
|
216
|
+
try {
|
|
217
|
+
entries = await store.list();
|
|
218
|
+
}
|
|
219
|
+
catch (e) {
|
|
220
|
+
stillHeld.push(`${store.name}: cannot list: ${e instanceof Error ? e.message : String(e)}`);
|
|
152
221
|
continue;
|
|
153
222
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
223
|
+
const seen = new Set();
|
|
224
|
+
for (const entry of entries) {
|
|
225
|
+
if (seen.has(entry.externalId))
|
|
226
|
+
continue;
|
|
227
|
+
seen.add(entry.externalId);
|
|
228
|
+
// A young entry may be a write in progress. So is one whose time is missing or does not parse.
|
|
229
|
+
if (!(Date.parse(entry.storedAt ?? "") < cutoff))
|
|
230
|
+
continue;
|
|
231
|
+
// The ledger records the repair first, as a retraction does. A write that is still in progress then fails at
|
|
232
|
+
// its own append, and a write that has appended makes this refuse. Either way the first record wins.
|
|
233
|
+
let ev;
|
|
159
234
|
try {
|
|
160
|
-
|
|
235
|
+
if (await ledger.get(entry.factId))
|
|
236
|
+
continue;
|
|
237
|
+
ev = await ledger.repair({ factId: entry.factId, store: store.name, externalId: entry.externalId, actor: who.actor, reason: a.reason, source: { receiptId: who.receiptId } });
|
|
161
238
|
}
|
|
162
|
-
catch {
|
|
163
|
-
// The
|
|
164
|
-
|
|
165
|
-
|
|
239
|
+
catch (e) {
|
|
240
|
+
// The ledger now knows the fact: the write won, and its entry stays. Otherwise nothing was removed. A ledger
|
|
241
|
+
// that cannot answer does not stop the sweep: the entries that it already removed keep their outcomes.
|
|
242
|
+
if (!(await ledger.get(entry.factId).catch(() => undefined)))
|
|
243
|
+
unrecorded.push({ store: store.name, externalId: entry.externalId, factId: entry.factId, error: e instanceof Error ? e.message : String(e) });
|
|
244
|
+
continue;
|
|
166
245
|
}
|
|
246
|
+
let { outcome, error } = await removeEntry(store, entry);
|
|
247
|
+
// Another server may have removed the entry already, and the store may then fail the delete. When the listing of
|
|
248
|
+
// the store no longer holds the entry, the delete is done, and the usual check decides the outcome.
|
|
249
|
+
if (error && (await store.list().then((now) => !now.some((e) => e.externalId === entry.externalId), () => false)))
|
|
250
|
+
({ outcome, error } = { outcome: await verifyEntry(store, entry), error: undefined });
|
|
251
|
+
if (error)
|
|
252
|
+
stillHeld.push(error);
|
|
253
|
+
repaired.push({ store: store.name, externalId: entry.externalId, factId: entry.factId, outcome, eventId: ev.eventId });
|
|
167
254
|
}
|
|
168
|
-
verification[store.name] = !checked ? "unverified" : gone ? "verified" : "stillIndexed";
|
|
169
255
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const ev = await ledger.forget({ factId, actor: who.actor, reason, source: { receiptId: who.receiptId }, ...(keepDigest === undefined ? {} : { keepDigest }), compact });
|
|
175
|
-
const { removedFrom, stillHeld, verification } = await removeFromStores(fact);
|
|
176
|
-
return { factId: ev.factId, valueDigest: ev.valueDigest, digestKind: ev.digestKind, txTime: ev.txTime, actor: ev.actor, reason: ev.reason, source: ev.source, erasedFromLedger: true, removedFrom, stillHeld, verification };
|
|
256
|
+
const out = { before: new Date(cutoff).toISOString(), repaired, unlisted, stillHeld, unrecorded };
|
|
257
|
+
if (stillHeld.length > 0 || unrecorded.length > 0)
|
|
258
|
+
return { isError: true, content: [{ type: "text", text: `repair incomplete: ${[...stillHeld, ...unrecorded.map((u) => `${u.store} ${u.externalId}: not removed, because the ledger did not record the repair: ${u.error}`)].join("; ")}` }, { type: "text", text: JSON.stringify(out) }] };
|
|
259
|
+
return json(out);
|
|
177
260
|
}
|
|
178
261
|
async function handle(name, args, meta, receiptId) {
|
|
179
262
|
const gatewayAgent = typeof meta[AGENT_META_KEY] === "string" ? meta[AGENT_META_KEY] : null;
|
|
@@ -209,8 +292,12 @@ export function createMemoryServer(ledger, opts = {}) {
|
|
|
209
292
|
const external = {};
|
|
210
293
|
const factId = randomUUID();
|
|
211
294
|
const preview = { ...input, factId, validFrom: input.validFrom ?? new Date().toISOString(), validTo: null, confidence: input.confidence ?? null };
|
|
295
|
+
// A failed append leaves the stores holding a fact the ledger lacks; memory.repair finds and removes it.
|
|
296
|
+
const started = Date.now();
|
|
212
297
|
for (const store of opts.stores ?? [])
|
|
213
298
|
external[store.name] = await store.put(preview);
|
|
299
|
+
if (Date.now() - started > REPAIR_MIN_AGE_MS / 2)
|
|
300
|
+
return fail(`the stores took more than ${REPAIR_MIN_AGE_MS / 120_000} minutes; the write is refused, and memory.repair removes what the stores took`);
|
|
214
301
|
const ev = await ledger.assert({ ...input, factId, external });
|
|
215
302
|
return json({ fact: ev.fact, eventId: ev.eventId, txTime: ev.txTime, supersedes: ev.supersedes });
|
|
216
303
|
}
|
|
@@ -283,6 +370,13 @@ export function createMemoryServer(ledger, opts = {}) {
|
|
|
283
370
|
return { isError: true, content: [{ type: "text", text: `swept the ledger, but some values are still held by stores: ${stillHeld.join("; ")}` }, { type: "text", text: JSON.stringify(out) }] };
|
|
284
371
|
return json(out);
|
|
285
372
|
}
|
|
373
|
+
case "memory.repair": {
|
|
374
|
+
const a = Repair.parse(args);
|
|
375
|
+
// One sweep at a time in this process: a second sweep then lists after the first has removed its entries.
|
|
376
|
+
const turn = repairTurn.then(() => repairSweep(a, who));
|
|
377
|
+
repairTurn = turn.then(() => { }, () => { });
|
|
378
|
+
return await turn;
|
|
379
|
+
}
|
|
286
380
|
case "memory.get": {
|
|
287
381
|
const a = Get.parse(args);
|
|
288
382
|
const f = await ledger.get(a.factId);
|
package/dist/stores.d.ts
CHANGED
|
@@ -1,21 +1,39 @@
|
|
|
1
1
|
import type { Fact } from "./ledger.ts";
|
|
2
|
+
/** One entry a store holds for a fact: the store's id for it, the fact's id, and the text the store indexed. */
|
|
3
|
+
export interface StoreEntry {
|
|
4
|
+
externalId: string;
|
|
5
|
+
factId: string;
|
|
6
|
+
text: string;
|
|
7
|
+
/** when the store received the entry, from its custody metadata; repair removes only entries older than its cutoff. Absent on entries that version 0.7.0 or earlier wrote. */
|
|
8
|
+
storedAt?: string;
|
|
9
|
+
}
|
|
2
10
|
export interface Store {
|
|
3
11
|
/** the key under which the store's id is recorded on the fact */
|
|
4
12
|
readonly name: string;
|
|
5
13
|
/** writes the fact and returns the store's own id for it */
|
|
6
14
|
put(fact: Fact): Promise<string>;
|
|
7
|
-
/** removes the fact from the store; called on retraction and forget */
|
|
8
|
-
remove(externalId: string, fact: Fact): Promise<void>;
|
|
9
15
|
/**
|
|
10
|
-
*
|
|
16
|
+
* removes the entry from the store; called on retraction, forget, and repair. Named delete, not remove, so that a
|
|
17
|
+
* store written for the earlier remove(externalId, fact) is refused at startup instead of called with the wrong arguments.
|
|
18
|
+
*/
|
|
19
|
+
delete(entry: StoreEntry): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Checks the store's own search no longer surfaces the entry: a delete by id and a search index catching up are
|
|
11
22
|
* different moments. Optional; a store without it is reported as unverified, never as verified.
|
|
12
23
|
*/
|
|
13
|
-
|
|
24
|
+
verifyDeleted?(entry: StoreEntry): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Every entry the store holds that carries custody metadata. The repair sweep compares them with the ledger.
|
|
27
|
+
* Optional; the sweep reports a store without it as unlisted.
|
|
28
|
+
*/
|
|
29
|
+
list?(): Promise<StoreEntry[]>;
|
|
14
30
|
}
|
|
31
|
+
/** The entry a fact has in a store, from the id the ledger recorded for it there. */
|
|
32
|
+
export declare function entryOf(fact: Fact, externalId: string): StoreEntry;
|
|
15
33
|
/** What the server reports per store after a removal. */
|
|
16
34
|
export type RemovalOutcome = "verified" | "stillIndexed" | "unverified" | "failed";
|
|
17
35
|
/** One line a retrieval store can index: what the fact says, in words. */
|
|
18
|
-
export declare function factText(f: Fact): string;
|
|
36
|
+
export declare function factText(f: Pick<Fact, "subject" | "predicate" | "value">): string;
|
|
19
37
|
/** Metadata every store receives alongside the text, so a memory can always be traced back to its custody. */
|
|
20
38
|
export declare function factMetadata(f: Fact): Record<string, unknown>;
|
|
21
39
|
/** The subset of mem0ai's MemoryClient this adapter uses. */
|
|
@@ -33,6 +51,20 @@ export interface Mem0Like {
|
|
|
33
51
|
memory?: string;
|
|
34
52
|
}[];
|
|
35
53
|
}>;
|
|
54
|
+
/** pages are numbered from 1; `next` is null on the last page */
|
|
55
|
+
getAll?(options?: {
|
|
56
|
+
filters?: Record<string, unknown>;
|
|
57
|
+
page?: number;
|
|
58
|
+
pageSize?: number;
|
|
59
|
+
}): Promise<{
|
|
60
|
+
next?: string | null;
|
|
61
|
+
results: {
|
|
62
|
+
id?: string;
|
|
63
|
+
memory?: string;
|
|
64
|
+
metadata?: unknown;
|
|
65
|
+
createdAt?: string | Date;
|
|
66
|
+
}[];
|
|
67
|
+
}>;
|
|
36
68
|
}
|
|
37
69
|
export interface Mem0Options {
|
|
38
70
|
userId: string;
|
|
@@ -55,6 +87,41 @@ export interface ZepLike {
|
|
|
55
87
|
}>;
|
|
56
88
|
episode: {
|
|
57
89
|
delete(uuid: string): Promise<unknown>;
|
|
90
|
+
/** one page of at most 50 episodes; the next cursor is the Zep-Next-Cursor response header, absent on the last page */
|
|
91
|
+
listByUserId?(userId: string, request: {
|
|
92
|
+
cursor?: string;
|
|
93
|
+
limit?: number;
|
|
94
|
+
}): {
|
|
95
|
+
withRawResponse(): Promise<{
|
|
96
|
+
data: {
|
|
97
|
+
uuid: string;
|
|
98
|
+
content: string;
|
|
99
|
+
createdAt?: string;
|
|
100
|
+
}[];
|
|
101
|
+
rawResponse: {
|
|
102
|
+
headers: {
|
|
103
|
+
get(name: string): string | null;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
}>;
|
|
107
|
+
};
|
|
108
|
+
listByGraphId?(graphId: string, request: {
|
|
109
|
+
cursor?: string;
|
|
110
|
+
limit?: number;
|
|
111
|
+
}): {
|
|
112
|
+
withRawResponse(): Promise<{
|
|
113
|
+
data: {
|
|
114
|
+
uuid: string;
|
|
115
|
+
content: string;
|
|
116
|
+
createdAt?: string;
|
|
117
|
+
}[];
|
|
118
|
+
rawResponse: {
|
|
119
|
+
headers: {
|
|
120
|
+
get(name: string): string | null;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
}>;
|
|
124
|
+
};
|
|
58
125
|
};
|
|
59
126
|
search?(request: {
|
|
60
127
|
userId?: string;
|
|
@@ -95,7 +162,7 @@ export interface PgvectorOptions {
|
|
|
95
162
|
dimensions: number;
|
|
96
163
|
/** table name, optionally schema-qualified; default "agent_memories"; created if missing */
|
|
97
164
|
table?: string;
|
|
98
|
-
/** how many nearest rows
|
|
165
|
+
/** how many nearest rows verifyDeleted inspects for the removed id; default 10 */
|
|
99
166
|
topK?: number;
|
|
100
167
|
}
|
|
101
168
|
/**
|
|
@@ -127,13 +194,23 @@ export interface LettaLike {
|
|
|
127
194
|
content: string;
|
|
128
195
|
}[];
|
|
129
196
|
}>;
|
|
197
|
+
/** cursor pages: `after` is the id of the last passage of the previous page; oldest first by default */
|
|
198
|
+
list?(agentId: string, query?: {
|
|
199
|
+
after?: string | null;
|
|
200
|
+
limit?: number | null;
|
|
201
|
+
}): Promise<{
|
|
202
|
+
id?: string;
|
|
203
|
+
text: string;
|
|
204
|
+
tags?: string[] | null;
|
|
205
|
+
created_at?: string | null;
|
|
206
|
+
}[]>;
|
|
130
207
|
};
|
|
131
208
|
};
|
|
132
209
|
}
|
|
133
210
|
export interface LettaOptions {
|
|
134
211
|
/** the agent whose archival memory receives the fact */
|
|
135
212
|
agentId: string;
|
|
136
|
-
/** tags attached to every passage, beside the custody tags; default none */
|
|
213
|
+
/** tags attached to every passage, beside the custody tags; list() returns only passages whose tags, beside the custody tags, are exactly this set; default none */
|
|
137
214
|
tags?: string[];
|
|
138
215
|
}
|
|
139
216
|
/**
|
|
@@ -155,11 +232,13 @@ export interface LangGraphStoreLike {
|
|
|
155
232
|
search?(namespacePrefix: string[], options?: {
|
|
156
233
|
filter?: Record<string, unknown>;
|
|
157
234
|
limit?: number;
|
|
235
|
+
offset?: number;
|
|
158
236
|
query?: string;
|
|
159
237
|
}): Promise<{
|
|
160
238
|
key: string;
|
|
161
239
|
namespace: string[];
|
|
162
240
|
value: Record<string, unknown>;
|
|
241
|
+
createdAt?: Date | string;
|
|
163
242
|
}[]>;
|
|
164
243
|
}
|
|
165
244
|
export interface LangGraphStoreOptions {
|