@theokit/sdk-memory 0.5.3 → 0.6.1

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 (36) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/in-memory-provider.d.ts +21 -1
  3. package/dist/in-memory-provider.d.ts.map +1 -1
  4. package/dist/index.cjs +178 -498
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +61 -464
  10. package/dist/index.js.map +1 -1
  11. package/dist/internal/active-memory/active-memory-cache.d.ts +1 -66
  12. package/dist/internal/active-memory/active-memory-cache.d.ts.map +1 -1
  13. package/dist/internal/active-memory/active-memory-types.d.ts +1 -54
  14. package/dist/internal/active-memory/active-memory-types.d.ts.map +1 -1
  15. package/dist/internal/adapter-http-error.d.ts.map +1 -1
  16. package/dist/internal/dreaming/dreaming-phases.d.ts +5 -50
  17. package/dist/internal/dreaming/dreaming-phases.d.ts.map +1 -1
  18. package/dist/internal/dreaming/dreaming-run.d.ts +3 -78
  19. package/dist/internal/dreaming/dreaming-run.d.ts.map +1 -1
  20. package/dist/internal/index/index-db.d.ts +1 -67
  21. package/dist/internal/index/index-db.d.ts.map +1 -1
  22. package/dist/internal/index/index-schema.d.ts +1 -29
  23. package/dist/internal/index/index-schema.d.ts.map +1 -1
  24. package/dist/internal/index/memory-index.d.ts +1 -10
  25. package/dist/internal/index/memory-index.d.ts.map +1 -1
  26. package/dist/internal/index/sqlite-vec-loader.d.ts +2 -59
  27. package/dist/internal/index/sqlite-vec-loader.d.ts.map +1 -1
  28. package/dist/internal/index/vec-index.d.ts +1 -131
  29. package/dist/internal/index/vec-index.d.ts.map +1 -1
  30. package/dist/internal/store/chunk-markdown.d.ts +1 -82
  31. package/dist/internal/store/chunk-markdown.d.ts.map +1 -1
  32. package/dist/internal/store/markdown-store.d.ts +1 -1
  33. package/dist/internal/store/markdown-store.d.ts.map +1 -1
  34. package/dist/internal/store/reader.d.ts +1 -86
  35. package/dist/internal/store/reader.d.ts.map +1 -1
  36. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # Changelog — @theokit/sdk-memory
2
2
 
3
+ ## 0.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1145](https://github.com/usetheokit/theokit-sdk/pull/1145) [`07930dc`](https://github.com/usetheokit/theokit-sdk/commit/07930dc7acbfbf09d2506ad6fa8e5bb98f883c65) Thanks [@aifactory-paulohenriquevn](https://github.com/apps/aifactory-paulohenriquevn)! - Re-export the index schema, database opener, sqlite-vec loader, vector index, chunker, reader and active-memory cache and types from `@theokit/sdk` instead of carrying a second copy.
8
+
9
+ ## 0.6.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#724](https://github.com/usetheokit/theokit-sdk/pull/724) [`bc2f665`](https://github.com/usetheokit/theokit-sdk/commit/bc2f665d4c5e03dda26858004ac60bd1f7d3f3bb) Thanks [@usetheodev](https://github.com/usetheodev)! - Memory can now be given a fact ceiling. Once the store is full, a new fact is refused with a
14
+ typed error. Before this, nothing stopped the store growing, and the one cap that did exist, 500
15
+ facts per dreaming sweep, left the rest out of clustering while the result still said
16
+ `status: "ok"`.
17
+
18
+ Set `memory.maxFacts` on an agent to declare a ceiling. A new fact at or over it is refused with a
19
+ `ConfigurationError` whose code is `memory_ceiling_reached`, and nothing is written. The message
20
+ gives the directory, how many facts it holds, the ceiling and what to consolidate. Recording a fact
21
+ that is already stored counts as a second observation, not a new fact, so it is still admitted. A
22
+ value that is not a positive integer is refused with `invalid_memory_ceiling` by `Agent.create`
23
+ and `Agent.resume`, before the agent exists, and again by the writer before anything touches
24
+ disk. A prompt-driven memory write that hits the ceiling reports it on one diagnostic line and
25
+ stores nothing. With no ceiling declared, nothing changes and no extra read happens.
26
+
27
+ The ceiling holds across processes. Every SDK process that writes one memory directory with a
28
+ ceiling takes a lock (`<directory>.lock`, beside the directory) around the count and the write, so
29
+ two processes one fact below the ceiling no longer both get in. The lock needs the optional
30
+ `proper-lockfile` peer. Without it the ceiling holds within one process only, and the SDK says so
31
+ once on its diagnostics channel. A writer that declares no ceiling, such as the Claude Code CLI,
32
+ takes no lock and can still add facts past it.
33
+
34
+ A resumed agent keeps its ceiling and its `memory.directory`. The directory is now saved with the
35
+ agent, and a `memory` object passed to `Agent.resume` replaces only the fields it sets (a field
36
+ set to `undefined` keeps its persisted value). Before
37
+ this, `Agent.resume(id, { memory: { enabled: true } })` came back with no ceiling, and any resumed
38
+ agent wrote to the default store instead of the directory it was created with.
39
+
40
+ `createInMemoryMarkdownProvider({ maxFacts })` in `@theokit/sdk-memory` applies the same ceiling
41
+ to the adapter's `write` and to the `memory_remember` tool. Each handle counts its own facts.
42
+
43
+ `DreamingSweepResult` gains `factsLeftOut`, the number of deduplicated facts past the 500-fact
44
+ cap that a sweep did not cluster. It is reported on both dispatch paths, the `@theokit/sdk-memory`
45
+ peer and the SDK's own fallback. It is 0 on a skipped sweep and absent on a failed one. It is also
46
+ absent when an older `@theokit/sdk-memory` runs the sweep, because that version cannot count it,
47
+ so read absence as unknown, not as 0. `ClusterResult`, which `@theokit/sdk-memory` exports, now
48
+ requires `factsLeftOut` too. Code that builds its own `ClusterResult`, such as a mock of
49
+ `remPhase`, has to add it.
50
+
51
+ `@theokit/sdk-memory` now needs `@theokit/sdk` `^5.10.0`, the first release that exports the
52
+ ceiling helpers it imports.
53
+
3
54
  ## 0.5.3
