/** * Provider-environment compilation for the two configuration formats (issue #1136). * * The engine consumes a format-agnostic bundle of provider engine-options * (`provider` / `model` / `personaProviders` / `providerRouting` / `autoRouting` / * `providerOptions` / `internalAgents`). This module is the anti-corruption boundary that * compiles either configuration format into that single bundle, so executor / runner / * provider SDK never branch on the format: * * - `LegacyProviderPolicyCompiler` reuses the values the bootstrap already assembled from * `config.yaml` + workflow + CLI, unchanged (byte-identical legacy behavior). * - `RuntimeProviderPolicyCompiler` maps a validated `runtime.yaml` `provider` section into * the same bundle: profile `options` become provider-specific options, `pool` assignments and * the `auto_routing` section become an `AutoRoutingConfig`, and `internal_agents` targets * become the `internalAgents` bundle entry consumed by the selector/assistant seams. * * The configuration format is loaded as a discriminated union and a single factory * (`compileProviderEnvironment`) selects the matching compiler. */ import type { ProviderType } from '../../../shared/types/provider.js'; import type { AutoRoutingConfig, InternalAgentSeats, PersonaProviderEntry, ProviderLadderConfig, ProviderRoutingConfig, ProviderRoutingEntry, TagRoutingConflictPolicy, TaktProvidersConfig } from '../../../core/models/config-types.js'; import type { StepProviderOptions } from '../../../core/models/workflow-types.js'; import type { PermissionMode } from '../../../core/models/types.js'; import type { ProviderResolutionSource } from '../../../core/workflow/provider-options-trace.js'; import { type RuntimeProviderResolutionContext } from './resolution-context.js'; import { type McpSection } from './schema.js'; import type { RuntimeProviderSection } from './schema.js'; /** * Provider/model/options resolved for the internal agents. The seat set is defined once in * `core/models/config-types.ts` so the compiler and the engine consumers cannot drift apart. */ export type InternalAgentEnvironment = InternalAgentSeats; /** Format-agnostic provider engine-options bundle consumed by the engine. */ export interface CompiledProviderEnvironment { provider: ProviderType | undefined; providerSource: ProviderResolutionSource; model: string | undefined; modelSource: ProviderResolutionSource; personaProviders: Record | undefined; providerRouting: ProviderRoutingConfig | undefined; autoRouting: AutoRoutingConfig | undefined; providerOptions: StepProviderOptions | undefined; permissionMode: PermissionMode | undefined; /** * How the engine resolves same-priority tag routing conflicts. Carried on the bundle (not * derived from the format at the seam) so executor/runner/SDK act on a policy, never on * "is this runtime-v1". */ tagConflictPolicy: TagRoutingConflictPolicy; /** * Provider/model/options for the internal selector/assistant agents. Undefined in legacy * mode (those seams keep resolving `taktProviders`); set in runtime-v1 mode so the selector * and assistant seams resolve the runtime.yaml `targets.internal_agents` ladder. */ internalAgents: InternalAgentEnvironment | undefined; /** * Runtime MCP assignment section (runtime-v1 only). Carries the `mcp` * section from `runtime.yaml` so the engine can resolve effective servers * per agent execution (issue #1137). Undefined in legacy mode. */ mcpAssignment?: McpSection | undefined; companions?: Record; /** * Every stage of each `ladder` assignment (issue #1208), so the promotion seam can advance a * matched target-less `{at:N}` to a later stage. Stage 0 is the initial assignment already * carried by provider/model/personaProviders/providerRouting; only the later stages are new * information. Undefined in legacy mode and when no assignment uses a `ladder`. `internal_agents` * ladders are intentionally excluded — those seats are not promotion targets. */ providerLadders: ProviderLadderConfig | undefined; } /** The exact provider engine-options the legacy bootstrap already resolved. */ export interface LegacyProviderEnvironmentInput { provider: ProviderType | undefined; providerSource: ProviderResolutionSource; model: string | undefined; modelSource: ProviderResolutionSource; personaProviders: Record | undefined; providerRouting: ProviderRoutingConfig | undefined; autoRouting: AutoRoutingConfig | undefined; providerOptions: StepProviderOptions | undefined; /** * `takt_providers` provider assignments explicitly written to project/global `config.yaml`. * order.md lists a `takt_providers` provider indication among the legacy settings that must not * coexist with an active runtime.yaml section, so it participates in mixed-config detection. */ taktProviders?: TaktProvidersConfig; } export type ProviderConfigModel = { kind: 'legacy'; legacy: LegacyProviderEnvironmentInput; } | { kind: 'runtime-v1'; section: RuntimeProviderSection | undefined; mcp: McpSection | undefined; resolutionContext?: RuntimeProviderResolutionContext; }; /** Factory/registry: pick the matching compiler for the loaded configuration format. */ export declare function compileProviderEnvironment(model: ProviderConfigModel): CompiledProviderEnvironment; /** LegacyProviderPolicyCompiler: pass the already-resolved legacy engine-options through unchanged. */ export declare function compileLegacyProviderEnvironment(legacy: LegacyProviderEnvironmentInput): CompiledProviderEnvironment; /** * RuntimeProviderPolicyCompiler: map a validated runtime.yaml `provider` section into the * shared engine-options bundle. Profile `options`, `pool`/`auto_routing`, and `internal_agents` * are all compiled into the bundle here; nothing is left unwired. When `section` is * undefined or inactive the runtime-v1 mode was entered by an active `mcp` section alone * (order.md:36); the bundle then carries no runtime provider/model/options but * still forwards the `mcp` assignment. */ export declare function compileRuntimeProviderEnvironment(section: RuntimeProviderSection | undefined, resolutionContext?: RuntimeProviderResolutionContext, mcp?: McpSection): CompiledProviderEnvironment; //# sourceMappingURL=environment.d.ts.map