@theokit/sdk-memory 0.6.4 → 0.7.4

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/index.cjs +142 -702
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +2 -2
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +17 -669
  8. package/dist/index.js.map +1 -1
  9. package/dist/internal/active-memory/active-memory.d.ts +4 -130
  10. package/dist/internal/active-memory/active-memory.d.ts.map +1 -1
  11. package/dist/internal/adapter-catalog.d.ts +2 -10
  12. package/dist/internal/adapter-catalog.d.ts.map +1 -1
  13. package/dist/internal/embedding/azure-openai-embedding.d.ts +1 -42
  14. package/dist/internal/embedding/azure-openai-embedding.d.ts.map +1 -1
  15. package/dist/internal/embedding/cohere-embedding.d.ts +1 -29
  16. package/dist/internal/embedding/cohere-embedding.d.ts.map +1 -1
  17. package/dist/internal/embedding/deepinfra-embedding.d.ts +1 -30
  18. package/dist/internal/embedding/deepinfra-embedding.d.ts.map +1 -1
  19. package/dist/internal/embedding/gemini-embedding.d.ts +1 -26
  20. package/dist/internal/embedding/gemini-embedding.d.ts.map +1 -1
  21. package/dist/internal/embedding/jina-embedding.d.ts +1 -21
  22. package/dist/internal/embedding/jina-embedding.d.ts.map +1 -1
  23. package/dist/internal/embedding/mistral-embedding.d.ts +1 -23
  24. package/dist/internal/embedding/mistral-embedding.d.ts.map +1 -1
  25. package/dist/internal/embedding/ollama-embedding.d.ts +1 -61
  26. package/dist/internal/embedding/ollama-embedding.d.ts.map +1 -1
  27. package/dist/internal/embedding/openai-embedding.d.ts +1 -33
  28. package/dist/internal/embedding/openai-embedding.d.ts.map +1 -1
  29. package/dist/internal/embedding/openrouter-embedding.d.ts +1 -29
  30. package/dist/internal/embedding/openrouter-embedding.d.ts.map +1 -1
  31. package/dist/internal/embedding/voyage-embedding.d.ts +1 -24
  32. package/dist/internal/embedding/voyage-embedding.d.ts.map +1 -1
  33. package/dist/internal/store/markdown-store.d.ts +1 -1
  34. package/dist/internal/store/markdown-store.d.ts.map +1 -1
  35. package/dist/internal/tools.d.ts +3 -81
  36. package/dist/internal/tools.d.ts.map +1 -1
  37. package/package.json +3 -3
  38. package/dist/internal/circuit-breaker.d.ts +0 -53
  39. package/dist/internal/circuit-breaker.d.ts.map +0 -1
@@ -1,84 +1,6 @@
1
- import type { MemoryIndex } from "./index/memory-index.js";
2
- import type { MemoryRoot } from "./store/markdown-store.js";
3
1
  /**
4
- * Memory tools (`memory_search` + `memory_get`) — ADR D5 of
5
- * memory-system-peer-project-parity. Tool schemas mirror peer-project
6
- * (`reference/peer-project/extensions/memory-core/src/tools.ts:228-475`).
7
- *
8
- * Each tool is exposed as a `MemoryTool` (name + description + JSON schema +
9
- * async execute). The agent-loop integration wires them via the existing
10
- * `ResolvedTool` interface in `tool-dispatch.ts`.
11
- *
12
- * Iter 64 (Stage 3 source-move #21): hybrid copy from sdk-core's
13
- * `internal/memory/tools.ts`. sdk-core retains its copy for v1.x
14
- * memory-tools back-compat; sdk-memory ships the canonical copy.
15
- * Dependency chain (all resolved):
16
- * - `@theokit/sdk/errors` for `ConfigurationError` (public)
17
- * - sibling `./index-manager-contract.js` for `MemorySearchHit`
18
- * (moved iter 47 — note: sdk-core copy imports from
19
- * `./index-manager.js`; sdk-memory uses the contract leaf
20
- * directly since the canonical type lives there)
21
- * - sibling `./memory-index.js` for `MemoryIndex` (moved iter 50)
22
- * - sibling `./markdown-store.js` for `memoryDir` (moved iter 56)
23
- * - sibling `./reader.js` for `readMemoryFileBounded` (moved iter 55)
24
- *
25
- * @internal
2
+ * Memory tools (`memory_search` + `memory_get`) — re-exported from `@theokit/sdk`, not
3
+ * reimplemented here (#1069).
26
4
  */