4
55
 
5
56
  ### Patch Changes
@@ -21,6 +21,26 @@
21
21
  * @public
22
22
  */
23
23
  import type { MemoryProvider } from "@theokit/sdk";
24
+ /**
25
+ * Options for {@link createInMemoryMarkdownProvider}.
26
+ *
27
+ * @public
28
+ */
29
+ export interface InMemoryMarkdownProviderOptions {
30
+ /**
31
+ * The most facts one handle may hold. Default: no ceiling.
32
+ *
33
+ * Each handle counts only its own facts, so two agents on one provider each get the full
34
+ * ceiling.
35
+ *
36
+ * At the ceiling a new fact is refused on both write paths: the adapter's `write` rejects with a
37
+ * `ConfigurationError` whose code is `memory_ceiling_reached`, and the `memory_remember` tool
38
+ * replies `{ ok: false, code, error }`. Nothing is stored either way, and `delete(id)` frees a
39
+ * slot. A value that is not a positive integer throws `invalid_memory_ceiling` when the provider
40
+ * is created.
41
+ */
42
+ maxFacts?: number;
43
+ }
24
44
  /**
25
45
  * Build a fresh `MemoryProvider` whose facts live in-process. The
26
46
  * returned provider is independent — call `createInMemoryMarkdownProvider()`
@@ -34,5 +54,5 @@ import type { MemoryProvider } from "@theokit/sdk";
34
54
  * Future LanceDB-backed impl will replace the substring match with
35
55
  * semantic-similarity ANN over embedding vectors.
36
56
  */
37
- export declare function createInMemoryMarkdownProvider(): MemoryProvider;
57
+ export declare function createInMemoryMarkdownProvider(options?: InMemoryMarkdownProviderOptions): MemoryProvider;
38
58
  //# sourceMappingURL=in-memory-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"in-memory-provider.d.ts","sourceRoot":"","sources":["../src/in-memory-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EASV,cAAc,EAMf,MAAM,cAAc,CAAC;AAyRtB;;;;;;;;;;;;GAYG;AACH,wBAAgB,8BAA8B,IAAI,cAAc,CAoE/D"}
1
+ {"version":3,"file":"in-memory-provider.d.ts","sourceRoot":"","sources":["../src/in-memory-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EASV,cAAc,EAMf,MAAM,cAAc,CAAC;AAQtB;;;;GAIG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAqTD;;;;;;;;;;;;GAYG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,GAAE,+BAAoC,GAC5C,cAAc,CAsEhB"}