@ponraaj/dimple-sdk 0.0.0-alpha.10 → 0.0.0-alpha.12

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 (68) hide show
  1. package/README.md +5 -4
  2. package/dist/dimple.d.ts +13 -0
  3. package/dist/errors.js +8330 -0
  4. package/dist/index.js +1936 -1688
  5. package/dist/internal/config/index.d.ts +1 -1
  6. package/dist/internal/config/service.d.ts +4 -0
  7. package/dist/internal/core/core.d.ts +8 -8
  8. package/dist/internal/core/hosted-embedding.d.ts +1 -1
  9. package/dist/internal/core/index.d.ts +6 -0
  10. package/dist/internal/core/layer.d.ts +17 -8
  11. package/dist/internal/embedder/auto-install.d.ts +23 -5
  12. package/dist/internal/embedder/index.d.ts +1 -1
  13. package/dist/internal/embedder/registry.d.ts +7 -0
  14. package/dist/internal/embedder/transformers.d.ts +6 -2
  15. package/dist/internal/extractor/code-extractor.d.ts +11 -1
  16. package/dist/internal/extractor/index.d.ts +1 -1
  17. package/dist/internal/extractor/languages/index.d.ts +1 -1
  18. package/dist/internal/extractor/languages/javascript.d.ts +1 -1
  19. package/dist/internal/extractor/languages/typescript.d.ts +1 -1
  20. package/dist/internal/installer/index.d.ts +11 -0
  21. package/dist/internal/llm/dream-classifier.d.ts +1 -1
  22. package/dist/internal/llm/index.d.ts +1 -1
  23. package/dist/internal/llm/service.d.ts +7 -1
  24. package/dist/internal/logger/index.d.ts +1 -1
  25. package/dist/internal/logger/service.d.ts +14 -3
  26. package/dist/internal/parser/code-parser.d.ts +12 -2
  27. package/dist/internal/parser/index.d.ts +3 -3
  28. package/dist/internal/parser/language-store.d.ts +3 -3
  29. package/dist/internal/parser/tree-sitter-engine.d.ts +1 -1
  30. package/dist/internal/retriever/hybrid.d.ts +21 -7
  31. package/dist/internal/retriever/index.d.ts +1 -1
  32. package/dist/internal/shared/effect/node.d.ts +155 -0
  33. package/dist/internal/shared/file-database.d.ts +17 -0
  34. package/dist/internal/shared/file-lock.d.ts +20 -0
  35. package/dist/internal/shared/schema/defaults.d.ts +13 -0
  36. package/dist/internal/store/audit.d.ts +1 -1
  37. package/dist/internal/store/db-backend.d.ts +2 -2
  38. package/dist/internal/store/graph/concepts.d.ts +2 -2
  39. package/dist/internal/store/graph/dream.d.ts +2 -2
  40. package/dist/internal/store/graph/errors.d.ts +1 -1
  41. package/dist/internal/store/graph/repair.d.ts +2 -2
  42. package/dist/internal/store/index.d.ts +3 -3
  43. package/dist/internal/store/libsql-backend.d.ts +1 -1
  44. package/dist/internal/store/schema/topics.d.ts +0 -12
  45. package/dist/internal/store/service.d.ts +6 -5
  46. package/dist/internal/store/store.d.ts +24 -5
  47. package/dist/internal/store/topics/errors.d.ts +1 -1
  48. package/dist/internal/store/topics/index.d.ts +2 -2
  49. package/dist/internal/store/topics/jobs.d.ts +2 -2
  50. package/dist/internal/store/topics/lifecycle.d.ts +27 -2
  51. package/dist/internal/store/topics/maintenance.d.ts +2 -2
  52. package/dist/internal/store/topics/query.d.ts +1 -1
  53. package/dist/internal/store/topics/routing.d.ts +1 -1
  54. package/dist/internal/store/topics/topic-vectors.d.ts +1 -1
  55. package/dist/internal/workflow/engine.d.ts +27 -3
  56. package/dist/internal/workflow/executor.d.ts +19 -5
  57. package/dist/internal/workflow/index.d.ts +5 -5
  58. package/dist/internal/workflow/persistence.d.ts +2 -2
  59. package/dist/internal/workflow/queue.d.ts +23 -2
  60. package/dist/internal/workflow/registry.d.ts +10 -0
  61. package/dist/internal/workflow/runtime.d.ts +22 -4
  62. package/package.json +23 -7
  63. package/dist/internal/wasm/grammar-store.d.ts +0 -14
  64. package/dist/internal/wasm/index.d.ts +0 -5
  65. package/dist/internal/wasm/wasm-cache.d.ts +0 -17
  66. package/dist/internal/wasm/wasm-downloader.d.ts +0 -10
  67. package/dist/internal/wasm/wasm-registry.d.ts +0 -16
  68. package/dist/internal/workflow/queue-store.d.ts +0 -5
