import { Either, ManagedRuntime, Option } from "effect"; import { CircularPluginDependency, CircularSlotDependency, MissingRequirement, UndeclaredCrossPluginDependency, UnresolvableSlotRef, } from "../errors.js"; import type { ForgedPlugin, PluginInput } from "../forge/define-plugin.js"; import type { SlotContext } from "../forge/define-slot.js"; import type { LocaleAdapter } from "../ports/locale.js"; import type { PersistenceDriver } from "../ports/persistence.js"; import type { TextMeasurer } from "../ports/text.js"; export interface NormalizedSlot { id: string; slotName: string; pluginId: string; contextKey: symbol; dependsOn: string[]; expose: boolean; persist?: boolean | string[]; configSchema?: unknown; create: (context: SlotContext) => unknown; } /** * Every failure mode `compileEnvironment` can produce, pre-runtime. These are * plain synchronous functions running before `ManagedRuntime.make`, so they * are not in an Effect context — they return `Either` rather than `Effect.fail`. */ export type CompileError = | MissingRequirement | CircularPluginDependency | CircularSlotDependency | UnresolvableSlotRef | UndeclaredCrossPluginDependency; export declare function resolveSlotRef( ref: string, declaringPluginId: string, all: Map, ): Option.Option; export declare function normalizeSlots( sorted: ForgedPlugin[], ): Either.Either; type KernelRuntime = ManagedRuntime.ManagedRuntime; export declare function compileEnvironment( pluginsInput: PluginInput[], options: { persistence: PersistenceDriver; localeAdapter?: LocaleAdapter; textMeasurer?: TextMeasurer; pluginConfig?: Record>; }, ): Either.Either< { runtime: KernelRuntime; resolvedPlugins: ForgedPlugin[]; sortedSlots: NormalizedSlot[]; }, CompileError >;