/** * applyPreset — the main orchestrator for preset application. * * Given a preset ref and user inputs, this function: * 1. Parses the preset manifest * 2. Validates all placeholder inputs * 3. Resolves each item ref (asset, library-instance, nested-preset, cross-item) * 4. Interpolates config and secrets * 5. Creates Instances in the Library * 6. Assigns the workspace to created Instances * 7. Stores secrets via SecretsRouter * 8. Returns the apply result * * Nesting: nested preset refs are recursively applied (max depth 3). * Outer-wins: outer preset's inputs override nested preset's defaults. * * NOTE: The `composes` field on preset items is validated at parse-time * (cross-item refs resolve to declared IDs) but NOT interpreted at apply-time. * Composition (e.g. attaching skills/connectors to an agent item) is a Phase 2 * concern — Task 1.7 will wire the composes declarations into the Instance's * config as part of the agent binding step. * * @docLink packages/library/concepts#preset-application */ import type { SecretsRouter } from "@skaile/workspaces/secrets"; import type { PresetManifest } from "@skaile/workspaces/types/manifests"; import type { Assignment, IAssetIndex, Instance, PinPolicy } from "../library.js"; /** * Options for {@link applyPreset}. * * @docLink packages/library/concepts#preset-application */ export interface ApplyOpts { /** The library for instance creation and assignment. */ library: IAssetIndex; /** Workspace ID for assignment creation. */ workspaceId: string; /** Pin policy for created instances (default: "minor-track"). */ pinPolicy?: PinPolicy; /** SecretsRouter for secret storage. */ secretsRouter?: SecretsRouter; /** Set of known preset refs (for nested detection). */ knownPresetRefs?: Set; /** Loader function for nested presets (given a ref, return manifest data). */ loadPreset?: (ref: string) => Promise | null>; /** Current nesting depth (internal, used for recursion). */ _depth?: number; /** Creator identity for audit trail. */ createdBy?: string; } /** * Aggregated result of a {@link applyPreset} call. * * @docLink packages/library/concepts#preset-application */ export interface ApplyResult { /** All instances created during this apply (including nested). */ instances: Instance[]; /** All assignments created during this apply. */ assignments: Assignment[]; /** Errors encountered (non-fatal — partial apply). */ errors: string[]; } /** * Per-item result used internally during preset application. * * @docLink packages/library/concepts#preset-application */ export interface ApplyItemResult { /** Instances created for this item. */ instances: Instance[]; /** Assignments created for this item. */ assignments: Assignment[]; /** Non-fatal errors for this item. */ errors: string[]; } /** * Apply a parsed preset manifest. * * This is the primary entry point for CLI and platform consumers. * It handles: validation → resolve → interpolate → create instances → * assign → store secrets. * * @param presetRef - Canonical ref of the preset being applied. * @param manifest - The validated preset manifest (already parsed). * @param inputs - User-provided placeholder values (key to value). * @param opts - Apply options (library, workspace, secrets, nesting context). * @returns Aggregated apply result. * @docLink packages/library/concepts#preset-application */ export declare function applyPreset(presetRef: string, manifest: PresetManifest, inputs: Record, opts: ApplyOpts): Promise; /** * Apply a preset from raw YAML data. * * Convenience wrapper that parses first, then applies. * * @param presetRef - Canonical ref of the preset. * @param data - Raw parsed YAML object (pre-read from disk). * @param inputs - User-provided placeholder values. * @param opts - Apply options. * @returns Aggregated apply result, with parse errors in `errors` if parse fails. * @docLink packages/library/concepts#preset-application */ export declare function applyPresetFromData(presetRef: string, data: unknown, inputs: Record, opts: ApplyOpts): Promise; //# sourceMappingURL=apply.d.ts.map