@ponraaj/dimple-sdk 0.0.0-alpha.4 → 0.0.0-alpha.5

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.
package/dist/indexer.d.ts CHANGED
@@ -25,11 +25,20 @@ export interface WalkResult {
25
25
  * SAME file always gets the SAME key regardless of which path list was
26
26
  * passed (idempotent re-indexing across invocation shapes). */
27
27
  readonly root: string;
28
+ /** The resolved input paths — the reconcile DOMAIN: units whose file
29
+ * path is outside every root are untouched by subtree runs. */
30
+ readonly roots: readonly string[];
28
31
  }
29
32
  /** Recursively collect indexable files from paths (dirs or files). */
30
33
  export declare const walkFiles: (paths: readonly string[], extensions: readonly string[]) => WalkResult;
31
34
  /** Read a file's text, capped at `maxBytes` (string slice = char-safe). */
32
35
  export declare const readCapped: (path: string, maxBytes: number) => string;
36
+ /** The repository's HEAD commit for provenance stamping — soft-failed
37
+ * (non-git trees, missing git, permission errors → null). Walks UP from
38
+ * the first indexed file (git finds the enclosing repo), so it works for
39
+ * absolute-path trees whose key root is "/". Platform side; the facade
40
+ * never touches node APIs. */
41
+ export declare const currentCommit: (firstFile: string | undefined) => string | null;
33
42
  /** Resolve a file's relative import specifiers to indexed-tree files
34
43
  * (bare/absolute specifiers are external modules — no node_modules
35
44
  * resolution). */
@@ -30,6 +30,12 @@ export declare const EmbeddingModelConfig: Schema.Struct<{
30
30
  readonly pooling: Schema.optional<Schema.Literals<readonly ["mean", "cls", "none"]>>;
31
31
  readonly normalize: Schema.optional<Schema.Boolean>;
32
32
  readonly cacheDir: Schema.optional<Schema.String>;
33
+ /** First-use auto-install of the optional `@huggingface/transformers`
34
+ * peer (default true) — the package is installed with the project's
35
+ * own package manager on the first local-embed use (scripts skipped,
36
+ * proven unnecessary for embedding). Set false to require a manual
37
+ * install. */
38
+ readonly autoInstall: Schema.optional<Schema.Boolean>;
33
39
  }>;
34
40
  export interface EmbeddingModelConfig extends Schema.Schema.Type<typeof EmbeddingModelConfig> {
35
41
  }
@@ -59,6 +65,12 @@ export declare const EmbeddingConfig: Schema.Struct<{
59
65
  readonly pooling: Schema.optional<Schema.Literals<readonly ["mean", "cls", "none"]>>;
60
66
  readonly normalize: Schema.optional<Schema.Boolean>;
61
67
  readonly cacheDir: Schema.optional<Schema.String>;
68
+ /** First-use auto-install of the optional `@huggingface/transformers`
69
+ * peer (default true) — the package is installed with the project's
70
+ * own package manager on the first local-embed use (scripts skipped,
71
+ * proven unnecessary for embedding). Set false to require a manual
72
+ * install. */
73
+ readonly autoInstall: Schema.optional<Schema.Boolean>;
62
74
  }>>;
63
75
  }>;
64
76
  export interface EmbeddingConfig extends Schema.Schema.Type<typeof EmbeddingConfig> {
@@ -151,6 +163,12 @@ export declare const DimpleConfig: Schema.Struct<{
151
163
  readonly pooling: Schema.optional<Schema.Literals<readonly ["mean", "cls", "none"]>>;
152
164
  readonly normalize: Schema.optional<Schema.Boolean>;
153
165
  readonly cacheDir: Schema.optional<Schema.String>;
166
+ /** First-use auto-install of the optional `@huggingface/transformers`
167
+ * peer (default true) — the package is installed with the project's
168
+ * own package manager on the first local-embed use (scripts skipped,
169
+ * proven unnecessary for embedding). Set false to require a manual
170
+ * install. */
171
+ readonly autoInstall: Schema.optional<Schema.Boolean>;
154
172
  }>>;
155
173
  }>>;
