@agent-custody/state 0.1.8 → 0.2.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/dist/stores.d.ts CHANGED
@@ -4,9 +4,16 @@ export interface Store {
4
4
  readonly name: string;
5
5
  /** writes the fact and returns the store's own id for it */
6
6
  put(fact: Fact): Promise<string>;
7
- /** removes the fact from the store; called on retraction */
7
+ /** removes the fact from the store; called on retraction and forget */
8
8
  remove(externalId: string, fact: Fact): Promise<void>;
9
+ /**
10
+ * Checks the store's own search no longer surfaces the fact: a delete by id and a search index catching up are
11
+ * different moments. Optional; a store without it is reported as unverified, never as verified.
12
+ */
13
+ verifyRemoved?(externalId: string, fact: Fact): Promise<boolean>;
9
14
  }
15
+ /** What the server reports per store after a removal. */
16
+ export type RemovalOutcome = "verified" | "stillIndexed" | "unverified" | "failed";
10
17
  /** One line a retrieval store can index: what the fact says, in words. */
11
18
  export declare function factText(f: Fact): string;
12
19
  /** Metadata every store receives alongside the text, so a memory can always be traced back to its custody. */
@@ -20,6 +27,12 @@ export interface Mem0Like {
20
27
  id?: string;
21
28
  }[]>;
22
29
  delete(memoryId: string): Promise<unknown>;
30
+ search?(query: string, options?: Record<string, unknown>): Promise<{
31
+ results: {
32
+ id?: string;
33
+ memory?: string;
34
+ }[];
35
+ }>;
23
36
  }
24
37
  export interface Mem0Options {
25
38
  userId: string;
@@ -43,6 +56,22 @@ export interface ZepLike {
43
56
  episode: {
44
57
  delete(uuid: string): Promise<unknown>;
45
58
  };
59
+ search?(request: {
60
+ userId?: string;
61
+ graphId?: string;
62
+ query: string;
63
+ limit?: number;
64
+ }): Promise<{
65
+ edges?: {
66
+ uuid: string;
67
+ fact: string;
68
+ episodes?: string[];
69
+ }[];
70
+ episodes?: {
71
+ uuid: string;
72
+ content: string;
73
+ }[];
74
+ }>;
46
75
  };
47
76
  }
48
77
  export type ZepOptions = {
package/dist/stores.js CHANGED
@@ -19,6 +19,15 @@ export function mem0Store(client, opts) {
19
19
  async remove(externalId) {
20
20
  await client.delete(externalId);
21
21
  },
22
+ ...(client.search
23
+ ? {
24
+ async verifyRemoved(externalId, fact) {
25
+ // Mem0's search scopes by filters, not by top-level entity parameters; the real client refuses the latter.
26
+ const { results } = await client.search(factText(fact), { filters: { user_id: opts.userId } });
27
+ return !results.some((r) => r.id === externalId || r.memory === factText(fact));
28
+ },
29
+ }
30
+ : {}),
22
31
  };
23
32
  }
24
33
  export function zepStore(client, opts) {
@@ -34,5 +43,16 @@ export function zepStore(client, opts) {
34
43
  async remove(externalId) {
35
44
  await client.graph.episode.delete(externalId);
36
45
  },
46
+ ...(client.graph.search
47
+ ? {
48
+ async verifyRemoved(externalId, fact) {
49
+ const target = opts.graphId ? { graphId: opts.graphId } : { userId: opts.userId };
50
+ const r = await client.graph.search({ ...target, query: factText(fact), limit: 20 });
51
+ const episodeHit = (r.episodes ?? []).some((e) => e.uuid === externalId);
52
+ const edgeHit = (r.edges ?? []).some((e) => (e.episodes ?? []).includes(externalId));
53
+ return !episodeHit && !edgeHit;
54
+ },
55
+ }
56
+ : {}),
37
57
  };
38
58
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agent-custody/state",
3
- "version": "0.1.8",
4
- "description": "Governed memory for AI agents: a fact ledger with provenance, valid time, rollback, and lineage, built on @agent-custody/receipts",
3
+ "version": "0.2.0",
4
+ "description": "Governed memory for AI agents: a fact ledger with provenance, valid time, rollback, lineage, certified forget, and a store that is a JSONL file, SQLite, or Postgres, built on @agent-custody/receipts",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -33,15 +33,24 @@
33
33
  "node": ">=22"
34
34
  },
35
35
  "dependencies": {
36
- "@agent-custody/receipts": "0.1.8",
36
+ "@agent-custody/receipts": "0.2.0",
37
37
  "@modelcontextprotocol/sdk": "^1.30.0",
38
38
  "zod": "^4.5.4"
39
39
  },
40
40
  "devDependencies": {
41
+ "@electric-sql/pglite": "0.5.8",
42
+ "@getzep/zep-cloud": "^3.28.0",
41
43
  "@types/node": "^26.4.1",
42
- "typescript": "^7.0.2",
43
- "vitest": "^5.0.0",
44
44
  "mem0ai": "^3.1.8",
45
- "@getzep/zep-cloud": "^3.28.0"
45
+ "typescript": "^7.0.2",
46
+ "vitest": "^5.0.0"
47
+ },
48
+ "peerDependencies": {
49
+ "pg": ">=8"
50
+ },
51
+ "peerDependenciesMeta": {
52
+ "pg": {
53
+ "optional": true
54
+ }
46
55
  }
47
56
  }