@ponraaj/dimple-sdk 0.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/dist/config.d.ts +13 -0
  2. package/dist/dimple.d.ts +101 -0
  3. package/dist/errors.d.ts +63 -0
  4. package/dist/index.d.ts +4 -0
  5. package/dist/index.js +8430 -0
  6. package/dist/indexer.d.ts +43 -0
  7. package/dist/internal/config/index.d.ts +4 -0
  8. package/dist/internal/config/loader.d.ts +9 -0
  9. package/dist/internal/config/schema.d.ts +176 -0
  10. package/dist/internal/config/service.d.ts +10 -0
  11. package/dist/internal/core/core.d.ts +95 -0
  12. package/dist/internal/core/index.d.ts +3 -0
  13. package/dist/internal/core/layer.d.ts +21 -0
  14. package/dist/internal/embedder/index.d.ts +4 -0
  15. package/dist/internal/embedder/openai.d.ts +8 -0
  16. package/dist/internal/embedder/provider.d.ts +29 -0
  17. package/dist/internal/embedder/registry.d.ts +10 -0
  18. package/dist/internal/embedder/transformers.d.ts +18 -0
  19. package/dist/internal/extractor/code-extractor.d.ts +15 -0
  20. package/dist/internal/extractor/content-handler.d.ts +17 -0
  21. package/dist/internal/extractor/index.d.ts +4 -0
  22. package/dist/internal/extractor/languages/index.d.ts +24 -0
  23. package/dist/internal/extractor/languages/javascript.d.ts +22 -0
  24. package/dist/internal/extractor/languages/typescript.d.ts +20 -0
  25. package/dist/internal/extractor/models/extraction.d.ts +53 -0
  26. package/dist/internal/llm/dream-classifier.d.ts +14 -0
  27. package/dist/internal/llm/index.d.ts +4 -0
  28. package/dist/internal/llm/llm.d.ts +54 -0
  29. package/dist/internal/llm/provider.d.ts +14 -0
  30. package/dist/internal/llm/service.d.ts +29 -0
  31. package/dist/internal/logger/format.d.ts +6 -0
  32. package/dist/internal/logger/index.d.ts +4 -0
  33. package/dist/internal/logger/ring.d.ts +33 -0
  34. package/dist/internal/logger/service.d.ts +50 -0
  35. package/dist/internal/logger/types.d.ts +39 -0
  36. package/dist/internal/parser/code-parser.d.ts +12 -0
  37. package/dist/internal/parser/index.d.ts +7 -0
  38. package/dist/internal/parser/language-store.d.ts +12 -0
  39. package/dist/internal/parser/models/parseRequest.d.ts +17 -0
  40. package/dist/internal/parser/models/treeHandle.d.ts +23 -0
  41. package/dist/internal/parser/tree-sitter-engine.d.ts +15 -0
  42. package/dist/internal/retriever/hybrid.d.ts +48 -0
  43. package/dist/internal/retriever/index.d.ts +3 -0
  44. package/dist/internal/retriever/rrf.d.ts +11 -0
  45. package/dist/internal/shared/errors/index.d.ts +2 -0
  46. package/dist/internal/shared/errors/parser.d.ts +21 -0
  47. package/dist/internal/shared/errors/wasm.d.ts +28 -0
  48. package/dist/internal/shared/types/index.d.ts +1 -0
  49. package/dist/internal/shared/types/language.d.ts +3 -0
  50. package/dist/internal/store/audit.d.ts +21 -0
  51. package/dist/internal/store/db-backend.d.ts +111 -0
  52. package/dist/internal/store/drizzle-schema.d.ts +1 -0
  53. package/dist/internal/store/error.d.ts +19 -0
  54. package/dist/internal/store/fnv1a32.d.ts +14 -0
  55. package/dist/internal/store/generated-migrations.d.ts +15 -0
  56. package/dist/internal/store/graph/candidates.d.ts +93 -0
  57. package/dist/internal/store/graph/concepts.d.ts +169 -0
  58. package/dist/internal/store/graph/dream.d.ts +171 -0
  59. package/dist/internal/store/graph/errors.d.ts +25 -0
  60. package/dist/internal/store/graph/index.d.ts +15 -0
  61. package/dist/internal/store/graph/observability.d.ts +37 -0
  62. package/dist/internal/store/graph/repair.d.ts +85 -0
  63. package/dist/internal/store/graph/retrieval-post-pass.d.ts +58 -0
  64. package/dist/internal/store/graph/traversal.d.ts +39 -0
  65. package/dist/internal/store/index.d.ts +38 -0
  66. package/dist/internal/store/libsql-backend.d.ts +18 -0
  67. package/dist/internal/store/models.d.ts +122 -0
  68. package/dist/internal/store/schema/graph.d.ts +970 -0
  69. package/dist/internal/store/schema/index.d.ts +7 -0
  70. package/dist/internal/store/schema/libsql.d.ts +2356 -0
  71. package/dist/internal/store/schema/metadata.d.ts +51 -0
  72. package/dist/internal/store/schema/topics.d.ts +1966 -0
  73. package/dist/internal/store/service.d.ts +162 -0
  74. package/dist/internal/store/store.d.ts +70 -0
  75. package/dist/internal/store/topics/errors.d.ts +39 -0
  76. package/dist/internal/store/topics/index.d.ts +24 -0
  77. package/dist/internal/store/topics/jobs.d.ts +149 -0
  78. package/dist/internal/store/topics/lifecycle.d.ts +126 -0
  79. package/dist/internal/store/topics/maintenance.d.ts +110 -0
  80. package/dist/internal/store/topics/observability.d.ts +102 -0
  81. package/dist/internal/store/topics/query.d.ts +43 -0
  82. package/dist/internal/store/topics/routing.d.ts +90 -0
  83. package/dist/internal/store/topics/topic-vectors.d.ts +24 -0
  84. package/dist/internal/store/topics/tree.d.ts +181 -0
  85. package/dist/internal/wasm/grammar-store.d.ts +14 -0
  86. package/dist/internal/wasm/index.d.ts +5 -0
  87. package/dist/internal/wasm/wasm-cache.d.ts +17 -0
  88. package/dist/internal/wasm/wasm-downloader.d.ts +10 -0
  89. package/dist/internal/wasm/wasm-registry.d.ts +16 -0
  90. package/dist/internal/workflow/config.d.ts +39 -0
  91. package/dist/internal/workflow/engine.d.ts +54 -0
  92. package/dist/internal/workflow/errors.d.ts +77 -0
  93. package/dist/internal/workflow/executor.d.ts +53 -0
  94. package/dist/internal/workflow/index.d.ts +13 -0
  95. package/dist/internal/workflow/persistence.d.ts +122 -0
  96. package/dist/internal/workflow/queue-store.d.ts +5 -0
  97. package/dist/internal/workflow/queue.d.ts +298 -0
  98. package/dist/internal/workflow/registry.d.ts +57 -0
  99. package/dist/internal/workflow/runtime.d.ts +161 -0
  100. package/dist/make.d.ts +27 -0
  101. package/package.json +45 -0
