@theokit/sdk-memory 0.3.1 → 0.3.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +133 -0
  2. package/LICENSE +2 -2
  3. package/README.md +42 -0
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/active-memory/active-memory-cache.d.ts +18 -0
  7. package/dist/internal/active-memory/active-memory-cache.d.ts.map +1 -1
  8. package/dist/internal/active-memory/active-memory-types.d.ts +25 -0
  9. package/dist/internal/active-memory/active-memory-types.d.ts.map +1 -1
  10. package/dist/internal/active-memory/active-memory.d.ts +54 -29
  11. package/dist/internal/active-memory/active-memory.d.ts.map +1 -1
  12. package/dist/internal/adapter-http-error.d.ts +18 -0
  13. package/dist/internal/adapter-http-error.d.ts.map +1 -1
  14. package/dist/internal/circuit-breaker.d.ts +17 -0
  15. package/dist/internal/circuit-breaker.d.ts.map +1 -1
  16. package/dist/internal/dreaming/dreaming-diary.d.ts +27 -0
  17. package/dist/internal/dreaming/dreaming-diary.d.ts.map +1 -1
  18. package/dist/internal/dreaming/dreaming-phases.d.ts +11 -0
  19. package/dist/internal/dreaming/dreaming-phases.d.ts.map +1 -1
  20. package/dist/internal/dreaming/dreaming-run.d.ts +34 -2
  21. package/dist/internal/dreaming/dreaming-run.d.ts.map +1 -1
  22. package/dist/internal/embedding/azure-openai-embedding.d.ts +22 -0
  23. package/dist/internal/embedding/azure-openai-embedding.d.ts.map +1 -1
  24. package/dist/internal/embedding/cohere-embedding.d.ts +18 -2
  25. package/dist/internal/embedding/cohere-embedding.d.ts.map +1 -1
  26. package/dist/internal/embedding/deepinfra-embedding.d.ts +13 -0
  27. package/dist/internal/embedding/deepinfra-embedding.d.ts.map +1 -1
  28. package/dist/internal/embedding/embedding-adapter.d.ts +36 -2
  29. package/dist/internal/embedding/embedding-adapter.d.ts.map +1 -1
  30. package/dist/internal/embedding/gemini-embedding.d.ts +9 -0
  31. package/dist/internal/embedding/gemini-embedding.d.ts.map +1 -1
  32. package/dist/internal/embedding/jina-embedding.d.ts +9 -0
  33. package/dist/internal/embedding/jina-embedding.d.ts.map +1 -1
  34. package/dist/internal/embedding/mistral-embedding.d.ts +8 -0
  35. package/dist/internal/embedding/mistral-embedding.d.ts.map +1 -1
  36. package/dist/internal/embedding/ollama-embedding.d.ts +21 -0
  37. package/dist/internal/embedding/ollama-embedding.d.ts.map +1 -1
  38. package/dist/internal/embedding/openai-embedding.d.ts +19 -12
  39. package/dist/internal/embedding/openai-embedding.d.ts.map +1 -1
  40. package/dist/internal/embedding/openrouter-embedding.d.ts +12 -0
  41. package/dist/internal/embedding/openrouter-embedding.d.ts.map +1 -1
  42. package/dist/internal/embedding/voyage-embedding.d.ts +9 -0
  43. package/dist/internal/embedding/voyage-embedding.d.ts.map +1 -1
  44. package/dist/internal/index/index-db.d.ts +25 -0
  45. package/dist/internal/index/index-db.d.ts.map +1 -1
  46. package/dist/internal/index/index-manager-contract.d.ts +28 -0
  47. package/dist/internal/index/index-manager-contract.d.ts.map +1 -1
  48. package/dist/internal/index/index-manager.d.ts +29 -0
  49. package/dist/internal/index/index-manager.d.ts.map +1 -1
  50. package/dist/internal/index/lance-index.d.ts +25 -0
  51. package/dist/internal/index/lance-index.d.ts.map +1 -1
  52. package/dist/internal/index/lance-memory-adapter.d.ts +27 -5
  53. package/dist/internal/index/lance-memory-adapter.d.ts.map +1 -1
  54. package/dist/internal/index/memory-index.d.ts +17 -2
  55. package/dist/internal/index/memory-index.d.ts.map +1 -1
  56. package/dist/internal/index/migrate-sqlite-to-lance.d.ts +12 -0
  57. package/dist/internal/index/migrate-sqlite-to-lance.d.ts.map +1 -1
  58. package/dist/internal/index/migration.d.ts +26 -0
  59. package/dist/internal/index/migration.d.ts.map +1 -1
  60. package/dist/internal/index/vec-index.d.ts +67 -16
  61. package/dist/internal/index/vec-index.d.ts.map +1 -1
  62. package/dist/internal/memory-types.d.ts +17 -1
  63. package/dist/internal/memory-types.d.ts.map +1 -1
  64. package/dist/internal/store/chunk-markdown.d.ts +17 -0
  65. package/dist/internal/store/chunk-markdown.d.ts.map +1 -1
  66. package/dist/internal/store/markdown-store.d.ts +26 -0
  67. package/dist/internal/store/markdown-store.d.ts.map +1 -1
  68. package/dist/internal/store/reader.d.ts +26 -3
  69. package/dist/internal/store/reader.d.ts.map +1 -1
  70. package/dist/internal/store/session-loader.d.ts +5 -0
  71. package/dist/internal/store/session-loader.d.ts.map +1 -1
  72. package/dist/internal/store/session-summary-writer.d.ts +14 -0
  73. package/dist/internal/store/session-summary-writer.d.ts.map +1 -1
  74. package/dist/internal/store/transcript-store.d.ts +12 -0
  75. package/dist/internal/store/transcript-store.d.ts.map +1 -1
  76. package/dist/internal/store/wiki-loader.d.ts +11 -0
  77. package/dist/internal/store/wiki-loader.d.ts.map +1 -1
  78. package/dist/internal/tools.d.ts +38 -0
  79. package/dist/internal/tools.d.ts.map +1 -1
  80. package/package.json +8 -7
  81. package/dist/internal/active-memory/composite-scorer.d.ts +0 -19
  82. package/dist/internal/active-memory/composite-scorer.d.ts.map +0 -1
  83. package/dist/internal/active-memory/query-analyzer.d.ts +0 -16
  84. package/dist/internal/active-memory/query-analyzer.d.ts.map +0 -1
  85. package/dist/internal/embedding/batch-encoder.d.ts +0 -30
  86. package/dist/internal/embedding/batch-encoder.d.ts.map +0 -1
  87. package/dist/internal/memory-scope.d.ts +0 -21
  88. package/dist/internal/memory-scope.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,138 @@
