mnemocyte 0.0.6 → 0.0.8
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 +63 -1
- package/dist/index.d.mts +518 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +621 -165
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -15
package/README.md
CHANGED
|
@@ -65,6 +65,68 @@ embedder,
|
|
|
65
65
|
|
|
66
66
|
The published package includes `migrations/0000_initial.sql`.
|
|
67
67
|
|
|
68
|
+
## Provider resilience
|
|
69
|
+
|
|
70
|
+
Mnemocyte applies an optional timeout and retry policy to every outbound
|
|
71
|
+
embedder call, and forwards `AbortSignal` cancellation to in-flight
|
|
72
|
+
attempts. Defaults disable both retries and timeouts so existing setups
|
|
73
|
+
are unaffected.
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
const client = createMnemocyte({
|
|
77
|
+
embedder,
|
|
78
|
+
provider: {
|
|
79
|
+
timeoutMs: 5_000,
|
|
80
|
+
retries: 2,
|
|
81
|
+
baseDelayMs: 200,
|
|
82
|
+
maxDelayMs: 2_000,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const controller = new AbortController();
|
|
87
|
+
setTimeout(() => controller.abort(), 1_000);
|
|
88
|
+
|
|
89
|
+
await client.remember({
|
|
90
|
+
entityId: "user_123",
|
|
91
|
+
content: "Prefers short answers.",
|
|
92
|
+
signal: controller.signal,
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Failures surface as `MnemocyteError` with stable `code`s:
|
|
97
|
+
|
|
98
|
+
- `"TIMEOUT"` — a single provider attempt exceeded `timeoutMs`.
|
|
99
|
+
- `"ABORTED"` — the operation was cancelled via `signal` (never retried).
|
|
100
|
+
- `"EMBEDDING"` — the embedder failed after all retries are exhausted.
|
|
101
|
+
|
|
102
|
+
## Pruning memories
|
|
103
|
+
|
|
104
|
+
`prune` bulk-deletes memories matching a filter. At least one selector
|
|
105
|
+
is required; `prune({})` is rejected to avoid accidental full deletion.
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
// Drop expired memories for one entity.
|
|
109
|
+
await client.prune({ entityId: "user_123", expired: true });
|
|
110
|
+
|
|
111
|
+
// Evict memories not accessed in the last 30 days, but never drop
|
|
112
|
+
// "high" or "critical" memories.
|
|
113
|
+
await client.prune({
|
|
114
|
+
notAccessedSince: new Date(Date.now() - 30 * 24 * 3600 * 1000),
|
|
115
|
+
maxImportance: "normal",
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Count what would be deleted without touching the store.
|
|
119
|
+
const preview = await client.prune({
|
|
120
|
+
entityId: "user_123",
|
|
121
|
+
superseded: true,
|
|
122
|
+
dryRun: true,
|
|
123
|
+
});
|
|
124
|
+
console.log(preview.matchedCount);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Available selectors: `entityId`, `expired`, `superseded`, `createdBefore`,
|
|
128
|
+
`notAccessedSince`, `types`, `tags`, `maxImportance`. They AND together.
|
|
129
|
+
|
|
68
130
|
## Retrieval tuning
|
|
69
131
|
|
|
70
132
|
```ts
|
|
@@ -93,7 +155,7 @@ pnpm checktypes
|
|
|
93
155
|
pnpm lint
|
|
94
156
|
pnpm run test:retrieval
|
|
95
157
|
pnpm run test:integration
|
|
96
|
-
pnpm pack
|
|
158
|
+
pnpm run pack:check
|
|
97
159
|
```
|
|
98
160
|
|
|
99
161
|
`test:integration` skips cleanly when `DATABASE_URL` is not set.
|