/** * Agent Runtime Binding Resolution — PRI-306 * * Pure functions that resolve which RuntimeProfile an internal agent uses, * check readiness, and produce adapter configuration. * * No I/O — env var access is injected via getEnvVar callback. * No `as` casts on untrusted data (ERR-001). * Missing fields fail loud with reason + nextAction (ERR-002, ERR-009). * Uses Object.hasOwn() for key checks (ERR-013). */ import type { EffectivePdConfig, InternalAgentName, RuntimeProfile } from './pd-config-types.js'; export interface AgentRuntimeBindingOk { ok: true; /** The resolved runtime profile */ profile: RuntimeProfile; /** The profile ID in the runtimeProfiles map */ profileId: string; /** How this binding was resolved: 'agent_override' = per-agent override, 'default_runtime' = fallback to defaultRuntime */ source: 'agent_override' | 'default_runtime'; } export interface AgentRuntimeBindingErr { ok: false; /** Readiness status */ readiness: 'needs_setup' | 'not_ready' | 'disabled'; /** Human-readable reason */ reason: string; /** Actionable next step */ nextAction: string; } export type AgentRuntimeBindingResult = AgentRuntimeBindingOk | AgentRuntimeBindingErr; export interface AgentRuntimeReadinessResult { readiness: 'ready' | 'not_ready' | 'needs_setup'; reason?: string; nextAction?: string; } export interface PiAiAdapterConfigResult { runtimeKind: 'pi-ai'; provider: string; model: string; apiKeyEnv: string; baseUrl?: string; timeoutMs?: number; maxRetries?: number; /** Optional max output tokens (max_tokens) for pi-ai LLM calls. */ maxTokens?: number; /** Optional reasoning level (from profile, flows to PiAiRuntimeAdapter; PRI-758). */ reasoning?: 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | false; /** Optional system prompt (from profile, flows to PiAiRuntimeAdapter). */ systemPrompt?: string; workspace: string; } export interface OpenClawAdapterConfigResult { runtimeKind: 'openclaw-cli'; workspaceDir: string; /** 'default' = delegate to OpenClaw's own mode resolution (CLI flags, workflows.yaml). * 'local' | 'gateway' = explicit mode from profile config. */ openclawMode: 'local' | 'gateway' | 'default'; } export type AdapterConfigResult = PiAiAdapterConfigResult | OpenClawAdapterConfigResult; /** * Resolve which RuntimeProfile an internal agent should use. * * Resolution order: * 1. Per-agent override (agent.runtimeProfile) → source: 'agent_override' * 2. defaultRuntime → source: 'default_runtime' * * If the resolved profile ID doesn't exist in runtimeProfiles, returns an error. * If the agent is disabled, returns a disabled result. */ export declare function resolveAgentRuntimeBinding(effective: EffectivePdConfig, agentName: InternalAgentName): AgentRuntimeBindingResult; /** * Check whether a RuntimeProfile is ready for use. * * For openclaw profiles: * - source=default → ready (delegated to OpenClaw) * - provider+model set → ready * - otherwise → needs_setup * * For pi-ai profiles: * - provider, model, apiKeyEnv all set AND apiKeyEnv exists in env → ready * - apiKeyEnv missing from env → not_ready (config is correct but env is not set up) * - provider or model missing → needs_setup (config is incomplete) * * The getEnvVar callback is injected to avoid process.env access in core. */ export declare function checkAgentRuntimeReadiness(profile: RuntimeProfile, getEnvVar: (name: string) => string | undefined): AgentRuntimeReadinessResult; /** * Transform a RuntimeProfile into adapter configuration. * * For pi-ai profiles: produces PiAiAdapterConfigResult with all fields needed * to construct a PiAiRuntimeAdapter. * * For openclaw profiles: produces OpenClawAdapterConfigResult. * OpenClaw profiles do NOT copy secrets — they only reference provider/model. * * This is a pure data transform. No I/O, no env access. */ export declare function createAdapterConfigFromProfile(profile: RuntimeProfile, workspaceDir: string): AdapterConfigResult; //# sourceMappingURL=pd-config-agent-binding.d.ts.map