1
1
  # Changelog — @theokit/sdk-memory
2
2
 
3
+ ## 0.3.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 1a4bbcf: The declared `@theokit/sdk` peer ranges stop promising versions the packages do not compile against.
8
+
9
+ All three declared `>=4.0.0`. `4.0.1` is the lowest published version that range admits — what a
10
+ consumer pinning conservatively, or resolving under an older transitive constraint, lands on. npm
11
+ resolves the combination with no `ERESOLVE` and no peer warning, and the build then fails on
12
+ `TS2552: Cannot find name` and `TS2305: has no exported member`.
13
+
14
+ The floors were measured by bisecting the 116 stable 4.x releases with a real build as the oracle.
15
+ Each one has its immediately preceding version failing, so these are exact versions rather than
16
+ intervals:
17
+
18
+ | package | floor | evidence |
19
+ | ---------------------- | ---------- | ------------------------------- |
20
+ | `@theokit/sdk-budget` | `>=4.54.0` | `4.53.1` fails, `4.54.0` passes |
21
+ | `@theokit/sdk-handoff` | `>=4.54.0` | `4.53.1` fails, `4.54.0` passes |
22
+ | `@theokit/sdk-memory` | `>=4.53.1` | `4.53.0` fails, `4.53.1` passes |
23
+
24
+ `sdk-memory` sits one release below the other two: this is not one shared migration, it is three
25
+ packages that each drifted past their own declared floor.
26
+
27
+ The oracle deletes every `dist/` before building. Without that the build reads a sibling's output
28
+ compiled against a different version, which is how a package "passes" against an SDK missing its
29
+ symbols — the failure mode that made the earlier measurement disagree with CI
30
+ (usetheokit/theokit-sdk#423).
31
+
32
+ - 4b5e468: Raises the `@theokit/sdk` peer floor from `>=4.53.1` to `>=4.54.0`.
33
+
34
+ Not because this package outgrew 4.53.1 — because **4.53.1's own published declarations do not
35
+ compile**. Building against it fails inside the SDK's `.d.ts`, not in any code here:
36
+
37
+ ```
38
+ @theokit/sdk/dist/index.d.ts(350,24): error TS2552: Cannot find name 'AgentBuilderDeps'
39
+ @theokit/sdk/dist/index.d.ts(3004,15): error TS2304: Cannot find name 'DECLARED'
40
+ ```
41
+
42
+ #345 (`e368fc18`) bound the re-exported names the rollup had left unimported, and first shipped in
43
+ 4.54.0. A floor that names 4.53.1 therefore promises a version nobody can build against.
44
+
45
+ Worth separating from the sibling fixes in this release: those floors were wrong because the code
46
+ had outgrown them. This one is wrong because the version it names is broken — a distinct reason to
47
+ audit a floor, now recorded beside it.
48
+
49
+ ## 0.3.2
50
+
51
+ ### Patch Changes
52
+
53
+ - e3f2a82: Public-API documentation reviewed file by file, and corrected wherever it disagreed
54
+ with the code. The docblocks ship in the `.d.ts`, so these read as behaviour changes
55
+ in an editor even though no behaviour changed.
56
+
57
+ The corrections that change what a caller would do:
58
+
59
+ - **`sdk-cache` documented its own premise backwards.** The header example labelled a
60
+ semantic hit as if it avoided the provider call. `asPlugin()` returns the cached
61
+ answer as `recalledContext`, which the agent loop injects as a `<memory-context>`
62
+ block _before_ the prompt — the request still goes to the provider. The two modes
63
+ are now labelled separately, with a table saying which one short-circuits and which
64
+ one seeds.
65
+ - **`sdk-handoff`'s five error classes said "throw".** Under the plugin wiring the
66
+ handler never throws; every failure becomes a tool result `{"ok":false,…}` handed
67
+ back to the model. Each class now says where it is actually observable. The header
68
+ also told readers to `import { Handoff } from "@theokit/sdk"`, from which it was
69
+ extracted.
70
+ - **`sdk-budget`'s `charge()` claimed idempotency across concurrent calls.** The mutex
71
+ serialises, it does not deduplicate: two identical calls record twice. Related, and
72
+ newly documented: with `maxUsd` set, a model missing from the pricing table denies
73
+ every request rather than passing it — and the table matches by exact string, so
74
+ `"openai/gpt-4o"` does not match `"gpt-4o"`.
75
+ - **The three `memory-*` adapters advertised an env-var fallback they do not read**,
76
+ and their peer dependencies are required rather than optional. Their behavioural
77
+ differences are now stated where they break the "interchangeable adapter"
78
+ assumption — honcho ignores `k` and always throws on `delete`; mem0 recalls across
79
+ sessions by design; supermemory ignores `sessionId` entirely.
80
+ - **`sdk-memory`'s `truncated` flag was documented as its own inverse**, and its
81
+ dreaming sweep claimed a mutex it never takes against the writer it names.
82
+ - **`sdk-tools`** corrected `run_vitest`'s unreachable `no_vitest` code, `truncation`'s
83
+ replacement-character claim, and two return shapes missing a live error code.
84
+ - **`acp`/`cli`** corrected sixteen statements including a named error class that is
85
+ not the one raised, a handler documented as calling `fork()` that refuses
86
+ unconditionally, handlers described as pure that mint ids and mutate a store, a
87
+ config loader credited to Zod in a package that does not import it, and a `--force`
88
+ scaffold described as atomic that deletes the destination before the rename.
89
+
90
+ Undocumented public symbols were documented across every package, with each claim
91
+ checked against the implementation rather than inferred from the name.
92
+
93
+ - e368fc1: Every published declaration file now compiles without `skipLibCheck` (#345). The
94
+ DTS rollup emitted symbols as a re-export from a chunk while omitting them from
95
+ that chunk's `import`, and dropped type-only imports from external packages —
96
+ leaving 51 unresolved references across ten of the twelve packages. Nothing broke
97
+ at runtime, and `tsc` stayed green for anyone with `skipLibCheck` on, but a
98
+ consumer running type-aware lint saw every type reached through one degrade to
99
+ `error`.
100
+
101
+ The declarations are repaired at build time from the compiler's own diagnostics.
102
+ No source or API change.
103
+
104
+ - e699569: **The repository moved to the official `usetheokit` organization.** Every `repository`, `bugs` and `homepage` field now points there, along with the README, `CONTRIBUTING.md`, `SECURITY.md` and the issue templates. Existing clones and any URL already published keep working — GitHub redirects a transferred repository permanently — so this is a correctness fix for the metadata npm renders, not a break.
105
+
106
+ **The Apache-2.0 text every package ships was replaced with the official one.** The copy distributed until now had paragraph 4(d) truncated: it read "except as required for describing the origin of the Work and reproducing the content of the NOTICE file", dropping "reasonable and customary use" from the licensed clause. §4(d) governs what a redistributor must do with attribution notices, and the omission narrowed it.
107
+
108
+ That matters more than a typo would. The manifests declare the SPDX identifier `Apache-2.0`, which is an assertion that the terms are _the_ Apache-2.0 terms — a licence scanner resolves the identifier and never reads the file. A consumer's compliance review, which does read the file, would find a body that no longer matches the identifier and has no name of its own. Every `LICENSE` in this repository is now byte-identical to the canonical text, with the appendix filled in.
109
+
110
+ Nothing else about the terms changed: the licence is the same licence it has always been meant to be, and no package changes what it grants.
111
+
112
+ - c7385d2: Test runs no longer claim every core on the host.
113
+
114
+ None of the package configs capped `maxWorkers`, so vitest's default applied: `os.availableParallelism()`,
115
+ one fork per core, each booting a full test environment. The repo's `test` script is
116
+ `turbo run test --filter='./packages/*'`, so that default is paid once per package _concurrently_ —
117
+ nproc forks times turbo's concurrency, on nproc cores. Measured on a 12-thread machine during an
118
+ unrelated investigation, two vitest pools alone were enough to reach load average 33.89 with the
119
+ desktop unusable; a full fan-out is several times that.
120
+
121
+ `@theokit/sdk` is the interesting case. B-104 recorded on 2026-08-19 that the `poolOptions.forks.*`
122
+ block was 100% dead in Vitest 4, deleted it, and noted that `fileParallelism: false` was forcing
123
+ `maxWorkers` to 1 unconditionally, so a fork-count knob could not act. B-059 then flipped
124
+ `fileParallelism` to `true` on 2026-08-20, which made the knob able to act again — and nothing
125
+ reintroduced one, so the package silently went back to the uncapped default. That comment has been
126
+ corrected along with the config; it claimed no knob existed, which is no longer true.
127
+
128
+ The cap leaves 4 cores free (`Math.max(2, cpus().length - 4)`), scaling with the runner rather than
129
+ hard-coding one machine's core count. It costs no wall-clock: measured in `theokit-ui`, the full
130
+ suite ran 73.96s at 4 workers against 74.36s at 12, so the parallelism above the cap was already
131
+ noise. Verified as resolved config rather than as file contents — `createVitest` reports
132
+ `maxWorkers: 8` on a 12-thread host, which is the formula, not the default.
133
+
134
+ This changes no published behaviour; it is test tooling only. Refs usetheokit/theokit-ui#51.
135
+
3
136
  ## 0.3.1
4
137
 
5
138
  ### Patch Changes
package/LICENSE CHANGED
@@ -137,8 +137,8 @@
137
137
 
138
138
  6. Trademarks. This License does not grant permission to use the trade
139
139
  names, trademarks, service marks, or product names of the Licensor,
140
- except as required for describing the origin of the Work and
141
- reproducing the content of the NOTICE file.
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
142
 
143
143
  7. Disclaimer of Warranty. Unless required by applicable law or
144
144
  agreed to in writing, Licensor provides the Work (and each
package/README.md CHANGED
@@ -4,6 +4,35 @@ Memory subsystem for [`@theokit/sdk`](https://www.npmjs.com/package/@theokit/sdk
4
4
  Implements the kernel-facing `MemoryProvider` port (SDK 2.0 Phase 1 / T1.1 —
5
5
  Hexagonal Architecture / SOLID Dependency Inversion).
6
6
 
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @theokit/sdk-memory
11
+ ```
12
+
13
+ `@theokit/sdk` (>=4.0.0) is a peer dependency. Three more are OPTIONAL, and which you need depends
14
+ on the backend you ask for — the in-memory markdown provider needs none of them:
15
+
16
+ ```bash
17
+ pnpm add better-sqlite3 # only when your Node has no built-in `node:sqlite`
18
+ pnpm add sqlite-vec # vector recall; without it, search is text-only
19
+ pnpm add @lancedb/lancedb # `backend: "lance"`, for large corpora
20
+ ```
21
+
22
+ The three behave differently when absent, and the difference is worth knowing before you debug a
23
+ thin answer:
24
+
25
+ - **`better-sqlite3`** — the driver is chosen at runtime. `node:sqlite` is used where the running
26
+ Node exposes it (22.5+), and this package is the fallback. Opening fails only on a Node without
27
+ the built-in AND without this installed.
28
+ - **`sqlite-vec`** — the index opens without it and reports `backend: "fts-only"`. Search still
29
+ works, by TEXT only; no vector table is created. This is a silent degradation by design, so check
30
+ `index.status().backend` when recall seems shallow.
31
+ - **`@lancedb/lancedb`** — asking for `backend: "lance"` without it raises
32
+ `ConfigurationError({ code: "lance_backend_unavailable" })` at open time, naming the install
33
+ command. No silent fallback, because a large-corpus backend quietly becoming a small one is worse
34
+ than a refusal.
35
+
7
36
  ```ts
8
37
  import { Agent } from "@theokit/sdk";
9
38
  import { createInMemoryMarkdownProvider } from "@theokit/sdk-memory";
@@ -81,6 +110,19 @@ hook points (init / buildTools / runActivePass / dispose). Your impl
81
110
  fulfills the contract; sdk-core never imports this package directly —
82
111
  that's the seam that makes the split possible.
83
112
 
113
+ ## API reference
114
+
115
+ Every symbol this package exports, with the exact specifier to import it from, is in the generated
116
+ capability map that ships inside `@theokit/sdk`:
117
+
118
+ ```
119
+ node_modules/@theokit/sdk/docs/harness-capability-map.md # symbol -> import specifier
120
+ node_modules/@theokit/sdk/docs/error-codes.md # every `code` an error can carry
121
+ ```
122
+
123
+ Both are generated from the built type declarations, so they describe the version you installed
124
+ rather than the version someone wrote a page about.
125
+
84
126
  ## License
85
127
 
86
128
  Apache-2.0 © useTheo