156
174
  readonly jobs: Schema.optional<Schema.Struct<{
@@ -0,0 +1,35 @@
1
+ /**
2
+ * First-use auto-install of the OPTIONAL `@huggingface/transformers` peer.
3
+ *
4
+ * `@huggingface/transformers` is an optional peer (its tree pulls the
5
+ * `sharp` + `onnxruntime-node` postinstall scripts that abort npm 11
6
+ * installs). When the config declares a `transformers` provider model,
7
+ * the intent is explicit — so the FIRST local-embed use installs the
8
+ * package automatically with the project's own package manager, instead
9
+ * of failing with a manual step.
10
+ *
11
+ * Safety notes:
12
+ * - The install is scoped to the detected project root (the manifest's
13
+ * directory) and uses the manager the project already uses.
14
+ * - EVERY install runs `--ignore-scripts` (npm/pnpm/yarn) or bun's
15
+ * default script-blocking — verified harmless: the onnxruntime-node
16
+ * binaries ship in the package; its postinstall is not required for
17
+ * embedding, and sharp is never loaded for text embeddings.
18
+ * - Failure (offline, restricted env) is a typed EmbeddingError with the
19
+ * manual command — never a crash.
20
+ */
21
+ export type PackageManager = "bun" | "npm" | "pnpm" | "yarn";
22
+ export interface InstallTarget {
23
+ readonly pm: PackageManager;
24
+ readonly root: string;
25
+ }
26
+ /** Detect the project's package manager by walking UP from `cwd` for a
27
+ * lockfile (bun.lock/bun.lockb → bun, package-lock.json → npm,
28
+ * pnpm-lock.yaml → pnpm, yarn.lock → yarn). Falls back to bun + cwd. */
29
+ export declare const detectPackageManager: (cwd: string) => InstallTarget;
30
+ /** The install argv for a manager. `--ignore-scripts` on npm/pnpm/yarn:
31
+ * the blocked postinstalls are proven unnecessary for embedding (bun
32
+ * blocks them by default already). */
33
+ export declare const installCommand: (pm: PackageManager) => readonly [string, ...string[]];
34
+ /** Run the install for the project at `cwd`; rejects on non-zero exit. */
35
+ export declare const installTransformers: (cwd: string) => Promise<void>;
@@ -1,6 +1,9 @@
1
1
  import { Config, Layer } from "effect";
2
- import type { DeviceType } from "@huggingface/transformers";
3
2
  import { Service, type EmbeddingModel } from "./provider.ts";
3
+ /** Mirror of transformers.js's `DeviceType` (the config schema carries the
4
+ * same literals) — kept local so the optional peer's types never appear
5
+ * in this module's surface. */
6
+ type DeviceType = "auto" | "gpu" | "cpu" | "wasm" | "webgpu" | "cuda" | "dml" | "coreml" | "webnn";
4
7
  interface TransformersOptions {
5
8
  readonly modelId?: string;
6
9
  readonly device?: DeviceType;
@@ -11,6 +14,12 @@ interface TransformersOptions {
11
14
  /** Declared output dimension — validated against the model's actual
12
15
  * output on first embed (a mismatch fails typed, precisely). */
13
16
  readonly dimensions?: number;
17
+ /** First-use auto-install of the optional `@huggingface/transformers`
18
+ * peer (default true): the config declaring a transformers provider is
19
+ * explicit intent — the missing package is installed with the project's
20
+ * own package manager (scripts skipped; proven unnecessary for
21
+ * embedding). Set false to require a manual install. */
22
+ readonly autoInstall?: boolean;
14
23
  }
15
24
  export declare const makeTransformersModel: (options?: TransformersOptions) => EmbeddingModel;
16
25
  export declare const layer: (options?: TransformersOptions) => Layer.Layer<Service>;
@@ -15,6 +15,13 @@ export declare const ExtractedChunk: Schema.Struct<{
15
15
  readonly endLine: Schema.Number;
16
16
  readonly language: Schema.String;
17
17
  readonly docstring: Schema.optional<Schema.String>;
18
+ /** Call sites inside this definition — the code_calls edge source:
19
+ * `[{ name, line }]`, callee names only (member/property calls unwrap
20
+ * to the property name). */
21
+ readonly calls: Schema.optional<Schema.$Array<Schema.Struct<{
22
+ readonly name: Schema.String;
23
+ readonly line: Schema.Number;
24
+ }>>>;
18
25
  }>;
19
26
  export interface ExtractedChunk extends Schema.Schema.Type<typeof ExtractedChunk> {
20
27
  }
@@ -40,6 +47,13 @@ export declare const ExtractedFile: Schema.Struct<{
40
47
  readonly endLine: Schema.Number;
41
48
  readonly language: Schema.String;
42
49
  readonly docstring: Schema.optional<Schema.String>;
50
+ /** Call sites inside this definition — the code_calls edge source:
51
+ * `[{ name, line }]`, callee names only (member/property calls unwrap
52
+ * to the property name). */
53
+ readonly calls: Schema.optional<Schema.$Array<Schema.Struct<{
54
+ readonly name: Schema.String;
55
+ readonly line: Schema.Number;
56
+ }>>>;
43
57
  }>>;
44
58
  readonly imports: Schema.optional<Schema.$Array<Schema.Struct<{
45
59
  readonly source: Schema.String;
@@ -1,4 +1,4 @@
1
- export { Service as Logging, layer as loggingLayer, layerConfig as loggingLayerConfig, make as makeLogging, consoleSink, fileSink, effectLogger, type Sink, type Interface as LoggingInterface, type StructuredOutput, } from "./service.ts";
1
+ export { Service as Logging, layer as loggingLayer, layerConfig as loggingLayerConfig, makeEffect as makeLogging, consoleSink, fileSink, effectLogger, type Sink, type Interface as LoggingInterface, type StructuredOutput, } from "./service.ts";
2
2
  export { LogConfig, LogLevel, SEV_NUM, LEVEL_ORDER, type LogEntry } from "./types.ts";
3
3
  export { RingBuffer, type RingFrame, type Subscriber } from "./ring.ts";
4
4
  export { renderJson, renderPretty } from "./format.ts";
@@ -1,4 +1,4 @@
1
- import { Config, Context, Layer, Logger } from "effect";
1
+ import { Config, Context, Effect, Layer, Logger } from "effect";
2
2
  import type { Scope } from "effect/Scope";
3
3
  import { RingBuffer } from "./ring.ts";
4
4
  import { type LogConfig, type LogEntry } from "./types.ts";
@@ -9,24 +9,32 @@ export interface Sink {
9
9
  /** Receives the ENTRY — each sink renders it its own way (pretty on the
10
10
  * console, JSONL in the file and ring). */
11
11
  readonly write: (entry: LogEntry) => void;
12
- readonly dispose: () => void;
12
+ readonly dispose: () => void | Promise<void>;
13
13
  }
14
14
  export declare const consoleSink: (pretty: boolean) => Sink;
15
- /** Append-per-event file sink (the pino model): each rendered line goes
15
+ /**
16
+ * Append-per-event file sink (the pino model): each rendered line goes
16
17
  * straight to the fd and the OS page cache does the buffering; `fsync`
17
18
  * runs on process exit and on dispose. NOT sync-flush-per-event (kills
18
- * throughput), NOT end-of-run dumps (lose everything on crash). */
19
- export declare const fileSink: (path: string) => Sink;
19
+ * throughput), NOT end-of-run dumps (lose everything on crash).
20
+ *
21
+ * `node:fs` loads LAZILY (dynamic import) — the module stays free of
22
+ * static node imports, so the worker bundle builds anywhere; a file sink
23
+ * is never configured on edge.
24
+ */
25
+ export declare const fileSink: (path: string) => Effect.Effect<Sink>;
20
26
  export interface Interface {
21
27
  readonly emit: (entry: LogEntry) => void;
22
28
  /** Live tail mirror: pre-rendered JSONL lines, drop-oldest, NOT durable. */
23
29
  readonly ring: RingBuffer;
24
- readonly dispose: () => void;
30
+ readonly dispose: () => void | Promise<void>;
25
31
  }
26
32
  declare const Service_base: Context.ServiceClass<Service, "@dimple/logger/Logging", Interface>;
27
33
  export declare class Service extends Service_base {
28
34
  }
29
- export declare const make: (config: LogConfig) => Interface;
35
+ /** Effect variant of `make` — builds the file sink through lazy `node:fs`
36
+ * (see `fileSink`; the console sink is sync). */
37
+ export declare const makeEffect: (config: LogConfig) => Effect.Effect<Interface>;
30
38
  /** The structured shape Effect's `Logger.formatStructured` emits. */
31
39
  export interface StructuredOutput {
32
40
  readonly level: string;
@@ -54,6 +54,10 @@ export interface GraphNeighborsOptions {
54
54
  readonly maxNeighbors?: number;
55
55
  readonly maxTotal?: number;
56
56
  readonly includePending?: boolean;
57
+ /** Restrict traversal to these edge kinds (default: all). The common
58
+ * ask is memory-only navigation: pass the three `memory_*` kinds to
59
+ * keep the topic/concept legs out of the answer. */
60
+ readonly edgeKinds?: readonly string[];
57
61
  /** Optional scope for the topic legs of the view (topic edges are
58
62
  * model-scoped by PK). `undefined` unions every model's topic edges —
59
63
  * the intended default (topic edges are retrieval context regardless
@@ -80,9 +84,17 @@ export interface Interface {
80
84
  readonly listIsolatedMemories: (limit: number, modelKey?: string) => Effect.Effect<readonly Record<string, unknown>[], StoreError>;
81
85
  readonly db: DrizzleDB;
82
86
  readonly tables: StoreTables;
83
- readonly ftsSearch: (query: string, namespace: string, limit: number, topicKeys?: ReadonlyArray<string>, modelKey?: string) => Effect.Effect<readonly Record<string, unknown>[], StoreError>;
84
- readonly vectorSearch: (query: ReadonlyArray<number>, namespace: string, limit: number, model: EmbeddingModelConfig, topicKeys?: ReadonlyArray<string>) => Effect.Effect<readonly Record<string, unknown>[], StoreError>;
87
+ readonly ftsSearch: (query: string, namespace: string, limit: number, topicKeys?: ReadonlyArray<string>, modelKey?: string, contentType?: string | ReadonlyArray<string>) => Effect.Effect<readonly Record<string, unknown>[], StoreError>;
88
+ readonly vectorSearch: (query: ReadonlyArray<number>, namespace: string, limit: number, model: EmbeddingModelConfig, topicKeys?: ReadonlyArray<string>, contentType?: string | ReadonlyArray<string>) => Effect.Effect<readonly Record<string, unknown>[], StoreError>;
85
89
  readonly sweep: (namespace: string) => Effect.Effect<SweepResult, StoreError>;
90
+ /** The DB's tables + columns (`dimple db-schema` surface). */
91
+ readonly listSchema: () => Effect.Effect<ReadonlyArray<{
92
+ readonly table: string;
93
+ readonly columns: ReadonlyArray<{
94
+ readonly name: string;
95
+ readonly type: string;
96
+ }>;
97
+ }>, StoreError>;
86
98
  /** Persist retrieval-audit rows (`retrieval_log`). Owned by the backend
87
99
  * so the `audit.write` job handler stays dialect-neutral. */
88
100
  readonly writeAuditRows: (rows: readonly RetrievalAuditRow[]) => Effect.Effect<void, StoreError>;
@@ -42,7 +42,7 @@ export interface CandidateMember {
42
42
  readonly metadata?: string | null;
43
43
  }
44
44
  /** Which rule produced a candidate (the provenance on `EdgeCandidate`). */
45
- export type CandidateKind = "near-duplicate" | "conflict-band" | "identity";
45
+ export type CandidateKind = "near-duplicate" | "conflict-band" | "identity" | "rename";
46
46
  /** One rule-derived edge proposal from `leafLocalCandidates`. */
47
47
  export interface EdgeCandidate {
48
48
  readonly fromMemoryId: string;
@@ -81,6 +81,8 @@ export interface GraphCandidatesOptions {
81
81
  /** Max pending candidates returned (clamped to [1, 200]; default 50). */
82
82
  readonly limit?: number;
83
83
  }
84
+ /** Cosine similarity of two vectors (equal-length; zero norm ⇒ 0). */
85
+ export declare const cosineSimilarity: (a: Float32Array, b: Float32Array) => number;
84
86
  /**
85
87
  * The leaf-local candidate scan: compare the new memory against its
86
88
  * leaf-mates (per the module rules) and return at most one candidate per
@@ -11,7 +11,7 @@ export declare const MemoryUnit: Schema.Struct<{
11
11
  readonly contentType: Schema.String;
12
12
  readonly state: Schema.Literals<readonly ["active", "superseded", "archived", "forgotten"]>;
13
13
  readonly createdAt: Schema.Number;
14
- readonly ttlSecs: Schema.Number;
14
+ readonly ttlSecs: Schema.NullOr<Schema.Number>;
15
15
  readonly namespace: Schema.String;
16
16
  readonly metadata: Schema.optional<Schema.String>;
17
17
  readonly embedding: Schema.optional<Schema.$Array<Schema.Number>>;
@@ -24,7 +24,7 @@ export declare const WriteMemoryInput: Schema.Struct<{
24
24
  readonly content: Schema.String;
25
25
  readonly contentType: Schema.optional<Schema.String>;
26
26
  readonly namespace: Schema.optional<Schema.String>;
27
- readonly ttlSecs: Schema.optional<Schema.Number>;
27
+ readonly ttlSecs: Schema.optional<Schema.NullOr<Schema.Number>>;
28
28
  readonly metadata: Schema.optional<Schema.String>;
29
29
  /** Typed overlay merged INTO the raw metadata blob on write (unknown blob
30
30
  * keys preserved. Takes precedence over `metadata`. */
@@ -38,6 +38,7 @@ export declare const WriteMemoryInput: Schema.Struct<{
38
38
  readonly confidence: Schema.Number;
39
39
  readonly affordances: Schema.$Array<Schema.String>;
40
40
  readonly language: Schema.optional<Schema.String>;
41
+ readonly codeVersion: Schema.optional<Schema.String>;
41
42
  readonly pinned: Schema.optional<Schema.Boolean>;
42
43
  }>>;
43
44
  }>;
@@ -51,7 +52,7 @@ export declare const ScoredMemory: Schema.Struct<{
51
52
  readonly contentType: Schema.String;
52
53
  readonly state: Schema.Literals<readonly ["active", "superseded", "archived", "forgotten"]>;
53
54
  readonly createdAt: Schema.Number;
54
- readonly ttlSecs: Schema.Number;
55
+ readonly ttlSecs: Schema.NullOr<Schema.Number>;
55
56
  readonly namespace: Schema.String;
56
57
  readonly metadata: Schema.optional<Schema.String>;
57
58
  readonly embedding: Schema.optional<Schema.$Array<Schema.Number>>;
@@ -74,14 +74,14 @@ export declare const artifactEdges: import("drizzle-orm/sqlite-core").SQLiteTabl
74
74
  name: string;
75
75
  tableName: "artifact_edges";
76
76
  dataType: "string enum";
77
- data: "memory_contradicts" | "memory_supersedes" | "memory_supports";
77
+ data: "code_calls" | "memory_contradicts" | "memory_supersedes" | "memory_supports";
78
78
  driverParam: string;
79
79
  notNull: true;
80
80
  hasDefault: false;
81
81
  isPrimaryKey: false;
82
82
  isAutoincrement: false;
83
83
  hasRuntimeDefault: false;
84
- enumValues: ["memory_supports", "memory_supersedes", "memory_contradicts"];
84
+ enumValues: ["memory_supports", "memory_supersedes", "memory_contradicts", "code_calls"];
85
85
  baseColumn: never;
86
86
  identity: undefined;
87
87
  generated: undefined;
@@ -218,7 +218,7 @@ export declare const artifactEdges: import("drizzle-orm/sqlite-core").SQLiteTabl
218
218
  dialect: 'sqlite';
219
219
  }>;
220
220
  /** The memory↔memory edge kinds `artifact_edges` can hold (the only kinds in the lean table). */
221
- export type EdgeKind = "memory_supports" | "memory_supersedes" | "memory_contradicts";
221
+ export type EdgeKind = "memory_supports" | "memory_supersedes" | "memory_contradicts" | "code_calls";
222
222
  /** Writers of edges (provenance on every row). */
223
223
  export type EdgeSource = "rule" | "llm" | "agent";
224
224
  export declare const ArtifactEdgeInsert: import("drizzle-orm/effect-schema").BuildSchema<"insert", {
@@ -274,14 +274,14 @@ export declare const ArtifactEdgeInsert: import("drizzle-orm/effect-schema").Bui
274
274
  name: string;
275
275
  tableName: "artifact_edges";
276
276
  dataType: "string enum";
277
- data: "memory_contradicts" | "memory_supersedes" | "memory_supports";
277
+ data: "code_calls" | "memory_contradicts" | "memory_supersedes" | "memory_supports";
278
278
  driverParam: string;
279
279
  notNull: true;
280
280
  hasDefault: false;
281
281
  isPrimaryKey: false;
282
282
  isAutoincrement: false;
283
283
  hasRuntimeDefault: false;
284
- enumValues: ["memory_supports", "memory_supersedes", "memory_contradicts"];
284
+ enumValues: ["memory_supports", "memory_supersedes", "memory_contradicts", "code_calls"];
285
285
  baseColumn: never;
286
286
  identity: undefined;
287
287
  generated: undefined;
@@ -468,14 +468,14 @@ export declare const ArtifactEdgeSelect: import("drizzle-orm/effect-schema").Bui
468
468
  name: string;
469
469
  tableName: "artifact_edges";
470
470
  dataType: "string enum";
471
- data: "memory_contradicts" | "memory_supersedes" | "memory_supports";
471
+ data: "code_calls" | "memory_contradicts" | "memory_supersedes" | "memory_supports";
472
472
  driverParam: string;
473
473
  notNull: true;
474
474
  hasDefault: false;
475
475
  isPrimaryKey: false;
476
476
  isAutoincrement: false;
477
477
  hasRuntimeDefault: false;
478
- enumValues: ["memory_supports", "memory_supersedes", "memory_contradicts"];
478
+ enumValues: ["memory_supports", "memory_supersedes", "memory_contradicts", "code_calls"];
479
479
  baseColumn: never;
480
480
  identity: undefined;
481
481
  generated: undefined;
@@ -104,7 +104,7 @@ export declare const memories: import("drizzle-orm/sqlite-core").SQLiteTableWith
104
104
  dataType: "number int53";
105
105
  data: number;
106
106
  driverParam: number;
107
- notNull: true;
107
+ notNull: false;
108
108
  hasDefault: true;
109
109
  isPrimaryKey: false;
110
110
  isAutoincrement: false;
@@ -847,7 +847,7 @@ export declare const MemoryInsert: import("drizzle-orm/effect-schema").BuildSche
847
847
  dataType: "number int53";
848
848
  data: number;
849
849
  driverParam: number;
850
- notNull: true;
850
+ notNull: false;
851
851
  hasDefault: true;
852
852
  isPrimaryKey: false;
853
853
  isAutoincrement: false;
@@ -1025,7 +1025,7 @@ export declare const MemorySelect: import("drizzle-orm/effect-schema").BuildSche
1025
1025
  dataType: "number int53";
1026
1026
  data: number;
1027
1027
  driverParam: number;
1028
- notNull: true;
1028
+ notNull: false;
1029
1029
  hasDefault: true;
1030
1030
  isPrimaryKey: false;
1031
1031
  isAutoincrement: false;
@@ -1203,7 +1203,7 @@ export declare const MemoryUpdate: import("drizzle-orm/effect-schema").BuildSche
1203
1203
  dataType: "number int53";
1204
1204
  data: number;
1205
1205
  driverParam: number;
1206
- notNull: true;
1206
+ notNull: false;
1207
1207
  hasDefault: true;
1208
1208
  isPrimaryKey: false;
1209
1209
  isAutoincrement: false;
@@ -27,6 +27,9 @@ export declare const MemoryMetadata: Schema.Struct<{
27
27
  readonly affordances: Schema.$Array<Schema.String>;
28
28
  /** Code-specific: "typescript" | "rust" | ... */
29
29
  readonly language: Schema.optional<Schema.String>;
30
+ /** Code-specific: the repo HEAD at index time (the indexer's
31
+ * provenance stamp — which commit this unit came from). */
32
+ readonly codeVersion: Schema.optional<Schema.String>;
30
33
  /** Writer-set pin: the memory is deliberately stable — automatic graph
31
34
  * lifecycle moves should leave it alone. */
32
35
  readonly pinned: Schema.optional<Schema.Boolean>;
@@ -48,4 +51,4 @@ export declare const encodeMetadata: (metadata: MemoryMetadata) => string;
48
51
  * does not declare (producer-specific extensions) survives. A malformed
49
52
  * existing blob is treated as empty — the merge never throws.
50
53
  */
51
- export declare const mergeMetadataBlob: (existing: string | null | undefined, typed: MemoryMetadata) => string;
54
+ export declare const mergeMetadataBlob: (existing: string | null | undefined, typed: Partial<MemoryMetadata>) => string;
@@ -65,11 +65,44 @@ export interface ExplainResult {
65
65
  }
66
66
  export interface Interface {
67
67
  readonly write: (input: WriteMemoryInput) => Effect.Effect<MemoryUnit, StoreError | DuplicateActiveKey>;
68
+ /** Upsert for the index path — the identity rule (same logical key ⇒
69
+ * confirmed `memory_supersedes`) made reachable for ACTIVE keys: demote
70
+ * the active holder of the key (if any), write the new unit, and link
71
+ * old → new with a confirmed rule edge, all in ONE transaction. Returns
72
+ * the new memory plus the superseded id (when a predecessor existed). */
73
+ readonly writeSuperseding: (input: WriteMemoryInput) => Effect.Effect<{
74
+ readonly memory: MemoryUnit;
75
+ readonly supersededId?: string;
76
+ }, StoreError | DuplicateActiveKey>;
77
+ /** Index reconciliation — demote every ACTIVE unit under `keyPrefix`
78
+ * that is (a) INSIDE the walked domain (its file path is under one of
79
+ * `walkedRoots`, joined against `keyRoot`) and (b) not among `keptKeys`
80
+ * (this run's unit keys — files AND chunks: a chunk the extractor no
81
+ * longer emits, e.g. a deleted function inside a surviving file, is
82
+ * vanished). Demotion is `source_removed` (one transaction). Returns the demoted
83
+ * rows for the rename-candidate scan. Units outside the walked domain
84
+ * (subtree runs) and normal (non-index) memories are never touched. */
85
+ readonly reconcile: (namespace: string, keyPrefix: string, keyRoot: string, walkedRoots: readonly string[], keptKeys: readonly string[]) => Effect.Effect<readonly {
86
+ readonly id: string;
87
+ readonly logicalKey: string;
88
+ readonly embedding: number[] | null;
89
+ }[], StoreError>;
90
+ /** Rename/move detection (human-gated): cosine each vanished unit's
91
+ * stored embedding against this run's new units; ≥ the near-duplicate
92
+ * band → a PENDING `memory_supersedes` candidate (source rule, never
93
+ * auto-confirms — a rename is a guess). Returns the new-candidate count. */
94
+ readonly reconcileRenameCandidates: (vanished: readonly {
95
+ readonly id: string;
96
+ readonly embedding: number[] | null;
97
+ }[], newUnitIds: readonly string[]) => Effect.Effect<number, StoreError>;
68
98
  readonly get: (id: string) => Effect.Effect<MemoryUnit, NotFound | StoreError>;
69
99
  readonly getByKey: (key: string, namespace: string) => Effect.Effect<MemoryUnit, NotFound | StoreError>;
70
100
  readonly recency: (namespace: string, limit: number) => Effect.Effect<ReadonlyArray<AugmentedMemory>, StoreError>;
71
101
  readonly searchFts5: (query: string, namespace: string, limit: number, opts?: {
72
102
  readonly topicKeys?: ReadonlyArray<string>;
103
+ /** Content-type filter: one kind or a list (code-vs-message
104
+ * separation lever at query time). */
105
+ readonly contentType?: string | ReadonlyArray<string>;
73
106
  /** `false` suppresses the per-leg audit row (fused-row callers). */
74
107
  readonly audit?: boolean;
75
108
  }) => Effect.Effect<ReadonlyArray<AugmentedMemory>, StoreError>;
@@ -77,9 +110,20 @@ export interface Interface {
77
110
  readonly topicKeys?: ReadonlyArray<string>;
78
111
  /** Restrict to memories annotated with ANY of these concept ids. */
79
112
  readonly conceptIds?: ReadonlyArray<string>;
113
+ /** Content-type filter: one kind or a list (code-vs-message
114
+ * separation lever at query time). */
115
+ readonly contentType?: string | ReadonlyArray<string>;
80
116
  /** `false` suppresses the per-leg audit row (fused-row callers). */
81
117
  readonly audit?: boolean;
82
118
  }) => Effect.Effect<ReadonlyArray<AugmentedMemory>, StoreError>;
119
+ /** The DB's tables + columns (`dimple db-schema` surface). */
120
+ readonly listSchema: () => Effect.Effect<ReadonlyArray<{
121
+ readonly table: string;
122
+ readonly columns: ReadonlyArray<{
123
+ readonly name: string;
124
+ readonly type: string;
125
+ }>;
126
+ }>, StoreError>;
83
127
  /** One fused retrieval-audit row (the hybrid path's audit contract). */
84
128
  readonly logAudit: (input: {
85
129
  readonly query: string;
@@ -104,7 +148,7 @@ export interface Interface {
104
148
  readonly getMemoryAnnotations: (memoryId: string) => Effect.Effect<readonly string[], StoreError>;
105
149
  readonly queryByMetadata: (filter: Record<string, unknown>) => Effect.Effect<readonly MemoryUnit[], StoreError>;
106
150
  readonly getMemoryMetadata: (id: string) => Effect.Effect<MemoryMetadata | undefined, NotFound | StoreError>;
107
- readonly setMemoryMetadata: (id: string, metadata: MemoryMetadata) => Effect.Effect<void, NotFound | StoreError>;
151
+ readonly setMemoryMetadata: (id: string, metadata: Partial<MemoryMetadata>) => Effect.Effect<void, NotFound | StoreError>;
108
152
  readonly ensureTopicTree: (modelKey: string) => Effect.Effect<{
109
153
  rootKey: string;
110
154
  unassignedKey: string;
package/dist/make.d.ts CHANGED
@@ -23,5 +23,26 @@ export type MakeDimpleOptions = {
23
23
  * Boot failures reject with the same closed `DimpleError` surface as the
24
24
  * facade methods (never raw Effect internals) and close the owned
25
25
  * resources (scope + runtime) before rethrowing.
26
+ *
27
+ * ### Reload (see `Dimple.reload`)
28
+ *
29
+ * The facade owns a mutable `LiveStack` cell. A reload:
30
+ *
31
+ * 1. re-resolves the config source TYPED (schema errors reject before
32
+ * anything pauses — a bad config has zero impact);
33
+ * 2. pauses: new calls wait on the gate, calls already in flight settle on
34
+ * the OLD stack;
35
+ * 3. boots a fresh stack from the re-resolved config;
36
+ * 4. drains (waits the in-flight count to zero, bounded by
37
+ * `RELOAD_DRAIN_MS`), then swaps the cell and disposes the old stack
38
+ * (worker fleet stops, clients close);
39
+ * 5. releases the gate. Boot or drain failure leaves the old stack
40
+ * untouched — the reload rejects and the system keeps serving the
41
+ * previous config (blue-green).
42
+ *
43
+ * Durable jobs make the pause safe: a handler interrupted by the old
44
+ * stack's disposal has its lease expire and is re-claimed after boot;
45
+ * handlers are idempotent by design (transactions roll back, watermarks
46
+ * advance only on success).
26
47
  */
27
48
  export declare const makeDimple: (options: MakeDimpleOptions) => Promise<Dimple>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ponraaj/dimple-sdk",
3
- "version": "0.0.0-alpha.4",
3
+ "version": "0.0.0-alpha.5",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist"
@@ -33,7 +33,6 @@
33
33
  "@ai-sdk/cohere": "^3",
34
34
  "@ai-sdk/google": "^2",
35
35
  "@ai-sdk/openai-compatible": "^3.0.21",
36
- "@huggingface/transformers": "^4.2.0",
37
36
  "@libsql/client": "^0.17.4",
38
37
  "ai": "^7.0.50",
39
38
  "drizzle-orm": "^1.0.0-rc.4",
@@ -43,6 +42,12 @@
43
42
  "zod": "^4.4.3"
44
43
  },
45
44
  "peerDependencies": {
45
+ "@huggingface/transformers": "^4.0.0",
46
46
  "typescript": "^5"
47
+ },
48
+ "peerDependenciesMeta": {
49
+ "@huggingface/transformers": {
50
+ "optional": true
51
+ }
47
52
  }
48
53
  }