@theokit/sdk-memory 0.3.0 → 0.3.2

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 +107 -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 +37 -3
  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 +9 -1
  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 +18 -3
  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 +18 -2
  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 +39 -1
  79. package/dist/internal/tools.d.ts.map +1 -1
  80. package/package.json +7 -6
  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,112 @@
1
1
  # Changelog — @theokit/sdk-memory
2
2
 
3
+ ## 0.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - e3f2a82: Public-API documentation reviewed file by file, and corrected wherever it disagreed
8
+ with the code. The docblocks ship in the `.d.ts`, so these read as behaviour changes
9
+ in an editor even though no behaviour changed.
10
+
11
+ The corrections that change what a caller would do:
12
+
13
+ - **`sdk-cache` documented its own premise backwards.** The header example labelled a
14
+ semantic hit as if it avoided the provider call. `asPlugin()` returns the cached
15
+ answer as `recalledContext`, which the agent loop injects as a `<memory-context>`
16
+ block _before_ the prompt — the request still goes to the provider. The two modes
17
+ are now labelled separately, with a table saying which one short-circuits and which
18
+ one seeds.
19
+ - **`sdk-handoff`'s five error classes said "throw".** Under the plugin wiring the
20
+ handler never throws; every failure becomes a tool result `{"ok":false,…}` handed
21
+ back to the model. Each class now says where it is actually observable. The header
22
+ also told readers to `import { Handoff } from "@theokit/sdk"`, from which it was
23
+ extracted.
24
+ - **`sdk-budget`'s `charge()` claimed idempotency across concurrent calls.** The mutex
25
+ serialises, it does not deduplicate: two identical calls record twice. Related, and
26
+ newly documented: with `maxUsd` set, a model missing from the pricing table denies
27
+ every request rather than passing it — and the table matches by exact string, so
28
+ `"openai/gpt-4o"` does not match `"gpt-4o"`.
29
+ - **The three `memory-*` adapters advertised an env-var fallback they do not read**,
30
+ and their peer dependencies are required rather than optional. Their behavioural
31
+ differences are now stated where they break the "interchangeable adapter"
32
+ assumption — honcho ignores `k` and always throws on `delete`; mem0 recalls across
33
+ sessions by design; supermemory ignores `sessionId` entirely.
34
+ - **`sdk-memory`'s `truncated` flag was documented as its own inverse**, and its
35
+ dreaming sweep claimed a mutex it never takes against the writer it names.
36
+ - **`sdk-tools`** corrected `run_vitest`'s unreachable `no_vitest` code, `truncation`'s
37
+ replacement-character claim, and two return shapes missing a live error code.
38
+ - **`acp`/`cli`** corrected sixteen statements including a named error class that is
39
+ not the one raised, a handler documented as calling `fork()` that refuses
40
+ unconditionally, handlers described as pure that mint ids and mutate a store, a
41
+ config loader credited to Zod in a package that does not import it, and a `--force`
42
+ scaffold described as atomic that deletes the destination before the rename.
43
+
44
+ Undocumented public symbols were documented across every package, with each claim
45
+ checked against the implementation rather than inferred from the name.
46
+
47
+ - e368fc1: Every published declaration file now compiles without `skipLibCheck` (#345). The
48
+ DTS rollup emitted symbols as a re-export from a chunk while omitting them from
49
+ that chunk's `import`, and dropped type-only imports from external packages —
50
+ leaving 51 unresolved references across ten of the twelve packages. Nothing broke
51
+ at runtime, and `tsc` stayed green for anyone with `skipLibCheck` on, but a
52
+ consumer running type-aware lint saw every type reached through one degrade to
53
+ `error`.
54
+
55
+ The declarations are repaired at build time from the compiler's own diagnostics.
56
+ No source or API change.
57
+
58
+ - 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.
59
+
60
+ **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.
61
+
62
+ 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.
63
+
64
+ 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.
65
+
66
+ - c7385d2: Test runs no longer claim every core on the host.
67
+
68
+ None of the package configs capped `maxWorkers`, so vitest's default applied: `os.availableParallelism()`,
69
+ one fork per core, each booting a full test environment. The repo's `test` script is
70
+ `turbo run test --filter='./packages/*'`, so that default is paid once per package _concurrently_ —
71
+ nproc forks times turbo's concurrency, on nproc cores. Measured on a 12-thread machine during an
72
+ unrelated investigation, two vitest pools alone were enough to reach load average 33.89 with the
73
+ desktop unusable; a full fan-out is several times that.
74
+
75
+ `@theokit/sdk` is the interesting case. B-104 recorded on 2026-08-19 that the `poolOptions.forks.*`
76
+ block was 100% dead in Vitest 4, deleted it, and noted that `fileParallelism: false` was forcing
77
+ `maxWorkers` to 1 unconditionally, so a fork-count knob could not act. B-059 then flipped
78
+ `fileParallelism` to `true` on 2026-08-20, which made the knob able to act again — and nothing
79
+ reintroduced one, so the package silently went back to the uncapped default. That comment has been
80
+ corrected along with the config; it claimed no knob existed, which is no longer true.
81
+
82
+ The cap leaves 4 cores free (`Math.max(2, cpus().length - 4)`), scaling with the runner rather than
83
+ hard-coding one machine's core count. It costs no wall-clock: measured in `theokit-ui`, the full
84
+ suite ran 73.96s at 4 workers against 74.36s at 12, so the parallelism above the cap was already
85
+ noise. Verified as resolved config rather than as file contents — `createVitest` reports
86
+ `maxWorkers: 8` on a 12-thread host, which is the formula, not the default.
87
+
88
+ This changes no published behaviour; it is test tooling only. Refs usetheokit/theokit-ui#51.
89
+
90
+ ## 0.3.1
91
+
92
+ ### Patch Changes
93
+
94
+ - 8790f70: Refuse a `workspace:` range before it can reach npm.
95
+
96
+ Five of this repo's twelve publishable packages declare internal dependencies as `workspace:^`, which
97
+ is correct on disk and becomes an unrecoverable defect if the publish goes out through a tool that
98
+ does not rewrite it: `pnpm` resolves the protocol while packing, `npm` ships the manifest verbatim.
99
+ A version published that way fails to install for everyone and cannot be corrected — only
100
+ deprecated.
101
+
102
+ Every publishable package now runs the guard in `prepublishOnly`, so it fires whichever way the
103
+ publish is invoked, and `pnpm release` runs it once across the repo before `changeset publish`.
104
+
105
+ Note for anyone reading a published manifest: the `prepublishOnly` entry points at a path inside
106
+ this repository. It never runs for a consumer — the hook only fires when the package itself is
107
+ published — and guarding the entry point that a hand-run `npm publish` actually uses was worth the
108
+ cosmetic wart of shipping the line.
109
+
3
110
  ## 0.3.0
4
111
 
5
112
  ### Minor 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