@theokit/sdk 4.61.0 → 4.63.0

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 (114) hide show
  1. package/CHANGELOG.md +139 -0
  2. package/dist/{agent-P42GA6RM.js → agent-536OOESZ.js} +8 -6
  3. package/dist/{agent-P42GA6RM.js.map → agent-536OOESZ.js.map} +1 -1
  4. package/dist/{agent-M53C3PAA.cjs → agent-5KYMG63I.cjs} +9 -7
  5. package/dist/{agent-M53C3PAA.cjs.map → agent-5KYMG63I.cjs.map} +1 -1
  6. package/dist/{agent-DIu6FooJ.d.ts → agent-BFno7Sfn.d.ts} +36 -21
  7. package/dist/{agent-D3Xr_-6Z.d.cts → agent-X0DKA943.d.cts} +36 -21
  8. package/dist/chunk-A4RAL2ER.cjs +51 -0
  9. package/dist/chunk-A4RAL2ER.cjs.map +1 -0
  10. package/dist/chunk-A4VHSE56.cjs +21 -0
  11. package/dist/chunk-A4VHSE56.cjs.map +1 -0
  12. package/dist/{chunk-CQ2TQ32Y.js → chunk-AMFXSENK.js} +3 -48
  13. package/dist/chunk-AMFXSENK.js.map +1 -0
  14. package/dist/chunk-C7QPML3L.js +831 -0
  15. package/dist/chunk-C7QPML3L.js.map +1 -0
  16. package/dist/{chunk-5IT6DUOO.cjs → chunk-CASUEY42.cjs} +4 -4
  17. package/dist/{chunk-5IT6DUOO.cjs.map → chunk-CASUEY42.cjs.map} +1 -1
  18. package/dist/{chunk-GQZKDGZM.js → chunk-CHKH5452.js} +90 -70
  19. package/dist/chunk-CHKH5452.js.map +1 -0
  20. package/dist/chunk-EHJEZAOO.cjs +864 -0
  21. package/dist/chunk-EHJEZAOO.cjs.map +1 -0
  22. package/dist/chunk-IRCJ7EHV.cjs +201 -0
  23. package/dist/chunk-IRCJ7EHV.cjs.map +1 -0
  24. package/dist/chunk-LW7G5DYW.js +19 -0
  25. package/dist/chunk-LW7G5DYW.js.map +1 -0
  26. package/dist/{chunk-532CSLYU.js → chunk-MG3SOM3M.js} +3 -3
  27. package/dist/{chunk-532CSLYU.js.map → chunk-MG3SOM3M.js.map} +1 -1
  28. package/dist/{chunk-R7YIVL3K.cjs → chunk-NLXOGBRJ.cjs} +98 -78
  29. package/dist/chunk-NLXOGBRJ.cjs.map +1 -0
  30. package/dist/{chunk-SKXBJ2NU.cjs → chunk-NXH4GPAQ.cjs} +2 -49
  31. package/dist/chunk-NXH4GPAQ.cjs.map +1 -0
  32. package/dist/chunk-R6TA2DRJ.js +194 -0
  33. package/dist/chunk-R6TA2DRJ.js.map +1 -0
  34. package/dist/{chunk-6OBIWHDR.cjs → chunk-UUP3MUZ6.cjs} +20 -361
  35. package/dist/chunk-UUP3MUZ6.cjs.map +1 -0
  36. package/dist/chunk-WE22OXQA.js +48 -0
  37. package/dist/chunk-WE22OXQA.js.map +1 -0
  38. package/dist/{chunk-QEKI3YKI.js → chunk-YTR3RBUZ.js} +13 -348
  39. package/dist/chunk-YTR3RBUZ.js.map +1 -0
  40. package/dist/{cron-BcWmzWzT.d.cts → cron-BuiRPrvt.d.cts} +1 -1
  41. package/dist/{cron-De6hzWCF.d.ts → cron-C2SIi31n.d.ts} +1 -1
  42. package/dist/cron.cjs +8 -6
  43. package/dist/cron.d.cts +2 -2
  44. package/dist/cron.d.ts +2 -2
  45. package/dist/cron.js +7 -5
  46. package/dist/eval.cjs +7 -5
  47. package/dist/eval.cjs.map +1 -1
  48. package/dist/eval.js +6 -4
  49. package/dist/eval.js.map +1 -1
  50. package/dist/{index-manager-RHPFVFSC.cjs → index-manager-6TEEIWM7.cjs} +7 -6
  51. package/dist/{index-manager-RHPFVFSC.cjs.map → index-manager-6TEEIWM7.cjs.map} +1 -1
  52. package/dist/{index-manager-AHAYJ33H.js → index-manager-ACEQG3IJ.js} +6 -5
  53. package/dist/{index-manager-AHAYJ33H.js.map → index-manager-ACEQG3IJ.js.map} +1 -1
  54. package/dist/index.cjs +35 -208
  55. package/dist/index.cjs.map +1 -1
  56. package/dist/index.d.cts +8 -3
  57. package/dist/index.d.ts +8 -3
  58. package/dist/index.js +22 -195
  59. package/dist/index.js.map +1 -1
  60. package/dist/internal/memory/active-memory.d.ts +8 -1
  61. package/dist/internal/memory/dreaming/diary.d.ts +39 -2
  62. package/dist/internal/memory/index-db.d.ts +44 -1
  63. package/dist/internal/memory/index-manager-contract.d.ts +10 -0
  64. package/dist/internal/memory/index-manager-helpers.d.ts +20 -1
  65. package/dist/internal/memory/index-manager.d.ts +1 -1
  66. package/dist/internal/memory/lance-index.d.ts +15 -1
  67. package/dist/internal/memory/migrate-sqlite-to-lance.d.ts +43 -0
  68. package/dist/internal/memory/storage/index.cjs +95 -12
  69. package/dist/internal/memory/storage/index.d.cts +11 -1
  70. package/dist/internal/memory/storage/index.d.ts +11 -1
  71. package/dist/internal/memory/storage/index.js +4 -1
  72. package/dist/internal/memory/storage/markdown-store.d.cts +13 -42
  73. package/dist/internal/memory/storage/markdown-store.d.ts +13 -42
  74. package/dist/internal/memory/storage/memory-root.d.cts +93 -0
  75. package/dist/internal/memory/storage/memory-root.d.ts +93 -0
  76. package/dist/internal/memory/storage/session-loader.d.cts +35 -1
  77. package/dist/internal/memory/storage/session-loader.d.ts +35 -1
  78. package/dist/internal/memory/storage/session-summary-writer.d.cts +50 -2
  79. package/dist/internal/memory/storage/session-summary-writer.d.ts +50 -2
  80. package/dist/internal/memory/storage/transcript-store.d.cts +38 -1
  81. package/dist/internal/memory/storage/transcript-store.d.ts +38 -1
  82. package/dist/internal/memory/storage/wiki-loader.d.cts +27 -2
  83. package/dist/internal/memory/storage/wiki-loader.d.ts +27 -2
  84. package/dist/internal/memory/tools.d.ts +8 -1
  85. package/dist/internal/memory/types.d.ts +5 -0
  86. package/dist/internal/persistence/index.cjs +12 -11
  87. package/dist/internal/persistence/index.cjs.map +1 -1
  88. package/dist/internal/persistence/index.js +2 -1
  89. package/dist/internal/persistence/index.js.map +1 -1
  90. package/dist/internal/persistence/session-dir.d.cts +0 -15
  91. package/dist/internal/persistence/session-dir.d.ts +0 -15
  92. package/dist/internal/runtime/memory/memory-store.d.ts +2 -2
  93. package/dist/persistence.cjs +9 -8
  94. package/dist/persistence.cjs.map +1 -1
  95. package/dist/persistence.js +2 -1
  96. package/dist/persistence.js.map +1 -1
  97. package/dist/subagents-loader.d.cts +1 -1
  98. package/dist/subagents-loader.d.ts +1 -1
  99. package/dist/types/agent.d.ts +11 -0
  100. package/dist/types/memory-provider.d.ts +8 -0
  101. package/docs/error-codes.md +10 -9
  102. package/docs/harness-capability-map.md +57 -17
  103. package/docs/memory-decisions.md +44 -7
  104. package/package.json +1 -1
  105. package/dist/chunk-2UCFUSPW.cjs +0 -468
  106. package/dist/chunk-2UCFUSPW.cjs.map +0 -1
  107. package/dist/chunk-6OBIWHDR.cjs.map +0 -1
  108. package/dist/chunk-CQ2TQ32Y.js.map +0 -1
  109. package/dist/chunk-GQZKDGZM.js.map +0 -1
  110. package/dist/chunk-QEKI3YKI.js.map +0 -1
  111. package/dist/chunk-R7YIVL3K.cjs.map +0 -1
  112. package/dist/chunk-SKXBJ2NU.cjs.map +0 -1
  113. package/dist/chunk-WCLDJSMY.js +0 -456
  114. package/dist/chunk-WCLDJSMY.js.map +0 -1