27
- export interface MemoryToolJson {
28
- name: string;
29
- description: string;
30
- inputSchema: Record<string, unknown>;
31
- }
32
- /**
33
- * A memory tool ready to hand to the agent loop: the JSON-serialisable
34
- * description an LLM sees, plus the `execute` that runs it. `execute` resolves
35
- * to a JSON string — the tool layer does no further encoding.
36
- */
37
- export interface MemoryTool extends MemoryToolJson {
38
- execute(input: Record<string, unknown>): Promise<string>;
39
- }
40
- /** Options for {@link createMemorySearchTool}. */
41
- export interface MemorySearchToolOptions {
42
- index: MemoryIndex;
43
- /** Cap on the JSON response size (EC-10 of edge-case review). Default 16384. */
44
- maxTotalChars?: number;
45
- }
46
- /**
47
- * Build the `memory_search` tool over an index that is already open. The tool
48
- * never opens or syncs anything: if `index.sync()` has not run, the search runs
49
- * against whatever the index last recorded, and a freshly created index returns
50
- * no hits.
51
- *
52
- * The tool accepts `query` (required), `maxResults` (default 10), `minScore`,
53
- * and `corpus`, where `corpus` maps to the index's source filter: `memory`,
54
- * `sessions`, `wiki`, or `all` (the default, which applies no filter). An
55
- * unrecognised `corpus` value is treated as `all` rather than rejected.
56
- *
57
- * `execute` returns `{"hits": [...], "truncated": bool}`. Hits are dropped from
58
- * the tail once their estimated size would exceed `maxTotalChars`, except that
59
- * the first hit is always kept even when it alone exceeds the cap.
60
- *
61
- * Use this for recall by meaning across the whole corpus, and
62
- * {@link createMemoryGetTool} when the model already knows the file and wants
63
- * exact lines.
64
- */
65
- export declare function createMemorySearchTool(opts: MemorySearchToolOptions): MemoryTool;
66
- /** Options for {@link createMemoryGetTool}. `cwd` is the workspace root, not the memory directory. */
67
- export interface MemoryGetToolOptions {
68
- /** The RESOLVED memory root the tool may read inside — not a cwd (#463). */
69
- root: MemoryRoot;
70
- }
71
- /**
72
- * Build the `memory_get` tool, which reads an exact excerpt from a file under
73
- * `<cwd>/.theokit/memory`. Needs no index and no embedding runtime — it is
74
- * plain file reading, so it works in a workspace where search is not configured.
75
- *
76
- * The tool accepts `path` (required, relative to the memory root), `from`
77
- * (1-indexed, default 1) and `lines` (default 200). A `path` whose resolved
78
- * location falls outside the memory root is rejected with a
79
- * `ConfigurationError` carrying the code `memory_path_escapes_root`. A path that
80
- * stays inside but does not exist is not caught here: the underlying read
81
- * rejects with the filesystem error.
82
- */
83
- export declare function createMemoryGetTool(opts: MemoryGetToolOptions): MemoryTool;
5
+ export { createMemoryGetTool, createMemorySearchTool, type MemoryGetToolOptions, type MemorySearchToolOptions, type MemoryTool, type MemoryToolJson, } from "@theokit/sdk/internal/memory-store";
84
6
  //# sourceMappingURL=tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/internal/tools.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAW,SAAQ,cAAc;IAChD,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC1D;AAiCD,kDAAkD;AAClD,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,WAAW,CAAC;IACnB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,uBAAuB,GAAG,UAAU,CAqBhF;AAED,sGAAsG;AACtG,MAAM,WAAW,oBAAoB;IACnC,4EAA4E;IAC5E,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,GAAG,UAAU,CA4B1E"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/internal/tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,UAAU,EACf,KAAK,cAAc,GACpB,MAAM,oCAAoC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theokit/sdk-memory",
3
- "version": "0.6.4",
3
+ "version": "0.7.4",
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": "^5.27.0"
44
+ "@theokit/sdk": "^9.1.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": "5.27.0"
64
+ "@theokit/sdk": "9.1.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"}