@theokit/sdk-memory 0.1.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 (99) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/LICENSE +201 -0
  3. package/README.md +86 -0
  4. package/dist/in-memory-provider.d.ts +38 -0
  5. package/dist/in-memory-provider.d.ts.map +1 -0
  6. package/dist/index.cjs +2585 -0
  7. package/dist/index.cjs.map +1 -0
  8. package/dist/index.d.cts +40 -0
  9. package/dist/index.d.ts +40 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +2500 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/internal/active-memory-cache.d.ts +49 -0
  14. package/dist/internal/active-memory-cache.d.ts.map +1 -0
  15. package/dist/internal/active-memory-types.d.ts +30 -0
  16. package/dist/internal/active-memory-types.d.ts.map +1 -0
  17. package/dist/internal/active-memory.d.ts +108 -0
  18. package/dist/internal/active-memory.d.ts.map +1 -0
  19. package/dist/internal/adapter-catalog.d.ts +82 -0
  20. package/dist/internal/adapter-catalog.d.ts.map +1 -0
  21. package/dist/internal/adapter-http-error.d.ts +63 -0
  22. package/dist/internal/adapter-http-error.d.ts.map +1 -0
  23. package/dist/internal/batch-encoder.d.ts +30 -0
  24. package/dist/internal/batch-encoder.d.ts.map +1 -0
  25. package/dist/internal/chunk-markdown.d.ts +66 -0
  26. package/dist/internal/chunk-markdown.d.ts.map +1 -0
  27. package/dist/internal/circuit-breaker.d.ts +36 -0
  28. package/dist/internal/circuit-breaker.d.ts.map +1 -0
  29. package/dist/internal/composite-scorer.d.ts +19 -0
  30. package/dist/internal/composite-scorer.d.ts.map +1 -0
  31. package/dist/internal/deepinfra-embedding.d.ts +25 -0
  32. package/dist/internal/deepinfra-embedding.d.ts.map +1 -0
  33. package/dist/internal/dreaming-diary.d.ts +38 -0
  34. package/dist/internal/dreaming-diary.d.ts.map +1 -0
  35. package/dist/internal/dreaming-phases.d.ts +43 -0
  36. package/dist/internal/dreaming-phases.d.ts.map +1 -0
  37. package/dist/internal/dreaming-run.d.ts +49 -0
  38. package/dist/internal/dreaming-run.d.ts.map +1 -0
  39. package/dist/internal/embedding-adapter.d.ts +57 -0
  40. package/dist/internal/embedding-adapter.d.ts.map +1 -0
  41. package/dist/internal/embedding-cache.d.ts +16 -0
  42. package/dist/internal/embedding-cache.d.ts.map +1 -0
  43. package/dist/internal/index-db.d.ts +50 -0
  44. package/dist/internal/index-db.d.ts.map +1 -0
  45. package/dist/internal/index-manager-contract.d.ts +70 -0
  46. package/dist/internal/index-manager-contract.d.ts.map +1 -0
  47. package/dist/internal/index-manager-dispatch.d.ts +36 -0
  48. package/dist/internal/index-manager-dispatch.d.ts.map +1 -0
  49. package/dist/internal/index-manager.d.ts +94 -0
  50. package/dist/internal/index-manager.d.ts.map +1 -0
  51. package/dist/internal/index-schema.d.ts +35 -0
  52. package/dist/internal/index-schema.d.ts.map +1 -0
  53. package/dist/internal/lance-index.d.ts +70 -0
  54. package/dist/internal/lance-index.d.ts.map +1 -0
  55. package/dist/internal/lance-memory-adapter.d.ts +102 -0
  56. package/dist/internal/lance-memory-adapter.d.ts.map +1 -0
  57. package/dist/internal/markdown-store.d.ts +17 -0
  58. package/dist/internal/markdown-store.d.ts.map +1 -0
  59. package/dist/internal/memory-index.d.ts +68 -0
  60. package/dist/internal/memory-index.d.ts.map +1 -0
  61. package/dist/internal/memory-scope.d.ts +21 -0
  62. package/dist/internal/memory-scope.d.ts.map +1 -0
  63. package/dist/internal/memory-types.d.ts +95 -0
  64. package/dist/internal/memory-types.d.ts.map +1 -0
  65. package/dist/internal/migrate-sqlite-to-lance.d.ts +49 -0
  66. package/dist/internal/migrate-sqlite-to-lance.d.ts.map +1 -0
  67. package/dist/internal/migration.d.ts +10 -0
  68. package/dist/internal/migration.d.ts.map +1 -0
  69. package/dist/internal/mistral-embedding.d.ts +23 -0
  70. package/dist/internal/mistral-embedding.d.ts.map +1 -0
  71. package/dist/internal/ollama-embedding.d.ts +48 -0
  72. package/dist/internal/ollama-embedding.d.ts.map +1 -0
  73. package/dist/internal/openai-compatible.d.ts +24 -0
  74. package/dist/internal/openai-compatible.d.ts.map +1 -0
  75. package/dist/internal/openai-embedding.d.ts +34 -0
  76. package/dist/internal/openai-embedding.d.ts.map +1 -0
  77. package/dist/internal/openrouter-embedding.d.ts +25 -0
  78. package/dist/internal/openrouter-embedding.d.ts.map +1 -0
  79. package/dist/internal/query-analyzer.d.ts +16 -0
  80. package/dist/internal/query-analyzer.d.ts.map +1 -0
  81. package/dist/internal/reader.d.ts +64 -0
  82. package/dist/internal/reader.d.ts.map +1 -0
  83. package/dist/internal/session-loader.d.ts +25 -0
  84. package/dist/internal/session-loader.d.ts.map +1 -0
  85. package/dist/internal/session-summary-writer.d.ts +43 -0
  86. package/dist/internal/session-summary-writer.d.ts.map +1 -0
  87. package/dist/internal/sqlite-vec-loader.d.ts +62 -0
  88. package/dist/internal/sqlite-vec-loader.d.ts.map +1 -0
  89. package/dist/internal/tools.d.ts +44 -0
  90. package/dist/internal/tools.d.ts.map +1 -0
  91. package/dist/internal/transcript-store.d.ts +36 -0
  92. package/dist/internal/transcript-store.d.ts.map +1 -0
  93. package/dist/internal/vec-index.d.ts +81 -0
  94. package/dist/internal/vec-index.d.ts.map +1 -0
  95. package/dist/internal/voyage-embedding.d.ts +23 -0
  96. package/dist/internal/voyage-embedding.d.ts.map +1 -0
  97. package/dist/internal/wiki-loader.d.ts +24 -0
  98. package/dist/internal/wiki-loader.d.ts.map +1 -0
  99. package/package.json +74 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-store.d.ts","sourceRoot":"","sources":["../../src/internal/markdown-store.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAiB,MAAM,mBAAmB,CAAC;AAqCtF,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,mFAAmF;AACnF,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAQ9E;AAED,kGAAkG;AAClG,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAcjF;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAUhE;AAsCD,iFAAiF;AACjF,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAGxF;AAED,wBAAsB,UAAU,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,IAAI,CAAC,CAGf"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Common `MemoryIndex` interface shared between the SQLite-backed