@@ -1,4 +1,4 @@
1
1
  export { DimpleConfig, EmbeddingModelConfig, EmbeddingConfig, IndexConfig, JobsConfig, TopicsConfig, } from "./schema.ts";
2
2
  export type { DimpleConfig as DimpleConfigType, EmbeddingModelConfig as EmbeddingModelConfigType, EmbeddingConfig as EmbeddingConfigType, IndexConfig as IndexConfigType, JobsConfig as JobsConfigType, TopicsConfig as TopicsConfigType, } from "./schema.ts";
3
- export { Service, layer } from "./service.ts";
3
+ export { Service, layer, configured as configConfigured, node as configNode } from "./service.ts";
4
4
  export { loadConfig, loadConfigFromFile } from "./loader.ts";
@@ -7,4 +7,8 @@ declare const Service_base: Context.ServiceClass<Service, "@dimple/Config", Inte
7
7
  export declare class Service extends Service_base {
8
8
  }
9
9
  export declare const layer: (overrides?: Partial<DimpleConfigType>) => Layer.Layer<Service, Error>;
10
+ /** The Config layer-graph node. `deps` stays empty — the composition root
11
+ * wires dependencies, per the layer-graph convention. */
12
+ export declare const configured: (overrides?: Partial<DimpleConfigType>) => import("../core/index.js").LayerProvider<Service, Error, undefined>;
13
+ export declare const node: import("../core/index.js").LayerProvider<Service, Error, undefined>;
10
14
  export {};
@@ -1,13 +1,13 @@
1
1
  import { Context, Effect, Schema } from "effect";
2
- import type { EmbeddingModelConfig } from "./internal/config/index.js";
3
- import type { LLM } from "./internal/llm/index.js";
4
- import { EmbeddingError, type EmbeddingModel } from "./internal/embedder/index.js";
5
- import type { LogConfig, Logging } from "./internal/logger/index.js";
6
- import { Store, graph, type TopicConfig } from "./internal/store/index.js";
7
- import { HybridRetrieval } from "./internal/retriever/index.js";
8
- import { JobRuntime, JobRegistry, type Handler, type JobDefinition } from "./internal/workflow/index.js";
2
+ import type { EmbeddingModelConfig } from "../config/index.js";
3
+ import type { LLM } from "../llm/index.js";
4
+ import { EmbeddingError, type EmbeddingModel } from "../embedder/index.js";
5
+ import type { LogConfig, Logging } from "../logger/index.js";
6
+ import { Store, graph, type TopicConfig } from "../store/index.js";
7
+ import { HybridRetrieval } from "../retriever/index.js";
8
+ import { JobRuntime, JobRegistry, type Handler, type JobDefinition } from "../workflow/index.js";
9
9
  /** Topic-tree config (the store's schema, defaults decoded by the layer). */
10
- export type { TopicConfig } from "./internal/store/index.js";
10
+ export type { TopicConfig } from "../store/index.js";
11
11
  /** Graph config (the store's schema — `graph.GraphConfig`). */
