{
  "components": {
    "schemas": {
      "APIKey": {
        "properties": {
          "allowed_combos": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "allowed_models": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "allowed_prefixes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "expires_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "exposure_mode": {
            "$ref": "#/components/schemas/ExposureMode"
          },
          "id": {
            "description": "Key UUID",
            "type": "string"
          },
          "last_used_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "memory_enabled": {
            "description": "Whether memory recall \u0026 extraction are enabled for this key",
            "type": "boolean"
          },
          "name": {
            "description": "Key label",
            "type": "string"
          },
          "prefix": {
            "description": "Lookup prefix (mr_live_...)",
            "type": "string"
          },
          "revoked_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "rpm_limit": {
            "description": "Per-key RPM limit",
            "type": "integer"
          },
          "token_quota": {
            "description": "Total token quota (0 = unlimited)",
            "type": "integer"
          },
          "tokens_used": {
            "description": "Tokens consumed",
            "type": "integer"
          },
          "tpm_limit": {
            "description": "Per-key TPM limit",
            "type": "integer"
          },
          "user_id": {
            "description": "Owning user ID",
            "type": "string"
          }
        },
        "required": [
          "id",
          "user_id",
          "name",
          "prefix",
          "exposure_mode",
          "created_at"
        ],
        "type": "object"
      },
      "APIKeyCreateResponse": {
        "properties": {
          "key": {
            "$ref": "#/components/schemas/APIKey"
          },
          "raw_key": {
            "description": "One-time raw virtual API key (mr_live_...)",
            "type": "string"
          }
        },
        "required": [
          "raw_key",
          "key"
        ],
        "type": "object"
      },
      "APIKeyEnvelope": {
        "properties": {
          "key": {
            "$ref": "#/components/schemas/APIKey"
          }
        },
        "required": [
          "key"
        ],
        "type": "object"
      },
      "APIKeyListResponse": {
        "properties": {
          "keys": {
            "items": {
              "$ref": "#/components/schemas/APIKey"
            },
            "type": "array"
          }
        },
        "required": [
          "keys"
        ],
        "type": "object"
      },
      "AdminCLIAutoSetupResponse": {
        "properties": {
          "accounts_created": {
            "description": "Count of accounts created",
            "type": "integer"
          },
          "accounts_updated": {
            "description": "Count of accounts updated",
            "type": "integer"
          },
          "global_cli_enabled": {
            "description": "Effective global CLI state after auto-setup",
            "type": "boolean"
          },
          "models_synced": {
            "description": "Total models synced",
            "type": "integer"
          },
          "providers_created": {
            "description": "Count of providers created",
            "type": "integer"
          },
          "providers_updated": {
            "description": "Count of providers updated",
            "type": "integer"
          },
          "results": {
            "items": {
              "$ref": "#/components/schemas/AutoSetupCLIProviderResult"
            },
            "type": "array"
          }
        },
        "required": [
          "global_cli_enabled",
          "providers_created",
          "providers_updated",
          "accounts_created",
          "accounts_updated",
          "models_synced",
          "results"
        ],
        "type": "object"
      },
      "AdminCLIConfig": {
        "properties": {
          "cli_enabled": {
            "description": "Effective global official CLI execution state",
            "type": "boolean"
          },
          "config_cli_enabled": {
            "description": "Startup value configured via MINIROUTE_CLI_ENABLED or YAML",
            "type": "boolean"
          },
          "default_timeout_seconds": {
            "description": "Default CLI subprocess timeout in seconds",
            "type": "integer"
          },
          "global_max_concurrent": {
            "description": "Global CLI concurrency semaphore cap",
            "type": "integer"
          },
          "source": {
            "description": "Configuration source (db | config)",
            "type": "string"
          }
        },
        "required": [
          "cli_enabled",
          "source",
          "config_cli_enabled",
          "global_max_concurrent",
          "default_timeout_seconds"
        ],
        "type": "object"
      },
      "AdminCLIDetectResponse": {
        "properties": {
          "cli_enabled": {
            "description": "Current global CLI execution state",
            "type": "boolean"
          },
          "profile_roots": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "providers": {
            "items": {
              "$ref": "#/components/schemas/DetectedCLIProvider"
            },
            "type": "array"
          }
        },
        "required": [
          "profile_roots",
          "cli_enabled",
          "providers"
        ],
        "type": "object"
      },
      "AdminImportSkillsResponse": {
        "properties": {
          "imported": {
            "description": "Number of imported skills",
            "type": "integer"
          },
          "installations": {
            "items": {
              "$ref": "#/components/schemas/SkillInstallation"
            },
            "type": "array"
          },
          "skills": {
            "items": {
              "$ref": "#/components/schemas/Skill"
            },
            "type": "array"
          }
        },
        "required": [
          "imported",
          "skills"
        ],
        "type": "object"
      },
      "AdminInstallSkillRequest": {
        "properties": {
          "always_on": {
            "description": "Always inject full skill instructions",
            "type": "boolean"
          },
          "is_enabled": {
            "description": "Enabled flag",
            "type": "boolean"
          },
          "scope_type": {
            "enum": [
              "global"
            ],
            "type": "string"
          },
          "skill_id": {
            "description": "Global skill UUID to install gateway-wide",
            "type": "string"
          }
        },
        "required": [
          "skill_id"
        ],
        "type": "object"
      },
      "AdminMemoryConfig": {
        "properties": {
          "config_extractor_model": {
            "description": "Default extractor_model configured in YAML/env",
            "type": "string"
          },
          "extractor_model": {
            "description": "Effective dedicated model or combo ID for async memory extraction",
            "type": "string"
          },
          "source": {
            "description": "Configuration source (db | config | unset)",
            "type": "string"
          }
        },
        "required": [
          "extractor_model",
          "source"
        ],
        "type": "object"
      },
      "AdminPatchUserRequest": {
        "properties": {
          "email": {
            "description": "Updated email",
            "type": "string"
          },
          "external_id": {
            "description": "Updated external ID",
            "type": [
              "string",
              "null"
            ]
          },
          "is_active": {
            "description": "Active flag",
            "type": "boolean"
          },
          "name": {
            "description": "Updated display name",
            "type": "string"
          },
          "password": {
            "description": "Updated password",
            "type": "string"
          },
          "plan_id": {
            "description": "Updated plan ID",
            "type": [
              "string",
              "null"
            ]
          },
          "role": {
            "$ref": "#/components/schemas/Role"
          }
        },
        "type": "object"
      },
      "AdminRuntimeInfo": {
        "properties": {
          "database_path": {
            "description": "SQLite database path",
            "type": "string"
          },
          "log_format": {
            "description": "Configured log format (json | text)",
            "type": "string"
          },
          "master_key_configured": {
            "description": "Whether MINIROUTE_MASTER_KEY is configured",
            "type": "boolean"
          },
          "server_addr": {
            "description": "Bound server host:port",
            "type": "string"
          },
          "trusted_proxies": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "server_addr",
          "database_path",
          "log_format",
          "master_key_configured",
          "trusted_proxies"
        ],
        "type": "object"
      },
      "AdminSkillInstallationsResponse": {
        "properties": {
          "installations": {
            "items": {
              "$ref": "#/components/schemas/SkillInstallation"
            },
            "type": "array"
          }
        },
        "required": [
          "installations"
        ],
        "type": "object"
      },
      "AdminSystemSettings": {
        "properties": {
          "allow_private_provider_urls": {
            "description": "Effective flag permitting loopback/private HTTP provider URLs",
            "type": "boolean"
          },
          "allow_private_provider_urls_source": {
            "description": "Source of allow_private_provider_urls (db | config)",
            "type": "string"
          },
          "cli_binaries": {
            "items": {
              "$ref": "#/components/schemas/CLIBinaryStatus"
            },
            "type": "array"
          },
          "cli_default_timeout_seconds": {
            "description": "Default CLI subprocess timeout in seconds",
            "type": "integer"
          },
          "cli_enabled": {
            "description": "Effective global official CLI execution state",
            "type": "boolean"
          },
          "cli_enabled_source": {
            "description": "Source of cli_enabled (db | config)",
            "type": "string"
          },
          "cli_max_concurrent": {
            "description": "Global CLI concurrency semaphore cap",
            "type": "integer"
          },
          "cli_profile_roots": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "config_allow_private_provider_urls": {
            "description": "Startup value from MINIROUTE_PROVIDERS_ALLOW_PRIVATE_URLS or YAML",
            "type": "boolean"
          },
          "config_cli_enabled": {
            "description": "Startup value from MINIROUTE_CLI_ENABLED or YAML",
            "type": "boolean"
          },
          "config_log_level": {
            "description": "Startup log level from MINIROUTE_LOG_LEVEL or YAML",
            "type": "string"
          },
          "config_memory_extractor_model": {
            "description": "Startup value from MINIROUTE_MEMORY_EXTRACTOR_MODEL or YAML",
            "type": "string"
          },
          "log_level": {
            "enum": [
              "debug",
              "info",
              "warn",
              "error"
            ],
            "type": "string"
          },
          "log_level_source": {
            "description": "Source of log_level (db | config)",
            "type": "string"
          },
          "memory_extractor_model": {
            "description": "Effective dedicated model or combo ID for async memory extraction",
            "type": "string"
          },
          "memory_extractor_model_source": {
            "description": "Source of memory_extractor_model (db | config | unset)",
            "type": "string"
          },
          "memory_extractor_timeout_seconds": {
            "description": "Async memory extraction job timeout in seconds",
            "type": "integer"
          },
          "runtime": {
            "$ref": "#/components/schemas/AdminRuntimeInfo"
          }
        },
        "required": [
          "cli_enabled",
          "cli_enabled_source",
          "config_cli_enabled",
          "cli_max_concurrent",
          "cli_default_timeout_seconds",
          "cli_profile_roots",
          "allow_private_provider_urls",
          "allow_private_provider_urls_source",
          "config_allow_private_provider_urls",
          "memory_extractor_model",
          "memory_extractor_model_source",
          "config_memory_extractor_model",
          "memory_extractor_timeout_seconds",
          "log_level",
          "log_level_source",
          "config_log_level",
          "cli_binaries",
          "runtime"
        ],
        "type": "object"
      },
      "AdminUserSyncRequest": {
        "properties": {
          "email": {
            "description": "User email",
            "type": "string"
          },
          "external_id": {
            "description": "External platform user ID (e.g., Laravel user ID)",
            "type": [
              "string",
              "null"
            ]
          },
          "is_active": {
            "description": "Account active status",
            "type": "boolean"
          },
          "name": {
            "description": "Display name",
            "type": "string"
          },
          "password": {
            "description": "Optional password",
            "type": "string"
          },
          "plan_id": {
            "description": "Assigned plan UUID",
            "type": [
              "string",
              "null"
            ]
          },
          "role": {
            "$ref": "#/components/schemas/Role"
          }
        },
        "required": [
          "email"
        ],
        "type": "object"
      },
      "AdminUserSyncResponse": {
        "properties": {
          "synced": {
            "description": "True when an existing user matched external_id and was updated",
            "type": "boolean"
          },
          "user": {
            "$ref": "#/components/schemas/User"
          }
        },
        "required": [
          "user"
        ],
        "type": "object"
      },
      "AnthropicMessage": {
        "properties": {
          "content": {
            "description": "String or array of Anthropic text/tool_use/tool_result blocks"
          },
          "role": {
            "enum": [
              "user",
              "assistant"
            ],
            "type": "string"
          }
        },
        "required": [
          "role",
          "content"
        ],
        "type": "object"
      },
      "AnthropicMessageRequest": {
        "properties": {
          "compression_level": {
            "$ref": "#/components/schemas/CompressionLevel"
          },
          "max_tokens": {
            "description": "Maximum output tokens",
            "type": "integer"
          },
          "messages": {
            "items": {
              "$ref": "#/components/schemas/AnthropicMessage"
            },
            "type": "array"
          },
          "model": {
            "description": "Model ID (with api_prefix) or combo name",
            "type": "string"
          },
          "session_id": {
            "description": "Optional session ID",
            "type": "string"
          },
          "skills": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "stream": {
            "description": "Stream Anthropic SSE events",
            "type": "boolean"
          },
          "system": {
            "description": "System prompt string or text block array"
          },
          "temperature": {
            "description": "Sampling temperature",
            "type": "number"
          },
          "tools": {
            "items": {
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "model",
          "messages"
        ],
        "type": "object"
      },
      "AnthropicMessageResponse": {
        "properties": {
          "content": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "id": {
            "description": "Message ID",
            "type": "string"
          },
          "model": {
            "description": "Requested model",
            "type": "string"
          },
          "role": {
            "description": "assistant",
            "type": "string"
          },
          "stop_reason": {
            "description": "end_turn | max_tokens | tool_use",
            "type": "string"
          },
          "stop_sequence": {
            "description": "Stop sequence if triggered",
            "type": [
              "string",
              "null"
            ]
          },
          "type": {
            "description": "message",
            "type": "string"
          },
          "usage": {
            "$ref": "#/components/schemas/AnthropicUsage"
          }
        },
        "required": [
          "id",
          "type",
          "role",
          "model",
          "content",
          "stop_reason",
          "usage"
        ],
        "type": "object"
      },
      "AnthropicUsage": {
        "properties": {
          "input_tokens": {
            "description": "Input tokens",
            "type": "integer"
          },
          "output_tokens": {
            "description": "Output tokens",
            "type": "integer"
          }
        },
        "required": [
          "input_tokens",
          "output_tokens"
        ],
        "type": "object"
      },
      "AuthResponse": {
        "properties": {
          "access_token": {
            "description": "JWT access token",
            "type": "string"
          },
          "expires_at": {
            "format": "date-time",
            "type": "string"
          },
          "refresh_token": {
            "description": "Rotating refresh token",
            "type": "string"
          },
          "token_type": {
            "description": "Bearer",
            "type": "string"
          },
          "user": {
            "$ref": "#/components/schemas/User"
          }
        },
        "required": [
          "user",
          "access_token",
          "refresh_token",
          "token_type",
          "expires_at"
        ],
        "type": "object"
      },
      "AutoSetupCLIProviderResult": {
        "properties": {
          "accounts_created": {
            "description": "Number of accounts added",
            "type": "integer"
          },
          "accounts_updated": {
            "description": "Number of accounts updated",
            "type": "integer"
          },
          "action": {
            "enum": [
              "created",
              "updated"
            ],
            "type": "string"
          },
          "api_prefix": {
            "description": "Provider api_prefix",
            "type": "string"
          },
          "models_synced": {
            "description": "Number of models synced",
            "type": "integer"
          },
          "protocol": {
            "description": "CLI protocol",
            "type": "string"
          },
          "provider_id": {
            "description": "Provider UUID",
            "type": "string"
          },
          "provider_name": {
            "description": "Provider name",
            "type": "string"
          },
          "resolved_binary": {
            "description": "Saved binary path",
            "type": "string"
          },
          "sync_error": {
            "description": "Non-fatal sync warning if discovery failed",
            "type": "string"
          }
        },
        "required": [
          "protocol",
          "provider_id",
          "provider_name",
          "api_prefix",
          "resolved_binary",
          "action"
        ],
        "type": "object"
      },
      "AutoSetupCLIRequest": {
        "properties": {
          "enable_global_cli": {
            "description": "Enable global CLI execution (default true)",
            "type": "boolean"
          },
          "protocols": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "sync_models": {
            "description": "Sync models for created/updated providers (default true)",
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "CLIBinaryStatus": {
        "properties": {
          "binary": {
            "description": "Default CLI binary name",
            "type": "string"
          },
          "found": {
            "description": "Whether the binary was found in PATH",
            "type": "boolean"
          },
          "path": {
            "description": "Resolved binary path if found",
            "type": "string"
          },
          "protocol": {
            "description": "CLI protocol identifier",
            "type": "string"
          }
        },
        "required": [
          "protocol",
          "binary",
          "found"
        ],
        "type": "object"
      },
      "CLIVerifyResult": {
        "properties": {
          "cli_home": {
            "description": "CLI HOME tested",
            "type": "string"
          },
          "error": {
            "description": "Error detail if unhealthy",
            "type": "string"
          },
          "healthy": {
            "description": "Whether live verification succeeded",
            "type": "boolean"
          },
          "latency_ms": {
            "description": "Probe duration in ms",
            "type": "integer"
          },
          "message": {
            "description": "Diagnostic summary",
            "type": "string"
          },
          "models_count": {
            "description": "Model count returned (for agy)",
            "type": "integer"
          },
          "protocol": {
            "description": "CLI protocol",
            "type": "string"
          },
          "resolved_binary": {
            "description": "Resolved binary path",
            "type": "string"
          }
        },
        "required": [
          "healthy",
          "protocol",
          "resolved_binary",
          "cli_home",
          "latency_ms"
        ],
        "type": "object"
      },
      "Combo": {
        "properties": {
          "cooldown_seconds": {
            "description": "429/failure cooldown duration",
            "type": "integer"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "description": "Combo UUID",
            "type": "string"
          },
          "is_enabled": {
            "description": "Combo enabled flag",
            "type": "boolean"
          },
          "max_retries": {
            "description": "Fallback retries across targets",
            "type": "integer"
          },
          "memory_enabled": {
            "description": "Whether memory recall \u0026 extraction are enabled for this combo",
            "type": "boolean"
          },
          "name": {
            "description": "Exposed combo model name",
            "type": "string"
          },
          "strategy": {
            "$ref": "#/components/schemas/RoutingStrategy"
          },
          "targets": {
            "items": {
              "$ref": "#/components/schemas/ComboTarget"
            },
            "type": "array"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "strategy",
          "cooldown_seconds",
          "max_retries",
          "is_enabled",
          "targets"
        ],
        "type": "object"
      },
      "ComboEnvelope": {
        "properties": {
          "combo": {
            "$ref": "#/components/schemas/Combo"
          }
        },
        "required": [
          "combo"
        ],
        "type": "object"
      },
      "ComboListResponse": {
        "properties": {
          "combos": {
            "items": {
              "$ref": "#/components/schemas/Combo"
            },
            "type": "array"
          }
        },
        "required": [
          "combos"
        ],
        "type": "object"
      },
      "ComboTarget": {
        "properties": {
          "account_ids": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "combo_id": {
            "description": "Owning combo UUID",
            "type": "string"
          },
          "id": {
            "description": "Target UUID",
            "type": "string"
          },
          "is_enabled": {
            "description": "Target enabled flag",
            "type": "boolean"
          },
          "priority": {
            "description": "Priority order",
            "type": "integer"
          },
          "provider_id": {
            "description": "Target provider UUID",
            "type": "string"
          },
          "upstream_model": {
            "description": "Upstream model ID",
            "type": "string"
          },
          "weight": {
            "description": "Traffic weight",
            "type": "integer"
          }
        },
        "required": [
          "id",
          "combo_id",
          "provider_id",
          "upstream_model",
          "priority",
          "weight",
          "is_enabled"
        ],
        "type": "object"
      },
      "ComboTargetInput": {
        "properties": {
          "account_ids": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "is_enabled": {
            "description": "Target enabled flag",
            "type": "boolean"
          },
          "priority": {
            "description": "Fallback priority (lower is higher priority)",
            "type": "integer"
          },
          "provider_id": {
            "description": "Target provider UUID",
            "type": "string"
          },
          "upstream_model": {
            "description": "Upstream model ID on that provider",
            "type": "string"
          },
          "weight": {
            "description": "Weighted distribution weight (\u003e= 1)",
            "type": "integer"
          }
        },
        "required": [
          "provider_id",
          "upstream_model"
        ],
        "type": "object"
      },
      "CompressionLevel": {
        "enum": [
          "conservative",
          "balanced",
          "aggressive"
        ],
        "type": "string"
      },
      "CompressionPreset": {
        "properties": {
          "caveman_output": {
            "description": "Append terse output directive",
            "type": "boolean"
          },
          "ccr_min_tokens": {
            "description": "Minimum block tokens to archive in CCR",
            "type": "integer"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "enabled_engines": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "id": {
            "description": "Preset UUID",
            "type": "string"
          },
          "is_default": {
            "description": "Default preset flag",
            "type": "boolean"
          },
          "level": {
            "$ref": "#/components/schemas/CompressionLevel"
          },
          "name": {
            "description": "Unique preset name",
            "type": "string"
          },
          "target_budget_tokens": {
            "description": "Target prompt token budget",
            "type": "integer"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "level",
          "enabled_engines",
          "is_default"
        ],
        "type": "object"
      },
      "CompressionPresetEnvelope": {
        "properties": {
          "compression_preset": {
            "$ref": "#/components/schemas/CompressionPreset"
          }
        },
        "required": [
          "compression_preset"
        ],
        "type": "object"
      },
      "CompressionPresetListResponse": {
        "properties": {
          "compression_presets": {
            "items": {
              "$ref": "#/components/schemas/CompressionPreset"
            },
            "type": "array"
          }
        },
        "required": [
          "compression_presets"
        ],
        "type": "object"
      },
      "CoreMemory": {
        "properties": {
          "agent_id": {
            "description": "Optional agent/workspace scope",
            "type": "string"
          },
          "content": {
            "description": "Concise pinned memory content",
            "type": "string"
          },
          "id": {
            "description": "Core memory UUID",
            "type": "string"
          },
          "key": {
            "description": "Memory key (e.g., preferred_language, coding_style)",
            "type": "string"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          },
          "user_id": {
            "description": "Owning user UUID",
            "type": "string"
          },
          "user_verified": {
            "description": "User-verified precedence flag",
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "user_id",
          "key",
          "content",
          "user_verified",
          "updated_at"
        ],
        "type": "object"
      },
      "CoreMemoryEnvelope": {
        "properties": {
          "memory": {
            "$ref": "#/components/schemas/CoreMemory"
          }
        },
        "required": [
          "memory"
        ],
        "type": "object"
      },
      "CreateAPIKeyRequest": {
        "properties": {
          "allowed_combos": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "allowed_models": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "allowed_prefixes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "expires_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "exposure_mode": {
            "$ref": "#/components/schemas/ExposureMode"
          },
          "memory_enabled": {
            "description": "Enable or disable memory engine for this key (default true)",
            "type": "boolean"
          },
          "name": {
            "description": "Key display name",
            "type": "string"
          },
          "rpm_limit": {
            "description": "Optional narrower RPM limit",
            "type": "integer"
          },
          "token_quota": {
            "description": "Optional token quota",
            "type": "integer"
          },
          "tpm_limit": {
            "description": "Optional narrower TPM limit",
            "type": "integer"
          }
        },
        "required": [
          "name"
        ],
        "type": "object"
      },
      "CreateComboRequest": {
        "properties": {
          "cooldown_seconds": {
            "description": "Cooldown seconds",
            "type": "integer"
          },
          "is_enabled": {
            "description": "Enabled flag",
            "type": "boolean"
          },
          "max_retries": {
            "description": "Max fallback retries",
            "type": "integer"
          },
          "memory_enabled": {
            "description": "Enable or disable memory engine for this combo (default true)",
            "type": "boolean"
          },
          "name": {
            "description": "Combo name",
            "type": "string"
          },
          "strategy": {
            "$ref": "#/components/schemas/RoutingStrategy"
          },
          "targets": {
            "items": {
              "$ref": "#/components/schemas/ComboTargetInput"
            },
            "type": "array"
          }
        },
        "required": [
          "name",
          "targets"
        ],
        "type": "object"
      },
      "CreateCompressionPresetRequest": {
        "properties": {
          "caveman_output": {
            "description": "Enable caveman output",
            "type": "boolean"
          },
          "ccr_min_tokens": {
            "description": "CCR threshold",
            "type": "integer"
          },
          "enabled_engines": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "is_default": {
            "description": "Default preset flag",
            "type": "boolean"
          },
          "level": {
            "$ref": "#/components/schemas/CompressionLevel"
          },
          "name": {
            "description": "Preset name",
            "type": "string"
          },
          "stages": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "target_budget_tokens": {
            "description": "Target token budget",
            "type": "integer"
          }
        },
        "required": [
          "name"
        ],
        "type": "object"
      },
      "CreateEpisodicMemoryRequest": {
        "properties": {
          "agent_id": {
            "description": "Optional agent/workspace scope",
            "type": "string"
          },
          "category": {
            "$ref": "#/components/schemas/MemoryCategory"
          },
          "confidence": {
            "description": "Confidence score (0..1)",
            "type": "number"
          },
          "fact": {
            "description": "Atomic fact statement",
            "type": "string"
          },
          "importance": {
            "description": "Importance score (0..1)",
            "type": "number"
          },
          "session_id": {
            "description": "Optional session ID",
            "type": "string"
          },
          "user_verified": {
            "description": "User-verified flag",
            "type": "boolean"
          }
        },
        "required": [
          "fact"
        ],
        "type": "object"
      },
      "CreatePlanRequest": {
        "properties": {
          "allow_cli_providers": {
            "description": "Whether official CLI providers are permitted",
            "type": "boolean"
          },
          "allow_compression": {
            "description": "Whether prompt/context compression is permitted",
            "type": "boolean"
          },
          "allow_epoch_summaries": {
            "description": "Whether Billion-Context epoch summaries are permitted",
            "type": "boolean"
          },
          "allow_memory": {
            "description": "Whether per-user memory is permitted",
            "type": "boolean"
          },
          "allow_skill_installation": {
            "description": "Whether installing skills is permitted",
            "type": "boolean"
          },
          "allow_system_prompt_override": {
            "description": "Whether user custom system prompt overrides are permitted",
            "type": "boolean"
          },
          "allowed_combos": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "allowed_compression_engines": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "allowed_models": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "allowed_prefixes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "daily_token_limit": {
            "description": "Daily token limit",
            "type": "integer"
          },
          "description": {
            "description": "Plan description",
            "type": "string"
          },
          "exposure_mode": {
            "$ref": "#/components/schemas/ExposureMode"
          },
          "is_default": {
            "description": "Default plan for newly registered users",
            "type": "boolean"
          },
          "max_api_keys": {
            "description": "Maximum active virtual API keys",
            "type": "integer"
          },
          "max_installed_skills": {
            "description": "Maximum installed skills",
            "type": "integer"
          },
          "max_memory_facts": {
            "description": "Maximum active episodic memory facts",
            "type": "integer"
          },
          "monthly_token_limit": {
            "description": "Monthly token limit",
            "type": "integer"
          },
          "name": {
            "description": "Plan display name",
            "type": "string"
          },
          "rpm_limit": {
            "description": "Requests per minute limit (0 = unlimited)",
            "type": "integer"
          },
          "slug": {
            "description": "Unique plan slug",
            "type": "string"
          },
          "tpm_limit": {
            "description": "Tokens per minute limit (0 = unlimited)",
            "type": "integer"
          }
        },
        "required": [
          "name",
          "slug"
        ],
        "type": "object"
      },
      "CreatePromptPolicyRequest": {
        "properties": {
          "is_enabled": {
            "description": "Enabled flag",
            "type": "boolean"
          },
          "mode": {
            "$ref": "#/components/schemas/PromptMode"
          },
          "name": {
            "description": "Policy name",
            "type": "string"
          },
          "priority": {
            "description": "Ordering priority",
            "type": "integer"
          },
          "scope_id": {
            "description": "Target ID for non-global scopes",
            "type": "string"
          },
          "scope_type": {
            "$ref": "#/components/schemas/PromptScopeType"
          },
          "template": {
            "description": "Template string",
            "type": "string"
          }
        },
        "required": [
          "name",
          "template"
        ],
        "type": "object"
      },
      "CreateProviderRequest": {
        "properties": {
          "account_cooldown_seconds": {
            "description": "Account cooldown duration in seconds",
            "type": "integer"
          },
          "account_max_retries": {
            "description": "Account retry limit before failover",
            "type": "integer"
          },
          "account_strategy": {
            "$ref": "#/components/schemas/RoutingStrategy"
          },
          "accounts": {
            "items": {
              "$ref": "#/components/schemas/ProviderAccountInput"
            },
            "type": "array"
          },
          "api_key": {
            "description": "Upstream API key (encrypted with AES-256-GCM at rest)",
            "type": "string"
          },
          "api_prefix": {
            "description": "Unique prefix (normalized with trailing slash)",
            "type": "string"
          },
          "base_url": {
            "description": "Upstream HTTP base URL (required for http_api)",
            "type": "string"
          },
          "cli_binary": {
            "description": "CLI executable name (for official_cli)",
            "type": "string"
          },
          "cli_enabled": {
            "description": "Enable CLI execution",
            "type": "boolean"
          },
          "driver_name": {
            "description": "Alias for protocol",
            "type": "string"
          },
          "driver_type": {
            "$ref": "#/components/schemas/DriverType"
          },
          "extra_headers": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object"
          },
          "is_enabled": {
            "description": "Enabled flag",
            "type": "boolean"
          },
          "max_concurrent": {
            "description": "Concurrency cap",
            "type": "integer"
          },
          "name": {
            "description": "Provider name",
            "type": "string"
          },
          "protocol": {
            "description": "Upstream protocol or CLI adapter",
            "type": "string"
          },
          "request_delay_ms": {
            "description": "Minimum delay in milliseconds between requests",
            "type": "integer"
          },
          "timeout_seconds": {
            "description": "Request timeout",
            "type": "integer"
          }
        },
        "required": [
          "name",
          "api_prefix",
          "driver_type"
        ],
        "type": "object"
      },
      "CreateServiceTokenRequest": {
        "properties": {
          "expires_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "description": "Service token label",
            "type": "string"
          },
          "scopes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "name"
        ],
        "type": "object"
      },
      "CreateSkillRequest": {
        "properties": {
          "description": {
            "description": "Short description",
            "type": "string"
          },
          "instructions": {
            "description": "Alias for instructions_md",
            "type": "string"
          },
          "instructions_md": {
            "description": "Full Markdown instructions",
            "type": "string"
          },
          "is_enabled": {
            "description": "Enabled flag",
            "type": "boolean"
          },
          "max_tokens": {
            "description": "Alias for token_estimate",
            "type": "integer"
          },
          "name": {
            "description": "Skill name",
            "type": "string"
          },
          "owner_user_id": {
            "description": "Owner user ID or external_id",
            "type": [
              "string",
              "null"
            ]
          },
          "slug": {
            "description": "Unique skill slug",
            "type": "string"
          },
          "token_estimate": {
            "description": "Estimated tokens",
            "type": "integer"
          },
          "triggers": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "slug",
          "name",
          "instructions_md"
        ],
        "type": "object"
      },
      "DetectedCLIAccount": {
        "properties": {
          "cli_home": {
            "description": "Isolated HOME path (empty for host default HOME)",
            "type": "string"
          },
          "display_home": {
            "description": "Effective HOME path inspected",
            "type": "string"
          },
          "existing_account_id": {
            "description": "Matched provider account UUID if already saved",
            "type": "string"
          },
          "name": {
            "description": "Suggested account name",
            "type": "string"
          },
          "ready": {
            "description": "Whether the binary and profile are ready to use",
            "type": "boolean"
          },
          "reason": {
            "description": "Non-secret detection signal",
            "type": "string"
          },
          "status": {
            "enum": [
              "logged_in",
              "profile_detected",
              "not_logged_in",
              "binary_missing"
            ],
            "type": "string"
          }
        },
        "required": [
          "name",
          "cli_home",
          "display_home",
          "status",
          "ready",
          "reason"
        ],
        "type": "object"
      },
      "DetectedCLIProvider": {
        "properties": {
          "accounts": {
            "items": {
              "$ref": "#/components/schemas/DetectedCLIAccount"
            },
            "type": "array"
          },
          "binary": {
            "description": "Default binary name",
            "type": "string"
          },
          "binary_found": {
            "description": "Whether the executable was found",
            "type": "boolean"
          },
          "default_api_prefix": {
            "description": "Default unique API prefix",
            "type": "string"
          },
          "existing_provider_id": {
            "description": "Matched provider UUID if already configured",
            "type": "string"
          },
          "name": {
            "description": "Display name",
            "type": "string"
          },
          "protocol": {
            "description": "CLI protocol (cli_agy | cli_claude | cli_codex | cli_gemini)",
            "type": "string"
          },
          "resolved_binary": {
            "description": "Resolved absolute path to binary",
            "type": "string"
          }
        },
        "required": [
          "protocol",
          "name",
          "default_api_prefix",
          "binary",
          "binary_found",
          "resolved_binary",
          "accounts"
        ],
        "type": "object"
      },
      "DriverType": {
        "enum": [
          "http_api",
          "official_cli"
        ],
        "type": "string"
      },
      "EffectivePolicy": {
        "properties": {
          "allow_cli_providers": {
            "description": "CLI provider access",
            "type": "boolean"
          },
          "allowed_combos": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "allowed_models": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "allowed_prefixes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "auto_extract_memory": {
            "description": "Effective auto memory extraction",
            "type": "boolean"
          },
          "caveman_output_enabled": {
            "description": "Effective caveman output",
            "type": "boolean"
          },
          "compression_enabled": {
            "description": "Effective compression enabled",
            "type": "boolean"
          },
          "compression_level": {
            "$ref": "#/components/schemas/CompressionLevel"
          },
          "custom_prompt_mode": {
            "$ref": "#/components/schemas/PromptMode"
          },
          "custom_system_prompt": {
            "description": "Effective custom prompt",
            "type": "string"
          },
          "daily_token_limit": {
            "description": "Effective daily token limit",
            "type": "integer"
          },
          "enabled_compression_engines": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "epoch_summaries_enabled": {
            "description": "Effective epoch summaries",
            "type": "boolean"
          },
          "exposure_mode": {
            "$ref": "#/components/schemas/ExposureMode"
          },
          "max_installed_skills": {
            "description": "Max installed skills from plan",
            "type": "integer"
          },
          "max_memory_facts": {
            "description": "Max memory facts from plan",
            "type": "integer"
          },
          "memory_enabled": {
            "description": "Effective memory enabled",
            "type": "boolean"
          },
          "monthly_token_limit": {
            "description": "Effective monthly token limit",
            "type": "integer"
          },
          "progressive_skill_disclosure": {
            "description": "Effective progressive disclosure",
            "type": "boolean"
          },
          "rpm_limit": {
            "description": "Effective RPM limit",
            "type": "integer"
          },
          "skills_enabled": {
            "description": "Effective skills enabled",
            "type": "boolean"
          },
          "system_prompt_enabled": {
            "description": "Effective custom prompt enabled",
            "type": "boolean"
          },
          "tpm_limit": {
            "description": "Effective TPM limit",
            "type": "integer"
          }
        },
        "required": [
          "exposure_mode",
          "compression_level",
          "custom_prompt_mode"
        ],
        "type": "object"
      },
      "EntitlementsResponse": {
        "properties": {
          "effective_policy": {
            "$ref": "#/components/schemas/EffectivePolicy"
          },
          "plan": {
            "$ref": "#/components/schemas/Plan"
          },
          "settings": {
            "$ref": "#/components/schemas/UserSettings"
          },
          "user": {
            "$ref": "#/components/schemas/User"
          }
        },
        "required": [
          "user",
          "settings",
          "effective_policy"
        ],
        "type": "object"
      },
      "EpisodicMemory": {
        "properties": {
          "access_count": {
            "description": "Recall access count",
            "type": "integer"
          },
          "agent_id": {
            "description": "Optional agent/workspace scope",
            "type": "string"
          },
          "bm25_rank": {
            "description": "Optional FTS5 BM25 rank when searching with query",
            "type": [
              "number",
              "null"
            ]
          },
          "category": {
            "$ref": "#/components/schemas/MemoryCategory"
          },
          "confidence": {
            "description": "Confidence score (0..1)",
            "type": "number"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "fact": {
            "description": "Atomic memory fact",
            "type": "string"
          },
          "id": {
            "description": "Episodic memory UUID",
            "type": "string"
          },
          "importance": {
            "description": "Importance weight (0..1)",
            "type": "number"
          },
          "last_accessed_at": {
            "format": "date-time",
            "type": "string"
          },
          "session_id": {
            "description": "Originating session ID",
            "type": "string"
          },
          "superseded_by": {
            "description": "Superseding memory ID if contradicted",
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          },
          "user_id": {
            "description": "Owning user UUID",
            "type": "string"
          },
          "user_verified": {
            "description": "User-verified flag",
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "user_id",
          "fact",
          "category",
          "confidence",
          "importance",
          "user_verified"
        ],
        "type": "object"
      },
      "EpisodicMemoryEnvelope": {
        "properties": {
          "memory": {
            "$ref": "#/components/schemas/EpisodicMemory"
          }
        },
        "required": [
          "memory"
        ],
        "type": "object"
      },
      "ErrorEnvelope": {
        "properties": {
          "code": {
            "description": "Machine-readable error code",
            "type": "string"
          },
          "error": {
            "description": "Human-readable error message",
            "type": "string"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "ExposureMode": {
        "enum": [
          "all",
          "selected",
          "combo_only"
        ],
        "type": "string"
      },
      "HealthResponse": {
        "properties": {
          "status": {
            "description": "ok",
            "type": "string"
          }
        },
        "required": [
          "status"
        ],
        "type": "object"
      },
      "ImportSkillRequest": {
        "properties": {
          "always_on": {
            "description": "Always inject full instructions when install=true",
            "type": "boolean"
          },
          "install": {
            "description": "Immediately install imported skill(s) (global scope on admin import, user/key/combo on user import)",
            "type": "boolean"
          },
          "is_enabled": {
            "description": "Enabled flag (defaults to true)",
            "type": "boolean"
          },
          "overwrite": {
            "description": "Overwrite existing skill with the same slug if permitted",
            "type": "boolean"
          },
          "scope_id": {
            "description": "Target API key ID or combo name/ID when install=true on user endpoints",
            "type": "string"
          },
          "scope_type": {
            "enum": [
              "user",
              "api_key",
              "combo"
            ],
            "type": "string"
          },
          "slug": {
            "description": "Optional slug override for the first imported skill",
            "type": "string"
          },
          "source": {
            "description": "skills.sh CLI command (e.g. `npx skills add https://github.com/vercel-labs/agent-browser --skill agent-browser`), skills.sh URL, GitHub URL, or raw GitHub .md URL",
            "type": "string"
          },
          "triggers": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "source"
        ],
        "type": "object"
      },
      "InstallSkillRequest": {
        "properties": {
          "always_on": {
            "description": "Always inject full skill instructions",
            "type": "boolean"
          },
          "is_enabled": {
            "description": "Enabled flag",
            "type": "boolean"
          },
          "scope_id": {
            "description": "Target API key ID, or combo name/ID (normalized and stored as combo name)",
            "type": "string"
          },
          "scope_type": {
            "enum": [
              "user",
              "api_key",
              "combo"
            ],
            "type": "string"
          },
          "skill_id": {
            "description": "Skill UUID to install",
            "type": "string"
          }
        },
        "required": [
          "skill_id"
        ],
        "type": "object"
      },
      "LoginRequest": {
        "properties": {
          "email": {
            "description": "User email",
            "type": "string"
          },
          "password": {
            "description": "Password",
            "type": "string"
          }
        },
        "required": [
          "email",
          "password"
        ],
        "type": "object"
      },
      "MemoryCategory": {
        "enum": [
          "preference",
          "project",
          "constraint",
          "fact"
        ],
        "type": "string"
      },
      "OpenAIChatCompletionChunk": {
        "properties": {
          "choices": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "created": {
            "description": "Unix timestamp",
            "type": "integer"
          },
          "id": {
            "description": "Completion ID",
            "type": "string"
          },
          "model": {
            "description": "Requested model",
            "type": "string"
          },
          "object": {
            "description": "chat.completion.chunk",
            "type": "string"
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        },
        "required": [
          "id",
          "object",
          "created",
          "model",
          "choices"
        ],
        "type": "object"
      },
      "OpenAIChatCompletionRequest": {
        "properties": {
          "compression_level": {
            "$ref": "#/components/schemas/CompressionLevel"
          },
          "max_completion_tokens": {
            "description": "OpenAI alias for max_tokens",
            "type": "integer"
          },
          "max_tokens": {
            "description": "Maximum completion tokens",
            "type": "integer"
          },
          "messages": {
            "items": {
              "$ref": "#/components/schemas/OpenAIChatMessage"
            },
            "type": "array"
          },
          "model": {
            "description": "Model ID (with api_prefix) or combo name",
            "type": "string"
          },
          "response_format": {
            "description": "Structured JSON output format (bypasses lossy compression)"
          },
          "session_id": {
            "description": "Optional session ID",
            "type": "string"
          },
          "skills": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "stream": {
            "description": "Stream SSE chunks",
            "type": "boolean"
          },
          "temperature": {
            "description": "Sampling temperature",
            "type": "number"
          },
          "tools": {
            "items": {
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "model",
          "messages"
        ],
        "type": "object"
      },
      "OpenAIChatCompletionResponse": {
        "properties": {
          "choices": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "created": {
            "description": "Unix timestamp",
            "type": "integer"
          },
          "id": {
            "description": "Completion ID",
            "type": "string"
          },
          "model": {
            "description": "Requested model",
            "type": "string"
          },
          "object": {
            "description": "chat.completion",
            "type": "string"
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        },
        "required": [
          "id",
          "object",
          "created",
          "model",
          "choices"
        ],
        "type": "object"
      },
      "OpenAIChatMessage": {
        "properties": {
          "content": {
            "description": "Message string or array of content parts"
          },
          "name": {
            "description": "Optional participant name",
            "type": "string"
          },
          "role": {
            "enum": [
              "system",
              "developer",
              "user",
              "assistant",
              "tool"
            ],
            "type": "string"
          },
          "tool_call_id": {
            "description": "Tool call ID for role=tool",
            "type": "string"
          },
          "tool_calls": {
            "items": {
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "role"
        ],
        "type": "object"
      },
      "OpenAIErrorDetail": {
        "properties": {
          "code": {
            "description": "Machine-readable error code",
            "type": "string"
          },
          "message": {
            "description": "Error message",
            "type": "string"
          },
          "param": {
            "description": "Optional failing parameter",
            "type": [
              "string",
              "null"
            ]
          },
          "type": {
            "description": "Error category",
            "type": "string"
          }
        },
        "required": [
          "message",
          "type",
          "code"
        ],
        "type": "object"
      },
      "OpenAIErrorEnvelope": {
        "properties": {
          "error": {
            "$ref": "#/components/schemas/OpenAIErrorDetail"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "OpenAIModelItem": {
        "properties": {
          "created": {
            "description": "Unix timestamp",
            "type": "integer"
          },
          "id": {
            "description": "Prefixed model ID or combo name",
            "type": "string"
          },
          "object": {
            "description": "model",
            "type": "string"
          },
          "owned_by": {
            "description": "Owner or combo",
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "created",
          "owned_by"
        ],
        "type": "object"
      },
      "OpenAIModelsListResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/OpenAIModelItem"
            },
            "type": "array"
          },
          "object": {
            "description": "list",
            "type": "string"
          }
        },
        "required": [
          "object",
          "data"
        ],
        "type": "object"
      },
      "PatchAPIKeyRequest": {
        "properties": {
          "memory_enabled": {
            "description": "Enable or disable memory engine for this virtual key",
            "type": "boolean"
          }
        },
        "required": [
          "memory_enabled"
        ],
        "type": "object"
      },
      "PatchAdminCLIConfigRequest": {
        "properties": {
          "cli_enabled": {
            "description": "Enable or disable global official CLI execution",
            "type": "boolean"
          }
        },
        "required": [
          "cli_enabled"
        ],
        "type": "object"
      },
      "PatchAdminMemoryConfigRequest": {
        "properties": {
          "extractor_model": {
            "description": "Dedicated model/combo ID for async memory extraction (empty string clears DB override)",
            "type": "string"
          }
        },
        "required": [
          "extractor_model"
        ],
        "type": "object"
      },
      "PatchAdminSystemSettingsRequest": {
        "properties": {
          "allow_private_provider_urls": {
            "description": "Allow loopback/private HTTP provider URLs",
            "type": "boolean"
          },
          "cli_default_timeout_seconds": {
            "description": "Default CLI subprocess timeout in seconds (\u003e= 1)",
            "type": "integer"
          },
          "cli_enabled": {
            "description": "Enable or disable global official CLI execution",
            "type": "boolean"
          },
          "cli_max_concurrent": {
            "description": "Global CLI concurrency semaphore cap (\u003e= 1)",
            "type": "integer"
          },
          "cli_profile_roots": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "log_level": {
            "enum": [
              "debug",
              "info",
              "warn",
              "error"
            ],
            "type": "string"
          },
          "memory_extractor_model": {
            "description": "Dedicated model/combo ID for async memory extraction (empty clears DB override)",
            "type": "string"
          },
          "memory_extractor_timeout_seconds": {
            "description": "Async memory extraction job timeout in seconds (\u003e= 1)",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "PatchComboRequest": {
        "properties": {
          "cooldown_seconds": {
            "description": "Cooldown seconds",
            "type": "integer"
          },
          "is_enabled": {
            "description": "Enabled flag",
            "type": "boolean"
          },
          "max_retries": {
            "description": "Max fallback retries",
            "type": "integer"
          },
          "memory_enabled": {
            "description": "Enable or disable memory engine for this combo",
            "type": "boolean"
          },
          "name": {
            "description": "Combo name",
            "type": "string"
          },
          "strategy": {
            "$ref": "#/components/schemas/RoutingStrategy"
          },
          "targets": {
            "items": {
              "$ref": "#/components/schemas/ComboTargetInput"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "PatchCompressionPresetRequest": {
        "properties": {
          "caveman_output": {
            "description": "Enable caveman output",
            "type": "boolean"
          },
          "ccr_min_tokens": {
            "description": "CCR threshold",
            "type": "integer"
          },
          "enabled_engines": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "is_default": {
            "description": "Default preset flag",
            "type": "boolean"
          },
          "level": {
            "$ref": "#/components/schemas/CompressionLevel"
          },
          "name": {
            "description": "Preset name",
            "type": "string"
          },
          "stages": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "target_budget_tokens": {
            "description": "Target token budget",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "PatchEpisodicMemoryRequest": {
        "properties": {
          "category": {
            "$ref": "#/components/schemas/MemoryCategory"
          },
          "confidence": {
            "description": "Updated confidence",
            "type": "number"
          },
          "fact": {
            "description": "Updated fact text",
            "type": "string"
          },
          "importance": {
            "description": "Updated importance",
            "type": "number"
          },
          "user_verified": {
            "description": "User-verified flag",
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "PatchPlanRequest": {
        "properties": {
          "allow_cli_providers": {
            "description": "Whether official CLI providers are permitted",
            "type": "boolean"
          },
          "allow_compression": {
            "description": "Whether prompt/context compression is permitted",
            "type": "boolean"
          },
          "allow_epoch_summaries": {
            "description": "Whether Billion-Context epoch summaries are permitted",
            "type": "boolean"
          },
          "allow_memory": {
            "description": "Whether per-user memory is permitted",
            "type": "boolean"
          },
          "allow_skill_installation": {
            "description": "Whether installing skills is permitted",
            "type": "boolean"
          },
          "allow_system_prompt_override": {
            "description": "Whether user custom system prompt overrides are permitted",
            "type": "boolean"
          },
          "allowed_combos": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "allowed_compression_engines": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "allowed_models": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "allowed_prefixes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "daily_token_limit": {
            "description": "Daily token limit",
            "type": "integer"
          },
          "description": {
            "description": "Plan description",
            "type": "string"
          },
          "exposure_mode": {
            "$ref": "#/components/schemas/ExposureMode"
          },
          "id": {
            "description": "Plan UUID",
            "type": "string"
          },
          "is_default": {
            "description": "Default plan for newly registered users",
            "type": "boolean"
          },
          "max_api_keys": {
            "description": "Maximum active virtual API keys",
            "type": "integer"
          },
          "max_installed_skills": {
            "description": "Maximum installed skills",
            "type": "integer"
          },
          "max_memory_facts": {
            "description": "Maximum active episodic memory facts",
            "type": "integer"
          },
          "monthly_token_limit": {
            "description": "Monthly token limit",
            "type": "integer"
          },
          "name": {
            "description": "Plan display name",
            "type": "string"
          },
          "rpm_limit": {
            "description": "Requests per minute limit (0 = unlimited)",
            "type": "integer"
          },
          "slug": {
            "description": "Unique plan slug",
            "type": "string"
          },
          "tpm_limit": {
            "description": "Tokens per minute limit (0 = unlimited)",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "PatchPromptPolicyRequest": {
        "properties": {
          "is_enabled": {
            "description": "Enabled flag",
            "type": "boolean"
          },
          "mode": {
            "$ref": "#/components/schemas/PromptMode"
          },
          "name": {
            "description": "Policy name",
            "type": "string"
          },
          "priority": {
            "description": "Priority",
            "type": "integer"
          },
          "scope_id": {
            "description": "Target scope ID",
            "type": "string"
          },
          "scope_type": {
            "$ref": "#/components/schemas/PromptScopeType"
          },
          "template": {
            "description": "Template string",
            "type": "string"
          }
        },
        "type": "object"
      },
      "PatchProviderAccountRequest": {
        "properties": {
          "api_key": {
            "description": "New API key (empty string clears stored key)",
            "type": "string"
          },
          "base_url": {
            "description": "Base URL override (empty string inherits provider)",
            "type": "string"
          },
          "cli_binary": {
            "description": "CLI binary override (empty string inherits provider)",
            "type": "string"
          },
          "cli_home": {
            "description": "Isolated HOME directory for official_cli",
            "type": "string"
          },
          "extra_headers": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object"
          },
          "is_enabled": {
            "description": "Enabled flag",
            "type": "boolean"
          },
          "max_concurrent": {
            "description": "Concurrency override (0 inherits provider)",
            "type": "integer"
          },
          "name": {
            "description": "Account label",
            "type": "string"
          },
          "priority": {
            "description": "Fallback priority (\u003e= 0)",
            "type": "integer"
          },
          "request_delay_ms": {
            "description": "Delay between requests override in ms (0 inherits provider)",
            "type": "integer"
          },
          "timeout_seconds": {
            "description": "Timeout override (0 inherits provider)",
            "type": "integer"
          },
          "weight": {
            "description": "Traffic weight (\u003e= 1)",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "PatchProviderModelRequest": {
        "properties": {
          "account_ids": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "is_enabled": {
            "description": "Enable or disable model exposure",
            "type": "boolean"
          },
          "memory_enabled": {
            "description": "Enable or disable memory engine for this model",
            "type": "boolean"
          },
          "upstream_model": {
            "description": "Upstream model ID (optional when supplied in path)",
            "type": "string"
          }
        },
        "type": "object"
      },
      "PatchProviderRequest": {
        "properties": {
          "account_cooldown_seconds": {
            "description": "Account cooldown duration in seconds",
            "type": "integer"
          },
          "account_max_retries": {
            "description": "Account retry limit before failover",
            "type": "integer"
          },
          "account_strategy": {
            "$ref": "#/components/schemas/RoutingStrategy"
          },
          "api_key": {
            "description": "New API key (empty string clears stored key)",
            "type": "string"
          },
          "api_prefix": {
            "description": "Unique prefix",
            "type": "string"
          },
          "base_url": {
            "description": "Base URL",
            "type": "string"
          },
          "cli_binary": {
            "description": "CLI binary",
            "type": "string"
          },
          "cli_enabled": {
            "description": "CLI enabled flag",
            "type": "boolean"
          },
          "driver_name": {
            "description": "Alias for protocol",
            "type": "string"
          },
          "driver_type": {
            "$ref": "#/components/schemas/DriverType"
          },
          "extra_headers": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object"
          },
          "is_enabled": {
            "description": "Enabled flag",
            "type": "boolean"
          },
          "max_concurrent": {
            "description": "Concurrency cap",
            "type": "integer"
          },
          "name": {
            "description": "Provider name",
            "type": "string"
          },
          "protocol": {
            "description": "Upstream protocol",
            "type": "string"
          },
          "request_delay_ms": {
            "description": "Minimum delay in milliseconds between requests",
            "type": "integer"
          },
          "timeout_seconds": {
            "description": "Timeout seconds",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "PatchSkillRequest": {
        "properties": {
          "description": {
            "description": "Description",
            "type": "string"
          },
          "instructions": {
            "description": "Alias for instructions_md",
            "type": "string"
          },
          "instructions_md": {
            "description": "Instructions",
            "type": "string"
          },
          "is_enabled": {
            "description": "Enabled flag",
            "type": "boolean"
          },
          "max_tokens": {
            "description": "Alias for token_estimate",
            "type": "integer"
          },
          "name": {
            "description": "Skill name",
            "type": "string"
          },
          "owner_user_id": {
            "description": "Owner user ID",
            "type": [
              "string",
              "null"
            ]
          },
          "slug": {
            "description": "Skill slug",
            "type": "string"
          },
          "token_estimate": {
            "description": "Estimated tokens",
            "type": "integer"
          },
          "triggers": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "Plan": {
        "properties": {
          "allow_cli_providers": {
            "description": "Whether official CLI providers are permitted",
            "type": "boolean"
          },
          "allow_compression": {
            "description": "Whether prompt/context compression is permitted",
            "type": "boolean"
          },
          "allow_epoch_summaries": {
            "description": "Whether Billion-Context epoch summaries are permitted",
            "type": "boolean"
          },
          "allow_memory": {
            "description": "Whether per-user memory is permitted",
            "type": "boolean"
          },
          "allow_skill_installation": {
            "description": "Whether installing skills is permitted",
            "type": "boolean"
          },
          "allow_system_prompt_override": {
            "description": "Whether user custom system prompt overrides are permitted",
            "type": "boolean"
          },
          "allowed_combos": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "allowed_compression_engines": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "allowed_models": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "allowed_prefixes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "daily_token_limit": {
            "description": "Daily token limit",
            "type": "integer"
          },
          "description": {
            "description": "Plan description",
            "type": "string"
          },
          "exposure_mode": {
            "$ref": "#/components/schemas/ExposureMode"
          },
          "id": {
            "description": "Plan UUID",
            "type": "string"
          },
          "is_default": {
            "description": "Default plan for newly registered users",
            "type": "boolean"
          },
          "max_api_keys": {
            "description": "Maximum active virtual API keys",
            "type": "integer"
          },
          "max_installed_skills": {
            "description": "Maximum installed skills",
            "type": "integer"
          },
          "max_memory_facts": {
            "description": "Maximum active episodic memory facts",
            "type": "integer"
          },
          "monthly_token_limit": {
            "description": "Monthly token limit",
            "type": "integer"
          },
          "name": {
            "description": "Plan display name",
            "type": "string"
          },
          "rpm_limit": {
            "description": "Requests per minute limit (0 = unlimited)",
            "type": "integer"
          },
          "slug": {
            "description": "Unique plan slug",
            "type": "string"
          },
          "tpm_limit": {
            "description": "Tokens per minute limit (0 = unlimited)",
            "type": "integer"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "slug",
          "exposure_mode"
        ],
        "type": "object"
      },
      "PlanEnvelope": {
        "properties": {
          "plan": {
            "$ref": "#/components/schemas/Plan"
          }
        },
        "required": [
          "plan"
        ],
        "type": "object"
      },
      "PlanListResponse": {
        "properties": {
          "plans": {
            "items": {
              "$ref": "#/components/schemas/Plan"
            },
            "type": "array"
          }
        },
        "required": [
          "plans"
        ],
        "type": "object"
      },
      "PlaygroundModelsResponse": {
        "properties": {
          "models": {
            "items": {
              "properties": {
                "id": {
                  "description": "Model or combo ID",
                  "type": "string"
                },
                "is_combo": {
                  "description": "True for routing combos",
                  "type": "boolean"
                },
                "owned_by": {
                  "description": "Provider name or 'combo'",
                  "type": "string"
                }
              },
              "required": [
                "id",
                "owned_by",
                "is_combo"
              ],
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "models"
        ],
        "type": "object"
      },
      "PrepareCLIProfileRequest": {
        "properties": {
          "name": {
            "description": "Optional account name (auto-numbered if omitted)",
            "type": "string"
          },
          "protocol": {
            "description": "CLI protocol (cli_agy | cli_claude | cli_codex | cli_gemini)",
            "type": "string"
          }
        },
        "required": [
          "protocol"
        ],
        "type": "object"
      },
      "PrepareCLIProfileResponse": {
        "properties": {
          "account": {
            "$ref": "#/components/schemas/ProviderAccount"
          },
          "login_command": {
            "description": "Copyable native CLI login command",
            "type": "string"
          },
          "provider_id": {
            "description": "Provider UUID",
            "type": "string"
          },
          "provider_name": {
            "description": "Provider name",
            "type": "string"
          }
        },
        "required": [
          "provider_id",
          "provider_name",
          "account",
          "login_command"
        ],
        "type": "object"
      },
      "PromptMode": {
        "enum": [
          "prepend",
          "append",
          "replace",
          "if_missing"
        ],
        "type": "string"
      },
      "PromptPolicy": {
        "properties": {
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "description": "Prompt policy UUID",
            "type": "string"
          },
          "is_enabled": {
            "description": "Enabled flag",
            "type": "boolean"
          },
          "mode": {
            "$ref": "#/components/schemas/PromptMode"
          },
          "name": {
            "description": "Policy name",
            "type": "string"
          },
          "priority": {
            "description": "Application priority",
            "type": "integer"
          },
          "scope_id": {
            "description": "Target scope ID (empty for global)",
            "type": "string"
          },
          "scope_type": {
            "$ref": "#/components/schemas/PromptScopeType"
          },
          "template": {
            "description": "Prompt template text",
            "type": "string"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "scope_type",
          "mode",
          "template",
          "is_enabled"
        ],
        "type": "object"
      },
      "PromptPolicyEnvelope": {
        "properties": {
          "prompt_policy": {
            "$ref": "#/components/schemas/PromptPolicy"
          }
        },
        "required": [
          "prompt_policy"
        ],
        "type": "object"
      },
      "PromptPolicyListResponse": {
        "properties": {
          "prompt_policies": {
            "items": {
              "$ref": "#/components/schemas/PromptPolicy"
            },
            "type": "array"
          }
        },
        "required": [
          "prompt_policies"
        ],
        "type": "object"
      },
      "PromptScopeType": {
        "enum": [
          "global",
          "combo",
          "user",
          "api_key"
        ],
        "type": "string"
      },
      "Provider": {
        "properties": {
          "account_cooldown_seconds": {
            "description": "Cooldown duration in seconds for rate-limited accounts",
            "type": "integer"
          },
          "account_max_retries": {
            "description": "Max retries across eligible accounts before failing over",
            "type": "integer"
          },
          "account_strategy": {
            "$ref": "#/components/schemas/RoutingStrategy"
          },
          "accounts": {
            "items": {
              "$ref": "#/components/schemas/ProviderAccount"
            },
            "type": "array"
          },
          "api_prefix": {
            "description": "Unique model namespace prefix (e.g., or/, groq/, cli-claude/)",
            "type": "string"
          },
          "base_url": {
            "description": "Upstream HTTP base URL",
            "type": "string"
          },
          "cli_binary": {
            "description": "Official CLI binary name or path",
            "type": "string"
          },
          "cli_enabled": {
            "description": "Whether CLI execution is enabled for this provider",
            "type": "boolean"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "driver_type": {
            "$ref": "#/components/schemas/DriverType"
          },
          "extra_headers": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object"
          },
          "has_api_key": {
            "description": "Whether an encrypted upstream API key is stored on the provider or any account",
            "type": "boolean"
          },
          "id": {
            "description": "Provider UUID",
            "type": "string"
          },
          "is_enabled": {
            "description": "Provider enabled flag",
            "type": "boolean"
          },
          "max_concurrent": {
            "description": "Max concurrent requests/subprocesses",
            "type": "integer"
          },
          "name": {
            "description": "Unique provider name",
            "type": "string"
          },
          "protocol": {
            "$ref": "#/components/schemas/ProviderProtocol"
          },
          "request_delay_ms": {
            "description": "Minimum delay in milliseconds between requests to this provider",
            "type": "integer"
          },
          "timeout_seconds": {
            "description": "Upstream timeout in seconds",
            "type": "integer"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "api_prefix",
          "driver_type",
          "protocol",
          "is_enabled"
        ],
        "type": "object"
      },
      "ProviderAccount": {
        "properties": {
          "base_url": {
            "description": "Optional HTTP base URL override",
            "type": "string"
          },
          "cli_binary": {
            "description": "Optional CLI binary override",
            "type": "string"
          },
          "cli_home": {
            "description": "Optional isolated HOME profile directory for official_cli accounts",
            "type": "string"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "extra_headers": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object"
          },
          "has_api_key": {
            "description": "Whether an encrypted upstream API key is stored",
            "type": "boolean"
          },
          "id": {
            "description": "Provider account UUID",
            "type": "string"
          },
          "is_enabled": {
            "description": "Account enabled flag",
            "type": "boolean"
          },
          "login_command": {
            "description": "Copyable native CLI login command for official_cli accounts",
            "type": "string"
          },
          "max_concurrent": {
            "description": "Optional per-account concurrency override (0 inherits provider)",
            "type": "integer"
          },
          "name": {
            "description": "Unique account label within the provider",
            "type": "string"
          },
          "priority": {
            "description": "Priority order (lower is higher priority)",
            "type": "integer"
          },
          "provider_id": {
            "description": "Owning provider UUID",
            "type": "string"
          },
          "request_delay_ms": {
            "description": "Optional per-account delay between requests in ms (0 inherits provider)",
            "type": "integer"
          },
          "timeout_seconds": {
            "description": "Optional per-account timeout override (0 inherits provider)",
            "type": "integer"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          },
          "weight": {
            "description": "Weighted distribution weight (\u003e= 1)",
            "type": "integer"
          }
        },
        "required": [
          "id",
          "provider_id",
          "name",
          "priority",
          "weight",
          "is_enabled"
        ],
        "type": "object"
      },
      "ProviderAccountEnvelope": {
        "properties": {
          "account": {
            "$ref": "#/components/schemas/ProviderAccount"
          }
        },
        "required": [
          "account"
        ],
        "type": "object"
      },
      "ProviderAccountInput": {
        "properties": {
          "api_key": {
            "description": "Upstream API key (for http_api providers)",
            "type": "string"
          },
          "auto_isolate": {
            "description": "Auto-create isolated cli_home directory (default true when adding 2nd+ official_cli account without cli_home)",
            "type": "boolean"
          },
          "base_url": {
            "description": "Optional HTTP base URL override",
            "type": "string"
          },
          "cli_binary": {
            "description": "Optional CLI binary override",
            "type": "string"
          },
          "cli_home": {
            "description": "Optional absolute HOME directory for isolated official_cli profile",
            "type": "string"
          },
          "extra_headers": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object"
          },
          "is_enabled": {
            "description": "Enabled flag",
            "type": "boolean"
          },
          "max_concurrent": {
            "description": "Optional concurrency override (0 inherits provider)",
            "type": "integer"
          },
          "name": {
            "description": "Unique account label within the provider",
            "type": "string"
          },
          "priority": {
            "description": "Fallback priority (\u003e= 0)",
            "type": "integer"
          },
          "request_delay_ms": {
            "description": "Optional delay between requests in ms (0 inherits provider)",
            "type": "integer"
          },
          "timeout_seconds": {
            "description": "Optional timeout override (0 inherits provider)",
            "type": "integer"
          },
          "weight": {
            "description": "Traffic weight (\u003e= 1)",
            "type": "integer"
          }
        },
        "required": [
          "name"
        ],
        "type": "object"
      },
      "ProviderAccountListResponse": {
        "properties": {
          "account_strategy": {
            "$ref": "#/components/schemas/RoutingStrategy"
          },
          "accounts": {
            "items": {
              "$ref": "#/components/schemas/ProviderAccount"
            },
            "type": "array"
          },
          "provider_id": {
            "description": "Provider UUID",
            "type": "string"
          }
        },
        "required": [
          "provider_id",
          "account_strategy",
          "accounts"
        ],
        "type": "object"
      },
      "ProviderEnvelope": {
        "properties": {
          "provider": {
            "$ref": "#/components/schemas/Provider"
          }
        },
        "required": [
          "provider"
        ],
        "type": "object"
      },
      "ProviderListResponse": {
        "properties": {
          "providers": {
            "items": {
              "$ref": "#/components/schemas/Provider"
            },
            "type": "array"
          }
        },
        "required": [
          "providers"
        ],
        "type": "object"
      },
      "ProviderModel": {
        "properties": {
          "account_ids": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "context_window": {
            "description": "Context window size in tokens",
            "type": "integer"
          },
          "exposed_model": {
            "description": "Exposed model ID with api_prefix",
            "type": "string"
          },
          "id": {
            "description": "Provider model UUID",
            "type": "string"
          },
          "is_enabled": {
            "description": "Whitelisted for routing",
            "type": "boolean"
          },
          "last_synced_at": {
            "format": "date-time",
            "type": "string"
          },
          "memory_enabled": {
            "description": "Whether memory recall \u0026 extraction are enabled for this model",
            "type": "boolean"
          },
          "provider_id": {
            "description": "Owning provider ID",
            "type": "string"
          },
          "upstream_model": {
            "description": "Upstream model name",
            "type": "string"
          }
        },
        "required": [
          "id",
          "provider_id",
          "upstream_model",
          "exposed_model",
          "is_enabled"
        ],
        "type": "object"
      },
      "ProviderModelEnvelope": {
        "properties": {
          "model": {
            "$ref": "#/components/schemas/ProviderModel"
          }
        },
        "required": [
          "model"
        ],
        "type": "object"
      },
      "ProviderModelTestResponse": {
        "properties": {
          "account_id": {
            "description": "Account ID used for the model test",
            "type": "string"
          },
          "error": {
            "description": "Sanitized error message if unhealthy",
            "type": "string"
          },
          "exposed_model": {
            "description": "Exposed model ID with api_prefix",
            "type": "string"
          },
          "healthy": {
            "description": "True if completion succeeded",
            "type": "boolean"
          },
          "input_tokens": {
            "description": "Prompt/input token count",
            "type": "integer"
          },
          "latency_ms": {
            "description": "End-to-end latency in milliseconds",
            "type": "integer"
          },
          "output": {
            "description": "Sample output text generated by the model",
            "type": "string"
          },
          "output_tokens": {
            "description": "Generated completion token count",
            "type": "integer"
          },
          "provider_id": {
            "description": "Provider UUID",
            "type": "string"
          },
          "tokens_per_sec": {
            "description": "Output token generation rate (tokens per second)",
            "type": "number"
          },
          "total_tokens": {
            "description": "Total token count",
            "type": "integer"
          },
          "upstream_model": {
            "description": "Tested upstream model ID",
            "type": "string"
          }
        },
        "required": [
          "healthy",
          "provider_id",
          "upstream_model",
          "exposed_model",
          "input_tokens",
          "output_tokens",
          "total_tokens",
          "tokens_per_sec",
          "latency_ms"
        ],
        "type": "object"
      },
      "ProviderModelsResponse": {
        "properties": {
          "models": {
            "items": {
              "$ref": "#/components/schemas/ProviderModel"
            },
            "type": "array"
          },
          "provider_id": {
            "description": "Provider UUID",
            "type": "string"
          }
        },
        "required": [
          "provider_id",
          "models"
        ],
        "type": "object"
      },
      "ProviderProtocol": {
        "enum": [
          "openai_compat",
          "anthropic",
          "gemini_api",
          "cli_claude",
          "cli_codex",
          "cli_gemini",
          "cli_agy"
        ],
        "type": "string"
      },
      "ProviderSyncResponse": {
        "properties": {
          "account_id": {
            "description": "Account ID used for sync",
            "type": "string"
          },
          "models": {
            "items": {
              "$ref": "#/components/schemas/ProviderModel"
            },
            "type": "array"
          },
          "provider_id": {
            "description": "Provider UUID",
            "type": "string"
          },
          "synced": {
            "description": "Number of models synced",
            "type": "integer"
          }
        },
        "required": [
          "provider_id",
          "synced",
          "models"
        ],
        "type": "object"
      },
      "ProviderTestResponse": {
        "properties": {
          "account_id": {
            "description": "Account ID used for the connectivity test",
            "type": "string"
          },
          "error": {
            "description": "Sanitized error detail if unhealthy",
            "type": "string"
          },
          "healthy": {
            "description": "True if connectivity/health check succeeded",
            "type": "boolean"
          },
          "latency_ms": {
            "description": "Check duration in milliseconds",
            "type": "integer"
          }
        },
        "required": [
          "healthy",
          "latency_ms"
        ],
        "type": "object"
      },
      "ProviderUsageBreakdown": {
        "properties": {
          "error_requests": {
            "description": "Error count",
            "type": "integer"
          },
          "provider_id": {
            "description": "Provider ID",
            "type": "string"
          },
          "requests": {
            "description": "Request count",
            "type": "integer"
          },
          "tokens_saved": {
            "description": "Tokens saved",
            "type": "integer"
          },
          "tokens_total": {
            "description": "Total tokens",
            "type": "integer"
          }
        },
        "required": [
          "provider_id",
          "requests",
          "tokens_total",
          "tokens_saved",
          "error_requests"
        ],
        "type": "object"
      },
      "ReadinessResponse": {
        "properties": {
          "error": {
            "description": "Readiness failure detail",
            "type": "string"
          },
          "status": {
            "description": "ready or not_ready",
            "type": "string"
          }
        },
        "required": [
          "status"
        ],
        "type": "object"
      },
      "RefreshRequest": {
        "properties": {
          "refresh_token": {
            "description": "Opaque rotating refresh token",
            "type": "string"
          }
        },
        "required": [
          "refresh_token"
        ],
        "type": "object"
      },
      "RegisterRequest": {
        "properties": {
          "email": {
            "description": "User email",
            "type": "string"
          },
          "name": {
            "description": "Optional display name",
            "type": "string"
          },
          "password": {
            "description": "Password (hashed with Argon2id)",
            "type": "string"
          }
        },
        "required": [
          "email",
          "password"
        ],
        "type": "object"
      },
      "Role": {
        "enum": [
          "superadmin",
          "admin",
          "user"
        ],
        "type": "string"
      },
      "RoutingStrategy": {
        "enum": [
          "priority",
          "weighted",
          "dynamic",
          "round_robin"
        ],
        "type": "string"
      },
      "ServiceToken": {
        "properties": {
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "created_by": {
            "description": "Creator user ID",
            "type": [
              "string",
              "null"
            ]
          },
          "expires_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "description": "Service token UUID",
            "type": "string"
          },
          "last_used_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "description": "Token label",
            "type": "string"
          },
          "prefix": {
            "description": "Lookup prefix (mr_svc_...)",
            "type": "string"
          },
          "revoked_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "scopes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "id",
          "name",
          "prefix",
          "scopes",
          "created_at"
        ],
        "type": "object"
      },
      "ServiceTokenCreateResponse": {
        "properties": {
          "raw_token": {
            "description": "One-time raw service token (mr_svc_...)",
            "type": "string"
          },
          "token": {
            "$ref": "#/components/schemas/ServiceToken"
          }
        },
        "required": [
          "raw_token",
          "token"
        ],
        "type": "object"
      },
      "ServiceTokenListResponse": {
        "properties": {
          "service_tokens": {
            "items": {
              "$ref": "#/components/schemas/ServiceToken"
            },
            "type": "array"
          }
        },
        "required": [
          "service_tokens"
        ],
        "type": "object"
      },
      "SessionEpochSummary": {
        "properties": {
          "agent_id": {
            "description": "Optional agent scope",
            "type": "string"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "end_turn": {
            "description": "Last turn covered",
            "type": "integer"
          },
          "epoch_index": {
            "description": "Zero-based epoch index",
            "type": "integer"
          },
          "id": {
            "description": "Epoch summary UUID",
            "type": "string"
          },
          "session_id": {
            "description": "Session identifier",
            "type": "string"
          },
          "start_turn": {
            "description": "First turn covered",
            "type": "integer"
          },
          "summary": {
            "description": "Frozen prefix-cache-friendly summary",
            "type": "string"
          },
          "token_count": {
            "description": "Summary token count",
            "type": "integer"
          },
          "user_id": {
            "description": "Owning user UUID",
            "type": "string"
          }
        },
        "required": [
          "id",
          "user_id",
          "session_id",
          "epoch_index",
          "start_turn",
          "end_turn",
          "summary",
          "token_count"
        ],
        "type": "object"
      },
      "SettingsPatchRequest": {
        "properties": {
          "auto_extract_memory": {
            "description": "Toggle async memory extraction",
            "type": "boolean"
          },
          "caveman_output_enabled": {
            "description": "Toggle terse output directive",
            "type": "boolean"
          },
          "compression_enabled": {
            "description": "Toggle compression",
            "type": "boolean"
          },
          "compression_level": {
            "$ref": "#/components/schemas/CompressionLevel"
          },
          "custom_prompt_mode": {
            "$ref": "#/components/schemas/PromptMode"
          },
          "custom_system_prompt": {
            "description": "Custom system prompt content",
            "type": "string"
          },
          "enabled_compression_engines": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "epoch_summaries_enabled": {
            "description": "Toggle epoch summaries",
            "type": "boolean"
          },
          "memory_enabled": {
            "description": "Toggle memory recall",
            "type": "boolean"
          },
          "progressive_skill_disclosure": {
            "description": "Toggle progressive skill disclosure",
            "type": "boolean"
          },
          "skills_enabled": {
            "description": "Toggle skills",
            "type": "boolean"
          },
          "system_prompt_enabled": {
            "description": "Toggle custom system prompt",
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "SettingsPatchResponse": {
        "properties": {
          "effective_policy": {
            "$ref": "#/components/schemas/EffectivePolicy"
          },
          "settings": {
            "$ref": "#/components/schemas/UserSettings"
          }
        },
        "required": [
          "settings",
          "effective_policy"
        ],
        "type": "object"
      },
      "Skill": {
        "properties": {
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "description": {
            "description": "Short description for progressive disclosure manifest",
            "type": "string"
          },
          "id": {
            "description": "Skill UUID",
            "type": "string"
          },
          "instructions_md": {
            "description": "Full Markdown skill instructions",
            "type": "string"
          },
          "is_enabled": {
            "description": "Enabled flag",
            "type": "boolean"
          },
          "name": {
            "description": "Display name",
            "type": "string"
          },
          "owner_user_id": {
            "description": "Null for global skills or owning user UUID",
            "type": [
              "string",
              "null"
            ]
          },
          "slug": {
            "description": "Unique skill slug",
            "type": "string"
          },
          "token_estimate": {
            "description": "Estimated instruction tokens",
            "type": "integer"
          },
          "triggers": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "id",
          "slug",
          "name",
          "instructions_md",
          "token_estimate",
          "is_enabled"
        ],
        "type": "object"
      },
      "SkillEnvelope": {
        "properties": {
          "skill": {
            "$ref": "#/components/schemas/Skill"
          }
        },
        "required": [
          "skill"
        ],
        "type": "object"
      },
      "SkillInstallation": {
        "properties": {
          "always_on": {
            "description": "Inject full instructions regardless of triggers",
            "type": "boolean"
          },
          "id": {
            "description": "Installation UUID",
            "type": "string"
          },
          "installed_at": {
            "format": "date-time",
            "type": "string"
          },
          "is_enabled": {
            "description": "Installation enabled flag",
            "type": "boolean"
          },
          "scope_id": {
            "description": "Target API key ID, normalized combo name, or empty for global/user",
            "type": "string"
          },
          "scope_type": {
            "enum": [
              "global",
              "user",
              "api_key",
              "combo"
            ],
            "type": "string"
          },
          "skill": {
            "$ref": "#/components/schemas/Skill"
          },
          "skill_id": {
            "description": "Installed skill UUID",
            "type": "string"
          },
          "user_id": {
            "description": "Owning user UUID (empty string when scope_type is global)",
            "type": "string"
          }
        },
        "required": [
          "id",
          "user_id",
          "skill_id",
          "scope_type",
          "is_enabled",
          "installed_at"
        ],
        "type": "object"
      },
      "SkillInstallationEnvelope": {
        "properties": {
          "installation": {
            "$ref": "#/components/schemas/SkillInstallation"
          }
        },
        "required": [
          "installation"
        ],
        "type": "object"
      },
      "SkillListResponse": {
        "properties": {
          "skills": {
            "items": {
              "$ref": "#/components/schemas/Skill"
            },
            "type": "array"
          }
        },
        "required": [
          "skills"
        ],
        "type": "object"
      },
      "StatusResponse": {
        "properties": {
          "status": {
            "description": "Operation status (ok, revoked, deleted, updated)",
            "type": "string"
          }
        },
        "required": [
          "status"
        ],
        "type": "object"
      },
      "TestProviderModelRequest": {
        "properties": {
          "account_id": {
            "description": "Optional provider account ID to test",
            "type": "string"
          },
          "prompt": {
            "description": "Optional test instruction prompt",
            "type": "string"
          },
          "upstream_model": {
            "description": "Upstream model ID (or exposed model with prefix)",
            "type": "string"
          }
        },
        "required": [
          "upstream_model"
        ],
        "type": "object"
      },
      "TokenPairResponse": {
        "properties": {
          "access_token": {
            "description": "JWT access token",
            "type": "string"
          },
          "expires_at": {
            "format": "date-time",
            "type": "string"
          },
          "refresh_token": {
            "description": "Rotating refresh token",
            "type": "string"
          },
          "token_type": {
            "description": "Bearer",
            "type": "string"
          }
        },
        "required": [
          "access_token",
          "refresh_token",
          "token_type",
          "expires_at"
        ],
        "type": "object"
      },
      "UISessionResponse": {
        "properties": {
          "authenticated": {
            "description": "True when authenticated",
            "type": "boolean"
          },
          "expires_at": {
            "format": "date-time",
            "type": "string"
          },
          "user": {
            "$ref": "#/components/schemas/User"
          }
        },
        "required": [
          "authenticated",
          "user"
        ],
        "type": "object"
      },
      "UpsertCoreMemoryRequest": {
        "properties": {
          "agent_id": {
            "description": "Optional agent/workspace scope",
            "type": "string"
          },
          "content": {
            "description": "Pinned content",
            "type": "string"
          },
          "key": {
            "description": "Core memory key",
            "type": "string"
          },
          "user_verified": {
            "description": "Mark as user-verified",
            "type": "boolean"
          }
        },
        "required": [
          "key",
          "content"
        ],
        "type": "object"
      },
      "Usage": {
        "properties": {
          "completion_tokens": {
            "description": "Output tokens",
            "type": "integer"
          },
          "prompt_tokens": {
            "description": "Input tokens",
            "type": "integer"
          },
          "total_tokens": {
            "description": "Total tokens",
            "type": "integer"
          }
        },
        "required": [
          "prompt_tokens",
          "completion_tokens",
          "total_tokens"
        ],
        "type": "object"
      },
      "UsageLog": {
        "properties": {
          "account_id": {
            "description": "Provider account ID that served the request",
            "type": "string"
          },
          "api_key_id": {
            "description": "Virtual API key UUID",
            "type": "string"
          },
          "combo_name": {
            "description": "Combo name if routed via combo",
            "type": "string"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "error_code": {
            "description": "Error code if failed",
            "type": "string"
          },
          "id": {
            "description": "Usage log UUID",
            "type": "string"
          },
          "is_cli": {
            "description": "True when executed via official_cli",
            "type": "boolean"
          },
          "latency_ms": {
            "description": "Latency in milliseconds",
            "type": "integer"
          },
          "memory_hits": {
            "description": "Memory facts injected",
            "type": "integer"
          },
          "provider_id": {
            "description": "Provider ID",
            "type": "string"
          },
          "request_id": {
            "description": "HTTP request ID",
            "type": "string"
          },
          "requested_model": {
            "description": "Model requested by client",
            "type": "string"
          },
          "session_id": {
            "description": "Session ID",
            "type": "string"
          },
          "skills_used": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "status_code": {
            "description": "HTTP status code",
            "type": "integer"
          },
          "stream": {
            "description": "True for SSE streaming",
            "type": "boolean"
          },
          "tokens_completion": {
            "description": "Completion tokens",
            "type": "integer"
          },
          "tokens_compressed": {
            "description": "Compressed input tokens",
            "type": "integer"
          },
          "tokens_original": {
            "description": "Original input tokens",
            "type": "integer"
          },
          "tokens_prompt": {
            "description": "Prompt tokens",
            "type": "integer"
          },
          "tokens_saved": {
            "description": "Tokens saved by compression",
            "type": "integer"
          },
          "tokens_total": {
            "description": "Total tokens",
            "type": "integer"
          },
          "upstream_model": {
            "description": "Resolved upstream model",
            "type": "string"
          },
          "user_id": {
            "description": "User UUID",
            "type": "string"
          }
        },
        "required": [
          "id",
          "request_id",
          "user_id",
          "provider_id",
          "requested_model",
          "tokens_total",
          "tokens_saved",
          "status_code",
          "created_at"
        ],
        "type": "object"
      },
      "UsageResponse": {
        "properties": {
          "by_provider": {
            "items": {
              "$ref": "#/components/schemas/ProviderUsageBreakdown"
            },
            "type": "array"
          },
          "logs": {
            "items": {
              "$ref": "#/components/schemas/UsageLog"
            },
            "type": "array"
          },
          "summary": {
            "$ref": "#/components/schemas/UsageSummary"
          }
        },
        "required": [
          "summary",
          "by_provider",
          "logs"
        ],
        "type": "object"
      },
      "UsageSummary": {
        "properties": {
          "avg_latency_ms": {
            "description": "Average latency in milliseconds",
            "type": "number"
          },
          "error_requests": {
            "description": "Failed inference requests",
            "type": "integer"
          },
          "memory_hits": {
            "description": "Total memory facts recalled",
            "type": "integer"
          },
          "tokens_completion": {
            "description": "Completion tokens",
            "type": "integer"
          },
          "tokens_compressed": {
            "description": "Post-compression input tokens",
            "type": "integer"
          },
          "tokens_original": {
            "description": "Pre-compression input tokens",
            "type": "integer"
          },
          "tokens_prompt": {
            "description": "Prompt tokens",
            "type": "integer"
          },
          "tokens_saved": {
            "description": "Total tokens saved",
            "type": "integer"
          },
          "tokens_total": {
            "description": "Total billed tokens",
            "type": "integer"
          },
          "total_requests": {
            "description": "Total inference requests",
            "type": "integer"
          }
        },
        "required": [
          "total_requests",
          "error_requests",
          "tokens_prompt",
          "tokens_completion",
          "tokens_total",
          "tokens_original",
          "tokens_compressed",
          "tokens_saved",
          "memory_hits",
          "avg_latency_ms"
        ],
        "type": "object"
      },
      "User": {
        "properties": {
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "email": {
            "description": "Normalized email address",
            "type": "string"
          },
          "external_id": {
            "description": "External platform user identifier (e.g., Laravel user ID)",
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "description": "Internal UUID",
            "type": "string"
          },
          "is_active": {
            "description": "Account active flag",
            "type": "boolean"
          },
          "name": {
            "description": "Display name",
            "type": "string"
          },
          "plan_id": {
            "description": "Assigned plan ID",
            "type": [
              "string",
              "null"
            ]
          },
          "role": {
            "$ref": "#/components/schemas/Role"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "id",
          "email",
          "name",
          "role",
          "is_active",
          "created_at",
          "updated_at"
        ],
        "type": "object"
      },
      "UserEnvelope": {
        "properties": {
          "user": {
            "$ref": "#/components/schemas/User"
          }
        },
        "required": [
          "user"
        ],
        "type": "object"
      },
      "UserImportSkillsResponse": {
        "properties": {
          "imported": {
            "description": "Number of imported skills",
            "type": "integer"
          },
          "installations": {
            "items": {
              "$ref": "#/components/schemas/SkillInstallation"
            },
            "type": "array"
          },
          "skills": {
            "items": {
              "$ref": "#/components/schemas/Skill"
            },
            "type": "array"
          }
        },
        "required": [
          "imported",
          "skills"
        ],
        "type": "object"
      },
      "UserListResponse": {
        "properties": {
          "users": {
            "items": {
              "$ref": "#/components/schemas/User"
            },
            "type": "array"
          }
        },
        "required": [
          "users"
        ],
        "type": "object"
      },
      "UserMemoriesResponse": {
        "properties": {
          "core": {
            "items": {
              "$ref": "#/components/schemas/CoreMemory"
            },
            "type": "array"
          },
          "episodic": {
            "items": {
              "$ref": "#/components/schemas/EpisodicMemory"
            },
            "type": "array"
          },
          "epochs": {
            "items": {
              "$ref": "#/components/schemas/SessionEpochSummary"
            },
            "type": "array"
          }
        },
        "required": [
          "core",
          "episodic",
          "epochs"
        ],
        "type": "object"
      },
      "UserSettings": {
        "properties": {
          "auto_extract_memory": {
            "description": "Enable async post-response memory extraction",
            "type": "boolean"
          },
          "caveman_output_enabled": {
            "description": "Enable terse output directive",
            "type": "boolean"
          },
          "compression_enabled": {
            "description": "Enable stacked context compression",
            "type": "boolean"
          },
          "compression_level": {
            "$ref": "#/components/schemas/CompressionLevel"
          },
          "custom_prompt_mode": {
            "$ref": "#/components/schemas/PromptMode"
          },
          "custom_system_prompt": {
            "description": "User system prompt template",
            "type": "string"
          },
          "enabled_compression_engines": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "epoch_summaries_enabled": {
            "description": "Enable Billion-Context epoch summaries",
            "type": "boolean"
          },
          "memory_enabled": {
            "description": "Enable per-user memory injection",
            "type": "boolean"
          },
          "progressive_skill_disclosure": {
            "description": "Enable progressive disclosure manifest",
            "type": "boolean"
          },
          "skills_enabled": {
            "description": "Enable skill injection",
            "type": "boolean"
          },
          "system_prompt_enabled": {
            "description": "Enable custom system prompt",
            "type": "boolean"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          },
          "user_id": {
            "description": "Owning user ID",
            "type": "string"
          }
        },
        "required": [
          "user_id",
          "compression_level",
          "custom_prompt_mode",
          "updated_at"
        ],
        "type": "object"
      },
      "UserSkillsResponse": {
        "properties": {
          "allow_skill_installation": {
            "description": "Whether plan allows skill installation",
            "type": "boolean"
          },
          "installed": {
            "items": {
              "$ref": "#/components/schemas/SkillInstallation"
            },
            "type": "array"
          },
          "max_installed_skills": {
            "description": "Plan maximum installed skills",
            "type": "integer"
          },
          "skills": {
            "items": {
              "$ref": "#/components/schemas/Skill"
            },
            "type": "array"
          },
          "skills_enabled": {
            "description": "Effective skills_enabled policy",
            "type": "boolean"
          }
        },
        "required": [
          "skills",
          "installed",
          "max_installed_skills",
          "allow_skill_installation",
          "skills_enabled"
        ],
        "type": "object"
      },
      "VerifyCLIRequest": {
        "properties": {
          "cli_binary": {
            "description": "Optional binary path override",
            "type": "string"
          },
          "cli_home": {
            "description": "Optional isolated CLI HOME path",
            "type": "string"
          },
          "protocol": {
            "description": "CLI protocol (cli_agy | cli_claude | cli_codex | cli_gemini)",
            "type": "string"
          }
        },
        "required": [
          "protocol"
        ],
        "type": "object"
      },
      "VerifyProviderAccountResponse": {
        "properties": {
          "account": {
            "$ref": "#/components/schemas/ProviderAccount"
          },
          "enabled": {
            "description": "Account enabled state after verification",
            "type": "boolean"
          },
          "healthy": {
            "description": "Whether verification succeeded",
            "type": "boolean"
          },
          "verify": {
            "$ref": "#/components/schemas/CLIVerifyResult"
          }
        },
        "required": [
          "healthy",
          "enabled",
          "account",
          "verify"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "AnthropicAPIKeyHeader": {
        "description": "Virtual LLM API key (mr_live_...) passed via X-API-Key header (Anthropic SDK compatible)",
        "in": "header",
        "name": "X-API-Key",
        "type": "apiKey"
      },
      "BearerJWT": {
        "bearerFormat": "JWT",
        "description": "User or Admin/Superadmin JWT access token from /api/v1/auth/login",
        "scheme": "bearer",
        "type": "http"
      },
      "ServiceTokenBearer": {
        "bearerFormat": "mr_svc_...",
        "description": "Scoped server-to-server Laravel Service Token passed as Authorization: Bearer mr_svc_...",
        "scheme": "bearer",
        "type": "http"
      },
      "ServiceTokenHeader": {
        "description": "Alternative header for passing a scoped mr_svc_... Service Token",
        "in": "header",
        "name": "X-Service-Token",
        "type": "apiKey"
      },
      "VirtualAPIKeyBearer": {
        "bearerFormat": "mr_live_...",
        "description": "Per-user virtual LLM API key (mr_live_...) passed as Authorization: Bearer mr_live_...",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "description": "Lightweight Go LLM API gateway, multi-provider aggregator, stacked context compression engine, per-user hybrid memory system, and Laravel-ready multi-tenant control plane.",
    "title": "MiniRoute Gateway \u0026 Control Plane API",
    "version": "0.1.0"
  },
  "jsonSchemaDialect": "https://spec.openapis.org/oas/3.1/dialect/base",
  "openapi": "3.1.0",
  "paths": {
    "/": {
      "get": {
        "description": "Serves the embedded single-page management console HTML shell protected by strict CSP, X-Frame-Options, and HttpOnly SameSite=Lax cookie sessions.",
        "responses": {
          "200": {
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Management console HTML page"
          }
        },
        "summary": "Authenticated management web UI",
        "tags": [
          "System"
        ]
      }
    },
    "/api/v1/admin/cli/auto-setup": {
      "post": {
        "description": "Automatically creates/updates official_cli providers and accounts using resolved binary paths and detected cli_home profiles, optionally enables global CLI execution, and syncs models.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutoSetupCLIRequest"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminCLIAutoSetupResponse"
                }
              }
            },
            "description": "Auto-setup summary"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Auto-setup detected CLI providers and accounts",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/cli/config": {
      "get": {
        "description": "Returns whether global official CLI subprocess execution (MINIROUTE_CLI_ENABLED) is currently active, its configuration source, and concurrency/timeout limits.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminCLIConfig"
                }
              }
            },
            "description": "Global CLI config"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Get global CLI execution configuration",
        "tags": [
          "Admin"
        ]
      },
      "patch": {
        "description": "Persists and immediately applies the global official CLI execution toggle without requiring a server restart.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchAdminCLIConfigRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminCLIConfig"
                }
              }
            },
            "description": "Updated global CLI config"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Toggle global CLI execution",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/cli/detect": {
      "get": {
        "description": "Scans PATH and standard binary directories for official CLIs (agy, claude, codex, gemini) and inspects default host HOME plus configured profile roots without reading or extracting OAuth tokens.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminCLIDetectResponse"
                }
              }
            },
            "description": "Detected CLI binaries and accounts"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Detect installed CLIs and logged-in profiles",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/cli/prepare-account": {
      "post": {
        "description": "Creates a new isolated cli_home directory (~/.miniroute/cli-homes/\u003ccli\u003e/\u003cname\u003e), registers the account as disabled pending login, and returns the copyable native login command.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PrepareCLIProfileRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrepareCLIProfileResponse"
                }
              }
            },
            "description": "Provisioned CLI account"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Provision isolated CLI profile account",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/cli/verify": {
      "post": {
        "description": "Runs a bounded non-destructive live verification probe against an official CLI binary and optional isolated cli_home.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VerifyCLIRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CLIVerifyResult"
                }
              }
            },
            "description": "Live verification result"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Live verify a CLI profile",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/combos": {
      "get": {
        "description": "Lists routing combos and their targets.",
        "parameters": [
          {
            "description": "Filter to enabled combos only",
            "in": "query",
            "name": "enabled_only",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ComboListResponse"
                }
              }
            },
            "description": "Combos list"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "List combos",
        "tags": [
          "Admin"
        ]
      },
      "post": {
        "description": "Creates a named routing combo with priority, weighted, or dynamic strategy.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateComboRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ComboEnvelope"
                }
              }
            },
            "description": "Created combo"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Combo name conflict"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Create combo",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/combos/{id}": {
      "delete": {
        "description": "Deletes a combo.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Combo deleted"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Delete combo",
        "tags": [
          "Admin"
        ]
      },
      "get": {
        "description": "Fetches a combo and its ordered/weighted targets.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ComboEnvelope"
                }
              }
            },
            "description": "Combo record"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Get combo",
        "tags": [
          "Admin"
        ]
      },
      "patch": {
        "description": "Updates combo routing strategy, cooldown, retries, or targets.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchComboRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ComboEnvelope"
                }
              }
            },
            "description": "Updated combo"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Combo name conflict"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Update combo",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/compression-presets": {
      "get": {
        "description": "Lists stacked compression presets.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompressionPresetListResponse"
                }
              }
            },
            "description": "Compression presets"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "List compression presets",
        "tags": [
          "Admin"
        ]
      },
      "post": {
        "description": "Creates a compression preset configuring stages (lite, session_dedup, rtk, headroom, ccr, caveman) and budgets.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCompressionPresetRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompressionPresetEnvelope"
                }
              }
            },
            "description": "Created compression preset"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Preset name conflict"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Create compression preset",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/compression-presets/{id}": {
      "delete": {
        "description": "Deletes a compression preset.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Compression preset deleted"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Delete compression preset",
        "tags": [
          "Admin"
        ]
      },
      "patch": {
        "description": "Updates an existing compression preset.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchCompressionPresetRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompressionPresetEnvelope"
                }
              }
            },
            "description": "Updated compression preset"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Preset name conflict"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Update compression preset",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/memory/config": {
      "get": {
        "description": "Returns the dedicated model or combo used for background memory extraction and epoch summarization.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminMemoryConfig"
                }
              }
            },
            "description": "Memory extractor config"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Get memory extractor configuration",
        "tags": [
          "Admin"
        ]
      },
      "patch": {
        "description": "Sets or clears the dedicated model/combo override used for async memory extraction and epoch summarization.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchAdminMemoryConfigRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminMemoryConfig"
                }
              }
            },
            "description": "Updated memory extractor config"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Set memory extractor model",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/plans": {
      "get": {
        "description": "Lists all subscription plans and feature entitlements.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlanListResponse"
                }
              }
            },
            "description": "Plans list"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "List plans",
        "tags": [
          "Admin"
        ]
      },
      "patch": {
        "description": "Patches a plan identified by id or slug in the request body.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchPlanRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlanEnvelope"
                }
              }
            },
            "description": "Updated plan"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Plan conflict"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Update plan by ID or slug",
        "tags": [
          "Admin"
        ]
      },
      "post": {
        "description": "Creates a new plan defining quotas, exposure rules, and allowed user toggles.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePlanRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlanEnvelope"
                }
              }
            },
            "description": "Created plan"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Plan conflict"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Create plan",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/plans/{id}": {
      "patch": {
        "description": "Patches a plan identified by its path ID.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchPlanRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlanEnvelope"
                }
              }
            },
            "description": "Updated plan"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Plan conflict"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Update plan by ID",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/prompt-policies": {
      "get": {
        "description": "Lists system prompt injection policies optionally filtered by scope_type and scope_id.",
        "parameters": [
          {
            "description": "Filter by scope_type (global | combo | user | api_key)",
            "in": "query",
            "name": "scope_type",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter by scope_id",
            "in": "query",
            "name": "scope_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PromptPolicyListResponse"
                }
              }
            },
            "description": "Prompt policies"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "List prompt policies",
        "tags": [
          "Admin"
        ]
      },
      "post": {
        "description": "Creates a system prompt policy for global, combo, user, or api_key scope.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreatePromptPolicyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PromptPolicyEnvelope"
                }
              }
            },
            "description": "Created prompt policy"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Create prompt policy",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/prompt-policies/{id}": {
      "delete": {
        "description": "Deletes a prompt policy.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Prompt policy deleted"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Delete prompt policy",
        "tags": [
          "Admin"
        ]
      },
      "patch": {
        "description": "Updates an existing prompt policy.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchPromptPolicyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PromptPolicyEnvelope"
                }
              }
            },
            "description": "Updated prompt policy"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Update prompt policy",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/providers": {
      "get": {
        "description": "Lists configured HTTP and official CLI providers with api_prefix metadata.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderListResponse"
                }
              }
            },
            "description": "Providers list"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "List providers",
        "tags": [
          "Admin"
        ]
      },
      "post": {
        "description": "Registers a new HTTP aggregator/provider or official CLI provider with unique api_prefix.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateProviderRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderEnvelope"
                }
              }
            },
            "description": "Created provider"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input or master_key_not_configured"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Provider name or api_prefix conflict"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Create provider",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/providers/{id}": {
      "delete": {
        "description": "Deletes a provider and reloads the routing registry.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Provider deleted"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Delete provider",
        "tags": [
          "Admin"
        ]
      },
      "get": {
        "description": "Fetches a single provider by ID.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderEnvelope"
                }
              }
            },
            "description": "Provider record"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Get provider",
        "tags": [
          "Admin"
        ]
      },
      "patch": {
        "description": "Updates provider transport, api_prefix, encrypted API key, CLI toggle, or concurrency limits.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchProviderRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderEnvelope"
                }
              }
            },
            "description": "Updated provider"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input or master_key_not_configured"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Provider conflict"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Update provider",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/providers/{id}/accounts": {
      "get": {
        "description": "Lists accounts configured under a provider and its account routing strategy.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderAccountListResponse"
                }
              }
            },
            "description": "Provider accounts"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "List provider accounts",
        "tags": [
          "Admin"
        ]
      },
      "post": {
        "description": "Adds an HTTP API key/header account or an isolated official CLI profile account under a provider.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProviderAccountInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderAccountEnvelope"
                }
              }
            },
            "description": "Created account"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Account name conflict"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Create provider account",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/providers/{id}/accounts/{accountID}": {
      "delete": {
        "description": "Deletes an account from a provider and reloads the routing registry.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Provider account UUID",
            "in": "path",
            "name": "accountID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Account deleted"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Delete provider account",
        "tags": [
          "Admin"
        ]
      },
      "patch": {
        "description": "Updates credentials, priority, weight, CLI profile, or enabled state for a provider account.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Provider account UUID",
            "in": "path",
            "name": "accountID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchProviderAccountRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderAccountEnvelope"
                }
              }
            },
            "description": "Updated account"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Account name conflict"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Update provider account",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/providers/{id}/accounts/{accountID}/test": {
      "post": {
        "description": "Runs a health check against a specific account on a provider.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Provider account UUID",
            "in": "path",
            "name": "accountID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderTestResponse"
                }
              }
            },
            "description": "Provider account health check result"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Test provider account connectivity",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/providers/{id}/accounts/{accountID}/verify": {
      "post": {
        "description": "Runs a live verification probe for a CLI account and enables it automatically when healthy unless enable=false.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Provider account UUID",
            "in": "path",
            "name": "accountID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Enable account automatically on healthy verify (default true)",
            "in": "query",
            "name": "enable",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerifyProviderAccountResponse"
                }
              }
            },
            "description": "Verify \u0026 enable result"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Verify \u0026 enable CLI provider account",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/providers/{id}/models": {
      "get": {
        "description": "Lists synced and whitelisted models for a provider.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter to enabled models only",
            "in": "query",
            "name": "enabled_only",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderModelsResponse"
                }
              }
            },
            "description": "Provider models"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "List provider models",
        "tags": [
          "Admin"
        ]
      },
      "patch": {
        "description": "Enables or disables an upstream model using upstream_model in the JSON body. Use this body-mode endpoint for slash-containing OpenRouter/HuggingFace model IDs (e.g., openai/gpt-4o, meta-llama/Llama-3.3-70B).",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchProviderModelRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderModelEnvelope"
                }
              }
            },
            "description": "Updated provider model"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Toggle provider model whitelist (body)",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/providers/{id}/models/test": {
      "post": {
        "description": "Sends a short instruction prompt to the specified upstream model and returns its output sample along with input_tokens, output_tokens, tokens_per_sec, and latency_ms.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TestProviderModelRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderModelTestResponse"
                }
              }
            },
            "description": "Model benchmark result"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Benchmark test a single provider model",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/providers/{id}/models/{model}": {
      "patch": {
        "description": "Enables or disables the specified single-segment upstream model. For slash-containing OpenRouter/HuggingFace model IDs, use body-mode PATCH /api/v1/admin/providers/{id}/models.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Upstream model identifier (single path segment)",
            "in": "path",
            "name": "model",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchProviderModelRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderModelEnvelope"
                }
              }
            },
            "description": "Updated provider model"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Toggle provider model whitelist (path)",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/providers/{id}/sync": {
      "post": {
        "description": "Fetches the upstream /models catalog and upserts prefixed models into provider_models.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Optional provider account ID to sync with",
            "in": "query",
            "name": "account_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderSyncResponse"
                }
              }
            },
            "description": "Synced provider models"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Upstream sync failed"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Sync upstream provider models",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/providers/{id}/test": {
      "post": {
        "description": "Runs a live health check or CLI binary check and returns sanitized latency and status.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Optional provider account ID to test",
            "in": "query",
            "name": "account_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderTestResponse"
                }
              }
            },
            "description": "Provider health check result"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Test provider connectivity",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/service-tokens": {
      "get": {
        "description": "Lists service tokens without exposing raw secrets.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceTokenListResponse"
                }
              }
            },
            "description": "Service tokens"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "List service tokens",
        "tags": [
          "Admin"
        ]
      },
      "post": {
        "description": "Creates a scoped mr_svc_... service token (superadmin or admin service token required).",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateServiceTokenRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceTokenCreateResponse"
                }
              }
            },
            "description": "Created service token (raw_token shown once)"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Create service token",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/service-tokens/{id}": {
      "delete": {
        "description": "Revokes a service token immediately.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Service token revoked"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Revoke service token",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/settings": {
      "get": {
        "description": "Returns live and persisted runtime settings (CLI execution, concurrency/timeouts, private provider URL toggle, memory extractor settings, log level) plus CLI binary detection and startup diagnostics.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminSystemSettings"
                }
              }
            },
            "description": "System settings"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Get gateway system \u0026 runtime settings",
        "tags": [
          "Admin"
        ]
      },
      "patch": {
        "description": "Persists and immediately applies one or more runtime gateway settings without restarting MiniRoute.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchAdminSystemSettingsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminSystemSettings"
                }
              }
            },
            "description": "Updated system settings"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Update gateway system \u0026 runtime settings",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/skills": {
      "get": {
        "description": "Lists all global skills or skills visible to a given user_id.",
        "parameters": [
          {
            "description": "Optional user ID filter",
            "in": "query",
            "name": "user_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SkillListResponse"
                }
              }
            },
            "description": "Skills list"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "List skills",
        "tags": [
          "Admin"
        ]
      },
      "post": {
        "description": "Creates a global or user-scoped progressive-disclosure skill.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSkillRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SkillEnvelope"
                }
              }
            },
            "description": "Created skill"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Skill slug conflict"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Create skill",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/skills/import": {
      "post": {
        "description": "Imports one or more global skills from a skills.sh CLI command, skills.sh URL, GitHub URL, or raw GitHub .md file, with optional immediate global installation.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportSkillRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminImportSkillsResponse"
                }
              }
            },
            "description": "Imported global skills"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid skill source"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Skill slug conflict"
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Upstream fetch failed"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Import global skills from skills.sh or GitHub",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/skills/install": {
      "post": {
        "description": "Attaches a global skill gateway-wide across all eligible users.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdminInstallSkillRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SkillInstallationEnvelope"
                }
              }
            },
            "description": "Installed global skill"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Skill cannot be installed globally or is already installed"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Install skill globally",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/skills/install/{installID}": {
      "delete": {
        "description": "Removes a gateway-wide global skill installation.",
        "parameters": [
          {
            "description": "Global installation UUID",
            "in": "path",
            "name": "installID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Global skill uninstalled"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Uninstall global skill",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/skills/installations": {
      "get": {
        "description": "Lists gateway-wide skill installations with scope_type='global'.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminSkillInstallationsResponse"
                }
              }
            },
            "description": "Global skill installations"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "List global skill installations",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/skills/{id}": {
      "delete": {
        "description": "Deletes a skill.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Skill deleted"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Delete skill",
        "tags": [
          "Admin"
        ]
      },
      "patch": {
        "description": "Updates a skill definition.",
        "parameters": [
          {
            "description": "Resource ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchSkillRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SkillEnvelope"
                }
              }
            },
            "description": "Updated skill"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Skill slug conflict"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Update skill",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/usage": {
      "get": {
        "description": "Aggregates gateway-wide or filtered usage, compression savings, memory hits, and per-provider breakdowns.",
        "parameters": [
          {
            "description": "Filter by user ID or external_id",
            "in": "query",
            "name": "user_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter by provider ID",
            "in": "query",
            "name": "provider_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter by provider account ID",
            "in": "query",
            "name": "account_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Start timestamp (RFC3339 or YYYY-MM-DD, inclusive UTC start of day)",
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End timestamp (RFC3339 or YYYY-MM-DD, inclusive UTC end of day)",
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Maximum usage logs to return",
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Pagination offset",
            "in": "query",
            "name": "offset",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageResponse"
                }
              }
            },
            "description": "Aggregated usage analytics"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Global usage and token savings analytics",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/users": {
      "get": {
        "description": "Lists users with limit/offset pagination.",
        "parameters": [
          {
            "description": "Page size (1..200, default 50)",
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Pagination offset",
            "in": "query",
            "name": "offset",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserListResponse"
                }
              }
            },
            "description": "Users list"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "List users",
        "tags": [
          "Admin"
        ]
      },
      "post": {
        "description": "Creates a new user or idempotently syncs an existing user matched by external_id.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdminUserSyncRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminUserSyncResponse"
                }
              }
            },
            "description": "Synced existing user"
          },
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminUserSyncResponse"
                }
              }
            },
            "description": "Created user"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Email or external_id conflict"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Create or sync user",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/admin/users/{id}": {
      "get": {
        "description": "Fetches a user by internal UUID or Laravel external_id.",
        "parameters": [
          {
            "description": "User internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserEnvelope"
                }
              }
            },
            "description": "User record"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Get user",
        "tags": [
          "Admin"
        ]
      },
      "patch": {
        "description": "Updates user profile, active status, role, external_id, or assigned plan_id.",
        "parameters": [
          {
            "description": "User internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdminPatchUserRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserEnvelope"
                }
              }
            },
            "description": "Updated user"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Admin or superadmin role required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Conflict (email/external_id conflict or last_superadmin when demoting/deactivating the last active superadmin)"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Update user",
        "tags": [
          "Admin"
        ]
      }
    },
    "/api/v1/auth/login": {
      "post": {
        "description": "Authenticates email/password and issues JWT access and refresh tokens.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            },
            "description": "Authenticated user and tokens"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid credentials"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User inactive"
          }
        },
        "summary": "Login user",
        "tags": [
          "Auth"
        ]
      }
    },
    "/api/v1/auth/logout": {
      "post": {
        "description": "Revokes the supplied refresh token.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefreshRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Logged out"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid refresh token"
          }
        },
        "summary": "Logout session",
        "tags": [
          "Auth"
        ]
      }
    },
    "/api/v1/auth/refresh": {
      "post": {
        "description": "Exchanges a valid refresh token for a new token pair; reuse revokes the token family.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefreshRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenPairResponse"
                }
              }
            },
            "description": "New token pair"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid, expired, or reused refresh token"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User inactive"
          }
        },
        "summary": "Rotate refresh token",
        "tags": [
          "Auth"
        ]
      }
    },
    "/api/v1/auth/register": {
      "post": {
        "description": "Registers a new user with Argon2id password hashing and returns JWT + rotating refresh token.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RegisterRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            },
            "description": "Registered user and tokens"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Email already registered"
          }
        },
        "summary": "Register user",
        "tags": [
          "Auth"
        ]
      }
    },
    "/api/v1/auth/session": {
      "get": {
        "description": "Validates HttpOnly session cookie or Bearer JWT and returns active user metadata.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UISessionResponse"
                }
              }
            },
            "description": "Authenticated browser session"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthenticated or expired"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User inactive or cross-site request blocked"
          }
        },
        "summary": "Get active browser session",
        "tags": [
          "Auth"
        ]
      },
      "post": {
        "description": "Authenticates email/password and sets HttpOnly SameSite=Lax cookies without returning raw tokens to JS. Requires X-MiniRoute-CSRF: 1.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UISessionResponse"
                }
              }
            },
            "description": "Session established"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid credentials"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "CSRF validation failed or user inactive"
          }
        },
        "summary": "Sign in for Web UI (HttpOnly cookies)",
        "tags": [
          "Auth"
        ]
      }
    },
    "/api/v1/auth/session/logout": {
      "post": {
        "description": "Revokes refresh cookie, clears session cookies, and sends Clear-Site-Data. Requires X-MiniRoute-CSRF: 1.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Session closed"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "CSRF validation failed"
          }
        },
        "summary": "Logout Web UI session",
        "tags": [
          "Auth"
        ]
      }
    },
    "/api/v1/auth/session/refresh": {
      "post": {
        "description": "Rotates the HttpOnly miniroute_refresh cookie and renews miniroute_access. Requires X-MiniRoute-CSRF: 1.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UISessionResponse"
                }
              }
            },
            "description": "Session rotated"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Missing, invalid, or reused refresh cookie"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "CSRF validation failed or user inactive"
          }
        },
        "summary": "Refresh Web UI HttpOnly session",
        "tags": [
          "Auth"
        ]
      }
    },
    "/api/v1/auth/session/register": {
      "post": {
        "description": "Creates a new account and sets HttpOnly SameSite=Lax session cookies. Requires X-MiniRoute-CSRF: 1.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RegisterRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UISessionResponse"
                }
              }
            },
            "description": "Registered and session established"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid input"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "CSRF validation failed"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Email already exists"
          }
        },
        "summary": "Register user for Web UI (HttpOnly cookies)",
        "tags": [
          "Auth"
        ]
      }
    },
    "/api/v1/me/entitlements": {
      "get": {
        "description": "Returns user profile, assigned plan, user toggles, and resolved EffectivePolicy (Plan AND UserToggle).",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntitlementsResponse"
                }
              }
            },
            "description": "Entitlements and effective policy"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Get user entitlements and effective policy",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/keys": {
      "get": {
        "description": "Lists virtual API keys belonging strictly to the target user.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIKeyListResponse"
                }
              }
            },
            "description": "User API keys"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "List user virtual API keys",
        "tags": [
          "Self-Service (/me)"
        ]
      },
      "post": {
        "description": "Creates a new virtual API key (mr_live_...) bounded by the user's plan exposure mode and limits.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAPIKeyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIKeyCreateResponse"
                }
              }
            },
            "description": "Created virtual API key (raw_key shown once)"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid API key parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Issue scoped virtual API key",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/keys/{id}": {
      "delete": {
        "description": "Revokes a virtual API key owned by the user.",
        "parameters": [
          {
            "description": "Virtual API key ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Key revoked"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Revoke virtual API key",
        "tags": [
          "Self-Service (/me)"
        ]
      },
      "patch": {
        "description": "Enables or disables memory recall and extraction for a virtual API key owned by the user.",
        "parameters": [
          {
            "description": "Virtual API key ID",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchAPIKeyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIKeyEnvelope"
                }
              }
            },
            "description": "Updated virtual API key"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid payload"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Update virtual API key memory breaker",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/memories": {
      "get": {
        "description": "Returns core profile memories, active episodic facts, and session epoch summaries strictly scoped to the user.",
        "parameters": [
          {
            "description": "Optional agent/workspace scope filter (defaults to 'default')",
            "in": "query",
            "name": "agent_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Optional session scope filter for epochs",
            "in": "query",
            "name": "session_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Optional FTS5 search query for episodic memories",
            "in": "query",
            "name": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Maximum episodic facts to return (1..200, default 50)",
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserMemoriesResponse"
                }
              }
            },
            "description": "User memories across all three tiers"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "List or search user memories",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/memories/core": {
      "put": {
        "description": "Creates or updates a pinned core profile preference or constraint for the user.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertCoreMemoryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CoreMemoryEnvelope"
                }
              }
            },
            "description": "Saved core memory"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid core memory payload"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Upsert core profile memory",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/memories/core/{memoryID}": {
      "delete": {
        "description": "Deletes a core profile memory owned by the user.",
        "parameters": [
          {
            "description": "Core memory ID",
            "in": "path",
            "name": "memoryID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Core memory deleted"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Delete core profile memory",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/memories/episodic": {
      "post": {
        "description": "Manually adds a user-verified or episodic fact to the user's FTS5 memory store.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateEpisodicMemoryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EpisodicMemoryEnvelope"
                }
              }
            },
            "description": "Created episodic memory"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid episodic memory payload"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Create episodic memory fact",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/memories/episodic/{memoryID}": {
      "delete": {
        "description": "Deletes an episodic memory fact owned by the user.",
        "parameters": [
          {
            "description": "Episodic memory ID",
            "in": "path",
            "name": "memoryID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Episodic memory deleted"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Delete episodic memory fact",
        "tags": [
          "Self-Service (/me)"
        ]
      },
      "patch": {
        "description": "Edits or marks an episodic fact as user-verified.",
        "parameters": [
          {
            "description": "Episodic memory ID",
            "in": "path",
            "name": "memoryID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchEpisodicMemoryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EpisodicMemoryEnvelope"
                }
              }
            },
            "description": "Updated episodic memory"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid update payload"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Update episodic memory fact",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/memories/epochs": {
      "delete": {
        "description": "Deletes compacted Billion-Context epoch summaries for the user for a given session_id (and optional agent_id).",
        "parameters": [
          {
            "description": "Optional agent scope filter (defaults to 'default')",
            "in": "query",
            "name": "agent_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Required session ID to clear",
            "in": "query",
            "name": "session_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Session epochs cleared"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Missing session_id query parameter"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Clear session epoch summaries",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/playground/chat": {
      "post": {
        "description": "Executes an authenticated OpenAI-compatible chat completion or SSE stream for interactive testing in the Playground.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenAIChatCompletionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIChatCompletionResponse"
                }
              }
            },
            "description": "Chat completion JSON or SSE stream"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIErrorEnvelope"
                }
              }
            },
            "description": "Model forbidden or CSRF rejected"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIErrorEnvelope"
                }
              }
            },
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Run Playground chat completion",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/playground/models": {
      "get": {
        "description": "Lists all visible models and combos available to test in the authenticated Playground.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlaygroundModelsResponse"
                }
              }
            },
            "description": "Playground model and combo list"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "List Playground models and combos",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/settings": {
      "patch": {
        "description": "Updates per-user feature toggles validated against the user's assigned plan entitlements (returns 403 if disallowed by plan).",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SettingsPatchRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SettingsPatchResponse"
                }
              }
            },
            "description": "Updated settings and effective policy"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid setting value"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Update user feature toggles",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/skills": {
      "get": {
        "description": "Lists skills visible to the user along with the user's installed skills.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserSkillsResponse"
                }
              }
            },
            "description": "Visible skills and user installations"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "List user skills and installations",
        "tags": [
          "Self-Service (/me)"
        ]
      },
      "post": {
        "description": "Creates a private skill owned by the user.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSkillRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SkillEnvelope"
                }
              }
            },
            "description": "Created skill"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid skill input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Skill slug conflict"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Create user-owned skill",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/skills/import": {
      "post": {
        "description": "Imports one or more private user-owned skills from a skills.sh CLI command (e.g. `npx skills add https://github.com/owner/repo --skill name`), skills.sh URL, GitHub repository/blob URL, or raw GitHub .md file URL, with optional immediate installation.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportSkillRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserImportSkillsResponse"
                }
              }
            },
            "description": "Imported skills"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid skill source or scope"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Skill import disallowed or quota exceeded"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Skill slug conflict"
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Upstream fetch failed"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Import skills from skills.sh or GitHub",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/skills/install": {
      "post": {
        "description": "Attaches a global or user-owned skill to the user, an API key, or a combo. For scope_type=combo, scope_id accepts a combo UUID or combo name and is normalized to the combo name.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InstallSkillRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SkillInstallationEnvelope"
                }
              }
            },
            "description": "Installed skill"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid installation payload"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Skill is already installed in this scope (skill_already_installed)"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Install skill for user",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/skills/install/{installID}": {
      "delete": {
        "description": "Removes a skill installation belonging to the user.",
        "parameters": [
          {
            "description": "Skill installation ID",
            "in": "path",
            "name": "installID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Skill uninstalled"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Uninstall skill",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/skills/{skillID}": {
      "delete": {
        "description": "Deletes a custom skill owned by the user.",
        "parameters": [
          {
            "description": "Skill ID",
            "in": "path",
            "name": "skillID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Skill deleted"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Delete user-owned skill",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/me/usage": {
      "get": {
        "description": "Returns aggregated token usage, compression savings, memory hits, per-provider breakdown, and recent logs for the user.",
        "parameters": [
          {
            "description": "Filter by provider ID",
            "in": "query",
            "name": "provider_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter by provider account ID",
            "in": "query",
            "name": "account_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Start timestamp (RFC3339 or YYYY-MM-DD, inclusive UTC start of day)",
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End timestamp (RFC3339 or YYYY-MM-DD, inclusive UTC end of day)",
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Maximum usage logs to return",
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Pagination offset",
            "in": "query",
            "name": "offset",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageResponse"
                }
              }
            },
            "description": "User usage analytics"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid date range filter"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "BearerJWT": []
          }
        ],
        "summary": "Query user usage and token savings",
        "tags": [
          "Self-Service (/me)"
        ]
      }
    },
    "/api/v1/users/{id}/entitlements": {
      "get": {
        "description": "Returns user profile, assigned plan, user toggles, and resolved EffectivePolicy (Plan AND UserToggle).",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntitlementsResponse"
                }
              }
            },
            "description": "Entitlements and effective policy"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Get user entitlements and effective policy",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      }
    },
    "/api/v1/users/{id}/keys": {
      "get": {
        "description": "Lists virtual API keys belonging strictly to the target user.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIKeyListResponse"
                }
              }
            },
            "description": "User API keys"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "List user virtual API keys",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      },
      "post": {
        "description": "Creates a new virtual API key (mr_live_...) bounded by the user's plan exposure mode and limits.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAPIKeyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIKeyCreateResponse"
                }
              }
            },
            "description": "Created virtual API key (raw_key shown once)"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid API key parameters"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Issue scoped virtual API key",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      }
    },
    "/api/v1/users/{id}/keys/{keyID}": {
      "delete": {
        "description": "Revokes a virtual API key owned by the user.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Virtual API key ID",
            "in": "path",
            "name": "keyID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Key revoked"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Revoke virtual API key",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      },
      "patch": {
        "description": "Enables or disables memory recall and extraction for a virtual API key owned by the user.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Virtual API key ID",
            "in": "path",
            "name": "keyID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchAPIKeyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIKeyEnvelope"
                }
              }
            },
            "description": "Updated virtual API key"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid payload"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Update virtual API key memory breaker",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      }
    },
    "/api/v1/users/{id}/memories": {
      "get": {
        "description": "Returns core profile memories, active episodic facts, and session epoch summaries strictly scoped to the user.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Optional agent/workspace scope filter (defaults to 'default')",
            "in": "query",
            "name": "agent_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Optional session scope filter for epochs",
            "in": "query",
            "name": "session_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Optional FTS5 search query for episodic memories",
            "in": "query",
            "name": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Maximum episodic facts to return (1..200, default 50)",
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserMemoriesResponse"
                }
              }
            },
            "description": "User memories across all three tiers"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "List or search user memories",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      }
    },
    "/api/v1/users/{id}/memories/core": {
      "put": {
        "description": "Creates or updates a pinned core profile preference or constraint for the user.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertCoreMemoryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CoreMemoryEnvelope"
                }
              }
            },
            "description": "Saved core memory"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid core memory payload"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Upsert core profile memory",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      }
    },
    "/api/v1/users/{id}/memories/core/{memoryID}": {
      "delete": {
        "description": "Deletes a core profile memory owned by the user.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Core memory ID",
            "in": "path",
            "name": "memoryID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Core memory deleted"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Delete core profile memory",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      }
    },
    "/api/v1/users/{id}/memories/episodic": {
      "post": {
        "description": "Manually adds a user-verified or episodic fact to the user's FTS5 memory store.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateEpisodicMemoryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EpisodicMemoryEnvelope"
                }
              }
            },
            "description": "Created episodic memory"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid episodic memory payload"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Create episodic memory fact",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      }
    },
    "/api/v1/users/{id}/memories/episodic/{memoryID}": {
      "delete": {
        "description": "Deletes an episodic memory fact owned by the user.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Episodic memory ID",
            "in": "path",
            "name": "memoryID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Episodic memory deleted"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Delete episodic memory fact",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      },
      "patch": {
        "description": "Edits or marks an episodic fact as user-verified.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Episodic memory ID",
            "in": "path",
            "name": "memoryID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatchEpisodicMemoryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EpisodicMemoryEnvelope"
                }
              }
            },
            "description": "Updated episodic memory"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid update payload"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Update episodic memory fact",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      }
    },
    "/api/v1/users/{id}/memories/epochs": {
      "delete": {
        "description": "Deletes compacted Billion-Context epoch summaries for the user for a given session_id (and optional agent_id).",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Optional agent scope filter (defaults to 'default')",
            "in": "query",
            "name": "agent_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Required session ID to clear",
            "in": "query",
            "name": "session_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Session epochs cleared"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Missing session_id query parameter"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Clear session epoch summaries",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      }
    },
    "/api/v1/users/{id}/settings": {
      "patch": {
        "description": "Updates per-user feature toggles validated against the user's assigned plan entitlements (returns 403 if disallowed by plan).",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SettingsPatchRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SettingsPatchResponse"
                }
              }
            },
            "description": "Updated settings and effective policy"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid setting value"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Update user feature toggles",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      }
    },
    "/api/v1/users/{id}/skills": {
      "get": {
        "description": "Lists skills visible to the user along with the user's installed skills.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserSkillsResponse"
                }
              }
            },
            "description": "Visible skills and user installations"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "List user skills and installations",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      },
      "post": {
        "description": "Creates a private skill owned by the user.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateSkillRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SkillEnvelope"
                }
              }
            },
            "description": "Created skill"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid skill input"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Skill slug conflict"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Create user-owned skill",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      }
    },
    "/api/v1/users/{id}/skills/import": {
      "post": {
        "description": "Imports one or more private user-owned skills from a skills.sh CLI command (e.g. `npx skills add https://github.com/owner/repo --skill name`), skills.sh URL, GitHub repository/blob URL, or raw GitHub .md file URL, with optional immediate installation.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportSkillRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserImportSkillsResponse"
                }
              }
            },
            "description": "Imported skills"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid skill source or scope"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Skill import disallowed or quota exceeded"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Skill slug conflict"
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Upstream fetch failed"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Import skills from skills.sh or GitHub",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      }
    },
    "/api/v1/users/{id}/skills/install": {
      "post": {
        "description": "Attaches a global or user-owned skill to the user, an API key, or a combo. For scope_type=combo, scope_id accepts a combo UUID or combo name and is normalized to the combo name.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InstallSkillRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SkillInstallationEnvelope"
                }
              }
            },
            "description": "Installed skill"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid installation payload"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Skill is already installed in this scope (skill_already_installed)"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Install skill for user",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      }
    },
    "/api/v1/users/{id}/skills/install/{installID}": {
      "delete": {
        "description": "Removes a skill installation belonging to the user.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Skill installation ID",
            "in": "path",
            "name": "installID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Skill uninstalled"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Uninstall skill",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      }
    },
    "/api/v1/users/{id}/skills/{skillID}": {
      "delete": {
        "description": "Deletes a custom skill owned by the user.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Skill ID",
            "in": "path",
            "name": "skillID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            },
            "description": "Skill deleted"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Delete user-owned skill",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      }
    },
    "/api/v1/users/{id}/usage": {
      "get": {
        "description": "Returns aggregated token usage, compression savings, memory hits, per-provider breakdown, and recent logs for the user.",
        "parameters": [
          {
            "description": "Target user internal UUID or Laravel external_id",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter by provider ID",
            "in": "query",
            "name": "provider_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Filter by provider account ID",
            "in": "query",
            "name": "account_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Start timestamp (RFC3339 or YYYY-MM-DD, inclusive UTC start of day)",
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "End timestamp (RFC3339 or YYYY-MM-DD, inclusive UTC end of day)",
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Maximum usage logs to return",
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "Pagination offset",
            "in": "query",
            "name": "offset",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageResponse"
                }
              }
            },
            "description": "User usage analytics"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid date range filter"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Forbidden or feature not in plan"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "User or resource not found"
          }
        },
        "security": [
          {
            "ServiceTokenBearer": []
          },
          {
            "ServiceTokenHeader": []
          },
          {
            "BearerJWT": []
          }
        ],
        "summary": "Query user usage and token savings",
        "tags": [
          "Laravel On-Behalf-Of (/users/{id})"
        ]
      }
    },
    "/docs": {
      "get": {
        "description": "Serves a self-contained HTML explorer backed by /openapi.json.",
        "responses": {
          "200": {
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Self-contained HTML documentation page"
          }
        },
        "summary": "Interactive API documentation",
        "tags": [
          "System"
        ]
      }
    },
    "/healthz": {
      "get": {
        "description": "Returns ok when the HTTP server is running.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            },
            "description": "Server is alive"
          }
        },
        "summary": "Liveness probe",
        "tags": [
          "System"
        ]
      }
    },
    "/openapi.json": {
      "get": {
        "description": "Serves the complete OpenAPI 3.1.0 JSON document.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "OpenAPI 3.1.0 JSON document"
          }
        },
        "summary": "OpenAPI 3.1.0 specification",
        "tags": [
          "System"
        ]
      }
    },
    "/readyz": {
      "get": {
        "description": "Verifies SQLite database connectivity.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReadinessResponse"
                }
              }
            },
            "description": "Server is ready"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReadinessResponse"
                }
              }
            },
            "description": "Database unavailable"
          }
        },
        "summary": "Readiness probe",
        "tags": [
          "System"
        ]
      }
    },
    "/v1/chat/completions": {
      "post": {
        "description": "Routes OpenAI-compatible chat completion requests with prompt/skill injection, memory recall, stacked compression, and SSE streaming.",
        "parameters": [
          {
            "description": "Optional session identifier for session-dedup, episodic memory, and epoch summaries",
            "in": "header",
            "name": "X-MiniRoute-Session-ID",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Comma-separated skill slugs to activate for this request",
            "in": "header",
            "name": "X-MiniRoute-Skills",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Optional compression override (conservative | balanced | aggressive)",
            "in": "header",
            "name": "X-MiniRoute-Compression-Level",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenAIChatCompletionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIChatCompletionResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIChatCompletionChunk"
                }
              }
            },
            "description": "Chat completion JSON or SSE stream (when stream=true)",
            "headers": {
              "X-MiniRoute-Account": {
                "description": "Selected upstream provider account ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-MiniRoute-Memory-Hits": {
                "description": "Number of injected memory facts",
                "schema": {
                  "type": "integer"
                }
              },
              "X-MiniRoute-Model": {
                "description": "Resolved upstream model ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-MiniRoute-Provider": {
                "description": "Selected upstream provider ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-MiniRoute-Skills-Used": {
                "description": "Comma-separated skill slugs injected",
                "schema": {
                  "type": "string"
                }
              },
              "X-MiniRoute-Tokens-Saved": {
                "description": "Tokens saved by stacked compression",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIErrorEnvelope"
                }
              }
            },
            "description": "Invalid request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid or missing API key"
          },
          "402": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "API key token quota exceeded"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIErrorEnvelope"
                }
              }
            },
            "description": "Model forbidden by exposure policy or CLI disabled"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIErrorEnvelope"
                }
              }
            },
            "description": "Requested model or combo not found"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIErrorEnvelope"
                }
              }
            },
            "description": "Rate limit exceeded"
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIErrorEnvelope"
                }
              }
            },
            "description": "Upstream provider error"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIErrorEnvelope"
                }
              }
            },
            "description": "No healthy targets available"
          },
          "504": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIErrorEnvelope"
                }
              }
            },
            "description": "Upstream request timeout"
          }
        },
        "security": [
          {
            "VirtualAPIKeyBearer": []
          },
          {
            "AnthropicAPIKeyHeader": []
          }
        ],
        "summary": "Create chat completion (OpenAI-compatible)",
        "tags": [
          "Inference"
        ]
      }
    },
    "/v1/messages": {
      "post": {
        "description": "Routes Anthropic Messages API requests through MiniRoute's context, memory, compression, and combo routing pipeline.",
        "parameters": [
          {
            "description": "Optional session identifier for session-dedup, episodic memory, and epoch summaries",
            "in": "header",
            "name": "X-MiniRoute-Session-ID",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Comma-separated skill slugs to activate for this request",
            "in": "header",
            "name": "X-MiniRoute-Skills",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Optional compression override (conservative | balanced | aggressive)",
            "in": "header",
            "name": "X-MiniRoute-Compression-Level",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnthropicMessageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicMessageResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "description": "Anthropic SSE events (message_start, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop)",
                  "type": "string"
                }
              }
            },
            "description": "Anthropic message JSON or SSE stream (when stream=true)",
            "headers": {
              "X-MiniRoute-Account": {
                "description": "Selected upstream provider account ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-MiniRoute-Memory-Hits": {
                "description": "Number of injected memory facts",
                "schema": {
                  "type": "integer"
                }
              },
              "X-MiniRoute-Model": {
                "description": "Resolved upstream model ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-MiniRoute-Provider": {
                "description": "Selected upstream provider ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-MiniRoute-Skills-Used": {
                "description": "Comma-separated skill slugs injected",
                "schema": {
                  "type": "string"
                }
              },
              "X-MiniRoute-Tokens-Saved": {
                "description": "Tokens saved by stacked compression",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIErrorEnvelope"
                }
              }
            },
            "description": "Invalid request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Invalid or missing API key"
          },
          "402": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "API key token quota exceeded"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIErrorEnvelope"
                }
              }
            },
            "description": "Model forbidden by exposure policy or CLI disabled"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIErrorEnvelope"
                }
              }
            },
            "description": "Requested model or combo not found"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIErrorEnvelope"
                }
              }
            },
            "description": "Rate limit exceeded"
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIErrorEnvelope"
                }
              }
            },
            "description": "Upstream provider error"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIErrorEnvelope"
                }
              }
            },
            "description": "No healthy targets available"
          },
          "504": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIErrorEnvelope"
                }
              }
            },
            "description": "Upstream request timeout"
          }
        },
        "security": [
          {
            "VirtualAPIKeyBearer": []
          },
          {
            "AnthropicAPIKeyHeader": []
          }
        ],
        "summary": "Create message (Anthropic-compatible)",
        "tags": [
          "Inference"
        ]
      }
    },
    "/v1/models": {
      "get": {
        "description": "Lists models and combos permitted by the virtual API key's exposure policy.",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIModelsListResponse"
                }
              }
            },
            "description": "Visible OpenAI-format model list"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Unauthorized"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            },
            "description": "Rate limit exceeded"
          }
        },
        "security": [
          {
            "VirtualAPIKeyBearer": []
          },
          {
            "AnthropicAPIKeyHeader": []
          }
        ],
        "summary": "List visible models",
        "tags": [
          "Inference"
        ]
      }
    }
  },
  "servers": [
    {
      "description": "Current MiniRoute server",
      "url": "/"
    }
  ],
  "tags": [
    {
      "description": "Health, readiness, OpenAPI specification, and interactive documentation",
      "name": "System"
    },
    {
      "description": "Direct client-to-MiniRoute OpenAI \u0026 Anthropic compatible inference and SSE streaming",
      "name": "Inference"
    },
    {
      "description": "User registration, login, rotating refresh tokens, and logout",
      "name": "Auth"
    },
    {
      "description": "Per-user isolated self-service endpoints authenticated by user Bearer JWT",
      "name": "Self-Service (/me)"
    },
    {
      "description": "Platform endpoints acting on behalf of a user by UUID or Laravel external_id",
      "name": "Laravel On-Behalf-Of (/users/{id})"
    },
    {
      "description": "Superadmin control plane for plans, users, service tokens, providers, combos, context governance, and analytics",
      "name": "Admin"
    }
  ]
}