@@ -3,6 +3,7 @@ import { type TelemetryHandle } from "../telemetry/tracer.js";
3
3
  import type { ActiveMemoryCache } from "./active-memory-cache.js";
4
4
  import type { ActiveMemoryQueryMode, ActiveMemoryResult, ActiveMemoryStatus } from "./active-memory-types.js";
5
5
  import type { MemoryIndex } from "./memory-index.js";
6
+ import { type MemoryRoot } from "./storage/memory-root.js";
6
7
  export type { ActiveMemoryQueryMode, ActiveMemoryResult, ActiveMemoryStatus };
7
8
  export interface RunActiveMemoryArgs {
8
9
  userText: string;
@@ -18,7 +19,13 @@ export interface RunActiveMemoryArgs {
18
19
  cache?: ActiveMemoryCache;
19
20
  /** Workspace root for transcript persistence. */
20
21
  cwd?: string;
21
- /** When true, write transcript JSON under .theokit/memory/transcripts/active-memory/. */
22
+ /**
23
+ * The memory root the caller already resolved. Falls back to the project store, which is right
24
+ * for a caller that has no `memory.directory` and wrong for one that does — so an agent passes
25
+ * its own (#463).
26
+ */
27
+ memoryRoot?: MemoryRoot;
28
+ /** When true, write transcript JSON under `<memory root>/transcripts/active-memory/`. */
22
29
  persistTranscripts?: boolean;
23
30
  /** Stable key the breaker + cache key by (default `default`). */
24
31
  agentKey?: string;
@@ -1,4 +1,41 @@
1
- export declare function diaryPath(cwd: string): string;
1
+ import type { MemoryRoot } from "../storage/memory-root.js";
2
+ /**
3
+ * Dream-diary append (ADR D7).
4
+ *
5
+ * Diary lives at `.theokit/memory/dream-diary.md` and grows with one entry
6
+ * per sweep. Each entry is content-hashed so the same input produces the
7
+ * same entry — idempotency contract.
8
+ *
9
+ * Writes go through `replaceFileAtomic` (EC-3 of edge-case review) so a
10
+ * crash mid-write can never leave a half-written diary.
11
+ *
12
+ * Shared with `@theokit/sdk-memory`; see the memory-store barrel.
13
+ */
14
+ export interface DiaryEntry {
15
+ timestampMs: number;
16
+ factsBefore: number;
17
+ factsAfter: number;
18
+ duplicatesRemoved: number;
19
+ clustersCreated: number;
20
+ notesWritten: number;
21
+ }
22
+ /** `<memory root>/dream-diary.md`. Takes the RESOLVED ROOT — see `storage/memory-root.ts` (#463). */
23
+ export declare function diaryPath(root: MemoryRoot): string;
24
+ /**
25
+ * One diary entry as the markdown that gets appended: a timestamp heading, the short entry hash,
26
+ * and the counts the sweep produced. The hash is what makes a re-run recognisable as the same
27
+ * sweep rather than a new one.
28
+ */
2
29
  export declare function renderDiaryEntry(entry: DiaryEntry): string;
3
- export declare function appendDiaryEntry(cwd: string, entry: DiaryEntry): Promise<void>;
30
+ /**
31
+ * Append one sweep's entry to `<memory root>/dream-diary.md`, creating the file with its header
32
+ * when this is the first sweep. The diary is a human-readable record of what dreaming changed —
33
+ * consolidations are otherwise invisible, because they alter the notes rather than announce
34
+ * themselves.
35
+ */
36
+ export declare function appendDiaryEntry(root: MemoryRoot, entry: DiaryEntry): Promise<void>;
37
+ /**
38
+ * A stable hash of one entry's counts, so two sweeps that did the same work read as the same work.
39
+ * Rendered truncated in the entry; the full value is what callers compare.
40
+ */
4
41
  export declare function entryHash(entry: DiaryEntry): string;
@@ -1,3 +1,32 @@
1
+ import type { MemoryRoot } from "./storage/memory-root.js";
2
+ /**
3
+ * Memory index DB handle + opener.
4
+ *
5
+ * M0-5 (plan m0-foundation-expose-primitives): the driver-load + WAL +
6
+ * corruption-recovery (EC-7) plumbing is now the shared `openSqliteResilient`
7
+ * primitive in `internal/persistence`; this module only declares the memory
8
+ * schema application (PRAGMA + SCHEMA) via its `onOpen` callback.
9
+ *
10
+ * Shared with `@theokit/sdk-memory`; see the memory-store barrel.
11
+ */
12
+ export interface MemoryDb {
13
+ exec(sql: string): void;
14
+ prepare(sql: string): {
15
+ run(...args: unknown[]): {
16
+ changes: number;
17
+ lastInsertRowid: number | bigint;
18
+ };
19
+ get(...args: unknown[]): Record<string, unknown> | undefined;
20
+ all(...args: unknown[]): Array<Record<string, unknown>>;
21
+ };
22
+ /** SQLite `pragma()` access (used by `applyWalWithFallback`). */
23
+ pragma(statement: string, options?: {
24
+ simple?: boolean;
25
+ }): unknown;
26
+ close(): void;
27
+ /** Load a SQLite loadable extension at the given path (used by sqlite-vec). */
28
+ loadExtension(path: string): void;
29
+ }
1
30
  export interface OpenDbOptions {
2
31
  filePath: string;
3
32
  /**
@@ -7,4 +36,18 @@ export interface OpenDbOptions {
7
36
  recoverCorrupt?: boolean;
8
37
  }
9
38
  export declare function openMemoryDb(opts: OpenDbOptions): Promise<MemoryDb>;
10
- export declare function defaultIndexPath(cwd: string): string;
39
+ /**
40
+ * `<index root>/.index/memory.sqlite`. Pure path computation.
41
+ *
42
+ * Takes a resolved root rather than a `cwd`: this function used to spell the default layout out
43
+ * again as a string literal — an answer to "where does memory live?" that no search for the shared
44
+ * helper would have found (#463).
45
+ *
46
+ * **The root it is given is the PROJECT store, even when the facts move.** `memory.directory` may
47
+ * point at the directory the Claude Code CLI manages, and that CLI has no index format — putting a
48
+ * binary artefact it does not understand inside a directory it owns is a different decision from
49
+ * putting the facts there, and it was made deliberately. The facts are what a user would lose; the
50
+ * index is derived and rebuildable from them. See `docs/memory-decisions.md` § 1 before relocating
51
+ * this, and `IndexManager.openSqliteInternal` for the caller that keeps the two apart.
52
+ */
53
+ export declare function defaultIndexPath(root: MemoryRoot): string;
@@ -1,4 +1,5 @@
1
1
  import type { EmbeddingRuntime } from "./embedding-adapter.js";
2
+ import type { MemoryRoot } from "./storage/memory-root.js";
2
3
  export interface IndexStatus {
3
4
  backend: "fts-only" | "hybrid";
4
5
  filesIndexed: number;
@@ -18,6 +19,15 @@ export interface SearchOptions {
18
19
  export type MemoryBackend = "sqlite-vec" | "lance";
19
20
  export interface OpenIndexOptions {
20
21
  cwd: string;
22
+ /**
23
+ * The memory root to index and to place the database under. Defaults to `<cwd>/.theokit/memory`.
24
+ *
25
+ * Optional HERE and required everywhere below, deliberately. This is a public entry point whose
26
+ * caller may legitimately have only a workspace; inside an agent the root is resolved once from
27
+ * `memory.directory` and passed in, which is what keeps the index and the writer looking at the
28
+ * same directory (#463).
29
+ */
30
+ memoryRoot?: MemoryRoot;
21
31
  filePath?: string;
22
32
  /** When provided, vector index is enabled in hybrid mode. */
23
33
  embedding?: EmbeddingRuntime;
@@ -1 +1,20 @@
1
- export {};
1
+ import type { MemoryRoot } from "./storage/memory-root.js";
2
+ /**
3
+ * One markdown file the corpus walk found, with the source bucket the indexer tags it with.
4
+ * Shared through the semver-exempt `internal/memory-store` sub-path, so it carries no
5
+ * visibility tag — see that barrel for why naming the tag here would delete this symbol.
6
+ */
7
+ export interface DiscoveredFile {
8
+ absolutePath: string;
9
+ relPath: string;
10
+ source: "memory" | "wiki" | "sessions";
11
+ }
12
+ /**
13
+ * Every markdown file the memory corpus holds: the index, the per-memory files, `notes/`,
14
+ * `wiki/` and `sessions/`, each tagged with the bucket `memory_search`'s `corpus` filters on.
15
+ *
16
+ * Shared through the semver-exempt `internal/memory-store` sub-path so `@theokit/sdk-memory` walks
17
+ * the same corpus. Its own copy did not: it never picked up the per-memory files at the root, so
18
+ * installing that package made every converged memory unsearchable and reported nothing.
19
+ */
20
+ export declare function collectMarkdownFiles(root: MemoryRoot): Promise<DiscoveredFile[]>;
@@ -1,7 +1,7 @@
1
1
  import { type MemoryIndex } from "./memory-index.js";
2
2
  import type { IndexStatus, MemorySearchHit, OpenIndexOptions, SearchOptions } from "./index-manager-contract.js";
3
3
  export declare class IndexManager implements MemoryIndex {
4
- private readonly cwd;
4
+ private readonly memoryRoot;
5
5
  private readonly db;
6
6
  private readonly embedding;
7
7
  private lastSyncMs;
@@ -1,4 +1,5 @@
1
1
  import type { EmbeddingRuntime } from "./embedding-adapter.js";
2
+ import { type MemoryRoot } from "./storage/memory-root.js";
2
3
  export interface LanceFactRecord {
3
4
  id: string;
4
5
  text: string;
@@ -11,8 +12,10 @@ export interface LanceFactRecord {
11
12
  }
12
13
  export interface OpenLanceOptions {
13
14
  cwd: string;
15
+ /** The resolved memory root. Defaults to `<cwd>/.theokit/memory` (#463). */
16
+ memoryRoot?: MemoryRoot;
14
17
  embedding: EmbeddingRuntime;
15
- /** Override storage location. Default: `<cwd>/.theokit/memory/lance/`. */
18
+ /** Override storage location. Default: `<memory root>/lance/`. */
16
19
  storagePath?: string;
17
20
  }
18
21
  export interface LanceSearchOptions {
@@ -30,3 +33,14 @@ export interface LanceSearchHit {
30
33
  userId: string;
31
34
  score: number;
32
35
  }
36
+ /**
37
+ * `<memory root>/lance`.
38
+ *
39
+ * Takes the RESOLVED ROOT. This used to spell the default layout out again as a string literal,
40
+ * beside a second copy of the same literal in `open()` — two more answers to "where does memory
41
+ * live?" that no `memoryDir` search would have surfaced (#463).
42
+ *
43
+ * Shared with `@theokit/sdk-memory` through the memory-store barrel, so it carries no
44
+ * visibility tag — naming that tag in this block would delete the function below it (#463).
45
+ */
46
+ export declare function lanceStoragePath(root: MemoryRoot): string;
@@ -1,3 +1,23 @@
1
+ import { type MemoryRoot } from "./storage/memory-root.js";
2
+ /**
3
+ * Migrate Memory.index from SQLite to LanceDB (ADR D44).
4
+ *
5
+ * EC-3 MUST FIX: validation uses NFC unicode normalization on both sides.
6
+ *
7
+ * Shared with `@theokit/sdk-memory` through the memory-store barrel (#463).
8
+ */
9
+ export interface MigrateOptions {
10
+ cwd: string;
11
+ /**
12
+ * Absolute path (or `~/`-prefixed) of the memory root to migrate, when the agent that wrote it
13
+ * set `memory.directory`. Defaults to `<cwd>/.theokit/memory` (#463).
14
+ */
15
+ directory?: string;
16
+ dryRun?: boolean;
17
+ batchSize?: number;
18
+ /** Inject for tests; defaults to console.log. */
19
+ logger?: (msg: string) => void;
20
+ }
1
21
  export interface MigrateResult {
2
22
  countSqlite: number;
3
23
  countLance: number;
@@ -13,3 +33,26 @@ export interface MigrateResult {
13
33
  /** Was the migration committed (false for dry-run). */
14
34
  committed: boolean;
15
35
  }
36
+ /**
37
+ * One row of the SQLite memory index, as the Lance migration reads it: the chunk plus the tenant
38
+ * columns the target table needs. Shared with `@theokit/sdk-memory`, which migrates the same table.
39
+ */
40
+ export interface SqliteFactRow {
41
+ id: string;
42
+ path: string;
43
+ source: "memory" | "sessions" | "wiki";
44
+ start_line: number;
45
+ end_line: number;
46
+ text: string;
47
+ namespace?: string | null;
48
+ scope?: string | null;
49
+ user_id?: string | null;
50
+ }
51
+ /**
52
+ * Read all facts from the SQLite memory index. Returns empty array if the
53
+ * SQLite db file does not exist (workspace never used Memory).
54
+ *
55
+ * Shared with `@theokit/sdk-memory` through the memory-store barrel, so it carries no visibility
56
+ * tag — naming that tag in this block would delete the function below it (#463).
57
+ */
58
+ export declare function readAllSqliteFacts(root: MemoryRoot): Promise<SqliteFactRow[]>;
@@ -1,11 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var chunk2UCFUSPW_cjs = require('../../../chunk-2UCFUSPW.cjs');
3
+ var chunkIRCJ7EHV_cjs = require('../../../chunk-IRCJ7EHV.cjs');
4
+ var chunkA4VHSE56_cjs = require('../../../chunk-A4VHSE56.cjs');
5
+ var chunkEHJEZAOO_cjs = require('../../../chunk-EHJEZAOO.cjs');
4
6
  require('../../../chunk-KRD3GQAA.cjs');
5
7
  require('../../../chunk-MUUQ2WFJ.cjs');
6
8
  require('../../../chunk-R3UPQFKK.cjs');
7
9
  require('../../../chunk-VKJ7V7EB.cjs');
8
10
  require('../../../chunk-BUIK7GUA.cjs');
11
+ require('../../../chunk-NXH4GPAQ.cjs');
9
12
  require('../../../chunk-ZF2LDKQQ.cjs');
10
13
  require('../../../chunk-I6TGFUCO.cjs');
11
14
  require('../../../chunk-K3FW2XZD.cjs');
@@ -14,41 +17,121 @@ require('../../../chunk-NUKRL3I6.cjs');
14
17
 
15
18
 
16
19
 
20
+ Object.defineProperty(exports, "appendDiaryEntry", {
21
+ enumerable: true,
22
+ get: function () { return chunkIRCJ7EHV_cjs.appendDiaryEntry; }
23
+ });
24
+ Object.defineProperty(exports, "diaryPath", {
25
+ enumerable: true,
26
+ get: function () { return chunkIRCJ7EHV_cjs.diaryPath; }
27
+ });
28
+ Object.defineProperty(exports, "entryHash", {
29
+ enumerable: true,
30
+ get: function () { return chunkIRCJ7EHV_cjs.entryHash; }
31
+ });
32
+ Object.defineProperty(exports, "readAllSqliteFacts", {
33
+ enumerable: true,
34
+ get: function () { return chunkIRCJ7EHV_cjs.readAllSqliteFacts; }
35
+ });
36
+ Object.defineProperty(exports, "renderDiaryEntry", {
37
+ enumerable: true,
38
+ get: function () { return chunkIRCJ7EHV_cjs.renderDiaryEntry; }
39
+ });
40
+ Object.defineProperty(exports, "persistActiveMemoryTranscript", {
41
+ enumerable: true,
42
+ get: function () { return chunkA4VHSE56_cjs.persistActiveMemoryTranscript; }
43
+ });
44
+ Object.defineProperty(exports, "MEMORY_INDEX_MAX_BYTES", {
45
+ enumerable: true,
46
+ get: function () { return chunkEHJEZAOO_cjs.MEMORY_INDEX_MAX_BYTES; }
47
+ });
48
+ Object.defineProperty(exports, "MEMORY_INDEX_MAX_LINES", {
49
+ enumerable: true,
50
+ get: function () { return chunkEHJEZAOO_cjs.MEMORY_INDEX_MAX_LINES; }
51
+ });
17
52
  Object.defineProperty(exports, "appendFact", {
18
53
  enumerable: true,
19
- get: function () { return chunk2UCFUSPW_cjs.appendFact; }
54
+ get: function () { return chunkEHJEZAOO_cjs.appendFact; }
20
55
  });
21
56
  Object.defineProperty(exports, "appendFactToMarkdown", {
22
57
  enumerable: true,
23
- get: function () { return chunk2UCFUSPW_cjs.appendFactToMarkdown; }
58
+ get: function () { return chunkEHJEZAOO_cjs.appendFactToMarkdown; }
59
+ });
60
+ Object.defineProperty(exports, "asMemoryRoot", {
61
+ enumerable: true,
62
+ get: function () { return chunkEHJEZAOO_cjs.asMemoryRoot; }
24
63
  });
25
64
  Object.defineProperty(exports, "claudeProjectMemoryDir", {
26
65
  enumerable: true,
27
- get: function () { return chunk2UCFUSPW_cjs.claudeProjectMemoryDir; }
66
+ get: function () { return chunkEHJEZAOO_cjs.claudeProjectMemoryDir; }
67
+ });
68
+ Object.defineProperty(exports, "collectMarkdownFiles", {
69
+ enumerable: true,
70
+ get: function () { return chunkEHJEZAOO_cjs.collectMarkdownFiles; }
28
71
  });
29
- Object.defineProperty(exports, "memoryDir", {
72
+ Object.defineProperty(exports, "defaultIndexPath", {
30
73
  enumerable: true,
31
- get: function () { return chunk2UCFUSPW_cjs.memoryDir; }
74
+ get: function () { return chunkEHJEZAOO_cjs.defaultIndexPath; }
75
+ });
76
+ Object.defineProperty(exports, "discoverSessionFiles", {
77
+ enumerable: true,
78
+ get: function () { return chunkEHJEZAOO_cjs.discoverSessionFiles; }
79
+ });
80
+ Object.defineProperty(exports, "discoverWikiFiles", {
81
+ enumerable: true,
82
+ get: function () { return chunkEHJEZAOO_cjs.discoverWikiFiles; }
83
+ });
84
+ Object.defineProperty(exports, "indexBudgetWarning", {
85
+ enumerable: true,
86
+ get: function () { return chunkEHJEZAOO_cjs.indexBudgetWarning; }
87
+ });
88
+ Object.defineProperty(exports, "lanceStoragePath", {
89
+ enumerable: true,
90
+ get: function () { return chunkEHJEZAOO_cjs.lanceStoragePath; }
32
91
  });
33
92
  Object.defineProperty(exports, "memoryMdPath", {
34
93
  enumerable: true,
35
- get: function () { return chunk2UCFUSPW_cjs.memoryMdPath; }
94
+ get: function () { return chunkEHJEZAOO_cjs.memoryMdPath; }
36
95
  });
37
- Object.defineProperty(exports, "memoryWriteDir", {
96
+ Object.defineProperty(exports, "memoryReadRoots", {
38
97
  enumerable: true,
39
- get: function () { return chunk2UCFUSPW_cjs.memoryWriteDir; }
98
+ get: function () { return chunkEHJEZAOO_cjs.memoryReadRoots; }
40
99
  });
41
100
  Object.defineProperty(exports, "notesDir", {
42
101
  enumerable: true,
43
- get: function () { return chunk2UCFUSPW_cjs.notesDir; }
102
+ get: function () { return chunkEHJEZAOO_cjs.notesDir; }
103
+ });
104
+ Object.defineProperty(exports, "projectMemoryDir", {
105
+ enumerable: true,
106
+ get: function () { return chunkEHJEZAOO_cjs.projectMemoryDir; }
44
107
  });
45
108
  Object.defineProperty(exports, "readFacts", {
46
109
  enumerable: true,
47
- get: function () { return chunk2UCFUSPW_cjs.readFacts; }
110
+ get: function () { return chunkEHJEZAOO_cjs.readFacts; }
48
111
  });
49
112
  Object.defineProperty(exports, "readFactsFromMarkdown", {
50
113
  enumerable: true,
51
- get: function () { return chunk2UCFUSPW_cjs.readFactsFromMarkdown; }
114
+ get: function () { return chunkEHJEZAOO_cjs.readFactsFromMarkdown; }
115
+ });
116
+ Object.defineProperty(exports, "resolveMemoryRoot", {
117
+ enumerable: true,
118
+ get: function () { return chunkEHJEZAOO_cjs.resolveMemoryRoot; }
119
+ });
120
+ Object.defineProperty(exports, "sessionSummaryPath", {
121
+ enumerable: true,
122
+ get: function () { return chunkEHJEZAOO_cjs.sessionSummaryPath; }
123
+ });
124
+ Object.defineProperty(exports, "sessionsDir", {
125
+ enumerable: true,
126
+ get: function () { return chunkEHJEZAOO_cjs.sessionsDir; }
127
+ });
128
+ Object.defineProperty(exports, "wikiDir", {
129
+ enumerable: true,
130
+ get: function () { return chunkEHJEZAOO_cjs.wikiDir; }
131
+ });
132
+ Object.defineProperty(exports, "writeSessionSummary", {
133
+ enumerable: true,
134
+ get: function () { return chunkEHJEZAOO_cjs.writeSessionSummary; }
52
135
  });
53
136
  //# sourceMappingURL=index.cjs.map
54
137
  //# sourceMappingURL=index.cjs.map
@@ -15,4 +15,14 @@
15
15
  * Semver-exempt: NOT part of the stable `@theokit/sdk` API. The sub-path IS declared in
16
16
  * `package.json` `exports`, so the names below must survive into the published declarations.
17
17
  */
18
- export { appendFact, appendFactToMarkdown, claudeProjectMemoryDir, memoryDir, memoryMdPath, memoryWriteDir, notesDir, readFacts, readFactsFromMarkdown, } from "./markdown-store.js";
18
+ export { appendDiaryEntry, type DiaryEntry, diaryPath, entryHash, renderDiaryEntry, } from "../dreaming/diary.js";
19
+ export { defaultIndexPath } from "../index-db.js";
20
+ export { collectMarkdownFiles, type DiscoveredFile } from "../index-manager-helpers.js";
21
+ export { lanceStoragePath } from "../lance-index.js";
22
+ export { readAllSqliteFacts, type SqliteFactRow } from "../migrate-sqlite-to-lance.js";
23
+ export { appendFact, appendFactToMarkdown, memoryMdPath, notesDir, readFacts, readFactsFromMarkdown, } from "./markdown-store.js";
24
+ export { asMemoryRoot, claudeProjectMemoryDir, indexBudgetWarning, MEMORY_INDEX_MAX_BYTES, MEMORY_INDEX_MAX_LINES, type MemoryLocationConfig, type MemoryRoot, memoryReadRoots, projectMemoryDir, resolveMemoryRoot, } from "./memory-root.js";
25
+ export { discoverSessionFiles, type SessionFile } from "./session-loader.js";
26
+ export { type SessionSummaryInput, sessionSummaryPath, sessionsDir, writeSessionSummary, } from "./session-summary-writer.js";
27
+ export { type ActiveMemoryTranscript, persistActiveMemoryTranscript } from "./transcript-store.js";
28
+ export { discoverWikiFiles, type WikiFile, wikiDir } from "./wiki-loader.js";
@@ -15,4 +15,14 @@
15
15
  * Semver-exempt: NOT part of the stable `@theokit/sdk` API. The sub-path IS declared in
16
16
  * `package.json` `exports`, so the names below must survive into the published declarations.
17
17
  */
18
- export { appendFact, appendFactToMarkdown, claudeProjectMemoryDir, memoryDir, memoryMdPath, memoryWriteDir, notesDir, readFacts, readFactsFromMarkdown, } from "./markdown-store.js";
18
+ export { appendDiaryEntry, type DiaryEntry, diaryPath, entryHash, renderDiaryEntry, } from "../dreaming/diary.js";
19
+ export { defaultIndexPath } from "../index-db.js";
20
+ export { collectMarkdownFiles, type DiscoveredFile } from "../index-manager-helpers.js";
21
+ export { lanceStoragePath } from "../lance-index.js";
22
+ export { readAllSqliteFacts, type SqliteFactRow } from "../migrate-sqlite-to-lance.js";
23
+ export { appendFact, appendFactToMarkdown, memoryMdPath, notesDir, readFacts, readFactsFromMarkdown, } from "./markdown-store.js";
24
+ export { asMemoryRoot, claudeProjectMemoryDir, indexBudgetWarning, MEMORY_INDEX_MAX_BYTES, MEMORY_INDEX_MAX_LINES, type MemoryLocationConfig, type MemoryRoot, memoryReadRoots, projectMemoryDir, resolveMemoryRoot, } from "./memory-root.js";
25
+ export { discoverSessionFiles, type SessionFile } from "./session-loader.js";
26
+ export { type SessionSummaryInput, sessionSummaryPath, sessionsDir, writeSessionSummary, } from "./session-summary-writer.js";
27
+ export { type ActiveMemoryTranscript, persistActiveMemoryTranscript } from "./transcript-store.js";
28
+ export { discoverWikiFiles, type WikiFile, wikiDir } from "./wiki-loader.js";
@@ -1,9 +1,12 @@
1
- export { appendFact, appendFactToMarkdown, claudeProjectMemoryDir, memoryDir, memoryMdPath, memoryWriteDir, notesDir, readFacts, readFactsFromMarkdown } from '../../../chunk-WCLDJSMY.js';
1
+ export { appendDiaryEntry, diaryPath, entryHash, readAllSqliteFacts, renderDiaryEntry } from '../../../chunk-R6TA2DRJ.js';
2
+ export { persistActiveMemoryTranscript } from '../../../chunk-LW7G5DYW.js';
3
+ export { MEMORY_INDEX_MAX_BYTES, MEMORY_INDEX_MAX_LINES, appendFact, appendFactToMarkdown, asMemoryRoot, claudeProjectMemoryDir, collectMarkdownFiles, defaultIndexPath, discoverSessionFiles, discoverWikiFiles, indexBudgetWarning, lanceStoragePath, memoryMdPath, memoryReadRoots, notesDir, projectMemoryDir, readFacts, readFactsFromMarkdown, resolveMemoryRoot, sessionSummaryPath, sessionsDir, wikiDir, writeSessionSummary } from '../../../chunk-C7QPML3L.js';
2
4
  import '../../../chunk-KVNWIAO4.js';
3
5
  import '../../../chunk-FD2UT76F.js';
4
6
  import '../../../chunk-QARJGQSA.js';
5
7
  import '../../../chunk-RIAM53CP.js';
6
8
  import '../../../chunk-FKMUFNQE.js';
9
+ import '../../../chunk-AMFXSENK.js';
7
10
  import '../../../chunk-Q5EWJPRY.js';
8
11
  import '../../../chunk-VF7EWVDG.js';
9
12
  import '../../../chunk-IDCKSLYH.js';
@@ -1,49 +1,19 @@
1
1
  import { type MemoryConfig, type MemoryFact } from "../types.js";
2
- /**
3
- * The memory root for a workspace: `<cwd>/.theokit/memory`. Every other path here derives from it,
4
- * and `memory_get` refuses to read outside it. Pure path computation — nothing is created on disk.
5
- */
6
- export declare function memoryDir(cwd: string): string;
7
- /**
8
- * Where a NEW fact should be written.
9
- *
10
- * `.theokit/memory` by default, exactly as before. When the agent was given a `local.sessionDir`,
11
- * it becomes `<sessionDir>/projects/<encoded-cwd>/memory` — the same place the transcript for that
12
- * project goes, so a session and the memories recorded during it land beside each other.
13
- *
14
- * `local.sessionDir` is the switch because it is already the option this project documents for CLI
15
- * interop: point it at `~/.claude` and the CLI can `--continue` a session this agent wrote. Someone
16
- * who set it has said they share state with that CLI, and memory following is what the sentence
17
- * already implied. It needs no new option, and nothing moves for anyone who never set it.
18
- *
19
- * Safe because of the rule this pairs with — WRITE ONE, READ ALL. {@link readFactsFromMarkdown}
20
- * covers every location, so a consumer whose new facts move keeps every fact they already had. The
21
- * change relocates where the next one lands; it orphans nothing.
22
- */
23
- export declare function memoryWriteDir(cwd: string, sessionDir: string | undefined): string;
24
- /**
25
- * Where the Claude Code CLI keeps THIS project's memories.
26
- *
27
- * `<claudeHome>/projects/<encoded-cwd>/memory` — the same `encodeProjectDir` scheme the transcripts
28
- * already use, which is why no new encoding is invented here. `CLAUDE_CONFIG_DIR` names the home
29
- * when set (the CLI's own variable); `~/.claude` otherwise.
30
- *
31
- * Read, never written. Writing here by default would relocate every existing consumer's memories,
32
- * and an additive change must not move what is already on disk — so this is the direction that
33
- * costs nothing: a memory the CLI wrote becomes visible, and a memory the SDK wrote stays where the
34
- * SDK put it.
35
- */
36
- export declare function claudeProjectMemoryDir(cwd: string): string;
2
+ import { type MemoryLocationConfig, type MemoryRoot } from "./memory-root.js";
37
3
  /**
38
4
  * Path to `MEMORY.md`, the index that points at the per-memory files — and, in stores written before
39
5
  * #389, the flat `## Facts` list itself. Pure path computation; the file may not exist.
6
+ *
7
+ * Takes the RESOLVED ROOT, not a `cwd`. Every path helper here does, so a caller that has not asked
8
+ * {@link resolveMemoryRoot} where memory lives does not compile — see `memory-root.ts` for the
9
+ * defect that made that the requirement (#463).
40
10
  */
41
- export declare function memoryMdPath(cwd: string): string;
11
+ export declare function memoryMdPath(root: MemoryRoot): string;
42
12
  /**
43
13
  * Path to `<memory root>/notes`, where per-topic notes and the consolidated notes a dreaming sweep
44
14
  * writes live. Pure path computation — the directory may not exist.
45
15
  */
46
- export declare function notesDir(cwd: string): string;
16
+ export declare function notesDir(root: MemoryRoot): string;
47
17
  /**
48
18
  * Every memory in the store: the per-memory files, plus any legacy `## Facts` bullets still in
49
19
  * `MEMORY.md`. Returns `[]` when the directory does not exist.
@@ -52,7 +22,7 @@ export declare function notesDir(cwd: string): string;
52
22
  * repositories, and the store's own header invites editing them by hand — a converged writer that
53
23
  * stopped reading them would delete what someone recorded, which is worse than the format it fixes.
54
24
  */
55
- export declare function readFactsFromMarkdown(cwd: string, sessionDir?: string): Promise<MemoryFact[]>;
25
+ export declare function readFactsFromMarkdown(cwd: string, config?: MemoryLocationConfig): Promise<MemoryFact[]>;
56
26
  /**
57
27
  * Write a fact as its own memory file and point the `MEMORY.md` index at it. Atomic + serialized.
58
28
  *
@@ -65,13 +35,14 @@ export declare function appendFactToMarkdown(cwd: string, fact: MemoryFact, targ
65
35
  * disabled the call resolves to `[]` without touching disk. Configuration-aware entry point;
66
36
  * {@link readFactsFromMarkdown} is the same read without the gate.
67
37
  */
68
- export declare function readFacts(cwd: string, config: MemoryConfig, memoryHome?: string): Promise<MemoryFact[]>;
38
+ export declare function readFacts(cwd: string, config: MemoryConfig): Promise<MemoryFact[]>;
69
39
  /**
70
40
  * Record a fact, honouring the `enabled` gate on {@link MemoryConfig}: when memory is disabled the
71
41
  * call resolves without touching disk. Configuration-aware entry point;
72
42
  * {@link appendFactToMarkdown} is the same write without the gate.
73
43
  *
74
- * `memoryHome` is the agent's `local.sessionDir` when it has one see {@link memoryWriteDir} for
75
- * which store that sends the fact to.
44
+ * The destination comes from `memory.directory` and from nothing else. It used to come from
45
+ * `local.sessionDir` the option that names the TRANSCRIPT home — so one option answered two
46
+ * questions and only this call site heard the second answer (#463).
76
47
  */
77
- export declare function appendFact(cwd: string, config: MemoryConfig, fact: MemoryFact, memoryHome?: string): Promise<void>;
48
+ export declare function appendFact(cwd: string, config: MemoryConfig, fact: MemoryFact): Promise<void>;
@@ -1,49 +1,19 @@
1
1
  import { type MemoryConfig, type MemoryFact } from "../types.js";
2
- /**
3
- * The memory root for a workspace: `<cwd>/.theokit/memory`. Every other path here derives from it,
4
- * and `memory_get` refuses to read outside it. Pure path computation — nothing is created on disk.
5
- */
6
- export declare function memoryDir(cwd: string): string;
7
- /**
8
- * Where a NEW fact should be written.
9
- *
10
- * `.theokit/memory` by default, exactly as before. When the agent was given a `local.sessionDir`,
11
- * it becomes `<sessionDir>/projects/<encoded-cwd>/memory` — the same place the transcript for that
12
- * project goes, so a session and the memories recorded during it land beside each other.
13
- *
14
- * `local.sessionDir` is the switch because it is already the option this project documents for CLI
15
- * interop: point it at `~/.claude` and the CLI can `--continue` a session this agent wrote. Someone
16
- * who set it has said they share state with that CLI, and memory following is what the sentence
17
- * already implied. It needs no new option, and nothing moves for anyone who never set it.
18
- *
19
- * Safe because of the rule this pairs with — WRITE ONE, READ ALL. {@link readFactsFromMarkdown}
20
- * covers every location, so a consumer whose new facts move keeps every fact they already had. The
21
- * change relocates where the next one lands; it orphans nothing.
22
- */
23
- export declare function memoryWriteDir(cwd: string, sessionDir: string | undefined): string;
24
- /**
25
- * Where the Claude Code CLI keeps THIS project's memories.
26
- *
27
- * `<claudeHome>/projects/<encoded-cwd>/memory` — the same `encodeProjectDir` scheme the transcripts
28
- * already use, which is why no new encoding is invented here. `CLAUDE_CONFIG_DIR` names the home
29
- * when set (the CLI's own variable); `~/.claude` otherwise.
30
- *
31
- * Read, never written. Writing here by default would relocate every existing consumer's memories,
32
- * and an additive change must not move what is already on disk — so this is the direction that
33
- * costs nothing: a memory the CLI wrote becomes visible, and a memory the SDK wrote stays where the
34
- * SDK put it.
35
- */
36
- export declare function claudeProjectMemoryDir(cwd: string): string;
2
+ import { type MemoryLocationConfig, type MemoryRoot } from "./memory-root.js";
37
3
  /**
38
4
  * Path to `MEMORY.md`, the index that points at the per-memory files — and, in stores written before
39
5
  * #389, the flat `## Facts` list itself. Pure path computation; the file may not exist.
6
+ *
7
+ * Takes the RESOLVED ROOT, not a `cwd`. Every path helper here does, so a caller that has not asked
8
+ * {@link resolveMemoryRoot} where memory lives does not compile — see `memory-root.ts` for the
9
+ * defect that made that the requirement (#463).
40
10
  */
41
- export declare function memoryMdPath(cwd: string): string;
11
+ export declare function memoryMdPath(root: MemoryRoot): string;
42
12
  /**
43
13
  * Path to `<memory root>/notes`, where per-topic notes and the consolidated notes a dreaming sweep
44
14
  * writes live. Pure path computation — the directory may not exist.
45
15
  */
46
- export declare function notesDir(cwd: string): string;
16
+ export declare function notesDir(root: MemoryRoot): string;
47
17
  /**
48
18
  * Every memory in the store: the per-memory files, plus any legacy `## Facts` bullets still in
49
19
  * `MEMORY.md`. Returns `[]` when the directory does not exist.
@@ -52,7 +22,7 @@ export declare function notesDir(cwd: string): string;
52
22
  * repositories, and the store's own header invites editing them by hand — a converged writer that
53
23
  * stopped reading them would delete what someone recorded, which is worse than the format it fixes.
54
24
  */
55
- export declare function readFactsFromMarkdown(cwd: string, sessionDir?: string): Promise<MemoryFact[]>;
25
+ export declare function readFactsFromMarkdown(cwd: string, config?: MemoryLocationConfig): Promise<MemoryFact[]>;
56
26
  /**
57
27
  * Write a fact as its own memory file and point the `MEMORY.md` index at it. Atomic + serialized.
58
28
  *
@@ -65,13 +35,14 @@ export declare function appendFactToMarkdown(cwd: string, fact: MemoryFact, targ
65
35
  * disabled the call resolves to `[]` without touching disk. Configuration-aware entry point;
66
36
  * {@link readFactsFromMarkdown} is the same read without the gate.
67
37
  */
68
- export declare function readFacts(cwd: string, config: MemoryConfig, memoryHome?: string): Promise<MemoryFact[]>;
38
+ export declare function readFacts(cwd: string, config: MemoryConfig): Promise<MemoryFact[]>;
69
39
  /**
70
40
  * Record a fact, honouring the `enabled` gate on {@link MemoryConfig}: when memory is disabled the
71
41
  * call resolves without touching disk. Configuration-aware entry point;
72
42
  * {@link appendFactToMarkdown} is the same write without the gate.
73
43
  *
74
- * `memoryHome` is the agent's `local.sessionDir` when it has one see {@link memoryWriteDir} for
75
- * which store that sends the fact to.
44
+ * The destination comes from `memory.directory` and from nothing else. It used to come from
45
+ * `local.sessionDir` the option that names the TRANSCRIPT home — so one option answered two
46
+ * questions and only this call site heard the second answer (#463).
76
47
  */
77
- export declare function appendFact(cwd: string, config: MemoryConfig, fact: MemoryFact, memoryHome?: string): Promise<void>;
48
+ export declare function appendFact(cwd: string, config: MemoryConfig, fact: MemoryFact): Promise<void>;