3
+ * `IndexManager` (default) and the Lance-backed adapter (ADR D43, shipped
4
+ * v1.4.0 via lancedb-backend-ship-v1-1 plan).
5
+ *
6
+ * Consumers (`local-agent-memory.ts`, `active-memory.ts`, `tools.ts`,
7
+ * `runActiveMemory`) only ever call `sync()`, `search()`, `status()`,
8
+ * `close()` — the union of those four methods is the portable surface.
9
+ *
10
+ * Why a separate file (vs declaring inline in `index-manager.ts`)? D43
11
+ * promised "extrair interface abstrata `MemoryIndex` em
12
+ * `internal/memory/index-interface.ts`". Keeping the contract physically
13
+ * separated from one of its implementations preserves OCP — future
14
+ * backends (Qdrant, PGVector) can land without touching IndexManager.
15
+ *
16
+ * Iter 50 (Stage 3 source-move #7): hybrid copy from sdk-core's
17
+ * `internal/memory/memory-index.ts`. sdk-core retains its copy for v1.x
18
+ * back-compat; sdk-memory ships the canonical copy that future
19
+ * `index-manager`, `lance-memory-adapter`, and `active-memory` moves
20
+ * will target as siblings.
21
+ *
22
+ * **Iter 50 side-effect:** by publicly re-exporting `MemorySearchHit`
23
+ * via the sdk-memory barrel, this file creates the FIRST reachable
24
+ * downstream consumer for `MemorySearchHit` inside sdk-memory's
25
+ * graph. That unblocks the rollup-plugin-dts treeshake limitation
26
+ * the iter 48 inline-duplicate workaround was guarding against —
27
+ * `internal/active-memory-types.ts` can now re-import the canonical
28
+ * `MemorySearchHit` from `./index-manager-contract.js` and drop its
29
+ * inline mirror. Deletion of that workaround lands in this same iter.
30
+ *
31
+ * @internal
32
+ */
33
+ import type { IndexStatus, MemorySearchHit, SearchOptions } from "./index-manager-contract.js";
34
+ export interface SyncResult {
35
+ filesScanned: number;
36
+ filesUpdated: number;
37
+ chunksWritten: number;
38
+ chunksEmbedded: number;
39
+ }
40
+ /**
41
+ * Common search-options parser used by both `IndexManager.search` and
42
+ * `LanceMemoryAdapter.search`. Returns the normalized cap + minimum-score
43
+ * floor — eliminates jscpd duplication while keeping per-backend search
44
+ * logic distinct.
45
+ */
46
+ export declare function parseSearchOptions(options?: SearchOptions): {
47
+ maxResults: number;
48
+ minScore: number;
49
+ };
50
+ export interface MemoryIndex {
51
+ /**
52
+ * Walk the memory corpus + reindex changed files. Lance backend has no
53
+ * markdown corpus to walk — its adapter returns zero counts (no-op) and
54
+ * relies on explicit `addFact` calls instead.
55
+ */
56
+ sync(): Promise<SyncResult>;
57
+ /**
58
+ * Semantic + textual search over the indexed corpus. Both backends
59
+ * return the same `MemorySearchHit[]` shape; Lance leaves `textScore`
60
+ * undefined (vector-only — no FTS5 layer).
61
+ */
62
+ search(query: string, options?: SearchOptions): Promise<MemorySearchHit[]>;
63
+ /** Snapshot of the index health (backend type + counts). */
64
+ status(): IndexStatus;
65
+ /** Release native handles. Idempotent. */
66
+ close(): Promise<void> | void;
67
+ }
68
+ //# sourceMappingURL=memory-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-index.d.ts","sourceRoot":"","sources":["../../src/internal/memory-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAW/F,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,aAAkB,GAAG;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAKA;AAED,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IAE5B;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAE3E,4DAA4D;IAC5D,MAAM,IAAI,WAAW,CAAC;IAEtB,0CAA0C;IAC1C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC/B"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Hierarchical memory scopes — path-based isolation for multi-agent setups.
3
+ *
4
+ * Inspired by CrewAI's `MemoryScope` with path hierarchy.
5
+ * Per ADR D4: scope stored as TEXT column, prefix-matched via LIKE.
6
+ *
7
+ * @internal
8
+ */
9
+ export declare function normalizeScopePath(path: string): string;
10
+ interface ScopeSearchOptions {
11
+ scopePrefix?: string;
12
+ }
13
+ export declare class MemoryScope {
14
+ private readonly rootPath;
15
+ constructor(rootPath: string);
16
+ get path(): string;
17
+ child(subPath: string): MemoryScope;
18
+ toSearchOptions(): ScopeSearchOptions;
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=memory-scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-scope.d.ts","sourceRoot":"","sources":["../../src/internal/memory-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED,UAAU,kBAAkB;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,QAAQ,EAAE,MAAM;IAI5B,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW;IAKnC,eAAe,IAAI,kBAAkB;CAGtC"}
@@ -0,0 +1,95 @@
1
+ export interface MemoryConfig {
2
+ enabled: boolean;
3
+ namespace?: string;
4
+ userId?: string;
5
+ scope?: "agent" | "user" | "team";
6
+ storePath?: string;
7
+ }
8
+ export interface MemoryFact {
9
+ text: string;
10
+ }
11
+ /**
12
+ * Canonical credential-redaction primitive (ADR D68).
13
+ *
14
+ * sdk-core's copy re-exports `redactSecrets` directly from
15
+ * `../security/index.js` (internal path). sdk-core's PUBLIC surface
16
+ * (`@theokit/sdk`) doesn't expose a bare `redactSecrets` symbol —
17
+ * it ships `Security.redact()` instead (T2.1, by design — the
18
+ * namespace also carries `Security.addPattern()`). sdk-memory's
19
+ * canonical `redactSecrets` re-export wraps `Security.redact` 1-to-1
20
+ * so consumers continue to see the same symbol name without sdk-memory
21
+ * having to import sdk-core's internal subpath. Same 12-pattern
22
+ * list, same two-bucket mask shape, same disable-via-env behavior.
23
+ */
24
+ export declare function redactSecrets(text: unknown, opts?: {
25
+ codeFile?: boolean;
26
+ }): string;
27
+ /**
28
+ * Resolve the legacy JSON memory path used pre-ADR-D8 (kept for migration
29
+ * helpers + tests). Centralized here so `migration.ts` and the legacy-aware
30
+ * `runtime/memory-store.ts` don't duplicate the path logic (jscpd cleanup).
31
+ */
32
+ export declare function legacyMemoryJsonPath(cwd: string, config: MemoryConfig): string;
33
+ /**
34
+ * A semantically meaningful slice of a markdown memory file, produced by
35
+ * `chunkMarkdown`. Each chunk carries stable line numbers + a content hash
36
+ * used downstream by the embedding cache.
37
+ *
38
+ * Mirrors OpenClaw's `MemoryChunk` shape
39
+ * (`referencia/openclaw/packages/memory-host-sdk/src/host/engine-storage.ts`).
40
+ *
41
+ * @internal
42
+ */
43
+ export interface MemoryChunk {
44
+ /** 1-indexed starting line in the source file. */
45
+ startLine: number;
46
+ /** 1-indexed ending line (inclusive). */
47
+ endLine: number;
48
+ /** Slice of markdown source text. */
49
+ text: string;
50
+ /** sha256 of `text`; stable across runs for identical inputs. */
51
+ hash: string;
52
+ /** Optional nearest heading text (without the `#` markers). */
53
+ heading?: string;
54
+ }
55
+ /**
56
+ * Result of `reader.readFile`. Contains the bounded slice plus truncation
57
+ * + provenance info.
58
+ *
59
+ * Mirrors OpenClaw's `MemoryReadResult` shape.
60
+ *
61
+ * @internal
62
+ */
63
+ export interface MemoryReadResult {
64
+ path: string;
65
+ /** Requested starting line (1-indexed, defaults to 1). */
66
+ from: number;
67
+ /** Number of lines actually returned (may be less than `lines` near EOF). */
68
+ linesReturned: number;
69
+ /** Total lines in the file (after the read). */
70
+ totalLines: number;
71
+ /** True when fewer lines were returned than the requested `lines` AND EOF was hit. */
72
+ truncated: boolean;
73
+ /** Lines past the returned slice that remain in the file. */
74
+ remainingLines: number;
75
+ /** Slice text (joined with `\n`). */
76
+ text: string;
77
+ }
78
+ /**
79
+ * Lightweight reference to a markdown file in the memory corpus.
80
+ *
81
+ * Mirrors OpenClaw's `MemoryFileEntry`.
82
+ *
83
+ * @internal
84
+ */
85
+ export interface MemoryFileEntry {
86
+ /** Absolute path on disk. */
87
+ path: string;
88
+ /** Path relative to the memory root (e.g. "MEMORY.md", "notes/foo.md"). */
89
+ relPath: string;
90
+ /** ms-since-epoch mtime. */
91
+ mtime: number;
92
+ /** sha256 of the file content; recomputed on each read. */
93
+ hash: string;
94
+ }
95
+ //# sourceMappingURL=memory-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-types.d.ts","sourceRoot":"","sources":["../../src/internal/memory-types.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAElF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CAY9E;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IAC1B,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,aAAa,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,sFAAsF;IACtF,SAAS,EAAE,OAAO,CAAC;IACnB,6DAA6D;IAC7D,cAAc,EAAE,MAAM,CAAC;IACvB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,OAAO,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;CACd"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Migrate Memory.index from SQLite to LanceDB (ADR D44).
3
+ *
4
+ * EC-3 MUST FIX: validation uses NFC unicode normalization on both sides.
5
+ *
6
+ * Iter 71 (Stage 3 source-move #28): hybrid copy from sdk-core's
7
+ * `internal/memory/migrate-sqlite-to-lance.ts`. sdk-core retains its
8
+ * copy for v1.x migration back-compat; sdk-memory ships the canonical
9
+ * copy.
10
+ *
11
+ * Dependency chain (all resolved):
12
+ * - `@theokit/sdk/errors` for `ConfigurationError` (public)
13
+ * - sibling `./memory-types.js` for `redactSecrets` (moved iter 52)
14
+ * - sibling `./index-db.js` for `defaultIndexPath` + `openMemoryDb` (moved iter 65)
15
+ * - sibling `./lance-index.js` for `LanceIndex` + `lanceStoragePath` (moved iter 68)
16
+ *
17
+ * @internal
18
+ */
19
+ export interface MigrateOptions {
20
+ cwd: string;
21
+ dryRun?: boolean;
22
+ batchSize?: number;
23
+ /** Inject for tests; defaults to console.log. */
24
+ logger?: (msg: string) => void;
25
+ }
26
+ export interface MigrateResult {
27
+ countSqlite: number;
28
+ countLance: number;
29
+ /** Set when validation succeeded (or dryRun); false on validation failure. */
30
+ validated: boolean;
31
+ /** Per-fact compare results (size = sample count, up to 10). */
32
+ sampleComparisons: ReadonlyArray<{
33
+ id: string;
34
+ match: boolean;
35
+ }>;
36
+ /** Lance storage location (final, after migration). */
37
+ lancePath: string;
38
+ /** Was the migration committed (false for dry-run). */
39
+ committed: boolean;
40
+ }
41
+ /**
42
+ * Run the migration. Writes Lance to `<cwd>/.theokit/memory/lance-new/`
43
+ * first, validates round-trip, then renames to `lance/` on success.
44
+ * SQLite db is preserved (CLI prompts user to delete).
45
+ *
46
+ * @internal
47
+ */
48
+ export declare function migrateSqliteToLance(opts: MigrateOptions): Promise<MigrateResult>;
49
+ //# sourceMappingURL=migrate-sqlite-to-lance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-sqlite-to-lance.d.ts","sourceRoot":"","sources":["../../src/internal/migrate-sqlite-to-lance.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iDAAiD;IACjD,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,SAAS,EAAE,OAAO,CAAC;IACnB,gEAAgE;IAChE,iBAAiB,EAAE,aAAa,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACjE,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,SAAS,EAAE,OAAO,CAAC;CACpB;AA0DD;;;;;;GAMG;AAEH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAmJvF"}
@@ -0,0 +1,10 @@
1
+ import { type MemoryConfig } from "./memory-types.js";
2
+ export interface MigrationResult {
3
+ migrated: boolean;
4
+ factCount: number;
5
+ reason?: "already-migrated" | "no-legacy-json" | "markdown-exists" | "readonly-fs";
6
+ }
7
+ export declare function migrateLegacyJson(cwd: string, config: MemoryConfig): Promise<MigrationResult>;
8
+ /** Test-only — reset the in-process migration flag map. */
9
+ export declare function resetMigrationStateForTests(): void;
10
+ //# sourceMappingURL=migration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../src/internal/migration.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwB,KAAK,YAAY,EAAmB,MAAM,mBAAmB,CAAC;AAoE7F,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,kBAAkB,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,aAAa,CAAC;CACpF;AAED,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,eAAe,CAAC,CAmB1B;AAED,2DAA2D;AAC3D,wBAAgB,2BAA2B,IAAI,IAAI,CAElD"}
@@ -0,0 +1,23 @@
1
+ import { createOpenAiCompatibleRuntime } from "./openai-compatible.js";
2
+ /**
3
+ * Mistral embedding adapter — OpenAI-compatible REST surface
4
+ * (`POST /v1/embeddings` against `https://api.mistral.ai`). Default model
5
+ * `mistral-embed` (1024 dims).
6
+ *
7
+ * Mirrors `referencia/openclaw/extensions/mistral/memory-embedding-adapter.ts`.
8
+ *
9
+ * Iter 74 (Stage 3 source-move #32): hybrid copy from sdk-core's
10
+ * `internal/memory/adapters/mistral-embedding.ts`.
11
+ *
12
+ * @internal
13
+ */
14
+ export declare const DEFAULT_MISTRAL_EMBEDDING_MODEL = "mistral-embed";
15
+ export declare const mistralMemoryEmbeddingProviderAdapter: {
16
+ id: string;
17
+ defaultModel: string;
18
+ transport: "remote";
19
+ authProviderId: string;
20
+ autoSelectPriority: number;
21
+ create: (options: Parameters<typeof createOpenAiCompatibleRuntime>[1]) => Promise<import("./embedding-adapter.js").EmbeddingRuntime>;
22
+ };
23
+ //# sourceMappingURL=mistral-embedding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mistral-embedding.d.ts","sourceRoot":"","sources":["../../src/internal/mistral-embedding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AAIvE;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,+BAA+B,kBAAkB,CAAC;AAM/D,eAAO,MAAM,qCAAqC;;;;;;sBAM9B,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAC,CAAC,CAAC;CAYtE,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Ollama embedding adapter (T3.1, ADR D183).
3
+ *
4
+ * Targets Ollama's OpenAI-compatible `/v1/embeddings` endpoint and reuses
5
+ * the shared `createOpenAiCompatibleRuntime` factory. The differentiating
6
+ * bits:
7
+ *
8
+ * - `authType: "none"` — Ollama local ignores `Authorization`. Sentinel
9
+ * `"ollama-local"` is passed as apiKey to satisfy the factory contract
10
+ * (mirrors OpenClaw `OLLAMA_DEFAULT_API_KEY = "ollama-local"`).
11
+ * - `OLLAMA_HOST` overrides the default `http://localhost:11434`.
12
+ * - `OLLAMA_API_KEY` (optional) overrides the sentinel for Ollama Cloud
13
+ * or reverse-proxy auth setups.
14
+ * - Default model: `nomic-embed-text` (768 dim, ~274MB). User can opt
15
+ * into `all-minilm` (384 dim, ~45MB) or any other locally-installed
16
+ * embedding model.
17
+ *
18
+ * EC-B MUST FIX (edge-case review 2026-05-21): empty text is rejected
19
+ * upstream in the shared factory (`classifyEntry` short-circuits to a
20
+ * zero vector). That behavior is acceptable here because the zero
21
+ * vector is identical for any empty input — downstream similarity
22
+ * calcs ignore zero-norm vectors via the existing `cosineSimilarity`
23
+ * guard. No additional fail-fast needed.
24
+ *
25
+ * EC-A MUST FIX (edge-case review 2026-05-21): dimension is locked
26
+ * by the `DIMENSION_BY_MODEL` table; an unknown model id throws
27
+ * `ConfigurationError(code: "embedding_unknown_model")` per the
28
+ * factory's EC-4 contract. Future model versions with different
29
+ * dimensions are added to the table here without breaking changes.
30
+ *
31
+ * Iter 74 (Stage 3 source-move #36): hybrid copy from sdk-core's
32
+ * `internal/memory/adapters/ollama-embedding.ts`. The only
33
+ * `transport: "local"` adapter in the cluster — enables 100%-local
34
+ * RAG with no remote API key.
35
+ *
36
+ * @internal
37
+ */
38
+ import { createOpenAiCompatibleRuntime } from "./openai-compatible.js";
39
+ export declare const DEFAULT_OLLAMA_EMBEDDING_MODEL = "nomic-embed-text";
40
+ export declare const ollamaMemoryEmbeddingProviderAdapter: {
41
+ id: string;
42
+ defaultModel: string;
43
+ transport: "local";
44
+ authProviderId: string;
45
+ autoSelectPriority: number;
46
+ create: (options: Parameters<typeof createOpenAiCompatibleRuntime>[1]) => Promise<import("./embedding-adapter.js").EmbeddingRuntime>;
47
+ };
48
+ //# sourceMappingURL=ollama-embedding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ollama-embedding.d.ts","sourceRoot":"","sources":["../../src/internal/ollama-embedding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AAIvE,eAAO,MAAM,8BAA8B,qBAAqB,CAAC;AAsBjE,eAAO,MAAM,oCAAoC;;;;;;sBAQ7B,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAC,CAAC,CAAC;CAiBtE,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { CreateAdapterOptions, EmbeddingRuntime } from "./embedding-adapter.js";
2
+ export interface OpenAiCompatibleConfig {
3
+ id: string;
4
+ defaultBaseUrl: string;
5
+ apiKeyEnv: string;
6
+ baseUrlEnv?: string;
7
+ defaultModel: string;
8
+ /**
9
+ * Dimension hint by model id. The chosen model MUST be in this table —
10
+ * unknown models throw `ConfigurationError(code: "embedding_unknown_model")`
11
+ * (EC-4 fix). This prevents vec0 virtual-table dimension mismatches that
12
+ * surface as cryptic errors downstream.
13
+ */
14
+ dimensionByModel: Record<string, number>;
15
+ /**
16
+ * Path component appended to `baseUrl` for the embeddings endpoint.
17
+ * Default `"/v1/embeddings"` (OpenAI canonical). REPLACES the default —
18
+ * does NOT concatenate. Used by DeepInfra (`"/v1/openai/embeddings"`),
19
+ * etc. (EC-2 fix).
20
+ */
21
+ embeddingsPath?: string;
22
+ }
23
+ export declare function createOpenAiCompatibleRuntime(cfg: OpenAiCompatibleConfig, options: CreateAdapterOptions): Promise<EmbeddingRuntime>;
24
+ //# sourceMappingURL=openai-compatible.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-compatible.d.ts","sourceRoot":"","sources":["../../src/internal/openai-compatible.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAEjB,MAAM,wBAAwB,CAAC;AAmChC,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAsB,6BAA6B,CACjD,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CAgD3B"}
@@ -0,0 +1,34 @@
1
+ import { createOpenAiCompatibleRuntime } from "./openai-compatible.js";
2
+ /**
3
+ * **Iter 74 rollup-plugin-dts workaround:** importing
4
+ * `MemoryEmbeddingProviderAdapter` from sibling `./embedding-adapter.js`
5
+ * fails dts emit because no public type reaches it transitively yet
6
+ * (same iter 48/53/55/66/67/69/72 class). Fix: drop the explicit
7
+ * type annotation on the exported adapter; TS infers the structural
8
+ * shape from the literal, and the catalog (iter 37 / this same iter)
9
+ * pin assignability against the canonical interface via its own
10
+ * `Record<string, MemoryEmbeddingProviderAdapter>` constraint.
11
+ *
12
+ * @internal
13
+ */
14
+ /**
15
+ * OpenAI embedding adapter (ADR D3) — built on the shared OpenAI-compatible
16
+ * factory. Native fetch only.
17
+ *
18
+ * Iter 74 (Stage 3 source-move #31): hybrid copy from sdk-core's
19
+ * `internal/memory/adapters/openai-embedding.ts`. Composes iter 45's
20
+ * `MemoryEmbeddingProviderAdapter` + iter 73's
21
+ * `createOpenAiCompatibleRuntime`.
22
+ *
23
+ * @internal
24
+ */
25
+ export declare const DEFAULT_OPENAI_EMBEDDING_MODEL = "text-embedding-3-small";
26
+ export declare const openAiMemoryEmbeddingProviderAdapter: {
27
+ id: string;
28
+ defaultModel: string;
29
+ transport: "remote";
30
+ authProviderId: string;
31
+ autoSelectPriority: number;
32
+ create: (options: Parameters<typeof createOpenAiCompatibleRuntime>[1]) => Promise<import("./embedding-adapter.js").EmbeddingRuntime>;
33
+ };
34
+ //# sourceMappingURL=openai-embedding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-embedding.d.ts","sourceRoot":"","sources":["../../src/internal/openai-embedding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AAEvE;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,8BAA8B,2BAA2B,CAAC;AAQvE,eAAO,MAAM,oCAAoC;;;;;;sBAM7B,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAC,CAAC,CAAC;CAYtE,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { createOpenAiCompatibleRuntime } from "./openai-compatible.js";
2
+ /**
3
+ * OpenRouter embedding adapter — routes through OpenRouter's
4
+ * `POST /api/v1/embeddings` endpoint (OpenAI-compatible request/response
5
+ * shape). The provider id strings follow OpenRouter's catalog
6
+ * (e.g. `"openai/text-embedding-3-small"`, `"mistralai/mistral-embed"`).
7
+ *
8
+ * Honors `OPENROUTER_API_KEY` and `OPENROUTER_API_BASE_URL`. Default base
9
+ * URL is `https://openrouter.ai/api`.
10
+ *
11
+ * Iter 74 (Stage 3 source-move #35): hybrid copy from sdk-core's
12
+ * `internal/memory/adapters/openrouter-embedding.ts`.
13
+ *
14
+ * @internal
15
+ */
16
+ export declare const DEFAULT_OPENROUTER_EMBEDDING_MODEL = "openai/text-embedding-3-small";
17
+ export declare const openRouterMemoryEmbeddingProviderAdapter: {
18
+ id: string;
19
+ defaultModel: string;
20
+ transport: "remote";
21
+ authProviderId: string;
22
+ autoSelectPriority: number;
23
+ create: (options: Parameters<typeof createOpenAiCompatibleRuntime>[1]) => Promise<import("./embedding-adapter.js").EmbeddingRuntime>;
24
+ };
25
+ //# sourceMappingURL=openrouter-embedding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openrouter-embedding.d.ts","sourceRoot":"","sources":["../../src/internal/openrouter-embedding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AAIvE;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,kCAAkC,kCAAkC,CAAC;AASlF,eAAO,MAAM,wCAAwC;;;;;;sBAMjC,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAC,CAAC,CAAC;CAYtE,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Query analyzer — LLM-driven sub-query distillation for complex queries.
3
+ *
4
+ * Inspired by CrewAI's `recall_flow.py`. Opt-in: short queries (≤250 chars)
5
+ * pass through unchanged. Per ADR D3.
6
+ *
7
+ * @internal
8
+ */
9
+ interface QueryAnalysisResult {
10
+ subQueries: string[];
11
+ timeFilter?: number;
12
+ scopeHint?: string;
13
+ }
14
+ export declare function analyzeQuery(query: string, callLlm: (system: string, user: string) => Promise<string>): Promise<QueryAnalysisResult>;
15
+ export {};
16
+ //# sourceMappingURL=query-analyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-analyzer.d.ts","sourceRoot":"","sources":["../../src/internal/query-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,UAAU,mBAAmB;IAC3B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,YAAY,CAChC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GACzD,OAAO,CAAC,mBAAmB,CAAC,CAmB9B"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * **Iter 55 rollup-plugin-dts workaround** (mirrors iter 48/53 pattern).
3
+ * The canonical sdk-core copy imports `MemoryReadResult` from
4
+ * `../types.js`. In sdk-memory the same type lives in sibling
5
+ * `./memory-types.js` (moved iter 52) but rollup-dts treeshakes it
6
+ * out of the dist .d.ts because no PUBLIC type reaches it
7
+ * transitively yet — `readMemoryFileBounded`'s return type would be
8
+ * the consumer BUT rollup-dts processes the import resolution before
9
+ * reader.ts itself becomes bundled into the public emit. Same class
10
+ * of bug as iter 48 (MemorySearchHit) + iter 53 (MemoryChunk).
11
+ *
12
+ * Fix: declare a byte-identical mirror of MemoryReadResult inline.
13
+ * When a future move (e.g. tools.ts wrapping readMemoryFileBounded
14
+ * as a public LLM tool, or IndexManager surface emitting these)
15
+ * gives MemoryReadResult a different publicly-reachable path, this
16
+ * mirror MUST be deleted + the canonical import restored to maintain
17
+ * single source of truth.
18
+ *
19
+ * @internal
20
+ */
21
+ interface MemoryReadResult {
22
+ path: string;
23
+ /** Requested starting line (1-indexed, defaults to 1). */
24
+ from: number;
25
+ /** Number of lines actually returned (may be less than `lines` near EOF). */
26
+ linesReturned: number;
27
+ /** Total lines in the file (after the read). */
28
+ totalLines: number;
29
+ /** True when fewer lines were returned than the requested `lines` AND EOF was hit. */
30
+ truncated: boolean;
31
+ /** Lines past the returned slice that remain in the file. */
32
+ remainingLines: number;
33
+ /** Slice text (joined with `\n`). */
34
+ text: string;
35
+ }
36
+ /**
37
+ * Bounded read with truncation info (ADR D5 — `memory_get` foundation).
38
+ *
39
+ * Mirrors OpenClaw's `buildMemoryReadResult` semantics:
40
+ * - `from` is 1-indexed.
41
+ * - `lines` defaults to 200 (`DEFAULT_MEMORY_READ_LINES`).
42
+ * - Returns up to EOF when the requested slice extends past file end.
43
+ * - Sets `truncated: true` when fewer lines were returned than requested AND
44
+ * there's still content past the slice. (At EOF, `truncated: false`.)
45
+ *
46
+ * Iter 55 (Stage 3 source-move #12): hybrid copy from sdk-core's
47
+ * `internal/memory/storage/reader.ts`. sdk-core retains its copy for
48
+ * v1.x `memory_get` back-compat; sdk-memory ships the canonical copy
49
+ * that future `tools.ts` move (memory_get LLM tool wraps this) will
50
+ * target as a sibling. `MemoryReadResult` comes from sibling
51
+ * `./memory-types.js` (moved iter 52).
52
+ *
53
+ * @internal
54
+ */
55
+ export declare const DEFAULT_MEMORY_READ_LINES = 200;
56
+ export interface ReadFileOptions {
57
+ cwd: string;
58
+ relPath: string;
59
+ from?: number;
60
+ lines?: number;
61
+ }
62
+ export declare function readMemoryFileBounded(opts: ReadFileOptions): Promise<MemoryReadResult>;
63
+ export {};
64
+ //# sourceMappingURL=reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../src/internal/reader.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,aAAa,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,sFAAsF;IACtF,SAAS,EAAE,OAAO,CAAC;IACnB,6DAA6D;IAC7D,cAAc,EAAE,MAAM,CAAC;IACvB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;GAkBG;AAEH,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA6B5F"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Session summary discovery (ADR D20).
3
+ *
4
+ * Mirrors `wiki-loader.ts:discoverWikiFiles`: scans
5
+ * `.theokit/memory/sessions/*.md` and returns `MemoryFileEntry`-shaped
6
+ * records. IndexManager tags each chunk with `source="sessions"` so
7
+ * `memory_search({ corpus: "sessions" })` filters them in.
8
+ *
9
+ * Iter 62 (Stage 3 source-move #19): hybrid copy from sdk-core's
10
+ * `internal/memory/storage/session-loader.ts`. sdk-core retains its
11
+ * copy for v1.x sessions back-compat; sdk-memory ships the canonical
12
+ * copy. **Closes the sessions/ cluster in sdk-memory** — session
13
+ * summary writer (iter 61) + session-loader (this iter) are both
14
+ * canonical. Dependencies (sibling, both moved):
15
+ * - `memoryDir` from `./markdown-store.js` (moved iter 56)
16
+ * - `sessionsDir` from `./session-summary-writer.js` (moved iter 61)
17
+ *
18
+ * @internal
19
+ */
20
+ export interface SessionFile {
21
+ absolutePath: string;
22
+ relPath: string;
23
+ }
24
+ export declare function discoverSessionFiles(cwd: string): Promise<SessionFile[]>;
25
+ //# sourceMappingURL=session-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-loader.d.ts","sourceRoot":"","sources":["../../src/internal/session-loader.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAiB9E"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Per-run session summary writer (ADR D20).
3
+ *
4
+ * After every finished run, write a markdown summary to
5
+ * `.theokit/memory/sessions/<runId>.md`. IndexManager picks these up with
6
+ * `source="sessions"` so `memory_search({ corpus: "sessions" })` can recall
7
+ * past conversations.
8
+ *
9
+ * EC-9: only `status === "finished"` runs trigger a write. Cancelled/errored
10
+ * runs would otherwise pollute the recall corpus with partial transcripts.
11
+ *
12
+ * Iter 61 (Stage 3 source-move #18): hybrid copy from sdk-core's
13
+ * `internal/memory/storage/session-summary-writer.ts`. sdk-core
14
+ * retains its copy for v1.x sessions back-compat; sdk-memory ships
15
+ * the canonical copy that the future `session-loader.ts` move will
16
+ * compose with as a sibling (loader reads back the markdown files
17
+ * this writer emits). Dependency chain (all resolved):
18
+ * - `@theokit/sdk/internal/persistence` for `replaceFileAtomic`
19
+ * - sibling `./markdown-store.js` for `memoryDir` (moved iter 56)
20
+ * - sibling `./memory-types.js` for `redactSecrets` (moved iter 52)
21
+ *
22
+ * @internal
23
+ */
24
+ export interface SessionSummaryInput {
25
+ cwd: string;
26
+ runId: string;
27
+ agentId: string;
28
+ userText: string;
29
+ assistantText: string;
30
+ status: "finished" | "running" | "error" | "cancelled";
31
+ at: number;
32
+ }
33
+ export declare function sessionsDir(cwd: string): string;
34
+ export declare function sessionSummaryPath(cwd: string, runId: string): string;
35
+ /**
36
+ * Write a session summary file. EC-9: a non-finished status returns early
37
+ * without touching disk. Secrets in both user and assistant text are
38
+ * redacted via the shared `redactSecrets` pattern.
39
+ *
40
+ * @internal
41
+ */
42
+ export declare function writeSessionSummary(input: SessionSummaryInput): Promise<void>;
43
+ //# sourceMappingURL=session-summary-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-summary-writer.d.ts","sourceRoot":"","sources":["../../src/internal/session-summary-writer.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,CAAC;IACvD,EAAE,EAAE,MAAM,CAAC;CACZ;AAID,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAErE;AAaD;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BnF"}