mnemocyte 0.5.0 → 0.5.1
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 +68 -177
- package/dist/embedders/index.mjs +1 -2
- package/dist/embedders/openai.d.mts +3 -8
- package/dist/embedders/openai.mjs +3 -4
- package/dist/embedders/openai.mjs.map +1 -1
- package/dist/{errors-DIPysVWl.mjs → errors-Dgt2nAs1.mjs} +2 -3
- package/dist/{errors-DIPysVWl.mjs.map → errors-Dgt2nAs1.mjs.map} +1 -1
- package/dist/index.d.mts +5 -11
- package/dist/index.mjs +947 -12
- package/dist/index.mjs.map +1 -1
- package/dist/{postgres-BHQ1pj16.mjs → postgres-BDti0rrm.mjs} +14 -23
- package/dist/{postgres-BHQ1pj16.mjs.map → postgres-BDti0rrm.mjs.map} +1 -1
- package/dist/{postgres-runtime-DxJxns07.mjs → postgres-runtime-51fQVwqa.mjs} +3 -4
- package/dist/{postgres-runtime-DxJxns07.mjs.map → postgres-runtime-51fQVwqa.mjs.map} +1 -1
- package/dist/store-config-BZ4J1hrM.mjs +304 -0
- package/dist/store-config-BZ4J1hrM.mjs.map +1 -0
- package/dist/stores/drizzle.d.mts +2 -7
- package/dist/stores/drizzle.mjs +3 -4
- package/dist/{types-XUWYDoXM.d.mts → types-DXYtLiOT.d.mts} +3 -4
- package/migrations/fresh-install.sql +43 -0
- package/package.json +23 -20
- package/dist/embedders/openai.d.mts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/store-config-BFFTm1sj.mjs +0 -1255
- package/dist/store-config-BFFTm1sj.mjs.map +0 -1
- package/dist/stores/drizzle.d.mts.map +0 -1
- package/dist/types-XUWYDoXM.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -21,7 +21,9 @@ logs, and duplicate-consolidation tools on top of your existing infrastructure.
|
|
|
21
21
|
- Provider retries, per-attempt timeouts, and caller `AbortSignal` cancellation.
|
|
22
22
|
- Pruning, duplicate detection, audit logs, and experimental consolidation.
|
|
23
23
|
|
|
24
|
-
Mnemocyte
|
|
24
|
+
Mnemocyte ships as ES modules. CommonJS code can load it with `require()` on
|
|
25
|
+
the supported Node versions (22.18 and newer); `require()` returns the
|
|
26
|
+
module's named exports.
|
|
25
27
|
|
|
26
28
|
## Install
|
|
27
29
|
|
|
@@ -116,7 +118,21 @@ boundary.
|
|
|
116
118
|
## Postgres
|
|
117
119
|
|
|
118
120
|
For persistent storage, enable pgvector in your Postgres database, apply the
|
|
119
|
-
bundled
|
|
121
|
+
appropriate bundled schema file, then pass `databaseUrl`. The commands below
|
|
122
|
+
use `psql` and assume `DATABASE_URL` points at the target database.
|
|
123
|
+
`-v ON_ERROR_STOP=1 --single-transaction` makes `psql` stop at the first error
|
|
124
|
+
and roll the whole file back, so a failed migration never leaves a partial
|
|
125
|
+
schema.
|
|
126
|
+
|
|
127
|
+
Enable pgvector before applying any Mnemocyte schema file:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
psql "$DATABASE_URL" -c 'CREATE EXTENSION IF NOT EXISTS vector;'
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The database role running that command must be allowed to install the
|
|
134
|
+
extension. Mnemocyte does not create extensions, tables, or indexes from the
|
|
135
|
+
client constructor.
|
|
120
136
|
|
|
121
137
|
```ts
|
|
122
138
|
const client = createMnemocyte({
|
|
@@ -168,6 +184,7 @@ host, database, and credential validation remains the driver's responsibility.
|
|
|
168
184
|
The package includes:
|
|
169
185
|
|
|
170
186
|
```txt
|
|
187
|
+
migrations/fresh-install.sql
|
|
171
188
|
migrations/0000_initial.sql
|
|
172
189
|
migrations/0001_add_mnemocyte_meta.sql
|
|
173
190
|
migrations/0002_add_embedding_model.sql
|
|
@@ -175,28 +192,44 @@ migrations/0000_initial.sql.template
|
|
|
175
192
|
migrations/render-initial.mjs
|
|
176
193
|
```
|
|
177
194
|
|
|
178
|
-
For
|
|
179
|
-
|
|
195
|
+
For a brand-new installation using the default 1536 dimensions, apply the
|
|
196
|
+
consolidated fresh-install file:
|
|
180
197
|
|
|
181
|
-
```
|
|
182
|
-
migrations/
|
|
183
|
-
|
|
184
|
-
|
|
198
|
+
```bash
|
|
199
|
+
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 --single-transaction -f node_modules/mnemocyte/migrations/fresh-install.sql
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
`fresh-install.sql` is generated from `0000_initial.sql.template` and combines
|
|
203
|
+
the final empty-database effects of `0000`, `0001`, and `0002`. It is only for
|
|
204
|
+
a brand-new installation and is not part of the Drizzle migration journal.
|
|
205
|
+
|
|
206
|
+
Existing installations must continue to use the numbered migration series.
|
|
207
|
+
The `0000` / `0001` / `0002` files remain the correct upgrade source; do not
|
|
208
|
+
apply `fresh-install.sql` over an existing Mnemocyte schema.
|
|
209
|
+
|
|
210
|
+
For an existing 0.1.x Postgres installation, apply `0001` and then `0002` in
|
|
211
|
+
the same order as before:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 --single-transaction -f node_modules/mnemocyte/migrations/0001_add_mnemocyte_meta.sql
|
|
215
|
+
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 --single-transaction -f node_modules/mnemocyte/migrations/0002_add_embedding_model.sql
|
|
185
216
|
```
|
|
186
217
|
|
|
187
|
-
For an existing 0.
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
218
|
+
For an existing 0.2.x or 0.3.x installation, apply only `0002`:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 --single-transaction -f node_modules/mnemocyte/migrations/0002_add_embedding_model.sql
|
|
222
|
+
```
|
|
191
223
|
|
|
192
224
|
For a different embedding dimension on a fresh installation, render an explicit
|
|
193
|
-
initial migration from the template
|
|
194
|
-
|
|
195
|
-
matching `mnemocyte_meta` dimensions and the installation-model
|
|
196
|
-
does not also need `0001
|
|
225
|
+
initial migration from the template, then apply that rendered file instead of
|
|
226
|
+
`fresh-install.sql` or any numbered migration. The rendered initial migration
|
|
227
|
+
includes the matching `mnemocyte_meta` dimensions and the installation-model
|
|
228
|
+
column, so it does not also need `0000`, `0001`, or `0002`.
|
|
197
229
|
|
|
198
230
|
```bash
|
|
199
231
|
node node_modules/mnemocyte/migrations/render-initial.mjs --dimensions 768 --out migrations/0000_initial.768.sql
|
|
232
|
+
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 --single-transaction -f migrations/0000_initial.768.sql
|
|
200
233
|
```
|
|
201
234
|
|
|
202
235
|
Inside this repository, the equivalent development shortcut is:
|
|
@@ -567,169 +600,27 @@ must be positive finite numbers, and `candidateMultiplier` must be an integer
|
|
|
567
600
|
of at least 1. Invalid tuning is rejected at client construction with
|
|
568
601
|
`MnemocyteError` code `"CONFIG"`.
|
|
569
602
|
|
|
570
|
-
##
|
|
571
|
-
|
|
572
|
-
`MemoryStore` is still an internal boundary rather than a public package
|
|
573
|
-
export, but its future-adapter contract is now documented directly in
|
|
574
|
-
[`src/memory/store.ts`](./src/memory/store.ts). The contract is based on
|
|
575
|
-
postconditions, not identical implementation mechanics: every method is
|
|
576
|
-
mandatory, and no capability-flag surface exists or is currently planned.
|
|
577
|
-
|
|
578
|
-
For adapter implementers, the main rules are:
|
|
579
|
-
|
|
580
|
-
- `ensureSchema` is a readiness hook, not permission for hidden schema
|
|
581
|
-
creation. `ensureEmbeddingCompatibility` unconditionally enforces whatever
|
|
582
|
-
compatibility is meaningful to the persistence model; a store without
|
|
583
|
-
persistent installation state may no-op.
|
|
584
|
-
- `insertMemories` takes ownership of prepared rows and returns exactly one
|
|
585
|
-
detached record per prepared ID. Store return order is untrusted; shared
|
|
586
|
-
orchestration rejects missing, duplicate, or unknown IDs and restores input
|
|
587
|
-
order. `getMemoryEmbeddings`, `getMemory`, and `stats` use the exact keyed,
|
|
588
|
-
detached, and count postconditions described in the source comments.
|
|
589
|
-
- `markMemoriesAccessed` requires distinct IDs and returns the committed
|
|
590
|
-
post-update access fields. Duplicate-ID behavior is intentionally not a
|
|
591
|
-
portable contract. Ordinary `addAuditEvents` calls are best-effort, and a
|
|
592
|
-
rejected batch may have partially persisted on some backends.
|
|
593
|
-
- `listAuditLog` uses stable event IDs, comparable timestamps, strict tuple
|
|
594
|
-
filters, and matching newest-first `(timestamp, id)` order. Tuple pagination
|
|
595
|
-
needs no transaction. Cancellation may be cooperative or active depending on
|
|
596
|
-
the implementation.
|
|
597
|
-
- `vectorSearch` may scan or use an approximate, planner-dependent index.
|
|
598
|
-
`lexicalSearch` may legitimately return different candidates and rankings
|
|
599
|
-
across implementations. `findDuplicatePairs` compares qualifying memories
|
|
600
|
-
pairwise and does not imply indexed nearest-neighbor pair generation.
|
|
601
|
-
- `deleteMemory`, `deleteMemoriesForEntity`, and non-dry-run `prune` must
|
|
602
|
-
protect referenced consolidation survivors with one atomic,
|
|
603
|
-
non-interleavable check-and-mutate operation and reject with `"CONFLICT"`
|
|
604
|
-
before any deletion. Other cancellation boundaries remain method- and
|
|
605
|
-
implementation-specific as documented by the public operations.
|
|
606
|
-
- `close` releases or destroys only implementation-owned state and resources.
|
|
607
|
-
A future adapter around a caller-supplied connection must not close that
|
|
608
|
-
connection.
|
|
609
|
-
|
|
610
|
-
## Roadmap
|
|
611
|
-
|
|
612
|
-
Planned larger milestones:
|
|
613
|
-
|
|
614
|
-
- public `MemoryStore` adapter surface
|
|
615
|
-
- `@mnemocyte/mcp`
|
|
616
|
-
|
|
617
|
-
See [ROADMAP.md](./docs/ROADMAP.md).
|
|
618
|
-
|
|
619
|
-
## Pre-v1 Notes
|
|
620
|
-
|
|
621
|
-
Current behavior:
|
|
622
|
-
|
|
623
|
-
- `createMnemocyte()` selects an explicitly supplied `store`, the URL-owned
|
|
624
|
-
Postgres/pgvector backend, or the in-memory backend; supplying both `store`
|
|
625
|
-
and `databaseUrl` rejects instead of selecting a precedence.
|
|
626
|
-
- Both backends run through an internal `MemoryStore` boundary and shared
|
|
627
|
-
client orchestration; `MemoryStore` is not exported as a public adapter API
|
|
628
|
-
yet.
|
|
629
|
-
- `mnemocyte/stores/drizzle` exposes the first supported public adapter factory
|
|
630
|
-
for a caller-owned postgres.js Drizzle instance without exporting the full
|
|
631
|
-
`MemoryStore` contract.
|
|
632
|
-
- Postgres schema setup is explicit; the client does not create tables or
|
|
633
|
-
indexes for you.
|
|
634
|
-
- `findDuplicates`, audit-log workflows, and `experimental.consolidate` are
|
|
635
|
-
available before v1 but still subject to API refinement.
|
|
636
|
-
|
|
637
|
-
Known limitations before v1:
|
|
638
|
-
|
|
639
|
-
- The internal `MemoryStore` boundary is not a public adapter API yet.
|
|
640
|
-
`drizzleStore(db)` returns an opaque config value and currently supports only
|
|
641
|
-
postgres.js, the `public` schema, and pre-applied Mnemocyte migrations.
|
|
642
|
-
- Configured provider timeouts abort the per-attempt `AbortSignal`; the
|
|
643
|
-
underlying provider request only stops promptly when the embedder honors that
|
|
644
|
-
signal.
|
|
645
|
-
- Postgres model and dimension metadata are installation-wide. Mixed embedding
|
|
646
|
-
vector spaces in one database are intentionally unsupported.
|
|
647
|
-
|
|
648
|
-
Planned v1 direction:
|
|
649
|
-
|
|
650
|
-
- Keep storage adapters behind `MemoryStore` while shared core code owns
|
|
651
|
-
validation, embedding, scoring, observability, resilience, and context
|
|
652
|
-
building.
|
|
653
|
-
- Keep root `mnemocyte` imports provider-SDK-free.
|
|
654
|
-
- Keep migrations, dimensions, and production index choices explicit.
|
|
655
|
-
|
|
656
|
-
## Development
|
|
657
|
-
|
|
658
|
-
### Prerequisites
|
|
659
|
-
|
|
660
|
-
- Node.js 22.18 or newer. CI tests the minimum 22.18 release and Node 24.
|
|
661
|
-
- pnpm 11.1.1, matching the `packageManager` field in `package.json`.
|
|
662
|
-
- Postgres with pgvector only when you want to run the integration suite.
|
|
663
|
-
|
|
664
|
-
Clone the repository and install its locked dependencies:
|
|
665
|
-
|
|
666
|
-
```bash
|
|
667
|
-
git clone https://github.com/Meenic/mnemocyte.git
|
|
668
|
-
cd mnemocyte
|
|
669
|
-
pnpm install --frozen-lockfile
|
|
670
|
-
```
|
|
671
|
-
|
|
672
|
-
Mnemocyte is a library, not a standalone server. Use the quick-start example
|
|
673
|
-
from a consuming TypeScript project, or run the repository build in watch mode
|
|
674
|
-
while developing:
|
|
675
|
-
|
|
676
|
-
```bash
|
|
677
|
-
pnpm dev
|
|
678
|
-
```
|
|
679
|
-
|
|
680
|
-
Create the publishable ESM artifacts in `dist/` with:
|
|
681
|
-
|
|
682
|
-
```bash
|
|
683
|
-
pnpm build
|
|
684
|
-
```
|
|
685
|
-
|
|
686
|
-
### Validation
|
|
687
|
-
|
|
688
|
-
Run the same main gates used by CI before committing:
|
|
689
|
-
|
|
690
|
-
```bash
|
|
691
|
-
pnpm checktypes
|
|
692
|
-
pnpm lint
|
|
693
|
-
pnpm test
|
|
694
|
-
pnpm run pack:check
|
|
695
|
-
```
|
|
696
|
-
|
|
697
|
-
`pnpm test` builds the package, runs unit behavior, verifies package exports,
|
|
698
|
-
and type-checks the public declarations. `pnpm lint` is a read-only formatting,
|
|
699
|
-
lint, and import-order check; use `pnpm lint:fix` to apply its safe fixes. The
|
|
700
|
-
Postgres suite is separate:
|
|
701
|
-
|
|
702
|
-
```bash
|
|
703
|
-
DATABASE_URL=postgres://... pnpm run test:integration
|
|
704
|
-
```
|
|
705
|
-
|
|
706
|
-
On PowerShell, set the environment variable for the current process first:
|
|
707
|
-
|
|
708
|
-
```powershell
|
|
709
|
-
$env:DATABASE_URL = "postgres://..."
|
|
710
|
-
pnpm run test:integration
|
|
711
|
-
```
|
|
712
|
-
|
|
713
|
-
`test:integration` skips when `DATABASE_URL` is not set. The database must have
|
|
714
|
-
pgvector available; the test applies the bundled migrations.
|
|
603
|
+
## Limitations
|
|
715
604
|
|
|
716
|
-
|
|
605
|
+
Mnemocyte is pre-1.0. Today:
|
|
717
606
|
|
|
718
|
-
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
-
|
|
725
|
-
-
|
|
726
|
-
|
|
727
|
-
`
|
|
607
|
+
- Postgres stores one embedding model and dimension per installation; mixed
|
|
608
|
+
vector spaces in one database are not supported.
|
|
609
|
+
- The bundled HNSW index supports at most 2,000 dimensions. Rendering a
|
|
610
|
+
larger dimension produces a migration that fails at `CREATE INDEX`.
|
|
611
|
+
- `drizzleStore(db)` supports only postgres.js-backed Drizzle instances, the
|
|
612
|
+
`public` schema and pre-applied migrations.
|
|
613
|
+
- Without `entityId`, `prune` applies to every entity in the database.
|
|
614
|
+
- `forgetAll` rejects with `"CONFLICT"` after a consolidation until the
|
|
615
|
+
superseded memories are pruned first (`prune({ entityId, superseded: true
|
|
616
|
+
})`).
|
|
617
|
+
- Provider timeouts abort the attempt's `AbortSignal`; the request stops
|
|
618
|
+
promptly only if the embedder forwards that signal.
|
|
728
619
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
boundaries or the public surface.
|
|
620
|
+
The planned 0.6 release changes the API; see the
|
|
621
|
+
[roadmap](./docs/ROADMAP.md).
|
|
732
622
|
|
|
733
|
-
##
|
|
623
|
+
## Contributing
|
|
734
624
|
|
|
735
|
-
See [
|
|
625
|
+
See [docs/DEVELOPMENT.md](./docs/DEVELOPMENT.md) for setup, structure,
|
|
626
|
+
testing and releases, and [AGENTS.md](./AGENTS.md) for repository rules.
|
package/dist/embedders/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { openaiEmbedder };
|
|
1
|
+
export { openaiEmbedder } from "./openai.mjs";
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { l as Embedder } from "../types-
|
|
2
|
-
|
|
3
|
-
//#region src/embedders/openai.d.ts
|
|
4
|
-
interface OpenAIEmbedderOptions {
|
|
1
|
+
import { l as Embedder } from "../types-DXYtLiOT.mjs";
|
|
2
|
+
export interface OpenAIEmbedderOptions {
|
|
5
3
|
/**
|
|
6
4
|
* OpenAI API key. Defaults to `process.env.OPENAI_API_KEY`.
|
|
7
5
|
*/
|
|
@@ -25,7 +23,4 @@ interface OpenAIEmbedderOptions {
|
|
|
25
23
|
* Create an OpenAI-backed {@link Embedder}. This adapter uses `fetch`
|
|
26
24
|
* directly so provider SDKs never become part of Mnemocyte's dependency graph.
|
|
27
25
|
*/
|
|
28
|
-
declare function openaiEmbedder(options: OpenAIEmbedderOptions): Embedder;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { OpenAIEmbedderOptions, openaiEmbedder };
|
|
31
|
-
//# sourceMappingURL=openai.d.mts.map
|
|
26
|
+
export declare function openaiEmbedder(options: OpenAIEmbedderOptions): Embedder;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { t as MnemocyteError } from "../errors-
|
|
2
|
-
|
|
1
|
+
import { t as MnemocyteError } from "../errors-Dgt2nAs1.mjs";
|
|
2
|
+
// src/embedders/openai.ts
|
|
3
3
|
const KNOWN_MODEL_DIMENSIONS = {
|
|
4
4
|
"text-embedding-3-small": 1536,
|
|
5
5
|
"text-embedding-3-large": 3072,
|
|
6
6
|
"text-embedding-ada-002": 1536
|
|
7
7
|
};
|
|
8
|
-
const CONFIGURABLE_DIMENSION_MODELS = new Set(["text-embedding-3-small", "text-embedding-3-large"]);
|
|
8
|
+
const CONFIGURABLE_DIMENSION_MODELS = /* @__PURE__ */ new Set(["text-embedding-3-small", "text-embedding-3-large"]);
|
|
9
9
|
function isRecord(value) {
|
|
10
10
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11
11
|
}
|
|
@@ -87,7 +87,6 @@ function openaiEmbedder(options) {
|
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
//#endregion
|
|
91
90
|
export { openaiEmbedder };
|
|
92
91
|
|
|
93
92
|
//# sourceMappingURL=openai.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.mjs","names":[],"sources":["../../src/embedders/openai.ts"],"sourcesContent":["import { MnemocyteError } from \"../errors.js\";\nimport type { Embedder } from \"../types.js\";\n\nconst KNOWN_MODEL_DIMENSIONS: Record<string, number> = {\n\t\"text-embedding-3-small\": 1536,\n\t\"text-embedding-3-large\": 3072,\n\t\"text-embedding-ada-002\": 1536,\n};\n\nconst CONFIGURABLE_DIMENSION_MODELS = new Set([\n\t\"text-embedding-3-small\",\n\t\"text-embedding-3-large\",\n]);\n\nexport interface OpenAIEmbedderOptions {\n\t/**\n\t * OpenAI API key. Defaults to `process.env.OPENAI_API_KEY`.\n\t */\n\treadonly apiKey?: string;\n\t/**\n\t * OpenAI embedding model name.\n\t */\n\treadonly model: string;\n\t/**\n\t * Output dimensions. Required for unknown/future model names and accepted\n\t * only for OpenAI models that support configurable dimensions.\n\t */\n\treadonly dimensions?: number;\n\t/**\n\t * Override the OpenAI API base URL. Intended for tests and compatible\n\t * deployments; defaults to `https://api.openai.com/v1`.\n\t */\n\treadonly baseUrl?: string;\n}\n\ninterface OpenAIEmbeddingItem {\n\treadonly embedding: number[];\n\treadonly index: number;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction validateEmbeddingResponse(\n\tbody: unknown,\n\texpectedCount: number,\n): OpenAIEmbeddingItem[] {\n\tif (!isRecord(body) || !Array.isArray(body.data)) {\n\t\tthrow new MnemocyteError(\n\t\t\t\"OpenAI returned malformed embedding response data.\",\n\t\t\t\"EMBEDDING\",\n\t\t);\n\t}\n\tif (body.data.length !== expectedCount) {\n\t\tthrow new MnemocyteError(\n\t\t\t\"OpenAI returned an unexpected number of embeddings.\",\n\t\t\t\"EMBEDDING\",\n\t\t);\n\t}\n\n\tconst indices = new Set<number>();\n\tconst items: OpenAIEmbeddingItem[] = [];\n\tfor (const item of body.data) {\n\t\tif (!isRecord(item)) {\n\t\t\tthrow new MnemocyteError(\n\t\t\t\t\"OpenAI returned a malformed embedding item.\",\n\t\t\t\t\"EMBEDDING\",\n\t\t\t);\n\t\t}\n\t\tconst { embedding, index } = item;\n\t\tif (\n\t\t\ttypeof index !== \"number\" ||\n\t\t\t!Number.isInteger(index) ||\n\t\t\tindex < 0 ||\n\t\t\tindex >= expectedCount\n\t\t) {\n\t\t\tthrow new MnemocyteError(\n\t\t\t\t\"OpenAI returned an embedding with an invalid index.\",\n\t\t\t\t\"EMBEDDING\",\n\t\t\t);\n\t\t}\n\t\tif (indices.has(index)) {\n\t\t\tthrow new MnemocyteError(\n\t\t\t\t\"OpenAI returned a duplicate embedding index.\",\n\t\t\t\t\"EMBEDDING\",\n\t\t\t);\n\t\t}\n\t\tif (!Array.isArray(embedding)) {\n\t\t\tthrow new MnemocyteError(\n\t\t\t\t\"OpenAI returned an embedding that is not an array.\",\n\t\t\t\t\"EMBEDDING\",\n\t\t\t);\n\t\t}\n\t\tindices.add(index);\n\t\titems.push({ embedding: embedding as number[], index });\n\t}\n\treturn items;\n}\n\nfunction assertDimensions(dimensions: number): void {\n\tif (!Number.isInteger(dimensions) || dimensions < 1) {\n\t\tthrow new MnemocyteError(\n\t\t\t\"openaiEmbedder dimensions must be a positive integer.\",\n\t\t\t\"CONFIG\",\n\t\t);\n\t}\n}\n\nfunction resolveApiKey(apiKey: string | undefined): string {\n\tconst resolved = apiKey ?? process.env.OPENAI_API_KEY;\n\tif (!resolved || resolved.trim().length === 0) {\n\t\tthrow new MnemocyteError(\n\t\t\t\"openaiEmbedder requires an API key. Pass apiKey or set OPENAI_API_KEY.\",\n\t\t\t\"CONFIG\",\n\t\t);\n\t}\n\treturn resolved;\n}\n\nfunction resolveDimensions(options: OpenAIEmbedderOptions): {\n\tembedderDimensions: number;\n\trequestDimensions?: number;\n} {\n\tconst defaultDimensions = KNOWN_MODEL_DIMENSIONS[options.model];\n\tif (defaultDimensions === undefined) {\n\t\tif (options.dimensions === undefined) {\n\t\t\tthrow new MnemocyteError(\n\t\t\t\t`openaiEmbedder requires dimensions for unknown model \"${options.model}\".`,\n\t\t\t\t\"CONFIG\",\n\t\t\t);\n\t\t}\n\t\tassertDimensions(options.dimensions);\n\t\treturn {\n\t\t\tembedderDimensions: options.dimensions,\n\t\t\trequestDimensions: options.dimensions,\n\t\t};\n\t}\n\n\tif (\n\t\toptions.dimensions !== undefined &&\n\t\t!CONFIGURABLE_DIMENSION_MODELS.has(options.model)\n\t) {\n\t\tthrow new MnemocyteError(\n\t\t\t`openaiEmbedder does not support a dimensions override for \"${options.model}\".`,\n\t\t\t\"CONFIG\",\n\t\t);\n\t}\n\n\tif (options.dimensions !== undefined) {\n\t\tassertDimensions(options.dimensions);\n\t\treturn {\n\t\t\tembedderDimensions: options.dimensions,\n\t\t\trequestDimensions: options.dimensions,\n\t\t};\n\t}\n\n\treturn { embedderDimensions: defaultDimensions };\n}\n\n/**\n * Create an OpenAI-backed {@link Embedder}. This adapter uses `fetch`\n * directly so provider SDKs never become part of Mnemocyte's dependency graph.\n */\nexport function openaiEmbedder(options: OpenAIEmbedderOptions): Embedder {\n\tconst apiKey = resolveApiKey(options.apiKey);\n\tconst { embedderDimensions, requestDimensions } = resolveDimensions(options);\n\tconst baseUrl = options.baseUrl ?? \"https://api.openai.com/v1\";\n\n\treturn {\n\t\tmodel: options.model,\n\t\tdimensions: embedderDimensions,\n\t\tasync embed(texts, embedOptions) {\n\t\t\tconst response = await fetch(`${baseUrl}/embeddings`, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\tauthorization: `Bearer ${apiKey}`,\n\t\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t},\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\tmodel: options.model,\n\t\t\t\t\tinput: [...texts],\n\t\t\t\t\tencoding_format: \"float\",\n\t\t\t\t\t...(requestDimensions === undefined\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: { dimensions: requestDimensions }),\n\t\t\t\t}),\n\t\t\t\t...(embedOptions?.signal === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { signal: embedOptions.signal }),\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow Object.assign(\n\t\t\t\t\tnew Error(\n\t\t\t\t\t\t`OpenAI embeddings request failed with status ${response.status}.`,\n\t\t\t\t\t),\n\t\t\t\t\t{ status: response.status },\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst items = validateEmbeddingResponse(\n\t\t\t\tawait response.json(),\n\t\t\t\ttexts.length,\n\t\t\t);\n\t\t\treturn items\n\t\t\t\t.sort((left, right) => left.index - right.index)\n\t\t\t\t.map((item) => item.embedding);\n\t\t},\n\t};\n}\n"],"mappings":";;AAGA,MAAM,yBAAiD;CACtD,0BAA0B;CAC1B,0BAA0B;CAC1B,0BAA0B;AAC3B;AAEA,MAAM,
|
|
1
|
+
{"version":3,"file":"openai.mjs","names":[],"sources":["../../src/embedders/openai.ts"],"sourcesContent":["import { MnemocyteError } from \"../errors.js\";\nimport type { Embedder } from \"../types.js\";\n\nconst KNOWN_MODEL_DIMENSIONS: Record<string, number> = {\n\t\"text-embedding-3-small\": 1536,\n\t\"text-embedding-3-large\": 3072,\n\t\"text-embedding-ada-002\": 1536,\n};\n\nconst CONFIGURABLE_DIMENSION_MODELS = new Set([\n\t\"text-embedding-3-small\",\n\t\"text-embedding-3-large\",\n]);\n\nexport interface OpenAIEmbedderOptions {\n\t/**\n\t * OpenAI API key. Defaults to `process.env.OPENAI_API_KEY`.\n\t */\n\treadonly apiKey?: string;\n\t/**\n\t * OpenAI embedding model name.\n\t */\n\treadonly model: string;\n\t/**\n\t * Output dimensions. Required for unknown/future model names and accepted\n\t * only for OpenAI models that support configurable dimensions.\n\t */\n\treadonly dimensions?: number;\n\t/**\n\t * Override the OpenAI API base URL. Intended for tests and compatible\n\t * deployments; defaults to `https://api.openai.com/v1`.\n\t */\n\treadonly baseUrl?: string;\n}\n\ninterface OpenAIEmbeddingItem {\n\treadonly embedding: number[];\n\treadonly index: number;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction validateEmbeddingResponse(\n\tbody: unknown,\n\texpectedCount: number,\n): OpenAIEmbeddingItem[] {\n\tif (!isRecord(body) || !Array.isArray(body.data)) {\n\t\tthrow new MnemocyteError(\n\t\t\t\"OpenAI returned malformed embedding response data.\",\n\t\t\t\"EMBEDDING\",\n\t\t);\n\t}\n\tif (body.data.length !== expectedCount) {\n\t\tthrow new MnemocyteError(\n\t\t\t\"OpenAI returned an unexpected number of embeddings.\",\n\t\t\t\"EMBEDDING\",\n\t\t);\n\t}\n\n\tconst indices = new Set<number>();\n\tconst items: OpenAIEmbeddingItem[] = [];\n\tfor (const item of body.data) {\n\t\tif (!isRecord(item)) {\n\t\t\tthrow new MnemocyteError(\n\t\t\t\t\"OpenAI returned a malformed embedding item.\",\n\t\t\t\t\"EMBEDDING\",\n\t\t\t);\n\t\t}\n\t\tconst { embedding, index } = item;\n\t\tif (\n\t\t\ttypeof index !== \"number\" ||\n\t\t\t!Number.isInteger(index) ||\n\t\t\tindex < 0 ||\n\t\t\tindex >= expectedCount\n\t\t) {\n\t\t\tthrow new MnemocyteError(\n\t\t\t\t\"OpenAI returned an embedding with an invalid index.\",\n\t\t\t\t\"EMBEDDING\",\n\t\t\t);\n\t\t}\n\t\tif (indices.has(index)) {\n\t\t\tthrow new MnemocyteError(\n\t\t\t\t\"OpenAI returned a duplicate embedding index.\",\n\t\t\t\t\"EMBEDDING\",\n\t\t\t);\n\t\t}\n\t\tif (!Array.isArray(embedding)) {\n\t\t\tthrow new MnemocyteError(\n\t\t\t\t\"OpenAI returned an embedding that is not an array.\",\n\t\t\t\t\"EMBEDDING\",\n\t\t\t);\n\t\t}\n\t\tindices.add(index);\n\t\titems.push({ embedding: embedding as number[], index });\n\t}\n\treturn items;\n}\n\nfunction assertDimensions(dimensions: number): void {\n\tif (!Number.isInteger(dimensions) || dimensions < 1) {\n\t\tthrow new MnemocyteError(\n\t\t\t\"openaiEmbedder dimensions must be a positive integer.\",\n\t\t\t\"CONFIG\",\n\t\t);\n\t}\n}\n\nfunction resolveApiKey(apiKey: string | undefined): string {\n\tconst resolved = apiKey ?? process.env.OPENAI_API_KEY;\n\tif (!resolved || resolved.trim().length === 0) {\n\t\tthrow new MnemocyteError(\n\t\t\t\"openaiEmbedder requires an API key. Pass apiKey or set OPENAI_API_KEY.\",\n\t\t\t\"CONFIG\",\n\t\t);\n\t}\n\treturn resolved;\n}\n\nfunction resolveDimensions(options: OpenAIEmbedderOptions): {\n\tembedderDimensions: number;\n\trequestDimensions?: number;\n} {\n\tconst defaultDimensions = KNOWN_MODEL_DIMENSIONS[options.model];\n\tif (defaultDimensions === undefined) {\n\t\tif (options.dimensions === undefined) {\n\t\t\tthrow new MnemocyteError(\n\t\t\t\t`openaiEmbedder requires dimensions for unknown model \"${options.model}\".`,\n\t\t\t\t\"CONFIG\",\n\t\t\t);\n\t\t}\n\t\tassertDimensions(options.dimensions);\n\t\treturn {\n\t\t\tembedderDimensions: options.dimensions,\n\t\t\trequestDimensions: options.dimensions,\n\t\t};\n\t}\n\n\tif (\n\t\toptions.dimensions !== undefined &&\n\t\t!CONFIGURABLE_DIMENSION_MODELS.has(options.model)\n\t) {\n\t\tthrow new MnemocyteError(\n\t\t\t`openaiEmbedder does not support a dimensions override for \"${options.model}\".`,\n\t\t\t\"CONFIG\",\n\t\t);\n\t}\n\n\tif (options.dimensions !== undefined) {\n\t\tassertDimensions(options.dimensions);\n\t\treturn {\n\t\t\tembedderDimensions: options.dimensions,\n\t\t\trequestDimensions: options.dimensions,\n\t\t};\n\t}\n\n\treturn { embedderDimensions: defaultDimensions };\n}\n\n/**\n * Create an OpenAI-backed {@link Embedder}. This adapter uses `fetch`\n * directly so provider SDKs never become part of Mnemocyte's dependency graph.\n */\nexport function openaiEmbedder(options: OpenAIEmbedderOptions): Embedder {\n\tconst apiKey = resolveApiKey(options.apiKey);\n\tconst { embedderDimensions, requestDimensions } = resolveDimensions(options);\n\tconst baseUrl = options.baseUrl ?? \"https://api.openai.com/v1\";\n\n\treturn {\n\t\tmodel: options.model,\n\t\tdimensions: embedderDimensions,\n\t\tasync embed(texts, embedOptions) {\n\t\t\tconst response = await fetch(`${baseUrl}/embeddings`, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\tauthorization: `Bearer ${apiKey}`,\n\t\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t},\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\tmodel: options.model,\n\t\t\t\t\tinput: [...texts],\n\t\t\t\t\tencoding_format: \"float\",\n\t\t\t\t\t...(requestDimensions === undefined\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: { dimensions: requestDimensions }),\n\t\t\t\t}),\n\t\t\t\t...(embedOptions?.signal === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { signal: embedOptions.signal }),\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow Object.assign(\n\t\t\t\t\tnew Error(\n\t\t\t\t\t\t`OpenAI embeddings request failed with status ${response.status}.`,\n\t\t\t\t\t),\n\t\t\t\t\t{ status: response.status },\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst items = validateEmbeddingResponse(\n\t\t\t\tawait response.json(),\n\t\t\t\ttexts.length,\n\t\t\t);\n\t\t\treturn items\n\t\t\t\t.sort((left, right) => left.index - right.index)\n\t\t\t\t.map((item) => item.embedding);\n\t\t},\n\t};\n}\n"],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/errors.ts
|
|
2
2
|
/**
|
|
3
3
|
* Error type thrown by every public Mnemocyte API.
|
|
4
4
|
*
|
|
@@ -48,7 +48,6 @@ var MnemocyteError = class extends Error {
|
|
|
48
48
|
function isMnemocyteError(error) {
|
|
49
49
|
return error instanceof MnemocyteError;
|
|
50
50
|
}
|
|
51
|
-
//#endregion
|
|
52
51
|
export { isMnemocyteError as n, MnemocyteError as t };
|
|
53
52
|
|
|
54
|
-
//# sourceMappingURL=errors-
|
|
53
|
+
//# sourceMappingURL=errors-Dgt2nAs1.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors-
|
|
1
|
+
{"version":3,"file":"errors-Dgt2nAs1.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Stable, machine-readable error code attached to every {@link MnemocyteError}.\n *\n * - `\"CONFIG\"` — invalid client configuration (e.g. missing or malformed embedder).\n * - `\"VALIDATION\"` — invalid argument passed to a client method.\n * - `\"DB\"` — Postgres or driver-level failure.\n * - `\"EMBEDDING\"` — embedder threw or returned an invalid vector.\n * - `\"NOT_FOUND\"` — referenced memory or entity does not exist.\n * - `\"CONFLICT\"` — the requested mutation conflicts with stored relationships.\n * - `\"MIGRATION\"` — schema/migration check failed against the target database.\n * - `\"TIMEOUT\"` — a provider call exceeded its configured timeout.\n * - `\"ABORTED\"` — the operation was cancelled via an `AbortSignal`.\n */\nexport type MnemocyteErrorCode =\n\t| \"CONFIG\"\n\t| \"VALIDATION\"\n\t| \"DB\"\n\t| \"EMBEDDING\"\n\t| \"NOT_FOUND\"\n\t| \"CONFLICT\"\n\t| \"MIGRATION\"\n\t| \"TIMEOUT\"\n\t| \"ABORTED\";\n\n/**\n * Error type thrown by every public Mnemocyte API.\n *\n * Use the {@link MnemocyteError.code} property — not the message — to branch\n * on failure modes, or call {@link isMnemocyteError} as a type guard when\n * working with `unknown` errors.\n *\n * @example\n * ```ts\n * try {\n * await client.recall({ entityId: \"u1\", query: \"hi\" });\n * } catch (err) {\n * if (isMnemocyteError(err) && err.code === \"DB\") {\n * // handle database failure\n * }\n * throw err;\n * }\n * ```\n */\nexport class MnemocyteError extends Error {\n\t/** Stable, machine-readable failure code. See {@link MnemocyteErrorCode}. */\n\treadonly code: MnemocyteErrorCode;\n\t/** Underlying cause, if any (e.g. an original driver or embedder error). */\n\toverride readonly cause?: unknown;\n\n\t/**\n\t * @param message - Human-readable error message.\n\t * @param code - Stable failure code; see {@link MnemocyteErrorCode}.\n\t * @param cause - Optional underlying cause (driver error, network error, etc.).\n\t */\n\tconstructor(message: string, code: MnemocyteErrorCode, cause?: unknown) {\n\t\tsuper(message);\n\t\tthis.name = \"MnemocyteError\";\n\t\tthis.code = code;\n\t\tthis.cause = cause;\n\t}\n}\n\n/**\n * Type guard for {@link MnemocyteError}.\n *\n * This guard uses `instanceof` and recognizes errors created by the same loaded\n * Mnemocyte class. It does not recognize structurally similar errors or errors\n * created by another installed copy of the package.\n *\n * @param error - Value to test (typically a caught `unknown`).\n * @returns `true` if `error` is a {@link MnemocyteError}.\n */\nexport function isMnemocyteError(error: unknown): error is MnemocyteError {\n\treturn error instanceof MnemocyteError;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2CA,IAAa,iBAAb,cAAoC,MAAM;;CAEzC;;CAEA;;;;;;CAOA,YAAY,SAAiB,MAA0B,OAAiB;EACvE,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,QAAQ;CACd;AACD;;;;;;;;;;;AAYA,SAAgB,iBAAiB,OAAyC;CACzE,OAAO,iBAAiB;AACzB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { A as PruneInput, C as MnemocyteConfig, D as MnemocyteStoreConfig, E as MnemocyteOperation, F as RetrievalConfig, I as RetrievalExplanation, L as RetrievalScoreWeights, M as RecallInput, N as RememberInput, O as ObservabilityConfig, P as RememberManyInput, R as RetrievalScores, S as MnemocyteClient, T as MnemocyteObservationPhase, _ as ListAuditLogInput, a as ConsolidateInput, b as MemoryWithScore, c as DuplicatePair, d as ExperimentalMnemocyteClient, f as FindDuplicatesInput, g as JsonValue, h as JsonObject, i as BuildContextInput, j as PruneResult, k as ProviderResilienceConfig, l as Embedder, m as ImportanceLevel, n as AuditEvent, o as ConsolidateResult, p as GlobalStats, r as AuditLogCursor, s as ContextFormat, t as AuditConfig, u as EntityStats, v as Memory, w as MnemocyteObservation, x as MnemocyteBackend, y as MemoryType, z as TokenCounter } from "./types-
|
|
2
|
-
|
|
3
|
-
//#region src/client.d.ts
|
|
1
|
+
import { A as PruneInput, C as MnemocyteConfig, D as MnemocyteStoreConfig, E as MnemocyteOperation, F as RetrievalConfig, I as RetrievalExplanation, L as RetrievalScoreWeights, M as RecallInput, N as RememberInput, O as ObservabilityConfig, P as RememberManyInput, R as RetrievalScores, S as MnemocyteClient, T as MnemocyteObservationPhase, _ as ListAuditLogInput, a as ConsolidateInput, b as MemoryWithScore, c as DuplicatePair, d as ExperimentalMnemocyteClient, f as FindDuplicatesInput, g as JsonValue, h as JsonObject, i as BuildContextInput, j as PruneResult, k as ProviderResilienceConfig, l as Embedder, m as ImportanceLevel, n as AuditEvent, o as ConsolidateResult, p as GlobalStats, r as AuditLogCursor, s as ContextFormat, t as AuditConfig, u as EntityStats, v as Memory, w as MnemocyteObservation, x as MnemocyteBackend, y as MemoryType, z as TokenCounter } from "./types-DXYtLiOT.mjs";
|
|
4
2
|
/**
|
|
5
3
|
* Create a Mnemocyte client.
|
|
6
4
|
*
|
|
@@ -30,9 +28,7 @@ import { A as PruneInput, C as MnemocyteConfig, D as MnemocyteStoreConfig, E as
|
|
|
30
28
|
* });
|
|
31
29
|
* ```
|
|
32
30
|
*/
|
|
33
|
-
declare function createMnemocyte(config: MnemocyteConfig): MnemocyteClient;
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/errors.d.ts
|
|
31
|
+
export declare function createMnemocyte(config: MnemocyteConfig): MnemocyteClient;
|
|
36
32
|
/**
|
|
37
33
|
* Stable, machine-readable error code attached to every {@link MnemocyteError}.
|
|
38
34
|
*
|
|
@@ -66,7 +62,7 @@ type MnemocyteErrorCode = "CONFIG" | "VALIDATION" | "DB" | "EMBEDDING" | "NOT_FO
|
|
|
66
62
|
* }
|
|
67
63
|
* ```
|
|
68
64
|
*/
|
|
69
|
-
declare class MnemocyteError extends Error {
|
|
65
|
+
export declare class MnemocyteError extends Error {
|
|
70
66
|
/** Stable, machine-readable failure code. See {@link MnemocyteErrorCode}. */
|
|
71
67
|
readonly code: MnemocyteErrorCode;
|
|
72
68
|
/** Underlying cause, if any (e.g. an original driver or embedder error). */
|
|
@@ -88,7 +84,5 @@ declare class MnemocyteError extends Error {
|
|
|
88
84
|
* @param error - Value to test (typically a caught `unknown`).
|
|
89
85
|
* @returns `true` if `error` is a {@link MnemocyteError}.
|
|
90
86
|
*/
|
|
91
|
-
declare function isMnemocyteError(error: unknown): error is MnemocyteError;
|
|
92
|
-
|
|
93
|
-
export { type AuditConfig, type AuditEvent, type AuditLogCursor, type BuildContextInput, type ConsolidateInput, type ConsolidateResult, type ContextFormat, type DuplicatePair, type Embedder, type EntityStats, type ExperimentalMnemocyteClient, type FindDuplicatesInput, type GlobalStats, type ImportanceLevel, type JsonObject, type JsonValue, type ListAuditLogInput, type Memory, type MemoryType, type MemoryWithScore, type MnemocyteBackend, type MnemocyteClient, type MnemocyteConfig, MnemocyteError, type MnemocyteErrorCode, type MnemocyteObservation, type MnemocyteObservationPhase, type MnemocyteOperation, type MnemocyteStoreConfig, type ObservabilityConfig, type ProviderResilienceConfig, type PruneInput, type PruneResult, type RecallInput, type RememberInput, type RememberManyInput, type RetrievalConfig, type RetrievalExplanation, type RetrievalScoreWeights, type RetrievalScores, type TokenCounter, createMnemocyte, isMnemocyteError };
|
|
94
|
-
//# sourceMappingURL=index.d.mts.map
|
|
87
|
+
export declare function isMnemocyteError(error: unknown): error is MnemocyteError;
|
|
88
|
+
export type { AuditConfig, AuditEvent, AuditLogCursor, BuildContextInput, ConsolidateInput, ConsolidateResult, ContextFormat, DuplicatePair, Embedder, EntityStats, ExperimentalMnemocyteClient, FindDuplicatesInput, GlobalStats, ImportanceLevel, JsonObject, JsonValue, ListAuditLogInput, Memory, MemoryType, MemoryWithScore, MnemocyteBackend, MnemocyteClient, MnemocyteConfig, MnemocyteErrorCode, MnemocyteObservation, MnemocyteObservationPhase, MnemocyteOperation, MnemocyteStoreConfig, ObservabilityConfig, ProviderResilienceConfig, PruneInput, PruneResult, RecallInput, RememberInput, RememberManyInput, RetrievalConfig, RetrievalExplanation, RetrievalScoreWeights, RetrievalScores, TokenCounter };
|