mnemocyte 0.0.8 → 0.1.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 +109 -1
- package/dist/index.d.mts +263 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +492 -60
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -52,6 +52,12 @@ explain: true,
|
|
|
52
52
|
await client.close();
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
See also: [Provider resilience](#provider-resilience),
|
|
56
|
+
[Pruning memories](#pruning-memories),
|
|
57
|
+
[Finding duplicates](#finding-duplicates-experimental),
|
|
58
|
+
[Audit log](#audit-log-experimental), and
|
|
59
|
+
[Consolidating duplicates](#consolidating-duplicates-experimental).
|
|
60
|
+
|
|
55
61
|
## Postgres usage
|
|
56
62
|
|
|
57
63
|
Run the included migration against a Postgres database with pgvector enabled, then pass `databaseUrl`:
|
|
@@ -59,12 +65,18 @@ Run the included migration against a Postgres database with pgvector enabled, th
|
|
|
59
65
|
```ts
|
|
60
66
|
const client = createMnemocyte({
|
|
61
67
|
databaseUrl: process.env.DATABASE_URL,
|
|
62
|
-
embedder,
|
|
68
|
+
embedder, // embedder.dimensions MUST be 1536 — see below
|
|
63
69
|
});
|
|
64
70
|
```
|
|
65
71
|
|
|
66
72
|
The published package includes `migrations/0000_initial.sql`.
|
|
67
73
|
|
|
74
|
+
> **Embedding dimensionality is pinned to 1536 on the Postgres backend.**
|
|
75
|
+
> The bundled migration creates `embedding vector(1536)`. If
|
|
76
|
+
> `embedder.dimensions` is anything else, `createMnemocyte` throws a
|
|
77
|
+
> `MnemocyteError` with code `"CONFIG"` *before* opening the connection
|
|
78
|
+
> pool. The in-memory backend has no such constraint.
|
|
79
|
+
|
|
68
80
|
## Provider resilience
|
|
69
81
|
|
|
70
82
|
Mnemocyte applies an optional timeout and retry policy to every outbound
|
|
@@ -127,6 +139,102 @@ console.log(preview.matchedCount);
|
|
|
127
139
|
Available selectors: `entityId`, `expired`, `superseded`, `createdBefore`,
|
|
128
140
|
`notAccessedSince`, `types`, `tags`, `maxImportance`. They AND together.
|
|
129
141
|
|
|
142
|
+
## Finding duplicates (experimental)
|
|
143
|
+
|
|
144
|
+
`findDuplicates` is a **read-only** scan that surfaces near-identical
|
|
145
|
+
memories for one entity using pairwise cosine similarity. It is
|
|
146
|
+
intentionally passive — nothing is deleted or modified — so callers can
|
|
147
|
+
decide their own consolidation policy.
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
const pairs = await client.findDuplicates({
|
|
151
|
+
entityId: "user_123",
|
|
152
|
+
threshold: 0.95, // default 0.95
|
|
153
|
+
limit: 50, // default 100, ordered by similarity desc
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
for (const { a, b, similarity } of pairs) {
|
|
157
|
+
console.log(similarity.toFixed(3), a.content, "<>", b.content);
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Optional selectors: `types`, `tags` (both required on each pair member),
|
|
162
|
+
`includeSuperseded`, `includeExpired`. Superseded and expired memories
|
|
163
|
+
are excluded by default.
|
|
164
|
+
|
|
165
|
+
> Part of Phase 6 (consolidation tooling). The API surface may change in
|
|
166
|
+
> follow-up releases as conflict detection and active dedup land.
|
|
167
|
+
|
|
168
|
+
## Audit log (experimental)
|
|
169
|
+
|
|
170
|
+
When `audit.enabled` is `true`, Mnemocyte records an entry on every
|
|
171
|
+
state-changing operation (`remember`, `forget`, `forgetAll`, `prune`).
|
|
172
|
+
Read with `client.listAuditLog()`.
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
const client = createMnemocyte({
|
|
176
|
+
embedder,
|
|
177
|
+
audit: { enabled: true },
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
await client.remember({ entityId: "user_123", content: "Likes tea." });
|
|
181
|
+
await client.prune({ entityId: "user_123", expired: true });
|
|
182
|
+
|
|
183
|
+
const log = await client.listAuditLog({
|
|
184
|
+
entityId: "user_123",
|
|
185
|
+
limit: 100,
|
|
186
|
+
});
|
|
187
|
+
for (const event of log) {
|
|
188
|
+
console.log(event.timestamp, event.description, event.metadata);
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Recorded `description` slugs:
|
|
193
|
+
|
|
194
|
+
- `"memory.created"` — single insert; metadata: `{ memoryId, type, importance }`
|
|
195
|
+
- `"memory.deleted"` — single `forget`; metadata: `{ memoryId }`
|
|
196
|
+
- `"entity.cleared"` — `forgetAll`; metadata: `{ count }`
|
|
197
|
+
- `"memory.pruned"` — real (non-dryRun) `prune` with an `entityId` selector; metadata: `{ count }`
|
|
198
|
+
|
|
199
|
+
Audit entries are **sticky**: `forgetAll` no longer erases prior log
|
|
200
|
+
entries — wiping an entity is itself a recorded `"entity.cleared"`
|
|
201
|
+
event. Disable audit by leaving `audit.enabled` unset (the default);
|
|
202
|
+
historical entries remain readable.
|
|
203
|
+
|
|
204
|
+
> Part of Phase 6 (consolidation tooling). The API surface may change
|
|
205
|
+
> as conflict detection and consolidation land.
|
|
206
|
+
|
|
207
|
+
## Consolidating duplicates (experimental)
|
|
208
|
+
|
|
209
|
+
`client.experimental.consolidate()` merges likely-duplicate memories
|
|
210
|
+
into a single survivor. Each loser is marked `supersededBy = survivor.id`
|
|
211
|
+
and excluded from `recall` by default. Tags are unioned onto the
|
|
212
|
+
survivor unless `mergeTags: false`. Idempotent — already-superseded
|
|
213
|
+
memories are skipped.
|
|
214
|
+
|
|
215
|
+
Pair it with `findDuplicates` to build a complete dedup pipeline:
|
|
216
|
+
|
|
217
|
+
```ts
|
|
218
|
+
const pairs = await client.findDuplicates({
|
|
219
|
+
entityId: "user_123",
|
|
220
|
+
threshold: 0.97,
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
for (const { a, b } of pairs) {
|
|
224
|
+
await client.experimental.consolidate({
|
|
225
|
+
entityId: "user_123",
|
|
226
|
+
survivorId: a.id,
|
|
227
|
+
supersededIds: [b.id],
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
When `audit.enabled` is `true`, each newly superseded memory writes a
|
|
233
|
+
`"memory.superseded"` audit event with metadata `{ memoryId, supersededBy }`.
|
|
234
|
+
|
|
235
|
+
> The `experimental` namespace is intentionally unstable. Members may
|
|
236
|
+
> change or move to the main client surface in future releases.
|
|
237
|
+
|
|
130
238
|
## Retrieval tuning
|
|
131
239
|
|
|
132
240
|
```ts
|
package/dist/index.d.mts
CHANGED
|
@@ -40,7 +40,7 @@ type MnemocyteBackend = "in-memory" | "postgres";
|
|
|
40
40
|
* The set of public {@link MnemocyteClient} methods that emit
|
|
41
41
|
* {@link MnemocyteObservation} events through {@link ObservabilityConfig.onEvent}.
|
|
42
42
|
*/
|
|
43
|
-
type MnemocyteOperation = "remember" | "rememberMany" | "recall" | "buildContext" | "forget" | "forgetAll" | "prune" | "stats" | "close";
|
|
43
|
+
type MnemocyteOperation = "remember" | "rememberMany" | "recall" | "buildContext" | "forget" | "forgetAll" | "prune" | "findDuplicates" | "listAuditLog" | "consolidate" | "stats" | "close";
|
|
44
44
|
/**
|
|
45
45
|
* Lifecycle phase of a {@link MnemocyteObservation}.
|
|
46
46
|
*
|
|
@@ -149,6 +149,30 @@ interface MnemocyteConfig {
|
|
|
149
149
|
* {@link ProviderResilienceConfig}.
|
|
150
150
|
*/
|
|
151
151
|
provider?: ProviderResilienceConfig;
|
|
152
|
+
/**
|
|
153
|
+
* Audit-log configuration. When enabled, Mnemocyte records an
|
|
154
|
+
* {@link AuditEvent} for every state-changing operation
|
|
155
|
+
* (`remember`, `forget`, `forgetAll`, `prune`). Read with
|
|
156
|
+
* {@link MnemocyteClient.listAuditLog}.
|
|
157
|
+
*
|
|
158
|
+
* @experimental Part of Phase 6 (consolidation tooling).
|
|
159
|
+
*/
|
|
160
|
+
audit?: AuditConfig;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Audit-log configuration. See {@link MnemocyteConfig.audit}.
|
|
164
|
+
*
|
|
165
|
+
* @experimental Part of Phase 6 (consolidation tooling).
|
|
166
|
+
*/
|
|
167
|
+
interface AuditConfig {
|
|
168
|
+
/**
|
|
169
|
+
* Master switch for audit logging. When `false` (default), Mnemocyte
|
|
170
|
+
* neither writes nor relies on the audit log; existing log entries
|
|
171
|
+
* remain readable via {@link MnemocyteClient.listAuditLog}.
|
|
172
|
+
*
|
|
173
|
+
* @defaultValue `false`
|
|
174
|
+
*/
|
|
175
|
+
enabled?: boolean;
|
|
152
176
|
}
|
|
153
177
|
/**
|
|
154
178
|
* Pluggable embedding provider. Wraps an external embedding API
|
|
@@ -184,7 +208,7 @@ interface Embedder {
|
|
|
184
208
|
* new memory and link the previous one via {@link Memory.supersededBy}.
|
|
185
209
|
*/
|
|
186
210
|
interface Memory {
|
|
187
|
-
/** Unique identifier (
|
|
211
|
+
/** Unique identifier (`mem_*` prefixed string). */
|
|
188
212
|
id: string;
|
|
189
213
|
/** Owning entity — typically a user, agent, or session ID. */
|
|
190
214
|
entityId: string;
|
|
@@ -208,6 +232,13 @@ interface Memory {
|
|
|
208
232
|
embeddingDimensions: number;
|
|
209
233
|
/** ID of the memory that supersedes this one, or `null` if active. */
|
|
210
234
|
supersededBy: string | null;
|
|
235
|
+
/**
|
|
236
|
+
* Wall-clock time when this memory was superseded, or `null` if it
|
|
237
|
+
* has not been superseded. Set together with
|
|
238
|
+
* {@link Memory.supersededBy} by
|
|
239
|
+
* {@link ExperimentalMnemocyteClient.consolidate}.
|
|
240
|
+
*/
|
|
241
|
+
supersededAt: Date | null;
|
|
211
242
|
/** Optional expiry; expired memories are filtered out by default. */
|
|
212
243
|
expiresAt: Date | null;
|
|
213
244
|
/** Last time this memory was returned by {@link MnemocyteClient.recall}. */
|
|
@@ -476,6 +507,142 @@ interface PruneResult {
|
|
|
476
507
|
/** `true` when {@link PruneInput.dryRun} was set. */
|
|
477
508
|
dryRun: boolean;
|
|
478
509
|
}
|
|
510
|
+
/**
|
|
511
|
+
* Input for {@link MnemocyteClient.findDuplicates}.
|
|
512
|
+
*
|
|
513
|
+
* Performs a pairwise cosine-similarity scan of stored memories for a
|
|
514
|
+
* single entity and returns pairs whose similarity meets
|
|
515
|
+
* {@link FindDuplicatesInput.threshold}. The scan is read-only — no
|
|
516
|
+
* memories are modified or deleted.
|
|
517
|
+
*
|
|
518
|
+
* @experimental Part of Phase 6 (consolidation tooling). API may change.
|
|
519
|
+
*/
|
|
520
|
+
interface FindDuplicatesInput {
|
|
521
|
+
/** Entity whose memories should be scanned for duplicates. */
|
|
522
|
+
entityId: string;
|
|
523
|
+
/**
|
|
524
|
+
* Cosine-similarity cutoff in `[0, 1]`. Pairs whose similarity is at
|
|
525
|
+
* or above this value are returned. @defaultValue `0.95`
|
|
526
|
+
*/
|
|
527
|
+
threshold?: number;
|
|
528
|
+
/**
|
|
529
|
+
* Maximum number of duplicate pairs to return, ordered by descending
|
|
530
|
+
* similarity. @defaultValue `100`
|
|
531
|
+
*/
|
|
532
|
+
limit?: number;
|
|
533
|
+
/** Restrict the scan to these memory types. */
|
|
534
|
+
types?: readonly MemoryType[];
|
|
535
|
+
/** Require both memories in the pair to include all of these tags. */
|
|
536
|
+
tags?: readonly string[];
|
|
537
|
+
/** Include superseded memories in the scan. @defaultValue `false` */
|
|
538
|
+
includeSuperseded?: boolean;
|
|
539
|
+
/** Include expired memories in the scan. @defaultValue `false` */
|
|
540
|
+
includeExpired?: boolean;
|
|
541
|
+
/** Optional cancellation signal. */
|
|
542
|
+
signal?: AbortSignal;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* A pair of memories that are likely duplicates.
|
|
546
|
+
*
|
|
547
|
+
* The pair is unordered (i.e. `{a, b}` is the same logical result as
|
|
548
|
+
* `{b, a}`); Mnemocyte returns each pair only once.
|
|
549
|
+
*
|
|
550
|
+
* @experimental Part of Phase 6 (consolidation tooling). Shape may change.
|
|
551
|
+
*/
|
|
552
|
+
interface DuplicatePair {
|
|
553
|
+
/** One of the two memories in the duplicate pair. */
|
|
554
|
+
a: Memory;
|
|
555
|
+
/** The other memory in the duplicate pair. */
|
|
556
|
+
b: Memory;
|
|
557
|
+
/** Cosine similarity between the two embeddings, in `[0, 1]`. */
|
|
558
|
+
similarity: number;
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* A single audit-log entry recording a state-changing operation.
|
|
562
|
+
*
|
|
563
|
+
* @experimental Part of Phase 6 (consolidation tooling).
|
|
564
|
+
*/
|
|
565
|
+
interface AuditEvent {
|
|
566
|
+
/** Unique identifier (`evt_*` prefixed string). */
|
|
567
|
+
id: string;
|
|
568
|
+
/** Entity whose state was changed. */
|
|
569
|
+
entityId: string;
|
|
570
|
+
/**
|
|
571
|
+
* Stable, dotted slug describing the change. Examples:
|
|
572
|
+
* `"memory.created"`, `"memory.deleted"`, `"memory.pruned"`,
|
|
573
|
+
* `"entity.cleared"`.
|
|
574
|
+
*/
|
|
575
|
+
description: string;
|
|
576
|
+
/** Free-form structured details about the change. */
|
|
577
|
+
metadata: Record<string, unknown>;
|
|
578
|
+
/** When the change was recorded. */
|
|
579
|
+
timestamp: Date;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Input for {@link MnemocyteClient.listAuditLog}.
|
|
583
|
+
*
|
|
584
|
+
* @experimental Part of Phase 6 (consolidation tooling).
|
|
585
|
+
*/
|
|
586
|
+
interface ListAuditLogInput {
|
|
587
|
+
/** Entity whose audit log should be returned. */
|
|
588
|
+
entityId: string;
|
|
589
|
+
/**
|
|
590
|
+
* Maximum number of entries to return, ordered newest first.
|
|
591
|
+
* @defaultValue `50`
|
|
592
|
+
*/
|
|
593
|
+
limit?: number;
|
|
594
|
+
/** Only return entries strictly before this timestamp. */
|
|
595
|
+
before?: Date;
|
|
596
|
+
/** Only return entries strictly after this timestamp. */
|
|
597
|
+
after?: Date;
|
|
598
|
+
/** Optional cancellation signal. */
|
|
599
|
+
signal?: AbortSignal;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Input for {@link ExperimentalMnemocyteClient.consolidate}.
|
|
603
|
+
*
|
|
604
|
+
* Marks each memory in {@link ConsolidateInput.supersededIds} as
|
|
605
|
+
* superseded by {@link ConsolidateInput.survivorId}. Optionally
|
|
606
|
+
* unions the losers' tags into the survivor.
|
|
607
|
+
*
|
|
608
|
+
* @experimental Part of Phase 6 (consolidation tooling).
|
|
609
|
+
*/
|
|
610
|
+
interface ConsolidateInput {
|
|
611
|
+
/** Entity that owns every memory referenced. */
|
|
612
|
+
entityId: string;
|
|
613
|
+
/** Memory that should win the merge. Must not itself be superseded. */
|
|
614
|
+
survivorId: string;
|
|
615
|
+
/**
|
|
616
|
+
* Memories to mark as superseded by the survivor. Already-superseded
|
|
617
|
+
* entries in this list are skipped silently for idempotency. Must
|
|
618
|
+
* not contain {@link ConsolidateInput.survivorId}.
|
|
619
|
+
*/
|
|
620
|
+
supersededIds: readonly string[];
|
|
621
|
+
/**
|
|
622
|
+
* When `true`, the survivor's `tags` becomes the union of its own
|
|
623
|
+
* tags and the tags of every memory that was actually superseded.
|
|
624
|
+
* @defaultValue `true`
|
|
625
|
+
*/
|
|
626
|
+
mergeTags?: boolean;
|
|
627
|
+
/** Optional cancellation signal. */
|
|
628
|
+
signal?: AbortSignal;
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Result returned by {@link ExperimentalMnemocyteClient.consolidate}.
|
|
632
|
+
*
|
|
633
|
+
* @experimental Part of Phase 6 (consolidation tooling).
|
|
634
|
+
*/
|
|
635
|
+
interface ConsolidateResult {
|
|
636
|
+
/** Echoes {@link ConsolidateInput.survivorId}. */
|
|
637
|
+
survivorId: string;
|
|
638
|
+
/**
|
|
639
|
+
* Number of memories actually marked as superseded. Excludes entries
|
|
640
|
+
* that were already superseded (idempotent skip).
|
|
641
|
+
*/
|
|
642
|
+
supersededCount: number;
|
|
643
|
+
/** The IDs that were newly superseded during this call. */
|
|
644
|
+
supersededIds: readonly string[];
|
|
645
|
+
}
|
|
479
646
|
/**
|
|
480
647
|
* Stats for a single entity, returned by
|
|
481
648
|
* {@link MnemocyteClient.stats} when an `entityId` is provided.
|
|
@@ -572,6 +739,55 @@ interface MnemocyteClient {
|
|
|
572
739
|
* ```
|
|
573
740
|
*/
|
|
574
741
|
prune(input: PruneInput): Promise<PruneResult>;
|
|
742
|
+
/**
|
|
743
|
+
* Scan an entity's memories for likely duplicates by pairwise cosine
|
|
744
|
+
* similarity and return matching pairs, ordered by descending
|
|
745
|
+
* similarity. Read-only — no memories are modified.
|
|
746
|
+
*
|
|
747
|
+
* @experimental Part of Phase 6 (consolidation tooling). API may change.
|
|
748
|
+
*
|
|
749
|
+
* @example
|
|
750
|
+
* ```ts
|
|
751
|
+
* const pairs = await client.findDuplicates({
|
|
752
|
+
* entityId: "user_123",
|
|
753
|
+
* threshold: 0.95,
|
|
754
|
+
* limit: 50,
|
|
755
|
+
* });
|
|
756
|
+
* for (const { a, b, similarity } of pairs) {
|
|
757
|
+
* console.log(similarity, a.content, "<>", b.content);
|
|
758
|
+
* }
|
|
759
|
+
* ```
|
|
760
|
+
*/
|
|
761
|
+
findDuplicates(input: FindDuplicatesInput): Promise<DuplicatePair[]>;
|
|
762
|
+
/**
|
|
763
|
+
* Return audit-log entries for `entityId`, newest first.
|
|
764
|
+
*
|
|
765
|
+
* Entries are recorded automatically when
|
|
766
|
+
* {@link MnemocyteConfig.audit}.`enabled` is `true`. Historic entries
|
|
767
|
+
* remain readable even after toggling `enabled` back to `false`.
|
|
768
|
+
*
|
|
769
|
+
* @experimental Part of Phase 6 (consolidation tooling). API may change.
|
|
770
|
+
*
|
|
771
|
+
* @example
|
|
772
|
+
* ```ts
|
|
773
|
+
* const log = await client.listAuditLog({
|
|
774
|
+
* entityId: "user_123",
|
|
775
|
+
* limit: 100,
|
|
776
|
+
* });
|
|
777
|
+
* for (const event of log) {
|
|
778
|
+
* console.log(event.timestamp, event.description, event.metadata);
|
|
779
|
+
* }
|
|
780
|
+
* ```
|
|
781
|
+
*/
|
|
782
|
+
listAuditLog(input: ListAuditLogInput): Promise<AuditEvent[]>;
|
|
783
|
+
/**
|
|
784
|
+
* Unstable, opt-in extension surface. Members may change or be
|
|
785
|
+
* removed without a semver bump until they graduate to the main
|
|
786
|
+
* client interface.
|
|
787
|
+
*
|
|
788
|
+
* @experimental Part of Phase 6 (consolidation tooling).
|
|
789
|
+
*/
|
|
790
|
+
experimental: ExperimentalMnemocyteClient;
|
|
575
791
|
/**
|
|
576
792
|
* Return statistics. With an `entityId`, returns {@link EntityStats};
|
|
577
793
|
* without one, returns {@link GlobalStats}.
|
|
@@ -585,6 +801,45 @@ interface MnemocyteClient {
|
|
|
585
801
|
*/
|
|
586
802
|
close(): Promise<void>;
|
|
587
803
|
}
|
|
804
|
+
/**
|
|
805
|
+
* Extension surface for unstable Phase 6 operations. Reached via
|
|
806
|
+
* {@link MnemocyteClient.experimental}.
|
|
807
|
+
*
|
|
808
|
+
* @experimental Members may change or be removed without a semver bump.
|
|
809
|
+
*/
|
|
810
|
+
interface ExperimentalMnemocyteClient {
|
|
811
|
+
/**
|
|
812
|
+
* Consolidate likely-duplicate memories into a single survivor by
|
|
813
|
+
* marking the others as superseded. Optionally unions their tags
|
|
814
|
+
* onto the survivor. Idempotent for memories that are already
|
|
815
|
+
* superseded.
|
|
816
|
+
*
|
|
817
|
+
* Emits one `"memory.superseded"` audit event per newly superseded
|
|
818
|
+
* memory when {@link MnemocyteConfig.audit}.`enabled` is `true`.
|
|
819
|
+
*
|
|
820
|
+
* @experimental Part of Phase 6 (consolidation tooling). API may change.
|
|
821
|
+
*
|
|
822
|
+
* @throws {MnemocyteError} `"VALIDATION"` for empty `supersededIds`,
|
|
823
|
+
* a `survivorId` that also appears in `supersededIds`, or a survivor
|
|
824
|
+
* that is itself already superseded.
|
|
825
|
+
* @throws {MnemocyteError} `"NOT_FOUND"` if the survivor or any
|
|
826
|
+
* non-already-superseded memory in `supersededIds` does not belong
|
|
827
|
+
* to `entityId`.
|
|
828
|
+
*
|
|
829
|
+
* @example
|
|
830
|
+
* ```ts
|
|
831
|
+
* const pairs = await client.findDuplicates({ entityId: "user_123" });
|
|
832
|
+
* for (const { a, b } of pairs) {
|
|
833
|
+
* await client.experimental.consolidate({
|
|
834
|
+
* entityId: "user_123",
|
|
835
|
+
* survivorId: a.id,
|
|
836
|
+
* supersededIds: [b.id],
|
|
837
|
+
* });
|
|
838
|
+
* }
|
|
839
|
+
* ```
|
|
840
|
+
*/
|
|
841
|
+
consolidate(input: ConsolidateInput): Promise<ConsolidateResult>;
|
|
842
|
+
}
|
|
588
843
|
//#endregion
|
|
589
844
|
//#region src/client.d.ts
|
|
590
845
|
/**
|
|
@@ -601,14 +856,16 @@ interface MnemocyteClient {
|
|
|
601
856
|
*
|
|
602
857
|
* @param config - Client configuration. {@link MnemocyteConfig.embedder} is required.
|
|
603
858
|
* @returns A {@link MnemocyteClient} instance.
|
|
604
|
-
* @throws {MnemocyteError} With code `"CONFIG"` if `embedder` is missing or
|
|
605
|
-
*
|
|
859
|
+
* @throws {MnemocyteError} With code `"CONFIG"` if `embedder` is missing or
|
|
860
|
+
* invalid (including when `databaseUrl` is set and `embedder.dimensions`
|
|
861
|
+
* is not 1536 — the dimensionality pinned by the bundled migration), or
|
|
862
|
+
* `"VALIDATION"` if `databaseUrl` is provided but empty.
|
|
606
863
|
*
|
|
607
864
|
* @example Postgres-backed client
|
|
608
865
|
* ```ts
|
|
609
866
|
* const client = createMnemocyte({
|
|
610
867
|
* databaseUrl: process.env.DATABASE_URL,
|
|
611
|
-
* embedder,
|
|
868
|
+
* embedder, // embedder.dimensions MUST be 1536 for the Postgres backend
|
|
612
869
|
* });
|
|
613
870
|
* ```
|
|
614
871
|
*/
|
|
@@ -670,5 +927,5 @@ declare class MnemocyteError extends Error {
|
|
|
670
927
|
*/
|
|
671
928
|
declare function isMnemocyteError(error: unknown): error is MnemocyteError;
|
|
672
929
|
//#endregion
|
|
673
|
-
export { type BuildContextInput, type ContextFormat, type Embedder, type EntityStats, type GlobalStats, type ImportanceLevel, type Memory, type MemoryType, type MemoryWithScore, type MnemocyteBackend, type MnemocyteClient, type MnemocyteConfig, MnemocyteError, type MnemocyteErrorCode, type MnemocyteObservation, type MnemocyteObservationPhase, type MnemocyteOperation, type ObservabilityConfig, type ProviderResilienceConfig, type PruneInput, type PruneResult, type RecallInput, type RememberInput, type RetrievalConfig, type RetrievalExplanation, type RetrievalScoreWeights, type RetrievalScores, type TokenCounter, createMnemocyte, isMnemocyteError };
|
|
930
|
+
export { type AuditConfig, type AuditEvent, type BuildContextInput, type ConsolidateInput, type ConsolidateResult, type ContextFormat, type DuplicatePair, type Embedder, type EntityStats, type ExperimentalMnemocyteClient, type FindDuplicatesInput, type GlobalStats, type ImportanceLevel, type ListAuditLogInput, type Memory, type MemoryType, type MemoryWithScore, type MnemocyteBackend, type MnemocyteClient, type MnemocyteConfig, MnemocyteError, type MnemocyteErrorCode, type MnemocyteObservation, type MnemocyteObservationPhase, type MnemocyteOperation, type ObservabilityConfig, type ProviderResilienceConfig, type PruneInput, type PruneResult, type RecallInput, type RememberInput, type RetrievalConfig, type RetrievalExplanation, type RetrievalScoreWeights, type RetrievalScores, type TokenCounter, createMnemocyte, isMnemocyteError };
|
|
674
931
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/client.ts","../src/errors.ts"],"mappings":";;AAYA;;;;;AAcA;;;;;AAWA;KAzBY,UAAA;;;;AAiCZ;;;KAnBY,eAAA;;AAyBZ;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/client.ts","../src/errors.ts"],"mappings":";;AAYA;;;;;AAcA;;;;;AAWA;KAzBY,UAAA;;;;AAiCZ;;;KAnBY,eAAA;;AAyBZ;;;;;AAoBA;;;KAlCY,a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