@theokit/sdk-memory 0.6.4 → 0.7.3
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 +45 -0
- package/dist/index.cjs +120 -387
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -356
- package/dist/index.js.map +1 -1
- package/dist/internal/active-memory/active-memory.d.ts +1 -1
- package/dist/internal/active-memory/active-memory.d.ts.map +1 -1
- package/dist/internal/adapter-catalog.d.ts +2 -10
- package/dist/internal/adapter-catalog.d.ts.map +1 -1
- package/dist/internal/embedding/azure-openai-embedding.d.ts +1 -42
- package/dist/internal/embedding/azure-openai-embedding.d.ts.map +1 -1
- package/dist/internal/embedding/cohere-embedding.d.ts +1 -29
- package/dist/internal/embedding/cohere-embedding.d.ts.map +1 -1
- package/dist/internal/embedding/deepinfra-embedding.d.ts +1 -30
- package/dist/internal/embedding/deepinfra-embedding.d.ts.map +1 -1
- package/dist/internal/embedding/gemini-embedding.d.ts +1 -26
- package/dist/internal/embedding/gemini-embedding.d.ts.map +1 -1
- package/dist/internal/embedding/jina-embedding.d.ts +1 -21
- package/dist/internal/embedding/jina-embedding.d.ts.map +1 -1
- package/dist/internal/embedding/mistral-embedding.d.ts +1 -23
- package/dist/internal/embedding/mistral-embedding.d.ts.map +1 -1
- package/dist/internal/embedding/ollama-embedding.d.ts +1 -61
- package/dist/internal/embedding/ollama-embedding.d.ts.map +1 -1
- package/dist/internal/embedding/openai-embedding.d.ts +1 -33
- package/dist/internal/embedding/openai-embedding.d.ts.map +1 -1
- package/dist/internal/embedding/openrouter-embedding.d.ts +1 -29
- package/dist/internal/embedding/openrouter-embedding.d.ts.map +1 -1
- package/dist/internal/embedding/voyage-embedding.d.ts +1 -24
- package/dist/internal/embedding/voyage-embedding.d.ts.map +1 -1
- package/dist/internal/store/markdown-store.d.ts +1 -1
- package/dist/internal/store/markdown-store.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/internal/circuit-breaker.d.ts +0 -53
- package/dist/internal/circuit-breaker.d.ts.map +0 -1
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
* @internal
|
|
40
40
|
*/
|
|
41
41
|
import type { TelemetryHandle } from "@theokit/sdk";
|
|
42
|
-
import type { CircuitBreaker } from "
|
|
42
|
+
import type { CircuitBreaker } from "@theokit/sdk/retry";
|
|
43
43
|
import type { MemoryIndex } from "../index/memory-index.js";
|
|
44
44
|
import type { ActiveMemoryCache } from "./active-memory-cache.js";
|
|
45
45
|
import type { ActiveMemoryQueryMode, ActiveMemoryResult, ActiveMemoryStatus } from "./active-memory-types.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active-memory.d.ts","sourceRoot":"","sources":["../../../src/internal/active-memory/active-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,KAAK,EAAY,eAAe,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"active-memory.d.ts","sourceRoot":"","sources":["../../../src/internal/active-memory/active-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,KAAK,EAAY,eAAe,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,0BAA0B,CAAC;AAIjF,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAElC,YAAY,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAC;AAmB9E;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,yDAAyD;IACzD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uDAAuD;IACvD,SAAS,CAAC,EAAE,qBAAqB,CAAC;IAClC,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uFAAuF;IACvF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3E,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,OAAO,EAAE,mBAAmB,CAAC;IAC7B,2CAA2C;IAC3C,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,wCAAwC;IACxC,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,iDAAiD;IACjD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yFAAyF;IACzF,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AASD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAsD5F"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MemoryEmbeddingProviderAdapter } from "./embedding/embedding-adapter.js";
|
|
1
2
|
/**
|
|
2
3
|
* Memory embedding adapter catalog, indexed by provider id.
|
|
3
4
|
*
|
|
@@ -37,15 +38,6 @@
|
|
|
37
38
|
* @internal
|
|
38
39
|
*/
|
|
39
40
|
export declare const MEMORY_EMBEDDING_ADAPTERS: {
|
|
40
|
-
openai
|
|
41
|
-
mistral: import("./embedding/embedding-adapter.js").MemoryEmbeddingProviderAdapter;
|
|
42
|
-
openrouter: import("./embedding/embedding-adapter.js").MemoryEmbeddingProviderAdapter;
|
|
43
|
-
voyage: import("./embedding/embedding-adapter.js").MemoryEmbeddingProviderAdapter;
|
|
44
|
-
deepinfra: import("./embedding/embedding-adapter.js").MemoryEmbeddingProviderAdapter;
|
|
45
|
-
ollama: import("./embedding/embedding-adapter.js").MemoryEmbeddingProviderAdapter;
|
|
46
|
-
"azure-openai": import("./embedding/embedding-adapter.js").MemoryEmbeddingProviderAdapter;
|
|
47
|
-
cohere: import("./embedding/embedding-adapter.js").MemoryEmbeddingProviderAdapter;
|
|
48
|
-
jina: import("./embedding/embedding-adapter.js").MemoryEmbeddingProviderAdapter;
|
|
49
|
-
gemini: import("./embedding/embedding-adapter.js").MemoryEmbeddingProviderAdapter;
|
|
41
|
+
readonly [K in "openai" | "mistral" | "openrouter" | "voyage" | "deepinfra" | "ollama" | "azure-openai" | "cohere" | "jina" | "gemini"]: MemoryEmbeddingProviderAdapter;
|
|
50
42
|
};
|
|
51
43
|
//# sourceMappingURL=adapter-catalog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-catalog.d.ts","sourceRoot":"","sources":["../../src/internal/adapter-catalog.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adapter-catalog.d.ts","sourceRoot":"","sources":["../../src/internal/adapter-catalog.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAcvF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,yBAAyB,EAAE;IACtC,QAAQ,EAAE,CAAC,IACP,QAAQ,GACR,SAAS,GACT,YAAY,GACZ,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,cAAc,GACd,QAAQ,GACR,MAAM,GACN,QAAQ,GAAG,8BAA8B;CAa9C,CAAC"}
|
|
@@ -1,43 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Azure OpenAI embedding adapter.
|
|
4
|
-
*
|
|
5
|
-
* Azure addresses the DEPLOYMENT in the path rather than the model in the body:
|
|
6
|
-
* `https://{resource}.openai.azure.com/openai/deployments/{deployment}/embeddings?api-version=...`.
|
|
7
|
-
* `{model}` in `embeddingsPath` is substituted by `createOpenAiCompatibleRuntime`, so `model` here
|
|
8
|
-
* names the Azure deployment.
|
|
9
|
-
*
|
|
10
|
-
* `AZURE_OPENAI_ENDPOINT` supplies the resource URL (without the `/openai/...` suffix);
|
|
11
|
-
* `AZURE_OPENAI_API_KEY` the credential.
|
|
12
|
-
*
|
|
13
|
-
* theokit#128 (catalog parity): sdk-core gained this adapter in T4.10 and the peer never mirrored
|
|
14
|
-
* it, so a `sdk-memory` user asking for `azure-openai` was rejected by a provider the SDK's own
|
|
15
|
-
* `Theokit.inspect.embeddingAdapters()` advertised.
|
|
16
|
-
*
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
export declare const DEFAULT_AZURE_OPENAI_EMBEDDING_MODEL = "text-embedding-3-small";
|
|
20
|
-
/**
|
|
21
|
-
* Azure OpenAI embeddings. Same models as the OpenAI adapter, addressed the
|
|
22
|
-
* Azure way, and the one adapter whose configuration is not just "set a key".
|
|
23
|
-
*
|
|
24
|
-
* Two things differ from every other adapter here. `model` names your Azure
|
|
25
|
-
* DEPLOYMENT, not an OpenAI model id — it is substituted into the path
|
|
26
|
-
* (`/openai/deployments/{model}/embeddings`) rather than sent in the body. And
|
|
27
|
-
* `AZURE_OPENAI_ENDPOINT` must be set to your resource URL, without the
|
|
28
|
-
* `/openai/...` suffix; the built-in default is a placeholder that resolves
|
|
29
|
-
* nowhere, so leaving it unset fails at the network rather than at
|
|
30
|
-
* configuration.
|
|
31
|
-
*
|
|
32
|
-
* Authentication uses the `api-key` header, which is what an Azure resource key
|
|
33
|
-
* expects; Entra ID bearer tokens are not supported by this adapter. Reads
|
|
34
|
-
* `AZURE_OPENAI_API_KEY`. The API version is pinned to `2024-02-01`.
|
|
35
|
-
*
|
|
36
|
-
* The deployment name still has to appear in the dimension table
|
|
37
|
-
* (`text-embedding-3-small`, `-3-large`, `ada-002`), so a deployment named
|
|
38
|
-
* anything else is refused with `embedding_unknown_model` — pass `model` as the
|
|
39
|
-
* matching id and point the base URL at the right deployment, or add the name to
|
|
40
|
-
* the table.
|
|
41
|
-
*/
|
|
42
|
-
export declare const azureOpenAiMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter;
|
|
1
|
+
export { azureOpenAiMemoryEmbeddingProviderAdapter, DEFAULT_AZURE_OPENAI_EMBEDDING_MODEL, } from "@theokit/sdk/internal/memory-adapters";
|
|
43
2
|
//# sourceMappingURL=azure-openai-embedding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azure-openai-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/azure-openai-embedding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"azure-openai-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/azure-openai-embedding.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yCAAyC,EACzC,oCAAoC,GACrC,MAAM,uCAAuC,CAAC"}
|
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Cohere embedding adapter — `POST /v2/embed` at `https://api.cohere.com`. Despite living beside
|
|
4
|
-
* the OpenAI-compatible adapters, this endpoint is NOT OpenAI-shaped in either direction; the
|
|
5
|
-
* `dialect` below is what makes it work.
|
|
6
|
-
*
|
|
7
|
-
* Honors `COHERE_API_KEY`.
|
|
8
|
-
*
|
|
9
|
-
* theokit#128 (catalog parity): mirrors sdk-core's T4.10 adapter, which the peer never picked up.
|
|
10
|
-
*
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export declare const DEFAULT_COHERE_EMBEDDING_MODEL = "embed-english-v3.0";
|
|
14
|
-
/**
|
|
15
|
-
* Cohere embeddings. Priority 30, so it is auto-selected ahead of OpenAI when
|
|
16
|
-
* both keys are present.
|
|
17
|
-
*
|
|
18
|
-
* Cohere does not speak the OpenAI wire, and this adapter supplies a dialect for
|
|
19
|
-
* it: the request names its payload `texts`, the response returns
|
|
20
|
-
* `{embeddings: {float: [...]}}`, and `input_type` is sent as
|
|
21
|
-
* `search_document`. That last choice matters — Cohere's v3 models embed
|
|
22
|
-
* documents and queries into different spaces, and this runtime always embeds as
|
|
23
|
-
* a document, including the query side of a search. Expect somewhat weaker
|
|
24
|
-
* retrieval than a Cohere-native setup that embeds queries as `search_query`.
|
|
25
|
-
*
|
|
26
|
-
* Reads `COHERE_API_KEY`; no base-URL environment override is declared. The
|
|
27
|
-
* light models are 384 dimensions and the others 1024.
|
|
28
|
-
*/
|
|
29
|
-
export declare const cohereMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter;
|
|
1
|
+
export { cohereMemoryEmbeddingProviderAdapter, DEFAULT_COHERE_EMBEDDING_MODEL, } from "@theokit/sdk/internal/memory-adapters";
|
|
30
2
|
//# sourceMappingURL=cohere-embedding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cohere-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/cohere-embedding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cohere-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/cohere-embedding.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oCAAoC,EACpC,8BAA8B,GAC/B,MAAM,uCAAuC,CAAC"}
|
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* DeepInfra embedding adapter — hosts open-source embedding models
|
|
4
|
-
* (BGE, E5, Jina, etc.) at pay-per-token. OpenAI-compatible REST at
|
|
5
|
-
* `POST /v1/openai/embeddings` (note the `/openai` segment; not the
|
|
6
|
-
* canonical `/v1/embeddings`). The `embeddingsPath` override on
|
|
7
|
-
* `OpenAiCompatibleConfig` REPLACES the default suffix (EC-2).
|
|
8
|
-
*
|
|
9
|
-
* Honors `DEEPINFRA_API_KEY` and `DEEPINFRA_API_BASE_URL`.
|
|
10
|
-
*
|
|
11
|
-
* Iter 74 (Stage 3 source-move #33): hybrid copy from sdk-core's
|
|
12
|
-
* `internal/memory/adapters/deepinfra-embedding.ts`.
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export declare const DEFAULT_DEEPINFRA_EMBEDDING_MODEL = "BAAI/bge-large-en-v1.5";
|
|
17
|
-
/**
|
|
18
|
-
* Open-weight embedding models (BGE, E5, GTE, MiniLM) hosted by DeepInfra.
|
|
19
|
-
* Reach for it when you want a specific open model — particularly a multilingual
|
|
20
|
-
* one — behind a hosted API rather than running it yourself.
|
|
21
|
-
*
|
|
22
|
-
* Its endpoint is `/v1/openai/embeddings`, not the canonical `/v1/embeddings`;
|
|
23
|
-
* the wire format is otherwise OpenAI-shaped. Reads `DEEPINFRA_API_KEY` and
|
|
24
|
-
* honours `DEEPINFRA_API_BASE_URL`. Priority 13.
|
|
25
|
-
*
|
|
26
|
-
* Dimensions vary sharply across the ten models it knows (384 to 1024), and
|
|
27
|
-
* switching between them invalidates an existing vector index — the index drops
|
|
28
|
-
* every vector and re-embeds on the next sync.
|
|
29
|
-
*/
|
|
30
|
-
export declare const deepinfraMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter;
|
|
1
|
+
export { DEFAULT_DEEPINFRA_EMBEDDING_MODEL, deepinfraMemoryEmbeddingProviderAdapter, } from "@theokit/sdk/internal/memory-adapters";
|
|
31
2
|
//# sourceMappingURL=deepinfra-embedding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepinfra-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/deepinfra-embedding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deepinfra-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/deepinfra-embedding.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iCAAiC,EACjC,uCAAuC,GACxC,MAAM,uCAAuC,CAAC"}
|
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Google Gemini embedding adapter — the OpenAI-compatible surface at
|
|
4
|
-
* `https://generativelanguage.googleapis.com/v1/embeddings`.
|
|
5
|
-
*
|
|
6
|
-
* Gemini's NATIVE embedding endpoint has a different shape
|
|
7
|
-
* (`POST /v1beta/models/{model}:embedContent`); this adapter deliberately targets the
|
|
8
|
-
* OpenAI-compatible one so it composes with the shared runtime.
|
|
9
|
-
*
|
|
10
|
-
* Honors `GEMINI_API_KEY`.
|
|
11
|
-
*
|
|
12
|
-
* theokit#128 (catalog parity): mirrors sdk-core's T4.10 adapter, which the peer never picked up.
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export declare const DEFAULT_GEMINI_EMBEDDING_MODEL = "text-embedding-004";
|
|
17
|
-
/**
|
|
18
|
-
* Google Gemini embeddings through Google's OpenAI-compatible surface at
|
|
19
|
-
* `/v1beta/openai/embeddings`. Gemini's native embedding endpoint
|
|
20
|
-
* (`/v1beta/models/{model}:embedContent`) has a different shape and is
|
|
21
|
-
* deliberately not used, so this composes with the shared runtime like the rest.
|
|
22
|
-
*
|
|
23
|
-
* Both known models are 768 dimensions. Reads `GEMINI_API_KEY`; no base-URL
|
|
24
|
-
* environment override is declared. Priority 30.
|
|
25
|
-
*/
|
|
26
|
-
export declare const geminiMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter;
|
|
1
|
+
export { DEFAULT_GEMINI_EMBEDDING_MODEL, geminiMemoryEmbeddingProviderAdapter, } from "@theokit/sdk/internal/memory-adapters";
|
|
27
2
|
//# sourceMappingURL=gemini-embedding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/gemini-embedding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gemini-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/gemini-embedding.ts"],"names":[],"mappings":"AACA,OAAO,EACL,8BAA8B,EAC9B,oCAAoC,GACrC,MAAM,uCAAuC,CAAC"}
|
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Jina AI embedding adapter — OpenAI-compatible at `https://api.jina.ai/v1/embeddings`.
|
|
4
|
-
*
|
|
5
|
-
* Honors `JINA_API_KEY`.
|
|
6
|
-
*
|
|
7
|
-
* theokit#128 (catalog parity): mirrors sdk-core's T4.10 adapter, which the peer never picked up.
|
|
8
|
-
*
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export declare const DEFAULT_JINA_EMBEDDING_MODEL = "jina-embeddings-v3";
|
|
12
|
-
/**
|
|
13
|
-
* Jina AI embeddings, over the standard OpenAI wire. Highest auto-select
|
|
14
|
-
* priority in the catalog (35), so it wins over OpenAI when both keys are
|
|
15
|
-
* present.
|
|
16
|
-
*
|
|
17
|
-
* Default `jina-embeddings-v3` at 1024 dimensions; the v2 models are 768 and
|
|
18
|
-
* 512. Reads `JINA_API_KEY`. No base-URL environment override is declared —
|
|
19
|
-
* point it elsewhere by passing `baseUrl` to `create`.
|
|
20
|
-
*/
|
|
21
|
-
export declare const jinaMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter;
|
|
1
|
+
export { DEFAULT_JINA_EMBEDDING_MODEL, jinaMemoryEmbeddingProviderAdapter, } from "@theokit/sdk/internal/memory-adapters";
|
|
22
2
|
//# sourceMappingURL=jina-embedding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jina-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/jina-embedding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jina-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/jina-embedding.ts"],"names":[],"mappings":"AACA,OAAO,EACL,4BAA4B,EAC5B,kCAAkC,GACnC,MAAM,uCAAuC,CAAC"}
|
|
@@ -1,24 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Mistral embedding adapter — OpenAI-compatible REST surface
|
|
4
|
-
* (`POST /v1/embeddings` against `https://api.mistral.ai`). Default model
|
|
5
|
-
* `mistral-embed` (1024 dims).
|
|
6
|
-
*
|
|
7
|
-
* Mirrors `reference/peer-project/extensions/mistral/memory-embedding-adapter.ts`.
|
|
8
|
-
*
|
|
9
|
-
* Iter 74 (Stage 3 source-move #32): hybrid copy from sdk-core's
|
|
10
|
-
* `internal/memory/adapters/mistral-embedding.ts`.
|
|
11
|
-
*
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
export declare const DEFAULT_MISTRAL_EMBEDDING_MODEL = "mistral-embed";
|
|
15
|
-
/**
|
|
16
|
-
* Mistral embeddings, over the standard OpenAI wire. One model only,
|
|
17
|
-
* `mistral-embed` at 1024 dimensions; any other id is refused with
|
|
18
|
-
* `embedding_unknown_model`.
|
|
19
|
-
*
|
|
20
|
-
* Reads `MISTRAL_API_KEY` and honours `MISTRAL_API_BASE_URL`. Priority 18, just
|
|
21
|
-
* below OpenAI.
|
|
22
|
-
*/
|
|
23
|
-
export declare const mistralMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter;
|
|
1
|
+
export { DEFAULT_MISTRAL_EMBEDDING_MODEL, mistralMemoryEmbeddingProviderAdapter, } from "@theokit/sdk/internal/memory-adapters";
|
|
24
2
|
//# sourceMappingURL=mistral-embedding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mistral-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/mistral-embedding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mistral-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/mistral-embedding.ts"],"names":[],"mappings":"AACA,OAAO,EACL,+BAA+B,EAC/B,qCAAqC,GACtC,MAAM,uCAAuC,CAAC"}
|
|
@@ -1,62 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Ollama embedding adapter (T3.1, ADR D183).
|
|
3
|
-
*
|
|
4
|
-
* Targets Ollama's OpenAI-compatible `/v1/embeddings` endpoint and reuses
|
|
5
|
-
* the shared `createOpenAiCompatibleRuntime` factory. The differentiating
|
|
6
|
-
* bits:
|
|
7
|
-
*
|
|
8
|
-
* - `authType: "none"` — Ollama local ignores `Authorization`. Sentinel
|
|
9
|
-
* `"ollama-local"` is passed as apiKey to satisfy the factory contract
|
|
10
|
-
* (mirrors peer-project `OLLAMA_DEFAULT_API_KEY = "ollama-local"`).
|
|
11
|
-
* - `OLLAMA_HOST` overrides the default `http://localhost:11434`.
|
|
12
|
-
* - `OLLAMA_API_KEY` (optional) overrides the sentinel for Ollama Cloud
|
|
13
|
-
* or reverse-proxy auth setups.
|
|
14
|
-
* - Default model: `nomic-embed-text` (768 dim, ~274MB). User can opt
|
|
15
|
-
* into `all-minilm` (384 dim, ~45MB) or any other locally-installed
|
|
16
|
-
* embedding model.
|
|
17
|
-
*
|
|
18
|
-
* EC-B MUST FIX (edge-case review 2026-05-21): empty text is rejected
|
|
19
|
-
* upstream in the shared factory (`classifyEntry` short-circuits to a
|
|
20
|
-
* zero vector). That behavior is acceptable here because the zero
|
|
21
|
-
* vector is identical for any empty input — downstream similarity
|
|
22
|
-
* calcs ignore zero-norm vectors via the existing `cosineSimilarity`
|
|
23
|
-
* guard. No additional fail-fast needed.
|
|
24
|
-
*
|
|
25
|
-
* EC-A MUST FIX (edge-case review 2026-05-21): dimension is locked
|
|
26
|
-
* by the `DIMENSION_BY_MODEL` table; an unknown model id throws
|
|
27
|
-
* `ConfigurationError(code: "embedding_unknown_model")` per the
|
|
28
|
-
* factory's EC-4 contract. Future model versions with different
|
|
29
|
-
* dimensions are added to the table here without breaking changes.
|
|
30
|
-
*
|
|
31
|
-
* Iter 74 (Stage 3 source-move #36): hybrid copy from sdk-core's
|
|
32
|
-
* `internal/memory/adapters/ollama-embedding.ts`. The only
|
|
33
|
-
* `transport: "local"` adapter in the cluster — enables 100%-local
|
|
34
|
-
* RAG with no remote API key.
|
|
35
|
-
*
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
import type { MemoryEmbeddingProviderAdapter } from "./embedding-adapter.js";
|
|
39
|
-
/**
|
|
40
|
-
* Model used when the caller names none: `nomic-embed-text`, 768 dimensions,
|
|
41
|
-
* roughly 274MB to pull. `all-minilm` is the smaller alternative at 384
|
|
42
|
-
* dimensions and roughly 45MB.
|
|
43
|
-
*/
|
|
44
|
-
export declare const DEFAULT_OLLAMA_EMBEDDING_MODEL = "nomic-embed-text";
|
|
45
|
-
/**
|
|
46
|
-
* Embeddings from a local Ollama instance — the only adapter in the catalog with
|
|
47
|
-
* `transport: "local"`, and the one to choose when the corpus must not leave the
|
|
48
|
-
* machine or when there is no API key to spend.
|
|
49
|
-
*
|
|
50
|
-
* It needs an Ollama server reachable at `OLLAMA_HOST` (default
|
|
51
|
-
* `http://localhost:11434`) with the chosen embedding model already pulled;
|
|
52
|
-
* nothing here starts a server or downloads a model, so a missing model surfaces
|
|
53
|
-
* as an HTTP error from Ollama rather than a configuration error.
|
|
54
|
-
*
|
|
55
|
-
* No credential is required: a sentinel key is sent and local Ollama ignores it.
|
|
56
|
-
* Set `OLLAMA_API_KEY` for Ollama Cloud or an authenticating reverse proxy.
|
|
57
|
-
*
|
|
58
|
-
* Auto-select priority is 10, the lowest in the catalog, so a configured remote
|
|
59
|
-
* provider wins over it. Request it explicitly to prefer local.
|
|
60
|
-
*/
|
|
61
|
-
export declare const ollamaMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter;
|
|
1
|
+
export { DEFAULT_OLLAMA_EMBEDDING_MODEL, ollamaMemoryEmbeddingProviderAdapter, } from "@theokit/sdk/internal/memory-adapters";
|
|
62
2
|
//# sourceMappingURL=ollama-embedding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ollama-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/ollama-embedding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ollama-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/ollama-embedding.ts"],"names":[],"mappings":"AACA,OAAO,EACL,8BAA8B,EAC9B,oCAAoC,GACrC,MAAM,uCAAuC,CAAC"}
|
|
@@ -1,34 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* OpenAI embedding adapter (ADR D3) — built on the shared OpenAI-compatible
|
|
4
|
-
* factory. Native fetch only.
|
|
5
|
-
*
|
|
6
|
-
* Iter 74 (Stage 3 source-move #31): hybrid copy from sdk-core's
|
|
7
|
-
* `internal/memory/adapters/openai-embedding.ts`. Composes iter 45's
|
|
8
|
-
* `MemoryEmbeddingProviderAdapter` + iter 73's
|
|
9
|
-
* `createOpenAiCompatibleRuntime`.
|
|
10
|
-
*
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export declare const DEFAULT_OPENAI_EMBEDDING_MODEL = "text-embedding-3-small";
|
|
14
|
-
/**
|
|
15
|
-
* OpenAI embeddings — `text-embedding-3-small` (1536), `text-embedding-3-large` (3072) and
|
|
16
|
-
* `text-embedding-ada-002` (1536).
|
|
17
|
-
*
|
|
18
|
-
* It is NOT selected for you. The provider is whatever the caller names in
|
|
19
|
-
* `embedding: { provider }`; omit that and no embedding runtime is built at all. Its
|
|
20
|
-
* `autoSelectPriority` of `20` is metadata no code path reads today, and it is not the highest
|
|
21
|
-
* value in the catalog either — `jina` is 35, `cohere` and `gemini` are 30, `azure-openai` is 25.
|
|
22
|
-
* The 3072-wide `text-embedding-3-large` is reachable through `azure-openai` and, as
|
|
23
|
-
* `openai/text-embedding-3-large`, through `openrouter` as well.
|
|
24
|
-
*
|
|
25
|
-
* Reads `OPENAI_API_KEY`; `OPENAI_API_BASE_URL` redirects it at a compatible
|
|
26
|
-
* gateway. `create` rejects with an `AuthenticationError`
|
|
27
|
-
* (`embedding_missing_api_key`) when no key is found, and with a
|
|
28
|
-
* `ConfigurationError` (`embedding_unknown_model`) for a model outside
|
|
29
|
-
* `text-embedding-3-small`, `text-embedding-3-large` and
|
|
30
|
-
* `text-embedding-ada-002` — the dimension has to be known before any vector
|
|
31
|
-
* table is created, so an unlisted model is refused rather than probed.
|
|
32
|
-
*/
|
|
33
|
-
export declare const openAiMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter;
|
|
1
|
+
export { DEFAULT_OPENAI_EMBEDDING_MODEL, openAiMemoryEmbeddingProviderAdapter, } from "@theokit/sdk/internal/memory-adapters";
|
|
34
2
|
//# sourceMappingURL=openai-embedding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/openai-embedding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"openai-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/openai-embedding.ts"],"names":[],"mappings":"AACA,OAAO,EACL,8BAA8B,EAC9B,oCAAoC,GACrC,MAAM,uCAAuC,CAAC"}
|
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* OpenRouter embedding adapter — routes through OpenRouter's
|
|
4
|
-
* `POST /api/v1/embeddings` endpoint (OpenAI-compatible request/response
|
|
5
|
-
* shape). The provider id strings follow OpenRouter's catalog
|
|
6
|
-
* (e.g. `"openai/text-embedding-3-small"`, `"mistralai/mistral-embed"`).
|
|
7
|
-
*
|
|
8
|
-
* Honors `OPENROUTER_API_KEY` and `OPENROUTER_API_BASE_URL`. Default base
|
|
9
|
-
* URL is `https://openrouter.ai/api`.
|
|
10
|
-
*
|
|
11
|
-
* Iter 74 (Stage 3 source-move #35): hybrid copy from sdk-core's
|
|
12
|
-
* `internal/memory/adapters/openrouter-embedding.ts`.
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export declare const DEFAULT_OPENROUTER_EMBEDDING_MODEL = "openai/text-embedding-3-small";
|
|
17
|
-
/**
|
|
18
|
-
* Embeddings routed through OpenRouter, which lets one key reach several
|
|
19
|
-
* upstream providers. Use it when you want to switch provider without changing
|
|
20
|
-
* credentials; use the provider's own adapter when you want its full model
|
|
21
|
-
* range, since only the four ids in this adapter's dimension table are
|
|
22
|
-
* accepted.
|
|
23
|
-
*
|
|
24
|
-
* Model ids carry the upstream prefix, for example
|
|
25
|
-
* `openai/text-embedding-3-small` or `mistralai/mistral-embed`. The endpoint is
|
|
26
|
-
* `/v1/embeddings` under the base `https://openrouter.ai/api`. Reads
|
|
27
|
-
* `OPENROUTER_API_KEY` and honours `OPENROUTER_API_BASE_URL`. Priority 15.
|
|
28
|
-
*/
|
|
29
|
-
export declare const openRouterMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter;
|
|
1
|
+
export { DEFAULT_OPENROUTER_EMBEDDING_MODEL, openRouterMemoryEmbeddingProviderAdapter, } from "@theokit/sdk/internal/memory-adapters";
|
|
30
2
|
//# sourceMappingURL=openrouter-embedding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openrouter-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/openrouter-embedding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"openrouter-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/openrouter-embedding.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kCAAkC,EAClC,wCAAwC,GACzC,MAAM,uCAAuC,CAAC"}
|
|
@@ -1,25 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Voyage AI embedding adapter — `POST /v1/embeddings` at
|
|
4
|
-
* `https://api.voyageai.com` with the OpenAI-compatible `{ model, input }`
|
|
5
|
-
* request shape. Free tier (200M tokens/month) covers most SDK use.
|
|
6
|
-
*
|
|
7
|
-
* Honors `VOYAGE_API_KEY` and `VOYAGE_API_BASE_URL`.
|
|
8
|
-
*
|
|
9
|
-
* Iter 74 (Stage 3 source-move #34): hybrid copy from sdk-core's
|
|
10
|
-
* `internal/memory/adapters/voyage-embedding.ts`.
|
|
11
|
-
*
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
export declare const DEFAULT_VOYAGE_EMBEDDING_MODEL = "voyage-3-lite";
|
|
15
|
-
/**
|
|
16
|
-
* Voyage AI embeddings, over the standard OpenAI wire. Default model
|
|
17
|
-
* `voyage-3-lite` at 512 dimensions — the narrowest in the catalog, which makes
|
|
18
|
-
* the index smaller and the search cheaper at some cost in quality; `voyage-3`
|
|
19
|
-
* and `voyage-3-large` are 1024, and `voyage-code-3` is the one to pick for
|
|
20
|
-
* source code.
|
|
21
|
-
*
|
|
22
|
-
* Reads `VOYAGE_API_KEY` and honours `VOYAGE_API_BASE_URL`. Priority 14.
|
|
23
|
-
*/
|
|
24
|
-
export declare const voyageMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter;
|
|
1
|
+
export { DEFAULT_VOYAGE_EMBEDDING_MODEL, voyageMemoryEmbeddingProviderAdapter, } from "@theokit/sdk/internal/memory-adapters";
|
|
25
2
|
//# sourceMappingURL=voyage-embedding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voyage-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/voyage-embedding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"voyage-embedding.d.ts","sourceRoot":"","sources":["../../../src/internal/embedding/voyage-embedding.ts"],"names":[],"mappings":"AACA,OAAO,EACL,8BAA8B,EAC9B,oCAAoC,GACrC,MAAM,uCAAuC,CAAC"}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
|
-
export { appendFact, appendFactToMarkdown, asMemoryRoot, ceilingReachedError, claudeProjectMemoryDir, collectMarkdownFiles, type DiscoveredFile, defaultIndexPath, indexBudgetWarning, lanceStoragePath, MEMORY_INDEX_MAX_BYTES, MEMORY_INDEX_MAX_LINES, type MemoryLocationConfig, type MemoryRoot, memoryIndexRoot, memoryMdPath, memoryReadRoots, notesDir, projectMemoryDir, readAllSqliteFacts, readFacts, readFactsFromMarkdown, resolveMaxFacts, resolveMemoryRoot, type SqliteFactRow, } from "@theokit/sdk/internal/memory-store";
|
|
21
|
+
export { appendFact, appendFactToMarkdown, asMemoryRoot, ceilingReachedError, claudeProjectMemoryDir, collectMarkdownFiles, type DiscoveredFile, defaultIndexPath, type FactEntryInfo, factsBlockRange, indexBudgetWarning, lanceStoragePath, listFactEntries, MEMORY_INDEX_MAX_BYTES, MEMORY_INDEX_MAX_LINES, type MemoryLocationConfig, type MemoryRoot, memoryIndexRoot, memoryMdPath, memoryReadRoots, notesDir, projectMemoryDir, readAllSqliteFacts, readFacts, readFactsFromMarkdown, readLegacyEntriesIn, readMemoryEntriesIn, removeFactEntry, resolveMaxFacts, resolveMemoryRoot, type SqliteFactRow, unlessMissing, } from "@theokit/sdk/internal/memory-store";
|
|
22
22
|
/** One note discovered under `notes/`: its file name without the `.md` suffix, and its absolute path. */
|
|
23
23
|
export interface NoteFile {
|
|
24
24
|
slug: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-store.d.ts","sourceRoot":"","sources":["../../../src/internal/store/markdown-store.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,KAAK,cAAc,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,oBAAoB,EACzB,KAAK,UAAU,EACf,eAAe,EACf,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"markdown-store.d.ts","sourceRoot":"","sources":["../../../src/internal/store/markdown-store.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,KAAK,cAAc,EACnB,gBAAgB,EAChB,KAAK,aAAa,EAClB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,oBAAoB,EACzB,KAAK,UAAU,EACf,eAAe,EACf,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,KAAK,aAAa,EAClB,aAAa,GACd,MAAM,oCAAoC,CAAC;AAE5C,yGAAyG;AACzG,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAahE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theokit/sdk-memory",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Memory subsystem for @theokit/sdk — MemoryProvider impls (markdown file store today; LanceDB + embeddings + circuit breaker next iters). Consumes the kernel-facing port from sdk-core.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/usetheokit/theokit-sdk#readme",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"better-sqlite3": "^12.0.0",
|
|
42
42
|
"sqlite-vec": ">=0.1.0",
|
|
43
43
|
"@lancedb/lancedb": ">=0.20.0",
|
|
44
|
-
"@theokit/sdk": "^
|
|
44
|
+
"@theokit/sdk": "^9.0.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|
|
47
47
|
"better-sqlite3": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@types/better-sqlite3": "^7.6.13",
|
|
62
62
|
"better-sqlite3": "^12.10.0",
|
|
63
63
|
"sqlite-vec": "^0.1.6",
|
|
64
|
-
"@theokit/sdk": "
|
|
64
|
+
"@theokit/sdk": "9.0.0"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"provenance": true,
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Consecutive-timeout circuit breaker for Active Memory recall.
|
|
3
|
-
*
|
|
4
|
-
* Mirrors peer-project's `circuitBreakerMaxTimeouts` + `circuitBreakerCooldownMs`
|
|
5
|
-
* config: after N consecutive timeouts the breaker trips and `shouldSkip`
|
|
6
|
-
* returns `true` until `cooldownMs` has elapsed. A successful recall resets
|
|
7
|
-
* the counter immediately.
|
|
8
|
-
*
|
|
9
|
-
* Per-key isolation so two agents in the same process don't share a counter.
|
|
10
|
-
*
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export interface CircuitBreakerOptions {
|
|
14
|
-
maxTimeouts?: number;
|
|
15
|
-
cooldownMs?: number;
|
|
16
|
-
/** Injectable clock for tests. */
|
|
17
|
-
now?: () => number;
|
|
18
|
-
}
|
|
19
|
-
interface KeyState {
|
|
20
|
-
consecutiveTimeouts: number;
|
|
21
|
-
cooldownUntilMs: number;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Stops calling a recall path that keeps timing out.
|
|
25
|
-
*
|
|
26
|
-
* After `maxTimeouts` consecutive timeouts on a key (default 3) the breaker
|
|
27
|
-
* opens and {@link CircuitBreaker.shouldSkip} reports `true` until `cooldownMs`
|
|
28
|
-
* has elapsed (default 60s). The first `shouldSkip` after the cooldown closes
|
|
29
|
-
* the breaker and resets the counter, so it re-opens only after another full run
|
|
30
|
-
* of timeouts.
|
|
31
|
-
*
|
|
32
|
-
* It counts timeouts, not failures. An error recorded by neither
|
|
33
|
-
* `recordTimeout` nor `recordSuccess` leaves the counter where it was, so a call
|
|
34
|
-
* path that throws rather than hanging will never trip it.
|
|
35
|
-
*
|
|
36
|
-
* State is per key and held in this instance, which is what keeps two agents in
|
|
37
|
-
* one process from sharing a counter. Construct one per agent and pass a stable
|
|
38
|
-
* key.
|
|
39
|
-
*/
|
|
40
|
-
export declare class CircuitBreaker {
|
|
41
|
-
private readonly opts;
|
|
42
|
-
private readonly states;
|
|
43
|
-
constructor(opts?: CircuitBreakerOptions);
|
|
44
|
-
/** @returns true when the breaker is open and the call should be skipped. */
|
|
45
|
-
shouldSkip(key: string): boolean;
|
|
46
|
-
recordSuccess(key: string): void;
|
|
47
|
-
recordTimeout(key: string): void;
|
|
48
|
-
/** @internal — tests inspect counter state. */
|
|
49
|
-
inspect(key: string): Readonly<KeyState>;
|
|
50
|
-
private now;
|
|
51
|
-
}
|
|
52
|
-
export {};
|
|
53
|
-
//# sourceMappingURL=circuit-breaker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"circuit-breaker.d.ts","sourceRoot":"","sources":["../../src/internal/circuit-breaker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,UAAU,QAAQ;IAChB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;CACzB;AAKD;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAc;IAGb,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+B;gBAEzB,IAAI,GAAE,qBAA0B;IAE7D,6EAA6E;IAC7E,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAWhC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAOhC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAShC,+CAA+C;IAC/C,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC;IAIxC,OAAO,CAAC,GAAG;CAGZ"}
|