/** * Resolves vendor-neutral model gateway configuration. Gateway mode routes compatible model * traffic through its endpoint and credential, with strict admission for conflicting * provider keys. */ /** * Vendor-neutral gateway env var: the OpenAI-compatible base URL that fronts * all model traffic when broker/gateway mode is enabled. * * Canonical name mirrors `MODEL_GATEWAY_URL_KEY` in the sibling E2 module * for cross-layer greppability. * Duplicated (not imported) to keep the packages/core -> plugin dependency * direction clean. */ export declare const MODEL_GATEWAY_URL_KEY = "ELIZA_MODEL_GATEWAY_URL"; /** * Vendor-neutral gateway env var: the agent-scoped bearer token the gateway * expects. An unmodified OpenAI SDK sends this as the api key. * * Canonical name mirrors `MODEL_GATEWAY_TOKEN_KEY` in the sibling E2 module. */ export declare const MODEL_GATEWAY_TOKEN_KEY = "ELIZA_MODEL_GATEWAY_TOKEN"; /** * Fail-closed strict-mode env var (E1-only; the E2 sub-agent module has no * strict mode). When truthy, refuse to run if a raw provider key is present * while gateway mode is on. */ export declare const MODEL_GATEWAY_STRICT_KEY = "ELIZA_MODEL_GATEWAY_STRICT"; /** * Raw provider keys that must never coexist with the gateway token when * strict mode is on, and that are scrubbed from OpenAI-compatible client * config when gateway mode is on. Kept small and explicit on purpose. * * This is the CORE-RUNTIME subset relevant to the OpenAI-compatible client * paths here. The sibling E2 module maintains a broader * `MODEL_GATEWAY_EXCLUDED_PROVIDER_KEYS` list because a spawned * sub-agent env can carry additional credential sources (CODEX_API_KEY, * CLAUDE_CODE_OAUTH_TOKEN, ELIZA_-prefixed keys, etc.) that don't apply to the * in-process model client resolved here. */ export declare const RAW_PROVIDER_KEY_VARS: readonly ["OPENAI_API_KEY", "ANTHROPIC_API_KEY"]; export type RawProviderKeyVar = (typeof RAW_PROVIDER_KEY_VARS)[number]; /** * Minimal accessor shape. Callers pass their existing setting resolver (which * may layer runtime settings over `process.env`) so gateway resolution honours * the exact same precedence as the raw vars it replaces. */ export type GetSettingFn = (key: string) => string | undefined; export interface ModelGatewayResolution { /** Whether gateway mode is active (i.e. a gateway URL was provided). */ enabled: boolean; /** Whether strict fail-closed mode is enabled. */ strict: boolean; /** Effective base URL for OpenAI-compatible clients (undefined = unchanged). */ baseURL: string | undefined; /** Effective api key for OpenAI-compatible clients (undefined = unchanged). */ apiKey: string | undefined; } /** * Error thrown when strict gateway mode detects a raw provider key that would * bypass the broker. Named so callers can distinguish it from generic config * errors if they want to. */ export declare class ModelGatewayStrictError extends Error { readonly offendingVars: RawProviderKeyVar[]; constructor(offendingVars: RawProviderKeyVar[]); } /** * Resolve model-gateway settings from a getSetting accessor. * * @throws ModelGatewayStrictError when strict mode is on, gateway mode is on, * and one or more raw provider keys are present. */ export declare function resolveModelGateway(getSetting: GetSettingFn): ModelGatewayResolution; /** * Shape of an OpenAI-compatible base URL + api key pair, as consumed by the * resolved model config. */ export interface OpenAiCompatibleCreds { baseURL: string | undefined; apiKey: string | undefined; } /** * Apply gateway resolution to a raw OpenAI-compatible base URL / api key pair. * * When gateway mode is on: * - the gateway URL overrides the base URL, * - the gateway token overrides the api key, * - the incoming raw api key is scrubbed (dropped) so it never travels with * the gateway request. * * When gateway mode is off, the inputs are returned unchanged. */ export declare function applyModelGateway(raw: OpenAiCompatibleCreds, resolution: ModelGatewayResolution): OpenAiCompatibleCreds;