12
12
  export type GraphConfig = graph.GraphConfig;
13
13
  /**
@@ -1,4 +1,4 @@
1
- import { type EmbeddingModel } from "./internal/embedder/index.js";
1
+ import { type EmbeddingModel } from "../embedder/index.js";
2
2
  export interface HostedEmbeddingOptions {
3
3
  readonly modelId: string;
4
4
  readonly model: string;
@@ -1,3 +1,9 @@
1
1
  export { Service as Core, make as makeCore, type Interface as CoreInterface, type CoreOptions, } from "./core.ts";
2
2
  export { layer as coreLayer, layerConfig as coreLayerConfig } from "./layer.ts";
3
+ export type { CoreGraphServices } from "./layer.ts";
4
+ /** The layer-graph surface, as the reference exposes it: one value namespace
5
+ * whose members are the `make`/`group`/`compile` constructors and the
6
+ * `Graph`/`Node`/`Provider`/`Replacement` types. */
7
+ export * as LayerNode from "../shared/effect/node.js";
8
+ export { compile as compileLayers, group as groupLayers, make as makeLayer, tags as layerTags, unbound as unboundLayer, type Graph as LayerGraph, type Provider as LayerProvider, type Replacement as LayerReplacement, } from "../shared/effect/node.js";
3
9
  export { CoreConfigError } from "./core.ts";
@@ -1,14 +1,23 @@
1
1
  import { Layer } from "effect";
2
- import { Store, DbBackend } from "./internal/store/index.js";
3
- import { EmbeddingError, EmbeddingModelRegistry } from "./internal/embedder/index.js";
4
- import { HybridRetrieval } from "./internal/retriever/index.js";
5
- import { JobRuntime, JobRegistry } from "./internal/workflow/index.js";
6
- import { Logging } from "./internal/logger/index.js";
7
- import { Service as ConfigService } from "./internal/config/index.js";
2
+ import { Store, DbBackend } from "../store/index.js";
3
+ import { EmbeddingError, EmbeddingModelRegistry } from "../embedder/index.js";
4
+ import { HybridRetrieval } from "../retriever/index.js";
5
+ import { JobRuntime, JobRegistry } from "../workflow/index.js";
6
+ import { Logging } from "../logger/index.js";
7
+ import { Service as ConfigService } from "../config/index.js";
8
8
  import type { CoreOptions } from "./core.ts";
9
9
  import { CoreConfigError } from "./core.ts";
10
10
  import { Service } from "./core.ts";
11
- export declare const layer: (options: CoreOptions) => Layer.Layer<import("effect/unstable/persistence/PersistedQueue").PersistedQueueFactory | import("effect/unstable/persistence/Persistence").Persistence | Logging | DbBackend | JobRuntime | JobRegistry | Store | EmbeddingModelRegistry | HybridRetrieval | Service | import("effect/unstable/workflow/WorkflowEngine").WorkflowEngine, CoreConfigError | EmbeddingError | import("./internal/retriever/index.js").HybridError | import("./internal/workflow/index.js").RegistryError | import("effect/unstable/sql/SqlError").SqlError | import("./internal/store/index.js").StoreError, import("effect/Scope").Scope>;
11
+ /**
12
+ * Everything the composed graph exposes. Every node is a root, so the
13
+ * compiled group merges each node's outputs: the Core service plus the
14
+ * store (with `DbBackend` and the single `Logging` install), the embedder
15
+ * registry, hybrid retrieval, and the job stack (runtime, registry, durable
16
+ * engine, persistence, queue factory). The workers node contributes no
17
+ * service (it runs fibers).
18
+ */
19
+ export type CoreGraphServices = Layer.Success<ReturnType<typeof layer>>;
20
+ export declare const layer: (options: CoreOptions) => Layer.Layer<import("effect/persistence/PersistedQueue").PersistedQueueFactory | import("effect/persistence/Persistence").Persistence | Logging | DbBackend | JobRuntime | JobRegistry | Store | EmbeddingModelRegistry | HybridRetrieval | Service | import("effect/workflow/WorkflowEngine").WorkflowEngine, CoreConfigError | EmbeddingError | import("../retriever/index.js").HybridError | import("../workflow/index.js").RegistryError | import("effect/sql/SqlError").SqlError | import("../store/index.js").StoreError, never>;
12
21
  /**
13
22
  * Config-driven variant — the `dimple.jsonc` path (the SDK's
14
23
  * `makeDimple({ config })`): reads the resolved `DimpleConfig` from
@@ -18,4 +27,4 @@ export declare const layer: (options: CoreOptions) => Layer.Layer<import("effect
18
27
  */
