open-mem 0.8.0 → 0.10.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/CHANGELOG.md +16 -0
- package/README.md +27 -4
- package/dist/adapters/mcp/server.d.ts.map +1 -1
- package/dist/adapters/opencode/tools.d.ts.map +1 -1
- package/dist/ai/compressor.d.ts +1 -0
- package/dist/ai/compressor.d.ts.map +1 -1
- package/dist/ai/conflict-evaluator.d.ts +1 -0
- package/dist/ai/conflict-evaluator.d.ts.map +1 -1
- package/dist/ai/entity-extractor.d.ts +1 -0
- package/dist/ai/entity-extractor.d.ts.map +1 -1
- package/dist/ai/errors.d.ts +14 -0
- package/dist/ai/errors.d.ts.map +1 -0
- package/dist/ai/fallback.d.ts +26 -0
- package/dist/ai/fallback.d.ts.map +1 -0
- package/dist/ai/provider.d.ts +4 -0
- package/dist/ai/provider.d.ts.map +1 -1
- package/dist/ai/summarizer.d.ts +1 -0
- package/dist/ai/summarizer.d.ts.map +1 -1
- package/dist/claude-code.js +92 -73
- package/dist/config.d.ts.map +1 -1
- package/dist/context/builder.d.ts.map +1 -1
- package/dist/contracts/api.d.ts +4 -0
- package/dist/contracts/api.d.ts.map +1 -1
- package/dist/core/contracts.d.ts +6 -2
- package/dist/core/contracts.d.ts.map +1 -1
- package/dist/core/memory-engine.d.ts +4 -1
- package/dist/core/memory-engine.d.ts.map +1 -1
- package/dist/cursor.js +92 -73
- package/dist/daemon.js +40 -28
- package/dist/db/observations.d.ts +2 -0
- package/dist/db/observations.d.ts.map +1 -1
- package/dist/hooks/session-events.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +123 -104
- package/dist/maintenance.js +55 -42
- package/dist/mcp.js +61 -48
- package/dist/store/ports.d.ts +1 -0
- package/dist/store/ports.d.ts.map +1 -1
- package/dist/tools/save.d.ts.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/agents-md.d.ts +13 -3
- package/dist/utils/agents-md.d.ts.map +1 -1
- package/dist/utils/folder-context-maintenance.d.ts +11 -3
- package/dist/utils/folder-context-maintenance.d.ts.map +1 -1
- package/package.json +9 -7
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.10.0] - 2026-02-08
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **OpenRouter provider support** — access 100+ models via `OPEN_MEM_PROVIDER=openrouter` + `OPENROUTER_API_KEY`. Auto-detected from env vars, default model `google/gemini-2.5-flash-lite`. Embeddings correctly return null (OpenRouter doesn't support them).
|
|
12
|
+
- **Provider fallback chain** — automatic failover when primary AI provider returns retryable errors (429/500/503). Configure with `OPEN_MEM_FALLBACK_PROVIDERS=google,anthropic,openai`. Config errors (400/401/403) throw immediately without fallback. Applies only to language models, never to embeddings.
|
|
13
|
+
- **Timeline anchor navigation** — `mem-history` tool now accepts `anchor` (observation ID), `depthBefore`, and `depthAfter` parameters for cross-session chronological navigation around a specific observation.
|
|
14
|
+
- `src/ai/errors.ts` — shared `isRetryable()`, `isConfigError()`, and `sleep()` utilities extracted from 3 duplicated locations.
|
|
15
|
+
- `src/ai/fallback.ts` — `FallbackLanguageModel` wrapper implementing Vercel AI SDK `LanguageModel` interface with try→fail→next semantics.
|
|
16
|
+
- `@openrouter/ai-sdk-provider` dependency for OpenRouter integration.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- All AI consumers (compressor, summarizer, entity-extractor, conflict-evaluator, reranker) now use `createModelWithFallback()` instead of `createModel()` — transparent fallback when configured.
|
|
20
|
+
- `AGENTS.md` generation now includes observation IDs, key concepts, and decision summaries in tables.
|
|
21
|
+
- `mem-create` tool description improved for clarity.
|
|
22
|
+
- Context injection now includes "When to Save" guidance with `mem-create` reference.
|
|
23
|
+
|
|
8
24
|
## [0.7.0] - 2026-02-08
|
|
9
25
|
|
|
10
26
|
### Added (Interop & Ops)
|
package/README.md
CHANGED
|
@@ -64,7 +64,14 @@ export OPENAI_API_KEY=sk-...
|
|
|
64
64
|
export OPEN_MEM_MODEL=gpt-4o
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
**
|
|
67
|
+
**OpenRouter (100+ models):**
|
|
68
|
+
```bash
|
|
69
|
+
export OPEN_MEM_PROVIDER=openrouter
|
|
70
|
+
export OPENROUTER_API_KEY=sk-or-...
|
|
71
|
+
export OPEN_MEM_MODEL=google/gemini-2.5-flash-lite
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Auto-detection:** open-mem detects your provider from environment variables: `GOOGLE_GENERATIVE_AI_API_KEY` → Google, `ANTHROPIC_API_KEY` → Anthropic, AWS credentials → Bedrock, `OPENROUTER_API_KEY` → OpenRouter.
|
|
68
75
|
|
|
69
76
|
Without any provider configured, open-mem still works — it falls back to a basic metadata extractor that captures tool names, file paths, and output snippets.
|
|
70
77
|
|
|
@@ -180,6 +187,12 @@ On session end, open-mem auto-generates `AGENTS.md` files in project folders tha
|
|
|
180
187
|
|
|
181
188
|
User content outside the managed tags is preserved. Disable with `OPEN_MEM_FOLDER_CONTEXT=false`.
|
|
182
189
|
|
|
190
|
+
**Modes:**
|
|
191
|
+
- **Dispersed** (default): Creates `AGENTS.md` in each touched folder with activity for that folder
|
|
192
|
+
- **Single**: Creates one root file with all folder activity grouped by section headers (`### src/tools/`, `### src/hooks/`, etc.)
|
|
193
|
+
|
|
194
|
+
Configure via `OPEN_MEM_FOLDER_CONTEXT_MODE=single` or `OPEN_MEM_FOLDER_CONTEXT_FILENAME=CLAUDE.md`.
|
|
195
|
+
|
|
183
196
|
### Token ROI Tracking
|
|
184
197
|
|
|
185
198
|
The context injector includes a "Memory Economics" footer showing how much context compression saves: read cost vs. original discovery cost, with a savings percentage. This helps you understand the value of AI compression at a glance.
|
|
@@ -210,12 +223,15 @@ Manually save an important observation to memory.
|
|
|
210
223
|
|
|
211
224
|
### memory.history
|
|
212
225
|
|
|
213
|
-
View a timeline of past coding sessions
|
|
226
|
+
View a timeline of past coding sessions, or center the view around a specific observation for cross-session navigation.
|
|
214
227
|
|
|
215
228
|
| Argument | Type | Required | Description |
|
|
216
229
|
|----------|------|----------|-------------|
|
|
217
230
|
| `limit` | number | no | Number of recent sessions (1–20, default: 5) |
|
|
218
231
|
| `sessionId` | string | no | Show details for a specific session |
|
|
232
|
+
| `anchor` | string | no | Observation ID to center the timeline around (cross-session view) |
|
|
233
|
+
| `depthBefore` | number | no | Observations to show before anchor (0–20, default: 5) |
|
|
234
|
+
| `depthAfter` | number | no | Observations to show after anchor (0–20, default: 5) |
|
|
219
235
|
|
|
220
236
|
### memory.get
|
|
221
237
|
|
|
@@ -378,10 +394,12 @@ open-mem works out of the box with zero configuration. All settings can be custo
|
|
|
378
394
|
|
|
379
395
|
| Variable | Default | Description |
|
|
380
396
|
|----------|---------|-------------|
|
|
381
|
-
| `OPEN_MEM_PROVIDER` | `google` | AI provider: `google`, `anthropic`, `bedrock`, `openai` |
|
|
397
|
+
| `OPEN_MEM_PROVIDER` | `google` | AI provider: `google`, `anthropic`, `bedrock`, `openai`, `openrouter` |
|
|
382
398
|
| `GOOGLE_GENERATIVE_AI_API_KEY` | — | API key for Google Gemini provider ([free](https://aistudio.google.com/apikey)) |
|
|
383
399
|
| `ANTHROPIC_API_KEY` | — | API key for Anthropic provider |
|
|
384
400
|
| `OPENAI_API_KEY` | — | API key for OpenAI provider |
|
|
401
|
+
| `OPENROUTER_API_KEY` | — | API key for OpenRouter provider |
|
|
402
|
+
| `OPEN_MEM_FALLBACK_PROVIDERS` | — | Comma-separated fallback providers (e.g., `google,anthropic,openai`) |
|
|
385
403
|
| `OPEN_MEM_DB_PATH` | `.open-mem/memory.db` | Path to SQLite database |
|
|
386
404
|
| `OPEN_MEM_MODEL` | `gemini-2.5-flash-lite` | Model for AI compression |
|
|
387
405
|
| `OPEN_MEM_MAX_CONTEXT_TOKENS` | `4000` | Token budget for injected context |
|
|
@@ -397,6 +415,8 @@ open-mem works out of the box with zero configuration. All settings can be custo
|
|
|
397
415
|
| `OPEN_MEM_MAX_OBSERVATIONS` | `50` | Maximum observations to consider for context |
|
|
398
416
|
| `OPEN_MEM_FOLDER_CONTEXT` | `true` | Set to `false` to disable AGENTS.md generation |
|
|
399
417
|
| `OPEN_MEM_FOLDER_CONTEXT_MAX_DEPTH` | `5` | Max folder depth for AGENTS.md generation |
|
|
418
|
+
| `OPEN_MEM_FOLDER_CONTEXT_MODE` | `dispersed` | Context file mode: `dispersed` (per-folder) or `single` (one root file) |
|
|
419
|
+
| `OPEN_MEM_FOLDER_CONTEXT_FILENAME` | `AGENTS.md` | Filename for context files (e.g. `CLAUDE.md` for Claude Code) |
|
|
400
420
|
| `OPEN_MEM_PLATFORM_OPENCODE` | `true` | Set to `false` to disable OpenCode adapter |
|
|
401
421
|
| `OPEN_MEM_PLATFORM_CLAUDE_CODE` | `false` | Set to `true` to enable Claude Code adapter surface |
|
|
402
422
|
| `OPEN_MEM_PLATFORM_CURSOR` | `false` | Set to `true` to enable Cursor adapter surface |
|
|
@@ -412,7 +432,7 @@ If you need to configure open-mem programmatically (e.g. for testing or custom i
|
|
|
412
432
|
| Option | Type | Default | Description |
|
|
413
433
|
|--------|------|---------|-------------|
|
|
414
434
|
| `dbPath` | string | `.open-mem/memory.db` | SQLite database file path |
|
|
415
|
-
| `provider` | string | `google` | AI provider: `google`, `anthropic`, `bedrock`, `openai` |
|
|
435
|
+
| `provider` | string | `google` | AI provider: `google`, `anthropic`, `bedrock`, `openai`, `openrouter` |
|
|
416
436
|
| `apiKey` | string | `undefined` | Provider API key |
|
|
417
437
|
| `model` | string | `gemini-2.5-flash-lite` | Model for compression |
|
|
418
438
|
| `maxTokensPerCompression` | number | `1024` | Max tokens per compression response |
|
|
@@ -430,6 +450,9 @@ If you need to configure open-mem programmatically (e.g. for testing or custom i
|
|
|
430
450
|
| `logLevel` | string | `warn` | Log level: `debug`, `info`, `warn`, `error` |
|
|
431
451
|
| `folderContextEnabled` | boolean | `true` | Auto-generate AGENTS.md in active folders |
|
|
432
452
|
| `folderContextMaxDepth` | number | `5` | Max folder depth from project root |
|
|
453
|
+
| `folderContextMode` | string | `dispersed` | Context file mode: `dispersed` (per-folder) or `single` (one root file) |
|
|
454
|
+
| `folderContextFilename` | string | `AGENTS.md` | Filename for context files (e.g. `CLAUDE.md` for Claude Code) |
|
|
455
|
+
| `fallbackProviders` | string[] | `undefined` | Comma-separated provider names for automatic failover (e.g., `["google","anthropic"]`) |
|
|
433
456
|
|
|
434
457
|
</details>
|
|
435
458
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/adapters/mcp/server.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAgCzD,MAAM,WAAW,aAAa;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC;CACrC;AAkCD,qBAAa,SAAS;IACrB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAsB;IACxD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAW;IACrD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,UAAU,CAAuB;gBAE7B,IAAI,EAAE,aAAa;IAW/B,KAAK,IAAI,IAAI;IA0Bb,OAAO,CAAC,MAAM;IA8Cd,OAAO,CAAC,gBAAgB;IAmCxB,OAAO,CAAC,kBAAkB;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/adapters/mcp/server.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAgCzD,MAAM,WAAW,aAAa;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC;CACrC;AAkCD,qBAAa,SAAS;IACrB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAsB;IACxD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAW;IACrD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,UAAU,CAAuB;gBAE7B,IAAI,EAAE,aAAa;IAW/B,KAAK,IAAI,IAAI;IA0Bb,OAAO,CAAC,MAAM;IA8Cd,OAAO,CAAC,gBAAgB;IAmCxB,OAAO,CAAC,kBAAkB;YAgEZ,cAAc;YA8Cd,WAAW;IAiJzB,OAAO,CAAC,IAAI;CAGZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/adapters/opencode/tools.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,aAAa,CAAC;AAuBhE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/adapters/opencode/tools.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,aAAa,CAAC;AAuBhE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAiKxF"}
|
package/dist/ai/compressor.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compressor.d.ts","sourceRoot":"","sources":["../../src/ai/compressor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAsB,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"compressor.d.ts","sourceRoot":"","sources":["../../src/ai/compressor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAsB,MAAM,IAAI,CAAC;AAEtD,OAAO,EAAkB,KAAK,iBAAiB,EAA4B,MAAM,UAAU,CAAC;AAS5F,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB,EAAE,MAAM,CAAC;IAChC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAMD;;;;GAIG;AACH,qBAAa,qBAAqB;IACjC,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,MAAM,CAAmB;IAGjC,SAAS,sBAAgB;gBAEb,MAAM,EAAE,gBAAgB;IAyBpC,+DAA+D;IAC/D,MAAM,CAAC,QAAQ,CAAC,gBAAgB,SAAU;IAE1C;;;;OAIG;IACG,QAAQ,CACb,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAqDpC;;;OAGG;IACG,aAAa,CAClB,KAAK,EAAE,aAAa,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,cAAc,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC,GACA,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAqBjD;;;OAGG;IACH,yBAAyB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,iBAAiB;IAuB5E,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAarC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conflict-evaluator.d.ts","sourceRoot":"","sources":["../../src/ai/conflict-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAsB,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"conflict-evaluator.d.ts","sourceRoot":"","sources":["../../src/ai/conflict-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAsB,MAAM,IAAI,CAAC;AAEtD,OAAO,EAAE,KAAK,kBAAkB,EAAmC,MAAM,UAAU,CAAC;AACpF,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,MAAM,WAAW,CAAC;AAInB,6CAA6C;AAC7C,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,CAAC;AAC9E,yCAAyC;AACzC,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,2DAA2D;AAC3D,MAAM,WAAW,uBAAuB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED;;;GAGG;AACH,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,MAAM,CAA0B;IAExC,SAAS,sBAAgB;gBAEb,MAAM,EAAE,uBAAuB;IAqB3C;;;OAGG;IACG,QAAQ,CACb,MAAM,EAAE,sBAAsB,EAC9B,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,GAC1C,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;CAgCrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-extractor.d.ts","sourceRoot":"","sources":["../../src/ai/entity-extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAsB,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"entity-extractor.d.ts","sourceRoot":"","sources":["../../src/ai/entity-extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAsB,MAAM,IAAI,CAAC;AAEtD,OAAO,EAAE,KAAK,sBAAsB,EAAiC,MAAM,UAAU,CAAC;AACtF,OAAO,EAA+B,KAAK,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAI1F,kDAAkD;AAClD,YAAY,EAAE,sBAAsB,IAAI,sBAAsB,EAAE,2BAA2B,EAAE,CAAC;AAC9F,6CAA6C;AAC7C,YAAY,EACX,UAAU,EACV,YAAY,IAAI,eAAe,EAC/B,cAAc,IAAI,iBAAiB,EACnC,gBAAgB,GAChB,MAAM,UAAU,CAAC;AAElB,yDAAyD;AACzD,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED;;;GAGG;AACH,qBAAa,eAAe;IAC3B,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,MAAM,CAAwB;IAEtC,SAAS,sBAAgB;gBAEb,MAAM,EAAE,qBAAqB;IAqBzC;;;OAGG;IACG,OAAO,CAAC,WAAW,EAAE,2BAA2B,GAAG,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;CAgC/F"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if an error is retryable (429/500/503 or overloaded).
|
|
3
|
+
*/
|
|
4
|
+
export declare function isRetryable(error: unknown): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Check if an error is a config error that should NOT trigger fallback.
|
|
7
|
+
* Returns true for 400/401/403 errors.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isConfigError(error: unknown): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Sleep utility for retry delays.
|
|
12
|
+
*/
|
|
13
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/ai/errors.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAcnD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAQrD;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { LanguageModelV2, LanguageModelV3 } from "@ai-sdk/provider";
|
|
2
|
+
/** Concrete model type (excludes string model IDs from the LanguageModel union). */
|
|
3
|
+
type ConcreteLanguageModel = LanguageModelV2 | LanguageModelV3;
|
|
4
|
+
export interface FallbackProvider {
|
|
5
|
+
name: string;
|
|
6
|
+
model: ConcreteLanguageModel;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Wraps multiple LanguageModel instances and automatically fails over to
|
|
10
|
+
* backup providers when the primary returns retryable errors (429/500/503).
|
|
11
|
+
*
|
|
12
|
+
* Config errors (400/401/403) are thrown immediately — they indicate
|
|
13
|
+
* misconfiguration, not transient failures.
|
|
14
|
+
*/
|
|
15
|
+
export declare class FallbackLanguageModel {
|
|
16
|
+
readonly specificationVersion: string;
|
|
17
|
+
readonly provider: string;
|
|
18
|
+
readonly modelId: string;
|
|
19
|
+
readonly supportedUrls: ConcreteLanguageModel["supportedUrls"];
|
|
20
|
+
private providers;
|
|
21
|
+
constructor(providers: FallbackProvider[]);
|
|
22
|
+
doGenerate(options: unknown): Promise<unknown>;
|
|
23
|
+
doStream(options: unknown): Promise<unknown>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=fallback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["../../src/ai/fallback.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAOzE,oFAAoF;AACpF,KAAK,qBAAqB,GAAG,eAAe,GAAG,eAAe,CAAC;AAE/D,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,qBAAqB,CAAC;CAC7B;AAMD;;;;;;GAMG;AACH,qBAAa,qBAAqB;IACjC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC,eAAe,CAAC,CAAC;IAE/D,OAAO,CAAC,SAAS,CAAqB;gBAE1B,SAAS,EAAE,gBAAgB,EAAE;IAiBnC,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAkC9C,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;CA6BlD"}
|
package/dist/ai/provider.d.ts
CHANGED
|
@@ -22,4 +22,8 @@ export declare function createModel(config: ModelConfig): LanguageModel;
|
|
|
22
22
|
* Returns null for providers that don't support embeddings (e.g., Anthropic).
|
|
23
23
|
*/
|
|
24
24
|
export declare function createEmbeddingModel(config: ModelConfig): EmbeddingModel | null;
|
|
25
|
+
export declare function buildFallbackConfigs(config: {
|
|
26
|
+
fallbackProviders?: string[];
|
|
27
|
+
}): ModelConfig[];
|
|
28
|
+
export declare function createModelWithFallback(primaryConfig: ModelConfig, fallbackConfigs?: ModelConfig[]): LanguageModel;
|
|
25
29
|
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/ai/provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/ai/provider.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAOxD,yCAAyC;AACzC,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAElF,uDAAuD;AACvD,MAAM,WAAW,WAAW;IAC3B,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAcD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGzD;AAMD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAkC9D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,cAAc,GAAG,IAAI,CA4B/E;AA+BD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAAE,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,WAAW,EAAE,CAU5F;AAED,wBAAgB,uBAAuB,CACtC,aAAa,EAAE,WAAW,EAC1B,eAAe,GAAE,WAAW,EAAO,GACjC,aAAa,CAYf"}
|
package/dist/ai/summarizer.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarizer.d.ts","sourceRoot":"","sources":["../../src/ai/summarizer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAsB,MAAM,IAAI,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,KAAK,aAAa,EAAwB,MAAM,UAAU,CAAC;AASpE,mDAAmD;AACnD,MAAM,WAAW,gBAAgB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB,EAAE,MAAM,CAAC;IAChC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,mBAAmB,EAAE,OAAO,CAAC;CAC7B;AAMD;;;GAGG;AACH,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,MAAM,CAAmB;IAGjC,SAAS,sBAAgB;gBAEb,MAAM,EAAE,gBAAgB;
|
|
1
|
+
{"version":3,"file":"summarizer.d.ts","sourceRoot":"","sources":["../../src/ai/summarizer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAsB,MAAM,IAAI,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,KAAK,aAAa,EAAwB,MAAM,UAAU,CAAC;AASpE,mDAAmD;AACnD,MAAM,WAAW,gBAAgB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB,EAAE,MAAM,CAAC;IAChC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAMD;;;GAGG;AACH,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,MAAM,CAAmB;IAGjC,SAAS,sBAAgB;gBAEb,MAAM,EAAE,gBAAgB;IAyBpC;;;;OAIG;IACG,SAAS,CACd,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,aAAa,CAAC,WAAW,CAAC,GACtC,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAyChC;;OAEG;IACH,qBAAqB,CAAC,YAAY,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,aAAa;IAqC9E,yEAAyE;IACzE,eAAe,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO;CAGlD"}
|