@@ -0,0 +1,54 @@
1
+ import { Cause, Effect, Schema } from "effect";
2
+ import { type LanguageModel } from "ai";
3
+ import { z } from "zod";
4
+ declare const LLMError_base: Schema.Class<LLMError, Schema.TaggedStruct<"llm.LLMError", {
5
+ readonly message: Schema.String;
6
+ readonly cause: Schema.optional<Schema.Defect>;
7
+ }>, Cause.YieldableError>;
8
+ export declare class LLMError extends LLMError_base {
9
+ }
10
+ /** Provider reasoning-effort levels (opt-in; only sent when configured —
11
+ * servers that don't support it ignore the extra field). */
12
+ export type ReasoningEffort = "low" | "medium" | "high";
13
+ export interface GenerateTextInput {
14
+ readonly prompt: string;
15
+ readonly system?: string;
16
+ readonly temperature?: number;
17
+ readonly maxOutputTokens?: number;
18
+ readonly reasoningEffort?: ReasoningEffort;
19
+ }
20
+ export interface GenerateObjectInput<A> {
21
+ readonly prompt: string;
22
+ readonly system?: string;
23
+ readonly schema: z.ZodType<A>;
24
+ readonly temperature?: number;
25
+ readonly maxOutputTokens?: number;
26
+ readonly reasoningEffort?: ReasoningEffort;
27
+ }
28
+ /** Construction-time defaults (the `llm` config section); per-call
29
+ * overrides win. */
30
+ export interface LLMDefaults {
31
+ readonly temperature?: number | undefined;
32
+ readonly maxOutputTokens?: number | undefined;
33
+ readonly reasoningEffort?: ReasoningEffort | undefined;
34
+ }
35
+ export interface LLM {
36
+ readonly generateText: (input: GenerateTextInput) => Effect.Effect<string, LLMError>;
37
+ readonly generateObject: <A>(input: GenerateObjectInput<A>) => Effect.Effect<A, LLMError>;
38
+ }
39
+ /**
40
+ * Wraps a Vercel AI SDK language model behind a small Effect-based interface.
41
+ * The wrapper is provider-agnostic: any `LanguageModel` works, and callers
42
+ * never touch the AI SDK directly. All provider failures surface as a typed
43
+ * `LLMError` on the error channel.
44
+ *
45
+ * Structured generation forces a synthetic tool call — the one
46
+ * structured-output mechanism every chat protocol supports (tool-call
47
+ * arguments are strict JSON, so there is no dependency on `response_format`
48
+ * modes that many OpenAI-compatible gateways reject, and no fragile
49
+ * fence-stripping). Providers without tool support fall back to plain text
50
+ * generation with the JSON schema embedded in the prompt plus tolerant
51
+ * extraction; both paths end in zod validation.
52
+ */
53
+ export declare const makeLLM: (model: LanguageModel, defaults?: LLMDefaults) => LLM;
54
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { LanguageModel } from "ai";
2
+ export interface OpenAICompatibleOptions {
3
+ readonly baseURL: string;
4
+ readonly apiKey: string;
5
+ readonly modelId?: string;
6
+ readonly name?: string;
7
+ }
8
+ /**
9
+ * Builds a language model for any OpenAI-compatible chat endpoint
10
+ * (for example OpenCode Go style base URLs). The model id defaults to
11
+ * "default", which those gateways route to their default model; pass
12
+ * `modelId` to target a specific model on the endpoint.
13
+ */
14
+ export declare const openAICompatible: (options: OpenAICompatibleOptions) => LanguageModel;
@@ -0,0 +1,29 @@
1
+ import { Config, Context, Layer } from "effect";
2
+ import { Service as ConfigService } from "./internal/config/index.js";
3
+ import { type LLM, type LLMDefaults } from "./llm.ts";
4
+ /**
5
+ * Connection options for the OpenAI-compatible LLM layer: the chat
6
+ * endpoint base URL, the API key for that endpoint, and the model id the
7
+ * endpoint should route to (OpenCode Go style gateways accept "default").
8
+ * The layer builds a language model from these and wraps it with
9
+ * `makeLLM`.
10
+ */
11
+ export interface LLMOptions extends LLMDefaults {
12
+ readonly baseURL: string;
13
+ readonly apiKey: string;
14
+ readonly modelId: string;
15
+ }
16
+ /** The LLM service surface — the `makeLLM` wrapper's methods. */
17
+ export interface Interface extends LLM {
18
+ }
19
+ declare const Service_base: Context.ServiceClass<Service, "@dimple/LLM", Interface>;
20
+ export declare class Service extends Service_base {
21
+ }
22
+ export declare const layer: (options: LLMOptions) => Layer.Layer<Service, never, never>;
23
+ export declare const layerConfig: (config: Config.Wrap<LLMOptions>) => Layer.Layer<Service, Config.ConfigError, never>;
24
+ /**
25
+ * Builds the LLM layer from the loaded `dimple.json` config (the `llm`
26
+ * section). Fails with a clear error when the section is absent.
27
+ */
28
+ export declare const layerFromConfig: () => Layer.Layer<Service, Error, ConfigService>;
29
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { LogEntry } from "./types.ts";
2
+ /** Render one entry as a single JSON line (JSONL/NDJSON: append-only, one
3
+ * bad line is isolated, a crash corrupts at most the last partial line). */
4
+ export declare function renderJson(entry: LogEntry): string;
5
+ /** Human-readable one-line rendering for console debugging. */
6
+ export declare function renderPretty(entry: LogEntry): string;
@@ -0,0 +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";
2
+ export { LogConfig, LogLevel, SEV_NUM, LEVEL_ORDER, type LogEntry } from "./types.ts";
3
+ export { RingBuffer, type RingFrame, type Subscriber } from "./ring.ts";
4
+ export { renderJson, renderPretty } from "./format.ts";
@@ -0,0 +1,33 @@
1
+ /** One pre-rendered line + monotonic sequence id (for Last-Event-ID
2
+ * resume on the SSE tail). */
3
+ export interface RingFrame {
4
+ readonly seq: number;
5
+ readonly line: string;
6
+ }
7
+ export interface Subscriber {
8
+ readonly id: number;
9
+ /** null once the subscriber has been evicted for being too slow. */
10
+ readonly poll: () => string[] | null;
11
+ readonly close: () => void;
12
+ }
13
+ /** Drop-oldest ring of pre-rendered log lines with per-subscriber bounded
14
+ * queues (the live-tail mirror). NOT durable — the file sink is the source
15
+ * of truth (Vector buffering model); a crash loses the ring only. */
16
+ export declare class RingBuffer {
17
+ private readonly frames;
18
+ private nextSeq;
19
+ private nextId;
20
+ private readonly queues;
21
+ private readonly evicted;
22
+ private readonly capacity;
23
+ /** Invalid capacities (0, negative, NaN, Infinity) clamp to 0 — a
24
+ * zero-capacity ring retains nothing. */
25
+ constructor(capacity: number);
26
+ get seq(): number;
27
+ /** All frames currently held (initial snapshot for a new subscriber). */
28
+ snapshot(): RingFrame[];
29
+ push(line: string): void;
30
+ /** Subscribe for live frames. `poll()` drains the subscriber's queue;
31
+ * returns null once the subscriber was evicted (caller closes). */
32
+ subscribe(): Subscriber;
33
+ }
@@ -0,0 +1,50 @@
1
+ import { Config, Context, Layer, Logger } from "effect";
2
+ import type { Scope } from "effect/Scope";
3
+ import { RingBuffer } from "./ring.ts";
4
+ import { type LogConfig, type LogEntry } from "./types.ts";
5
+ /** A sink consumes rendered log lines. File sinks always render JSONL
6
+ * (the durable, machine-readable source of truth); the console sink may
7
+ * render pretty for humans. */
8
+ export interface Sink {
9
+ /** Receives the ENTRY — each sink renders it its own way (pretty on the
10
+ * console, JSONL in the file and ring). */
11
+ readonly write: (entry: LogEntry) => void;
12
+ readonly dispose: () => void;
13
+ }
14
+ export declare const consoleSink: (pretty: boolean) => Sink;
15
+ /** Append-per-event file sink (the pino model): each rendered line goes
16
+ * straight to the fd and the OS page cache does the buffering; `fsync`
17
+ * 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;
20
+ export interface Interface {
21
+ readonly emit: (entry: LogEntry) => void;
22
+ /** Live tail mirror: pre-rendered JSONL lines, drop-oldest, NOT durable. */
23
+ readonly ring: RingBuffer;
24
+ readonly dispose: () => void;
25
+ }
26
+ declare const Service_base: Context.ServiceClass<Service, "@dimple/logger/Logging", Interface>;
27
+ export declare class Service extends Service_base {
28
+ }
29
+ export declare const make: (config: LogConfig) => Interface;
30
+ /** The structured shape Effect's `Logger.formatStructured` emits. */
31
+ export interface StructuredOutput {
32
+ readonly level: string;
33
+ readonly fiberId: string;
34
+ readonly timestamp: string;
35
+ readonly message: unknown;
36
+ readonly cause: string | undefined;
37
+ readonly annotations: Record<string, unknown>;
38
+ readonly spans: Record<string, number>;
39
+ }
40
+ /** The Effect `Logger` that feeds the Logging service. */
41
+ export declare const effectLogger: (logging: Interface) => Logger.Logger<unknown, void>;
42
+ /** Installs the Logging service AND replaces Effect's default logger with
43
+ * the adapter feeding it. `mergeWithExisting: false` — one logger
44
+ * everywhere (the job runtime emits through this too). */
45
+ export declare const layer: (config: LogConfig) => Layer.Layer<Service, never, Scope>;
46
+ /** Config-driven variant (the repo convention): `layerConfig(config)` or
47
+ * `layerConfig(Config.succeed({...}))` — resolves the config inside the
48
+ * layer and delegates to `layer` (no Effect.runSync in package sources). */
49
+ export declare const layerConfig: (config: Config.Wrap<LogConfig>) => Layer.Layer<Service, Config.ConfigError, Scope>;
50
+ export {};
@@ -0,0 +1,39 @@
1
+ import { Schema } from "effect";
2
+ /** Named levels, ordered low → high. `All`/`None` are absent on purpose:
3
+ * a user-configured logger always has a concrete floor. */
4
+ export type LogLevel = "trace" | "debug" | "info" | "warn" | "error";
5
+ /** v4-beta note: `Schema.Literals` takes a readonly array (not variadic). */
6
+ export declare const LogLevel: Schema.Literals<readonly ["trace", "debug", "info", "warn", "error"]>;
7
+ /** OTel severity numbers (logs data model): TRACE=1, DEBUG=5, INFO=9,
8
+ * WARN=13, ERROR=17. */
9
+ export declare const SEV_NUM: Record<LogLevel, number>;
10
+ export declare const LEVEL_ORDER: Record<LogLevel, number>;
11
+ export declare const LogConfig: Schema.Struct<{
12
+ readonly enabled: Schema.withDecodingDefaultType<Schema.optional<Schema.Boolean>, never>;
13
+ readonly level: Schema.withDecodingDefaultType<Schema.optional<Schema.Literals<readonly ["trace", "debug", "info", "warn", "error"]>>, never>;
14
+ readonly format: Schema.withDecodingDefaultType<Schema.optional<Schema.Literals<readonly ["jsonl", "pretty"]>>, never>;
15
+ /** Optional file path for the durable sink (JSONL appended per event). */
16
+ readonly file: Schema.optionalKey<Schema.String>;
17
+ /** Per-emitting-package level overrides, keyed by package name. */
18
+ readonly scopes: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Literals<readonly ["trace", "debug", "info", "warn", "error"]>>>;
19
+ /** Ring buffer capacity for the live tail (pre-rendered lines). Invalid
20
+ * values (0, negative, NaN, Infinity) are clamped by the RingBuffer. */
21
+ readonly ringSize: Schema.withDecodingDefaultType<Schema.optional<Schema.Number>, never>;
22
+ }>;
23
+ export type LogConfig = Schema.Schema.Type<typeof LogConfig>;
24
+ /** OTel-aligned structured log entry. `scope` is the EMITTING PACKAGE
25
+ * (InstrumentationScope), never a feature name; `event` is a stable,
26
+ * low-cardinality operation name; variable payload goes in `attrs`. */
27
+ export interface LogEntry {
28
+ readonly ts: string;
29
+ readonly level: LogLevel;
30
+ readonly sevNum: number;
31
+ readonly scope: string;
32
+ readonly event: string;
33
+ readonly message: string;
34
+ readonly fiber: string;
35
+ readonly traceId?: string;
36
+ readonly spanId?: string;
37
+ readonly attrs: Record<string, unknown>;
38
+ readonly cause?: string;
39
+ }
@@ -0,0 +1,12 @@
1
+ import { Context, Effect, Layer } from "effect";
2
+ import { TreeHandle } from "./models/treeHandle";
3
+ import type { ParseRequest } from "./models/parseRequest";
4
+ import { ParseError } from "@dimple/shared/errors";
5
+ export interface Interface {
6
+ readonly parse: (request: ParseRequest) => Effect.Effect<TreeHandle, ParseError>;
7
+ }
8
+ declare const Service_base: Context.ServiceClass<Service, "@dimple/parser/CodeParser", Interface>;
9
+ export declare class Service extends Service_base {
10
+ }
11
+ export declare const layer: Layer.Layer<Service, import("@dimple/shared/errors").ParserInitError, never>;
12
+ export {};
@@ -0,0 +1,7 @@
1
+ export { Service as CodeParser, layer as codeParserLayer } from "./code-parser";
2
+ export { Service as LanguageStore, layer as languageStoreLayer } from "./language-store";
3
+ export { layer as treeSitterEngineLayer } from "./tree-sitter-engine";
4
+ export { ParseRequest } from "./models/parseRequest";
5
+ export { TreeHandle, TreeSchema } from "./models/treeHandle";
6
+ export type { LanguageId } from "@dimple/shared/types/language";
7
+ export { ParserInitError, LanguageLoadError, ParseError } from "@dimple/shared/errors";
@@ -0,0 +1,12 @@
1
+ import { Context, Effect, Layer } from "effect";
2
+ import type { LanguageId } from "@dimple/shared/types/language";
3
+ import { LanguageLoadError } from "@dimple/shared/errors";
4
+ import { Language } from "web-tree-sitter";
5
+ export interface Interface {
6
+ readonly get: (lang: LanguageId) => Effect.Effect<Language, LanguageLoadError>;
7
+ }
8
+ declare const Service_base: Context.ServiceClass<Service, "@dimple/parser/LanguageStore", Interface>;
9
+ export declare class Service extends Service_base {
10
+ }
11
+ export declare const layer: Layer.Layer<Service, import("@dimple/shared/errors").ParserInitError, never>;
12
+ export {};
@@ -0,0 +1,17 @@
1
+ import { Schema } from "effect";
2
+ /**
3
+ * Schema for ParseRequest - the input to CodeParser.parse().
4
+ *
5
+ * Validates at runtime that:
6
+ * - lang is a valid LanguageId
7
+ * - source is a non-empty-or-any string
8
+ *
9
+ * Example:
10
+ *
11
+ * ParseRequest({ lang: "typescript", source: "const x = 1" })
12
+ */
13
+ export declare const ParseRequest: Schema.Struct<{
14
+ readonly lang: Schema.Literals<readonly ["javascript", "typescript", "tsx", "jsx", "python", "rust", "go"]>;
15
+ readonly source: Schema.String;
16
+ }>;
17
+ export type ParseRequest = Schema.Schema.Type<typeof ParseRequest>;
@@ -0,0 +1,23 @@
1
+ import { Schema } from "effect";
2
+ import { Tree } from "web-tree-sitter";
3
+ /**
4
+ * Schema for validating that a value is a tree-sitter `Tree` instance.
5
+ */
6
+ export declare const TreeSchema: Schema.instanceOf<Tree, Tree>;
7
+ /**
8
+ * TreeHandle wraps a parsed tree-sitter tree with its metadata.
9
+ *
10
+ * Fields:
11
+ * - `tree`: The parsed tree-sitter Tree (rootNode, walk, edit, etc.)
12
+ * - `lang`: The language identifier used for parsing
13
+ * - `source`: The original source code that was parsed
14
+ *
15
+ * This is the output type of `CodeParser.parse()`.
16
+ */
17
+ export declare const TreeHandle: Schema.Struct<{
18
+ readonly tree: Schema.instanceOf<Tree, Tree>;
19
+ readonly lang: Schema.Literals<readonly ["javascript", "typescript", "tsx", "jsx", "python", "rust", "go"]>;
20
+ readonly source: Schema.String;
21
+ }>;
22
+ export interface TreeHandle extends Schema.Schema.Type<typeof TreeHandle> {
23
+ }
@@ -0,0 +1,15 @@
1
+ import { Layer } from "effect";
2
+ import { ParserInitError } from "@dimple/shared/errors";
3
+ /**
4
+ * Tree-sitter engine initialization — the ORIGINAL design: `Parser.init()`
5
+ * with no override, so web-tree-sitter's glue resolves `tree-sitter.wasm`
6
+ * relative to ITS OWN module (import.meta.url). That keeps the engine wasm
7
+ * riding inside the web-tree-sitter npm package — nothing wasm is shipped
8
+ * or downloaded by dimple itself (only the LANGUAGE grammars go through
9
+ * the runtime download + cache in @dimple/wasm).
10
+ *
11
+ * Bundling note: the SDK build EXTERNALIZES web-tree-sitter (it is a
12
+ * runtime dependency of the published package), so the module — and its
13
+ * wasm — stay intact at the consumer's node_modules.
14
+ */
15
+ export declare const layer: Layer.Layer<never, ParserInitError, never>;
@@ -0,0 +1,48 @@
1
+ import { Context, Effect, Layer, Schema } from "effect";
2
+ import { EmbeddingModelRegistry } from "./internal/embedder/index.js";
3
+ import { Store as StoreService } from "./internal/store/index.js";
4
+ import type { AugmentedMemory } from "./internal/store/index.js";
5
+ declare const HybridError_base: Schema.Class<HybridError, Schema.TaggedStruct<"HybridRetrieval.HybridError", {
6
+ readonly message: Schema.String;
7
+ }>, import("effect/Cause").YieldableError>;
8
+ export declare class HybridError extends HybridError_base {
9
+ }
10
+ export interface QueryProfile {
11
+ /** Rescale fused scores toward fresh memories (see the formula in
12
+ * `hybrid`): 0 disables the boost entirely. */
13
+ readonly recencyBoost?: number;
14
+ /** Restrict the dense leg to memories annotated with any of these
15
+ * concept ids (passed through to `Store.searchVector`). */
16
+ readonly conceptFilter?: readonly string[];
17
+ readonly modeWeights?: {
18
+ readonly vector?: number;
19
+ readonly fts?: number;
20
+ };
21
+ }
22
+ export interface Interface {
23
+ readonly hybrid: (query: string, options?: {
24
+ readonly namespace?: string;
25
+ readonly limit?: number;
26
+ readonly k?: number;
27
+ readonly profile?: QueryProfile | "hybrid" | "semantic" | "keyword";
28
+ readonly topics?: {
29
+ readonly topicKeys?: ReadonlyArray<string>;
30
+ };
31
+ }) => Effect.Effect<readonly AugmentedMemory[], HybridError>;
32
+ }
33
+ declare const Service_base: Context.ServiceClass<Service, "@dimple/retriever/HybridRetrieval", Interface>;
34
+ export declare class Service extends Service_base {
35
+ }
36
+ /**
37
+ * Layer factory: `hybridRetrievalLayer()` (no args) is the default
38
+ * instance; pass `{ defaultK, defaultLimit }` to override the retrieval
39
+ * defaults (the config path threads `defaultK`/`defaultLimit`).
40
+ */
41
+ export declare const layer: (options?: {
42
+ readonly defaultK?: number;
43
+ readonly defaultLimit?: number;
44
+ }) => Layer.Layer<Service, HybridError, StoreService | EmbeddingModelRegistry>;
45
+ /** Default instance (no option overrides) — the classic const consumers
46
+ * (tests, compositions) keep working; the factory form stays available. */
47
+ export declare const hybridRetrievalLayer: Layer.Layer<Service, HybridError, StoreService | EmbeddingModelRegistry>;
48
+ export {};
@@ -0,0 +1,3 @@
1
+ export { Service as HybridRetrieval, layer as hybridRetrievalLayerFactory, hybridRetrievalLayer, HybridError, type QueryProfile, } from "./hybrid.ts";
2
+ export { fuse } from "./rrf.ts";
3
+ export type { RankResult } from "./rrf.ts";
@@ -0,0 +1,11 @@
1
+ export interface RankResult {
2
+ readonly memoryId: string;
3
+ readonly denseScore: number | null;
4
+ readonly fts5Score: number | null;
5
+ readonly rrfScore: number;
6
+ }
7
+ /**
8
+ * Reciprocal Rank Fusion
9
+ * RRF(d) = sum(1 / (k + rank_i(d))) for each retriever i
10
+ */
11
+ export declare function fuse(denseRanks: ReadonlyArray<readonly [string, number]> | null, fts5Ranks: ReadonlyArray<readonly [string, number]> | null, k: number, limit: number): RankResult[];
@@ -0,0 +1,2 @@
1
+ export { WasmCacheError, RegistryError, WasmDownloadError, GrammarProvisionError } from "./wasm";
2
+ export { ParseError, LanguageLoadError, ParserInitError } from "./parser";
@@ -0,0 +1,21 @@
1
+ import { Schema } from "effect";
2
+ declare const ParserInitError_base: Schema.Class<ParserInitError, Schema.TaggedStruct<"ParserInitError", {
3
+ readonly message: Schema.String;
4
+ readonly cause: Schema.optional<Schema.Defect>;
5
+ }>, import("effect/Cause").YieldableError>;
6
+ export declare class ParserInitError extends ParserInitError_base {
7
+ }
8
+ declare const LanguageLoadError_base: Schema.Class<LanguageLoadError, Schema.TaggedStruct<"LanguageLoadError", {
9
+ readonly lang: Schema.Literals<readonly ["javascript", "typescript", "tsx", "jsx", "python", "rust", "go"]>;
10
+ readonly message: Schema.String;
11
+ readonly cause: Schema.optional<Schema.Defect>;
12
+ }>, import("effect/Cause").YieldableError>;
13
+ export declare class LanguageLoadError extends LanguageLoadError_base {
14
+ }
15
+ declare const ParseError_base: Schema.Class<ParseError, Schema.TaggedStruct<"ParseError", {
16
+ readonly message: Schema.String;
17
+ readonly cause: Schema.optional<Schema.Defect>;
18
+ }>, import("effect/Cause").YieldableError>;
19
+ export declare class ParseError extends ParseError_base {
20
+ }
21
+ export {};
@@ -0,0 +1,28 @@
1
+ import { Schema } from "effect";
2
+ declare const WasmCacheError_base: Schema.Class<WasmCacheError, Schema.TaggedStruct<"WasmCacheError", {
3
+ readonly message: Schema.String;
4
+ readonly cause: Schema.optional<Schema.Defect>;
5
+ }>, import("effect/Cause").YieldableError>;
6
+ export declare class WasmCacheError extends WasmCacheError_base {
7
+ }
8
+ declare const RegistryError_base: Schema.Class<RegistryError, Schema.TaggedStruct<"RegistryError", {
9
+ readonly message: Schema.String;
10
+ readonly cause: Schema.optional<Schema.Defect>;
11
+ }>, import("effect/Cause").YieldableError>;
12
+ export declare class RegistryError extends RegistryError_base {
13
+ }
14
+ declare const WasmDownloadError_base: Schema.Class<WasmDownloadError, Schema.TaggedStruct<"WasmDownloadError", {
15
+ readonly message: Schema.String;
16
+ readonly url: Schema.String;
17
+ readonly cause: Schema.optional<Schema.Defect>;
18
+ }>, import("effect/Cause").YieldableError>;
19
+ export declare class WasmDownloadError extends WasmDownloadError_base {
20
+ }
21
+ declare const GrammarProvisionError_base: Schema.Class<GrammarProvisionError, Schema.TaggedStruct<"GrammarProvisionError", {
22
+ readonly language: Schema.String;
23
+ readonly message: Schema.String;
24
+ readonly cause: Schema.optional<Schema.Defect>;
25
+ }>, import("effect/Cause").YieldableError>;
26
+ export declare class GrammarProvisionError extends GrammarProvisionError_base {
27
+ }
28
+ export {};
@@ -0,0 +1 @@
1
+ export type { LanguageId } from "./language";
@@ -0,0 +1,3 @@
1
+ import { Schema } from "effect";
2
+ export declare const LanguageId: Schema.Literals<readonly ["javascript", "typescript", "tsx", "jsx", "python", "rust", "go"]>;
3
+ export type LanguageId = Schema.Schema.Type<typeof LanguageId>;
@@ -0,0 +1,21 @@
1
+ import { Effect } from "effect";
2
+ import { JobFailure, type Handler, type JobContext } from "./internal/workflow/index.js";
3
+ import { Service as DbBackend } from "./db-backend.ts";
4
+ import type { Interface as DbBackendInterface } from "./db-backend.ts";
5
+ /** The `audit.write` handler shape (see queue.ts). */
6
+ export type AuditWriteHandler = (payload: unknown, ctx: JobContext) => Effect.Effect<unknown, JobFailure, DbBackend>;
7
+ /**
8
+ * Factory for the `audit.write` job handler. Payload: `{ rows }` — one or
9
+ * more `retrieval_log` rows enqueued by the store's `enqueueAudit` seam
10
+ * (the query path's audit writes). The handler performs the actual insert
11
+ * through `DbBackend.writeAuditRows`, so it stays dialect-neutral. This is
12
+ * the durable, visible counterpart of the old fire-and-forget insert: the
13
+ * job either succeeds (row persisted) or fails loudly (queue retry /
14
+ * observability), never silently.
15
+ */
16
+ export declare function auditWriteHandler(deps: {
17
+ readonly backend: DbBackendInterface;
18
+ }): Handler;
19
+ export declare function auditWriteHandler(deps: {
20
+ readonly backend?: DbBackendInterface;
21
+ }): AuditWriteHandler;
@@ -0,0 +1,111 @@
1
+ import { Context, Effect } from "effect";
2
+ import type { StoreError } from "./error.ts";
3
+ import type { RetrievalAuditRow, SweepResult } from "./models.ts";
4
+ import type { EmbeddingModelConfig } from "./internal/config/index.js";
5
+ /** Opaque handle to a Drizzle database instance.
6
+ * Concrete type varies by backend dialect (LibSQLDatabase, PgDatabase, etc.).
7
+ * Standard CRUD uses Drizzle's polymorphic query builder — no dialect-specific cast needed
8
+ * for select/insert/update/delete. Vector and FTS operations are backend-specific. */
9
+ export type DrizzleDB = any;
10
+ /** Tables exposed by a backend for the Store to use in Drizzle query builder calls.
11
+ * Each backend provides its own dialect-specific table objects (sqliteTable / pgTable).
12
+ * The `any` type is intentional — Drizzle's query builder accepts tables polymorphically
13
+ * for standard CRUD (select/insert/update/delete). */
14
+ export interface StoreTables {
15
+ readonly memories: any;
16
+ readonly memoryEvents: any;
17
+ readonly concepts: any;
18
+ readonly memoryConcepts: any;
19
+ readonly conceptRelations: any;
20
+ readonly retrievalLog: any;
21
+ readonly topics: any;
22
+ readonly artifactEdges: any;
23
+ }
24
+ /** A topic centroid row from a per-model topic vector table (raw SQL boundary shape). */
25
+ export interface TopicVectorRow {
26
+ readonly topicKey: string;
27
+ readonly sumVector: number[];
28
+ }
29
+ /** A memory embedding row from a per-model memory vector table (raw SQL boundary shape). */
30
+ export interface MemoryVectorRow {
31
+ readonly memoryId: string;
32
+ readonly vector: number[];
33
+ }
34
+ /**
35
+ * Canonical row of a `graphNeighbors` traversal.
36
+ * The backend returns raw view rows (`Record<string, unknown>[]` — snake_case
37
+ * `graph_edges` columns plus `depth`); the store casts once at the boundary
38
+ * into this shape (the `graph/traversal.ts` helper, mirror of `ftsSearch`).
39
+ */
40
+ export interface GraphNeighborRow {
41
+ /** The edge that reached this row's `to` endpoint. */
42
+ readonly fromId: string;
43
+ readonly fromKind: string;
44
+ readonly toId: string;
45
+ readonly toKind: string;
46
+ readonly edgeKind: string;
47
+ readonly edgeStatus: string;
48
+ readonly weight: number;
49
+ readonly edgeSource: string;
50
+ readonly depth: number;
51
+ }
52
+ export interface GraphNeighborsOptions {
53
+ readonly maxDepth?: number;
54
+ readonly maxNeighbors?: number;
55
+ readonly maxTotal?: number;
56
+ readonly includePending?: boolean;
57
+ /** Optional scope for the topic legs of the view (topic edges are
58
+ * model-scoped by PK). `undefined` unions every model's topic edges —
59
+ * the intended default (topic edges are retrieval context regardless
60
+ * of the model that wrote them). */
61
+ readonly modelKey?: string;
62
+ }
63
+ export interface Interface {
64
+ readonly runMigrations: () => Effect.Effect<void, StoreError>;
65
+ /**
66
+ * True when the cause chain contains a UNIQUE-constraint violation. The
67
+ * store uses it to map duplicate inserts to typed domain errors; the
68
+ * dialect-specific detection (SQLite message vs PG error code 23505)
69
+ * stays backend-owned.
70
+ */
71
+ readonly isUniqueViolation: (cause: unknown) => boolean;
72
+ /**
73
+ * Memories with NO live incident edge (either endpoint; expired and
74
+ * rejected edges do not count as live) — the isolated-memory survey for
75
+ * the candidate review surface and coverage metrics. Rows are
76
+ * `{ id, createdAt }`, ordered by `created_at` then `id` (deterministic).
77
+ * `limit` bounds the rows (0 = unbounded); `modelKey` optionally scopes
78
+ * to the model's active population.
79
+ */
80
+ readonly listIsolatedMemories: (limit: number, modelKey?: string) => Effect.Effect<readonly Record<string, unknown>[], StoreError>;
81
+ readonly db: DrizzleDB;
82
+ 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>;
85
+ readonly sweep: (namespace: string) => Effect.Effect<SweepResult, StoreError>;
86
+ /** Persist retrieval-audit rows (`retrieval_log`). Owned by the backend
87
+ * so the `audit.write` job handler stays dialect-neutral. */
88
+ readonly writeAuditRows: (rows: readonly RetrievalAuditRow[]) => Effect.Effect<void, StoreError>;
89
+ /** Metadata-filtered memory lookup (the one
90
+ * `json_extract` (SQLite) / `->` (PG) portability wart, now backend-owned
91
+ * like `ftsSearch`). Raw SQL, returns `Record<string, unknown>[]` — the
92
+ * store casts once at the boundary. Supported filter keys mirror the old
93
+ * store-level SQL exactly: `topic` (LIKE on `$.topics`) and `sourceType`
94
+ * (equality on `$.sourceType`); unknown keys are ignored. `limit` is
95
+ * optional — omitted means no LIMIT. */
96
+ readonly queryByMetadata: (filter: Record<string, unknown>, limit?: number) => Effect.Effect<readonly Record<string, unknown>[], StoreError>;
97
+ readonly graphNeighbors: (kind: "memory" | "topic" | "concept", id: string, opts?: GraphNeighborsOptions) => Effect.Effect<readonly Record<string, unknown>[], StoreError>;
98
+ readonly ensureVectorTable: (model: EmbeddingModelConfig) => Effect.Effect<void, StoreError>;
99
+ readonly insertVector: (memoryId: string, vector: ReadonlyArray<number>, model: EmbeddingModelConfig) => Effect.Effect<void, StoreError>;
100
+ readonly deleteVector: (memoryId: string, dimensions: number) => Effect.Effect<void, StoreError>;
101
+ readonly ensureTopicVectorTable: (model: EmbeddingModelConfig) => Effect.Effect<void, StoreError>;
102
+ readonly upsertTopicVector: (topicKey: string, sumVector: ReadonlyArray<number>, model: EmbeddingModelConfig) => Effect.Effect<void, StoreError>;
103
+ readonly deleteTopicVectors: (model: EmbeddingModelConfig) => Effect.Effect<void, StoreError>;
104
+ readonly fetchTopicVectors: (model: EmbeddingModelConfig) => Effect.Effect<ReadonlyArray<TopicVectorRow>, StoreError>;
105
+ readonly fetchMemoryVectors: (memoryIds: ReadonlyArray<string>, model: EmbeddingModelConfig) => Effect.Effect<ReadonlyArray<MemoryVectorRow>, StoreError>;
106
+ readonly listMemoryIds: (model: EmbeddingModelConfig) => Effect.Effect<ReadonlyArray<string>, StoreError>;
107
+ }
108
+ declare const Service_base: Context.ServiceClass<Service, "@dimple/store/DbBackend", Interface>;
109
+ export declare class Service extends Service_base {
110
+ }
111
+ export {};
@@ -0,0 +1 @@
1
+ export { memories, memoryEvents, concepts, memoryConcepts, conceptRelations, retrievalLog, MemoryInsert, MemorySelect, MemoryUpdate, MemoryEventInsert, MemoryEventSelect, ConceptInsert, ConceptSelect, MemoryConceptInsert, MemoryConceptSelect, ConceptRelationInsert, ConceptRelationSelect, RetrievalLogInsert, RetrievalLogSelect, } from "./schema/libsql.ts";
@@ -0,0 +1,19 @@
1
+ import { Schema } from "effect";
2
+ declare const StoreError_base: Schema.Class<StoreError, Schema.TaggedStruct<"Store.StoreError", {
3
+ readonly message: Schema.String;
4
+ readonly cause: Schema.optional<Schema.Defect>;
5
+ }>, import("effect/Cause").YieldableError>;
6
+ export declare class StoreError extends StoreError_base {
7
+ }
8
+ declare const NotFound_base: Schema.Class<NotFound, Schema.TaggedStruct<"Store.NotFound", {
9
+ readonly id: Schema.String;
10
+ }>, import("effect/Cause").YieldableError>;
11
+ export declare class NotFound extends NotFound_base {
12
+ }
13
+ declare const DuplicateActiveKey_base: Schema.Class<DuplicateActiveKey, Schema.TaggedStruct<"Store.DuplicateActiveKey", {
14
+ readonly logicalKey: Schema.String;
15
+ readonly namespace: Schema.String;
16
+ }>, import("effect/Cause").YieldableError>;
17
+ export declare class DuplicateActiveKey extends DuplicateActiveKey_base {
18
+ }
19
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * FNV-1a 32-bit hash of a string — deterministic, no crypto needed.
3
+ *
4
+ * The repo's single canonical implementation, used by:
5
+ * - `topics/jobs.ts` — content-addressable split child keys (`t_<hash>`).
6
+ * - `store.ts` — the retrieval audit hash (`retrieval_log.query_hash`,
7
+ * deterministic + joinable, replacing the former
8
+ * random UUID prefix.
9
+ *
10
+ * Returns the raw unsigned 32-bit hash as a number; callers format it
11
+ * (`.toString(16)` for hex). A string's hash is stable across runs, DBs and
12
+ * processes — same query text ⇒ same hash.
13
+ */
14
+ export declare const fnv1a32: (text: string) => number;