19
28
  export declare const layerConfig: (options?: {
20
29
  readonly migrationFolder?: string;
21
- }) => Layer.Layer<import("effect/unstable/persistence/PersistedQueue").PersistedQueueFactory | import("effect/unstable/persistence/Persistence").Persistence | Logging | DbBackend | JobRuntime | JobRegistry | Store | EmbeddingModelRegistry | HybridRetrieval | Service | import("effect/unstable/workflow/WorkflowEngine").WorkflowEngine, CoreConfigError | EmbeddingError | import("./internal/retriever/index.js").HybridError | import("./internal/workflow/index.js").RegistryError | import("effect/unstable/sql/SqlError").SqlError | import("./internal/store/index.js").StoreError, import("effect/Scope").Scope | ConfigService>;
30
+ }) => Layer.Layer<import("effect/persistence/PersistedQueue").PersistedQueueFactory | import("effect/persistence/Persistence").Persistence | Logging | DbBackend | JobRuntime | JobRegistry | Store | EmbeddingModelRegistry | HybridRetrieval | Service | import("effect/workflow/WorkflowEngine").WorkflowEngine, CoreConfigError | EmbeddingError | import("../retriever/index.js").HybridError | import("../workflow/index.js").RegistryError | import("effect/sql/SqlError").SqlError | import("../store/index.js").StoreError, ConfigService>;
@@ -1,10 +1,28 @@
1
- import { type PackageManager } from "./internal/installer/index.js";
2
- export type { InstallTarget, PackageManager } from "./internal/installer/index.js";
3
- export { detectPackageManager } from "./internal/installer/index.js";
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` install scripts, which npm 12 blocks by
6
+ * default and npm 11 runs with an advisory warning — npm RFC #0054). When
7
+ * the config declares a `transformers` provider model,
8
+ * the intent is explicit — so the FIRST local-embed use installs the
9
+ * package automatically with the project's own package manager, instead
10
+ * of failing with a manual step.
11
+ *
12
+ * Thin wrapper over the shared `@dimple/installer` machinery (manager
13
+ * detection, script-skipping argv, timeout-kill, in-flight dedup, win32
14
+ * shims, pnpm `-w`); failures map onto the typed `EmbeddingError` with
15
+ * the manual command.
16
+ */
17
+ import { Effect } from "effect";
18
+ import { EmbeddingError } from "./provider.ts";
19
+ import { type PackageManager } from "../installer/index.js";
20
+ export type { InstallTarget, PackageManager } from "../installer/index.js";
21
+ export { detectPackageManager } from "../installer/index.js";
4
22
  /** The install argv for a manager with the transformers package (kept for
5
23
  * callers/tests that assert the shape). */
6
24
  export declare const installCommand: (pm: PackageManager) => readonly [string, ...string[]];
7
25
  /** Install transformers at the project root detected from `cwd`. The
8
26
  * shared installer kills the child on timeout and dedups concurrent
9
- * first-use installs; failures reject with the manual command. */
10
- export declare const installTransformers: (cwd: string) => Promise<void>;
27
+ * first-use installs; failures fail typed with the manual command. */
28
+ export declare const installTransformers: (cwd: string) => Effect.Effect<void, EmbeddingError>;
@@ -1,3 +1,3 @@
1
1
  export { Service as EmbeddingModelRegistry, type Interface as EmbeddingModelRegistryInterface, type EmbeddingModel, EmbeddingError, } from "./provider.ts";
2
2
  export { layer as transformersEmbeddingLayer, layerConfig as transformersEmbeddingLayerConfig, makeTransformersModel, buildSessionOptions, } from "./transformers.ts";
3
- export { layer as registryLayer, type ModelSpec } from "./registry.ts";
3
+ export { layer as registryLayer, configured as registryConfigured, type ModelSpec, } from "./registry.ts";
@@ -8,3 +8,10 @@ export interface ModelSpec {
8
8
  readonly apiKey?: string;
9
9
  }
10
10
  export declare const layer: (...models: ModelSpec[]) => Layer.Layer<Service, EmbeddingError>;
11
+ /**
12
+ * Node declaration over `layer`, for the composition root: the graph wires
13
+ * the dependencies, so `deps` stays empty here. The variadic model list is
14
+ * the declaration's whole configuration — no `node` default, because an
15
+ * empty registry has no models and `defaultModelId` fails typed.
16
+ */
17
+ export declare const configured: (...models: ModelSpec[]) => import("../core/index.js").LayerProvider<Service, EmbeddingError, undefined>;
@@ -7,7 +7,11 @@ type DeviceType = "auto" | "gpu" | "cpu" | "wasm" | "webgpu" | "cuda" | "dml" |
7
7
  /** The ORT session-options shape transformers.js forwards to
8
8
  * onnxruntime-node (executionProviders with a bounded CUDA arena). */
9
9
  interface OrtSessionOptions {
10
- readonly executionProviders: readonly [
10
+ /** ORT JS session options are camelCase; transformers.js reads them from
11
+ * a snake_case `session_options` bag. The CPU arena pre-allocates and
12
+ * holds memory across runs (onnxruntime#11627). */
13
+ readonly enableCpuMemArena?: boolean;
14
+ readonly executionProviders?: readonly [
11
15
  {
12
16
  readonly name: string;
13
17
  readonly device_id: number;
@@ -34,7 +38,7 @@ interface TransformersOptions {
34
38
  * limited VRAM (≤8GB): ORT's default arena is unbounded (grows by
35
39
  * powers of two), so batch inference OOMs mid-run and leaves the
36
40
  * process unable to allocate even a cublas handle afterwards. Forwarded
37
- * to the pipeline's sessionOptions; absent = ORT defaults (CPU and
41
+ * to the pipeline's `session_options`; absent = ORT defaults (CPU and
38
42
  * ample-VRAM GPUs unaffected). */
39
43
  readonly sessionOptions?: {
40
44
  readonly gpuMemLimit?: number | undefined;
@@ -1,5 +1,5 @@
1
1
  import { Context, Effect, Layer } from "effect";
2
- import type { TreeHandle } from "./internal/parser/index.js";
2
+ import type { TreeHandle } from "../parser/index.js";
3
3
  import { ExtractedFile, ExtractionError } from "./models/extraction";
4
4
  export interface ExtractRequest {
5
5
  readonly filePath: string;
@@ -12,4 +12,14 @@ declare const Service_base: Context.ServiceClass<Service, "@dimple/extractor/Cod
12
12
  export declare class Service extends Service_base {
13
13
  }
14
14
  export declare const layer: Layer.Layer<Service, never, never>;
15
+ /**
16
+ * Layer-graph declaration for `CodeExtractor`. The layer has no
17
+ * requirements of its own (a `TreeHandle` is passed per call, not
18
+ * injected), so `deps` stays empty and the composition root wires the
19
+ * parser that produces those handles.
20
+ */
21
+ export declare const configured: () => import("../core/index.js").LayerProvider<Service, never, undefined>;
22
+ /** The default declaration — the live implementation the composition root
23
+ * picks unless it replaces this node. */
24
+ export declare const node: import("../core/index.js").LayerProvider<Service, never, undefined>;
15
25
  export {};
@@ -1,4 +1,4 @@
1
- export { Service as CodeExtractor, layer as codeExtractorLayer } from "./code-extractor";
1
+ export { Service as CodeExtractor, layer as codeExtractorLayer, configured as codeExtractorConfigured, node as codeExtractorNode, } from "./code-extractor";
2
2
  export type { ExtractRequest } from "./code-extractor";
3
3
  export { ExtractedFile, ExtractedChunk, ImportInfo, ExtractionError } from "./models/extraction";
4
4
  export { Service as ContentHandler, layer as contentHandlerLayer, ContentError, } from "./content-handler";
@@ -1,4 +1,4 @@
1
- import type { TreeHandle } from "./internal/parser/index.js";
1
+ import type { TreeHandle } from "../../parser/index.js";
2
2
  import type { ExtractedChunk, ImportInfo } from "../models/extraction";
3
3
  import { ExtractionError } from "../models/extraction";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { TreeHandle } from "./internal/parser/index.js";
1
+ import type { TreeHandle } from "../../parser/index.js";
2
2
  import type { ExtractedChunk, ImportInfo } from "../models/extraction";
3
3
  /**
4
4
  * Extract chunks and imports from a JavaScript/JSX file.
@@ -1,4 +1,4 @@
1
- import type { TreeHandle } from "./internal/parser/index.js";
1
+ import type { TreeHandle } from "../../parser/index.js";
2
2
  import type { ExtractedChunk, ImportInfo } from "../models/extraction";
3
3
  /**
4
4
  * Extract chunks and imports from a TypeScript/TSX file.
@@ -16,11 +16,22 @@ export declare const resolveExecutable: (pm: PackageManager, platform?: NodeJS.P
16
16
  /** The base install argv for a manager. Scripts are skipped everywhere;
17
17
  * pnpm at a workspace root additionally gets `-w`. */
18
18
  export declare const installArgs: (pm: PackageManager, packages: readonly string[], root: string) => string[];
19
+ /** The slice of a spawned child the installer uses; tests inject a fake. */
20
+ export interface InstallChild {
21
+ on(event: "error", listener: (cause: Error) => void): void;
22
+ on(event: "exit", listener: (code: number | null, signal: string | null) => void): void;
23
+ kill(signal?: NodeJS.Signals): boolean;
24
+ }
19
25
  export interface InstallOptions {
20
26
  readonly cwd?: string;
21
27
  /** Hard deadline; the child is SIGKILLed when it trips (default 5 min). */
22
28
  readonly timeoutMs?: number;
23
29
  /** Injectable for tests (defaults to process.platform). */
24
30
  readonly platform?: NodeJS.Platform;
31
+ /** Injectable for tests; defaults to `node:child_process.spawn`. */
32
+ readonly spawnImpl?: (command: string, args: readonly string[], options: {
33
+ readonly cwd: string;
34
+ readonly stdio: "ignore";
35
+ }) => InstallChild;
25
36
  }
26
37
  export declare const installOptionalPeers: (packages: readonly string[], opts?: InstallOptions) => Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import type { LLM } from "./llm.ts";
2
- import type { DreamClassifier } from "./internal/store/index.js";
2
+ import type { DreamClassifier } from "../store/index.js";
3
3
  /**
4
4
  * Builds a `DreamClassifier` from a generic `LLM`. `modelId` (when given)
5
5
  * is mentioned in the system prompt so the model knows which embedding
@@ -1,4 +1,4 @@
1
1
  export { LLMError, makeLLM, type GenerateTextInput, type GenerateObjectInput, type LLM, } from "./llm.ts";
2
2
  export { openAICompatible, type OpenAICompatibleOptions } from "./provider.ts";
3
3
  export { makeDreamClassifier } from "./dream-classifier.ts";
4
- export { Service as LLMService, type Interface as LLMServiceInterface, type LLMOptions, layer as llmLayer, layerConfig as llmLayerConfig, layerFromConfig as llmLayerFromConfig, } from "./service.ts";
4
+ export { Service as LLMService, type Interface as LLMServiceInterface, type LLMOptions, layer as llmLayer, layerConfig as llmLayerConfig, layerFromConfig as llmLayerFromConfig, configured as llmConfigured, } from "./service.ts";
@@ -1,5 +1,5 @@
1
1
  import { Config, Context, Layer } from "effect";
2
- import { Service as ConfigService } from "./internal/config/index.js";
2
+ import { Service as ConfigService } from "../config/index.js";
3
3
  import { type LLM, type LLMDefaults } from "./llm.ts";
4
4
  /**
5
5
  * Connection options for the OpenAI-compatible LLM layer: the chat
@@ -26,4 +26,10 @@ export declare const layerConfig: (config: Config.Wrap<LLMOptions>) => Layer.Lay
26
26
  * section). Fails with a clear error when the section is absent.
27
27
  */
28
28
  export declare const layerFromConfig: () => Layer.Layer<Service, Error, ConfigService>;
29
+ /**
30
+ * Node declaration over `layer`, for the composition root: the graph wires
31
+ * the dependencies, so `deps` stays empty here. `LLMOptions` is all-required
32
+ * (endpoint, key, model), so there is no `node` default to declare.
33
+ */
34
+ export declare const configured: (options: LLMOptions) => import("../core/index.js").LayerProvider<Service, never, undefined>;
29
35
  export {};
@@ -1,4 +1,4 @@
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";
1
+ export { Service as Logging, layer as loggingLayer, layerConfig as loggingLayerConfig, configured as loggingConfigured, node as loggingNode, silentConfig as loggingSilentConfig, 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";
@@ -32,7 +32,7 @@ export interface Interface {
32
32
  declare const Service_base: Context.ServiceClass<Service, "@dimple/logger/Logging", Interface>;
33
33
  export declare class Service extends Service_base {
34
34
  }
35
- /** Effect variant of `make` — builds the file sink through lazy `node:fs`
35
+ /** Effect variant of the sync logger factory — builds the file sink through lazy `node:fs`
36
36
  * (see `fileSink`; the console sink is sync). */
37
37
  export declare const makeEffect: (config: LogConfig) => Effect.Effect<Interface>;
38
38
  /** Effect log messages: strings pass through, arrays are joined, anything
@@ -60,10 +60,21 @@ export interface StructuredOutput {
60
60
  export declare const effectLogger: (logging: Interface) => Logger.Logger<unknown, void>;
61
61
  /** Installs the Logging service AND replaces Effect's default logger with
62
62
  * the adapter feeding it. `mergeWithExisting: false` — one logger
63
- * everywhere (the job runtime emits through this too). */
64
- export declare const layer: (config: LogConfig) => Layer.Layer<Service, never, Scope>;
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>;
65
67
  /** Config-driven variant (the repo convention): `layerConfig(config)` or
66
68
  * `layerConfig(Config.succeed({...}))` — resolves the config inside the
67
69
  * layer and delegates to `layer` (no Effect.runSync in package sources). */
68
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>;
69
80
  export {};
@@ -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 "@dimple/shared/errors";
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("@dimple/shared/errors").ParserInitError, never>;
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 "@dimple/shared/types/language";
7
- export { ParserInitError, LanguageLoadError, ParseError } from "@dimple/shared/errors";
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 "@dimple/shared/types/language";
3
- import { LanguageLoadError } from "@dimple/shared/errors";
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("@dimple/shared/errors").ParserInitError, never>;
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 "@dimple/shared/errors";
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 { 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";
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>;