@ponraaj/dimple-sdk 0.0.0-alpha.1 → 0.0.0-alpha.11
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/README.md +99 -0
- package/dist/dimple.d.ts +116 -5
- package/dist/errors.d.ts +24 -2
- package/dist/errors.js +8218 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3584 -1999
- package/dist/indexer.d.ts +9 -0
- package/dist/internal/config/index.d.ts +1 -1
- package/dist/internal/config/schema.d.ts +87 -0
- package/dist/internal/config/service.d.ts +4 -0
- package/dist/internal/core/core.d.ts +8 -8
- package/dist/internal/core/hosted-embedding.d.ts +33 -0
- package/dist/internal/core/index.d.ts +6 -0
- package/dist/internal/core/layer.d.ts +17 -8
- package/dist/internal/embedder/auto-install.d.ts +28 -0
- package/dist/internal/embedder/index.d.ts +2 -3
- package/dist/internal/embedder/registry.d.ts +7 -0
- package/dist/internal/embedder/transformers.d.ts +40 -2
- package/dist/internal/extractor/code-extractor.d.ts +11 -1
- package/dist/internal/extractor/index.d.ts +1 -1
- package/dist/internal/extractor/languages/index.d.ts +1 -1
- package/dist/internal/extractor/languages/javascript.d.ts +1 -1
- package/dist/internal/extractor/languages/typescript.d.ts +1 -1
- package/dist/internal/extractor/models/extraction.d.ts +14 -0
- package/dist/internal/installer/index.d.ts +37 -0
- package/dist/internal/llm/dream-classifier.d.ts +1 -1
- package/dist/internal/llm/index.d.ts +1 -1
- package/dist/internal/llm/service.d.ts +7 -1
- package/dist/internal/logger/index.d.ts +1 -1
- package/dist/internal/logger/service.d.ts +44 -14
- package/dist/internal/logger/types.d.ts +15 -3
- package/dist/internal/parser/code-parser.d.ts +12 -2
- package/dist/internal/parser/index.d.ts +3 -3
- package/dist/internal/parser/language-store.d.ts +3 -3
- package/dist/internal/parser/tree-sitter-engine.d.ts +1 -1
- package/dist/internal/retriever/hybrid.d.ts +21 -7
- package/dist/internal/retriever/index.d.ts +1 -1
- package/dist/internal/shared/effect/node.d.ts +155 -0
- package/dist/internal/shared/file-database.d.ts +17 -0
- package/dist/internal/shared/file-lock.d.ts +20 -0
- package/dist/internal/shared/schema/defaults.d.ts +13 -0
- package/dist/internal/store/audit.d.ts +8 -2
- package/dist/internal/store/db-backend.d.ts +48 -10
- package/dist/internal/store/graph/candidates.d.ts +3 -1
- package/dist/internal/store/graph/concepts.d.ts +16 -7
- package/dist/internal/store/graph/dream.d.ts +9 -3
- package/dist/internal/store/graph/errors.d.ts +1 -1
- package/dist/internal/store/graph/repair.d.ts +9 -3
- package/dist/internal/store/graph/traversal.d.ts +1 -1
- package/dist/internal/store/index.d.ts +4 -3
- package/dist/internal/store/libsql-backend.d.ts +1 -1
- package/dist/internal/store/models.d.ts +4 -3
- package/dist/internal/store/schema/graph.d.ts +7 -7
- package/dist/internal/store/schema/libsql.d.ts +4 -4
- package/dist/internal/store/schema/metadata.d.ts +4 -1
- package/dist/internal/store/schema/topics.d.ts +0 -12
- package/dist/internal/store/service.d.ts +85 -5
- package/dist/internal/store/store.d.ts +24 -5
- package/dist/internal/store/topics/errors.d.ts +1 -1
- package/dist/internal/store/topics/jobs.d.ts +9 -3
- package/dist/internal/store/topics/lifecycle.d.ts +9 -3
- package/dist/internal/store/topics/maintenance.d.ts +10 -4
- package/dist/internal/store/topics/query.d.ts +1 -1
- package/dist/internal/store/topics/routing.d.ts +34 -1
- package/dist/internal/store/topics/topic-vectors.d.ts +11 -4
- package/dist/internal/store/topics/tree.d.ts +15 -9
- package/dist/internal/workflow/engine.d.ts +27 -3
- package/dist/internal/workflow/executor.d.ts +20 -6
- package/dist/internal/workflow/index.d.ts +4 -4
- package/dist/internal/workflow/persistence.d.ts +3 -3
- package/dist/internal/workflow/queue.d.ts +8 -5
- package/dist/internal/workflow/registry.d.ts +11 -1
- package/dist/internal/workflow/runtime.d.ts +22 -4
- package/dist/internal/workflow/signals.d.ts +21 -0
- package/dist/make.d.ts +27 -0
- package/package.json +34 -10
- package/dist/internal/embedder/openai.d.ts +0 -8
- package/dist/internal/wasm/grammar-store.d.ts +0 -14
- package/dist/internal/wasm/index.d.ts +0 -5
- package/dist/internal/wasm/wasm-cache.d.ts +0 -17
- package/dist/internal/wasm/wasm-downloader.d.ts +0 -10
- package/dist/internal/wasm/wasm-registry.d.ts +0 -16
- package/dist/internal/workflow/queue-store.d.ts +0 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config, Context, Layer, Logger } from "effect";
|
|
1
|
+
import { Config, Context, Effect, Layer, Logger, Schema } 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,42 +9,72 @@ 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
|
-
/**
|
|
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
|
-
|
|
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
|
-
|
|
30
|
-
|
|
35
|
+
/** Effect variant of the sync logger factory — 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>;
|
|
38
|
+
/** Effect log messages: strings pass through, arrays are joined, anything
|
|
39
|
+
* else renders as JSON (the `Logger.formatStructured` message contract).
|
|
40
|
+
* The schema is total for the values Effect actually emits; the caller
|
|
41
|
+
* supplies the JSON fallback when decoding fails. */
|
|
42
|
+
declare const LogMessage: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.Unknown>]>;
|
|
43
|
+
type LogMessage = Schema.Schema.Type<typeof LogMessage>;
|
|
44
|
+
/** The structured shape after boundary decoding of Effect's raw
|
|
45
|
+
* `Logger.formatStructured` output (annotations carry arbitrary JSON
|
|
46
|
+
* values; the decode happens in `effectLogger` before `toEntry`). */
|
|
31
47
|
export interface StructuredOutput {
|
|
32
48
|
readonly level: string;
|
|
33
49
|
readonly fiberId: string;
|
|
34
50
|
readonly timestamp: string;
|
|
35
|
-
readonly message:
|
|
51
|
+
readonly message: LogMessage;
|
|
36
52
|
readonly cause: string | undefined;
|
|
37
|
-
readonly annotations: Record<string,
|
|
38
|
-
readonly spans: Record<string, number
|
|
53
|
+
readonly annotations: Readonly<Record<string, Schema.Json>>;
|
|
54
|
+
readonly spans: Readonly<Record<string, number>>;
|
|
39
55
|
}
|
|
40
|
-
/** The Effect `Logger` that feeds the Logging service.
|
|
56
|
+
/** The Effect `Logger` that feeds the Logging service. The raw structured
|
|
57
|
+
* output is decoded at this boundary: annotations may carry arbitrary
|
|
58
|
+
* values, so each is decoded as JSON (non-JSON payloads degrade to their
|
|
59
|
+
* JSON rendering, keeping the JSONL sink lossless). */
|
|
41
60
|
export declare const effectLogger: (logging: Interface) => Logger.Logger<unknown, void>;
|
|
42
61
|
/** Installs the Logging service AND replaces Effect's default logger with
|
|
43
62
|
* the adapter feeding it. `mergeWithExisting: false` — one logger
|
|
44
|
-
* everywhere (the job runtime emits through this too).
|
|
45
|
-
|
|
63
|
+
* everywhere (the job runtime emits through this too). The acquisition is
|
|
64
|
+
* scope-owned (`Layer.effect` strips the build `Scope`), so the layer has no
|
|
65
|
+
* requirements of its own. */
|
|
66
|
+
export declare const layer: (config: LogConfig) => Layer.Layer<Service, never>;
|
|
46
67
|
/** Config-driven variant (the repo convention): `layerConfig(config)` or
|
|
47
68
|
* `layerConfig(Config.succeed({...}))` — resolves the config inside the
|
|
48
69
|
* layer and delegates to `layer` (no Effect.runSync in package sources). */
|
|
49
70
|
export declare const layerConfig: (config: Config.Wrap<LogConfig>) => Layer.Layer<Service, Config.ConfigError, Scope>;
|
|
71
|
+
/** Silent-by-default logging config: the Logging service is always
|
|
72
|
+
* available, and `layer` sets Effect's minimum-level filter to "None" so
|
|
73
|
+
* every log is short-circuited at the source. The single silent config
|
|
74
|
+
* consumed by @dimple/core and @dimple/store. */
|
|
75
|
+
export declare const silentConfig: LogConfig;
|
|
76
|
+
/** The Logging layer-graph node. `deps` stays empty — the composition root
|
|
77
|
+
* wires dependencies, per the layer-graph convention. */
|
|
78
|
+
export declare const configured: (config?: LogConfig) => import("../core/index.js").LayerProvider<Service, never, undefined>;
|
|
79
|
+
export declare const node: import("../core/index.js").LayerProvider<Service, never, undefined>;
|
|
50
80
|
export {};
|
|
@@ -6,8 +6,20 @@ export type LogLevel = "trace" | "debug" | "info" | "warn" | "error";
|
|
|
6
6
|
export declare const LogLevel: Schema.Literals<readonly ["trace", "debug", "info", "warn", "error"]>;
|
|
7
7
|
/** OTel severity numbers (logs data model): TRACE=1, DEBUG=5, INFO=9,
|
|
8
8
|
* WARN=13, ERROR=17. */
|
|
9
|
-
export declare const SEV_NUM:
|
|
10
|
-
|
|
9
|
+
export declare const SEV_NUM: {
|
|
10
|
+
trace: number;
|
|
11
|
+
debug: number;
|
|
12
|
+
info: number;
|
|
13
|
+
warn: number;
|
|
14
|
+
error: number;
|
|
15
|
+
};
|
|
16
|
+
export declare const LEVEL_ORDER: {
|
|
17
|
+
trace: number;
|
|
18
|
+
debug: number;
|
|
19
|
+
info: number;
|
|
20
|
+
warn: number;
|
|
21
|
+
error: number;
|
|
22
|
+
};
|
|
11
23
|
export declare const LogConfig: Schema.Struct<{
|
|
12
24
|
readonly enabled: Schema.withDecodingDefaultType<Schema.optional<Schema.Boolean>, never>;
|
|
13
25
|
readonly level: Schema.withDecodingDefaultType<Schema.optional<Schema.Literals<readonly ["trace", "debug", "info", "warn", "error"]>>, never>;
|
|
@@ -34,6 +46,6 @@ export interface LogEntry {
|
|
|
34
46
|
readonly fiber: string;
|
|
35
47
|
readonly traceId?: string;
|
|
36
48
|
readonly spanId?: string;
|
|
37
|
-
readonly attrs: Record<string,
|
|
49
|
+
readonly attrs: Record<string, Schema.Json>;
|
|
38
50
|
readonly cause?: string;
|
|
39
51
|
}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { Context, Effect, Layer } from "effect";
|
|
2
2
|
import { TreeHandle } from "./models/treeHandle";
|
|
3
3
|
import type { ParseRequest } from "./models/parseRequest";
|
|
4
|
-
import { ParseError } from "
|
|
4
|
+
import { ParseError } from "../shared/errors/index.js";
|
|
5
5
|
export interface Interface {
|
|
6
6
|
readonly parse: (request: ParseRequest) => Effect.Effect<TreeHandle, ParseError>;
|
|
7
7
|
}
|
|
8
8
|
declare const Service_base: Context.ServiceClass<Service, "@dimple/parser/CodeParser", Interface>;
|
|
9
9
|
export declare class Service extends Service_base {
|
|
10
10
|
}
|
|
11
|
-
export declare const layer: Layer.Layer<Service, import("
|
|
11
|
+
export declare const layer: Layer.Layer<Service, import("../shared/errors/index.js").ParserInitError, never>;
|
|
12
|
+
/**
|
|
13
|
+
* Layer-graph declaration for `CodeParser`. `layer` is already
|
|
14
|
+
* self-contained — it provides `languageStoreLayer`, which in turn provides
|
|
15
|
+
* the wasm grammar store and the tree-sitter engine — so `deps` stays empty
|
|
16
|
+
* and the composition root wires the rest of the system.
|
|
17
|
+
*/
|
|
18
|
+
export declare const configured: () => import("../core/index.js").LayerProvider<Service, import("../shared/errors/index.js").ParserInitError, undefined>;
|
|
19
|
+
/** The default declaration — the live implementation the composition root
|
|
20
|
+
* picks unless it replaces this node. */
|
|
21
|
+
export declare const node: import("../core/index.js").LayerProvider<Service, import("../shared/errors/index.js").ParserInitError, undefined>;
|
|
12
22
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { Service as CodeParser, layer as codeParserLayer } from "./code-parser";
|
|
1
|
+
export { Service as CodeParser, layer as codeParserLayer, configured as codeParserConfigured, node as codeParserNode, } from "./code-parser";
|
|
2
2
|
export { Service as LanguageStore, layer as languageStoreLayer } from "./language-store";
|
|
3
3
|
export { layer as treeSitterEngineLayer } from "./tree-sitter-engine";
|
|
4
4
|
export { ParseRequest } from "./models/parseRequest";
|
|
5
5
|
export { TreeHandle, TreeSchema } from "./models/treeHandle";
|
|
6
|
-
export type { LanguageId } from "
|
|
7
|
-
export { ParserInitError, LanguageLoadError, ParseError } from "
|
|
6
|
+
export type { LanguageId } from "../shared/types/language.js";
|
|
7
|
+
export { ParserInitError, LanguageLoadError, ParseError } from "../shared/errors/index.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context, Effect, Layer } from "effect";
|
|
2
|
-
import type { LanguageId } from "
|
|
3
|
-
import { LanguageLoadError } from "
|
|
2
|
+
import type { LanguageId } from "../shared/types/language.js";
|
|
3
|
+
import { LanguageLoadError } from "../shared/errors/index.js";
|
|
4
4
|
import { Language } from "web-tree-sitter";
|
|
5
5
|
export interface Interface {
|
|
6
6
|
readonly get: (lang: LanguageId) => Effect.Effect<Language, LanguageLoadError>;
|
|
@@ -8,5 +8,5 @@ export interface Interface {
|
|
|
8
8
|
declare const Service_base: Context.ServiceClass<Service, "@dimple/parser/LanguageStore", Interface>;
|
|
9
9
|
export declare class Service extends Service_base {
|
|
10
10
|
}
|
|
11
|
-
export declare const layer: Layer.Layer<Service, import("
|
|
11
|
+
export declare const layer: Layer.Layer<Service, import("../shared/errors/index.js").ParserInitError, never>;
|
|
12
12
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
|
-
import { ParserInitError } from "
|
|
2
|
+
import { ParserInitError } from "../shared/errors/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Tree-sitter engine initialization — the ORIGINAL design: `Parser.init()`
|
|
5
5
|
* with no override, so web-tree-sitter's glue resolves `tree-sitter.wasm`
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
2
|
+
import { type Graph } from "../shared/effect/node.js";
|
|
3
|
+
import { EmbeddingModelRegistry } from "../embedder/index.js";
|
|
4
|
+
import { Store as StoreService } from "../store/index.js";
|
|
5
|
+
import type { AugmentedMemory } from "../store/index.js";
|
|
5
6
|
declare const HybridError_base: Schema.Class<HybridError, Schema.TaggedStruct<"HybridRetrieval.HybridError", {
|
|
6
7
|
readonly message: Schema.String;
|
|
7
8
|
}>, import("effect/Cause").YieldableError>;
|
|
@@ -33,16 +34,29 @@ export interface Interface {
|
|
|
33
34
|
declare const Service_base: Context.ServiceClass<Service, "@dimple/retriever/HybridRetrieval", Interface>;
|
|
34
35
|
export declare class Service extends Service_base {
|
|
35
36
|
}
|
|
37
|
+
/** Retrieval defaults for `layer` and the `configured` node; both fields are
|
|
38
|
+
* optional, and an omitted field falls back to the built-in default
|
|
39
|
+
* (k = 60, limit = 10). */
|
|
40
|
+
export interface HybridRetrievalOptions {
|
|
41
|
+
readonly defaultK?: number;
|
|
42
|
+
readonly defaultLimit?: number;
|
|
43
|
+
}
|
|
36
44
|
/**
|
|
37
45
|
* Layer factory: `hybridRetrievalLayer()` (no args) is the default
|
|
38
46
|
* instance; pass `{ defaultK, defaultLimit }` to override the retrieval
|
|
39
47
|
* defaults (the config path threads `defaultK`/`defaultLimit`).
|
|
40
48
|
*/
|
|
41
|
-
export declare const layer: (options?:
|
|
42
|
-
readonly defaultK?: number;
|
|
43
|
-
readonly defaultLimit?: number;
|
|
44
|
-
}) => Layer.Layer<Service, HybridError, StoreService | EmbeddingModelRegistry>;
|
|
49
|
+
export declare const layer: (options?: HybridRetrievalOptions) => Layer.Layer<Service, HybridError, StoreService | EmbeddingModelRegistry>;
|
|
45
50
|
/** Default instance (no option overrides) — the classic const consumers
|
|
46
51
|
* (tests, compositions) keep working; the factory form stays available. */
|
|
47
52
|
export declare const hybridRetrievalLayer: Layer.Layer<Service, HybridError, StoreService | EmbeddingModelRegistry>;
|
|
53
|
+
/**
|
|
54
|
+
* Node declaration over the factory, for the composition root. The `Store` and
|
|
55
|
+
* `EmbeddingModelRegistry` providers are dependencies the root owns (the
|
|
56
|
+
* retriever package has no default store or embedder), so the caller passes
|
|
57
|
+
* them as the `deps` tuple; `make` then checks that they cover the layer's
|
|
58
|
+
* requirements. The tuple elements may be any graph that provides at least the
|
|
59
|
+
* named service, and their build errors are preserved on the node.
|
|
60
|
+
*/
|
|
61
|
+
export declare const configured: <const StoreE, const RegistryE>(options: HybridRetrievalOptions | undefined, deps: readonly [Graph<StoreService, StoreE>, Graph<EmbeddingModelRegistry, RegistryE>]) => import("../core/index.js").LayerProvider<Service, RegistryE | StoreE | HybridError, undefined>;
|
|
48
62
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { Service as HybridRetrieval, layer as hybridRetrievalLayerFactory, hybridRetrievalLayer, HybridError, type QueryProfile, } from "./hybrid.ts";
|
|
1
|
+
export { Service as HybridRetrieval, layer as hybridRetrievalLayerFactory, hybridRetrievalLayer, configured as hybridRetrievalConfigured, HybridError, type HybridRetrievalOptions, type QueryProfile, } from "./hybrid.ts";
|
|
2
2
|
export { fuse } from "./rrf.ts";
|
|
3
3
|
export type { RankResult } from "./rrf.ts";
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Brand, Context, Layer } from "effect";
|
|
2
|
+
/** The reference exposes its whole surface as one value namespace
|
|
3
|
+
* (`import { LayerNode } from "@opencode/util/effect/layer-node"`); dimple's
|
|
4
|
+
* module IS that surface, so the same name is exported here. */
|
|
5
|
+
export * as LayerNode from "./node.ts";
|
|
6
|
+
/**
|
|
7
|
+
* Typed layer graphs, ported from OpenCode v2's `LayerNode`
|
|
8
|
+
* (`packages/util/src/effect/layer-node.ts`).
|
|
9
|
+
*
|
|
10
|
+
* A graph is a node (`make`) or an ordered group (`group`). A node carries a
|
|
11
|
+
* service or name, an implementation layer, the nodes it depends on, and an
|
|
12
|
+
* optional tag. `compile` resolves the effective graph (applying
|
|
13
|
+
* replacements, rejecting cycles and unbound nodes), shares builds through
|
|
14
|
+
* Effect's memo maps, and infers the output layer from the declarations —
|
|
15
|
+
* there is no caller-stated cast.
|
|
16
|
+
*
|
|
17
|
+
* Type-level checks reject a node whose `deps` do not provide every service
|
|
18
|
+
* its layer requires, a replacement that drops outputs, widens errors, or
|
|
19
|
+
* crosses tags, and a group output that is not promised by every root. All
|
|
20
|
+
* declarations stay lazy: nothing is acquired until Effect builds the
|
|
21
|
+
* compiled layer.
|
|
22
|
+
*/
|
|
23
|
+
declare const GraphTypeId: unique symbol;
|
|
24
|
+
declare const VarianceTypeId: unique symbol;
|
|
25
|
+
declare const NodeTypeId: unique symbol;
|
|
26
|
+
declare const ReplacementTypeId: unique symbol;
|
|
27
|
+
export type Tag<Name extends string = string> = Name & Brand.Brand<"LayerNode.Tag">;
|
|
28
|
+
export type Graph<A, E = never, T extends Tag | undefined = Tag | undefined> = GraphValue<A, E, T>;
|
|
29
|
+
export type Node<A, E = never, T extends Tag | undefined = undefined> = NodeValue<A, E, T>;
|
|
30
|
+
export type Provider<A, E = never, T extends Tag | undefined = undefined> = ProviderNode<A, E, T>;
|
|
31
|
+
export type Replacement = ReplacementValue;
|
|
32
|
+
export type Replacements = readonly Replacement[];
|
|
33
|
+
type AnyGraph = Graph<never, unknown>;
|
|
34
|
+
type AnyNode = AnyGraph & {
|
|
35
|
+
readonly [NodeTypeId]: unknown;
|
|
36
|
+
readonly tag: Tag | undefined;
|
|
37
|
+
};
|
|
38
|
+
type RuntimeLayer = Layer.Layer<never, unknown, unknown>;
|
|
39
|
+
type GraphList = readonly [] | readonly [AnyGraph, ...AnyGraph[]];
|
|
40
|
+
export type Output<Item> = CommonOutput<Item, Item extends Graph<infer A, unknown> ? A : never>;
|
|
41
|
+
export type Error<Item> = Item extends Graph<never, infer E> ? E : never;
|
|
42
|
+
type GraphTag<Item> = [Item] extends [never] ? undefined : Item extends Graph<never, unknown, infer T> ? T : never;
|
|
43
|
+
type CommonOutput<Item, A> = A extends unknown ? [Item] extends [Graph<A, unknown>] ? A : never : never;
|
|
44
|
+
type LayerOutput<Item extends Layer.Any, A = Layer.Success<Item>> = A extends unknown ? [Item] extends [Layer.Layer<A, unknown, unknown>] ? A : never : never;
|
|
45
|
+
type ListOutput<Items extends readonly AnyGraph[], A = never> = [Items] extends [
|
|
46
|
+
readonly [infer Head extends AnyGraph, ...infer Tail extends readonly AnyGraph[]]
|
|
47
|
+
] ? ListOutput<Tail, A | Output<Head>> : A;
|
|
48
|
+
type Definition = {
|
|
49
|
+
readonly kind: "group";
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly dependencies: readonly AnyGraph[];
|
|
52
|
+
} | {
|
|
53
|
+
readonly kind: "unbound";
|
|
54
|
+
readonly name: string;
|
|
55
|
+
} | {
|
|
56
|
+
readonly kind: "layer";
|
|
57
|
+
readonly name: string;
|
|
58
|
+
readonly implementation: RuntimeLayer;
|
|
59
|
+
readonly dependencies: readonly AnyGraph[];
|
|
60
|
+
};
|
|
61
|
+
declare class GraphValue<in A, out E, out T extends Tag | undefined> {
|
|
62
|
+
private readonly graph;
|
|
63
|
+
readonly [VarianceTypeId]: {
|
|
64
|
+
readonly output: (_: A) => void;
|
|
65
|
+
readonly error: () => E;
|
|
66
|
+
readonly tags: () => T;
|
|
67
|
+
};
|
|
68
|
+
readonly [GraphTypeId]: Definition;
|
|
69
|
+
constructor(definition: Definition);
|
|
70
|
+
get name(): string;
|
|
71
|
+
}
|
|
72
|
+
declare class NodeValue<in out A, in out E, in out T extends Tag | undefined> extends GraphValue<A, E, T> {
|
|
73
|
+
readonly tag: T;
|
|
74
|
+
readonly [NodeTypeId]: (_: [A, E, T]) => [A, E, T];
|
|
75
|
+
constructor(definition: Exclude<Definition, {
|
|
76
|
+
kind: "group";
|
|
77
|
+
}>, tag: T);
|
|
78
|
+
/** Replace this declaration, including every dependency on it, without acquiring its old wiring. */
|
|
79
|
+
replace<const Target extends AnyNode | Layer.Any>(this: Node<A, E, T>, replacement: Target & CheckReplacement<A, E, T, Target>): Replacement;
|
|
80
|
+
}
|
|
81
|
+
declare class ProviderNode<in out A, in out E, in out T extends Tag | undefined> extends NodeValue<A, E, T> {
|
|
82
|
+
/** Decorate the implementation while preserving its dependency wiring and service contract. */
|
|
83
|
+
mapLayer(this: Provider<A, E, T>, f: <R>(layer: Layer.Layer<A, E, R>) => Layer.Layer<A, E, R>): Provider<A, E, T>;
|
|
84
|
+
}
|
|
85
|
+
declare class ReplacementValue {
|
|
86
|
+
private readonly checked;
|
|
87
|
+
readonly [ReplacementTypeId]: {
|
|
88
|
+
readonly source: AnyNode;
|
|
89
|
+
readonly target: AnyNode;
|
|
90
|
+
};
|
|
91
|
+
constructor(source: AnyNode, target: AnyNode);
|
|
92
|
+
}
|
|
93
|
+
type CheckErrors<Expected, Actual> = [Exclude<Actual, Expected>] extends [never] ? never : {
|
|
94
|
+
readonly "New replacement errors": Exclude<Actual, Expected>;
|
|
95
|
+
};
|
|
96
|
+
type CheckReplacement<A, E, T, Target> = [ReplacementErrors<A, E, T, Target>] extends [never] ? unknown : ReplacementErrors<A, E, T, Target>;
|
|
97
|
+
type ReplacementErrors<A, E, T, Target> = Target extends AnyNode ? [Exclude<A, Output<Target>>] extends [never] ? [GraphTag<Target>] extends [T] ? CheckErrors<E, Error<Target>> : {
|
|
98
|
+
readonly "Invalid replacement tag": GraphTag<Target>;
|
|
99
|
+
} : {
|
|
100
|
+
readonly "Missing replacement outputs": Exclude<A, Output<Target>>;
|
|
101
|
+
} : Target extends Layer.Layer<A, infer E2, never> ? CheckErrors<E, E2> : {
|
|
102
|
+
readonly "Replacement must be a closed layer": Target;
|
|
103
|
+
};
|
|
104
|
+
type CheckDependencies<Implementation extends Layer.Any, Items extends GraphList> = [
|
|
105
|
+
Exclude<Layer.Services<Implementation>, ListOutput<Items>>
|
|
106
|
+
] extends [never] ? unknown : {
|
|
107
|
+
readonly "Missing dependencies": Exclude<Layer.Services<Implementation>, ListOutput<Items>>;
|
|
108
|
+
};
|
|
109
|
+
type Identity = {
|
|
110
|
+
readonly service: Context.Service.Any;
|
|
111
|
+
readonly name?: never;
|
|
112
|
+
} | {
|
|
113
|
+
readonly name: string;
|
|
114
|
+
readonly service?: never;
|
|
115
|
+
};
|
|
116
|
+
type CheckLayer<Implementation> = [Implementation] extends [RuntimeLayer] ? unknown : {
|
|
117
|
+
readonly "Layer contract must be preserved": Implementation;
|
|
118
|
+
};
|
|
119
|
+
type TagInput<T> = {
|
|
120
|
+
readonly tag: T;
|
|
121
|
+
} | ([T] extends [undefined] ? {
|
|
122
|
+
readonly tag?: undefined;
|
|
123
|
+
} : never);
|
|
124
|
+
type MakeInput<Implementation extends Layer.Any, Items extends GraphList, T extends Tag | undefined> = Identity & TagInput<T> & {
|
|
125
|
+
readonly layer: Implementation & CheckLayer<NoInfer<Implementation>>;
|
|
126
|
+
readonly deps: Items & CheckDependencies<Implementation, NoInfer<Items>>;
|
|
127
|
+
};
|
|
128
|
+
type DistributiveOmit<A, K extends PropertyKey> = A extends unknown ? Omit<A, K> : never;
|
|
129
|
+
export type TagConfig = Readonly<Record<string, readonly string[]>>;
|
|
130
|
+
type TagNames<Config extends TagConfig> = keyof Config & string;
|
|
131
|
+
type CheckTags<Items extends GraphList, Names extends string> = [
|
|
132
|
+
Exclude<GraphTag<Items[number]>, Tag<Names> | undefined>
|
|
133
|
+
] extends [never] ? unknown : {
|
|
134
|
+
readonly "Invalid tag dependencies": Exclude<GraphTag<Items[number]>, Tag<Names> | undefined>;
|
|
135
|
+
};
|
|
136
|
+
export interface Tags<Config extends TagConfig> {
|
|
137
|
+
readonly values: {
|
|
138
|
+
readonly [Name in TagNames<Config>]: Tag<Name>;
|
|
139
|
+
};
|
|
140
|
+
readonly make: <Name extends TagNames<Config>>(name: Name) => <const Implementation extends Layer.Any, const Items extends GraphList>(input: DistributiveOmit<MakeInput<Implementation, Items, Tag<Name>>, "tag"> & CheckTags<Items, Name | Extract<Config[Name][number], string>>) => Provider<LayerOutput<Implementation>, Layer.Error<Implementation> | Error<Items[number]>, Tag<Name>>;
|
|
141
|
+
}
|
|
142
|
+
export declare function tags<const Config extends {
|
|
143
|
+
readonly [Name in keyof Config]: readonly (keyof Config & string)[];
|
|
144
|
+
}>(config: Config): Tags<Config>;
|
|
145
|
+
export declare function make<const Implementation extends Layer.Any, const Items extends GraphList, const T extends Tag | undefined = undefined>(input: MakeInput<Implementation, Items, T>): Provider<LayerOutput<Implementation>, Layer.Error<Implementation> | Error<Items[number]>, T>;
|
|
146
|
+
export declare function unbound<R, S, const T extends Tag>(service: Context.Key<R, S>, tag: T): Node<R, never, T>;
|
|
147
|
+
/** Ordered, associative composition. Only these roots' outputs are exposed; their dependencies remain private. */
|
|
148
|
+
export declare function group<const Items extends readonly AnyGraph[]>(dependencies: Items): Graph<ListOutput<Items>, Error<Items[number]>, GraphTag<Items[number]>>;
|
|
149
|
+
export interface CompileOptions {
|
|
150
|
+
readonly replacements?: Replacements;
|
|
151
|
+
/** Share subgraphs rooted at this tag; give the remaining wiring a fresh map for each build. */
|
|
152
|
+
readonly shared?: Tag;
|
|
153
|
+
}
|
|
154
|
+
/** Resolve the final overrides before validating or acquiring anything. Effect owns acquisition and finalization. */
|
|
155
|
+
export declare function compile<A, E>(root: Graph<A, E>, options?: CompileOptions): Layer.Layer<A, E>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-local database preparation shared by the store and jobs backends:
|
|
3
|
+
* create the parent directory libSQL cannot, then restrict the database file
|
|
4
|
+
* and its sidecars to the owner (`0600`).
|
|
5
|
+
*
|
|
6
|
+
* SQLite creates new sidecars (`-journal`, `-wal`, `-shm`) with the
|
|
7
|
+
* database's own mode, so restricting the database file also covers sidecars
|
|
8
|
+
* created later. Any existing mode is overridden — an old permissive file is
|
|
9
|
+
* tightened on the next boot, and a file the process can write but cannot
|
|
10
|
+
* chmod fails the boot instead of running permissively.
|
|
11
|
+
*
|
|
12
|
+
* Reference: opencode v2's `Database` layer (`restrictToOwner`) — a
|
|
13
|
+
* local-first store must not be world-readable under a permissive umask.
|
|
14
|
+
* `node:fs` is imported lazily and remote URLs are untouched, so the module
|
|
15
|
+
* stays bundler-safe for workerd.
|
|
16
|
+
*/
|
|
17
|
+
export declare const prepareFileDatabase: (url: string) => Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-process migration lock shared by the store backend and the workflow
|
|
3
|
+
* queue stack. Both run `CREATE TABLE`-style migrations on a `file:` database
|
|
4
|
+
* at boot; two runtimes starting together race them and the loser fails with
|
|
5
|
+
* a raw "Failed to execute statement". An exclusive lock file next to the
|
|
6
|
+
* database serializes them. Remote URLs skip locking — the server owns its
|
|
7
|
+
* migrations.
|
|
8
|
+
*
|
|
9
|
+
* `node:fs` is imported lazily: callers bundle for workerd, and the lock is
|
|
10
|
+
* only ever reached for `file:` URLs.
|
|
11
|
+
*/
|
|
12
|
+
export interface FileLockOptions {
|
|
13
|
+
/** Steal a lock whose mtime is older than this (a crashed owner). */
|
|
14
|
+
readonly staleMs?: number;
|
|
15
|
+
/** Give up after this long and throw (default 30s). */
|
|
16
|
+
readonly timeoutMs?: number;
|
|
17
|
+
}
|
|
18
|
+
/** Acquire `<db>.migrate-lock` for a `file:` URL. Remote URLs resolve to
|
|
19
|
+
* `undefined` (nothing to release). */
|
|
20
|
+
export declare const acquireMigrationLock: (url: string) => Promise<(() => void) | undefined>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Defaulted optional struct fields for Effect 4.0.0.
|
|
4
|
+
*
|
|
5
|
+
* `Schema.optionalWith` does not exist in this version; `optional` plus
|
|
6
|
+
* `withDecodingDefaultType` is the equivalent: the key may be absent or
|
|
7
|
+
* `undefined` on input, the default fills it during decoding, and the
|
|
8
|
+
* decoded type keeps the field required. Curried so the default thunk is
|
|
9
|
+
* contextually typed against the already-fixed schema type.
|
|
10
|
+
*/
|
|
11
|
+
export declare const optionalWithDefault: <S extends Schema.Constraint>(schema: S) => (options: {
|
|
12
|
+
default: () => Schema.Schema.Type<S>;
|
|
13
|
+
}) => Schema.withDecodingDefaultType<Schema.optional<S>>;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import
|
|
2
|
+
import type { RetrievalAuditRow } from "./models.ts";
|
|
3
|
+
import { JobFailure, type Handler, type JobContext } from "../workflow/index.js";
|
|
3
4
|
import { Service as DbBackend } from "./db-backend.ts";
|
|
4
5
|
import type { Interface as DbBackendInterface } from "./db-backend.ts";
|
|
6
|
+
/** The decoded `audit.write` payload — mirrors the queue definition's
|
|
7
|
+
* schema (`{ rows }`); the executor decodes before calling. */
|
|
8
|
+
export interface AuditWritePayload {
|
|
9
|
+
readonly rows: ReadonlyArray<RetrievalAuditRow>;
|
|
10
|
+
}
|
|
5
11
|
/** The `audit.write` handler shape (see queue.ts). */
|
|
6
|
-
export type AuditWriteHandler = (payload:
|
|
12
|
+
export type AuditWriteHandler = (payload: AuditWritePayload, ctx: JobContext) => Effect.Effect<unknown, JobFailure, DbBackend>;
|
|
7
13
|
/**
|
|
8
14
|
* Factory for the `audit.write` job handler. Payload: `{ rows }` — one or
|
|
9
15
|
* more `retrieval_log` rows enqueued by the store's `enqueueAudit` seam
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context, Effect } from "effect";
|
|
2
2
|
import type { StoreError } from "./error.ts";
|
|
3
3
|
import type { RetrievalAuditRow, SweepResult } from "./models.ts";
|
|
4
|
-
import type { EmbeddingModelConfig } from "
|
|
4
|
+
import type { EmbeddingModelConfig } from "../config/index.js";
|
|
5
5
|
/** Opaque handle to a Drizzle database instance.
|
|
6
6
|
* Concrete type varies by backend dialect (LibSQLDatabase, PgDatabase, etc.).
|
|
7
7
|
* Standard CRUD uses Drizzle's polymorphic query builder — no dialect-specific cast needed
|
|
@@ -29,7 +29,7 @@ export interface TopicVectorRow {
|
|
|
29
29
|
/** A memory embedding row from a per-model memory vector table (raw SQL boundary shape). */
|
|
30
30
|
export interface MemoryVectorRow {
|
|
31
31
|
readonly memoryId: string;
|
|
32
|
-
readonly vector: number[];
|
|
32
|
+
readonly vector: readonly number[];
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Canonical row of a `graphNeighbors` traversal.
|
|
@@ -54,12 +54,23 @@ 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
|
|
60
64
|
* of the model that wrote them). */
|
|
61
65
|
readonly modelKey?: string;
|
|
62
66
|
}
|
|
67
|
+
/** Metadata filter keys for `queryByMetadata` — `topic` (LIKE on
|
|
68
|
+
* `$.topics`) and `sourceType` (equality on `$.sourceType`); unknown keys
|
|
69
|
+
* are ignored (see the SQL in libsql-backend). */
|
|
70
|
+
export interface MetadataFilter {
|
|
71
|
+
readonly topic?: string;
|
|
72
|
+
readonly sourceType?: string;
|
|
73
|
+
}
|
|
63
74
|
export interface Interface {
|
|
64
75
|
readonly runMigrations: () => Effect.Effect<void, StoreError>;
|
|
65
76
|
/**
|
|
@@ -77,31 +88,58 @@ export interface Interface {
|
|
|
77
88
|
* `limit` bounds the rows (0 = unbounded); `modelKey` optionally scopes
|
|
78
89
|
* to the model's active population.
|
|
79
90
|
*/
|
|
80
|
-
readonly listIsolatedMemories: (limit: number, modelKey?: string) => Effect.Effect<readonly
|
|
91
|
+
readonly listIsolatedMemories: (limit: number, modelKey?: string) => Effect.Effect<readonly unknown[], StoreError>;
|
|
81
92
|
readonly db: DrizzleDB;
|
|
82
93
|
readonly tables: StoreTables;
|
|
83
|
-
readonly ftsSearch: (query: string, namespace: string, limit: number, topicKeys?: ReadonlyArray<string>, modelKey?: string
|
|
84
|
-
|
|
94
|
+
readonly ftsSearch: (query: string, namespace: string, limit: number, topicKeys?: ReadonlyArray<string>, modelKey?: string, contentType?: string | ReadonlyArray<string>,
|
|
95
|
+
/** Include the 384-float `embedding` blob per row (default false —
|
|
96
|
+
* search results never need vectors; write paths read them via
|
|
97
|
+
* fetchMemoryVectors). */
|
|
98
|
+
includeEmbedding?: boolean) => Effect.Effect<readonly unknown[], StoreError>;
|
|
99
|
+
readonly vectorSearch: (query: ReadonlyArray<number>, namespace: string, limit: number, model: EmbeddingModelConfig, topicKeys?: ReadonlyArray<string>, contentType?: string | ReadonlyArray<string>, includeEmbedding?: boolean) => Effect.Effect<readonly unknown[], StoreError>;
|
|
85
100
|
readonly sweep: (namespace: string) => Effect.Effect<SweepResult, StoreError>;
|
|
101
|
+
/** The DB's tables + columns (`dimple db-schema` surface). */
|
|
102
|
+
readonly listSchema: () => Effect.Effect<ReadonlyArray<{
|
|
103
|
+
readonly table: string;
|
|
104
|
+
readonly columns: ReadonlyArray<{
|
|
105
|
+
readonly name: string;
|
|
106
|
+
readonly type: string;
|
|
107
|
+
}>;
|
|
108
|
+
}>, StoreError>;
|
|
86
109
|
/** Persist retrieval-audit rows (`retrieval_log`). Owned by the backend
|
|
87
110
|
* so the `audit.write` job handler stays dialect-neutral. */
|
|
88
111
|
readonly writeAuditRows: (rows: readonly RetrievalAuditRow[]) => Effect.Effect<void, StoreError>;
|
|
89
112
|
/** Metadata-filtered memory lookup (the one
|
|
90
113
|
* `json_extract` (SQLite) / `->` (PG) portability wart, now backend-owned
|
|
91
|
-
* like `ftsSearch`). Raw SQL, returns
|
|
92
|
-
*
|
|
93
|
-
*
|
|
114
|
+
* like `ftsSearch`). Raw SQL, returns raw rows — the store casts once at
|
|
115
|
+
* the boundary. Supported filter keys mirror the old store-level SQL
|
|
116
|
+
* exactly: `topic` (LIKE on `$.topics`) and `sourceType`
|
|
94
117
|
* (equality on `$.sourceType`); unknown keys are ignored. `limit` is
|
|
95
118
|
* optional — omitted means no LIMIT. */
|
|
96
|
-
readonly queryByMetadata: (filter:
|
|
97
|
-
readonly graphNeighbors: (kind: "memory" | "topic" | "concept", id: string, opts?: GraphNeighborsOptions) => Effect.Effect<readonly
|
|
119
|
+
readonly queryByMetadata: (filter: MetadataFilter, limit?: number) => Effect.Effect<readonly unknown[], StoreError>;
|
|
120
|
+
readonly graphNeighbors: (kind: "memory" | "topic" | "concept", id: string, opts?: GraphNeighborsOptions) => Effect.Effect<readonly unknown[], StoreError>;
|
|
98
121
|
readonly ensureVectorTable: (model: EmbeddingModelConfig) => Effect.Effect<void, StoreError>;
|
|
99
122
|
readonly insertVector: (memoryId: string, vector: ReadonlyArray<number>, model: EmbeddingModelConfig) => Effect.Effect<void, StoreError>;
|
|
123
|
+
/** Batch variant of `insertVector` — one multi-row statement (bulk
|
|
124
|
+
* ingest: per-memory statements dominate the write path). */
|
|
125
|
+
readonly insertVectors: (entries: ReadonlyArray<{
|
|
126
|
+
readonly memoryId: string;
|
|
127
|
+
readonly vector: ReadonlyArray<number>;
|
|
128
|
+
}>, model: EmbeddingModelConfig) => Effect.Effect<void, StoreError>;
|
|
100
129
|
readonly deleteVector: (memoryId: string, dimensions: number) => Effect.Effect<void, StoreError>;
|
|
101
130
|
readonly ensureTopicVectorTable: (model: EmbeddingModelConfig) => Effect.Effect<void, StoreError>;
|
|
102
131
|
readonly upsertTopicVector: (topicKey: string, sumVector: ReadonlyArray<number>, model: EmbeddingModelConfig) => Effect.Effect<void, StoreError>;
|
|
132
|
+
/** Batch variant of `upsertTopicVector` — one multi-row statement (the
|
|
133
|
+
* bulk-routing path: sequential per-key upserts dominate batch ingest). */
|
|
134
|
+
readonly upsertTopicVectors: (entries: ReadonlyArray<{
|
|
135
|
+
readonly topicKey: string;
|
|
136
|
+
readonly sumVector: ReadonlyArray<number>;
|
|
137
|
+
}>, model: EmbeddingModelConfig) => Effect.Effect<void, StoreError>;
|
|
103
138
|
readonly deleteTopicVectors: (model: EmbeddingModelConfig) => Effect.Effect<void, StoreError>;
|
|
104
139
|
readonly fetchTopicVectors: (model: EmbeddingModelConfig) => Effect.Effect<ReadonlyArray<TopicVectorRow>, StoreError>;
|
|
140
|
+
/** Single-row variant — the forget path's per-ancestor maintenance
|
|
141
|
+
* re-read the WHOLE table per level before (O(depth × N) decodes). */
|
|
142
|
+
readonly fetchTopicVector: (topicKey: string, model: EmbeddingModelConfig) => Effect.Effect<TopicVectorRow | undefined, StoreError>;
|
|
105
143
|
readonly fetchMemoryVectors: (memoryIds: ReadonlyArray<string>, model: EmbeddingModelConfig) => Effect.Effect<ReadonlyArray<MemoryVectorRow>, StoreError>;
|
|
106
144
|
readonly listMemoryIds: (model: EmbeddingModelConfig) => Effect.Effect<ReadonlyArray<string>, StoreError>;
|
|
107
145
|
}
|
|
@@ -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
|