{
  "$defs": {
    "AccountStrategy": {
      "description": "How a multi-account provider's per-account targets are ordered.",
      "oneOf": [
        {
          "const": "failover",
          "description": "Accounts in declared order — the first is primary; routing drops\nto the next on a retryable failure (5xx / 429 / timeout) or a\npayment / credit-exhaustion error. The default.",
          "type": "string"
        },
        {
          "const": "balance",
          "description": "Accounts ordered with a process-random rotation so the primary\n(and therefore the load) spreads evenly across accounts. The\nremaining accounts still act as failover targets for that\nrequest.",
          "type": "string"
        }
      ]
    },
    "AcpAgentConfig": {
      "description": "One configured upstream ACP agent, as written in `bitrouter.yaml` under\n`agents:`.\n\nThe same `name` is what every `bro acp` subcommand addresses an\nagent by, and what [`AcpAgentConfig::validate`] constrains.",
      "properties": {
        "name": {
          "description": "Agent id. Non-empty; no `/`.",
          "type": "string"
        },
        "transport": {
          "$ref": "#/$defs/AcpTransport",
          "description": "Wire transport."
        }
      },
      "required": [
        "name",
        "transport"
      ],
      "type": "object"
    },
    "AcpRecordingConfig": {
      "description": "Local ACP conversation content recording, independent of routing evidence.",
      "properties": {
        "enabled": {
          "default": false,
          "description": "Store observable session messages and tool results until explicitly deleted.\nNo content is recorded or sent to an evaluator by default.",
          "type": "boolean"
        }
      },
      "type": "object"
    },
    "AcpTransport": {
      "description": "How to dial one upstream ACP agent.\n\nv1.0 ships stdio only — the spec lists stdio as the primary transport for\nagent processes spawned by an IDE / CLI client.",
      "oneOf": [
        {
          "description": "Stdio transport: launch `command` with `args` and exchange JSON-RPC\nover the child's stdin/stdout.",
          "properties": {
            "args": {
              "default": [],
              "description": "Arguments to pass to the child.",
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "command": {
              "description": "The program to spawn (resolved via `$PATH`).",
              "type": "string"
            },
            "env": {
              "additionalProperties": {
                "type": "string"
              },
              "default": {},
              "description": "Extra environment variables for the child. Inherited env is kept.",
              "type": "object"
            },
            "type": {
              "const": "stdio",
              "type": "string"
            }
          },
          "required": [
            "type",
            "command"
          ],
          "type": "object"
        }
      ]
    },
    "AgentApiConfig": {
      "additionalProperties": false,
      "description": "Privileged HTTP access to the BRO task service. The app validates a\nloopback listener, nonempty token environment variable, and workspace\nallowlist before binding; `server.skip_auth` never grants this authority.",
      "properties": {
        "enabled": {
          "default": false,
          "description": "Whether to bind the task HTTP listener.",
          "type": "boolean"
        },
        "listen": {
          "default": "127.0.0.1:4359",
          "description": "Loopback host and port, distinct from inference and control.",
          "type": "string"
        },
        "token_env": {
          "default": "",
          "description": "Environment variable containing the dedicated task bearer token.",
          "type": "string"
        },
        "workspaces": {
          "default": [],
          "description": "Exact server-owned workspace paths admitted for task submission.",
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      },
      "type": "object"
    },
    "ApiProtocol": {
      "description": "Wire protocol. Known values: `chat_completions`, `messages`, `responses`, `decisions`; any other string names an externally-registered (outbound-only) custom protocol.",
      "examples": [
        "chat_completions",
        "messages",
        "responses",
        "decisions"
      ],
      "type": "string"
    },
    "Capability": {
      "description": "An optional inference feature a request may require and a provider may\nadvertise. Capabilities are API-agnostic: the same capability maps to a\ndifferent wire parameter in each protocol (structured outputs is Chat\nCompletions' `response_format`, Messages' `output_config.format`, Generate\nContent's `responseSchema`, Responses' `text.format`). The serde\nrepresentation (e.g. `structured_outputs`) is the stable token used to match\na request's needs against a provider's advertised capabilities.\n\nA capability-aware `RoutingTable`\ncan read the set a request requires ([`Prompt::required_capabilities`]) and\nrestrict the chain to providers advertising all of them.",
      "oneOf": [
        {
          "const": "structured_outputs",
          "description": "JSON-Schema-constrained output — [`ResponseFormat::JsonSchema`].",
          "type": "string"
        },
        {
          "const": "tools",
          "description": "Tool / function calling — the request supplies a non-empty tool list.",
          "type": "string"
        },
        {
          "const": "reasoning",
          "description": "Extended reasoning / thinking — the request sets a reasoning-effort hint.",
          "type": "string"
        },
        {
          "const": "web_search",
          "description": "Provider-side web search / browsing.",
          "type": "string"
        },
        {
          "const": "logprobs",
          "description": "Token log-probabilities in the response.",
          "type": "string"
        },
        {
          "const": "image_input",
          "description": "Image input (vision) — a message carries an `image/*` file part.",
          "type": "string"
        },
        {
          "const": "audio_input",
          "description": "Audio input — a message carries an `audio/*` file part.",
          "type": "string"
        },
        {
          "const": "video_input",
          "description": "Video input — a message carries a `video/*` file part.",
          "type": "string"
        },
        {
          "const": "file_input",
          "description": "Document / file input — a message carries a non-image/audio/video file\npart (e.g. `application/pdf`).",
          "type": "string"
        },
        {
          "const": "image_output",
          "description": "Image output (generation) — the request asks for an `image` output\nmodality.",
          "type": "string"
        },
        {
          "const": "audio_output",
          "description": "Audio output (speech) — the request asks for an `audio` output modality.",
          "type": "string"
        }
      ]
    },
    "ChatCompletionsCompatibility": {
      "description": "Chat Completions request-shape compatibility settings.",
      "properties": {
        "google_extensions": {
          "default": false,
          "description": "Enable the demonstrated Google Chat extensions for this selected model.\nSigned tool history additionally requires a credential-bound replay proof.",
          "type": "boolean"
        },
        "supports_store": {
          "default": null,
          "description": "Whether this target accepts the optional `store` request field. `None`\npreserves the OpenAI-compatible default (supported).",
          "type": [
            "boolean",
            "null"
          ]
        },
        "supports_stream_options": {
          "default": null,
          "description": "Whether this target accepts `stream_options`. `None` preserves the\nOpenAI-compatible default (supported, with `include_usage` injected).\nSetting this to `false` also disables the router's usage-chunk request,\nso it is appropriate only when the target rejects the entire object.",
          "type": [
            "boolean",
            "null"
          ]
        },
        "token_limit_field": {
          "anyOf": [
            {
              "$ref": "#/$defs/ChatTokenLimitField"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Token-limit field required by this upstream model."
        }
      },
      "type": "object"
    },
    "ChatConfig": {
      "description": "`bro chat`'s own configuration.",
      "properties": {
        "agent": {
          "default": null,
          "description": "Default ACP harness for bare `bitrouter` (catalog id or configured agent).",
          "type": [
            "string",
            "null"
          ]
        },
        "commands": {
          "description": "Prompt-expansion commands.\n\n`/name args` in `bro chat`, or `bro acp prompt \"/name args\"`,\nsends `prompt` with `$ARGUMENTS` replaced by everything typed after the\nname.\n\nThere is deliberately no key that *runs* anything. A command here\nproduces a prompt and nothing else, which is what lets the registry be\nopen — user-authored, unreviewed — while the registry of commands that\nreach BitRouter's own ports stays closed and guarded.",
          "items": {
            "$ref": "#/$defs/PromptCommandConfig"
          },
          "type": "array"
        },
        "model": {
          "default": null,
          "description": "Default daemon-routable model for the chat session.",
          "type": [
            "string",
            "null"
          ]
        }
      },
      "type": "object"
    },
    "ChatTokenLimitField": {
      "description": "Chat Completions field used to carry the output-token budget.\n\nOpenAI-compatible providers are split between the legacy `max_tokens`\nspelling and the current `max_completion_tokens` spelling. The canonical\nprompt keeps one semantic token budget; this enum only records which wire\nspelling should be used when the prompt is rendered back to Chat\nCompletions.",
      "oneOf": [
        {
          "const": "max_tokens",
          "description": "Legacy Chat Completions field.",
          "type": "string"
        },
        {
          "const": "max_completion_tokens",
          "description": "Current Chat Completions field, including reasoning tokens.",
          "type": "string"
        }
      ]
    },
    "CheckerConfig": {
      "anyOf": [
        {
          "additionalProperties": false,
          "description": "A callback registered under this checker id by the host.",
          "properties": {
            "native": {
              "$ref": "#/$defs/NativeCheckerConfig",
              "description": "Expected code/rules revision; registration must match exactly."
            }
          },
          "required": [
            "native"
          ],
          "type": "object"
        }
      ],
      "description": "A request-check implementation explicitly linked by a custom host.\n\nThe existing `native.revision` configuration shape remains supported. Former\nHTTP declarations are rejected with a migration diagnostic, never ignored."
    },
    "ContinuationConfig": {
      "description": "Always-active durable provider continuation lifecycle settings.",
      "properties": {
        "prune_batch_size": {
          "default": 1000,
          "description": "Maximum expired rows removed by one prune operation.",
          "format": "uint",
          "minimum": 0,
          "type": "integer"
        },
        "retention_days": {
          "default": 30,
          "description": "Days before a continuation becomes unusable.",
          "format": "uint32",
          "minimum": 0,
          "type": "integer"
        }
      },
      "type": "object"
    },
    "ControlConfig": {
      "additionalProperties": false,
      "description": "Scoped operator administration API settings.\n\nThe control API is deliberately separate from the inference listener and\nthe local control socket. It is disabled by default, may bind only to a\nloopback address, and authenticates named credentials when configured.\nOtherwise `BITROUTER_CONTROL_TOKEN` grants read-only access.\n[`ServerConfig::skip_auth`] never applies to it.",
      "properties": {
        "credentials": {
          "description": "Explicit operator credentials. Empty keeps the legacy read-only token.",
          "items": {
            "$ref": "#/$defs/ControlCredentialConfig"
          },
          "type": "array"
        },
        "enabled": {
          "default": false,
          "description": "Whether to start the HTTP control listener.",
          "type": "boolean"
        },
        "listen": {
          "default": "127.0.0.1:4358",
          "description": "Loopback `host:port` to listen on.",
          "type": "string"
        }
      },
      "type": "object"
    },
    "ControlCredentialConfig": {
      "additionalProperties": false,
      "description": "A token reference only; configuration never stores the bearer value.",
      "properties": {
        "id": {
          "description": "Non-secret operator identifier used for ownership and audit events.",
          "type": "string"
        },
        "scopes": {
          "description": "Explicit management authority, unrelated to inference authentication.",
          "items": {
            "$ref": "#/$defs/ControlScope"
          },
          "type": "array"
        },
        "token_env": {
          "description": "Host environment variable that contains this credential's bearer token.",
          "type": "string"
        }
      },
      "required": [
        "id",
        "token_env",
        "scopes"
      ],
      "type": "object"
    },
    "ControlScope": {
      "description": "Authority granted by a host operator, independently of inference credentials.",
      "oneOf": [
        {
          "const": "control:read",
          "description": "Host-wide operational inspection, including usage and policy metadata.",
          "type": "string"
        },
        {
          "const": "control:reload",
          "description": "Reload server-owned configuration; requires the read grant as well.",
          "type": "string"
        }
      ]
    },
    "DatabaseConfig": {
      "description": "Database connection settings.",
      "properties": {
        "url": {
          "default": "sqlite://./bitrouter.db",
          "description": "Connection URL (e.g. `sqlite://./bitrouter.db`).",
          "type": "string"
        }
      },
      "type": "object"
    },
    "DecisionModelConfig": {
      "additionalProperties": false,
      "description": "An optional `decision_model:` block enables native context decisions.",
      "properties": {
        "api_key_env": {
          "default": "TYPESAFE_API_KEY",
          "description": "Environment variable containing the API credential.",
          "type": "string"
        },
        "base_url": {
          "default": "https://api.typesafe.ai",
          "description": "TypeSafe API root; a compatible local endpoint can be used for testing.",
          "type": "string"
        },
        "max_response_bytes": {
          "default": 1048576,
          "description": "Maximum response bytes; independent of context and checkpoint limits.",
          "format": "uint",
          "minimum": 0,
          "type": "integer"
        },
        "model": {
          "description": "Decision model name or alias from TypeSafe's authenticated model list.",
          "type": "string"
        },
        "policy": {
          "$ref": "#/$defs/DecisionPolicy",
          "default": {
            "candidate_excerpt_bytes": 2048,
            "confidence_threshold": 0.85,
            "max_candidates": 32,
            "max_request_bytes": 131072,
            "minimum_savings_fraction": 0.1,
            "model_switch_penalty_microusd": 1000,
            "prefix_loss_penalty_microusd_per_kib": 0,
            "retain_recent_groups": 2,
            "target_context_bytes": 98304
          },
          "description": "Native context planning limits, frozen into each decision intent."
        },
        "pricing": {
          "anyOf": [
            {
              "$ref": "#/$defs/DecisionPricing"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Optional operator-supplied token prices; estimates, never settled bills."
        },
        "timeout_ms": {
          "default": 30000,
          "description": "Whole-attempt timeout, including reading and validating the response.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "model"
      ],
      "type": "object"
    },
    "DecisionPolicy": {
      "additionalProperties": false,
      "description": "Bounds used by the native harness when compiling task-specific context.\nThese are local planning limits, not claims about provider capacity.",
      "properties": {
        "candidate_excerpt_bytes": {
          "default": 2048,
          "description": "Maximum text preview per candidate sent to the decision model.",
          "format": "uint",
          "minimum": 0,
          "type": "integer"
        },
        "confidence_threshold": {
          "default": 0.85,
          "description": "Minimum confidence for a lossy representation or context omission.",
          "format": "double",
          "type": "number"
        },
        "max_candidates": {
          "default": 32,
          "description": "Most candidate evidence groups judged in one planning pass.",
          "format": "uint",
          "minimum": 0,
          "type": "integer"
        },
        "max_request_bytes": {
          "default": 131072,
          "description": "Maximum serialized decision request, including rubrics and task text.",
          "format": "uint",
          "minimum": 0,
          "type": "integer"
        },
        "minimum_savings_fraction": {
          "default": 0.1,
          "description": "Required relative improvement before changing a feasible prior plan.",
          "format": "double",
          "type": "number"
        },
        "model_switch_penalty_microusd": {
          "default": 1000,
          "description": "Planning penalty for changing models; not a provider charge.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "prefix_loss_penalty_microusd_per_kib": {
          "default": 0,
          "description": "Optional planning penalty per KiB of lost exact prompt prefix.\nMatching bytes never establish an actual provider cache hit.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "retain_recent_groups": {
          "default": 2,
          "description": "Recent complete groups always kept in the active worker's view.",
          "format": "uint",
          "minimum": 0,
          "type": "integer"
        },
        "target_context_bytes": {
          "default": 98304,
          "description": "Soft prompt byte target. Required evidence may exceed it up to hard limits.",
          "format": "uint",
          "minimum": 0,
          "type": "integer"
        }
      },
      "type": "object"
    },
    "DecisionPricing": {
      "additionalProperties": false,
      "description": "Optional token prices supplied by the operator, distinct from provider bills.",
      "properties": {
        "input_usd_per_million": {
          "description": "USD per million input tokens.",
          "format": "double",
          "type": "number"
        },
        "output_usd_per_million": {
          "description": "USD per million output tokens.",
          "format": "double",
          "type": "number"
        }
      },
      "required": [
        "input_usd_per_million",
        "output_usd_per_million"
      ],
      "type": "object"
    },
    "EvalAuthorityConfig": {
      "description": "Identity and metric scope admitted for one evaluator authority.",
      "properties": {
        "allow_hard_fail": {
          "default": false,
          "description": "Whether submissions may declare hard violations.",
          "type": "boolean"
        },
        "allowed_metrics": {
          "default": [],
          "description": "Exact metric ids, namespace wildcards, or `*` accepted from this authority.",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "api_key_ids": {
          "default": [],
          "description": "Virtual-key record ids authorized for submissions.",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "kind": {
          "$ref": "#/$defs/EvalAuthorityKind",
          "default": "generic",
          "description": "Evaluator class this authority may claim."
        },
        "user_ids": {
          "default": [],
          "description": "Authenticated user ids authorized for submissions.",
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      },
      "type": "object"
    },
    "EvalAuthorityKind": {
      "description": "Evaluator trust class configured by the operator.",
      "oneOf": [
        {
          "const": "task_native",
          "description": "Benchmark- or task-native verifier.",
          "type": "string"
        },
        {
          "const": "human",
          "description": "Human review.",
          "type": "string"
        },
        {
          "const": "enterprise",
          "description": "Enterprise-owned private evaluator.",
          "type": "string"
        },
        {
          "const": "agentic",
          "description": "Agent-driven review.",
          "type": "string"
        },
        {
          "const": "generic",
          "description": "Evaluator without a stronger domain-specific class.",
          "type": "string"
        }
      ]
    },
    "EvalConfig": {
      "description": "Generic evaluation exchange configuration.",
      "properties": {
        "authorities": {
          "additionalProperties": {
            "$ref": "#/$defs/EvalAuthorityConfig"
          },
          "default": {},
          "description": "Trusted evaluator authorities keyed by stable authority id.",
          "type": "object"
        }
      },
      "type": "object"
    },
    "FusionSettings": {
      "description": "The `server_tools.fusion` config section. Its presence enables the Fusion\nserver tool and the `bitrouter/fusion` model alias; its fields supply the\nalias defaults (the panel/judge a bare `bitrouter/fusion` request expands\nto). An explicit `bitrouter:fusion` declaration on a request overrides these.",
      "properties": {
        "alias": {
          "default": null,
          "description": "Alias slug (defaults to `bitrouter/fusion`). Custom aliases cannot use\n`@preset`, `bitrouter:`, or the reserved `bitrouter/` namespace.",
          "type": [
            "string",
            "null"
          ]
        },
        "judge": {
          "default": null,
          "description": "Default judge model (defaults to the first panel model).",
          "type": [
            "string",
            "null"
          ]
        },
        "outer_model": {
          "default": null,
          "description": "The model the alias resolves to (defaults to the judge, then the first\npanel model).",
          "type": [
            "string",
            "null"
          ]
        },
        "panel": {
          "default": [],
          "description": "Default panel models the alias expands to.",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "synthesizer": {
          "default": null,
          "description": "Optional dedicated synthesizer model.",
          "type": [
            "string",
            "null"
          ]
        },
        "web_tools": {
          "default": [],
          "description": "Provider web tools forwarded to every panel member, in\nprovider-namespaced declaration form (e.g. `{type: \"<provider>:<tool>\"}`).",
          "items": true,
          "type": "array"
        }
      },
      "type": "object"
    },
    "InputTokenCounting": {
      "description": "Explicit provider support, never inferred from a compatible generation API.",
      "oneOf": [
        {
          "const": "responses",
          "description": "POST /responses/input_tokens on the same provider endpoint.",
          "type": "string"
        }
      ]
    },
    "McpAggregateConfig": {
      "description": "`mcp.aggregate` — the virtual aggregate endpoint.",
      "properties": {
        "enabled": {
          "default": true,
          "description": "When `true` (the default), mount the aggregate route. When `false`,\nonly per-server routes (`/mcp/{server}`) are mounted.",
          "type": "boolean"
        },
        "route": {
          "default": "/mcp",
          "description": "HTTP path for the aggregate endpoint. Default `/mcp`.",
          "type": "string"
        }
      },
      "type": "object"
    },
    "McpCacheConfig": {
      "description": "`mcp.cache` — the TTL cache wrapping cheap list calls.",
      "properties": {
        "enabled": {
          "default": true,
          "description": "When `false`, the cache layer is not installed.",
          "type": "boolean"
        },
        "max_entries_per_server": {
          "default": 64,
          "description": "LRU safety bound — max entries per server.",
          "format": "uint",
          "minimum": 0,
          "type": "integer"
        },
        "prompts_list_ttl_secs": {
          "default": 300,
          "description": "TTL for `prompts/list`. `0` disables for this method.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "resources_list_ttl_secs": {
          "default": 60,
          "description": "TTL for `resources/list`. `0` disables for this method.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "resources_templates_list_ttl_secs": {
          "default": 300,
          "description": "TTL for `resources/templates/list`. `0` disables for this method.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "tools_list_ttl_secs": {
          "default": 60,
          "description": "TTL for `tools/list`. `0` disables for this method.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        }
      },
      "type": "object"
    },
    "McpConfig": {
      "description": "Top-level MCP gateway settings.",
      "properties": {
        "aggregate": {
          "$ref": "#/$defs/McpAggregateConfig",
          "description": "Aggregation (fan-out) endpoint settings."
        },
        "cache": {
          "$ref": "#/$defs/McpCacheConfig",
          "description": "List-call cache settings."
        },
        "upstream_protocol": {
          "$ref": "#/$defs/McpUpstreamProtocol",
          "description": "MCP startup lifecycle and protocol version for upstream servers."
        }
      },
      "type": "object"
    },
    "McpServerConfig": {
      "description": "One configured upstream MCP server, as written in `bitrouter.yaml`.\n\nThe same `name` becomes the URL segment in `POST /mcp/{name}` and the\nidentifier the [`super::RoutingTable`] resolves against. Restrictions\nchosen to match the v0 config schema for paste-compatibility:\n\n- non-empty\n- no `/` (collides with the URL path segment)\n- not literally `sse` (reserved by the spec's deprecated transport name)",
      "properties": {
        "aggregate": {
          "default": true,
          "description": "Whether this server participates in the aggregate fan-out endpoint\n(typically `POST /mcp`). Default: `true`.",
          "type": "boolean"
        },
        "name": {
          "description": "Server id. URL-safe; no slashes.",
          "type": "string"
        },
        "tool_prefix": {
          "default": null,
          "description": "Prefix prepended to upstream tool/prompt names when this server\nparticipates in aggregate fan-out. When `None`, the config-load layer\nfills in `{server_name}__`.",
          "type": [
            "string",
            "null"
          ]
        },
        "transport": {
          "$ref": "#/$defs/McpTransport",
          "description": "Wire transport."
        }
      },
      "required": [
        "name",
        "transport"
      ],
      "type": "object"
    },
    "McpTransport": {
      "description": "How to dial one upstream MCP server.\n\nSerde tag is `type: \"http\" | \"stdio\"` to match the wire shape used in\n`bitrouter.yaml`.",
      "oneOf": [
        {
          "description": "Streamable HTTP transport — `POST <url>` JSON-RPC with optional SSE\nresponses.",
          "properties": {
            "headers": {
              "additionalProperties": {
                "type": "string"
              },
              "default": {},
              "description": "Static headers added to every request (e.g. `Authorization`).",
              "type": "object"
            },
            "type": {
              "const": "http",
              "type": "string"
            },
            "url": {
              "description": "The MCP endpoint URL (e.g. `https://mcp.example.com/v1/mcp`).",
              "type": "string"
            }
          },
          "required": [
            "type",
            "url"
          ],
          "type": "object"
        },
        {
          "description": "Stdio transport — spawn `command` with `args` and exchange JSON-RPC\nover the child's stdin/stdout.",
          "properties": {
            "args": {
              "default": [],
              "description": "Arguments to pass to the child.",
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "command": {
              "description": "The program to spawn (resolved via `$PATH`).",
              "type": "string"
            },
            "env": {
              "additionalProperties": {
                "type": "string"
              },
              "default": {},
              "description": "Extra environment variables for the child. Inherited env is kept.",
              "type": "object"
            },
            "type": {
              "const": "stdio",
              "type": "string"
            }
          },
          "required": [
            "type",
            "command"
          ],
          "type": "object"
        }
      ]
    },
    "McpUpstreamProtocol": {
      "description": "`mcp.upstream_protocol` — the startup lifecycle and protocol version the\ngateway uses when dialing upstream MCP servers.\n\n`auto` (the default) starts with modern `server/discover` and uses rmcp's\nclassified legacy fallback. `latest` forces the legacy `initialize` path;\n`2026-07-28` is the explicit spelling of the modern preference.",
      "oneOf": [
        {
          "const": "auto",
          "description": "Prefer `server/discover` and `2026-07-28`, falling back through rmcp's\ncompatibility path when the upstream identifies itself as legacy.",
          "type": "string"
        },
        {
          "const": "latest",
          "description": "Use the legacy `initialize` lifecycle with the latest version the MCP\nSDK treats as current — today `2025-11-25`.",
          "type": "string"
        },
        {
          "const": "2026-07-28",
          "description": "Use `server/discover` and the modern `2026-07-28` lifecycle. rmcp falls\nback after its discovery timeout or a correlated JSON-RPC error it\nclassifies as legacy; transport failures, malformed or uncorrelated\nresponses, and modern rejection codes fail the connection. Opting in\nalso lets upstreams answer `tools/call` with MRTR `input_required` or a\nTasks `task` handle; neither is a shape this gateway can carry, so both\nsurface as explicit errors (see `docs/MCP_2026_07_28_SPEC.md` D1).",
          "type": "string"
        }
      ]
    },
    "ModelCompatibility": {
      "description": "Provider/model request-shape compatibility settings.",
      "properties": {
        "chat_completions": {
          "$ref": "#/$defs/ChatCompletionsCompatibility",
          "default": {
            "google_extensions": false,
            "supports_store": null,
            "supports_stream_options": null,
            "token_limit_field": null
          },
          "description": "Chat Completions-specific request settings."
        }
      },
      "type": "object"
    },
    "ModelTokenLimits": {
      "additionalProperties": false,
      "description": "Independently declared token limits. An input limit is not a combined\ncontext window, and an absent limit is unknown rather than unbounded.",
      "properties": {
        "context_window": {
          "default": null,
          "description": "Combined input and output capacity, only when explicitly known.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "max_input_tokens": {
          "default": null,
          "description": "Maximum input tokens, independently of the output allowance.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "max_output_tokens": {
          "default": null,
          "description": "Maximum generated tokens for one request.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        }
      },
      "type": "object"
    },
    "NativeCheckerConfig": {
      "additionalProperties": false,
      "description": "Startup identity for trusted, compiled-in request-check code.",
      "properties": {
        "revision": {
          "description": "Operator-chosen code/rules revision. Change it when behavior changes.",
          "type": "string"
        }
      },
      "required": [
        "revision"
      ],
      "type": "object"
    },
    "PatternMap_for_ProtocolList": {
      "description": "Glob-prefix pattern list; each entry is a single-key object mapping a pattern (`*`, `prefix*`, or an exact literal) to its value.",
      "items": {
        "additionalProperties": {
          "$ref": "#/$defs/ProtocolList"
        },
        "type": "object"
      },
      "type": "array"
    },
    "PatternMap_for_RateLimit": {
      "description": "Glob-prefix pattern list; each entry is a single-key object mapping a pattern (`*`, `prefix*`, or an exact literal) to its value.",
      "items": {
        "additionalProperties": {
          "$ref": "#/$defs/RateLimit"
        },
        "type": "object"
      },
      "type": "array"
    },
    "PolicyConfig": {
      "description": "Current routing-policy artifact configuration.",
      "properties": {
        "mode": {
          "$ref": "#/$defs/PolicyRuntimeMode",
          "default": "frozen",
          "description": "Runtime authority for adaptive routing and active policy publication.\n`writeback` is accepted as a migration alias for older configuration."
        },
        "path": {
          "default": null,
          "description": "Override for the policy lock. Relative paths are resolved against the\ndirectory containing the parsed `bitrouter.yaml`. `None` means the\nsibling `policy-lock.yaml` default.",
          "type": [
            "string",
            "null"
          ]
        }
      },
      "type": "object"
    },
    "PolicyRuntimeMode": {
      "description": "Process-owned routing-policy behavior.",
      "oneOf": [
        {
          "const": "frozen",
          "description": "Route from the static lock while continuing to record evidence. Learned\ndatabase state cannot affect live routing or replace the active lock.",
          "type": "string"
        },
        {
          "const": "adaptive",
          "description": "Permit explicit validated publication to atomically replace the active\nlock. Request-time routing remains identical to frozen mode.",
          "type": "string"
        }
      ]
    },
    "PresetConfig": {
      "description": "An `@preset` definition.",
      "properties": {
        "model": {
          "default": null,
          "description": "Substitute the request's model with this one.",
          "type": [
            "string",
            "null"
          ]
        },
        "params": {
          "additionalProperties": true,
          "default": {},
          "description": "Generation-parameter overrides, merged shallowly into the request.",
          "type": "object"
        },
        "policy": {
          "default": null,
          "description": "Name of a policy in `policy-lock.yaml`. Only requests that explicitly\nselect this preset opt into adaptive model selection.",
          "type": [
            "string",
            "null"
          ]
        },
        "routing": {
          "$ref": "#/$defs/RoutingConfig",
          "default": {
            "ignore": [],
            "only": [],
            "require_tags": [],
            "sort": null
          },
          "description": "Routing knobs fed into the cascade."
        },
        "system_prompt": {
          "default": null,
          "description": "Prepend / replace the system prompt.",
          "type": [
            "string",
            "null"
          ]
        }
      },
      "type": "object"
    },
    "PricingConfig": {
      "description": "Per-model pricing as written in config: micro-USD per token.\n\nThe top-level rates are the **base bracket**. [`context_tiers`] optionally\nraises the per-token rate once a request's input (prompt) token count\ncrosses a threshold — some upstreams bill a steeper rate above a context\nlength (e.g. a higher rate past 128k input tokens). Empty ⇒ flat pricing.\n\n[`context_tiers`]: PricingConfig::context_tiers",
      "properties": {
        "cache_read_micro_usd_per_token": {
          "default": null,
          "description": "Micro-USD per cache-read prompt token (base bracket).",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        },
        "cache_write_micro_usd_per_token": {
          "default": null,
          "description": "Micro-USD per cache-write prompt token (base bracket).",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        },
        "context_tiers": {
          "description": "Optional higher context brackets, applied by total input-token count.\nThe selected bracket's rates apply to the whole request (a step\nfunction); the consumer's bracket pick is order-independent.",
          "items": {
            "$ref": "#/$defs/PricingTierConfig"
          },
          "type": "array"
        },
        "endpoint_profile": {
          "anyOf": [
            {
              "$ref": "#/$defs/PricingEndpointProfile"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Published tariff's processing profile. A mismatch with the effective\nendpoint makes application price evidence unavailable."
        },
        "input_micro_usd_per_token": {
          "default": null,
          "description": "Micro-USD per uncached prompt token (base bracket). `None` means the\nprovider did not publish a rate; explicit `0` remains free.",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        },
        "output_micro_usd_per_token": {
          "default": null,
          "description": "Micro-USD per completion (output) token (base bracket).",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        }
      },
      "type": "object"
    },
    "PricingEndpointProfile": {
      "description": "Published processing-profile provenance; application pricing validates the\neffective endpoint rather than inferring premiums from this declaration.",
      "oneOf": [
        {
          "const": "openai_global",
          "description": "OpenAI global processing.",
          "type": "string"
        },
        {
          "const": "openai_us",
          "description": "OpenAI US regional processing.",
          "type": "string"
        },
        {
          "const": "openai_europe",
          "description": "OpenAI European regional processing.",
          "type": "string"
        }
      ]
    },
    "PricingTierConfig": {
      "description": "One higher context-pricing bracket in config — see\n[`PricingConfig::context_tiers`].",
      "properties": {
        "above_input_tokens": {
          "description": "Exclusive lower bound on total input tokens: a request whose input\nsize is strictly greater than this enters the bracket (a base bracket\ndocumented as \"≤ 128k\" is written as `above_input_tokens: 128000`).",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "cache_read_micro_usd_per_token": {
          "default": null,
          "description": "Micro-USD per cache-read prompt token for this bracket. `None` inherits\nthe base rate.",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        },
        "cache_write_micro_usd_per_token": {
          "default": null,
          "description": "Micro-USD per cache-write prompt token for this bracket. `None` inherits\nthe base rate.",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        },
        "input_micro_usd_per_token": {
          "default": null,
          "description": "Micro-USD per uncached prompt token for this bracket. `None` inherits\nthe base rate.",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        },
        "output_micro_usd_per_token": {
          "default": null,
          "description": "Micro-USD per completion (output) token for this bracket. `None`\ninherits the base rate.",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        }
      },
      "required": [
        "above_input_tokens"
      ],
      "type": "object"
    },
    "PromptCommandConfig": {
      "description": "One user-authored command that expands to a prompt.",
      "properties": {
        "description": {
          "default": "",
          "description": "One line for `/commands`.",
          "type": "string"
        },
        "name": {
          "description": "What to type after the slash. May not be a name BitRouter answers —\nthat is rejected when the config is loaded, not resolved at runtime.",
          "type": "string"
        },
        "prompt": {
          "description": "The prompt to send. `$ARGUMENTS` is replaced by whatever was typed\nafter the name; a template that uses it twice gets it twice.",
          "type": "string"
        }
      },
      "required": [
        "name",
        "prompt"
      ],
      "type": "object"
    },
    "ProtocolList": {
      "anyOf": [
        {
          "$ref": "#/$defs/ApiProtocol"
        },
        {
          "items": {
            "$ref": "#/$defs/ApiProtocol"
          },
          "type": "array"
        }
      ],
      "description": "One protocol (bare string) or an ordered set of them (array); the head is the preferred outbound protocol."
    },
    "ProviderAccount": {
      "description": "One credential within a multi-account provider. An account varies\nonly the credential (and optionally the base URL) — the protocol,\nmodel catalog, and rate limits are the provider's.",
      "properties": {
        "api_base": {
          "default": "",
          "description": "Optional per-account `api_base` override. Empty inherits the\nprovider's `api_base` — set it only for multi-region / multi-org\ndeployments where each account lives on a different host.",
          "type": "string"
        },
        "api_key": {
          "default": "",
          "description": "This account's API key (often a `${VAR}` reference).",
          "type": "string"
        },
        "label": {
          "default": "",
          "description": "Optional human label, surfaced in the request log so an operator\ncan see which account served a request. Defaults to\n`account-<n>` (1-based) when empty.",
          "type": "string"
        }
      },
      "type": "object"
    },
    "ProviderClass": {
      "description": "A provider's routing-preference class. Its position in\n[`RegistryConfig::provider_priority`] is its rank (earlier = preferred); the\ndefault ladder, highest first, is: first-party subscription ▸ gateway\nsubscription ▸ first-party token API ▸ bitrouter-cloud ▸ third-party token\nAPI.",
      "oneOf": [
        {
          "const": "first-party-subscription",
          "description": "A first-party / official upstream billed by flat-rate subscription\n(e.g. a first-party coding plan).",
          "type": "string"
        },
        {
          "const": "gateway-subscription",
          "description": "A gateway / aggregator billed by subscription.",
          "type": "string"
        },
        {
          "const": "first-party-api",
          "description": "A first-party / official upstream billed pay-as-you-go per token.",
          "type": "string"
        },
        {
          "const": "bitrouter-cloud",
          "description": "The bitrouter hosted gateway.",
          "type": "string"
        },
        {
          "const": "third-party-api",
          "description": "A third-party / community reseller billed pay-as-you-go per token.",
          "type": "string"
        }
      ]
    },
    "ProviderConfig": {
      "description": "One upstream provider entry — registry-style.\n\n`Debug` redacts `api_key` (v0 audit S9) so a future `tracing::error!(?config, …)`\ncan't dump the platform credential straight into structured logs.",
      "properties": {
        "account_strategy": {
          "$ref": "#/$defs/AccountStrategy",
          "description": "How the per-account targets are ordered when `accounts` is set."
        },
        "accounts": {
          "description": "Multiple credentials for this one provider — e.g. two\nsubscriptions to the same upstream. When non-empty, the routing\ntable expands the provider into one routing target per account;\n[`account_strategy`](Self::account_strategy) decides their\norder. Empty = a single-credential provider keyed off the\ntop-level [`api_key`](Self::api_key) (the common case).",
          "items": {
            "$ref": "#/$defs/ProviderAccount"
          },
          "type": "array"
        },
        "active": {
          "default": true,
          "description": "Whether this provider is active / routable.",
          "type": "boolean"
        },
        "api_base": {
          "default": "",
          "description": "Upstream API base URL.",
          "type": "string"
        },
        "api_key": {
          "default": "",
          "description": "Upstream API key (often a `${VAR}` reference).",
          "type": "string"
        },
        "api_protocol": {
          "$ref": "#/$defs/PatternMap_for_ProtocolList",
          "description": "Glob-prefix `api_protocol` pattern list — each pattern maps to an\nordered set of supported wire protocols (the head is the preferred\ndefault). Precedence: per-model override > longest matching pattern >\nhost-inferred default. A bare protocol string still parses to a\none-element set, so single-protocol providers are unchanged."
        },
        "auto_discover": {
          "default": false,
          "description": "When `true` and `models` is empty, discover models from the provider's\n`/models` endpoint at startup and on reload.",
          "type": "boolean"
        },
        "class": {
          "anyOf": [
            {
              "$ref": "#/$defs/ProviderClass"
            },
            {
              "type": "null"
            }
          ],
          "description": "Routing-preference class. Set by the public registry merge (or\ndirectly in config), then mapped to a numeric rank via\n[`RegistryConfig::provider_priority`]. `None` ⇒ unclassed: the provider\nsorts after every classed one in the auto-cascade (Strategy 3). Plain\nconfigs leave this `None`, preserving the alphabetical default order."
        },
        "derives": {
          "default": null,
          "description": "Inherit defaults from another provider in this config (acceptance F20 /\nv0 `derives`). The named provider's `headers`, `api_protocol`,\n`rate_limits`, `models`, `tags` and `auto_discover` flow into *this*\nprovider's empty fields; explicit fields here win. Resolved by\n[`resolve_derivations`] after the config is parsed.",
          "type": [
            "string",
            "null"
          ]
        },
        "headers": {
          "additionalProperties": {
            "$ref": "#/$defs/ProviderHeaderConfig"
          },
          "description": "Additional headers applied to every inference request for this\nprovider. A string is shorthand for a static default. The expanded\nform can opt into forwarding the same inbound header, which overrides\nthe default for that request.",
          "type": "object"
        },
        "models": {
          "description": "Declared model entries. Empty + `auto_discover` triggers discovery.",
          "items": {
            "$ref": "#/$defs/ProviderModel"
          },
          "type": "array"
        },
        "priority": {
          "default": null,
          "description": "Explicit routing priority (lower = preferred). When set it overrides the\nclass-derived rank, so an operator can pin one provider ahead of others\nregardless of class. `None` ⇒ derive the rank from [`class`](Self::class).",
          "format": "int32",
          "type": [
            "integer",
            "null"
          ]
        },
        "protocol_endpoints": {
          "additionalProperties": {
            "type": "string"
          },
          "default": {},
          "description": "Optional per-protocol base-URL override, keyed by protocol name\n([`ApiProtocol::as_str`]). When one provider serves different protocols\nat different paths under a single host — e.g. OpenAI-style under\n`BASE/v1` and Anthropic Messages under `BASE/anthropic` — give each\nprotocol's base here; protocol-native routing copies the chosen\nprotocol's base onto the routing target. Protocols absent here use\n[`api_base`](Self::api_base).",
          "type": "object"
        },
        "rate_limits": {
          "$ref": "#/$defs/PatternMap_for_RateLimit",
          "description": "Glob-prefix `rate_limits` pattern list, keyed per matched pattern."
        },
        "tags": {
          "default": [],
          "description": "Free-form tags, used by `RoutingPrefs.require_tags` filtering.",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "timeouts": {
          "$ref": "#/$defs/TimeoutConfig",
          "description": "Per-provider upstream timeout overrides. Each set field layers over the\nresolved global [`UpstreamConfig::timeouts`]; unset fields inherit it.\nNot inherited via [`derives`](Self::derives)."
        }
      },
      "type": "object"
    },
    "ProviderHeaderConfig": {
      "anyOf": [
        {
          "description": "Static value; equivalent to `{ default: value, passthrough: false }`.",
          "type": "string"
        },
        {
          "$ref": "#/$defs/ProviderHeaderPolicy",
          "description": "Expanded default/passthrough policy."
        }
      ],
      "description": "One provider header entry in `bitrouter.yaml`.\n\nA scalar string is shorthand for a static default with passthrough\ndisabled. The mapping form supports an optional `default` and an explicit\ninbound `passthrough` switch."
    },
    "ProviderHeaderPolicy": {
      "additionalProperties": false,
      "description": "Expanded provider header behavior.",
      "properties": {
        "default": {
          "default": null,
          "description": "Static value used when no allowed inbound value is present.",
          "type": [
            "string",
            "null"
          ]
        },
        "passthrough": {
          "default": false,
          "description": "Allow the inbound request's value(s) to override the static default.",
          "type": "boolean"
        }
      },
      "type": "object"
    },
    "ProviderModel": {
      "description": "One model entry under a provider.",
      "properties": {
        "api_protocol": {
          "anyOf": [
            {
              "$ref": "#/$defs/ProtocolList"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Per-model protocol override (highest precedence) — an ordered set of\nsupported protocols, or a bare string for a single one."
        },
        "capabilities": {
          "default": [],
          "description": "Features this concrete provider/model route explicitly advertises.\nAn empty list means unknown, not unsupported. Runtime routing preserves\nlegacy unknown entries; policy code that grants a capability-specific\nexception requires a positive declaration.",
          "items": {
            "$ref": "#/$defs/Capability"
          },
          "type": "array"
        },
        "compatibility": {
          "$ref": "#/$defs/ModelCompatibility",
          "default": {
            "chat_completions": {
              "google_extensions": false,
              "supports_store": null,
              "supports_stream_options": null,
              "token_limit_field": null
            }
          },
          "description": "Provider/model request-shape quirks that do not change model semantics."
        },
        "id": {
          "description": "The id this model is addressed by — a canonical `<org>/<model>` id when\nthe entry comes from the provider registry, or the upstream id for a\nhand-written config. This is the **match key** the auto-cascade compares\nthe requested model against.",
          "type": "string"
        },
        "input_token_counting": {
          "anyOf": [
            {
              "$ref": "#/$defs/InputTokenCounting"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Explicit support for a provider input-token counting endpoint. Managed\nrequests require a successful count when enabled; ordinary calls do not\ninvoke it. API wire compatibility alone does not enable counting."
        },
        "pricing": {
          "anyOf": [
            {
              "$ref": "#/$defs/PricingConfig"
            },
            {
              "type": "null"
            }
          ],
          "description": "Per-model pricing."
        },
        "pricing_by_protocol": {
          "additionalProperties": {
            "$ref": "#/$defs/PricingConfig"
          },
          "description": "Independent complete tariffs by outbound wire. Missing buckets never inherit\nordinary generation rates; Decisions requires its own tariff.",
          "type": "object"
        },
        "provider_model_id": {
          "default": null,
          "description": "The provider's own upstream model id — what is sent on the wire. When\n`None`, [`id`](Self::id) is used for both matching and dispatch (the\nhand-written-config case, where the two coincide). The registry merge\nsets this so a canonical [`id`](Self::id) routes to the provider's\nupstream name (e.g. `anthropic/claude-sonnet-4.6` → `claude-sonnet-4-6`).",
          "type": [
            "string",
            "null"
          ]
        },
        "rate_limits": {
          "anyOf": [
            {
              "$ref": "#/$defs/RateLimit"
            },
            {
              "type": "null"
            }
          ],
          "description": "Per-model rate-limit override."
        },
        "reasoning_effort": {
          "anyOf": [
            {
              "$ref": "#/$defs/ReasoningEffortConfig"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Positively verified qualitative effort levels for this exact route.\nAbsence means unknown, not unsupported."
        },
        "token_limits": {
          "$ref": "#/$defs/ModelTokenLimits",
          "default": {
            "context_window": null,
            "max_input_tokens": null,
            "max_output_tokens": null
          },
          "description": "Concrete route token limits. Missing fields remain unknown. In\nparticular, an input limit does not imply a combined context window."
        }
      },
      "required": [
        "id"
      ],
      "type": "object"
    },
    "RateLimit": {
      "description": "A rate limit for one `(provider, pattern)` bucket. Limits are keyed\nper-`(provider, matched pattern)` — two patterns with different RPMs get\nindependent windows.",
      "properties": {
        "requests_per_minute": {
          "default": null,
          "description": "Requests-per-minute ceiling for this bucket.",
          "format": "uint32",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "tokens_per_minute": {
          "default": null,
          "description": "Tokens-per-minute ceiling for this bucket.",
          "format": "uint32",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        }
      },
      "type": "object"
    },
    "ReasoningEffort": {
      "description": "Qualitative reasoning-effort levels understood by BitRouter's built-in\nOpenAI, Anthropic, and Gemini protocol adapters.\n\nThis is the cross-provider superset, not a claim that every model supports\nevery value. Exact provider/model routes advertise their supported subset\nseparately and policy-owned effort targets are validated against it before\ndispatch.",
      "oneOf": [
        {
          "const": "none",
          "description": "Disable reasoning where the selected model supports doing so.",
          "type": "string"
        },
        {
          "const": "minimal",
          "description": "Use the smallest non-zero reasoning setting exposed by the model.",
          "type": "string"
        },
        {
          "const": "low",
          "description": "Prefer low reasoning cost and latency.",
          "type": "string"
        },
        {
          "const": "medium",
          "description": "Balance reasoning depth with cost and latency.",
          "type": "string"
        },
        {
          "const": "high",
          "description": "Prefer deeper reasoning over cost and latency.",
          "type": "string"
        },
        {
          "const": "xhigh",
          "description": "Use the provider's extra-high reasoning setting.",
          "type": "string"
        },
        {
          "const": "max",
          "description": "Use the provider's maximum reasoning setting.",
          "type": "string"
        }
      ]
    },
    "ReasoningEffortConfig": {
      "additionalProperties": false,
      "description": "Exact qualitative reasoning-effort support for one provider/model route.\n\nAbsence means unknown rather than unsupported. Policy-owned effort targets\nrequire this positive declaration; ordinary caller-authored parameters keep\ntheir existing pass-through behavior when support is unknown.",
      "properties": {
        "default": {
          "anyOf": [
            {
              "$ref": "#/$defs/ReasoningEffort"
            },
            {
              "type": "null"
            }
          ],
          "description": "Provider default when the request omits an effort value."
        },
        "levels": {
          "description": "Effort values accepted by this exact provider/model route.",
          "items": {
            "$ref": "#/$defs/ReasoningEffort"
          },
          "type": "array"
        }
      },
      "required": [
        "levels"
      ],
      "type": "object"
    },
    "RegistryConfig": {
      "description": "Runtime public registry integration settings — the top-level `registry:`\nblock in `bitrouter.yaml`.",
      "properties": {
        "enabled": {
          "default": true,
          "description": "Whether to fetch the registry and merge its BYOK providers into the\nrouting table. Default `true`. Also gated by\n[`inherit_defaults`](Config::inherit_defaults) — either being false\ndisables the merge.",
          "type": "boolean"
        },
        "provider_priority": {
          "description": "Provider-class priority, highest first. A provider's auto-cascade rank\nis its class's index here; a per-provider [`ProviderConfig::priority`]\noverrides it, and a class absent from this list ranks last. Defaults to\n[`ProviderClass::default_priority`].",
          "items": {
            "$ref": "#/$defs/ProviderClass"
          },
          "type": "array"
        },
        "url": {
          "default": "https://raw.githubusercontent.com/bitrouter/bitrouter/main/dist/registry",
          "description": "Base URL of the registry `dist/` artifacts. Defaults to\n[`DEFAULT_REGISTRY_URL`]. Point it at a pinned `reg-<timestamp>` tag or\nan internal mirror for reproducible deployments.",
          "type": "string"
        }
      },
      "type": "object"
    },
    "RouterChecks": {
      "additionalProperties": false,
      "description": "Request checks attached to a named router.",
      "properties": {
        "request": {
          "default": [],
          "description": "Ordered compiled checks. Every checker must allow the request.",
          "items": {
            "$ref": "#/$defs/RouterRequestCheck"
          },
          "type": "array"
        }
      },
      "type": "object"
    },
    "RouterConfig": {
      "additionalProperties": false,
      "description": "One named router definition.",
      "properties": {
        "checks": {
          "$ref": "#/$defs/RouterChecks",
          "default": {
            "request": []
          },
          "description": "Fail-closed checks run before this router may contact an upstream."
        },
        "defaults": {
          "$ref": "#/$defs/RouterDefaults",
          "default": {
            "params": {},
            "system_prompt": null
          },
          "description": "Request values filled only when the caller omitted them."
        },
        "selection": {
          "$ref": "#/$defs/RouterSelection",
          "description": "The model or policy selection performed by this router."
        }
      },
      "required": [
        "selection"
      ],
      "type": "object"
    },
    "RouterDefaults": {
      "additionalProperties": false,
      "description": "Defaults supplied by a named router.",
      "properties": {
        "params": {
          "additionalProperties": true,
          "default": {},
          "description": "Generation parameters shallow-merged behind explicit request values.",
          "type": "object"
        },
        "system_prompt": {
          "default": null,
          "description": "System prompt used only when the request did not provide one.",
          "type": [
            "string",
            "null"
          ]
        }
      },
      "type": "object"
    },
    "RouterRequestCheck": {
      "additionalProperties": false,
      "description": "One router-to-checker binding.",
      "properties": {
        "checker": {
          "description": "Checker id under the top-level `checkers` map.",
          "type": "string"
        },
        "max_input_bytes": {
          "default": 262144,
          "description": "Maximum projected text bytes. Oversize input is rejected, never truncated.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        },
        "timeout_ms": {
          "default": 500,
          "description": "Total checker deadline, including queue admission and callback execution.",
          "format": "uint64",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "checker"
      ],
      "type": "object"
    },
    "RouterRoutingConfig": {
      "additionalProperties": false,
      "description": "Provider routing preferences accepted by a named router.",
      "properties": {
        "ignore": {
          "default": [],
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "only": {
          "default": [],
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "require_tags": {
          "default": [],
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "sort": {
          "anyOf": [
            {
              "$ref": "#/$defs/SortOrder"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        }
      },
      "type": "object"
    },
    "RouterSelection": {
      "description": "Model selection performed by a named router.",
      "oneOf": [
        {
          "additionalProperties": false,
          "description": "Resolve one existing model selector.",
          "properties": {
            "kind": {
              "const": "model",
              "type": "string"
            },
            "model": {
              "description": "Existing physical or virtual model selector.",
              "type": "string"
            },
            "routing": {
              "$ref": "#/$defs/RouterRoutingConfig",
              "default": {
                "ignore": [],
                "only": [],
                "require_tags": [],
                "sort": null
              },
              "description": "Provider preferences applied by the existing cascade resolver."
            }
          },
          "required": [
            "kind",
            "model"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "description": "Let one existing policy choose the effective model.",
          "properties": {
            "base_model": {
              "description": "Exact base-model input retained by the current policy runtime.",
              "type": "string"
            },
            "kind": {
              "const": "policy",
              "type": "string"
            },
            "policy": {
              "description": "Policy name in `policy-lock.yaml`.",
              "type": "string"
            },
            "routing": {
              "$ref": "#/$defs/RouterRoutingConfig",
              "default": {
                "ignore": [],
                "only": [],
                "require_tags": [],
                "sort": null
              },
              "description": "Provider preferences applied after the policy selects a model."
            }
          },
          "required": [
            "kind",
            "policy",
            "base_model"
          ],
          "type": "object"
        }
      ]
    },
    "RoutingConfig": {
      "description": "Routing knobs shared by presets and variants.",
      "properties": {
        "ignore": {
          "default": [],
          "description": "Drop these providers from the chain.",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "only": {
          "default": [],
          "description": "Restrict the chain to exactly these providers.",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "require_tags": {
          "default": [],
          "description": "Require providers carrying all these tags.",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "sort": {
          "anyOf": [
            {
              "$ref": "#/$defs/SortOrder"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Cascade-chain ordering."
        }
      },
      "type": "object"
    },
    "ServerConfig": {
      "description": "HTTP server settings.",
      "properties": {
        "control_socket": {
          "default": "./bitrouter.sock",
          "description": "Unix control socket path.",
          "type": "string"
        },
        "listen": {
          "default": "0.0.0.0:4356",
          "description": "`host:port` to listen on.",
          "type": "string"
        },
        "log_level": {
          "default": "info",
          "description": "Log filter for the daemon, in `tracing-subscriber` `EnvFilter` syntax —\na bare level (`debug`) or a per-target list (`info,bitrouter=debug`).\n\n`RUST_LOG` overrides this when set, following the Rust convention. The\nfilter is resolved once at startup, so changing it needs a restart —\n`bro reload` will not pick it up. Applies to `bro serve`\n(and therefore `start`); other subcommands install their subscriber\nbefore any config is read and honour `RUST_LOG` only.",
          "type": "string"
        },
        "require_known_pricing": {
          "default": false,
          "description": "Deny dispatch when any routed tariff cannot guarantee complete known-price\ncoverage. Decisions caching remains unverified and fails this admission.",
          "type": "boolean"
        },
        "skip_auth": {
          "default": false,
          "description": "SDK-level flag: when `true`, credential-less requests are admitted with\na synthesised local caller. Code default is **`false`** — only the\nconfig file produced by `bro init` writes `true`.",
          "type": "boolean"
        }
      },
      "type": "object"
    },
    "ServerToolsConfig": {
      "description": "The OSS `server_tools` config section. Names the MCP servers whose tools\nBitRouter attaches to LLM requests and executes inside the loop, with an\noptional override of the loop's iteration cap. An empty `mcp_servers`\nleaves the pipeline strictly single-shot.",
      "properties": {
        "advisor": {
          "default": false,
          "description": "Enable the `advisor` server tool (consult a stronger model mid-task).\nAdvertised per-request only when the caller declares `bitrouter:advisor`.",
          "type": "boolean"
        },
        "fusion": {
          "anyOf": [
            {
              "$ref": "#/$defs/FusionSettings"
            },
            {
              "type": "null"
            }
          ],
          "description": "Multi-model deliberation (Fusion). When set, the `bitrouter:fusion`\nserver tool and the `bitrouter/fusion` model alias are enabled."
        },
        "max_iterations": {
          "default": null,
          "description": "Optional override of the loop's maximum tool-execution rounds.",
          "format": "uint32",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "mcp_servers": {
          "default": [],
          "description": "MCP server names (keys of `mcp_servers`) whose tools are injected into\nLLM requests and executed by the loop.",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "subagent": {
          "default": false,
          "description": "Enable the `subagent` server tool (delegate a task to a worker model).\nAdvertised per-request only when the caller declares `bitrouter:subagent`.",
          "type": "boolean"
        },
        "web_fetch": {
          "anyOf": [
            {
              "$ref": "#/$defs/WebFetchSettings"
            },
            {
              "type": "null"
            }
          ],
          "description": "Built-in `web_fetch` server tool (BYOK). When set, the\n`bitrouter:web_fetch` tool is enabled, served by the configured fetch\nbackends. Advertised per-request only when the caller declares it."
        },
        "web_search": {
          "anyOf": [
            {
              "$ref": "#/$defs/WebSearchSettings"
            },
            {
              "type": "null"
            }
          ],
          "description": "Built-in `web_search` server tool (BYOK). When set, the\n`bitrouter:web_search` tool is enabled, served by the configured search\nbackends. Advertised per-request only when the caller declares it."
        }
      },
      "type": "object"
    },
    "SortOrder": {
      "description": "How a cascade chain should be ordered.",
      "oneOf": [
        {
          "const": "alphabetical",
          "description": "Sort by provider name, ascending. The Phase-1 default; later replaced by\na recommender (cost / latency / throughput scoring).",
          "type": "string"
        },
        {
          "const": "latency",
          "description": "Sort by lowest latency first.",
          "type": "string"
        },
        {
          "const": "cost",
          "description": "Sort by lowest cost first.",
          "type": "string"
        }
      ]
    },
    "TimeoutConfig": {
      "description": "Upstream HTTP timeout knobs, in seconds. Every field is optional; an unset\nfield inherits the level above — a provider override inherits the resolved\nglobal value, and an unset global inherits the built-in default\n([`HttpTimeouts::default`]). `total_secs` is opt-in at every level: unset ⇒\nno overall wall-clock cap (the right default for long agentic streams).\n\nUsed both as the top-level `upstream.timeouts` block and as the per-provider\n`providers.<id>.timeouts` override; timeouts are **not** inherited via a\nprovider's `derives:` chain.",
      "properties": {
        "connect_secs": {
          "default": null,
          "description": "TCP connect timeout, seconds.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "pool_idle_secs": {
          "default": null,
          "description": "Idle pooled-connection eviction, seconds.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "read_secs": {
          "default": null,
          "description": "Idle (per-read) timeout, seconds — fires when the upstream sends no\nbytes for this long, including mid-stream. The effective stream-idle\nguard.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "tcp_keepalive_secs": {
          "default": null,
          "description": "TCP keepalive probe interval, seconds.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        },
        "total_secs": {
          "default": null,
          "description": "Overall wall-clock cap for the entire request/stream, seconds. Opt-in:\nunset ⇒ no cap. Setting it bounds total stream duration, so keep it\ngenerous for reasoning / agentic providers.",
          "format": "uint64",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        }
      },
      "type": "object"
    },
    "TrajectoryConfig": {
      "description": "Durable trajectory progress-control settings.",
      "properties": {
        "enabled": {
          "default": false,
          "description": "Explicit opt-in for durable trajectory routing and settlement.",
          "type": "boolean"
        },
        "outbox_batch_size": {
          "default": 100,
          "description": "Maximum durable outbox rows attempted in one publication batch.",
          "format": "uint",
          "minimum": 0,
          "type": "integer"
        },
        "retention_days": {
          "default": 30,
          "description": "Age boundary used by startup retention, in whole days.",
          "format": "uint32",
          "minimum": 0,
          "type": "integer"
        }
      },
      "type": "object"
    },
    "UpstreamConfig": {
      "description": "Outbound / upstream HTTP settings — the client BitRouter uses to call\nproviders. Distinct from [`ServerConfig`], which is the inbound listen\nsocket. Currently just [`timeouts`](Self::timeouts); grouped under\n`upstream:` so future outbound knobs have a home.",
      "properties": {
        "fallback_backoff_ms": {
          "default": [],
          "description": "Optional delay schedule before advancing through a retryable fallback\nchain, in milliseconds. The first value applies before the second\ncandidate, the second before the third, and the last value repeats when\nthe chain is longer than the schedule. Empty (the default) preserves\nimmediate fallback.",
          "items": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "type": "array"
        },
        "timeouts": {
          "$ref": "#/$defs/TimeoutConfig",
          "description": "Global upstream timeout defaults. A provider may override any field\nunder `providers.<id>.timeouts:`."
        }
      },
      "type": "object"
    },
    "VariantConfig": {
      "description": "A `:variant` definition — a routing modifier only.",
      "properties": {
        "routing": {
          "$ref": "#/$defs/RoutingConfig",
          "default": {
            "ignore": [],
            "only": [],
            "require_tags": [],
            "sort": null
          },
          "description": "Routing knobs fed into the cascade."
        }
      },
      "type": "object"
    },
    "VirtualEndpoint": {
      "description": "One endpoint of a virtual model.",
      "properties": {
        "provider": {
          "description": "The provider id this endpoint routes to.",
          "type": "string"
        },
        "service_id": {
          "description": "The service / model id at that provider.",
          "type": "string"
        }
      },
      "required": [
        "provider",
        "service_id"
      ],
      "type": "object"
    },
    "VirtualModel": {
      "description": "An explicit virtual-model definition (Strategy 2).",
      "properties": {
        "endpoints": {
          "description": "The endpoints this virtual model maps to. Their meaning depends on\n[`strategy`](Self::strategy): under `priority` they are an *ordered*\npreference list; under `cascade` the order is a starting point that\nthe cascade ordering then re-sorts.",
          "items": {
            "$ref": "#/$defs/VirtualEndpoint"
          },
          "type": "array"
        },
        "pricing": {
          "anyOf": [
            {
              "$ref": "#/$defs/PricingConfig"
            },
            {
              "type": "null"
            }
          ],
          "description": "Optional pricing for the virtual model."
        },
        "strategy": {
          "$ref": "#/$defs/VirtualModelStrategy",
          "description": "How this virtual model's [`endpoints`](Self::endpoints) are ordered\ninto the fallback chain. See [`VirtualModelStrategy`]. Defaults to\n[`Priority`](VirtualModelStrategy::Priority)."
        }
      },
      "required": [
        "endpoints"
      ],
      "type": "object"
    },
    "VirtualModelStrategy": {
      "description": "How a [`VirtualModel`]'s endpoints are ordered into its fallback chain\n(Strategy 2). Mirrors the typed-enum + serde pattern of\n[`AccountStrategy`].\n\nBoth strategies build a chain that `execute_with_fallback` walks: a\nretryable failure (5xx / 408 / 429 / timeout / credit-exhaustion) always\nadvances to the next endpoint — that failover-on-error behaviour is a\nproperty of *any* chain and is shared by both. They differ only in the\n**order** the endpoints take in that chain.",
      "oneOf": [
        {
          "const": "priority",
          "description": "Endpoints are tried in **declared YAML order** — the first is the\npreferred endpoint, the rest are failover targets reached only when a\npreceding one fails with a retryable error. Routing preferences\n(`sort` / `only` / `ignore`) do **not** reorder or filter the chain:\nthe operator's declared priority is authoritative. This is the\ndefault and matches the historical (pre-typed-`strategy`) behaviour.",
          "type": "string"
        },
        {
          "const": "cascade",
          "description": "Endpoints are treated as an unordered candidate set and **re-ordered by\nthe request's [`SortOrder`]** (the same cascade ordering Strategy-3\nauto-cascade applies to providers), and filtered by `only` / `ignore` /\n`require_tags`.\nUse this when the endpoints are interchangeable and you want\ncost/latency-aware (or, today, alphabetical) selection rather than a\nfixed priority order. `Latency` / `Cost` have no metrics source yet, so\nthey currently fall back to alphabetical-by-provider — the same honest\nlimitation Strategy-3 documents.",
          "type": "string"
        }
      ]
    },
    "WebFetchBackendConfig": {
      "description": "One configured extraction backend. The `kind` tag selects the engine; the\nBYOK key resolves from `api_key` (supports `${VAR}` substitution) or, when\nomitted, the engine's conventional environment variable.",
      "oneOf": [
        {
          "description": "exa.ai `/contents` — key `api_key` or `EXA_API_KEY`.",
          "properties": {
            "api_base": {
              "default": null,
              "description": "Endpoint override (else the engine default).",
              "type": [
                "string",
                "null"
              ]
            },
            "api_key": {
              "default": null,
              "description": "Explicit API key (else `EXA_API_KEY`).",
              "type": [
                "string",
                "null"
              ]
            },
            "kind": {
              "const": "exa",
              "type": "string"
            }
          },
          "required": [
            "kind"
          ],
          "type": "object"
        },
        {
          "description": "firecrawl.dev `/v2/scrape` — key `api_key` or `FIRECRAWL_API_KEY`.",
          "properties": {
            "api_base": {
              "default": null,
              "description": "Endpoint override (else the engine default).",
              "type": [
                "string",
                "null"
              ]
            },
            "api_key": {
              "default": null,
              "description": "Explicit API key (else `FIRECRAWL_API_KEY`).",
              "type": [
                "string",
                "null"
              ]
            },
            "kind": {
              "const": "firecrawl",
              "type": "string"
            }
          },
          "required": [
            "kind"
          ],
          "type": "object"
        },
        {
          "description": "tavily.com `/extract` — key `api_key` or `TAVILY_API_KEY`.",
          "properties": {
            "api_base": {
              "default": null,
              "description": "Endpoint override (else the engine default).",
              "type": [
                "string",
                "null"
              ]
            },
            "api_key": {
              "default": null,
              "description": "Explicit API key (else `TAVILY_API_KEY`).",
              "type": [
                "string",
                "null"
              ]
            },
            "kind": {
              "const": "tavily",
              "type": "string"
            }
          },
          "required": [
            "kind"
          ],
          "type": "object"
        }
      ]
    },
    "WebFetchSettings": {
      "description": "The `server_tools.web_fetch` section. Its presence enables the\n`bitrouter:web_fetch` server tool (advertised only when a request declares\nit). An empty `backends` list leaves the tool effectively off.",
      "properties": {
        "backends": {
          "description": "Extraction backends in preference/failover order; the first that resolves\na key is the default.",
          "items": {
            "$ref": "#/$defs/WebFetchBackendConfig"
          },
          "type": "array"
        },
        "max_content_tokens": {
          "default": null,
          "description": "Default cap on returned content per fetch, in tokens (caller may lower\nit). Defaults to [`DEFAULT_MAX_CONTENT_TOKENS`].",
          "format": "uint32",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        }
      },
      "type": "object"
    },
    "WebSearchBackendConfig": {
      "description": "One configured search backend. The `kind` tag selects the engine; the BYOK\nkey resolves from `api_key` (supports `${VAR}` substitution) or, when\nomitted, the engine's conventional environment variable.",
      "oneOf": [
        {
          "description": "parallel.ai — key `api_key` or `PARALLEL_API_KEY`.",
          "properties": {
            "api_base": {
              "default": null,
              "description": "Endpoint override (else the engine default).",
              "type": [
                "string",
                "null"
              ]
            },
            "api_key": {
              "default": null,
              "description": "Explicit API key (else `PARALLEL_API_KEY`).",
              "type": [
                "string",
                "null"
              ]
            },
            "kind": {
              "const": "parallel",
              "type": "string"
            }
          },
          "required": [
            "kind"
          ],
          "type": "object"
        },
        {
          "description": "exa.ai — key `api_key` or `EXA_API_KEY`.",
          "properties": {
            "api_base": {
              "default": null,
              "description": "Endpoint override (else the engine default).",
              "type": [
                "string",
                "null"
              ]
            },
            "api_key": {
              "default": null,
              "description": "Explicit API key (else `EXA_API_KEY`).",
              "type": [
                "string",
                "null"
              ]
            },
            "kind": {
              "const": "exa",
              "type": "string"
            }
          },
          "required": [
            "kind"
          ],
          "type": "object"
        },
        {
          "description": "firecrawl.dev — key `api_key` or `FIRECRAWL_API_KEY`.",
          "properties": {
            "api_base": {
              "default": null,
              "description": "Endpoint override (else the engine default).",
              "type": [
                "string",
                "null"
              ]
            },
            "api_key": {
              "default": null,
              "description": "Explicit API key (else `FIRECRAWL_API_KEY`).",
              "type": [
                "string",
                "null"
              ]
            },
            "kind": {
              "const": "firecrawl",
              "type": "string"
            }
          },
          "required": [
            "kind"
          ],
          "type": "object"
        },
        {
          "description": "tavily.com — key `api_key` or `TAVILY_API_KEY`.",
          "properties": {
            "api_base": {
              "default": null,
              "description": "Endpoint override (else the engine default).",
              "type": [
                "string",
                "null"
              ]
            },
            "api_key": {
              "default": null,
              "description": "Explicit API key (else `TAVILY_API_KEY`).",
              "type": [
                "string",
                "null"
              ]
            },
            "kind": {
              "const": "tavily",
              "type": "string"
            }
          },
          "required": [
            "kind"
          ],
          "type": "object"
        },
        {
          "description": "A web-search-capable model whose *native* search tool is forwarded, made\navailable to every model routed through BitRouter.",
          "properties": {
            "kind": {
              "const": "native",
              "type": "string"
            },
            "model": {
              "description": "The search-capable model serving the call.",
              "type": "string"
            },
            "name": {
              "default": null,
              "description": "Backend id the caller pins (e.g. `\"native\"`); defaults to `\"native\"`.",
              "type": [
                "string",
                "null"
              ]
            },
            "tool": {
              "description": "The provider-defined native search tool, e.g.\n`{ \"type\": \"anthropic:web_search_20250305\" }`."
            }
          },
          "required": [
            "kind",
            "model",
            "tool"
          ],
          "type": "object"
        }
      ]
    },
    "WebSearchSettings": {
      "description": "The `server_tools.web_search` section. Its presence enables the\n`bitrouter:web_search` server tool (advertised only when a request declares\nit). An empty `backends` list leaves the tool effectively off.",
      "properties": {
        "backends": {
          "description": "Search backends in preference/failover order; the first that resolves a\nkey is the default.",
          "items": {
            "$ref": "#/$defs/WebSearchBackendConfig"
          },
          "type": "array"
        },
        "max_results": {
          "default": null,
          "description": "Default maximum results per call (caller may lower it). Defaults to\n[`DEFAULT_MAX_RESULTS`].",
          "format": "uint32",
          "minimum": 0,
          "type": [
            "integer",
            "null"
          ]
        }
      },
      "type": "object"
    }
  },
  "$id": "https://bitrouter.dev/schema/v1.0.0-alpha.33/config.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "The top-level configuration.",
  "properties": {
    "acp_recording": {
      "$ref": "#/$defs/AcpRecordingConfig",
      "default": {
        "enabled": false
      },
      "description": "Opt-in local storage of observable ACP conversation content."
    },
    "agent_api": {
      "$ref": "#/$defs/AgentApiConfig",
      "description": "Opt-in privileged BRO coding task API, separate from inference and control."
    },
    "agents": {
      "additionalProperties": {
        "$ref": "#/$defs/AcpAgentConfig"
      },
      "default": {},
      "description": "Upstream ACP agents, keyed by agent id. Surfaced by the\n`bro agents` CLI (list / check / install). Empty by default.",
      "type": "object"
    },
    "chat": {
      "$ref": "#/$defs/ChatConfig",
      "description": "The interactive session's own configuration."
    },
    "checkers": {
      "additionalProperties": {
        "$ref": "#/$defs/CheckerConfig"
      },
      "default": {},
      "description": "Compiled request-check extensions, keyed by the ids referenced from named routers.",
      "type": "object"
    },
    "continuation": {
      "$ref": "#/$defs/ContinuationConfig",
      "default": {
        "prune_batch_size": 1000,
        "retention_days": 30
      },
      "description": "Durable provider continuation mapping lifecycle."
    },
    "control": {
      "$ref": "#/$defs/ControlConfig",
      "description": "Opt-in, read-only operator control API settings."
    },
    "database": {
      "$ref": "#/$defs/DatabaseConfig",
      "description": "Database connection settings."
    },
    "decision_model": {
      "anyOf": [
        {
          "$ref": "#/$defs/DecisionModelConfig"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Typed decision backend for native context routing. Absent means the\nconservative compiler runs without remote semantic judgments."
    },
    "eval": {
      "$ref": "#/$defs/EvalConfig",
      "default": {
        "authorities": {}
      },
      "description": "Generic evaluation exchange authorities and admission scopes."
    },
    "inherit_defaults": {
      "default": true,
      "description": "Whether providers inherit workspace defaults.",
      "type": "boolean"
    },
    "mcp": {
      "$ref": "#/$defs/McpConfig",
      "description": "Top-level MCP gateway settings (aggregation, caching). All fields\ndefault — `mcp:` is optional in `bitrouter.yaml`."
    },
    "mcp_servers": {
      "additionalProperties": {
        "$ref": "#/$defs/McpServerConfig"
      },
      "default": {},
      "description": "Upstream MCP servers, keyed by server id. The id is what appears in\n`POST /mcp/{id}` and what the `mcp` pipeline's routing table looks up.\nEmpty by default — when empty, the binary does not mount the MCP route.",
      "type": "object"
    },
    "models": {
      "additionalProperties": {
        "$ref": "#/$defs/VirtualModel"
      },
      "description": "Explicit virtual-model definitions (Strategy 2.2). Optional —\nwhen absent, bare model names fall through to Strategy 3 auto-cascade.",
      "type": "object"
    },
    "plugins": {
      "additionalProperties": true,
      "default": {},
      "description": "Plugin config, keyed by plugin / bundle id.",
      "type": "object"
    },
    "policy": {
      "$ref": "#/$defs/PolicyConfig",
      "default": {
        "mode": "frozen",
        "path": null
      },
      "description": "Adaptive model-policy settings. A file-backed config resolves the\noptional path relative to its own directory; when omitted the app looks\nfor `policy-lock.yaml` next to `bitrouter.yaml`. The SDK only carries\nthis declaration -- loading and evolving policy locks belongs to the\nBitRouter app layer."
    },
    "presets": {
      "additionalProperties": {
        "$ref": "#/$defs/PresetConfig"
      },
      "description": "`@preset` definitions.",
      "type": "object"
    },
    "providers": {
      "additionalProperties": {
        "$ref": "#/$defs/ProviderConfig"
      },
      "description": "Upstream providers, keyed by provider id.",
      "type": "object"
    },
    "registry": {
      "$ref": "#/$defs/RegistryConfig",
      "description": "Public registry integration: whether to fetch + merge the registry's\nBYOK providers, where to fetch it from, and the provider-class priority\nladder used to order the auto-cascade."
    },
    "routers": {
      "additionalProperties": {
        "$ref": "#/$defs/RouterConfig"
      },
      "default": {},
      "description": "Named request routers, addressed as `bitrouter/<id>`.",
      "type": "object"
    },
    "server": {
      "$ref": "#/$defs/ServerConfig",
      "description": "HTTP server settings."
    },
    "server_tools": {
      "$ref": "#/$defs/ServerToolsConfig",
      "description": "Server-side tool loop: MCP server ids whose tools BitRouter injects into\nLLM requests and executes itself. Empty by default — the pipeline stays\nsingle-shot."
    },
    "trajectory": {
      "$ref": "#/$defs/TrajectoryConfig",
      "default": {
        "enabled": false,
        "outbox_batch_size": 100,
        "retention_days": 30
      },
      "description": "Durable trajectory progress-control and local operations settings."
    },
    "upstream": {
      "$ref": "#/$defs/UpstreamConfig",
      "description": "Outbound / upstream HTTP settings (the client that calls providers)."
    },
    "variants": {
      "additionalProperties": {
        "$ref": "#/$defs/VariantConfig"
      },
      "description": "`:variant` definitions.",
      "type": "object"
    }
  },
  "title": "BitRouter config",
  "type": "object"
}
