/**
 * Per-runtime emitter dispatcher — V2 Phase 3, Round 1.
 *
 * Proposal: 2026-05-08-COMPONENT-DEPENDENCIES-V2.md, "Realize bridge" section.
 *
 * The dispatcher is a small registry + lookup framework. The real work lives in
 * each topology-specific emitter implementation (library.ts, and future
 * service.ts / managed.ts / executable.ts / messaging.ts files).
 *
 * Round 1 ships: dispatcher framework + library topology emitter (this file +
 * library.ts). The two cross-branch types — `ResolvedComponent` (Agent A) and
 * `FactoryV2Metadata` / `InstanceFactory` (Agent B) — are imported from their
 * canonical locations: Round 1d (this commit) reconciled the local stubs with
 * the merged real types.
 *
 * Round 2 will add: service, managed, executable, messaging emitters + CLI wiring.
 */
import type { ComponentSpec, SpecVerseAST, InstanceFactory, FactoryTopology } from '@specverse/types';
import type { ResolvedComponent } from '../resolver/index.js';
export type { ResolvedComponent } from '../resolver/index.js';
export type { FactoryTopology, InstanceFactory } from '@specverse/types';
/** Alias kept for back-compat with the Round-1 stub naming. */
export type FactoryMetadata = InstanceFactory;
/**
 * A single entry in a component's `import:` block.
 * Mirrors the V2 Phase 1 schema additions (commit bb4b99b):
 *   - from: provider name (resolved via 4-step lookup)
 *   - version?: semver range (optional, defaults to ^latest)
 *   - select: array of bare or dotted operation names
 */
export interface ImportEntry {
    from: string;
    version?: string;
    select: string[];
}
/**
 * Context passed to every runtime emitter.
 * Carries the consumer-side view (component + import entry) alongside
 * the resolved provider (Agent A) and the factory metadata (Agent B).
 */
export interface RuntimeEmitterContext {
    /** The component that contains the `import:` block. */
    consumerComponent: ComponentSpec;
    /** The specific {from, version?, select} entry being emitted. */
    importEntry: ImportEntry;
    /**
     * Resolver result for this import entry.
     * Round 1 stub: callers construct this manually; Agent A's resolver will
     * produce it automatically when integrated in Round 2.
     */
    resolved: ResolvedComponent;
    /**
     * Factory metadata from the manifest's capabilityMappings.
     * Round 1 stub: callers construct this manually; Agent B's schema +
     * the registry-aware manifest-emitter will produce it when integrated.
     */
    factory: FactoryMetadata;
    /**
     * Absolute path to the consumer component's realize output directory.
     * Generated clients land at `<outputDir>/clients/<provider-name>.ts`.
     */
    outputDir: string;
    /**
     * The full parsed spec, for cross-component type lookups.
     * Optional in Round 1 — the library emitter doesn't need cross-spec
     * lookups yet; future emitters may need it for server-bind code.
     */
    spec?: SpecVerseAST;
}
/**
 * Structured deployment-instance suggestion an emitter produces alongside
 * its files/imports. The realize pipeline collects every emitter's
 * suggestions into `<outputDir>/v2-deployment-suggestions.yaml` (V2 P3
 * Round 3 follow-up), which the user merges into their deployment block
 * manually. Auto-merge isn't safe — deployment shape is user-controlled
 * (env-specific values, secrets, scaling parameters).
 *
 * Library-topology emitters do NOT produce suggestions (libraries are
 * in-process imports, not deployment instances).
 */
export interface DeploymentInstanceSuggestion {
    /** Provider name (importEntry.from) — anchors the suggestion to its import. */
    provider: string;
    /** Component that declared the import — for cross-checking which
     *  deployment-instance scope the suggestion belongs to. */
    consumerComponent?: string;
    /**
     * Which deployment-instance category this provider lands in. Mirrors
     * the schema's InstancesSection keys (services, communications,
     * infrastructure, …). Out-of-band categories should not be used.
     */
    category: 'services' | 'communications' | 'infrastructure' | 'storage' | 'security' | 'monitoring';
    /** Instance key under the category (lower-camelCase client name). */
    key: string;
    /** Pre-built config block — placeholder values use `<...>` markers. */
    config: Record<string, unknown>;
    /** Factory name driving the choice (manifest.capabilityMappings). */
    factory: string;
    /** Topology that emitted this suggestion. */
    topology: FactoryTopology;
    /** Optional review-time hints (TODOs, OAuth flows, etc.). */
    reviewNotes?: string[];
}
/**
 * What a runtime emitter produces.
 */
export interface RuntimeEmitterResult {
    /**
     * Files to write into the consumer's output directory.
     * Paths are relative to `outputDir`.
     */
    files: Array<{
        path: string;
        content: string;
    }>;
    /**
     * Import statements the consumer's main module (SalesReportController.ts)
     * should add to wire up the generated client.
     */
    imports: Array<{
        from: string;
        specifier: string;
    }>;
    /**
     * Optional realize-time hints or warnings.
     */
    notes?: string[];
    /**
     * V2 P3 R3 follow-up: structured deployment-instance suggestion. The
     * free-text equivalent is in `notes` for human review; this field is
     * the machine-readable version that the realize pipeline aggregates
     * into v2-deployment-suggestions.yaml. Library-topology emissions
     * omit this field.
     */
    deploymentSuggestion?: DeploymentInstanceSuggestion;
}
/**
 * Contract every topology-specific emitter must satisfy.
 */
export interface RuntimeEmitter {
    /** The topology this emitter handles. Drives dispatch lookup. */
    topology: FactoryTopology;
    /** Emit files for one import entry. */
    emit(ctx: RuntimeEmitterContext): Promise<RuntimeEmitterResult>;
}
/**
 * Look up the correct emitter for the factory's topology.
 *
 * The emitters map is injected by the caller, making the dispatcher
 * extensible without engine changes: register new emitters by adding
 * entries to the map.
 *
 * @param factory - The resolved factory metadata (drives the topology lookup).
 * @param emitters - Registry of topology → RuntimeEmitter. Typically built
 *   once per realize run by `buildDefaultEmitters()`.
 * @returns The matching RuntimeEmitter.
 * @throws Error if no emitter is registered for the factory's topology.
 */
export declare function dispatchRuntimeEmitter(factory: FactoryMetadata, emitters: Map<string, RuntimeEmitter>): RuntimeEmitter;
/**
 * Build the default emitter registry for a realize run.
 *
 * Round 1 shipped library; Round 2 added service / managed / executable /
 * messaging. All 5 are registered here so the realize-side dispatcher can
 * pick whichever the factory's v2metadata.topology selects.
 *
 * The 'external' topology is intentionally NOT registered — V2's design
 * defines it as a passthrough requiring manual wiring (no auto-emission).
 * Specs that bind a factory with topology: 'external' will trip a clear
 * "No runtime emitter registered" error, which is the desired behavior.
 *
 * Imports are deferred to avoid circular deps — each emitter file imports
 * only from dispatcher.ts, not vice versa.
 */
export declare function buildDefaultEmitters(): Promise<Map<string, RuntimeEmitter>>;
//# sourceMappingURL=dispatcher.d.ts.map