Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust
400 KB
Raw Blame
# generated by datamodel-codegen:
#   filename:  codex_app_server_protocol.v2.schemas.json

from __future__ import annotations
from pydantic import BaseModel, ConfigDict, Field, RootModel
from typing import Annotated, Any, Literal
from enum import Enum


class CodexAppServerProtocolV2(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class AbsolutePathBuf(RootModel[str]):
    root: Annotated[
        str,
        Field(
            description="A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute."
        ),
    ]


class ApiKeyAccount(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["apiKey"], Field(title="ApiKeyAccountType")]


class AmazonBedrockAccount(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["amazonBedrock"], Field(title="AmazonBedrockAccountType")]
    uses_codex_managed_credentials: Annotated[
        bool | None, Field(alias="usesCodexManagedCredentials")
    ] = False


class GcpAccount(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["gcp"], Field(title="GcpAccountType")]


class AccountRoutingOverride(Enum):
    no_constraint = "NO_CONSTRAINT"
    us = "us"
    us_cr = "us_cr"


class AccountTokenUsageDailyBucket(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    start_date: Annotated[str, Field(alias="startDate")]
    tokens: int


class AccountTokenUsageSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    current_streak_days: Annotated[int | None, Field(alias="currentStreakDays")] = None
    lifetime_tokens: Annotated[int | None, Field(alias="lifetimeTokens")] = None
    longest_running_turn_sec: Annotated[int | None, Field(alias="longestRunningTurnSec")] = None
    longest_streak_days: Annotated[int | None, Field(alias="longestStreakDays")] = None
    peak_daily_tokens: Annotated[int | None, Field(alias="peakDailyTokens")] = None


class ActivePermissionProfile(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    extends: Annotated[
        str | None,
        Field(
            description="Parent profile identifier from the selected permissions profile's `extends` setting, when present."
        ),
    ] = None
    id: Annotated[
        str,
        Field(
            description="Identifier from `default_permissions` or the implicit built-in default, such as `:workspace` or a user-defined `[permissions.<id>]` profile."
        ),
    ]


class AddCreditsNudgeCreditType(Enum):
    credits = "credits"
    usage_limit = "usage_limit"


class AddCreditsNudgeEmailStatus(Enum):
    sent = "sent"
    cooldown_active = "cooldown_active"


class AdditionalContextKind(Enum):
    untrusted = "untrusted"
    application = "application"


class AdditionalNetworkPermissions(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    enabled: bool | None = None


class AgentMessageDelivery(RootModel[Literal["async"]]):
    root: Literal["async"]


class AgentMessageDeltaNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    delta: str
    item_id: Annotated[str, Field(alias="itemId")]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class InputTextAgentMessageInputContent(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    text: str
    type: Annotated[Literal["input_text"], Field(title="InputTextAgentMessageInputContentType")]


class EncryptedContentAgentMessageInputContent(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    encrypted_content: str
    type: Annotated[
        Literal["encrypted_content"], Field(title="EncryptedContentAgentMessageInputContentType")
    ]


class AgentMessageInputContent(
    RootModel[InputTextAgentMessageInputContent | EncryptedContentAgentMessageInputContent]
):
    root: InputTextAgentMessageInputContent | EncryptedContentAgentMessageInputContent


class AgentPath(RootModel[str]):
    root: str


class AllowDenyRequirement(Enum):
    allow = "allow"
    deny = "deny"


class AnalyticsConfig(BaseModel):
    model_config = ConfigDict(
        extra="allow",
        populate_by_name=True,
    )
    enabled: bool | None = None


class AppBranding(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    category: str | None = None
    developer: str | None = None
    is_discoverable_app: Annotated[bool, Field(alias="isDiscoverableApp")]
    privacy_policy: Annotated[str | None, Field(alias="privacyPolicy")] = None
    terms_of_service: Annotated[str | None, Field(alias="termsOfService")] = None
    website: str | None = None


class AppLinksConfig(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class AppReview(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    status: str


class AppScreenshot(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    file_id: Annotated[str | None, Field(alias="fileId")] = None
    url: str | None = None
    user_prompt: Annotated[str, Field(alias="userPrompt")]


class AppSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    category: str | None = None
    description: str | None = None
    id: str
    install_url: Annotated[str | None, Field(alias="installUrl")] = None
    name: str


class AppTemplateUnavailableReason(Enum):
    not_configured_for_workspace = "NOT_CONFIGURED_FOR_WORKSPACE"
    no_active_workspace = "NO_ACTIVE_WORKSPACE"


class AppToolApproval(Enum):
    auto = "auto"
    prompt = "prompt"
    writes = "writes"
    approve = "approve"


class AppToolConfig(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approval_mode: AppToolApproval | None = None
    enabled: bool | None = None


class AppToolSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    description: str
    disabled_reason: Annotated[str | None, Field(alias="disabledReason")] = None
    is_enabled: Annotated[bool | None, Field(alias="isEnabled")] = True
    is_read_only: Annotated[bool | None, Field(alias="isReadOnly")] = False
    name: str
    title: str | None = None


class AppToolsConfig(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ApprovalsReviewer(Enum):
    user = "user"
    auto_review = "auto_review"
    guardian_subagent = "guardian_subagent"


class AppsDefaultConfig(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approvals_reviewer: ApprovalsReviewer | None = None
    default_tools_approval_mode: AppToolApproval | None = None
    destructive_enabled: bool | None = True
    enabled: bool | None = True
    open_world_enabled: bool | None = True


class AppsInstalledParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    force_refresh: Annotated[
        bool | None,
        Field(
            alias="forceRefresh",
            description="When true and Apps are permitted, refresh and publish the hosted connector runtime tool snapshot first.",
        ),
    ] = None
    thread_id: Annotated[
        str | None,
        Field(
            alias="threadId",
            description="Optional loaded thread id used to evaluate effective app configuration.",
        ),
    ] = None


class AppsListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cursor: Annotated[
        str | None, Field(description="Opaque pagination cursor returned by a previous call.")
    ] = None
    force_refetch: Annotated[
        bool | None,
        Field(
            alias="forceRefetch",
            description="When true, bypass app caches and fetch the latest data from sources.",
        ),
    ] = None
    limit: Annotated[
        int | None,
        Field(description="Optional page size; defaults to a reasonable server-side value.", ge=0),
    ] = None
    thread_id: Annotated[
        str | None,
        Field(
            alias="threadId",
            description="Optional thread id used to evaluate app feature gating from that thread's config.",
        ),
    ] = None


class AppsReadParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    app_ids: Annotated[
        list[str],
        Field(
            alias="appIds",
            description="App ids to read. The server accepts at most 100 ids and deduplicates repeated ids while preserving their first-request order.",
        ),
    ]
    include_tools: Annotated[
        bool | None,
        Field(
            alias="includeTools",
            description="When true, include display-only public tool summaries in the returned metadata.",
        ),
    ] = None
    thread_id: Annotated[
        str | None,
        Field(
            alias="threadId",
            description="Optional loaded thread id used to evaluate effective app configuration.",
        ),
    ] = None


class AskForApprovalValue(Enum):
    untrusted = "untrusted"
    on_request = "on-request"
    never = "never"


class Granular(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    mcp_elicitations: bool
    request_permissions: bool | None = False
    rules: bool
    sandbox_approval: bool
    skill_approval: bool | None = False


class GranularAskForApproval(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    granular: Granular


class AskForApproval(RootModel[AskForApprovalValue | GranularAskForApproval]):
    root: AskForApprovalValue | GranularAskForApproval


class AsyncUserInputQuestion(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    options: list[str] | None = None
    title: str


class AuthMode(Enum):
    apikey = "apikey"
    chatgpt = "chatgpt"
    chatgpt_auth_tokens = "chatgptAuthTokens"
    headers = "headers"
    agent_identity = "agentIdentity"
    personal_access_token = "personalAccessToken"
    bedrock_api_key = "bedrockApiKey"
    bedrock_access_keys = "bedrockAccessKeys"


class AuthRecoveryNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message: str
    provider: str
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class AutoCompactTokenLimitScope(Enum):
    total = "total"
    body_after_prefix = "body_after_prefix"


class AutoReviewDecisionSource(RootModel[Literal["agent"]]):
    root: Annotated[
        Literal["agent"],
        Field(
            description="[UNSTABLE] Source that produced a terminal approval auto-review decision."
        ),
    ]


class AutoReviewRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    ignore_rules: Annotated[list[str] | None, Field(alias="ignoreRules")] = None
    required_on_models: Annotated[list[str] | None, Field(alias="requiredOnModels")] = None


class BrowserUseAccessApprovalLifetime(Enum):
    turn = "turn"
    thread = "thread"


class BrowserUseOriginPolicy(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    access: AllowDenyRequirement | None = None
    access_approval_lifetime: Annotated[
        BrowserUseAccessApprovalLifetime | None, Field(alias="accessApprovalLifetime")
    ] = None
    auto_review: Annotated[AllowDenyRequirement | None, Field(alias="autoReview")] = None
    downloads: AllowDenyRequirement | None = None
    full_cdp_access: Annotated[AllowDenyRequirement | None, Field(alias="fullCdpAccess")] = None
    persistent_approval: Annotated[bool | None, Field(alias="persistentApproval")] = None
    uploads: AllowDenyRequirement | None = None


class BrowserUseOriginPolicyConfig(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    access: AllowDenyRequirement | None = None
    downloads: AllowDenyRequirement | None = None
    full_cdp_access: AllowDenyRequirement | None = None
    uploads: AllowDenyRequirement | None = None


class ByteRange(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    end: Annotated[int, Field(ge=0)]
    start: Annotated[int, Field(ge=0)]


class CancelLoginAccountParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    login_id: Annotated[str, Field(alias="loginId")]


class CancelLoginAccountStatus(Enum):
    canceled = "canceled"
    not_found = "notFound"


class EnvironmentCapabilityRootLocation(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    environment_id: Annotated[str, Field(alias="environmentId")]
    path: Annotated[
        str, Field(description="Absolute path for the root in the selected environment.")
    ]
    type: Annotated[Literal["environment"], Field(title="EnvironmentCapabilityRootLocationType")]


class CapabilityRootLocation(RootModel[EnvironmentCapabilityRootLocation]):
    root: Annotated[
        EnvironmentCapabilityRootLocation,
        Field(description="Location used to resolve a selected capability root."),
    ]


class CliAuthCredentialsStoreMode(Enum):
    file = "file"
    keyring = "keyring"
    auto = "auto"
    ephemeral = "ephemeral"


class ClientInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str
    title: str | None = None
    version: str


class CodexErrorInfoValue(str, Enum):
    context_window_exceeded = "contextWindowExceeded"
    session_budget_exceeded = "sessionBudgetExceeded"
    usage_limit_exceeded = "usageLimitExceeded"
    rate_limit_exceeded = "rateLimitExceeded"
    flex_unavailable = "flexUnavailable"
    server_overloaded = "serverOverloaded"
    cyber_policy = "cyberPolicy"
    misalignment_policy_violation = "misalignmentPolicyViolation"
    too_many_denials = "tooManyDenials"
    internal_server_error = "internalServerError"
    unauthorized = "unauthorized"
    bad_request = "badRequest"
    thread_rollback_failed = "threadRollbackFailed"
    sandbox_error = "sandboxError"
    other = "other"

    @classmethod
    def _missing_(cls, value: object) -> CodexErrorInfoValue | None:
        if not isinstance(value, str):
            return None
        member = str.__new__(cls, value)
        member._name_ = value
        member._value_ = value
        return member


class HttpConnectionFailed(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    http_status_code: Annotated[int | None, Field(alias="httpStatusCode", ge=0)] = None


class HttpConnectionFailedCodexErrorInfo(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    http_connection_failed: Annotated[HttpConnectionFailed, Field(alias="httpConnectionFailed")]


class ResponseStreamConnectionFailed(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    http_status_code: Annotated[int | None, Field(alias="httpStatusCode", ge=0)] = None


class ResponseStreamConnectionFailedCodexErrorInfo(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    response_stream_connection_failed: Annotated[
        ResponseStreamConnectionFailed, Field(alias="responseStreamConnectionFailed")
    ]


class ResponseStreamDisconnected(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    http_status_code: Annotated[int | None, Field(alias="httpStatusCode", ge=0)] = None


class ResponseStreamDisconnectedCodexErrorInfo(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    response_stream_disconnected: Annotated[
        ResponseStreamDisconnected, Field(alias="responseStreamDisconnected")
    ]


class ResponseTooManyFailedAttempts(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    http_status_code: Annotated[int | None, Field(alias="httpStatusCode", ge=0)] = None


class ResponseTooManyFailedAttemptsCodexErrorInfo(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    response_too_many_failed_attempts: Annotated[
        ResponseTooManyFailedAttempts, Field(alias="responseTooManyFailedAttempts")
    ]


class CodexResponseHandoffMode(Enum):
    thinking = "thinking"
    commentary = "commentary"
    bem_tags = "bemTags"


class CollabAgentStatus(Enum):
    pending_init = "pendingInit"
    running = "running"
    interrupted = "interrupted"
    completed = "completed"
    errored = "errored"
    shutdown = "shutdown"
    not_found = "notFound"


class CollabAgentTool(Enum):
    spawn_agent = "spawnAgent"
    send_input = "sendInput"
    resume_agent = "resumeAgent"
    wait = "wait"
    close_agent = "closeAgent"
    send_message = "sendMessage"
    followup_task = "followupTask"
    interrupt_agent = "interruptAgent"
    list_agents = "listAgents"


class CollabAgentToolCallStatus(Enum):
    in_progress = "inProgress"
    completed = "completed"
    failed = "failed"
    interrupted = "interrupted"


class ListFilesCommandAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    command: str
    path: str | None = None
    type: Annotated[Literal["listFiles"], Field(title="ListFilesCommandActionType")]


class SearchCommandAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    command: str
    path: str | None = None
    query: str | None = None
    type: Annotated[Literal["search"], Field(title="SearchCommandActionType")]


class UnknownCommandAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    command: str
    type: Annotated[Literal["unknown"], Field(title="UnknownCommandActionType")]


class CommandExecOutputStream(Enum):
    stdout = "stdout"
    stderr = "stderr"


class CommandExecResizeResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class CommandExecResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    exit_code: Annotated[int, Field(alias="exitCode", description="Process exit code.")]
    stderr: Annotated[
        str,
        Field(
            description="Buffered stderr capture.\n\nEmpty when stderr was streamed via `command/exec/outputDelta`."
        ),
    ]
    stdout: Annotated[
        str,
        Field(
            description="Buffered stdout capture.\n\nEmpty when stdout was streamed via `command/exec/outputDelta`."
        ),
    ]


class CommandExecTerminalSize(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cols: Annotated[int, Field(description="Terminal width in character cells.", ge=0)]
    rows: Annotated[int, Field(description="Terminal height in character cells.", ge=0)]


class CommandExecTerminateParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    process_id: Annotated[
        str,
        Field(
            alias="processId",
            description="Client-supplied, connection-scoped `processId` from the original `command/exec` request.",
        ),
    ]


class CommandExecTerminateResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class CommandExecWriteParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    close_stdin: Annotated[
        bool | None,
        Field(
            alias="closeStdin", description="Close stdin after writing `deltaBase64`, if present."
        ),
    ] = None
    delta_base64: Annotated[
        str | None,
        Field(alias="deltaBase64", description="Optional base64-encoded stdin bytes to write."),
    ] = None
    process_id: Annotated[
        str,
        Field(
            alias="processId",
            description="Client-supplied, connection-scoped `processId` from the original `command/exec` request.",
        ),
    ]


class CommandExecWriteResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class CommandExecutionOutputDeltaNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    delta: str
    item_id: Annotated[str, Field(alias="itemId")]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class CommandExecutionSource(Enum):
    agent = "agent"
    user_shell = "userShell"
    unified_exec_startup = "unifiedExecStartup"
    unified_exec_interaction = "unifiedExecInteraction"


class CommandExecutionStatus(Enum):
    in_progress = "inProgress"
    completed = "completed"
    failed = "failed"
    declined = "declined"


class CommandMigration(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str


class ComputerUseMacosConfig(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    bundle_ids: dict[str, Any] | None = None


class ComputerUseMacosRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    bundle_ids: Annotated[dict[str, Any] | None, Field(alias="bundleIds")] = None


class ComputerUseWindowsExeConfig(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    access: AllowDenyRequirement
    binary_name: str | None = None
    product_name: str
    publisher_name: str


class ComputerUseWindowsExeRequirement(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    access: AllowDenyRequirement
    binary_name: Annotated[str | None, Field(alias="binaryName")] = None
    product_name: Annotated[str, Field(alias="productName")]
    publisher_name: Annotated[str, Field(alias="publisherName")]


class ComputerUseWindowsRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    aumids: dict[str, Any] | None = None
    exes: list[ComputerUseWindowsExeRequirement] | None = None


class PackagedDefaultsConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    file: Annotated[
        AbsolutePathBuf, Field(description="Path to the packaged default configuration file.")
    ]
    type: Annotated[
        Literal["packagedDefaults"], Field(title="PackagedDefaultsConfigLayerSourceType")
    ]


class MdmConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    domain: str
    key: str
    type: Annotated[Literal["mdm"], Field(title="MdmConfigLayerSourceType")]


class SystemConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    file: Annotated[
        AbsolutePathBuf,
        Field(
            description="This is the path to the system config.toml file, though it is not guaranteed to exist."
        ),
    ]
    type: Annotated[Literal["system"], Field(title="SystemConfigLayerSourceType")]


class EnterpriseManagedConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: Annotated[str, Field(description="Stable identifier for the delivered layer.")]
    name: Annotated[
        str,
        Field(
            description="Admin-facing name for the delivered layer. This is surfaced in diagnostics so users know which cloud layer needs administrator attention."
        ),
    ]
    type: Annotated[
        Literal["enterpriseManaged"], Field(title="EnterpriseManagedConfigLayerSourceType")
    ]


class UserConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    file: Annotated[
        AbsolutePathBuf,
        Field(
            description="This is the path to the user's config.toml file, though it is not guaranteed to exist."
        ),
    ]
    profile: Annotated[
        str | None,
        Field(
            description="Name of the selected profile-v2 config layered on top of the base user config, when this layer represents one."
        ),
    ] = None
    type: Annotated[Literal["user"], Field(title="UserConfigLayerSourceType")]


class ProjectConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    dot_codex_folder: Annotated[AbsolutePathBuf, Field(alias="dotCodexFolder")]
    type: Annotated[Literal["project"], Field(title="ProjectConfigLayerSourceType")]


class SessionFlagsConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["sessionFlags"], Field(title="SessionFlagsConfigLayerSourceType")]


class LegacyManagedConfigTomlFromFileConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    file: AbsolutePathBuf
    type: Annotated[
        Literal["legacyManagedConfigTomlFromFile"],
        Field(title="LegacyManagedConfigTomlFromFileConfigLayerSourceType"),
    ]


class LegacyManagedConfigTomlFromMdmConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[
        Literal["legacyManagedConfigTomlFromMdm"],
        Field(title="LegacyManagedConfigTomlFromMdmConfigLayerSourceType"),
    ]


class ConfigLayerSource(
    RootModel[
        PackagedDefaultsConfigLayerSource
        | MdmConfigLayerSource
        | SystemConfigLayerSource
        | EnterpriseManagedConfigLayerSource
        | UserConfigLayerSource
        | ProjectConfigLayerSource
        | SessionFlagsConfigLayerSource
        | LegacyManagedConfigTomlFromFileConfigLayerSource
        | LegacyManagedConfigTomlFromMdmConfigLayerSource
    ]
):
    root: (
        PackagedDefaultsConfigLayerSource
        | MdmConfigLayerSource
        | SystemConfigLayerSource
        | EnterpriseManagedConfigLayerSource
        | UserConfigLayerSource
        | ProjectConfigLayerSource
        | SessionFlagsConfigLayerSource
        | LegacyManagedConfigTomlFromFileConfigLayerSource
        | LegacyManagedConfigTomlFromMdmConfigLayerSource
    )


class ConfigReadParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: Annotated[
        str | None,
        Field(
            description="Optional working directory to resolve project config layers. If specified, return the effective config as seen from that directory (i.e., including any project layers between `cwd` and the project/repo root)."
        ),
    ] = None
    include_layers: Annotated[bool | None, Field(alias="includeLayers")] = None


class CommandConfiguredHookHandler(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    additional_context_limit: Annotated[
        int | None,
        Field(
            alias="additionalContextLimit",
            description="Approximate token threshold for spilling this hook's `additionalContext` to disk. `null` uses 2,500 tokens; `0` disables spilling for this hook. The threshold is evaluated against the original context; a spilled preview also includes recovery metadata.",
            ge=0,
        ),
    ] = None
    async_: Annotated[bool, Field(alias="async")]
    command: str
    command_windows: Annotated[str | None, Field(alias="commandWindows")] = None
    status_message: Annotated[str | None, Field(alias="statusMessage")] = None
    timeout_sec: Annotated[int | None, Field(alias="timeoutSec", ge=0)] = None
    type: Annotated[Literal["command"], Field(title="CommandConfiguredHookHandlerType")]


class McpToolConfiguredHookHandler(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    input: dict[str, Any]
    server: str
    status_message: Annotated[str | None, Field(alias="statusMessage")] = None
    timeout_sec: Annotated[int | None, Field(alias="timeoutSec", ge=0)] = None
    tool: str
    type: Annotated[Literal["mcp_tool"], Field(title="McpToolConfiguredHookHandlerType")]


class PromptConfiguredHookHandler(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["prompt"], Field(title="PromptConfiguredHookHandlerType")]


class AgentConfiguredHookHandler(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["agent"], Field(title="AgentConfiguredHookHandlerType")]


class ConfiguredHookHandler(
    RootModel[
        CommandConfiguredHookHandler
        | McpToolConfiguredHookHandler
        | PromptConfiguredHookHandler
        | AgentConfiguredHookHandler
    ]
):
    root: (
        CommandConfiguredHookHandler
        | McpToolConfiguredHookHandler
        | PromptConfiguredHookHandler
        | AgentConfiguredHookHandler
    )


class ConfiguredHookMatcherGroup(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    hooks: list[ConfiguredHookHandler]
    matcher: str | None = None


class ConnectorMetadata(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    description: str | None = None
    distribution_channel: Annotated[str | None, Field(alias="distributionChannel")] = None
    icon_url: Annotated[str | None, Field(alias="iconUrl")] = None
    icon_url_dark: Annotated[str | None, Field(alias="iconUrlDark")] = None
    id: str
    install_url: Annotated[str | None, Field(alias="installUrl")] = None
    name: str
    plugin_display_names: Annotated[list[str] | None, Field(alias="pluginDisplayNames")] = []
    tool_summaries: Annotated[list[AppToolSummary] | None, Field(alias="toolSummaries")] = None


class ConsumeAccountRateLimitResetCreditOutcome(Enum):
    reset = "reset"
    nothing_to_reset = "nothingToReset"
    no_credit = "noCredit"
    already_redeemed = "alreadyRedeemed"


class ConsumeAccountRateLimitResetCreditParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    credit_id: Annotated[
        str | None,
        Field(
            alias="creditId",
            description="Opaque reset-credit identifier to redeem. When omitted, the backend selects the next available credit.",
        ),
    ] = None
    idempotency_key: Annotated[
        str,
        Field(
            alias="idempotencyKey",
            description="Identifies one logical reset attempt. A UUID is recommended; reuse the same value when retrying that attempt.",
        ),
    ]


class ConsumeAccountRateLimitResetCreditResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    outcome: ConsumeAccountRateLimitResetCreditOutcome


class InputTextContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    text: str
    type: Annotated[Literal["input_text"], Field(title="InputTextContentItemType")]


class InputAudioContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    audio_url: str
    type: Annotated[Literal["input_audio"], Field(title="InputAudioContentItemType")]


class OutputTextContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    annotations: list[Any] | None = None
    logprobs: list[Any] | None = None
    text: str
    type: Annotated[Literal["output_text"], Field(title="OutputTextContentItemType")]


class ContextCompactedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class ConversationTextRole(Enum):
    user = "user"
    developer = "developer"
    assistant = "assistant"


class CreditsSnapshot(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    balance: str | None = None
    has_credits: Annotated[bool, Field(alias="hasCredits")]
    unlimited: bool


class CyberAccessProgram(Enum):
    standard = "standard"
    daybreak_blue = "daybreakBlue"
    daybreak_red = "daybreakRed"


class DeprecationNoticeNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    details: Annotated[
        str | None,
        Field(description="Optional extra guidance, such as migration steps or rationale."),
    ] = None
    summary: Annotated[str, Field(description="Concise summary of what is deprecated.")]


class DesktopOnboardingEntrypoint(RootModel[Literal["life_sciences"]]):
    root: Literal["life_sciences"]


class InputTextDynamicToolCallOutputContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    text: str
    type: Annotated[
        Literal["inputText"], Field(title="InputTextDynamicToolCallOutputContentItemType")
    ]


class InputImageDynamicToolCallOutputContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    image_url: Annotated[str, Field(alias="imageUrl")]
    type: Annotated[
        Literal["inputImage"], Field(title="InputImageDynamicToolCallOutputContentItemType")
    ]


class InputAudioDynamicToolCallOutputContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    audio_url: Annotated[str, Field(alias="audioUrl")]
    type: Annotated[
        Literal["inputAudio"], Field(title="InputAudioDynamicToolCallOutputContentItemType")
    ]


class DynamicToolCallOutputContentItem(
    RootModel[
        InputTextDynamicToolCallOutputContentItem
        | InputImageDynamicToolCallOutputContentItem
        | InputAudioDynamicToolCallOutputContentItem
    ]
):
    root: (
        InputTextDynamicToolCallOutputContentItem
        | InputImageDynamicToolCallOutputContentItem
        | InputAudioDynamicToolCallOutputContentItem
    )


class DynamicToolCallStatus(Enum):
    in_progress = "inProgress"
    completed = "completed"
    failed = "failed"


class FunctionDynamicToolNamespaceTool(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    defer_loading: Annotated[bool | None, Field(alias="deferLoading")] = None
    description: str
    input_schema: Annotated[Any, Field(alias="inputSchema")]
    name: str
    type: Annotated[Literal["function"], Field(title="FunctionDynamicToolNamespaceToolType")]


class DynamicToolNamespaceTool(RootModel[FunctionDynamicToolNamespaceTool]):
    root: FunctionDynamicToolNamespaceTool


class FunctionDynamicToolSpec(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    defer_loading: Annotated[bool | None, Field(alias="deferLoading")] = None
    description: str
    input_schema: Annotated[Any, Field(alias="inputSchema")]
    name: str
    type: Annotated[Literal["function"], Field(title="FunctionDynamicToolSpecType")]


class NamespaceDynamicToolSpec(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    description: str
    name: str
    tools: list[DynamicToolNamespaceTool]
    type: Annotated[Literal["namespace"], Field(title="NamespaceDynamicToolSpecType")]


class DynamicToolSpec(RootModel[FunctionDynamicToolSpec | NamespaceDynamicToolSpec]):
    root: FunctionDynamicToolSpec | NamespaceDynamicToolSpec


class EnvironmentConnectionNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    environment_id: Annotated[str, Field(alias="environmentId")]
    thread_id: Annotated[str, Field(alias="threadId")]


class EnvironmentSkillsParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    required: Annotated[
        list[str] | None,
        Field(description="Exact catalog names that must be available from this environment."),
    ] = None


class ExperimentalFeatureEnablementSetParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    enablement: Annotated[
        dict[str, bool],
        Field(
            description="Process-wide runtime feature enablement keyed by canonical feature name.\n\nOnly named features are updated. Omitted features are left unchanged. Send an empty map for a no-op."
        ),
    ]


class ExperimentalFeatureEnablementSetResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    enablement: Annotated[
        dict[str, bool], Field(description="Feature enablement entries updated by this request.")
    ]


class ExperimentalFeatureListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cursor: Annotated[
        str | None, Field(description="Opaque pagination cursor returned by a previous call.")
    ] = None
    limit: Annotated[
        int | None,
        Field(description="Optional page size; defaults to a reasonable server-side value.", ge=0),
    ] = None
    thread_id: Annotated[
        str | None,
        Field(
            alias="threadId",
            description="Optional loaded thread id. Pass this when showing feature state for an existing thread so enablement is computed from that thread's refreshed config, including project-local config for the thread's cwd.",
        ),
    ] = None


class ExperimentalFeatureStage(Enum):
    beta = "beta"
    under_development = "underDevelopment"
    stable = "stable"
    deprecated = "deprecated"
    removed = "removed"


class ExternalAgentConfigDetectParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwds: Annotated[
        list[str] | None,
        Field(description="Zero or more working directories to include for repo-scoped detection."),
    ] = None
    include_home: Annotated[
        bool | None,
        Field(
            alias="includeHome",
            description="If true, include detection under the user's home directory.",
        ),
    ] = None
    max_session_age_days: Annotated[
        int | None,
        Field(
            alias="maxSessionAgeDays",
            description="Maximum age in days for detected sessions. Missing values use the default limit.",
            ge=0,
        ),
    ] = None
    max_sessions: Annotated[
        int | None,
        Field(
            alias="maxSessions",
            description="Maximum number of sessions to detect. Missing values use the default limit.",
            ge=0,
        ),
    ] = None
    migration_source: Annotated[
        str | None,
        Field(
            alias="migrationSource",
            description="Optional migration-source selector. Missing or unrecognized values use the default source.",
        ),
    ] = None
    source: Annotated[
        str | None,
        Field(
            description="Deprecated field retained for compatibility. This field is ignored; use `migrationSource` to select the migration source."
        ),
    ] = None


class ExternalAgentConfigImportHistoryRecordResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    import_id: Annotated[str, Field(alias="importId")]


class ExternalAgentConfigImportResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    import_id: Annotated[str, Field(alias="importId")]


class ExternalAgentConfigMigrationItemType(Enum):
    agents_md = "AGENTS_MD"
    config = "CONFIG"
    skills = "SKILLS"
    plugins = "PLUGINS"
    mcp_server_config = "MCP_SERVER_CONFIG"
    subagents = "SUBAGENTS"
    hooks = "HOOKS"
    commands = "COMMANDS"
    memory = "MEMORY"
    sessions = "SESSIONS"


class ExternalAgentDetectedConnectorSource(Enum):
    remote_mcp_servers_config = "remoteMcpServersConfig"
    session_tool_use = "sessionToolUse"


class ExternalAgentImportedConnectorSource(RootModel[Literal["remoteMcpServersConfig"]]):
    root: Literal["remoteMcpServersConfig"]


class FeedbackRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    enabled: bool | None = None


class FeedbackUploadParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    classification: str
    extra_log_files: Annotated[list[str] | None, Field(alias="extraLogFiles")] = None
    include_logs: Annotated[bool | None, Field(alias="includeLogs")] = None
    reason: str | None = None
    tags: dict[str, Any] | None = None
    thread_id: Annotated[str | None, Field(alias="threadId")] = None


class FeedbackUploadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    prompt_hash: Annotated[
        str | None,
        Field(
            alias="promptHash",
            description="Whitespace-normalized SHA-256 of the session base instructions, matching the uploaded `prompt_hash` tag. Does not include later developer messages. Null when the reported rollout has no prompt metadata.",
        ),
    ] = None
    thread_id: Annotated[str, Field(alias="threadId")]


class FileChangeOutputDeltaNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    delta: str
    item_id: Annotated[str, Field(alias="itemId")]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class FileSystemAccessMode(Enum):
    read = "read"
    write = "write"
    deny = "deny"


class GlobPatternFileSystemPath(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    pattern: str
    type: Annotated[Literal["glob_pattern"], Field(title="GlobPatternFileSystemPathType")]


class RootFileSystemSpecialPath(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    kind: Literal["root"]


class MinimalFileSystemSpecialPath(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    kind: Literal["minimal"]


class TmpdirFileSystemSpecialPath(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    kind: Literal["tmpdir"]


class SlashTmpFileSystemSpecialPath(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    kind: Literal["slash_tmp"]


class ForcedChatgptWorkspaceIds(RootModel[str | list[str]]):
    root: Annotated[
        str | list[str],
        Field(
            description="Backward-compatible API shape for ChatGPT workspace login restrictions."
        ),
    ]


class ForcedLoginMethod(Enum):
    chatgpt = "chatgpt"
    api = "api"


class FsChangedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    changed_paths: Annotated[
        list[AbsolutePathBuf],
        Field(
            alias="changedPaths", description="File or directory paths associated with this event."
        ),
    ]
    watch_id: Annotated[
        str,
        Field(alias="watchId", description="Watch identifier previously provided to `fs/watch`."),
    ]


class FsCopyParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    destination_path: Annotated[
        AbsolutePathBuf, Field(alias="destinationPath", description="Absolute destination path.")
    ]
    recursive: Annotated[
        bool | None, Field(description="Required for directory copies; ignored for file copies.")
    ] = None
    source_path: Annotated[
        AbsolutePathBuf, Field(alias="sourcePath", description="Absolute source path.")
    ]


class FsCopyResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class FsCreateDirectoryParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: Annotated[AbsolutePathBuf, Field(description="Absolute directory path to create.")]
    recursive: Annotated[
        bool | None,
        Field(description="Whether parent directories should also be created. Defaults to `true`."),
    ] = None


class FsCreateDirectoryResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class FsGetMetadataParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: Annotated[AbsolutePathBuf, Field(description="Absolute path to inspect.")]


class FsGetMetadataResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    created_at_ms: Annotated[
        int,
        Field(
            alias="createdAtMs",
            description="File creation time in Unix milliseconds when available, otherwise `0`.",
        ),
    ]
    is_directory: Annotated[
        bool, Field(alias="isDirectory", description="Whether the path resolves to a directory.")
    ]
    is_file: Annotated[
        bool, Field(alias="isFile", description="Whether the path resolves to a regular file.")
    ]
    is_symlink: Annotated[
        bool, Field(alias="isSymlink", description="Whether the path itself is a symbolic link.")
    ]
    modified_at_ms: Annotated[
        int,
        Field(
            alias="modifiedAtMs",
            description="File modification time in Unix milliseconds when available, otherwise `0`.",
        ),
    ]


class FsReadDirectoryEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    file_name: Annotated[
        str,
        Field(
            alias="fileName",
            description="Direct child entry name only, not an absolute or relative path.",
        ),
    ]
    is_directory: Annotated[
        bool, Field(alias="isDirectory", description="Whether this entry resolves to a directory.")
    ]
    is_file: Annotated[
        bool, Field(alias="isFile", description="Whether this entry resolves to a regular file.")
    ]


class FsReadDirectoryParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: Annotated[AbsolutePathBuf, Field(description="Absolute directory path to read.")]


class FsReadDirectoryResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    entries: Annotated[
        list[FsReadDirectoryEntry],
        Field(description="Direct child entries in the requested directory."),
    ]


class FsReadFileParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: Annotated[AbsolutePathBuf, Field(description="Absolute path to read.")]


class FsReadFileResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data_base64: Annotated[
        str, Field(alias="dataBase64", description="File contents encoded as base64.")
    ]


class FsRemoveParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    force: Annotated[
        bool | None,
        Field(description="Whether missing paths should be ignored. Defaults to `true`."),
    ] = None
    path: Annotated[AbsolutePathBuf, Field(description="Absolute path to remove.")]
    recursive: Annotated[
        bool | None,
        Field(description="Whether directory removal should recurse. Defaults to `true`."),
    ] = None


class FsRemoveResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class FsUnwatchParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    watch_id: Annotated[
        str,
        Field(alias="watchId", description="Watch identifier previously provided to `fs/watch`."),
    ]


class FsUnwatchResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class FsWatchParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: Annotated[AbsolutePathBuf, Field(description="Absolute file or directory path to watch.")]
    watch_id: Annotated[
        str,
        Field(
            alias="watchId",
            description="Connection-scoped watch identifier used for `fs/unwatch` and `fs/changed`.",
        ),
    ]


class FsWatchResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: Annotated[
        AbsolutePathBuf, Field(description="Canonicalized path associated with the watch.")
    ]


class FsWriteFileParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data_base64: Annotated[
        str, Field(alias="dataBase64", description="File contents encoded as base64.")
    ]
    path: Annotated[AbsolutePathBuf, Field(description="Absolute path to write.")]


class FsWriteFileResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class InputTextFunctionCallOutputContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    text: str
    type: Annotated[
        Literal["input_text"], Field(title="InputTextFunctionCallOutputContentItemType")
    ]


class InputAudioFunctionCallOutputContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    audio_url: str
    type: Annotated[
        Literal["input_audio"], Field(title="InputAudioFunctionCallOutputContentItemType")
    ]


class EncryptedContentFunctionCallOutputContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    encrypted_content: str
    type: Annotated[
        Literal["encrypted_content"],
        Field(title="EncryptedContentFunctionCallOutputContentItemType"),
    ]


class FuzzyFileSearchMatchType(Enum):
    file = "file"
    directory = "directory"


class FuzzyFileSearchParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cancellation_token: Annotated[str | None, Field(alias="cancellationToken")] = None
    query: str
    roots: list[str]


class Indice(RootModel[int]):
    root: Annotated[int, Field(ge=0)]


class FuzzyFileSearchResult(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    file_name: str
    indices: list[Indice] | None = None
    match_type: FuzzyFileSearchMatchType
    path: str
    root: str
    score: Annotated[int, Field(ge=0)]


class FuzzyFileSearchSessionCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    session_id: Annotated[str, Field(alias="sessionId")]


class FuzzyFileSearchSessionUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    files: list[FuzzyFileSearchResult]
    query: str
    session_id: Annotated[str, Field(alias="sessionId")]


class GatewayOAuthCancelResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class GatewayOAuthLoginResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class GatewayOAuthStatus(Enum):
    not_ready = "notReady"
    started = "started"
    succeeded = "succeeded"
    failed = "failed"


class GetAccountParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    refresh_token: Annotated[
        bool | None,
        Field(
            alias="refreshToken",
            description="When `true`, requests a proactive token refresh before returning.\n\nIn managed auth mode this triggers the normal refresh-token flow. In external auth mode this flag is ignored. Clients should refresh tokens themselves and call `account/login/start` with `chatgptAuthTokens`.",
        ),
    ] = None


class GetAccountRateLimitsParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    exclude_reset_credit_details: Annotated[
        bool | None,
        Field(
            alias="excludeResetCreditDetails",
            description="Skip the separate reset-credit detail lookup for background usage polls. The usage response still includes the available count; omitted/false preserves detailed reads.",
        ),
    ] = None
    supports_luna_reserve: Annotated[
        bool | None,
        Field(
            alias="supportsLunaReserve",
            description="The client supports automatic Luna Reserve fallback. For eligible ChatGPT CLI users, allow the backend to record experiment exposure after ordinary usage is blocked.",
        ),
    ] = None


class GetAccountTokenUsageParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[
        str | None,
        Field(
            alias="threadId",
            description="When present, read estimated usage for this thread instead of account-wide token activity.",
        ),
    ] = None


class GitInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    branch: str | None = None
    origin_url: Annotated[str | None, Field(alias="originUrl")] = None
    sha: str | None = None


class ApplyPatchGuardianApprovalReviewAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: AbsolutePathBuf
    files: list[AbsolutePathBuf]
    type: Annotated[
        Literal["applyPatch"], Field(title="ApplyPatchGuardianApprovalReviewActionType")
    ]


class McpToolCallGuardianApprovalReviewAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    connector_id: Annotated[str | None, Field(alias="connectorId")] = None
    connector_name: Annotated[str | None, Field(alias="connectorName")] = None
    server: str
    tool_name: Annotated[str, Field(alias="toolName")]
    tool_title: Annotated[str | None, Field(alias="toolTitle")] = None
    type: Annotated[
        Literal["mcpToolCall"], Field(title="McpToolCallGuardianApprovalReviewActionType")
    ]


class GuardianApprovalReviewStatus(Enum):
    in_progress = "inProgress"
    approved = "approved"
    denied = "denied"
    timed_out = "timedOut"
    aborted = "aborted"


class GuardianCommandSource(Enum):
    shell = "shell"
    unified_exec = "unifiedExec"


class GuardianRiskLevel(Enum):
    low = "low"
    medium = "medium"
    high = "high"
    critical = "critical"


class GuardianUserAuthorization(Enum):
    unknown = "unknown"
    low = "low"
    medium = "medium"
    high = "high"


class GuardianWarningNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message: Annotated[str, Field(description="Concise guardian warning message for the user.")]
    thread_id: Annotated[
        str, Field(alias="threadId", description="Thread target for the guardian warning.")
    ]


class HookErrorInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message: str
    path: str


class HookEventName(Enum):
    pre_model_request = "preModelRequest"
    post_model_request = "postModelRequest"
    pre_tool_use = "preToolUse"
    permission_request = "permissionRequest"
    post_tool_use = "postToolUse"
    pre_compact = "preCompact"
    post_compact = "postCompact"
    session_start = "sessionStart"
    session_end = "sessionEnd"
    user_prompt_submit = "userPromptSubmit"
    subagent_start = "subagentStart"
    subagent_stop = "subagentStop"
    stop = "stop"
    interrupt = "interrupt"


class HookExecutionMode(Enum):
    sync = "sync"
    async_ = "async"


class HookHandlerType(Enum):
    command = "command"
    mcp_tool = "mcpTool"
    prompt = "prompt"
    agent = "agent"


class HookMigration(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str


class HookOutputEntryKind(Enum):
    warning = "warning"
    stop = "stop"
    feedback = "feedback"
    context = "context"
    error = "error"


class HookPromptFragment(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    hook_run_id: Annotated[str, Field(alias="hookRunId")]
    text: str


class HookRunStatus(Enum):
    running = "running"
    completed = "completed"
    failed = "failed"
    blocked = "blocked"
    stopped = "stopped"


class HookScope(Enum):
    thread = "thread"
    turn = "turn"


class HookSource(Enum):
    system = "system"
    user = "user"
    project = "project"
    mdm = "mdm"
    session_flags = "sessionFlags"
    plugin = "plugin"
    cloud_requirements = "cloudRequirements"
    cloud_managed_config = "cloudManagedConfig"
    legacy_managed_config_file = "legacyManagedConfigFile"
    legacy_managed_config_mdm = "legacyManagedConfigMdm"
    unknown = "unknown"


class HookTrustStatus(Enum):
    managed = "managed"
    untrusted = "untrusted"
    trusted = "trusted"
    modified = "modified"


class HooksListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwds: Annotated[
        list[str] | None,
        Field(description="When empty, defaults to the current session working directory."),
    ] = None


class ImageDetail(Enum):
    auto = "auto"
    low = "low"
    high = "high"
    original = "original"


class UsageLimitExceededImageGenerationFailure(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    limit_id: Annotated[str, Field(alias="limitId")]
    resets_at: Annotated[int | None, Field(alias="resetsAt")] = None
    type: Annotated[
        Literal["usageLimitExceeded"], Field(title="UsageLimitExceededImageGenerationFailureType")
    ]


class ImageGenerationFailure(RootModel[UsageLimitExceededImageGenerationFailure]):
    root: UsageLimitExceededImageGenerationFailure


class ImageGenerationInputImage(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: AbsolutePathBuf
    sha256: Annotated[
        str,
        Field(description="Lowercase SHA-256 of the file bytes read before image normalization."),
    ]


class InAppBrowserRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    allow_external_browser_settings_import: Annotated[
        bool | None, Field(alias="allowExternalBrowserSettingsImport")
    ] = None


class InitializeCapabilities(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    experimental_api: Annotated[
        bool | None,
        Field(
            alias="experimentalApi",
            description="Opt into receiving experimental API methods and fields.",
        ),
    ] = False
    explicit_gateway_oauth: Annotated[
        bool | None,
        Field(
            alias="explicitGatewayOauth",
            description="Use explicit gateway OAuth login instead of automatic browser authorization. Applies to this app-server's gateway runtime; later connections cannot undo it.",
        ),
    ] = None
    extensions: Annotated[
        dict[str, Any] | None,
        Field(description="MCP extension settings declared by the app-server client."),
    ] = None
    mcp_server_openai_form_elicitation: Annotated[
        bool | None,
        Field(
            alias="mcpServerOpenaiFormElicitation",
            description="Legacy opt-in for the `openai/form` MCP extension.\n\nNew clients should declare `openai/form` in [`Self::extensions`].",
        ),
    ] = None
    opt_out_notification_methods: Annotated[
        list[str] | None,
        Field(
            alias="optOutNotificationMethods",
            description="Exact notification method names that should be suppressed for this connection (for example `thread/started`).",
        ),
    ] = None
    request_attestation: Annotated[
        bool | None,
        Field(
            alias="requestAttestation",
            description="Opt into `attestation/generate` requests for upstream `x-oai-attestation`.",
        ),
    ] = False


class InitializeParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    capabilities: InitializeCapabilities | None = None
    client_info: Annotated[ClientInfo, Field(alias="clientInfo")]


class InputModality(Enum):
    text = "text"
    image = "image"
    audio = "audio"


class InstalledApp(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    callable: Annotated[
        bool,
        Field(
            description="Whether the connector is enabled and has a non-synthetic, model-visible tool allowed by effective MCP and app/tool policy in the committed runtime snapshot."
        ),
    ]
    enabled: Annotated[
        bool,
        Field(
            description="Effective enabled state after applying global, workspace, local, and managed configuration at read time."
        ),
    ]
    id: str
    runtime_name: Annotated[
        str | None,
        Field(
            alias="runtimeName",
            description="Best-effort name carried by the runtime tool catalog. Canonical app metadata remains owned by `app/read`.",
        ),
    ] = None


class InternalChatMessageMetadataPassthrough(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    turn_id: str | None = None


class LegacyAppPathString(RootModel[str]):
    root: str


class ExecLocalShellAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    command: list[str]
    env: dict[str, Any] | None = None
    timeout_ms: Annotated[int | None, Field(ge=0)] = None
    type: Annotated[Literal["exec"], Field(title="ExecLocalShellActionType")]
    user: str | None = None
    working_directory: str | None = None


class LocalShellAction(RootModel[ExecLocalShellAction]):
    root: ExecLocalShellAction


class LocalShellStatus(Enum):
    completed = "completed"
    in_progress = "in_progress"
    incomplete = "incomplete"


class ApiKeyLoginAccountParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    api_key: Annotated[str, Field(alias="apiKey")]
    type: Annotated[Literal["apiKey"], Field(title="ApiKeyv2::LoginAccountParamsType")]


class ChatgptDeviceCodeLoginAccountParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[
        Literal["chatgptDeviceCode"], Field(title="ChatgptDeviceCodev2::LoginAccountParamsType")
    ]


class ChatgptAuthTokensLoginAccountParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    access_token: Annotated[
        str,
        Field(
            alias="accessToken",
            description="Access token (JWT) supplied by the client. This token is used for backend API requests and email extraction.",
        ),
    ]
    chatgpt_account_id: Annotated[
        str,
        Field(
            alias="chatgptAccountId",
            description="Workspace/account identifier supplied by the client.",
        ),
    ]
    chatgpt_plan_type: Annotated[
        str | None,
        Field(
            alias="chatgptPlanType",
            description="Optional plan type supplied by the client.\n\nWhen `null`, Codex attempts to derive the plan type from access-token claims. If unavailable, the plan defaults to `unknown`.",
        ),
    ] = None
    type: Annotated[
        Literal["chatgptAuthTokens"], Field(title="ChatgptAuthTokensv2::LoginAccountParamsType")
    ]


class AmazonBedrockLoginAccountParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    api_key: Annotated[str, Field(alias="apiKey")]
    region: str
    type: Annotated[
        Literal["amazonBedrock"], Field(title="AmazonBedrockv2::LoginAccountParamsType")
    ]


class AmazonBedrockAccessKeysLoginAccountParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    access_key_id: Annotated[str, Field(alias="accessKeyId")]
    region: str
    secret_access_key: Annotated[str, Field(alias="secretAccessKey")]
    session_token: Annotated[str | None, Field(alias="sessionToken")] = None
    type: Annotated[
        Literal["amazonBedrockAccessKeys"],
        Field(title="AmazonBedrockAccessKeysv2::LoginAccountParamsType"),
    ]


class ApiKeyLoginAccountResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["apiKey"], Field(title="ApiKeyv2::LoginAccountResponseType")]


class ChatgptLoginAccountResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    auth_url: Annotated[
        str,
        Field(
            alias="authUrl",
            description="URL the client should open in a browser to initiate the OAuth flow.",
        ),
    ]
    login_id: Annotated[str, Field(alias="loginId")]
    type: Annotated[Literal["chatgpt"], Field(title="Chatgptv2::LoginAccountResponseType")]


class ChatgptDeviceCodeLoginAccountResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    login_id: Annotated[str, Field(alias="loginId")]
    type: Annotated[
        Literal["chatgptDeviceCode"], Field(title="ChatgptDeviceCodev2::LoginAccountResponseType")
    ]
    user_code: Annotated[
        str,
        Field(alias="userCode", description="One-time code the user must enter after signing in."),
    ]
    verification_url: Annotated[
        str,
        Field(
            alias="verificationUrl",
            description="URL the client should open in a browser to complete device code authorization.",
        ),
    ]


class ChatgptAuthTokensLoginAccountResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[
        Literal["chatgptAuthTokens"], Field(title="ChatgptAuthTokensv2::LoginAccountResponseType")
    ]


class AmazonBedrockLoginAccountResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[
        Literal["amazonBedrock"], Field(title="AmazonBedrockv2::LoginAccountResponseType")
    ]


class LoginAccountResponse(
    RootModel[
        ApiKeyLoginAccountResponse
        | ChatgptLoginAccountResponse
        | ChatgptDeviceCodeLoginAccountResponse
        | ChatgptAuthTokensLoginAccountResponse
        | AmazonBedrockLoginAccountResponse
    ]
):
    root: Annotated[
        ApiKeyLoginAccountResponse
        | ChatgptLoginAccountResponse
        | ChatgptDeviceCodeLoginAccountResponse
        | ChatgptAuthTokensLoginAccountResponse
        | AmazonBedrockLoginAccountResponse,
        Field(title="LoginAccountResponse"),
    ]


class LoginAppBrand(Enum):
    codex = "codex"
    chatgpt = "chatgpt"


class LogoutAccountResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ManagedHooksRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    interrupt: Annotated[
        list[ConfiguredHookMatcherGroup] | None, Field(alias="Interrupt", validate_default=True)
    ] = []
    permission_request: Annotated[
        list[ConfiguredHookMatcherGroup], Field(alias="PermissionRequest")
    ]
    post_compact: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="PostCompact")]
    post_model_request: Annotated[
        list[ConfiguredHookMatcherGroup] | None,
        Field(alias="PostModelRequest", validate_default=True),
    ] = []
    post_tool_use: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="PostToolUse")]
    pre_compact: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="PreCompact")]
    pre_model_request: Annotated[
        list[ConfiguredHookMatcherGroup] | None,
        Field(alias="PreModelRequest", validate_default=True),
    ] = []
    pre_tool_use: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="PreToolUse")]
    session_end: Annotated[
        list[ConfiguredHookMatcherGroup] | None, Field(alias="SessionEnd", validate_default=True)
    ] = []
    session_start: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="SessionStart")]
    stop: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="Stop")]
    subagent_start: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="SubagentStart")]
    subagent_stop: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="SubagentStop")]
    user_prompt_submit: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="UserPromptSubmit")]
    managed_dir: Annotated[str | None, Field(alias="managedDir")] = None
    windows_managed_dir: Annotated[str | None, Field(alias="windowsManagedDir")] = None


class MarketplaceAddParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    ref_name: Annotated[str | None, Field(alias="refName")] = None
    source: str
    sparse_paths: Annotated[list[str] | None, Field(alias="sparsePaths")] = None


class MarketplaceAddResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    already_added: Annotated[bool, Field(alias="alreadyAdded")]
    installed_root: Annotated[AbsolutePathBuf, Field(alias="installedRoot")]
    marketplace_name: Annotated[str, Field(alias="marketplaceName")]


class MarketplaceInterface(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    display_name: Annotated[str | None, Field(alias="displayName")] = None


class MarketplaceLoadErrorInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_path: Annotated[AbsolutePathBuf, Field(alias="marketplacePath")]
    message: str


class MarketplaceRemoveParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_name: Annotated[str, Field(alias="marketplaceName")]


class MarketplaceRemoveResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    installed_root: Annotated[AbsolutePathBuf | None, Field(alias="installedRoot")] = None
    marketplace_name: Annotated[str, Field(alias="marketplaceName")]


class MarketplaceUpgradeErrorInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_name: Annotated[str, Field(alias="marketplaceName")]
    message: str


class MarketplaceUpgradeParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_name: Annotated[str | None, Field(alias="marketplaceName")] = None


class MarketplaceUpgradeResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    errors: list[MarketplaceUpgradeErrorInfo]
    selected_marketplaces: Annotated[list[str], Field(alias="selectedMarketplaces")]
    upgraded_roots: Annotated[list[AbsolutePathBuf], Field(alias="upgradedRoots")]


class McpAppDisplayMode(Enum):
    inline = "inline"
    fullscreen = "fullscreen"


class McpAppUi(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    preferred_model_display_mode: Annotated[
        McpAppDisplayMode, Field(alias="preferredModelDisplayMode")
    ]
    resource_uri: Annotated[str, Field(alias="resourceUri")]


class McpAuthStatus(Enum):
    unknown = "unknown"
    unsupported = "unsupported"
    not_logged_in = "notLoggedIn"
    bearer_token = "bearerToken"
    o_auth = "oAuth"


class McpResourceReadTarget(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    connector_id: Annotated[str, Field(alias="connectorId")]
    link_id: Annotated[
        str | None,
        Field(
            alias="linkId",
            description="Null explicitly requests no-auth access, subject to the app's resource policy.",
        ),
    ]


class McpServerConnectionStatus(Enum):
    not_started = "notStarted"
    starting = "starting"
    connected = "connected"
    authentication_required = "authenticationRequired"
    failed = "failed"
    cancelled = "cancelled"
    disabled = "disabled"


class McpServerEventNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: str
    params: Any


class McpServerEventStreamNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    notification: McpServerEventNotification
    subscription_id: Annotated[str, Field(alias="subscriptionId")]


class McpServerInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    description: str | None = None
    icons: list[Any] | None = None
    name: str
    title: str | None = None
    version: str
    website_url: Annotated[str | None, Field(alias="websiteUrl")] = None


class McpServerMigration(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str


class McpServerOauthClientRegistration(Enum):
    auto = "auto"
    cimd = "cimd"
    dcr = "dcr"


class McpServerOauthLoginCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    error: str | None = None
    login_id: Annotated[
        str | None,
        Field(
            alias="loginId",
            description="Identifies the explicit login attempt. Older servers omit this field.",
        ),
    ] = None
    name: str
    success: bool
    thread_id: Annotated[str | None, Field(alias="threadId")] = None


class McpServerOauthLoginParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    client_registration: Annotated[
        McpServerOauthClientRegistration | None,
        Field(
            alias="clientRegistration",
            description="Registration strategy for this login only; omission selects automatic discovery.",
        ),
    ] = None
    name: str
    scopes: list[str] | None = None
    thread_id: Annotated[str | None, Field(alias="threadId")] = None
    timeout_secs: Annotated[int | None, Field(alias="timeoutSecs")] = None


class McpServerOauthLoginResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    authorization_url: Annotated[str, Field(alias="authorizationUrl")]
    login_id: Annotated[
        str | None,
        Field(
            alias="loginId",
            description="Identifies this login attempt across the response and completion notification. Older servers omit this field; current servers always return it.",
        ),
    ] = None


class McpServerRefreshResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class McpServerStartupFailureReason(RootModel[Literal["reauthenticationRequired"]]):
    root: Literal["reauthenticationRequired"]


class McpServerStartupState(Enum):
    starting = "starting"
    ready = "ready"
    failed = "failed"
    cancelled = "cancelled"


class McpServerStatusDetail(Enum):
    full = "full"
    tools_and_auth_only = "toolsAndAuthOnly"


class McpServerStatusUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    error: str | None = None
    failure_reason: Annotated[
        McpServerStartupFailureReason | None, Field(alias="failureReason")
    ] = None
    name: str
    status: McpServerStartupState
    thread_id: Annotated[str | None, Field(alias="threadId")] = None


class McpServerToolCallParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    field_meta: Annotated[Any | None, Field(alias="_meta")] = None
    arguments: Any | None = None
    server: str
    thread_id: Annotated[str, Field(alias="threadId")]
    tool: str


class McpServerToolCallResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    field_meta: Annotated[Any | None, Field(alias="_meta")] = None
    content: list[Any]
    is_error: Annotated[bool | None, Field(alias="isError")] = None
    structured_content: Annotated[Any | None, Field(alias="structuredContent")] = None


class McpToolCallAppContext(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    action_name: Annotated[str | None, Field(alias="actionName")] = None
    app_name: Annotated[str | None, Field(alias="appName")] = None
    connector_id: Annotated[str, Field(alias="connectorId")]
    link_id: Annotated[str | None, Field(alias="linkId")] = None
    resource_uri: Annotated[str | None, Field(alias="resourceUri")] = None


class McpToolCallError(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message: str


class McpToolCallProgressNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item_id: Annotated[str, Field(alias="itemId")]
    message: str
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class McpToolCallResult(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    field_meta: Annotated[Any | None, Field(alias="_meta")] = None
    content: list[Any]
    structured_content: Annotated[Any | None, Field(alias="structuredContent")] = None


class McpToolCallStatus(Enum):
    in_progress = "inProgress"
    completed = "completed"
    failed = "failed"


class MemoryCitationEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    line_end: Annotated[int, Field(alias="lineEnd", ge=0)]
    line_start: Annotated[int, Field(alias="lineStart", ge=0)]
    note: str
    path: str


class MergeStrategy(Enum):
    replace = "replace"
    upsert = "upsert"


class MessagePhase(Enum):
    commentary = "commentary"
    partial_answer = "partial_answer"
    final_answer = "final_answer"


class MisalignmentSteer(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message: str


class ModeKind(Enum):
    plan = "plan"
    default = "default"


class ModelAccessPrograms(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cyber: Annotated[list[CyberAccessProgram], Field(description="Accepted explicit selections.")]


class ModelAvailabilityNux(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message: str


class ModelListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cursor: Annotated[
        str | None, Field(description="Opaque pagination cursor returned by a previous call.")
    ] = None
    include_hidden: Annotated[
        bool | None,
        Field(
            alias="includeHidden",
            description="When true, include models that are hidden from the default picker list.",
        ),
    ] = None
    limit: Annotated[
        int | None,
        Field(description="Optional page size; defaults to a reasonable server-side value.", ge=0),
    ] = None


class ModelProviderCapabilitiesReadParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ModelProviderCapabilitiesReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    image_generation: Annotated[bool, Field(alias="imageGeneration")]
    web_search: Annotated[bool, Field(alias="webSearch")]


class ModelRerouteReason(RootModel[Literal["highRiskCyberActivity"]]):
    root: Literal["highRiskCyberActivity"]


class ModelReroutedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    from_model: Annotated[str, Field(alias="fromModel")]
    reason: ModelRerouteReason
    thread_id: Annotated[str, Field(alias="threadId")]
    to_model: Annotated[str, Field(alias="toModel")]
    turn_id: Annotated[str, Field(alias="turnId")]


class ModelSafetyBufferingUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    faster_model: Annotated[str | None, Field(alias="fasterModel")] = None
    model: str
    reasons: list[str]
    show_buffering_ui: Annotated[bool, Field(alias="showBufferingUi")]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]
    use_cases: Annotated[list[str], Field(alias="useCases")]


class ModelServiceTier(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    description: str
    id: str
    name: str


class ModelUpgradeInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    migration_markdown: Annotated[str | None, Field(alias="migrationMarkdown")] = None
    model: str
    model_link: Annotated[str | None, Field(alias="modelLink")] = None
    retirement_at: Annotated[
        int | None,
        Field(
            alias="retirementAt",
            description="Informational Unix timestamp for this upgrade's scheduled retirement, if known.",
        ),
    ] = None
    upgrade_copy: Annotated[str | None, Field(alias="upgradeCopy")] = None


class ModelVerification(RootModel[Literal["trustedAccessForCyber"]]):
    root: Literal["trustedAccessForCyber"]


class ModelVerificationNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]
    verifications: list[ModelVerification]


class MultiAgentModeValue(Enum):
    explicit_request_only = "explicitRequestOnly"
    proactive = "proactive"


class CustomMultiAgentMode(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    custom: str


class MultiAgentMode(RootModel[MultiAgentModeValue | CustomMultiAgentMode]):
    root: Annotated[
        MultiAgentModeValue | CustomMultiAgentMode,
        Field(
            description="Controls the effective multi-agent delegation instructions for a turn. `custom` means the configured mode hint defines the policy instead of a built-in policy."
        ),
    ]


class MultiAgentVersion(Enum):
    disabled = "disabled"
    v1 = "v1"
    v2 = "v2"


class NetworkAccess(Enum):
    restricted = "restricted"
    enabled = "enabled"


class NetworkApprovalProtocol(Enum):
    http = "http"
    https = "https"
    socks5_tcp = "socks5Tcp"
    socks5_udp = "socks5Udp"


class NetworkDomainPermission(Enum):
    allow = "allow"
    deny = "deny"


class NetworkRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    allow_local_binding: Annotated[bool | None, Field(alias="allowLocalBinding")] = None
    allow_unix_sockets: Annotated[
        list[str] | None,
        Field(
            alias="allowUnixSockets",
            description="Legacy compatibility view derived from `unix_sockets`.",
        ),
    ] = None
    allow_upstream_proxy: Annotated[bool | None, Field(alias="allowUpstreamProxy")] = None
    allowed_domains: Annotated[
        list[str] | None,
        Field(
            alias="allowedDomains", description="Legacy compatibility view derived from `domains`."
        ),
    ] = None
    dangerously_allow_all_unix_sockets: Annotated[
        bool | None, Field(alias="dangerouslyAllowAllUnixSockets")
    ] = None
    dangerously_allow_non_loopback_proxy: Annotated[
        bool | None, Field(alias="dangerouslyAllowNonLoopbackProxy")
    ] = None
    denied_domains: Annotated[
        list[str] | None,
        Field(
            alias="deniedDomains", description="Legacy compatibility view derived from `domains`."
        ),
    ] = None
    domains: Annotated[
        dict[str, Any] | None,
        Field(description="Canonical network permission map for `experimental_network`."),
    ] = None
    enabled: bool | None = None
    http_port: Annotated[int | None, Field(alias="httpPort", ge=0)] = None
    managed_allowed_domains_only: Annotated[
        bool | None,
        Field(
            alias="managedAllowedDomainsOnly",
            description="When true, only managed allowlist entries are respected while managed network enforcement is active.",
        ),
    ] = None
    review_domains: Annotated[
        list[str] | None,
        Field(
            alias="reviewDomains",
            description="Host patterns routed to network approval before ordinary allow rules.",
        ),
    ] = None
    socks_port: Annotated[int | None, Field(alias="socksPort", ge=0)] = None
    unix_sockets: Annotated[
        dict[str, Any] | None,
        Field(
            alias="unixSockets",
            description="Canonical unix socket permission map for `experimental_network`.",
        ),
    ] = None


class NetworkUnixSocketPermission(Enum):
    allow = "allow"
    deny = "deny"


class NonSteerableTurnKind(Enum):
    review = "review"
    compact = "compact"


class NullableGetAccountRateLimitsParams(RootModel[GetAccountRateLimitsParams | None]):
    root: Annotated[
        GetAccountRateLimitsParams | None, Field(title="Nullable_GetAccountRateLimitsParams")
    ]


class NullableGetAccountTokenUsageParams(RootModel[GetAccountTokenUsageParams | None]):
    root: Annotated[
        GetAccountTokenUsageParams | None, Field(title="Nullable_GetAccountTokenUsageParams")
    ]


class PatchApplyStatus(Enum):
    in_progress = "inProgress"
    completed = "completed"
    failed = "failed"
    declined = "declined"


class AddPatchChangeKind(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["add"], Field(title="AddPatchChangeKindType")]


class DeletePatchChangeKind(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["delete"], Field(title="DeletePatchChangeKindType")]


class UpdatePatchChangeKind(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    move_path: str | None = None
    type: Annotated[Literal["update"], Field(title="UpdatePatchChangeKindType")]


class PatchChangeKind(
    RootModel[AddPatchChangeKind | DeletePatchChangeKind | UpdatePatchChangeKind]
):
    root: AddPatchChangeKind | DeletePatchChangeKind | UpdatePatchChangeKind


class PathUri(RootModel[str]):
    root: str


class PermissionProfileListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cursor: Annotated[
        str | None, Field(description="Opaque pagination cursor returned by a previous call.")
    ] = None
    cwd: Annotated[
        str | None,
        Field(description="Optional working directory to resolve project config layers."),
    ] = None
    limit: Annotated[
        int | None, Field(description="Optional page size; defaults to the full result set.", ge=0)
    ] = None


class PermissionProfileSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    allowed: Annotated[
        bool, Field(description="Whether the effective requirements allow selecting this profile.")
    ]
    description: Annotated[
        str | None, Field(description="Optional user-facing description for display in clients.")
    ] = None
    id: Annotated[str, Field(description="Available permission profile identifier.")]


class Personality(Enum):
    none = "none"
    friendly = "friendly"
    pragmatic = "pragmatic"


class PlanDeltaNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    delta: str
    item_id: Annotated[str, Field(alias="itemId")]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class PlanType(str, Enum):
    free = "free"
    go = "go"
    plus = "plus"
    pro = "pro"
    prolite = "prolite"
    promax = "promax"
    team = "team"
    self_serve_business_prolite = "self_serve_business_prolite"
    self_serve_business_usage_based = "self_serve_business_usage_based"
    business = "business"
    ent26 = "ent26"
    enterprise_cbp_automation = "enterprise_cbp_automation"
    enterprise_cbp_usage_based = "enterprise_cbp_usage_based"
    enterprise = "enterprise"
    edu = "edu"
    edu_plus = "edu_plus"
    edu_pro = "edu_pro"
    sci = "sci"
    sci_plus = "sci_plus"
    unknown = "unknown"

    @classmethod
    def _missing_(cls, value: object) -> PlanType | None:
        if not isinstance(value, str) or not value:
            return None
        member = str.__new__(cls, value)
        member._name_ = value
        member._value_ = value
        return member


class PluginAuthPolicy(Enum):
    on_install = "ON_INSTALL"
    on_use = "ON_USE"


class PluginAvailability(Enum):
    disabled_by_admin = "DISABLED_BY_ADMIN"
    available = "AVAILABLE"


class PluginDisabledReason(Enum):
    disabled_by_admin = "disabled_by_admin"
    plan_not_eligible = "plan_not_eligible"
    required_app_unavailable = "required_app_unavailable"
    unknown = "unknown"


class PluginHookSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    event_name: Annotated[HookEventName, Field(alias="eventName")]
    key: str


class PluginInstallParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    install_attempt_id: Annotated[
        str | None,
        Field(
            alias="installAttemptId",
            description="Client-generated identifier used to correlate one installation attempt.",
        ),
    ] = None
    marketplace_path: Annotated[AbsolutePathBuf | None, Field(alias="marketplacePath")] = None
    plugin_name: Annotated[str, Field(alias="pluginName")]
    remote_marketplace_name: Annotated[str | None, Field(alias="remoteMarketplaceName")] = None


class PluginInstallPolicy(Enum):
    not_available = "NOT_AVAILABLE"
    available = "AVAILABLE"
    installed_by_default = "INSTALLED_BY_DEFAULT"


class PluginInstallPolicySource(Enum):
    workspace_setting = "WORKSPACE_SETTING"
    implicit_canonical_app = "IMPLICIT_CANONICAL_APP"


class PluginInstallResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    apps_needing_auth: Annotated[list[AppSummary], Field(alias="appsNeedingAuth")]
    auth_policy: Annotated[PluginAuthPolicy, Field(alias="authPolicy")]


class PluginInstalledParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwds: Annotated[
        list[AbsolutePathBuf] | None,
        Field(description="Optional working directories used to discover repo marketplaces."),
    ] = None
    install_suggestion_plugin_names: Annotated[
        list[str] | None,
        Field(
            alias="installSuggestionPluginNames",
            description="Additional uninstalled plugin names that should be returned when present locally. This is used by mention surfaces that intentionally expose install entrypoints.",
        ),
    ] = None


class PluginInterface(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    brand_color: Annotated[str | None, Field(alias="brandColor")] = None
    capabilities: list[str]
    category: str | None = None
    composer_icon: Annotated[
        AbsolutePathBuf | None,
        Field(
            alias="composerIcon",
            description="Local composer icon path, resolved from the installed plugin package.",
        ),
    ] = None
    composer_icon_url: Annotated[
        str | None,
        Field(
            alias="composerIconUrl", description="Remote composer icon URL from the plugin catalog."
        ),
    ] = None
    default_prompt: Annotated[
        list[str] | None,
        Field(
            alias="defaultPrompt",
            description="Starter prompts for the plugin. Capped at 3 entries with a maximum of 128 characters per entry.",
        ),
    ] = None
    developer_name: Annotated[str | None, Field(alias="developerName")] = None
    display_name: Annotated[str | None, Field(alias="displayName")] = None
    logo: Annotated[
        AbsolutePathBuf | None,
        Field(description="Local logo path, resolved from the installed plugin package."),
    ] = None
    logo_dark: Annotated[
        AbsolutePathBuf | None,
        Field(
            alias="logoDark",
            description="Local dark-mode logo path, resolved from the installed plugin package.",
        ),
    ] = None
    logo_url: Annotated[
        str | None, Field(alias="logoUrl", description="Remote logo URL from the plugin catalog.")
    ] = None
    logo_url_dark: Annotated[
        str | None,
        Field(
            alias="logoUrlDark", description="Remote dark-mode logo URL from the plugin catalog."
        ),
    ] = None
    long_description: Annotated[str | None, Field(alias="longDescription")] = None
    privacy_policy_url: Annotated[str | None, Field(alias="privacyPolicyUrl")] = None
    screenshot_urls: Annotated[
        list[str],
        Field(
            alias="screenshotUrls", description="Remote screenshot URLs from the plugin catalog."
        ),
    ]
    screenshots: Annotated[
        list[AbsolutePathBuf],
        Field(description="Local screenshot paths, resolved from the installed plugin package."),
    ]
    short_description: Annotated[str | None, Field(alias="shortDescription")] = None
    terms_of_service_url: Annotated[str | None, Field(alias="termsOfServiceUrl")] = None
    website_url: Annotated[str | None, Field(alias="websiteUrl")] = None


class PluginListMarketplaceKind(Enum):
    local = "local"
    vertical = "vertical"
    workspace_directory = "workspace-directory"
    shared_with_me = "shared-with-me"
    created_by_me_remote = "created-by-me-remote"


class PluginListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwds: Annotated[
        list[AbsolutePathBuf] | None,
        Field(
            description="Optional working directories used to discover repo marketplaces. When omitted, only home-scoped marketplaces and the official curated marketplace are considered."
        ),
    ] = None
    force_refetch: Annotated[
        bool | None,
        Field(
            alias="forceRefetch",
            description="Whether the client requests a fresh remote plugin catalog fetch.",
        ),
    ] = None
    marketplace_kinds: Annotated[
        list[PluginListMarketplaceKind] | None,
        Field(
            alias="marketplaceKinds",
            description="Optional marketplace kind filter. When omitted, only local marketplaces are queried, plus the default remote catalog when enabled by feature flag.",
        ),
    ] = None


class PluginReadParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_path: Annotated[AbsolutePathBuf | None, Field(alias="marketplacePath")] = None
    plugin_name: Annotated[str, Field(alias="pluginName")]
    remote_marketplace_name: Annotated[str | None, Field(alias="remoteMarketplaceName")] = None


class PluginReconcileChangedPlugin(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    has_apps: Annotated[bool, Field(alias="hasApps")]
    has_hooks: Annotated[bool, Field(alias="hasHooks")]
    has_mcps: Annotated[bool, Field(alias="hasMcps")]
    has_skills: Annotated[
        bool,
        Field(
            alias="hasSkills",
            description="Whether either bundle declares skill roots; not a validated inventory of enabled skills.",
        ),
    ]
    id: Annotated[
        str, Field(description="Local plugin ID (`name@marketplace`), matching `PluginSummary.id`.")
    ]


class PluginReconcileParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    reason: Annotated[
        str | None,
        Field(
            description="Optional client-provided reason recorded with the reconciliation attempt."
        ),
    ] = None


class PluginReconcileResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    changed_plugins: Annotated[
        list[PluginReconcileChangedPlugin],
        Field(
            alias="changedPlugins",
            description="Plugins affected by bundle changes, enablement changes, or removals. Installed-state changes compare against the previous cached snapshot, including cached reinstalls. Removal hints survive cache cleanup failures; unchanged plugins are omitted.",
        ),
    ]
    failed_materialization_remote_plugin_ids: Annotated[
        list[str],
        Field(
            alias="failedMaterializationRemotePluginIds",
            description="Subset of failures for which the requested bundle could not be materialized. A previously cached version may still be available.",
        ),
    ]
    failed_remote_plugin_ids: Annotated[
        list[str],
        Field(
            alias="failedRemotePluginIds",
            description="Backend remote plugin IDs whose bundle or identity update failed.",
        ),
    ]


class PluginSearchScope(Enum):
    global_ = "global"
    workspace = "workspace"
    personal = "personal"


class PluginShareCheckoutParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    remote_plugin_id: Annotated[str, Field(alias="remotePluginId")]


class PluginShareCheckoutResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_name: Annotated[str, Field(alias="marketplaceName")]
    marketplace_path: Annotated[AbsolutePathBuf, Field(alias="marketplacePath")]
    plugin_id: Annotated[str, Field(alias="pluginId")]
    plugin_name: Annotated[str, Field(alias="pluginName")]
    plugin_path: Annotated[AbsolutePathBuf, Field(alias="pluginPath")]
    remote_plugin_id: Annotated[str, Field(alias="remotePluginId")]
    remote_version: Annotated[str | None, Field(alias="remoteVersion")] = None


class PluginShareDeleteParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    remote_plugin_id: Annotated[str, Field(alias="remotePluginId")]


class PluginShareDeleteResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class PluginShareDiscoverability(Enum):
    listed = "LISTED"
    unlisted = "UNLISTED"
    private = "PRIVATE"


class PluginShareListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class PluginSharePrincipalRole(Enum):
    reader = "reader"
    editor = "editor"
    owner = "owner"


class PluginSharePrincipalType(Enum):
    user = "user"
    group = "group"
    workspace = "workspace"


class PluginShareSaveResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    can_publish_to_workspace: Annotated[bool | None, Field(alias="canPublishToWorkspace")] = None
    remote_plugin_id: Annotated[str, Field(alias="remotePluginId")]
    share_url: Annotated[str, Field(alias="shareUrl")]


class PluginShareTargetRole(Enum):
    reader = "reader"
    editor = "editor"


class PluginShareUpdateDiscoverability(Enum):
    unlisted = "UNLISTED"
    private = "PRIVATE"
    listed = "LISTED"


class PluginSkillReadParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    remote_marketplace_name: Annotated[str, Field(alias="remoteMarketplaceName")]
    remote_plugin_id: Annotated[str, Field(alias="remotePluginId")]
    skill_name: Annotated[str, Field(alias="skillName")]


class PluginSkillReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    contents: str | None = None


class LocalPluginSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: AbsolutePathBuf
    type: Annotated[Literal["local"], Field(title="LocalPluginSourceType")]


class GitPluginSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: str | None = None
    ref_name: Annotated[str | None, Field(alias="refName")] = None
    sha: str | None = None
    type: Annotated[Literal["git"], Field(title="GitPluginSourceType")]
    url: str


class NpmPluginSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    package: str
    registry: Annotated[
        str | None,
        Field(
            description="Optional HTTPS registry URL. Authentication stays in the user's npm config."
        ),
    ] = None
    type: Annotated[Literal["npm"], Field(title="NpmPluginSourceType")]
    version: Annotated[str | None, Field(description="Optional npm version or version range.")] = (
        None
    )


class RemotePluginSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["remote"], Field(title="RemotePluginSourceType")]


class PluginSource(
    RootModel[LocalPluginSource | GitPluginSource | NpmPluginSource | RemotePluginSource]
):
    root: LocalPluginSource | GitPluginSource | NpmPluginSource | RemotePluginSource


class PluginUninstallParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    plugin_id: Annotated[str, Field(alias="pluginId")]


class PluginUninstallResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class PluginsMigration(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_name: Annotated[str, Field(alias="marketplaceName")]
    plugin_names: Annotated[list[str], Field(alias="pluginNames")]


class ProcessExitedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    exit_code: Annotated[int, Field(alias="exitCode", description="Process exit code.")]
    process_handle: Annotated[
        str,
        Field(
            alias="processHandle",
            description="Client-supplied, connection-scoped `processHandle` from `process/spawn`.",
        ),
    ]
    stderr: Annotated[
        str,
        Field(
            description="Buffered stderr capture.\n\nEmpty when stderr was streamed via `process/outputDelta`."
        ),
    ]
    stderr_cap_reached: Annotated[
        bool,
        Field(
            alias="stderrCapReached",
            description="Whether stderr reached `outputBytesCap`.\n\nIn streaming mode, stderr is empty and cap state is also reported on the final stderr `process/outputDelta` notification.",
        ),
    ]
    stdout: Annotated[
        str,
        Field(
            description="Buffered stdout capture.\n\nEmpty when stdout was streamed via `process/outputDelta`."
        ),
    ]
    stdout_cap_reached: Annotated[
        bool,
        Field(
            alias="stdoutCapReached",
            description="Whether stdout reached `outputBytesCap`.\n\nIn streaming mode, stdout is empty and cap state is also reported on the final stdout `process/outputDelta` notification.",
        ),
    ]


class ProcessOutputStream(Enum):
    stdout = "stdout"
    stderr = "stderr"


class ProcessTerminalSize(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cols: Annotated[int, Field(description="Terminal width in character cells.", ge=0)]
    rows: Annotated[int, Field(description="Terminal height in character cells.", ge=0)]


class ProjectChangeType(Enum):
    created = "created"
    updated = "updated"
    deleted = "deleted"


class ProjectChangedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    change_type: Annotated[ProjectChangeType, Field(alias="changeType")]
    project_id: Annotated[str, Field(alias="projectId")]


class ProjectRoot(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: AbsolutePathBuf


class ProjectSortKey(Enum):
    position = "position"
    recency_at = "recencyAt"


class RateLimitReachedType(Enum):
    rate_limit_reached = "rate_limit_reached"
    workspace_owner_credits_depleted = "workspace_owner_credits_depleted"
    workspace_member_credits_depleted = "workspace_member_credits_depleted"
    workspace_owner_usage_limit_reached = "workspace_owner_usage_limit_reached"
    workspace_member_usage_limit_reached = "workspace_member_usage_limit_reached"


class RateLimitResetCreditStatus(Enum):
    available = "available"
    redeeming = "redeeming"
    redeemed = "redeemed"
    unknown = "unknown"


class RateLimitResetType(Enum):
    codex_rate_limits = "codexRateLimits"
    unknown = "unknown"


class RateLimitWindow(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    resets_at: Annotated[int | None, Field(alias="resetsAt")] = None
    used_percent: Annotated[int, Field(alias="usedPercent")]
    window_duration_mins: Annotated[int | None, Field(alias="windowDurationMins")] = None


class RealtimeConversationVersion(Enum):
    v1 = "v1"
    v2 = "v2"
    v3 = "v3"


class RealtimeOutputModality(Enum):
    text = "text"
    audio = "audio"


class RealtimeVoice(Enum):
    alloy = "alloy"
    arbor = "arbor"
    ash = "ash"
    aube = "aube"
    ballad = "ballad"
    breeze = "breeze"
    bubbie = "bubbie"
    cedar = "cedar"
    coral = "coral"
    cove = "cove"
    echo = "echo"
    ember = "ember"
    haetsal = "haetsal"
    hanul = "hanul"
    himari = "himari"
    juniper = "juniper"
    leher = "leher"
    maple = "maple"
    marin = "marin"
    miko = "miko"
    neer = "neer"
    porto = "porto"
    rindo = "rindo"
    rio = "rio"
    rivage = "rivage"
    sage = "sage"
    selva = "selva"
    shimmer = "shimmer"
    sol = "sol"
    sonna = "sonna"
    spruce = "spruce"
    tinta = "tinta"
    vale = "vale"
    verse = "verse"
    viola = "viola"


class RealtimeVoicesList(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    default_v1: Annotated[RealtimeVoice, Field(alias="defaultV1")]
    default_v2: Annotated[RealtimeVoice, Field(alias="defaultV2")]
    v1: list[RealtimeVoice]
    v2: list[RealtimeVoice]
    v3: list[RealtimeVoice] | None = []


class ReasoningEffort(str, Enum):
    none = "none"
    minimal = "minimal"
    low = "low"
    medium = "medium"
    high = "high"
    xhigh = "xhigh"
    max = "max"
    ultra = "ultra"

    @classmethod
    def _missing_(cls, value: object) -> ReasoningEffort | None:
        if not isinstance(value, str) or not value:
            return None
        member = str.__new__(cls, value)
        member._name_ = value
        member._value_ = value
        return member


class ReasoningEffortOption(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    description: str
    reasoning_effort: Annotated[ReasoningEffort, Field(alias="reasoningEffort")]


class ReasoningTextReasoningItemContent(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    text: str
    type: Annotated[Literal["reasoning_text"], Field(title="ReasoningTextReasoningItemContentType")]


class TextReasoningItemContent(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    text: str
    type: Annotated[Literal["text"], Field(title="TextReasoningItemContentType")]


class ReasoningItemContent(RootModel[ReasoningTextReasoningItemContent | TextReasoningItemContent]):
    root: ReasoningTextReasoningItemContent | TextReasoningItemContent


class SummaryTextReasoningItemReasoningSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    text: str
    type: Annotated[
        Literal["summary_text"], Field(title="SummaryTextReasoningItemReasoningSummaryType")
    ]


class ReasoningItemReasoningSummary(RootModel[SummaryTextReasoningItemReasoningSummary]):
    root: SummaryTextReasoningItemReasoningSummary


class ReasoningSummaryValue(Enum):
    auto = "auto"
    concise = "concise"
    detailed = "detailed"


class ReasoningSummary(RootModel[ReasoningSummaryValue | Literal["none"]]):
    root: Annotated[
        ReasoningSummaryValue | Literal["none"],
        Field(
            description="A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process. See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#reasoning-summaries"
        ),
    ]


class ReasoningSummaryPartAddedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item_id: Annotated[str, Field(alias="itemId")]
    summary_index: Annotated[int, Field(alias="summaryIndex")]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class ReasoningSummaryTextDeltaNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    delta: str
    item_id: Annotated[str, Field(alias="itemId")]
    summary_index: Annotated[int, Field(alias="summaryIndex")]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class ReasoningTextDeltaNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    content_index: Annotated[int, Field(alias="contentIndex")]
    delta: str
    item_id: Annotated[str, Field(alias="itemId")]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class RemoteControlConnectionStatus(Enum):
    disabled = "disabled"
    connecting = "connecting"
    connected = "connected"
    errored = "errored"


class RemoteControlDisableParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    ephemeral: bool | None = None


class RemoteControlEnableParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    ephemeral: bool | None = None


class RemoteControlStatusChangedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    environment_id: Annotated[str | None, Field(alias="environmentId")] = None
    installation_id: Annotated[str, Field(alias="installationId")]
    server_name: Annotated[str, Field(alias="serverName")]
    status: RemoteControlConnectionStatus


class RequestHeader(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str
    value: str


class RequestId(RootModel[str | int]):
    root: str | int


class ResidencyRequirement(RootModel[Literal["us"]]):
    root: Literal["us"]


class Resource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    field_meta: Annotated[Any | None, Field(alias="_meta")] = None
    annotations: Any | None = None
    description: str | None = None
    icons: list[Any] | None = None
    mime_type: Annotated[str | None, Field(alias="mimeType")] = None
    name: str
    size: int | None = None
    title: str | None = None
    uri: str


class ResourceContent1(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    field_meta: Annotated[Any | None, Field(alias="_meta")] = None
    mime_type: Annotated[str | None, Field(alias="mimeType")] = None
    text: str
    uri: Annotated[str, Field(description="The URI of this resource.")]


class ResourceContent2(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    field_meta: Annotated[Any | None, Field(alias="_meta")] = None
    blob: str
    mime_type: Annotated[str | None, Field(alias="mimeType")] = None
    uri: Annotated[str, Field(description="The URI of this resource.")]


class ResourceContent(RootModel[ResourceContent1 | ResourceContent2]):
    root: Annotated[
        ResourceContent1 | ResourceContent2,
        Field(description="Contents returned when reading a resource from an MCP server."),
    ]


class ResourceTemplate(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    annotations: Any | None = None
    description: str | None = None
    mime_type: Annotated[str | None, Field(alias="mimeType")] = None
    name: str
    title: str | None = None
    uri_template: Annotated[str, Field(alias="uriTemplate")]


class AdditionalToolsResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str | None = None
    role: str
    tools: list[Any]
    type: Annotated[Literal["additional_tools"], Field(title="AdditionalToolsResponseItemType")]


class AgentMessageResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    author: str
    content: list[AgentMessageInputContent]
    id: str | None = None
    internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
    recipient: str
    type: Annotated[Literal["agent_message"], Field(title="AgentMessageResponseItemType")]


class ReasoningResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    content: list[ReasoningItemContent] | None = None
    encrypted_content: str | None = None
    id: str | None = None
    internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
    summary: list[ReasoningItemReasoningSummary]
    type: Annotated[Literal["reasoning"], Field(title="ReasoningResponseItemType")]


class LocalShellCallResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    action: LocalShellAction
    call_id: Annotated[str | None, Field(description="Set when using the Responses API.")] = None
    encrypted_content: str | None = None
    id: Annotated[
        str | None,
        Field(description="Legacy id field retained for compatibility with older payloads."),
    ] = None
    internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
    status: LocalShellStatus
    type: Annotated[Literal["local_shell_call"], Field(title="LocalShellCallResponseItemType")]


class FunctionCallResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    arguments: str
    call_id: str
    encrypted_content: str | None = None
    encrypted_function_args: list[str] | None = None
    id: str | None = None
    internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
    name: str
    namespace: str | None = None
    status: str | None = None
    type: Annotated[Literal["function_call"], Field(title="FunctionCallResponseItemType")]


class ToolSearchCallResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    arguments: Any
    call_id: str | None = None
    encrypted_content: str | None = None
    execution: str
    id: str | None = None
    internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
    status: str | None = None
    type: Annotated[Literal["tool_search_call"], Field(title="ToolSearchCallResponseItemType")]


class CustomToolCallResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    call_id: str
    encrypted_content: str | None = None
    id: str | None = None
    input: str
    internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
    name: str
    namespace: str | None = None
    status: str | None = None
    type: Annotated[Literal["custom_tool_call"], Field(title="CustomToolCallResponseItemType")]


class ToolSearchOutputResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    call_id: str | None = None
    execution: str
    id: str | None = None
    internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
    status: str
    tools: list[Any]
    type: Annotated[Literal["tool_search_output"], Field(title="ToolSearchOutputResponseItemType")]


class ImageGenerationCallResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    encrypted_content: str | None = None
    id: str | None = None
    internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
    result: str
    revised_prompt: str | None = None
    status: str
    type: Annotated[
        Literal["image_generation_call"], Field(title="ImageGenerationCallResponseItemType")
    ]


class CompactionResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    encrypted_content: str
    id: str | None = None
    internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
    type: Annotated[Literal["compaction"], Field(title="CompactionResponseItemType")]


class CompactionTriggerResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["compaction_trigger"], Field(title="CompactionTriggerResponseItemType")]


class ContextCompactionResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    encrypted_content: str | None = None
    id: str | None = None
    internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
    type: Annotated[Literal["context_compaction"], Field(title="ContextCompactionResponseItemType")]


class OtherResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["other"], Field(title="OtherResponseItemType")]


class ResponseUsageMetadata(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    amount: str | None = None
    metadata: Any | None = None


class SearchResponsesApiWebSearchAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    queries: list[str] | None = None
    query: str | None = None
    type: Annotated[Literal["search"], Field(title="SearchResponsesApiWebSearchActionType")]


class OpenPageResponsesApiWebSearchAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["open_page"], Field(title="OpenPageResponsesApiWebSearchActionType")]
    url: str | None = None


class FindInPageResponsesApiWebSearchAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    pattern: str | None = None
    type: Annotated[
        Literal["find_in_page"], Field(title="FindInPageResponsesApiWebSearchActionType")
    ]
    url: str | None = None


class OtherResponsesApiWebSearchAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["other"], Field(title="OtherResponsesApiWebSearchActionType")]


class ResponsesApiWebSearchAction(
    RootModel[
        SearchResponsesApiWebSearchAction
        | OpenPageResponsesApiWebSearchAction
        | FindInPageResponsesApiWebSearchAction
        | OtherResponsesApiWebSearchAction
    ]
):
    root: (
        SearchResponsesApiWebSearchAction
        | OpenPageResponsesApiWebSearchAction
        | FindInPageResponsesApiWebSearchAction
        | OtherResponsesApiWebSearchAction
    )


class ReviewDelivery(Enum):
    inline = "inline"
    detached = "detached"


class UncommittedChangesReviewTarget(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[
        Literal["uncommittedChanges"], Field(title="UncommittedChangesReviewTargetType")
    ]


class BaseBranchReviewTarget(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    branch: str
    type: Annotated[Literal["baseBranch"], Field(title="BaseBranchReviewTargetType")]


class CommitReviewTarget(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    sha: str
    title: Annotated[
        str | None,
        Field(description="Optional human-readable label (e.g., commit subject) for UIs."),
    ] = None
    type: Annotated[Literal["commit"], Field(title="CommitReviewTargetType")]


class CustomReviewTarget(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    instructions: str
    type: Annotated[Literal["custom"], Field(title="CustomReviewTargetType")]


class ReviewTarget(
    RootModel[
        UncommittedChangesReviewTarget
        | BaseBranchReviewTarget
        | CommitReviewTarget
        | CustomReviewTarget
    ]
):
    root: (
        UncommittedChangesReviewTarget
        | BaseBranchReviewTarget
        | CommitReviewTarget
        | CustomReviewTarget
    )


class SandboxMode(Enum):
    read_only = "read-only"
    workspace_write = "workspace-write"
    danger_full_access = "danger-full-access"


class DangerFullAccessSandboxPolicy(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["dangerFullAccess"], Field(title="DangerFullAccessSandboxPolicyType")]


class ReadOnlySandboxPolicy(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    network_access: Annotated[bool | None, Field(alias="networkAccess")] = False
    type: Annotated[Literal["readOnly"], Field(title="ReadOnlySandboxPolicyType")]


class ExternalSandboxSandboxPolicy(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    network_access: Annotated[NetworkAccess | None, Field(alias="networkAccess")] = "restricted"
    type: Annotated[Literal["externalSandbox"], Field(title="ExternalSandboxSandboxPolicyType")]


class WorkspaceWriteSandboxPolicy(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    exclude_slash_tmp: Annotated[bool | None, Field(alias="excludeSlashTmp")] = False
    exclude_tmpdir_env_var: Annotated[bool | None, Field(alias="excludeTmpdirEnvVar")] = False
    network_access: Annotated[bool | None, Field(alias="networkAccess")] = False
    type: Annotated[Literal["workspaceWrite"], Field(title="WorkspaceWriteSandboxPolicyType")]
    writable_roots: Annotated[
        list[AbsolutePathBuf] | None, Field(alias="writableRoots", validate_default=True)
    ] = []


class SandboxPolicy(
    RootModel[
        DangerFullAccessSandboxPolicy
        | ReadOnlySandboxPolicy
        | ExternalSandboxSandboxPolicy
        | WorkspaceWriteSandboxPolicy
    ]
):
    root: (
        DangerFullAccessSandboxPolicy
        | ReadOnlySandboxPolicy
        | ExternalSandboxSandboxPolicy
        | WorkspaceWriteSandboxPolicy
    )


class SandboxWorkspaceWrite(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    exclude_slash_tmp: bool | None = False
    exclude_tmpdir_env_var: bool | None = False
    network_access: bool | None = False
    writable_roots: list[str] | None = []


class DailyScheduledTaskSchedule(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    time: str
    type: Annotated[Literal["daily"], Field(title="DailyScheduledTaskScheduleType")]


class WeekdaysScheduledTaskSchedule(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    time: str
    type: Annotated[Literal["weekdays"], Field(title="WeekdaysScheduledTaskScheduleType")]


class ScheduledTaskWeekday(Enum):
    mo = "MO"
    tu = "TU"
    we = "WE"
    th = "TH"
    fr = "FR"
    sa = "SA"
    su = "SU"


class SelectedCapabilityRoot(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: Annotated[
        str, Field(description="Stable identifier supplied by the capability selection platform.")
    ]
    location: Annotated[
        CapabilityRootLocation, Field(description="Where the selected root can be resolved.")
    ]


class SendAddCreditsNudgeEmailParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    credit_type: Annotated[AddCreditsNudgeCreditType, Field(alias="creditType")]


class SendAddCreditsNudgeEmailResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    status: AddCreditsNudgeEmailStatus


class ServerDiagnosticsGauge(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str
    value: Annotated[int, Field(ge=0)]


class ServerDiagnosticsProcess(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: Annotated[int, Field(ge=0)]
    physical_footprint_bytes: Annotated[int | None, Field(alias="physicalFootprintBytes", ge=0)] = (
        None
    )
    resident_memory_bytes: Annotated[int | None, Field(alias="residentMemoryBytes", ge=0)] = None


class ProjectChangedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["project/changed"], Field(title="Project/changedNotificationMethod")]
    params: ProjectChangedNotification


class ThreadEnvironmentConnectedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/environment/connected"],
        Field(title="Thread/environment/connectedNotificationMethod"),
    ]
    params: EnvironmentConnectionNotification


class ThreadEnvironmentDisconnectedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/environment/disconnected"],
        Field(title="Thread/environment/disconnectedNotificationMethod"),
    ]
    params: EnvironmentConnectionNotification


class ItemAgentMessageDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["item/agentMessage/delta"], Field(title="Item/agentMessage/deltaNotificationMethod")
    ]
    params: AgentMessageDeltaNotification


class ItemPlanDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["item/plan/delta"], Field(title="Item/plan/deltaNotificationMethod")]
    params: PlanDeltaNotification


class ProcessExitedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["process/exited"], Field(title="Process/exitedNotificationMethod")]
    params: ProcessExitedNotification


class ItemCommandExecutionOutputDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["item/commandExecution/outputDelta"],
        Field(title="Item/commandExecution/outputDeltaNotificationMethod"),
    ]
    params: CommandExecutionOutputDeltaNotification


class ItemFileChangeOutputDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["item/fileChange/outputDelta"],
        Field(title="Item/fileChange/outputDeltaNotificationMethod"),
    ]
    params: FileChangeOutputDeltaNotification


class ItemMcpToolCallProgressServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["item/mcpToolCall/progress"],
        Field(title="Item/mcpToolCall/progressNotificationMethod"),
    ]
    params: McpToolCallProgressNotification


class McpServerOauthLoginCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["mcpServer/oauthLogin/completed"],
        Field(title="McpServer/oauthLogin/completedNotificationMethod"),
    ]
    params: McpServerOauthLoginCompletedNotification


class McpServerStartupStatusUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["mcpServer/startupStatus/updated"],
        Field(title="McpServer/startupStatus/updatedNotificationMethod"),
    ]
    params: McpServerStatusUpdatedNotification


class McpServerEventStreamNotificationServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["mcpServer/event/stream/notification"],
        Field(title="McpServer/event/stream/notificationNotificationMethod"),
    ]
    params: McpServerEventStreamNotification


class RemoteControlStatusChangedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["remoteControl/status/changed"],
        Field(title="RemoteControl/status/changedNotificationMethod"),
    ]
    params: RemoteControlStatusChangedNotification


class FsChangedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["fs/changed"], Field(title="Fs/changedNotificationMethod")]
    params: FsChangedNotification


class ItemReasoningSummaryTextDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["item/reasoning/summaryTextDelta"],
        Field(title="Item/reasoning/summaryTextDeltaNotificationMethod"),
    ]
    params: ReasoningSummaryTextDeltaNotification


class ItemReasoningSummaryPartAddedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["item/reasoning/summaryPartAdded"],
        Field(title="Item/reasoning/summaryPartAddedNotificationMethod"),
    ]
    params: ReasoningSummaryPartAddedNotification


class ItemReasoningTextDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["item/reasoning/textDelta"],
        Field(title="Item/reasoning/textDeltaNotificationMethod"),
    ]
    params: ReasoningTextDeltaNotification


class ThreadCompactedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/compacted"], Field(title="Thread/compactedNotificationMethod")
    ]
    params: ContextCompactedNotification


class ModelReroutedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["model/rerouted"], Field(title="Model/reroutedNotificationMethod")]
    params: ModelReroutedNotification


class ModelVerificationServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["model/verification"], Field(title="Model/verificationNotificationMethod")
    ]
    params: ModelVerificationNotification


class ModelProviderAuthRecoveryStartedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["modelProvider/authRecoveryStarted"],
        Field(title="ModelProvider/authRecoveryStartedNotificationMethod"),
    ]
    params: AuthRecoveryNotification


class ModelProviderAuthRecoveryCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["modelProvider/authRecoveryCompleted"],
        Field(title="ModelProvider/authRecoveryCompletedNotificationMethod"),
    ]
    params: AuthRecoveryNotification


class ModelSafetyBufferingUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["model/safetyBuffering/updated"],
        Field(title="Model/safetyBuffering/updatedNotificationMethod"),
    ]
    params: ModelSafetyBufferingUpdatedNotification


class GuardianWarningServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["guardianWarning"], Field(title="GuardianWarningNotificationMethod")]
    params: GuardianWarningNotification


class DeprecationNoticeServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["deprecationNotice"], Field(title="DeprecationNoticeNotificationMethod")
    ]
    params: DeprecationNoticeNotification


class FuzzyFileSearchSessionUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["fuzzyFileSearch/sessionUpdated"],
        Field(title="FuzzyFileSearch/sessionUpdatedNotificationMethod"),
    ]
    params: FuzzyFileSearchSessionUpdatedNotification


class FuzzyFileSearchSessionCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["fuzzyFileSearch/sessionCompleted"],
        Field(title="FuzzyFileSearch/sessionCompletedNotificationMethod"),
    ]
    params: FuzzyFileSearchSessionCompletedNotification


class ServerRequestResolvedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    request_id: Annotated[RequestId, Field(alias="requestId")]
    thread_id: Annotated[str, Field(alias="threadId")]


class SessionMigration(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: str
    path: str
    title: str | None = None


class SessionSourceValue(Enum):
    cli = "cli"
    vscode = "vscode"
    exec = "exec"
    app_server = "appServer"
    unknown = "unknown"


class CustomSessionSource(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    custom: str


class Settings(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    developer_instructions: str | None = None
    model: str
    reasoning_effort: ReasoningEffort | None = None


class SkillErrorInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message: str
    path: str


class SkillInterface(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    brand_color: Annotated[str | None, Field(alias="brandColor")] = None
    default_prompt: Annotated[str | None, Field(alias="defaultPrompt")] = None
    display_name: Annotated[str | None, Field(alias="displayName")] = None
    icon_large: Annotated[AbsolutePathBuf | None, Field(alias="iconLarge")] = None
    icon_large_url: Annotated[
        str | None,
        Field(alias="iconLargeUrl", description="Remote large icon URL from the plugin catalog."),
    ] = None
    icon_small: Annotated[AbsolutePathBuf | None, Field(alias="iconSmall")] = None
    icon_small_url: Annotated[
        str | None,
        Field(alias="iconSmallUrl", description="Remote small icon URL from the plugin catalog."),
    ] = None
    short_description: Annotated[str | None, Field(alias="shortDescription")] = None


class SkillMigration(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str


class SkillScope(Enum):
    user = "user"
    repo = "repo"
    system = "system"
    admin = "admin"


class SkillSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    description: str
    enabled: bool
    interface: SkillInterface | None = None
    name: str
    path: LegacyAppPathString | None = None
    short_description: Annotated[str | None, Field(alias="shortDescription")] = None


class SkillToolDependency(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    command: str | None = None
    description: str | None = None
    transport: str | None = None
    type: str
    url: str | None = None
    value: str


class SkillsChangedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class SkillsConfigWriteParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    enabled: bool
    name: Annotated[str | None, Field(description="Name-based selector.")] = None
    path: Annotated[AbsolutePathBuf | None, Field(description="Path-based selector.")] = None


class SkillsConfigWriteResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    effective_enabled: Annotated[bool, Field(alias="effectiveEnabled")]


class SkillsExtraRootsSetParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    extra_roots: Annotated[list[AbsolutePathBuf], Field(alias="extraRoots")]


class SkillsExtraRootsSetResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class SkillsListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwds: Annotated[
        list[str] | None,
        Field(description="When empty, defaults to the current session working directory."),
    ] = None
    force_reload: Annotated[
        bool | None,
        Field(
            alias="forceReload",
            description="When true, bypass the skills cache and re-scan skills from disk.",
        ),
    ] = None


class SortDirection(Enum):
    asc = "asc"
    desc = "desc"


class SpendControlLimitSnapshot(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    limit: str
    remaining_percent: Annotated[int, Field(alias="remainingPercent")]
    resets_at: Annotated[int, Field(alias="resetsAt")]
    used: str


class StrictReviewRequiredNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    started_at_ms: Annotated[
        int,
        Field(
            alias="startedAtMs",
            description="Unix timestamp (in milliseconds) when this review started.",
        ),
    ]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class SubAgentActivityKind(Enum):
    started = "started"
    interacted = "interacted"
    interrupted = "interrupted"
    completed = "completed"


class SubAgentSourceValue(Enum):
    review = "review"
    compact = "compact"
    memory_consolidation = "memory_consolidation"


class OtherSubAgentSource(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    other: str


class SubagentMigration(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str


class TerminalInteractionNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item_id: Annotated[str, Field(alias="itemId")]
    process_id: Annotated[str, Field(alias="processId")]
    stdin: str
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class TextElement(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    byte_range: Annotated[
        ByteRange,
        Field(
            alias="byteRange",
            description="Byte range in the parent `text` buffer that this element occupies.",
        ),
    ]
    placeholder: Annotated[
        str | None,
        Field(
            description="Optional human-readable placeholder for the element, displayed in the UI."
        ),
    ] = None


class TextPosition(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    column: Annotated[
        int, Field(description="1-based column number (in Unicode scalar values).", ge=0)
    ]
    line: Annotated[int, Field(description="1-based line number.", ge=0)]


class TextRange(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    end: TextPosition
    start: TextPosition


class ThreadActiveFlag(Enum):
    waiting_on_approval = "waitingOnApproval"
    waiting_on_user_input = "waitingOnUserInput"


class ThreadApproveGuardianDeniedActionParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    event: Annotated[
        Any, Field(description="Serialized `codex_protocol::protocol::GuardianAssessmentEvent`.")
    ]
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadApproveGuardianDeniedActionResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ThreadArchiveParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadArchiveResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ThreadArchivedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadAttachment(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    attachment_type: Annotated[str, Field(alias="attachmentType")]
    created_at: Annotated[int, Field(alias="createdAt")]
    id: str
    identity_key: Annotated[str, Field(alias="identityKey")]
    payload: Any


class ThreadAttachmentAddOutcome(Enum):
    created = "created"
    existing = "existing"


class ThreadAttachmentAddParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    attachment_type: Annotated[str, Field(alias="attachmentType")]
    identity_key: Annotated[str, Field(alias="identityKey")]
    payload: Any
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadAttachmentAddResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    attachment: ThreadAttachment
    outcome: ThreadAttachmentAddOutcome


class ThreadAttachmentListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cursor: str | None = None
    limit: Annotated[int | None, Field(ge=0)] = None
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadAttachmentListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[ThreadAttachment]
    next_cursor: Annotated[str | None, Field(alias="nextCursor")] = None


class ThreadAttachmentOperation(Enum):
    created = "created"
    deleted = "deleted"


class ThreadAttachmentOwner(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    archived: Annotated[
        bool,
        Field(
            description="Whether the owning thread is archived, not whether it is currently executing a turn."
        ),
    ]
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadAttachmentOwnerListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    archived: Annotated[
        bool | None,
        Field(
            description="Omitted or null returns all matches; false returns non-archived threads only."
        ),
    ] = None
    attachment_type: Annotated[str, Field(alias="attachmentType")]
    cursor: str | None = None
    identity_key: Annotated[str, Field(alias="identityKey")]
    limit: Annotated[int | None, Field(ge=0)] = None


class ThreadAttachmentOwnerListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[ThreadAttachmentOwner]
    next_cursor: Annotated[str | None, Field(alias="nextCursor")] = None


class ThreadAttachmentRemoveParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    attachment_type: Annotated[str, Field(alias="attachmentType")]
    identity_key: Annotated[str, Field(alias="identityKey")]
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadAttachmentRemoveResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ThreadAttachmentUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    attachment_id: Annotated[str, Field(alias="attachmentId")]
    attachment_type: Annotated[str, Field(alias="attachmentType")]
    identity_key: Annotated[str, Field(alias="identityKey")]
    operation: ThreadAttachmentOperation
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadClosedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadCompactStartParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadCompactStartResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ThreadDeleteParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadDeleteResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ThreadDeletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadEnvironment(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: LegacyAppPathString
    environment_id: Annotated[str, Field(alias="environmentId")]
    runtime_workspace_roots: Annotated[
        list[LegacyAppPathString], Field(alias="runtimeWorkspaceRoots")
    ]


class ThreadExtra(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ThreadGoalClearResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cleared: bool


class ThreadGoalClearedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadGoalGetParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadGoalMutationOrigin(Enum):
    user = "user"
    automatic = "automatic"


class ThreadGoalStatus(Enum):
    active = "active"
    paused = "paused"
    blocked = "blocked"
    usage_limited = "usageLimited"
    budget_limited = "budgetLimited"
    complete = "complete"


class ThreadHistoryMode(Enum):
    legacy = "legacy"
    paginated = "paginated"


class ThreadId(RootModel[str]):
    root: str


class ThreadInjectItemsParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    items: Annotated[
        list[Any],
        Field(
            description="Raw Responses API items to append to the thread's model-visible history."
        ),
    ]
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadInjectItemsResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class HookPromptThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    fragments: list[HookPromptFragment]
    id: str
    type: Annotated[Literal["hookPrompt"], Field(title="HookPromptThreadItemType")]


class PlanThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    text: str
    type: Annotated[Literal["plan"], Field(title="PlanThreadItemType")]


class ReasoningThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    content: list[str] | None = []
    id: str
    summary: list[str] | None = []
    type: Annotated[Literal["reasoning"], Field(title="ReasoningThreadItemType")]


class McpToolCallThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    app_context: Annotated[McpToolCallAppContext | None, Field(alias="appContext")] = None
    arguments: Any
    duration_ms: Annotated[
        int | None,
        Field(alias="durationMs", description="The duration of the MCP tool call in milliseconds."),
    ] = None
    error: McpToolCallError | None = None
    id: str
    mcp_app_resource_uri: Annotated[
        str | None,
        Field(
            alias="mcpAppResourceUri",
            description="Legacy compatibility field; prefer `mcpAppUi.resourceUri` when available.",
        ),
    ] = None
    mcp_app_ui: Annotated[
        McpAppUi | None,
        Field(
            alias="mcpAppUi",
            description="Presentation captured from the invoked descriptor; absent in older history.",
        ),
    ] = None
    plugin_id: Annotated[str | None, Field(alias="pluginId")] = None
    read_only_hint: Annotated[bool | None, Field(alias="readOnlyHint")] = None
    result: McpToolCallResult | None = None
    server: str
    status: McpToolCallStatus
    tool: str
    type: Annotated[Literal["mcpToolCall"], Field(title="McpToolCallThreadItemType")]


class DynamicToolCallThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    arguments: Any
    content_items: Annotated[
        list[DynamicToolCallOutputContentItem] | None, Field(alias="contentItems")
    ] = None
    duration_ms: Annotated[
        int | None,
        Field(
            alias="durationMs", description="The duration of the dynamic tool call in milliseconds."
        ),
    ] = None
    id: str
    namespace: str | None = None
    status: DynamicToolCallStatus
    success: bool | None = None
    tool: str
    type: Annotated[Literal["dynamicToolCall"], Field(title="DynamicToolCallThreadItemType")]


class SubAgentActivityThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    agent_path: Annotated[str, Field(alias="agentPath")]
    agent_thread_id: Annotated[str, Field(alias="agentThreadId")]
    id: str
    kind: SubAgentActivityKind
    model: Annotated[
        str | None,
        Field(
            description="Resolved model at sub-agent creation; absent from older records and other activities."
        ),
    ] = None
    reasoning_effort: Annotated[
        ReasoningEffort | None,
        Field(
            alias="reasoningEffort",
            description="Resolved reasoning effort at sub-agent creation, when known.",
        ),
    ] = None
    type: Annotated[Literal["subAgentActivity"], Field(title="SubAgentActivityThreadItemType")]


class ImageViewThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    path: LegacyAppPathString
    type: Annotated[Literal["imageView"], Field(title="ImageViewThreadItemType")]


class SleepThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    duration_ms: Annotated[int, Field(alias="durationMs", ge=0)]
    id: str
    type: Annotated[Literal["sleep"], Field(title="SleepThreadItemType")]


class FileIdThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    failure: ImageGenerationFailure | None = None
    id: str
    input_images: Annotated[
        list[ImageGenerationInputImage] | None,
        Field(
            alias="inputImages",
            description="Observed local inputs for a completed generation, absent on older items.",
        ),
    ] = None
    revised_prompt: Annotated[str | None, Field(alias="revisedPrompt")] = None
    saved_path: Annotated[AbsolutePathBuf | None, Field(alias="savedPath")] = None
    status: str
    transparent_background: Annotated[bool | None, Field(alias="transparentBackground")] = None
    type: Annotated[Literal["imageGeneration"], Field(title="ImageGenerationThreadItemType")]
    file_id: Annotated[str, Field(alias="fileId")]


class ResultThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    failure: ImageGenerationFailure | None = None
    id: str
    input_images: Annotated[
        list[ImageGenerationInputImage] | None,
        Field(
            alias="inputImages",
            description="Observed local inputs for a completed generation, absent on older items.",
        ),
    ] = None
    revised_prompt: Annotated[str | None, Field(alias="revisedPrompt")] = None
    saved_path: Annotated[AbsolutePathBuf | None, Field(alias="savedPath")] = None
    status: str
    transparent_background: Annotated[bool | None, Field(alias="transparentBackground")] = None
    type: Annotated[Literal["imageGeneration"], Field(title="ImageGenerationThreadItemType")]
    result: str


ImageGenerationThreadItem = ResultThreadItem


class EnteredReviewModeThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    review: str
    type: Annotated[Literal["enteredReviewMode"], Field(title="EnteredReviewModeThreadItemType")]


class ExitedReviewModeThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    review: str
    type: Annotated[Literal["exitedReviewMode"], Field(title="ExitedReviewModeThreadItemType")]


class ContextCompactionThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    type: Annotated[Literal["contextCompaction"], Field(title="ContextCompactionThreadItemType")]


class ItemThreadItemsListAnchor(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item_id: Annotated[str, Field(alias="itemId")]
    type: Annotated[Literal["item"], Field(title="ItemThreadItemsListAnchorType")]


class ThreadItemsListAnchor(RootModel[ItemThreadItemsListAnchor]):
    root: Annotated[
        ItemThreadItemsListAnchor,
        Field(description="An exclusive item position within the requested visible turn."),
    ]


class ThreadItemsListCursor(RootModel[str | ThreadItemsListAnchor]):
    root: Annotated[
        str | ThreadItemsListAnchor,
        Field(description="Starting position for an item-history page."),
    ]


class ThreadItemsListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cursor: Annotated[
        ThreadItemsListCursor | None,
        Field(
            description="Opaque continuation cursor or an exclusive item anchor in the requested visible turn. An item anchor requires a non-empty `turnId`; ascending (the default) returns items after it, and descending returns items before it. Continue with the returned string cursor."
        ),
    ] = None
    limit: Annotated[int | None, Field(description="Optional item page size.", ge=0)] = None
    sort_direction: Annotated[
        SortDirection | None,
        Field(
            alias="sortDirection",
            description="Optional item pagination direction; defaults to ascending.",
        ),
    ] = None
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[
        str | None,
        Field(
            alias="turnId",
            description="Optional turn id to filter by. When omitted, returns items across the thread.",
        ),
    ] = None


class ThreadListCwdFilter(RootModel[str | list[str]]):
    root: str | list[str]


class ThreadLoadedListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cursor: Annotated[
        str | None, Field(description="Opaque pagination cursor returned by a previous call.")
    ] = None
    limit: Annotated[
        int | None, Field(description="Optional page size; defaults to no limit.", ge=0)
    ] = None


class ThreadLoadedListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: Annotated[
        list[str], Field(description="Thread ids for sessions currently loaded in memory.")
    ]
    next_cursor: Annotated[
        str | None,
        Field(
            alias="nextCursor",
            description="Opaque cursor to pass to the next call to continue after the last item. if None, there are no more items to return.",
        ),
    ] = None


class ThreadMemoryMode(Enum):
    enabled = "enabled"
    disabled = "disabled"


class ThreadMetadataGitInfoUpdateParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    branch: Annotated[
        str | None,
        Field(
            description="Omit to leave the stored branch unchanged, set to `null` to clear it, or provide a non-empty string to replace it."
        ),
    ] = None
    origin_url: Annotated[
        str | None,
        Field(
            alias="originUrl",
            description="Omit to leave the stored origin URL unchanged, set to `null` to clear it, or provide a non-empty string to replace it.",
        ),
    ] = None
    sha: Annotated[
        str | None,
        Field(
            description="Omit to leave the stored commit unchanged, set to `null` to clear it, or provide a non-empty string to replace it."
        ),
    ] = None


class ThreadMetadataUpdateParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    git_info: Annotated[
        ThreadMetadataGitInfoUpdateParams | None,
        Field(
            alias="gitInfo",
            description="Patch the stored Git metadata for this thread. Omit a field to leave it unchanged, set it to `null` to clear it, or provide a string to replace the stored value.",
        ),
    ] = None
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadNameUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]
    thread_name: Annotated[str | None, Field(alias="threadName")] = None


class CompletedThreadPredictionResult(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    text: str | None = None
    type: Annotated[Literal["completed"], Field(title="CompletedThreadPredictionResultType")]


class FailedThreadPredictionResult(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["failed"], Field(title="FailedThreadPredictionResultType")]


class ThreadPredictionResult(
    RootModel[CompletedThreadPredictionResult | FailedThreadPredictionResult]
):
    root: CompletedThreadPredictionResult | FailedThreadPredictionResult


class ThreadPredictionUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    result: ThreadPredictionResult
    source_turn_id: Annotated[str, Field(alias="sourceTurnId")]
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadProjectUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    project_id: Annotated[str | None, Field(alias="projectId")] = None
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadQueueChangedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadReadParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    include_turns: Annotated[
        bool | None,
        Field(
            alias="includeTurns",
            description="When true, include turns and their items from rollout history. Full-history hydration is deprecated for paginated threads; prefer a metadata-only read and page with `thread/turns/list` and `thread/items/list`.",
        ),
    ] = None
    thread_id: Annotated[str, Field(alias="threadId")]


class ReadThreadReadStateOperation(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["read"], Field(title="ReadThreadReadStateOperationType")]


class UnreadThreadReadStateOperation(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["unread"], Field(title="UnreadThreadReadStateOperationType")]


class ThreadReadStateOperation(
    RootModel[ReadThreadReadStateOperation | UnreadThreadReadStateOperation]
):
    root: ReadThreadReadStateOperation | UnreadThreadReadStateOperation


class ThreadRealtimeAudioChunk(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: str
    item_id: Annotated[str | None, Field(alias="itemId")] = None
    num_channels: Annotated[int, Field(alias="numChannels", ge=0)]
    sample_rate: Annotated[int, Field(alias="sampleRate", ge=0)]
    samples_per_channel: Annotated[int | None, Field(alias="samplesPerChannel", ge=0)] = None


class WholeItemThreadRealtimeBemItemPresentation(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[
        Literal["wholeItem"], Field(title="WholeItemThreadRealtimeBemItemPresentationType")
    ]


class InlineMarkdownThreadRealtimeBemItemPresentation(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[
        Literal["inlineMarkdown"],
        Field(title="InlineMarkdownThreadRealtimeBemItemPresentationType"),
    ]


class InlineVisualizationThreadRealtimeBemItemPresentation(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    index: Annotated[int, Field(ge=0)]
    type: Annotated[
        Literal["inlineVisualization"],
        Field(title="InlineVisualizationThreadRealtimeBemItemPresentationType"),
    ]


class ThreadRealtimeBemItemPresentation(
    RootModel[
        WholeItemThreadRealtimeBemItemPresentation
        | InlineMarkdownThreadRealtimeBemItemPresentation
        | InlineVisualizationThreadRealtimeBemItemPresentation
    ]
):
    root: Annotated[
        WholeItemThreadRealtimeBemItemPresentation
        | InlineMarkdownThreadRealtimeBemItemPresentation
        | InlineVisualizationThreadRealtimeBemItemPresentation,
        Field(
            description="EXPERIMENTAL - how an existing agent item appears in a realtime conversation."
        ),
    ]


class ThreadRealtimeClosedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    reason: str | None = None
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadRealtimeErrorNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message: str
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadRealtimeInitialItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    role: ConversationTextRole
    text: str


class RealtimeSessionStartedThreadRealtimeItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    realtime_session_id: Annotated[str, Field(alias="realtimeSessionId")]
    type: Annotated[
        Literal["realtimeSessionStarted"],
        Field(title="RealtimeSessionStartedThreadRealtimeItemType"),
    ]


class BemItemPromotedThreadRealtimeItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    realtime_session_id: Annotated[str, Field(alias="realtimeSessionId")]
    item_id: str
    presentation: ThreadRealtimeBemItemPresentation
    turn_id: str
    type: Annotated[
        Literal["bemItemPromoted"], Field(title="BemItemPromotedThreadRealtimeItemType")
    ]


class ThreadRealtimeItemAddedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item: Any
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadRealtimeItemTranscriptDeltaNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    delta: str
    item_id: Annotated[str, Field(alias="itemId")]
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadRealtimeOutputAudioDeltaNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    audio: ThreadRealtimeAudioChunk
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadRealtimeSdpNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    sdp: str
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadRealtimeSessionOutcome(Enum):
    ended = "ended"
    failed = "failed"


class WebsocketThreadRealtimeStartTransport(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["websocket"], Field(title="WebsocketThreadRealtimeStartTransportType")]


class WebrtcThreadRealtimeStartTransport(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    sdp: Annotated[
        str,
        Field(
            description="SDP offer generated by a WebRTC RTCPeerConnection after configuring audio and the realtime events data channel."
        ),
    ]
    type: Annotated[Literal["webrtc"], Field(title="WebrtcThreadRealtimeStartTransportType")]


class ExistingCallThreadRealtimeStartTransport(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    call_id: Annotated[
        str,
        Field(
            alias="callId",
            description="Identifier of a realtime call already created and negotiated by the client.",
        ),
    ]
    type: Annotated[
        Literal["existingCall"], Field(title="ExistingCallThreadRealtimeStartTransportType")
    ]


class ThreadRealtimeStartTransport(
    RootModel[
        WebsocketThreadRealtimeStartTransport
        | WebrtcThreadRealtimeStartTransport
        | ExistingCallThreadRealtimeStartTransport
    ]
):
    root: Annotated[
        WebsocketThreadRealtimeStartTransport
        | WebrtcThreadRealtimeStartTransport
        | ExistingCallThreadRealtimeStartTransport,
        Field(description="EXPERIMENTAL - transport used by thread realtime."),
    ]


class ThreadRealtimeStartedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    realtime_session_id: Annotated[str | None, Field(alias="realtimeSessionId")] = None
    thread_id: Annotated[str, Field(alias="threadId")]
    version: RealtimeConversationVersion


class ThreadRealtimeTranscriptDeltaNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    delta: Annotated[str, Field(description="Live transcript delta from the realtime event.")]
    role: str
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadRealtimeTranscriptDoneNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    role: str
    text: Annotated[str, Field(description="Final complete text for the transcript part.")]
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadRealtimeTranscriptRole(Enum):
    user = "user"
    assistant = "assistant"


class ThreadResumeParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approval_policy: Annotated[AskForApproval | None, Field(alias="approvalPolicy")] = None
    approvals_reviewer: Annotated[
        ApprovalsReviewer | None,
        Field(
            alias="approvalsReviewer",
            description="Override where approval requests are routed for review on this thread and subsequent turns.",
        ),
    ] = None
    base_instructions: Annotated[str | None, Field(alias="baseInstructions")] = None
    config: dict[str, Any] | None = None
    cwd: str | None = None
    developer_instructions: Annotated[str | None, Field(alias="developerInstructions")] = None
    exclude_turns: Annotated[
        bool | None,
        Field(
            alias="excludeTurns",
            description="When true, return only thread metadata and live-resume state without populating `thread.turns`. This is useful when the client plans to call `thread/turns/list` immediately after resuming. Full-history hydration is deprecated for paginated threads; use this with `thread/turns/list` and `thread/items/list` instead.",
        ),
    ] = None
    model: Annotated[
        str | None, Field(description="Configuration overrides for the resumed thread, if any.")
    ] = None
    model_provider: Annotated[str | None, Field(alias="modelProvider")] = None
    personality: Annotated[
        Personality | None,
        Field(
            description="@deprecated `friendly` and `pragmatic` no longer select a style. Changing this does not rewrite the thread's existing instructions."
        ),
    ] = None
    sandbox: SandboxMode | None = None
    service_tier: Annotated[str | None, Field(alias="serviceTier")] = None
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadRevertParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    before_turn_id: Annotated[
        str,
        Field(
            alias="beforeTurnId",
            description="Turn excluded from the replacement history, together with every later turn.",
        ),
    ]
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadRevertedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadSearchSortKey(Enum):
    created_at = "created_at"
    updated_at = "updated_at"
    recency_at = "recency_at"


class ThreadSectionAppearance(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    color: str | None = None
    icon: str | None = None


class ThreadSectionCreateParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    appearance: ThreadSectionAppearance | None = None
    name: Annotated[str, Field(description="The user-visible name of the section.")]


class ThreadSectionDeleteParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    section_id: Annotated[
        str,
        Field(
            alias="sectionId",
            description="The stable, server-generated identity of the section to delete.",
        ),
    ]


class ThreadSectionDeleteResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ThreadSectionListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cursor: Annotated[
        str | None, Field(description="Opaque pagination cursor returned by a previous call.")
    ] = None
    limit: Annotated[
        int | None, Field(description="Maximum number of sections to return.", ge=0)
    ] = None


class ThreadSectionMoveParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    before_thread_id: Annotated[
        str | None,
        Field(
            alias="beforeThreadId",
            description="Existing thread to insert before; omission or null appends to the section.",
        ),
    ] = None
    section_id: Annotated[
        str | None,
        Field(
            alias="sectionId",
            description="Destination section, or `null` to remove the thread from its section.",
        ),
    ] = None
    thread_id: Annotated[
        str,
        Field(alias="threadId", description="Thread to move into, within, or out of a section."),
    ]


class ThreadSectionMoveResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ThreadSectionUpdateParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    appearance: Annotated[
        ThreadSectionAppearance | None,
        Field(
            description="Omit to preserve appearance, use `null` to clear it, or provide a replacement."
        ),
    ] = None
    name: Annotated[str, Field(description="The updated user-visible name of the section.")]
    section_id: Annotated[
        str,
        Field(
            alias="sectionId",
            description="The stable, server-generated identity of the section to update.",
        ),
    ]


class ThreadSetNameParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadSetNameResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ThreadShellCommandParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    command: Annotated[
        str,
        Field(
            description="Shell command string evaluated by the thread's configured shell. Unlike `command/exec`, this intentionally preserves shell syntax such as pipes, redirects, and quoting. This runs unsandboxed with full access rather than inheriting the thread sandbox policy."
        ),
    ]
    thread_id: Annotated[str, Field(alias="threadId")]
    timeout_ms: Annotated[
        int | None,
        Field(
            alias="timeoutMs",
            description="Maximum execution time in milliseconds. Defaults to one hour when omitted or null. Must be non-negative; zero requests an immediate timeout, not unlimited execution. Does not affect the immediate RPC acknowledgement.",
        ),
    ] = None


class ThreadShellCommandResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ThreadSortKey(Enum):
    created_at = "created_at"
    updated_at = "updated_at"
    recency_at = "recency_at"
    section_position = "section_position"


class ThreadSource(str, Enum):
    user = "user"
    subagent = "subagent"
    memory_consolidation = "memory_consolidation"

    @classmethod
    def _missing_(cls, value: object) -> ThreadSource | None:
        if not isinstance(value, str):
            return None
        member = str.__new__(cls, value)
        member._name_ = value
        member._value_ = value
        return member


class ThreadSourceKind(Enum):
    cli = "cli"
    vscode = "vscode"
    exec = "exec"
    app_server = "appServer"
    sub_agent = "subAgent"
    sub_agent_review = "subAgentReview"
    sub_agent_compact = "subAgentCompact"
    sub_agent_thread_spawn = "subAgentThreadSpawn"
    sub_agent_other = "subAgentOther"
    unknown = "unknown"


class ThreadStartSource(Enum):
    startup = "startup"
    clear = "clear"


class NotLoadedThreadStatus(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["notLoaded"], Field(title="NotLoadedThreadStatusType")]


class IdleThreadStatus(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["idle"], Field(title="IdleThreadStatusType")]


class SystemErrorThreadStatus(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["systemError"], Field(title="SystemErrorThreadStatusType")]


class ActiveThreadStatus(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    active_flags: Annotated[list[ThreadActiveFlag], Field(alias="activeFlags")]
    type: Annotated[Literal["active"], Field(title="ActiveThreadStatusType")]


class ThreadStatus(
    RootModel[
        NotLoadedThreadStatus | IdleThreadStatus | SystemErrorThreadStatus | ActiveThreadStatus
    ]
):
    root: NotLoadedThreadStatus | IdleThreadStatus | SystemErrorThreadStatus | ActiveThreadStatus


class ThreadStatusChangedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    status: ThreadStatus
    thread_id: Annotated[str, Field(alias="threadId")]


class TurnStartedThreadTimelineEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    position: Annotated[int, Field(ge=0)]
    started_at: int | None = None
    turn_id: str
    type: Annotated[Literal["turnStarted"], Field(title="TurnStartedThreadTimelineEntryType")]


class ThreadUnarchiveParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadUnarchivedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadStartThreadUnreadPosition(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["threadStart"], Field(title="ThreadStartThreadUnreadPositionType")]


class TurnThreadUnreadPosition(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    turn_id: Annotated[str, Field(alias="turnId")]
    type: Annotated[Literal["turn"], Field(title="TurnThreadUnreadPositionType")]


class ThreadUnreadPosition(RootModel[ThreadStartThreadUnreadPosition | TurnThreadUnreadPosition]):
    root: ThreadStartThreadUnreadPosition | TurnThreadUnreadPosition


class ThreadUnsubscribeParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadUnsubscribeStatus(Enum):
    not_loaded = "notLoaded"
    not_subscribed = "notSubscribed"
    unsubscribed = "unsubscribed"


class ThreadUsageBreakdownGroup(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cached_input_tokens: Annotated[int | None, Field(alias="cachedInputTokens")] = None
    estimated_usage_credits_micros: Annotated[int, Field(alias="estimatedUsageCreditsMicros")]
    input_tokens: Annotated[int | None, Field(alias="inputTokens")] = None
    model: str | None = None
    net_new_input_tokens: Annotated[int | None, Field(alias="netNewInputTokens")] = None
    output_tokens: Annotated[int | None, Field(alias="outputTokens")] = None
    reasoning_effort: Annotated[str | None, Field(alias="reasoningEffort")] = None
    speed: str | None = None
    total_tokens: Annotated[int | None, Field(alias="totalTokens")] = None


class TokenUsageBreakdown(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cache_write_input_tokens: Annotated[int | None, Field(alias="cacheWriteInputTokens")] = 0
    cached_input_tokens: Annotated[int, Field(alias="cachedInputTokens")]
    input_tokens: Annotated[int, Field(alias="inputTokens")]
    output_tokens: Annotated[int, Field(alias="outputTokens")]
    reasoning_output_tokens: Annotated[int, Field(alias="reasoningOutputTokens")]
    total_tokens: Annotated[int, Field(alias="totalTokens")]


class Tool(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    field_meta: Annotated[Any | None, Field(alias="_meta")] = None
    annotations: Any | None = None
    description: str | None = None
    icons: list[Any] | None = None
    input_schema: Annotated[Any, Field(alias="inputSchema")]
    name: str
    output_schema: Annotated[Any | None, Field(alias="outputSchema")] = None
    title: str | None = None


class ToolExposureSurface(Enum):
    code_mode = "code_mode"
    deferred = "deferred"
    direct = "direct"


class TurnDiffUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    diff: str
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class TurnEnvironmentParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: LegacyAppPathString
    environment_id: Annotated[str, Field(alias="environmentId")]
    runtime_workspace_roots: Annotated[
        list[LegacyAppPathString] | None,
        Field(
            alias="runtimeWorkspaceRoots",
            description="Environment-native runtime workspace roots. Omitted defaults to `cwd`.",
        ),
    ] = None


class TurnInterruptParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class TurnInterruptResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )


class TurnItemsView(Enum):
    not_loaded = "notLoaded"
    summary = "summary"
    full = "full"


class TurnModerationMetadataNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    metadata: Any
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class TurnPlanStepStatus(Enum):
    pending = "pending"
    in_progress = "inProgress"
    completed = "completed"


class TurnStatus(Enum):
    completed = "completed"
    interrupted = "interrupted"
    failed = "failed"
    in_progress = "inProgress"


class TurnSteerResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    turn_id: Annotated[str, Field(alias="turnId")]


class TextUserInput(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    text: str
    text_elements: Annotated[
        list[TextElement] | None,
        Field(
            description="UI-defined spans within `text` used to render or persist special elements.",
            validate_default=True,
        ),
    ] = []
    type: Annotated[Literal["text"], Field(title="TextUserInputType")]


class ImageUserInput(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    detail: ImageDetail | None = None
    type: Annotated[Literal["image"], Field(title="ImageUserInputType")]
    url: str


class FileIdUserInput(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    detail: ImageDetail | None = None
    type: Annotated[Literal["image"], Field(title="ImageUserInputType")]
    file_id: Annotated[str, Field(alias="fileId")]


class LocalImageUserInput(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    detail: ImageDetail | None = None
    path: str
    type: Annotated[Literal["localImage"], Field(title="LocalImageUserInputType")]


class AudioUserInput(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["audio"], Field(title="AudioUserInputType")]
    url: str


class LocalAudioUserInput(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: str
    type: Annotated[Literal["localAudio"], Field(title="LocalAudioUserInputType")]


class SkillUserInput(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str
    path: str
    type: Annotated[Literal["skill"], Field(title="SkillUserInputType")]


class MentionUserInput(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str
    path: str
    type: Annotated[Literal["mention"], Field(title="MentionUserInputType")]


class UserInput(
    RootModel[
        TextUserInput
        | ImageUserInput
        | FileIdUserInput
        | LocalImageUserInput
        | AudioUserInput
        | LocalAudioUserInput
        | SkillUserInput
        | MentionUserInput
    ]
):
    root: (
        TextUserInput
        | ImageUserInput
        | FileIdUserInput
        | LocalImageUserInput
        | AudioUserInput
        | LocalAudioUserInput
        | SkillUserInput
        | MentionUserInput
    )


class Verbosity(Enum):
    low = "low"
    medium = "medium"
    high = "high"


class WarningNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message: Annotated[str, Field(description="Concise warning message for the user.")]
    thread_id: Annotated[
        str | None,
        Field(
            alias="threadId",
            description="Optional thread target when the warning applies to a specific thread.",
        ),
    ] = None


class SearchWebSearchAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    queries: list[str] | None = None
    query: str | None = None
    type: Annotated[Literal["search"], Field(title="SearchWebSearchActionType")]


class OpenPageWebSearchAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["openPage"], Field(title="OpenPageWebSearchActionType")]
    url: str | None = None


class FindInPageWebSearchAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    pattern: str | None = None
    type: Annotated[Literal["findInPage"], Field(title="FindInPageWebSearchActionType")]
    url: str | None = None


class OtherWebSearchAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["other"], Field(title="OtherWebSearchActionType")]


class WebSearchAction(
    RootModel[
        SearchWebSearchAction
        | OpenPageWebSearchAction
        | FindInPageWebSearchAction
        | OtherWebSearchAction
    ]
):
    root: (
        SearchWebSearchAction
        | OpenPageWebSearchAction
        | FindInPageWebSearchAction
        | OtherWebSearchAction
    )


class WebSearchContextSize(Enum):
    low = "low"
    medium = "medium"
    high = "high"


class WebSearchLocation(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    city: str | None = None
    country: str | None = None
    region: str | None = None
    timezone: str | None = None


class WebSearchMode(Enum):
    disabled = "disabled"
    cached = "cached"
    indexed = "indexed"
    live = "live"


class WebSearchToolConfig(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    allowed_domains: list[str] | None = None
    context_size: WebSearchContextSize | None = None
    location: WebSearchLocation | None = None


class WindowsSandboxImplementation(Enum):
    elevated = "elevated"
    unelevated = "unelevated"
    mxc = "mxc"


class WindowsSandboxReadiness(Enum):
    ready = "ready"
    not_configured = "notConfigured"
    update_required = "updateRequired"


class WindowsSandboxReadinessResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    status: WindowsSandboxReadiness


class WindowsSandboxSetupMode(Enum):
    elevated = "elevated"
    unelevated = "unelevated"


class WindowsSandboxSetupStartParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: AbsolutePathBuf | None = None
    mode: WindowsSandboxSetupMode


class WindowsSandboxSetupStartResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    started: bool


class WindowsWorldWritableWarningNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    extra_count: Annotated[int, Field(alias="extraCount", ge=0)]
    failed_scan: Annotated[bool, Field(alias="failedScan")]
    sample_paths: Annotated[list[str], Field(alias="samplePaths")]


class WorkspaceMessageType(Enum):
    headline = "headline"
    announcement = "announcement"
    unknown = "unknown"


class WorkspaceRouting(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    account_routing_override: Annotated[
        AccountRoutingOverride, Field(alias="accountRoutingOverride")
    ]
    backend_origin: Annotated[str, Field(alias="backendOrigin")]
    chatgpt_account_id: Annotated[str, Field(alias="chatgptAccountId")]


class WriteStatus(Enum):
    ok = "ok"
    ok_overridden = "okOverridden"


class ChatgptAccount(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    email: str | None
    plan_type: Annotated[PlanType, Field(alias="planType")]
    type: Annotated[Literal["chatgpt"], Field(title="ChatgptAccountType")]


class Account(RootModel[ApiKeyAccount | ChatgptAccount | AmazonBedrockAccount | GcpAccount]):
    root: ApiKeyAccount | ChatgptAccount | AmazonBedrockAccount | GcpAccount


class AccountLoginCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    error: str | None = None
    login_id: Annotated[str | None, Field(alias="loginId")] = None
    onboarding_entrypoint: Annotated[
        DesktopOnboardingEntrypoint | None, Field(alias="onboardingEntrypoint")
    ] = None
    success: bool


class AccountUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    auth_mode: Annotated[AuthMode | None, Field(alias="authMode")] = None
    plan_type: Annotated[PlanType | None, Field(alias="planType")] = None


class AdditionalContextEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    kind: AdditionalContextKind
    value: str


class AppConfig(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approvals_reviewer: ApprovalsReviewer | None = None
    default_tools_approval_mode: AppToolApproval | None = None
    default_tools_enabled: bool | None = None
    destructive_enabled: bool | None = None
    enabled: bool | None = True
    links: Annotated[
        AppLinksConfig | None, Field(description="Per-account approval settings keyed by link ID.")
    ] = None
    omit_tools_from: Annotated[
        list[ToolExposureSurface] | None,
        Field(description="Additional model-facing surfaces omitted for this connector's tools."),
    ] = None
    open_world_enabled: bool | None = None
    tools: AppToolsConfig | None = None


class AppLinkConfig(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approvals_reviewer: ApprovalsReviewer | None = None
    default_tools_approval_mode: AppToolApproval | None = None


class AppMetadata(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    categories: list[str] | None = None
    developer: str | None = None
    first_party_requires_install: Annotated[
        bool | None, Field(alias="firstPartyRequiresInstall")
    ] = None
    review: AppReview | None = None
    screenshots: list[AppScreenshot] | None = None
    seo_description: Annotated[str | None, Field(alias="seoDescription")] = None
    show_in_composer_when_unlinked: Annotated[
        bool | None, Field(alias="showInComposerWhenUnlinked")
    ] = None
    sub_categories: Annotated[list[str] | None, Field(alias="subCategories")] = None
    version: str | None = None
    version_id: Annotated[str | None, Field(alias="versionId")] = None
    version_notes: Annotated[str | None, Field(alias="versionNotes")] = None


class AppTemplateSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    canonical_connector_id: Annotated[str | None, Field(alias="canonicalConnectorId")] = None
    category: str | None = None
    description: str | None = None
    logo_url: Annotated[str | None, Field(alias="logoUrl")] = None
    logo_url_dark: Annotated[str | None, Field(alias="logoUrlDark")] = None
    materialized_app_ids: Annotated[list[str], Field(alias="materializedAppIds")]
    name: str
    reason: AppTemplateUnavailableReason | None = None
    template_id: Annotated[str, Field(alias="templateId")]


class ApplicationNetworkRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    domains: dict[str, NetworkDomainPermission]
    enabled: Annotated[
        bool,
        Field(description="When enabled, only explicitly allowed exact domains may be contacted."),
    ]


class ApplicationStorageRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    default_project_parent: Annotated[
        LegacyAppPathString | None, Field(alias="defaultProjectParent")
    ] = None
    projectless_workspace_root: Annotated[
        LegacyAppPathString | None, Field(alias="projectlessWorkspaceRoot")
    ] = None


class AppsConfig(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    field_default: Annotated[AppsDefaultConfig | None, Field(alias="_default")] = None


class AppsInstalledResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    apps: list[InstalledApp]


class AppsReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    apps: list[ConnectorMetadata]
    missing_app_ids: Annotated[list[str], Field(alias="missingAppIds")]


class BrowserUseConfig(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    allow_history_access: bool | None = None
    default_origin_policy: BrowserUseOriginPolicyConfig | None = None
    origins: dict[str, Any] | None = None


class BrowserUseExtensionRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    request_headers: Annotated[list[RequestHeader] | None, Field(alias="requestHeaders")] = None


class BrowserUseRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    allow_global_persistent_approval: Annotated[
        bool | None, Field(alias="allowGlobalPersistentApproval")
    ] = None
    allow_history_access: Annotated[bool | None, Field(alias="allowHistoryAccess")] = None
    allow_webmcp: Annotated[bool | None, Field(alias="allowWebmcp")] = None
    default_origin_policy: Annotated[
        BrowserUseOriginPolicy | None, Field(alias="defaultOriginPolicy")
    ] = None
    disable_auto_review: Annotated[bool | None, Field(alias="disableAutoReview")] = None
    extension: BrowserUseExtensionRequirements | None = None
    origins: dict[str, Any] | None = None


class CancelLoginAccountResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    status: CancelLoginAccountStatus


class InitializeRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["initialize"], Field(title="InitializeRequestMethod")]
    params: InitializeParams


class ThreadResumeRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/resume"], Field(title="Thread/resumeRequestMethod")]
    params: ThreadResumeParams


class ThreadArchiveRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/archive"], Field(title="Thread/archiveRequestMethod")]
    params: ThreadArchiveParams


class ThreadDeleteRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/delete"], Field(title="Thread/deleteRequestMethod")]
    params: ThreadDeleteParams


class ThreadUnsubscribeRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/unsubscribe"], Field(title="Thread/unsubscribeRequestMethod")]
    params: ThreadUnsubscribeParams


class ThreadNameSetRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/name/set"], Field(title="Thread/name/setRequestMethod")]
    params: ThreadSetNameParams


class ThreadGoalGetRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/goal/get"], Field(title="Thread/goal/getRequestMethod")]
    params: ThreadGoalGetParams


class ThreadMetadataUpdateRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["thread/metadata/update"], Field(title="Thread/metadata/updateRequestMethod")
    ]
    params: ThreadMetadataUpdateParams


class ThreadAttachmentAddRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["thread/attachment/add"], Field(title="Thread/attachment/addRequestMethod")
    ]
    params: ThreadAttachmentAddParams


class ThreadAttachmentListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["thread/attachment/list"], Field(title="Thread/attachment/listRequestMethod")
    ]
    params: ThreadAttachmentListParams


class ThreadAttachmentOwnerListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["thread/attachmentOwner/list"],
        Field(title="Thread/attachmentOwner/listRequestMethod"),
    ]
    params: ThreadAttachmentOwnerListParams


class ThreadAttachmentRemoveRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["thread/attachment/remove"], Field(title="Thread/attachment/removeRequestMethod")
    ]
    params: ThreadAttachmentRemoveParams


class ThreadSectionMoveRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["thread/section/move"], Field(title="Thread/section/moveRequestMethod")
    ]
    params: ThreadSectionMoveParams


class ThreadUnarchiveRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/unarchive"], Field(title="Thread/unarchiveRequestMethod")]
    params: ThreadUnarchiveParams


class ThreadCompactStartRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["thread/compact/start"], Field(title="Thread/compact/startRequestMethod")
    ]
    params: ThreadCompactStartParams


class ThreadShellCommandRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["thread/shellCommand"], Field(title="Thread/shellCommandRequestMethod")
    ]
    params: ThreadShellCommandParams


class ThreadApproveGuardianDeniedActionRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["thread/approveGuardianDeniedAction"],
        Field(title="Thread/approveGuardianDeniedActionRequestMethod"),
    ]
    params: ThreadApproveGuardianDeniedActionParams


class ThreadRevertRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/revert"], Field(title="Thread/revertRequestMethod")]
    params: ThreadRevertParams


class ThreadSectionListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["threadSection/list"], Field(title="ThreadSection/listRequestMethod")]
    params: ThreadSectionListParams


class ThreadSectionCreateRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["threadSection/create"], Field(title="ThreadSection/createRequestMethod")
    ]
    params: ThreadSectionCreateParams


class ThreadSectionUpdateRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["threadSection/update"], Field(title="ThreadSection/updateRequestMethod")
    ]
    params: ThreadSectionUpdateParams


class ThreadSectionDeleteRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["threadSection/delete"], Field(title="ThreadSection/deleteRequestMethod")
    ]
    params: ThreadSectionDeleteParams


class ThreadLoadedListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/loaded/list"], Field(title="Thread/loaded/listRequestMethod")]
    params: ThreadLoadedListParams


class ThreadReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/read"], Field(title="Thread/readRequestMethod")]
    params: ThreadReadParams


class ThreadItemsListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/items/list"], Field(title="Thread/items/listRequestMethod")]
    params: ThreadItemsListParams


class ThreadInjectItemsRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["thread/inject_items"], Field(title="Thread/injectItemsRequestMethod")
    ]
    params: ThreadInjectItemsParams


class SkillsListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["skills/list"], Field(title="Skills/listRequestMethod")]
    params: SkillsListParams


class SkillsExtraRootsSetRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["skills/extraRoots/set"], Field(title="Skills/extraRoots/setRequestMethod")
    ]
    params: SkillsExtraRootsSetParams


class HooksListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["hooks/list"], Field(title="Hooks/listRequestMethod")]
    params: HooksListParams


class MarketplaceAddRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["marketplace/add"], Field(title="Marketplace/addRequestMethod")]
    params: MarketplaceAddParams


class MarketplaceRemoveRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["marketplace/remove"], Field(title="Marketplace/removeRequestMethod")]
    params: MarketplaceRemoveParams


class MarketplaceUpgradeRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["marketplace/upgrade"], Field(title="Marketplace/upgradeRequestMethod")
    ]
    params: MarketplaceUpgradeParams


class PluginListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/list"], Field(title="Plugin/listRequestMethod")]
    params: PluginListParams


class PluginInstalledRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/installed"], Field(title="Plugin/installedRequestMethod")]
    params: PluginInstalledParams


class PluginReconcileRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/reconcile"], Field(title="Plugin/reconcileRequestMethod")]
    params: PluginReconcileParams


class PluginReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/read"], Field(title="Plugin/readRequestMethod")]
    params: PluginReadParams


class PluginSkillReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/skill/read"], Field(title="Plugin/skill/readRequestMethod")]
    params: PluginSkillReadParams


class PluginShareListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/share/list"], Field(title="Plugin/share/listRequestMethod")]
    params: PluginShareListParams


class PluginShareCheckoutRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["plugin/share/checkout"], Field(title="Plugin/share/checkoutRequestMethod")
    ]
    params: PluginShareCheckoutParams


class PluginShareDeleteRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["plugin/share/delete"], Field(title="Plugin/share/deleteRequestMethod")
    ]
    params: PluginShareDeleteParams


class AppReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["app/read"], Field(title="App/readRequestMethod")]
    params: AppsReadParams


class AppListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["app/list"], Field(title="App/listRequestMethod")]
    params: AppsListParams


class AppInstalledRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["app/installed"], Field(title="App/installedRequestMethod")]
    params: AppsInstalledParams


class FsReadFileRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["fs/readFile"], Field(title="Fs/readFileRequestMethod")]
    params: FsReadFileParams


class FsWriteFileRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["fs/writeFile"], Field(title="Fs/writeFileRequestMethod")]
    params: FsWriteFileParams


class FsCreateDirectoryRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["fs/createDirectory"], Field(title="Fs/createDirectoryRequestMethod")]
    params: FsCreateDirectoryParams


class FsGetMetadataRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["fs/getMetadata"], Field(title="Fs/getMetadataRequestMethod")]
    params: FsGetMetadataParams


class FsReadDirectoryRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["fs/readDirectory"], Field(title="Fs/readDirectoryRequestMethod")]
    params: FsReadDirectoryParams


class FsRemoveRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["fs/remove"], Field(title="Fs/removeRequestMethod")]
    params: FsRemoveParams


class FsCopyRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["fs/copy"], Field(title="Fs/copyRequestMethod")]
    params: FsCopyParams


class FsWatchRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["fs/watch"], Field(title="Fs/watchRequestMethod")]
    params: FsWatchParams


class FsUnwatchRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["fs/unwatch"], Field(title="Fs/unwatchRequestMethod")]
    params: FsUnwatchParams


class SkillsConfigWriteRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["skills/config/write"], Field(title="Skills/config/writeRequestMethod")
    ]
    params: SkillsConfigWriteParams


class PluginInstallRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/install"], Field(title="Plugin/installRequestMethod")]
    params: PluginInstallParams


class PluginUninstallRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/uninstall"], Field(title="Plugin/uninstallRequestMethod")]
    params: PluginUninstallParams


class TurnInterruptRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["turn/interrupt"], Field(title="Turn/interruptRequestMethod")]
    params: TurnInterruptParams


class ModelListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["model/list"], Field(title="Model/listRequestMethod")]
    params: ModelListParams


class AccountGatewayOAuthReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["account/gatewayOAuth/read"], Field(title="Account/gatewayOAuth/readRequestMethod")
    ]
    params: Annotated[None, Field(None)] = None


class AccountGatewayOAuthLoginRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["account/gatewayOAuth/login"],
        Field(title="Account/gatewayOAuth/loginRequestMethod"),
    ]
    params: Annotated[None, Field(None)] = None


class AccountGatewayOAuthCancelRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["account/gatewayOAuth/cancel"],
        Field(title="Account/gatewayOAuth/cancelRequestMethod"),
    ]
    params: Annotated[None, Field(None)] = None


class ModelProviderCapabilitiesReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["modelProvider/capabilities/read"],
        Field(title="ModelProvider/capabilities/readRequestMethod"),
    ]
    params: ModelProviderCapabilitiesReadParams


class ExperimentalFeatureListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["experimentalFeature/list"], Field(title="ExperimentalFeature/listRequestMethod")
    ]
    params: ExperimentalFeatureListParams


class PermissionProfileListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["permissionProfile/list"], Field(title="PermissionProfile/listRequestMethod")
    ]
    params: PermissionProfileListParams


class ExperimentalFeatureEnablementSetRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["experimentalFeature/enablement/set"],
        Field(title="ExperimentalFeature/enablement/setRequestMethod"),
    ]
    params: ExperimentalFeatureEnablementSetParams


class McpServerOauthLoginRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["mcpServer/oauth/login"], Field(title="McpServer/oauth/loginRequestMethod")
    ]
    params: McpServerOauthLoginParams


class ConfigMcpServerReloadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["config/mcpServer/reload"], Field(title="Config/mcpServer/reloadRequestMethod")
    ]
    params: Annotated[None, Field(None)] = None


class McpServerToolCallRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["mcpServer/tool/call"], Field(title="McpServer/tool/callRequestMethod")
    ]
    params: McpServerToolCallParams


class WindowsSandboxSetupStartRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["windowsSandbox/setupStart"], Field(title="WindowsSandbox/setupStartRequestMethod")
    ]
    params: WindowsSandboxSetupStartParams


class WindowsSandboxReadinessRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["windowsSandbox/readiness"], Field(title="WindowsSandbox/readinessRequestMethod")
    ]
    params: Annotated[None, Field(None)] = None


class AccountLoginCancelRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["account/login/cancel"], Field(title="Account/login/cancelRequestMethod")
    ]
    params: CancelLoginAccountParams


class AccountLogoutRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["account/logout"], Field(title="Account/logoutRequestMethod")]
    params: Annotated[None, Field(None)] = None


class AccountRateLimitsReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["account/rateLimits/read"], Field(title="Account/rateLimits/readRequestMethod")
    ]
    params: GetAccountRateLimitsParams | None = None


class AccountRateLimitResetCreditConsumeRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["account/rateLimitResetCredit/consume"],
        Field(title="Account/rateLimitResetCredit/consumeRequestMethod"),
    ]
    params: ConsumeAccountRateLimitResetCreditParams


class AccountUsageReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["account/usage/read"], Field(title="Account/usage/readRequestMethod")]
    params: GetAccountTokenUsageParams | None = None


class AccountWorkspaceMessagesReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["account/workspaceMessages/read"],
        Field(title="Account/workspaceMessages/readRequestMethod"),
    ]
    params: Annotated[None, Field(None)] = None


class AccountSendAddCreditsNudgeEmailRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["account/sendAddCreditsNudgeEmail"],
        Field(title="Account/sendAddCreditsNudgeEmailRequestMethod"),
    ]
    params: SendAddCreditsNudgeEmailParams


class FeedbackUploadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["feedback/upload"], Field(title="Feedback/uploadRequestMethod")]
    params: FeedbackUploadParams


class CommandExecWriteRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["command/exec/write"], Field(title="Command/exec/writeRequestMethod")]
    params: CommandExecWriteParams


class CommandExecTerminateRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["command/exec/terminate"], Field(title="Command/exec/terminateRequestMethod")
    ]
    params: CommandExecTerminateParams


class ConfigReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["config/read"], Field(title="Config/readRequestMethod")]
    params: ConfigReadParams


class ExternalAgentConfigDetectRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["externalAgentConfig/detect"],
        Field(title="ExternalAgentConfig/detectRequestMethod"),
    ]
    params: ExternalAgentConfigDetectParams


class ExternalAgentConfigImportReadHistoriesRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["externalAgentConfig/import/readHistories"],
        Field(title="ExternalAgentConfig/import/readHistoriesRequestMethod"),
    ]
    params: Annotated[None, Field(None)] = None


class ConfigRequirementsReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["configRequirements/read"], Field(title="ConfigRequirements/readRequestMethod")
    ]
    params: Annotated[None, Field(None)] = None


class AccountReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["account/read"], Field(title="Account/readRequestMethod")]
    params: GetAccountParams


class FuzzyFileSearchRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["fuzzyFileSearch"], Field(title="FuzzyFileSearchRequestMethod")]
    params: FuzzyFileSearchParams


class ActiveTurnNotSteerable(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    turn_kind: Annotated[NonSteerableTurnKind, Field(alias="turnKind")]


class ActiveTurnNotSteerableCodexErrorInfo(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    active_turn_not_steerable: Annotated[
        ActiveTurnNotSteerable, Field(alias="activeTurnNotSteerable")
    ]


class CodexErrorInfo(
    RootModel[
        CodexErrorInfoValue
        | HttpConnectionFailedCodexErrorInfo
        | ResponseStreamConnectionFailedCodexErrorInfo
        | ResponseStreamDisconnectedCodexErrorInfo
        | ResponseTooManyFailedAttemptsCodexErrorInfo
        | ActiveTurnNotSteerableCodexErrorInfo
        | dict[str, Any]
    ]
):
    root: Annotated[
        CodexErrorInfoValue
        | HttpConnectionFailedCodexErrorInfo
        | ResponseStreamConnectionFailedCodexErrorInfo
        | ResponseStreamDisconnectedCodexErrorInfo
        | ResponseTooManyFailedAttemptsCodexErrorInfo
        | ActiveTurnNotSteerableCodexErrorInfo
        | dict[str, Any],
        Field(
            description="This translation layer make sure that we expose codex error code in camel case.\n\nWhen an upstream HTTP status is available (for example, from the Responses API or a provider), it is forwarded in `httpStatusCode` on the relevant `codexErrorInfo` variant."
        ),
    ]


class CollabAgentState(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message: str | None = None
    status: CollabAgentStatus


class CollaborationMode(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    mode: ModeKind
    settings: Settings


class CollaborationModeMask(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    mode: ModeKind | None = None
    model: str | None = None
    name: str
    reasoning_effort: ReasoningEffort | None = None


class ReadCommandAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    command: str
    name: str
    path: LegacyAppPathString
    type: Annotated[Literal["read"], Field(title="ReadCommandActionType")]


class CommandAction(
    RootModel[
        ReadCommandAction | ListFilesCommandAction | SearchCommandAction | UnknownCommandAction
    ]
):
    root: ReadCommandAction | ListFilesCommandAction | SearchCommandAction | UnknownCommandAction


class CommandExecOutputDeltaNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cap_reached: Annotated[
        bool,
        Field(
            alias="capReached",
            description="`true` on the final streamed chunk for a stream when `outputBytesCap` truncated later output on that stream.",
        ),
    ]
    delta_base64: Annotated[
        str, Field(alias="deltaBase64", description="Base64-encoded output bytes.")
    ]
    process_id: Annotated[
        str,
        Field(
            alias="processId",
            description="Client-supplied, connection-scoped `processId` from the original `command/exec` request.",
        ),
    ]
    stream: Annotated[CommandExecOutputStream, Field(description="Output stream for this chunk.")]


class CommandExecParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    command: Annotated[
        list[str], Field(description="Command argv vector. Empty arrays are rejected.")
    ]
    cwd: Annotated[
        str | None, Field(description="Optional working directory. Defaults to the server cwd.")
    ] = None
    disable_output_cap: Annotated[
        bool | None,
        Field(
            alias="disableOutputCap",
            description="Disable stdout/stderr capture truncation for this request.\n\nCannot be combined with `outputBytesCap`.",
        ),
    ] = None
    disable_timeout: Annotated[
        bool | None,
        Field(
            alias="disableTimeout",
            description="Disable the timeout entirely for this request.\n\nCannot be combined with `timeoutMs`.",
        ),
    ] = None
    env: Annotated[
        dict[str, Any] | None,
        Field(
            description="Optional environment overrides merged into the server-computed environment.\n\nMatching names override inherited values. Set a key to `null` to unset an inherited variable."
        ),
    ] = None
    output_bytes_cap: Annotated[
        int | None,
        Field(
            alias="outputBytesCap",
            description="Optional per-stream stdout/stderr capture cap in bytes.\n\nWhen omitted, the server default applies. Cannot be combined with `disableOutputCap`.",
            ge=0,
        ),
    ] = None
    process_id: Annotated[
        str | None,
        Field(
            alias="processId",
            description="Optional client-supplied, connection-scoped process id.\n\nRequired for `tty`, `streamStdin`, `streamStdoutStderr`, and follow-up `command/exec/write`, `command/exec/resize`, and `command/exec/terminate` calls. When omitted, buffered execution gets an internal id that is not exposed to the client.",
        ),
    ] = None
    sandbox_policy: Annotated[
        SandboxPolicy | None,
        Field(
            alias="sandboxPolicy",
            description="Optional sandbox policy for this command.\n\nUses the same shape as thread/turn execution sandbox configuration and defaults to the user's configured policy when omitted. Cannot be combined with `permissionProfile`.",
        ),
    ] = None
    size: Annotated[
        CommandExecTerminalSize | None,
        Field(
            description="Optional initial PTY size in character cells. Only valid when `tty` is true."
        ),
    ] = None
    stream_stdin: Annotated[
        bool | None,
        Field(
            alias="streamStdin",
            description="Allow follow-up `command/exec/write` requests to write stdin bytes.\n\nRequires a client-supplied `processId`.",
        ),
    ] = None
    stream_stdout_stderr: Annotated[
        bool | None,
        Field(
            alias="streamStdoutStderr",
            description="Stream stdout/stderr via `command/exec/outputDelta` notifications.\n\nStreamed bytes are not duplicated into the final response and require a client-supplied `processId`.",
        ),
    ] = None
    timeout_ms: Annotated[
        int | None,
        Field(
            alias="timeoutMs",
            description="Optional timeout in milliseconds.\n\nWhen omitted, the server default applies. Cannot be combined with `disableTimeout`.",
        ),
    ] = None
    tty: Annotated[
        bool | None,
        Field(
            description="Enable PTY mode.\n\nThis implies `streamStdin` and `streamStdoutStderr`."
        ),
    ] = None


class CommandExecResizeParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    process_id: Annotated[
        str,
        Field(
            alias="processId",
            description="Client-supplied, connection-scoped `processId` from the original `command/exec` request.",
        ),
    ]
    size: Annotated[CommandExecTerminalSize, Field(description="New PTY size in character cells.")]


class ComputerUseRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    allow_locked_computer_use: Annotated[bool | None, Field(alias="allowLockedComputerUse")] = None
    allow_persistent_approval: Annotated[bool | None, Field(alias="allowPersistentApproval")] = None
    default_app_access: Annotated[AllowDenyRequirement | None, Field(alias="defaultAppAccess")] = (
        None
    )
    macos: ComputerUseMacosRequirements | None = None
    windows: ComputerUseWindowsRequirements | None = None


class ComputerUseWindowsConfig(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    aumids: dict[str, Any] | None = None
    exes: list[ComputerUseWindowsExeConfig] | None = None


class ConfigEdit(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    key_path: Annotated[str, Field(alias="keyPath")]
    merge_strategy: Annotated[MergeStrategy, Field(alias="mergeStrategy")]
    value: Any


class ConfigLayer(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    config: Any
    disabled_reason: Annotated[str | None, Field(alias="disabledReason")] = None
    name: ConfigLayerSource
    version: str


class ConfigLayerMetadata(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: ConfigLayerSource
    version: str


class ConfigValueWriteParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    expected_version: Annotated[str | None, Field(alias="expectedVersion")] = None
    file_path: Annotated[
        str | None,
        Field(
            alias="filePath",
            description="Path to the config file to write; defaults to the user's `config.toml` when omitted.",
        ),
    ] = None
    key_path: Annotated[str, Field(alias="keyPath")]
    merge_strategy: Annotated[MergeStrategy, Field(alias="mergeStrategy")]
    value: Any


class ConfigWarningNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    details: Annotated[
        str | None, Field(description="Optional extra guidance or error details.")
    ] = None
    path: Annotated[
        str | None,
        Field(description="Optional path to the config file that triggered the warning."),
    ] = None
    range: Annotated[
        TextRange | None,
        Field(description="Optional range for the error location inside the config file."),
    ] = None
    summary: Annotated[str, Field(description="Concise summary of the warning.")]


class ConfigurationReasoning(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    effort: ReasoningEffort


class InputImageContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    detail: ImageDetail | None = None
    type: Annotated[Literal["input_image"], Field(title="InputImageContentItemType")]
    image_url: str


class FileIdContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    detail: ImageDetail | None = None
    type: Annotated[Literal["input_image"], Field(title="InputImageContentItemType")]
    file_id: str


class ContentItem(
    RootModel[
        InputTextContentItem
        | InputImageContentItem
        | FileIdContentItem
        | InputAudioContentItem
        | OutputTextContentItem
    ]
):
    root: (
        InputTextContentItem
        | InputImageContentItem
        | FileIdContentItem
        | InputAudioContentItem
        | OutputTextContentItem
    )


class ExperimentalFeature(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    announcement: Annotated[
        str | None,
        Field(
            description="Announcement copy shown to users when the feature is introduced. Null when this feature is not in beta."
        ),
    ] = None
    default_enabled: Annotated[
        bool,
        Field(alias="defaultEnabled", description="Whether this feature is enabled by default."),
    ]
    description: Annotated[
        str | None,
        Field(
            description="Short summary describing what the feature does. Null when this feature is not in beta."
        ),
    ] = None
    display_name: Annotated[
        str | None,
        Field(
            alias="displayName",
            description="User-facing display name shown in the experimental features UI. Null when this feature is not in beta.",
        ),
    ] = None
    enabled: Annotated[
        bool, Field(description="Whether this feature is currently enabled in the loaded config.")
    ]
    name: Annotated[str, Field(description="Stable key used in config.toml and CLI flag toggles.")]
    stage: Annotated[
        ExperimentalFeatureStage, Field(description="Lifecycle stage of this feature flag.")
    ]


class ExperimentalFeatureListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[ExperimentalFeature]
    next_cursor: Annotated[
        str | None,
        Field(
            alias="nextCursor",
            description="Opaque cursor to pass to the next call to continue after the last item. If None, there are no more items to return.",
        ),
    ] = None


class ExternalAgentConfigImportHistoryRecordSuccessParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: str | None = None
    item_type: Annotated[ExternalAgentConfigMigrationItemType, Field(alias="itemType")]
    source: str | None = None
    target: str | None = None
    title: Annotated[
        str | None, Field(description="Original title for an imported session, when available.")
    ] = None


class ExternalAgentConfigImportItemTypeFailure(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: str | None = None
    error_type: Annotated[str | None, Field(alias="errorType")] = None
    failure_stage: Annotated[str, Field(alias="failureStage")]
    item_type: Annotated[ExternalAgentConfigMigrationItemType, Field(alias="itemType")]
    message: str
    source: str | None = None
    sub_error_type: Annotated[str | None, Field(alias="subErrorType")] = None


class ExternalAgentConfigImportItemTypeSuccess(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: str | None = None
    item_type: Annotated[ExternalAgentConfigMigrationItemType, Field(alias="itemType")]
    source: str | None = None
    target: str | None = None
    title: Annotated[
        str | None,
        Field(description="Original title for an imported session; null for other item types."),
    ] = None


class ExternalAgentConfigImportTypeResult(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    failures: list[ExternalAgentConfigImportItemTypeFailure]
    item_type: Annotated[ExternalAgentConfigMigrationItemType, Field(alias="itemType")]
    successes: list[ExternalAgentConfigImportItemTypeSuccess]


class ExternalAgentDetectedConnectorCandidate(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str
    session_count: Annotated[int, Field(alias="sessionCount", ge=0)]
    source: ExternalAgentDetectedConnectorSource


class ExternalAgentImportedConnectorCandidate(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str
    session_count: Annotated[int, Field(alias="sessionCount", ge=0)]
    source: ExternalAgentImportedConnectorSource


class FeedbackSaveParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    classification: str
    extra_log_files: Annotated[list[str] | None, Field(alias="extraLogFiles")] = None
    include_logs: Annotated[bool | None, Field(alias="includeLogs")] = None
    reason: str | None = None
    save_path: Annotated[
        LegacyAppPathString,
        Field(
            alias="savePath",
            description="Absolute, previously unused ZIP path on the app-server host. The caller owns this file, including after a disconnected RPC.",
        ),
    ]
    tags: dict[str, Any] | None = None
    thread_id: Annotated[str | None, Field(alias="threadId")] = None


class FeedbackSaveResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    prompt_hash: Annotated[
        str | None,
        Field(
            alias="promptHash",
            description="Same prompt hash as feedback/upload; null when prompt metadata is absent.",
        ),
    ] = None
    saved_path: Annotated[LegacyAppPathString, Field(alias="savedPath")]
    thread_id: Annotated[str, Field(alias="threadId")]


class PathFileSystemPath(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: LegacyAppPathString
    type: Annotated[Literal["path"], Field(title="PathFileSystemPathType")]


class KindFileSystemSpecialPath(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    kind: Literal["project_roots"]
    subpath: LegacyAppPathString | None = None


class FileSystemSpecialPath1(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    kind: Literal["unknown"]
    path: str
    subpath: LegacyAppPathString | None = None


class FileSystemSpecialPath(
    RootModel[
        RootFileSystemSpecialPath
        | MinimalFileSystemSpecialPath
        | KindFileSystemSpecialPath
        | TmpdirFileSystemSpecialPath
        | SlashTmpFileSystemSpecialPath
        | FileSystemSpecialPath1
    ]
):
    root: (
        RootFileSystemSpecialPath
        | MinimalFileSystemSpecialPath
        | KindFileSystemSpecialPath
        | TmpdirFileSystemSpecialPath
        | SlashTmpFileSystemSpecialPath
        | FileSystemSpecialPath1
    )


class FileUpdateChange(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    diff: str
    kind: PatchChangeKind
    path: str


class InputImageFunctionCallOutputContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    detail: ImageDetail | None = None
    type: Annotated[
        Literal["input_image"], Field(title="InputImageFunctionCallOutputContentItemType")
    ]
    image_url: str


class FileIdFunctionCallOutputContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    detail: ImageDetail | None = None
    type: Annotated[
        Literal["input_image"], Field(title="InputImageFunctionCallOutputContentItemType")
    ]
    file_id: str


class FunctionCallOutputContentItem(
    RootModel[
        InputTextFunctionCallOutputContentItem
        | InputImageFunctionCallOutputContentItem
        | FileIdFunctionCallOutputContentItem
        | InputAudioFunctionCallOutputContentItem
        | EncryptedContentFunctionCallOutputContentItem
    ]
):
    root: Annotated[
        InputTextFunctionCallOutputContentItem
        | InputImageFunctionCallOutputContentItem
        | FileIdFunctionCallOutputContentItem
        | InputAudioFunctionCallOutputContentItem
        | EncryptedContentFunctionCallOutputContentItem,
        Field(
            description="Responses API compatible content items that can be returned by a tool call. This is a subset of ContentItem with the types we support as function call outputs."
        ),
    ]


class GatewayOAuthChangedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    auth_url: Annotated[
        str | None,
        Field(
            alias="authUrl",
            description="Authorization handoff, sent only to the connection that started login.",
        ),
    ] = None
    error: str | None = None
    provider_id: Annotated[str, Field(alias="providerId")]
    status: GatewayOAuthStatus


class GatewayOAuthReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    error: str | None = None
    provider_id: Annotated[str, Field(alias="providerId")]
    provider_name: Annotated[str, Field(alias="providerName")]
    required: Annotated[
        bool,
        Field(
            description="Whether the selected provider uses gateway OAuth, even when already signed in."
        ),
    ]
    status: Annotated[
        GatewayOAuthStatus | None,
        Field(description="Null when the effective provider does not use gateway OAuth."),
    ] = None


class GetAccountResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    account: Account | None = None
    requires_openai_auth: Annotated[bool, Field(alias="requiresOpenaiAuth")]


class GuardianApprovalReview(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    rationale: str | None = None
    risk_level: Annotated[GuardianRiskLevel | None, Field(alias="riskLevel")] = None
    status: GuardianApprovalReviewStatus
    user_authorization: Annotated[
        GuardianUserAuthorization | None, Field(alias="userAuthorization")
    ] = None


class CommandGuardianApprovalReviewAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    command: str
    cwd: AbsolutePathBuf
    source: GuardianCommandSource
    type: Annotated[Literal["command"], Field(title="CommandGuardianApprovalReviewActionType")]


class ExecveGuardianApprovalReviewAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    argv: list[str]
    cwd: AbsolutePathBuf
    program: str
    source: GuardianCommandSource
    type: Annotated[Literal["execve"], Field(title="ExecveGuardianApprovalReviewActionType")]


class WriteStdinGuardianApprovalReviewAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approval_id: Annotated[str, Field(alias="approvalId")]
    cwd: LegacyAppPathString
    process_id: Annotated[str, Field(alias="processId")]
    stdin: str
    type: Annotated[
        Literal["writeStdin"], Field(title="WriteStdinGuardianApprovalReviewActionType")
    ]


class NetworkAccessGuardianApprovalReviewAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    host: str
    port: Annotated[int, Field(ge=0)]
    protocol: NetworkApprovalProtocol
    target: str
    type: Annotated[
        Literal["networkAccess"], Field(title="NetworkAccessGuardianApprovalReviewActionType")
    ]


class HookMetadata1(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    additional_context_limit: Annotated[
        int | None,
        Field(
            alias="additionalContextLimit",
            description="Configured `additionalContext` spill threshold. `null` uses 2,500 tokens; `0` disables spilling.",
            ge=0,
        ),
    ] = None
    current_hash: Annotated[str, Field(alias="currentHash")]
    display_order: Annotated[int, Field(alias="displayOrder")]
    enabled: bool
    event_name: Annotated[HookEventName, Field(alias="eventName")]
    is_managed: Annotated[bool, Field(alias="isManaged")]
    key: str
    matcher: str | None = None
    plugin_id: Annotated[str | None, Field(alias="pluginId")] = None
    source: HookSource
    source_path: Annotated[AbsolutePathBuf, Field(alias="sourcePath")]
    status_message: Annotated[str | None, Field(alias="statusMessage")] = None
    timeout_sec: Annotated[int, Field(alias="timeoutSec", ge=0)]
    trust_status: Annotated[HookTrustStatus, Field(alias="trustStatus")]
    async_: Annotated[bool | None, Field(alias="async")] = False
    command: str
    handler_type: Annotated[Literal["command"], Field(alias="handlerType")]


class HookMetadata2(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    additional_context_limit: Annotated[
        int | None,
        Field(
            alias="additionalContextLimit",
            description="Configured `additionalContext` spill threshold. `null` uses 2,500 tokens; `0` disables spilling.",
            ge=0,
        ),
    ] = None
    current_hash: Annotated[str, Field(alias="currentHash")]
    display_order: Annotated[int, Field(alias="displayOrder")]
    enabled: bool
    event_name: Annotated[HookEventName, Field(alias="eventName")]
    is_managed: Annotated[bool, Field(alias="isManaged")]
    key: str
    matcher: str | None = None
    plugin_id: Annotated[str | None, Field(alias="pluginId")] = None
    source: HookSource
    source_path: Annotated[AbsolutePathBuf, Field(alias="sourcePath")]
    status_message: Annotated[str | None, Field(alias="statusMessage")] = None
    timeout_sec: Annotated[int, Field(alias="timeoutSec", ge=0)]
    trust_status: Annotated[HookTrustStatus, Field(alias="trustStatus")]
    handler_type: Annotated[Literal["mcpTool"], Field(alias="handlerType")]
    server: str
    tool: str


class PromptHookMetadata(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    additional_context_limit: Annotated[
        int | None,
        Field(
            alias="additionalContextLimit",
            description="Configured `additionalContext` spill threshold. `null` uses 2,500 tokens; `0` disables spilling.",
            ge=0,
        ),
    ] = None
    current_hash: Annotated[str, Field(alias="currentHash")]
    display_order: Annotated[int, Field(alias="displayOrder")]
    enabled: bool
    event_name: Annotated[HookEventName, Field(alias="eventName")]
    is_managed: Annotated[bool, Field(alias="isManaged")]
    key: str
    matcher: str | None = None
    plugin_id: Annotated[str | None, Field(alias="pluginId")] = None
    source: HookSource
    source_path: Annotated[AbsolutePathBuf, Field(alias="sourcePath")]
    status_message: Annotated[str | None, Field(alias="statusMessage")] = None
    timeout_sec: Annotated[int, Field(alias="timeoutSec", ge=0)]
    trust_status: Annotated[HookTrustStatus, Field(alias="trustStatus")]
    handler_type: Annotated[Literal["prompt"], Field(alias="handlerType")]


class AgentHookMetadata(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    additional_context_limit: Annotated[
        int | None,
        Field(
            alias="additionalContextLimit",
            description="Configured `additionalContext` spill threshold. `null` uses 2,500 tokens; `0` disables spilling.",
            ge=0,
        ),
    ] = None
    current_hash: Annotated[str, Field(alias="currentHash")]
    display_order: Annotated[int, Field(alias="displayOrder")]
    enabled: bool
    event_name: Annotated[HookEventName, Field(alias="eventName")]
    is_managed: Annotated[bool, Field(alias="isManaged")]
    key: str
    matcher: str | None = None
    plugin_id: Annotated[str | None, Field(alias="pluginId")] = None
    source: HookSource
    source_path: Annotated[AbsolutePathBuf, Field(alias="sourcePath")]
    status_message: Annotated[str | None, Field(alias="statusMessage")] = None
    timeout_sec: Annotated[int, Field(alias="timeoutSec", ge=0)]
    trust_status: Annotated[HookTrustStatus, Field(alias="trustStatus")]
    handler_type: Annotated[Literal["agent"], Field(alias="handlerType")]


class HookMetadata(
    RootModel[HookMetadata1 | HookMetadata2 | PromptHookMetadata | AgentHookMetadata]
):
    root: HookMetadata1 | HookMetadata2 | PromptHookMetadata | AgentHookMetadata


class HookOutputEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    kind: HookOutputEntryKind
    text: str


class HookRunSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    completed_at: Annotated[int | None, Field(alias="completedAt")] = None
    display_order: Annotated[int, Field(alias="displayOrder")]
    duration_ms: Annotated[int | None, Field(alias="durationMs")] = None
    entries: list[HookOutputEntry]
    event_name: Annotated[HookEventName, Field(alias="eventName")]
    execution_mode: Annotated[HookExecutionMode, Field(alias="executionMode")]
    handler_type: Annotated[HookHandlerType, Field(alias="handlerType")]
    id: str
    scope: HookScope
    source: HookSource | None = "unknown"
    source_path: Annotated[AbsolutePathBuf, Field(alias="sourcePath")]
    started_at: Annotated[int, Field(alias="startedAt")]
    status: HookRunStatus
    status_message: Annotated[str | None, Field(alias="statusMessage")] = None


class HookStartedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    run: HookRunSummary
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str | None, Field(alias="turnId")] = None


class HooksListEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: str
    errors: list[HookErrorInfo]
    hooks: list[HookMetadata]
    warnings: list[str]


class HooksListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[HooksListEntry]


class ListMcpServerStatusParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cursor: Annotated[
        str | None, Field(description="Opaque pagination cursor returned by a previous call.")
    ] = None
    detail: Annotated[
        McpServerStatusDetail | None,
        Field(
            description="Controls how much MCP inventory data to fetch for each server. Defaults to `Full` when omitted."
        ),
    ] = None
    limit: Annotated[
        int | None,
        Field(description="Optional page size; defaults to a server-defined value.", ge=0),
    ] = None
    server_name: Annotated[
        str | None,
        Field(
            alias="serverName",
            description="Limit discovery to one server. With a thread ID, reuse that thread's MCP connection.",
        ),
    ] = None
    thread_id: Annotated[str | None, Field(alias="threadId")] = None


class ChatgptLoginAccountParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    app_brand: Annotated[LoginAppBrand | None, Field(alias="appBrand")] = None
    codex_streamlined_login: Annotated[bool | None, Field(alias="codexStreamlinedLogin")] = None
    type: Annotated[Literal["chatgpt"], Field(title="Chatgptv2::LoginAccountParamsType")]
    use_hosted_login_success_page: Annotated[
        bool | None, Field(alias="useHostedLoginSuccessPage")
    ] = None


class LoginAccountParams(
    RootModel[
        ApiKeyLoginAccountParams
        | ChatgptLoginAccountParams
        | ChatgptDeviceCodeLoginAccountParams
        | ChatgptAuthTokensLoginAccountParams
        | AmazonBedrockLoginAccountParams
        | AmazonBedrockAccessKeysLoginAccountParams
    ]
):
    root: Annotated[
        ApiKeyLoginAccountParams
        | ChatgptLoginAccountParams
        | ChatgptDeviceCodeLoginAccountParams
        | ChatgptAuthTokensLoginAccountParams
        | AmazonBedrockLoginAccountParams
        | AmazonBedrockAccessKeysLoginAccountParams,
        Field(title="LoginAccountParams"),
    ]


class McpResourceReadParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    connector_id: Annotated[str | None, Field(alias="connectorId")] = None
    origin_call_id: Annotated[
        str | None,
        Field(
            alias="originCallId",
            description="Originating MCP tool call used to select the resource's app.",
        ),
    ] = None
    server: str
    target: Annotated[
        McpResourceReadTarget | None,
        Field(description="Explicit hosted app/account. Omit to retain legacy resource discovery."),
    ] = None
    thread_id: Annotated[str | None, Field(alias="threadId")] = None
    uri: str


class McpResourceReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    contents: list[ResourceContent]
    origin_call_id: Annotated[
        str | None,
        Field(
            alias="originCallId",
            description="Originating call when the server applied app-specific resource scoping.",
        ),
    ] = None


class McpServerStatus(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    auth_status: Annotated[McpAuthStatus, Field(alias="authStatus")]
    http_origin: Annotated[
        str | None,
        Field(
            alias="httpOrigin",
            description="HTTP origin of the effective configured endpoint, including plugin servers. Excludes credentials, path, query, and fragment; null for non-HTTP transports.",
        ),
    ] = None
    name: str
    plugin_id: Annotated[str | None, Field(alias="pluginId")] = None
    resource_templates: Annotated[list[ResourceTemplate], Field(alias="resourceTemplates")]
    resources: list[Resource]
    runtime_status: Annotated[
        McpServerConnectionStatus | None,
        Field(
            alias="runtimeStatus",
            description="Current thread-runtime connection state; null when unavailable or the configuration changed.",
        ),
    ] = None
    server_capabilities: Annotated[
        Any | None,
        Field(
            alias="serverCapabilities",
            description="Capabilities advertised by the initialized MCP server; null when unavailable.",
        ),
    ] = None
    server_info: Annotated[McpServerInfo | None, Field(alias="serverInfo")] = None
    tool_list_meta: Annotated[
        Any | None,
        Field(
            alias="toolListMeta",
            description="Opaque `_meta` from the first page of the corresponding MCP tool catalog. Null when unavailable.",
        ),
    ] = None
    tools: dict[str, Tool]
    tools_error: Annotated[
        str | None,
        Field(
            alias="toolsError",
            description="Tool discovery failed and no catalog was returned. Null when a catalog is returned, including cached or empty catalogs.",
        ),
    ] = None


class MemoryCitation(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    entries: list[MemoryCitationEntry]
    thread_ids: Annotated[list[str], Field(alias="threadIds")]


class MigrationDetails(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    commands: Annotated[list[CommandMigration] | None, Field(validate_default=True)] = []
    hooks: Annotated[list[HookMigration] | None, Field(validate_default=True)] = []
    mcp_servers: Annotated[
        list[McpServerMigration] | None, Field(alias="mcpServers", validate_default=True)
    ] = []
    memory: list[str] | None = None
    plugins: Annotated[list[PluginsMigration] | None, Field(validate_default=True)] = []
    sessions: Annotated[list[SessionMigration] | None, Field(validate_default=True)] = []
    skills: Annotated[list[SkillMigration] | None, Field(validate_default=True)] = []
    subagents: Annotated[list[SubagentMigration] | None, Field(validate_default=True)] = []


class MisalignmentErrorDetails(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    detailed_explanation: Annotated[
        str | None,
        Field(
            alias="detailedExplanation",
            description="A substantive localized explanation is required before offering continuation.",
        ),
    ] = None
    error_type: Annotated[
        str | None,
        Field(
            alias="errorType",
            description="Open-ended classification; clients must accept categories added by Responses.",
        ),
    ] = None
    review_target: Annotated[
        str | None,
        Field(
            alias="reviewTarget",
            description="Opaque server-issued block target. Presence alone does not enable target-based continuation.",
        ),
    ] = None
    steer: Annotated[
        MisalignmentSteer | None,
        Field(
            description="Instruction to submit as the next turn's user input if continuation is confirmed."
        ),
    ] = None


class Model(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    additional_speed_tiers: Annotated[
        list[str] | None,
        Field(alias="additionalSpeedTiers", description="Deprecated: use `serviceTiers` instead."),
    ] = []
    availability_nux: Annotated[ModelAvailabilityNux | None, Field(alias="availabilityNux")] = None
    available_access_programs: Annotated[
        ModelAccessPrograms | None,
        Field(
            alias="availableAccessPrograms",
            description="Null when the catalog does not provide access-program metadata.",
        ),
    ] = None
    default_reasoning_effort: Annotated[ReasoningEffort, Field(alias="defaultReasoningEffort")]
    default_service_tier: Annotated[
        str | None,
        Field(
            alias="defaultServiceTier",
            description="Catalog default service tier id for this model, when one is configured.",
        ),
    ] = None
    description: str
    display_name: Annotated[str, Field(alias="displayName")]
    hidden: bool
    id: str
    input_modalities: Annotated[list[InputModality] | None, Field(alias="inputModalities")] = [
        "text",
        "image",
    ]
    is_default: Annotated[bool, Field(alias="isDefault")]
    model: str
    model_specialty: Annotated[str | None, Field(alias="modelSpecialty")] = None
    multi_agent_version: Annotated[
        MultiAgentVersion | None,
        Field(
            alias="multiAgentVersion",
            description="Multi-agent runtime declared by this model, when available.",
        ),
    ] = None
    service_tiers: Annotated[
        list[ModelServiceTier] | None, Field(alias="serviceTiers", validate_default=True)
    ] = []
    supported_reasoning_efforts: Annotated[
        list[ReasoningEffortOption], Field(alias="supportedReasoningEfforts")
    ]
    supports_personality: Annotated[
        bool | None,
        Field(
            alias="supportsPersonality",
            description="@deprecated Always false; models no longer support personality selection.",
        ),
    ] = False
    upgrade: str | None = None
    upgrade_info: Annotated[ModelUpgradeInfo | None, Field(alias="upgradeInfo")] = None


class ModelListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[Model]
    next_cursor: Annotated[
        str | None,
        Field(
            alias="nextCursor",
            description="Opaque cursor to pass to the next call to continue after the last item. If None, there are no more items to return.",
        ),
    ] = None


class NewThreadModelDefaults(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    model: str | None = None
    model_reasoning_effort: Annotated[
        ReasoningEffort | None, Field(alias="modelReasoningEffort")
    ] = None
    service_tier: Annotated[str | None, Field(alias="serviceTier")] = None


class OverriddenMetadata(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    effective_value: Annotated[Any, Field(alias="effectiveValue")]
    message: str
    overriding_layer: Annotated[ConfigLayerMetadata, Field(alias="overridingLayer")]


class PermissionProfileListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[PermissionProfileSummary]
    next_cursor: Annotated[
        str | None,
        Field(
            alias="nextCursor",
            description="Opaque cursor to pass to the next call to continue after the last item. If None, there are no more items to return.",
        ),
    ] = None


class PluginSharePrincipal(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str
    principal_id: Annotated[str, Field(alias="principalId")]
    principal_type: Annotated[PluginSharePrincipalType, Field(alias="principalType")]
    role: PluginSharePrincipalRole


class PluginShareTarget(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    principal_id: Annotated[str, Field(alias="principalId")]
    principal_type: Annotated[PluginSharePrincipalType, Field(alias="principalType")]
    role: PluginShareTargetRole


class PluginShareUpdateTargetsParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    discoverability: PluginShareUpdateDiscoverability
    remote_plugin_id: Annotated[str, Field(alias="remotePluginId")]
    share_targets: Annotated[list[PluginShareTarget], Field(alias="shareTargets")]


class PluginShareUpdateTargetsResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    discoverability: PluginShareDiscoverability
    principals: list[PluginSharePrincipal]


class ProcessOutputDeltaNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cap_reached: Annotated[
        bool,
        Field(
            alias="capReached",
            description="True on the final streamed chunk for this stream when output was truncated by `outputBytesCap`.",
        ),
    ]
    delta_base64: Annotated[
        str, Field(alias="deltaBase64", description="Base64-encoded output bytes.")
    ]
    process_handle: Annotated[
        str,
        Field(
            alias="processHandle",
            description="Client-supplied, connection-scoped `processHandle` from `process/spawn`.",
        ),
    ]
    stream: Annotated[
        ProcessOutputStream, Field(description="Output stream this chunk belongs to.")
    ]


class Project(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    created_at: Annotated[int, Field(alias="createdAt")]
    id: str
    metadata: dict[str, str]
    name: str
    position: int
    recency_at: Annotated[
        int | None,
        Field(
            alias="recencyAt",
            description="Newest non-archived member thread's recency, in Unix seconds; null when none exist.",
        ),
    ] = None
    roots: list[ProjectRoot]
    updated_at: Annotated[int, Field(alias="updatedAt")]


class QueuedSubmission(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    client_user_message_id: Annotated[str, Field(alias="clientUserMessageId")]
    id: str
    input: list[UserInput]


class RateLimitResetCredit(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    description: Annotated[
        str | None,
        Field(
            description="Backend-provided display description for this credit, or `null` when unavailable."
        ),
    ] = None
    expires_at: Annotated[
        int | None,
        Field(
            alias="expiresAt",
            description="Unix timestamp in seconds when the credit expires, or `null` if it does not expire.",
        ),
    ] = None
    granted_at: Annotated[
        int,
        Field(
            alias="grantedAt", description="Unix timestamp in seconds when the credit was granted."
        ),
    ]
    id: Annotated[str, Field(description="Opaque backend identifier for this reset credit.")]
    reset_type: Annotated[RateLimitResetType, Field(alias="resetType")]
    status: RateLimitResetCreditStatus
    title: Annotated[
        str | None,
        Field(
            description="Backend-provided display title for this credit, or `null` when unavailable."
        ),
    ] = None


class RateLimitResetCreditsSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    available_count: Annotated[int, Field(alias="availableCount")]
    credits: Annotated[
        list[RateLimitResetCredit] | None,
        Field(
            description="Detail rows for available reset credits, when the backend provides them.\n\n`null` means only `availableCount` is known, while an empty array means details were fetched and no available credits were returned. The backend may cap this list, so its length can be less than `availableCount`."
        ),
    ] = None


class RateLimitSnapshot(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    credits: CreditsSnapshot | None = None
    individual_limit: Annotated[
        SpendControlLimitSnapshot | None, Field(alias="individualLimit")
    ] = None
    limit_id: Annotated[str | None, Field(alias="limitId")] = None
    limit_name: Annotated[str | None, Field(alias="limitName")] = None
    normal_model_slug: Annotated[
        str | None,
        Field(
            alias="normalModelSlug",
            description="Normal model whose display name and reasoning options describe this quota alias.",
        ),
    ] = None
    plan_type: Annotated[PlanType | None, Field(alias="planType")] = None
    primary: RateLimitWindow | None = None
    rate_limit_reached_type: Annotated[
        RateLimitReachedType | None, Field(alias="rateLimitReachedType")
    ] = None
    secondary: RateLimitWindow | None = None
    spend_control_reached: Annotated[
        bool | None,
        Field(
            alias="spendControlReached",
            description="Backend-reported spend-control state. `None` is unavailable, not a sparse-update recovery.",
        ),
    ] = None


class RawResponseCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    response_id: Annotated[str, Field(alias="responseId")]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]
    usage: TokenUsageBreakdown | None = None
    usage_metadata: Annotated[ResponseUsageMetadata | None, Field(alias="usageMetadata")] = None


class MessageResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    content: list[ContentItem]
    encrypted_content: str | None = None
    id: str | None = None
    internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
    phase: MessagePhase | None = None
    role: str
    status: str | None = None
    type: Annotated[Literal["message"], Field(title="MessageResponseItemType")]


class WebSearchCallResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    action: ResponsesApiWebSearchAction | None = None
    encrypted_content: str | None = None
    id: str | None = None
    internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
    status: str | None = None
    type: Annotated[Literal["web_search_call"], Field(title="WebSearchCallResponseItemType")]


class ConfigurationUpdateResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    reasoning: ConfigurationReasoning
    type: Annotated[
        Literal["configuration_update"], Field(title="ConfigurationUpdateResponseItemType")
    ]


class ReviewStartParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    delivery: Annotated[
        ReviewDelivery | None,
        Field(
            description="Where to run the review: inline (default) on the current thread or detached on a new thread (returned in `reviewThreadId`). Detached delivery is deprecated and emits `deprecationNotice`. Use `thread/start` followed by an inline review for a separate review thread."
        ),
    ] = None
    target: ReviewTarget
    thread_id: Annotated[str, Field(alias="threadId")]


class HourlyScheduledTaskSchedule(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    days: list[ScheduledTaskWeekday] | None = None
    interval_hours: Annotated[int, Field(alias="intervalHours", ge=0)]
    type: Annotated[Literal["hourly"], Field(title="HourlyScheduledTaskScheduleType")]


class WeeklyScheduledTaskSchedule(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    days: list[ScheduledTaskWeekday]
    time: str
    type: Annotated[Literal["weekly"], Field(title="WeeklyScheduledTaskScheduleType")]


class ScheduledTaskSchedule(
    RootModel[
        HourlyScheduledTaskSchedule
        | DailyScheduledTaskSchedule
        | WeekdaysScheduledTaskSchedule
        | WeeklyScheduledTaskSchedule
    ]
):
    root: (
        HourlyScheduledTaskSchedule
        | DailyScheduledTaskSchedule
        | WeekdaysScheduledTaskSchedule
        | WeeklyScheduledTaskSchedule
    )


class ScheduledTaskSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    key: str
    name: str
    prompt: str
    schedule: ScheduledTaskSchedule


class ThreadStatusChangedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/status/changed"], Field(title="Thread/status/changedNotificationMethod")
    ]
    params: ThreadStatusChangedNotification


class ThreadArchivedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["thread/archived"], Field(title="Thread/archivedNotificationMethod")]
    params: ThreadArchivedNotification


class ThreadDeletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["thread/deleted"], Field(title="Thread/deletedNotificationMethod")]
    params: ThreadDeletedNotification


class ThreadUnarchivedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/unarchived"], Field(title="Thread/unarchivedNotificationMethod")
    ]
    params: ThreadUnarchivedNotification


class ThreadClosedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["thread/closed"], Field(title="Thread/closedNotificationMethod")]
    params: ThreadClosedNotification


class ThreadRevertedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["thread/reverted"], Field(title="Thread/revertedNotificationMethod")]
    params: ThreadRevertedNotification


class SkillsChangedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["skills/changed"], Field(title="Skills/changedNotificationMethod")]
    params: SkillsChangedNotification


class ThreadNameUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/name/updated"], Field(title="Thread/name/updatedNotificationMethod")
    ]
    params: ThreadNameUpdatedNotification


class ThreadAttachmentUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/attachment/updated"],
        Field(title="Thread/attachment/updatedNotificationMethod"),
    ]
    params: ThreadAttachmentUpdatedNotification


class ThreadPredictionUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/prediction/updated"],
        Field(title="Thread/prediction/updatedNotificationMethod"),
    ]
    params: ThreadPredictionUpdatedNotification


class ThreadGoalClearedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/goal/cleared"], Field(title="Thread/goal/clearedNotificationMethod")
    ]
    params: ThreadGoalClearedNotification


class ThreadQueueChangedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/queue/changed"], Field(title="Thread/queue/changedNotificationMethod")
    ]
    params: ThreadQueueChangedNotification


class ThreadProjectUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/project/updated"], Field(title="Thread/project/updatedNotificationMethod")
    ]
    params: ThreadProjectUpdatedNotification


class HookStartedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["hook/started"], Field(title="Hook/startedNotificationMethod")]
    params: HookStartedNotification


class TurnDiffUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["turn/diff/updated"], Field(title="Turn/diff/updatedNotificationMethod")
    ]
    params: TurnDiffUpdatedNotification


class AutoApprovalReviewStrictReviewRequiredServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["autoApprovalReview/strictReviewRequired"],
        Field(title="AutoApprovalReview/strictReviewRequiredNotificationMethod"),
    ]
    params: StrictReviewRequiredNotification


class CommandExecOutputDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["command/exec/outputDelta"],
        Field(title="Command/exec/outputDeltaNotificationMethod"),
    ]
    params: CommandExecOutputDeltaNotification


class ProcessOutputDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["process/outputDelta"], Field(title="Process/outputDeltaNotificationMethod")
    ]
    params: ProcessOutputDeltaNotification


class ItemCommandExecutionTerminalInteractionServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["item/commandExecution/terminalInteraction"],
        Field(title="Item/commandExecution/terminalInteractionNotificationMethod"),
    ]
    params: TerminalInteractionNotification


class ServerRequestResolvedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["serverRequest/resolved"], Field(title="ServerRequest/resolvedNotificationMethod")
    ]
    params: ServerRequestResolvedNotification


class AccountUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["account/updated"], Field(title="Account/updatedNotificationMethod")]
    params: AccountUpdatedNotification


class AccountGatewayOAuthChangedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["account/gatewayOAuth/changed"],
        Field(title="Account/gatewayOAuth/changedNotificationMethod"),
    ]
    params: GatewayOAuthChangedNotification


class TurnModerationMetadataServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["turn/moderationMetadata"], Field(title="Turn/moderationMetadataNotificationMethod")
    ]
    params: TurnModerationMetadataNotification


class WarningServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["warning"], Field(title="WarningNotificationMethod")]
    params: WarningNotification


class ConfigWarningServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["configWarning"], Field(title="ConfigWarningNotificationMethod")]
    params: ConfigWarningNotification


class ThreadRealtimeStartedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/realtime/started"], Field(title="Thread/realtime/startedNotificationMethod")
    ]
    params: ThreadRealtimeStartedNotification


class ThreadRealtimeItemAddedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/realtime/itemAdded"],
        Field(title="Thread/realtime/itemAddedNotificationMethod"),
    ]
    params: ThreadRealtimeItemAddedNotification


class ThreadRealtimeItemTranscriptDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/realtime/item/transcript/delta"],
        Field(title="Thread/realtime/item/transcript/deltaNotificationMethod"),
    ]
    params: ThreadRealtimeItemTranscriptDeltaNotification


class ThreadRealtimeTranscriptDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/realtime/transcript/delta"],
        Field(title="Thread/realtime/transcript/deltaNotificationMethod"),
    ]
    params: ThreadRealtimeTranscriptDeltaNotification


class ThreadRealtimeTranscriptDoneServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/realtime/transcript/done"],
        Field(title="Thread/realtime/transcript/doneNotificationMethod"),
    ]
    params: ThreadRealtimeTranscriptDoneNotification


class ThreadRealtimeOutputAudioDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/realtime/outputAudio/delta"],
        Field(title="Thread/realtime/outputAudio/deltaNotificationMethod"),
    ]
    params: ThreadRealtimeOutputAudioDeltaNotification


class ThreadRealtimeSdpServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/realtime/sdp"], Field(title="Thread/realtime/sdpNotificationMethod")
    ]
    params: ThreadRealtimeSdpNotification


class ThreadRealtimeErrorServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/realtime/error"], Field(title="Thread/realtime/errorNotificationMethod")
    ]
    params: ThreadRealtimeErrorNotification


class ThreadRealtimeClosedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/realtime/closed"], Field(title="Thread/realtime/closedNotificationMethod")
    ]
    params: ThreadRealtimeClosedNotification


class WindowsWorldWritableWarningServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["windows/worldWritableWarning"],
        Field(title="Windows/worldWritableWarningNotificationMethod"),
    ]
    params: WindowsWorldWritableWarningNotification


class AccountLoginCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["account/login/completed"], Field(title="Account/login/completedNotificationMethod")
    ]
    params: AccountLoginCompletedNotification


class SkillDependencies(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    tools: list[SkillToolDependency]


class SkillMetadata(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    dependencies: SkillDependencies | None = None
    description: str
    enabled: bool
    interface: SkillInterface | None = None
    name: str
    path: LegacyAppPathString
    plugin_id: Annotated[
        str | None,
        Field(
            alias="pluginId",
            description="Owning plugin ID, matching `PluginSummary.id`, when known.",
        ),
    ] = None
    scope: SkillScope
    short_description: Annotated[
        str | None,
        Field(
            alias="shortDescription",
            description="Legacy short_description from SKILL.md. Prefer SKILL.json interface.short_description.",
        ),
    ] = None


class SkillsListEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: str
    errors: list[SkillErrorInfo]
    skills: list[SkillMetadata]


class SkillsListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[SkillsListEntry]


class ThreadSpawn(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    agent_nickname: str | None = None
    agent_path: AgentPath | None = None
    agent_role: str | None = None
    depth: int
    parent_thread_id: ThreadId


class ThreadSpawnSubAgentSource(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    thread_spawn: ThreadSpawn


class SubAgentSource(
    RootModel[SubAgentSourceValue | ThreadSpawnSubAgentSource | OtherSubAgentSource]
):
    root: SubAgentSourceValue | ThreadSpawnSubAgentSource | OtherSubAgentSource


class ThreadForkParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approval_policy: Annotated[AskForApproval | None, Field(alias="approvalPolicy")] = None
    approvals_reviewer: Annotated[
        ApprovalsReviewer | None,
        Field(
            alias="approvalsReviewer",
            description="Override where approval requests are routed for review on this thread and subsequent turns.",
        ),
    ] = None
    base_instructions: Annotated[str | None, Field(alias="baseInstructions")] = None
    config: dict[str, Any] | None = None
    cwd: str | None = None
    developer_instructions: Annotated[str | None, Field(alias="developerInstructions")] = None
    ephemeral: bool | None = None
    exclude_turns: Annotated[
        bool | None,
        Field(
            alias="excludeTurns",
            description="When true, return only thread metadata and live fork state without populating `thread.turns`. This is useful when the client plans to call `thread/turns/list` immediately after forking. Full-history hydration is deprecated for paginated threads; use this with `thread/turns/list` and `thread/items/list` instead.",
        ),
    ] = None
    last_turn_id: Annotated[
        str | None,
        Field(
            alias="lastTurnId",
            description="Optional last turn id to fork through, inclusive.\n\nWhen specified, turns after `last_turn_id` are omitted from the fork. The referenced turn cannot be in progress.",
        ),
    ] = None
    model: Annotated[
        str | None, Field(description="Configuration overrides for the forked thread, if any.")
    ] = None
    model_provider: Annotated[str | None, Field(alias="modelProvider")] = None
    sandbox: SandboxMode | None = None
    service_tier: Annotated[str | None, Field(alias="serviceTier")] = None
    thread_id: Annotated[str, Field(alias="threadId")]
    thread_source: Annotated[
        ThreadSource | None,
        Field(
            alias="threadSource",
            description="Optional client-supplied analytics source classification for this forked thread.",
        ),
    ] = None


class ThreadGoal(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    created_at: Annotated[int, Field(alias="createdAt")]
    objective: str
    status: ThreadGoalStatus
    thread_id: Annotated[str, Field(alias="threadId")]
    time_used_seconds: Annotated[int, Field(alias="timeUsedSeconds")]
    token_budget: Annotated[int | None, Field(alias="tokenBudget")] = None
    tokens_used: Annotated[int, Field(alias="tokensUsed")]
    updated_at: Annotated[int, Field(alias="updatedAt")]


class ThreadGoalClearParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    origin: Annotated[
        ThreadGoalMutationOrigin | None,
        Field(description="Missing provenance does not supply user authorization."),
    ] = None
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadGoalGetResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    goal: ThreadGoal | None = None


class ThreadGoalSetParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    objective: str | None = None
    origin: Annotated[
        ThreadGoalMutationOrigin | None,
        Field(description="Missing provenance does not supply user authorization."),
    ] = None
    status: ThreadGoalStatus | None = None
    thread_id: Annotated[str, Field(alias="threadId")]
    token_budget: Annotated[int | None, Field(alias="tokenBudget")] = None


class ThreadGoalSetResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    goal: ThreadGoal


class ThreadGoalUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    goal: ThreadGoal
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str | None, Field(alias="turnId")] = None


class UserMessageThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    client_id: Annotated[str | None, Field(alias="clientId")] = None
    content: list[UserInput]
    id: str
    type: Annotated[Literal["userMessage"], Field(title="UserMessageThreadItemType")]


class AgentMessageThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    delivery: AgentMessageDelivery | None = None
    id: str
    memory_citation: Annotated[MemoryCitation | None, Field(alias="memoryCitation")] = None
    phase: MessagePhase | None = None
    questions: list[AsyncUserInputQuestion] | None = None
    text: str
    type: Annotated[Literal["agentMessage"], Field(title="AgentMessageThreadItemType")]


class CommandExecutionThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    aggregated_output: Annotated[
        str | None,
        Field(
            alias="aggregatedOutput",
            description="The command's output, aggregated from stdout and stderr.",
        ),
    ] = None
    command: Annotated[str, Field(description="The command to be executed.")]
    command_actions: Annotated[
        list[CommandAction],
        Field(
            alias="commandActions",
            description="A best-effort parsing of the command to understand the action(s) it will perform. This returns a list of CommandAction objects because a single shell command may be composed of many commands piped together.",
        ),
    ]
    cwd: Annotated[LegacyAppPathString, Field(description="The command's working directory.")]
    duration_ms: Annotated[
        int | None,
        Field(
            alias="durationMs", description="The duration of the command execution in milliseconds."
        ),
    ] = None
    exit_code: Annotated[
        int | None, Field(alias="exitCode", description="The command's exit code.")
    ] = None
    id: str
    plugin_id: Annotated[
        str | None,
        Field(
            alias="pluginId",
            description="Trusted first-party plugin id when this command resolves to one plugin script.",
        ),
    ] = None
    process_id: Annotated[
        str | None,
        Field(
            alias="processId",
            description="Identifier for the underlying PTY process (when available).",
        ),
    ] = None
    script_path: Annotated[
        str | None,
        Field(
            alias="scriptPath",
            description="Safe plugin-relative path when this command resolves to one plugin script.",
        ),
    ] = None
    source: CommandExecutionSource | None = "agent"
    status: CommandExecutionStatus
    type: Annotated[Literal["commandExecution"], Field(title="CommandExecutionThreadItemType")]


class FileChangeThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    changes: list[FileUpdateChange]
    id: str
    status: PatchApplyStatus
    type: Annotated[Literal["fileChange"], Field(title="FileChangeThreadItemType")]


class CollabAgentToolCallThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    agents_states: Annotated[
        dict[str, CollabAgentState],
        Field(
            alias="agentsStates",
            description="Last known status of the target agents, when available.",
        ),
    ]
    id: Annotated[str, Field(description="Unique identifier for this collab tool call.")]
    model: Annotated[
        str | None, Field(description="Model requested for the spawned agent, when applicable.")
    ] = None
    prompt: Annotated[
        str | None,
        Field(description="Prompt text sent as part of the collab tool call, when available."),
    ] = None
    reasoning_effort: Annotated[
        ReasoningEffort | None,
        Field(
            alias="reasoningEffort",
            description="Reasoning effort requested for the spawned agent, when applicable.",
        ),
    ] = None
    receiver_thread_ids: Annotated[
        list[str],
        Field(
            alias="receiverThreadIds",
            description="Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
        ),
    ]
    sender_thread_id: Annotated[
        str,
        Field(
            alias="senderThreadId", description="Thread ID of the agent issuing the collab request."
        ),
    ]
    status: Annotated[
        CollabAgentToolCallStatus, Field(description="Current status of the collab tool call.")
    ]
    tool: Annotated[CollabAgentTool, Field(description="Name of the collab tool that was invoked.")]
    type: Annotated[
        Literal["collabAgentToolCall"], Field(title="CollabAgentToolCallThreadItemType")
    ]


class WebSearchThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    action: WebSearchAction | None = None
    id: str
    query: str
    results: Annotated[
        list[Any] | None,
        Field(
            description="Structured search results returned out-of-band by standalone web search.\n\nThese stay as opaque JSON at the extension/app-server boundary so new result fields and result types can pass through without a Codex release."
        ),
    ] = None
    type: Annotated[Literal["webSearch"], Field(title="WebSearchThreadItemType")]


class ThreadListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    archived: Annotated[
        bool | None,
        Field(
            description="Optional archived filter; when set to true, only archived threads are returned. If false or null, only non-archived threads are returned."
        ),
    ] = None
    cursor: Annotated[
        str | None, Field(description="Opaque pagination cursor returned by a previous call.")
    ] = None
    cwd: Annotated[
        ThreadListCwdFilter | None,
        Field(
            description="Optional cwd filter or filters; when set, only threads whose session cwd exactly matches one of these paths are returned."
        ),
    ] = None
    excluded_thread_ids: Annotated[
        list[str] | None,
        Field(
            alias="excludedThreadIds",
            description="Thread IDs to exclude before applying the result limit. Up to 100 entries; invalid IDs or a larger list are rejected, never truncated. Send the same exclusions on each page. Omitted, null, or empty means no exclusions.",
        ),
    ] = None
    limit: Annotated[
        int | None,
        Field(description="Optional page size; defaults to a reasonable server-side value.", ge=0),
    ] = None
    model_providers: Annotated[
        list[str] | None,
        Field(
            alias="modelProviders",
            description="Optional provider filter; when set, only sessions recorded under these providers are returned. When present but empty, includes all providers.",
        ),
    ] = None
    originators: Annotated[
        list[str] | None,
        Field(
            description="Optional originator allowlist, matching any supplied value exactly. Supported by hosted backends only; the local app-server rejects a nonempty list. Omitted or empty lists leave originators unrestricted."
        ),
    ] = None
    search_term: Annotated[
        str | None,
        Field(
            alias="searchTerm",
            description="Optional substring filter for the extracted thread title.",
        ),
    ] = None
    section_id: Annotated[
        str | None,
        Field(
            alias="sectionId",
            description="Omit to include every section, set to `null` for unsectioned threads, or provide a section ID to return only threads in that section.",
        ),
    ] = None
    sort_direction: Annotated[
        SortDirection | None,
        Field(
            alias="sortDirection",
            description="Optional sort direction; defaults to descending (newest first).",
        ),
    ] = None
    sort_key: Annotated[
        ThreadSortKey | None,
        Field(alias="sortKey", description="Optional sort key; defaults to created_at."),
    ] = None
    source_kinds: Annotated[
        list[ThreadSourceKind] | None,
        Field(
            alias="sourceKinds",
            description="Optional source filter; when set, only sessions from these source kinds are returned. When omitted or empty, defaults to interactive sources.",
        ),
    ] = None
    use_state_db_only: Annotated[
        bool | None,
        Field(
            alias="useStateDbOnly",
            description="If true, return from the state DB without scanning JSONL rollouts to repair thread metadata. Omitted or false preserves scan-and-repair behavior.",
        ),
    ] = None


class ThreadReadState(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    first_unread: Annotated[ThreadUnreadPosition | None, Field(alias="firstUnread")] = None
    revision: str


class ThreadReadStateChangedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    read_state: Annotated[ThreadReadState, Field(alias="readState")]
    thread_id: Annotated[str, Field(alias="threadId")]


class TranscriptSegmentThreadRealtimeItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    realtime_session_id: Annotated[str, Field(alias="realtimeSessionId")]
    role: ThreadRealtimeTranscriptRole
    text: str
    type: Annotated[
        Literal["transcriptSegment"], Field(title="TranscriptSegmentThreadRealtimeItemType")
    ]


class RealtimeSessionClosedThreadRealtimeItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    realtime_session_id: Annotated[str, Field(alias="realtimeSessionId")]
    outcome: ThreadRealtimeSessionOutcome
    type: Annotated[
        Literal["realtimeSessionClosed"], Field(title="RealtimeSessionClosedThreadRealtimeItemType")
    ]


class ThreadRealtimeItem(
    RootModel[
        RealtimeSessionStartedThreadRealtimeItem
        | TranscriptSegmentThreadRealtimeItem
        | BemItemPromotedThreadRealtimeItem
        | RealtimeSessionClosedThreadRealtimeItem
    ]
):
    root: Annotated[
        RealtimeSessionStartedThreadRealtimeItem
        | TranscriptSegmentThreadRealtimeItem
        | BemItemPromotedThreadRealtimeItem
        | RealtimeSessionClosedThreadRealtimeItem,
        Field(
            description="EXPERIMENTAL - a thread-scoped realtime item in the canonical timeline."
        ),
    ]


class ThreadRealtimeItemCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item: ThreadRealtimeItem
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadRealtimeItemStartedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item: ThreadRealtimeItem
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadResumeInitialTurnsPageParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    items_view: Annotated[
        TurnItemsView | None,
        Field(
            alias="itemsView",
            description="How much item detail to include for each returned turn; defaults to summary.",
        ),
    ] = None
    limit: Annotated[int | None, Field(description="Optional turn page size.", ge=0)] = None
    sort_direction: Annotated[
        SortDirection | None,
        Field(
            alias="sortDirection",
            description="Optional turn pagination direction; defaults to descending.",
        ),
    ] = None


class ThreadSection(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    appearance: Annotated[
        ThreadSectionAppearance | None,
        Field(description="Optional appearance synchronized across clients."),
    ] = None
    id: Annotated[
        str,
        Field(
            description="Opaque UUIDv7 identity that remains stable when the section is renamed."
        ),
    ]
    name: Annotated[str, Field(description="The current user-visible section name.")]


class ThreadSectionCreateResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    section: ThreadSection


class ThreadSectionListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[ThreadSection]
    next_cursor: Annotated[
        str | None,
        Field(
            alias="nextCursor",
            description="Opaque cursor for the next page, or `null` when no sections remain.",
        ),
    ] = None


class ThreadSectionUpdateResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    section: ThreadSection


class ThreadSettings(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    active_permission_profile: Annotated[
        ActivePermissionProfile | None, Field(alias="activePermissionProfile")
    ] = None
    approval_policy: Annotated[AskForApproval, Field(alias="approvalPolicy")]
    approvals_reviewer: Annotated[ApprovalsReviewer, Field(alias="approvalsReviewer")]
    collaboration_mode: Annotated[CollaborationMode, Field(alias="collaborationMode")]
    cwd: AbsolutePathBuf
    disabled_plugin_ids: Annotated[
        list[str] | None,
        Field(
            alias="disabledPluginIds",
            description="Saved list of disabled plugin IDs. Does not yet filter plugin capabilities.",
        ),
    ] = []
    effort: ReasoningEffort | None = None
    model: str
    model_provider: Annotated[str, Field(alias="modelProvider")]
    personality: Annotated[
        Personality | None,
        Field(
            description="@deprecated Reports the saved setting; `friendly` and `pragmatic` no longer select a style."
        ),
    ] = None
    sandbox_policy: Annotated[SandboxPolicy, Field(alias="sandboxPolicy")]
    service_tier: Annotated[str | None, Field(alias="serviceTier")] = None
    summary: ReasoningSummary | None = None


class ThreadSettingsUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]
    thread_settings: Annotated[ThreadSettings, Field(alias="threadSettings")]


class ThreadStartParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approval_policy: Annotated[AskForApproval | None, Field(alias="approvalPolicy")] = None
    approvals_reviewer: Annotated[
        ApprovalsReviewer | None,
        Field(
            alias="approvalsReviewer",
            description="Override where approval requests are routed for review on this thread and subsequent turns.",
        ),
    ] = None
    base_instructions: Annotated[str | None, Field(alias="baseInstructions")] = None
    config: dict[str, Any] | None = None
    cwd: str | None = None
    developer_instructions: Annotated[str | None, Field(alias="developerInstructions")] = None
    ephemeral: bool | None = None
    model: str | None = None
    model_provider: Annotated[str | None, Field(alias="modelProvider")] = None
    personality: Annotated[
        Personality | None,
        Field(description="@deprecated `friendly` and `pragmatic` no longer select a style."),
    ] = None
    sandbox: SandboxMode | None = None
    service_name: Annotated[str | None, Field(alias="serviceName")] = None
    service_tier: Annotated[str | None, Field(alias="serviceTier")] = None
    session_start_source: Annotated[ThreadStartSource | None, Field(alias="sessionStartSource")] = (
        None
    )
    thread_source: Annotated[
        ThreadSource | None,
        Field(
            alias="threadSource",
            description="Optional client-supplied analytics source classification for this thread.",
        ),
    ] = None


class RealtimeThreadTimelineEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item: ThreadRealtimeItem
    position: Annotated[int, Field(ge=0)]
    type: Annotated[Literal["realtime"], Field(title="RealtimeThreadTimelineEntryType")]


class ThreadTokenUsage(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    last: TokenUsageBreakdown
    model_context_window: Annotated[int | None, Field(alias="modelContextWindow")] = None
    total: TokenUsageBreakdown


class ThreadTokenUsageUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]
    token_usage: Annotated[ThreadTokenUsage, Field(alias="tokenUsage")]
    turn_id: Annotated[str, Field(alias="turnId")]


class ThreadTurnsListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cursor: Annotated[
        str | None,
        Field(
            description="Opaque cursor to pass to the next call to continue after the last turn."
        ),
    ] = None
    items_view: Annotated[
        TurnItemsView | None,
        Field(
            alias="itemsView",
            description="How much item detail to include for each returned turn; defaults to summary.",
        ),
    ] = None
    limit: Annotated[int | None, Field(description="Optional turn page size.", ge=0)] = None
    sort_direction: Annotated[
        SortDirection | None,
        Field(
            alias="sortDirection",
            description="Optional turn pagination direction; defaults to descending.",
        ),
    ] = None
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadUnsubscribeResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    status: ThreadUnsubscribeStatus


class ThreadUsage(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    estimated_usage_credits_micros: Annotated[int, Field(alias="estimatedUsageCreditsMicros")]
    estimated_usage_usd_micros: Annotated[int | None, Field(alias="estimatedUsageUsdMicros")] = None
    groups: list[ThreadUsageBreakdownGroup]
    thread_id: Annotated[str, Field(alias="threadId")]


class ToolsV2(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    web_search: WebSearchToolConfig | None = None


class TurnError(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    additional_details: Annotated[str | None, Field(alias="additionalDetails")] = None
    codex_error_info: Annotated[CodexErrorInfo | None, Field(alias="codexErrorInfo")] = None
    message: str
    misalignment: Annotated[
        MisalignmentErrorDetails | None,
        Field(
            description="Optional public explanation and continuation instruction for a misalignment block."
        ),
    ] = None


class TurnPlanStep(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    status: TurnPlanStepStatus
    step: str


class TurnPlanUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    explanation: str | None = None
    plan: list[TurnPlanStep]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class TurnSteerParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    client_user_message_id: Annotated[str | None, Field(alias="clientUserMessageId")] = None
    expected_turn_id: Annotated[
        str,
        Field(
            alias="expectedTurnId",
            description="Required active turn id precondition. The request fails when it does not match the currently active turn.",
        ),
    ]
    input: list[UserInput]
    thread_id: Annotated[str, Field(alias="threadId")]


class WindowsSandboxSetupCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    error: str | None = None
    mode: WindowsSandboxSetupMode
    success: bool


class WorkspaceMessage(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    archived_at: Annotated[
        int | None,
        Field(
            alias="archivedAt",
            description="Unix timestamp (in seconds) when the message was archived.",
        ),
    ] = None
    created_at: Annotated[
        int | None,
        Field(
            alias="createdAt",
            description="Unix timestamp (in seconds) when the message was created.",
        ),
    ] = None
    message_body: Annotated[str, Field(alias="messageBody")]
    message_id: Annotated[str, Field(alias="messageId")]
    message_type: Annotated[WorkspaceMessageType, Field(alias="messageType")]


class AccountRateLimitsUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    rate_limits: Annotated[RateLimitSnapshot, Field(alias="rateLimits")]


class AppInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    app_metadata: Annotated[AppMetadata | None, Field(alias="appMetadata")] = None
    branding: AppBranding | None = None
    description: str | None = None
    distribution_channel: Annotated[str | None, Field(alias="distributionChannel")] = None
    icon_assets: Annotated[dict[str, Any] | None, Field(alias="iconAssets")] = None
    icon_dark_assets: Annotated[dict[str, Any] | None, Field(alias="iconDarkAssets")] = None
    id: str
    install_url: Annotated[str | None, Field(alias="installUrl")] = None
    is_accessible: Annotated[bool | None, Field(alias="isAccessible")] = False
    is_enabled: Annotated[
        bool | None,
        Field(
            alias="isEnabled",
            description="Whether this app is enabled in config.toml. Example: ```toml [apps.bad_app] enabled = false ```",
        ),
    ] = True
    labels: dict[str, Any] | None = None
    logo_url: Annotated[str | None, Field(alias="logoUrl")] = None
    logo_url_dark: Annotated[str | None, Field(alias="logoUrlDark")] = None
    name: str
    plugin_display_names: Annotated[list[str] | None, Field(alias="pluginDisplayNames")] = []


class AppListUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[AppInfo]


class ApplicationRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    network: ApplicationNetworkRequirements | None = None
    storage: ApplicationStorageRequirements | None = None


class AppsListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[AppInfo]
    next_cursor: Annotated[
        str | None,
        Field(
            alias="nextCursor",
            description="Opaque cursor to pass to the next call to continue after the last item. If None, there are no more items to return.",
        ),
    ] = None


class ThreadStartRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/start"], Field(title="Thread/startRequestMethod")]
    params: ThreadStartParams


class ThreadForkRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/fork"], Field(title="Thread/forkRequestMethod")]
    params: ThreadForkParams


class ThreadGoalSetRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/goal/set"], Field(title="Thread/goal/setRequestMethod")]
    params: ThreadGoalSetParams


class ThreadGoalClearRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/goal/clear"], Field(title="Thread/goal/clearRequestMethod")]
    params: ThreadGoalClearParams


class ThreadListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/list"], Field(title="Thread/listRequestMethod")]
    params: ThreadListParams


class ThreadTurnsListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/turns/list"], Field(title="Thread/turns/listRequestMethod")]
    params: ThreadTurnsListParams


class PluginShareUpdateTargetsRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["plugin/share/updateTargets"],
        Field(title="Plugin/share/updateTargetsRequestMethod"),
    ]
    params: PluginShareUpdateTargetsParams


class TurnSteerRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["turn/steer"], Field(title="Turn/steerRequestMethod")]
    params: TurnSteerParams


class ReviewStartRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["review/start"], Field(title="Review/startRequestMethod")]
    params: ReviewStartParams


class McpServerStatusListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["mcpServerStatus/list"], Field(title="McpServerStatus/listRequestMethod")
    ]
    params: ListMcpServerStatusParams


class McpServerResourceReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["mcpServer/resource/read"], Field(title="McpServer/resource/readRequestMethod")
    ]
    params: McpResourceReadParams


class AccountLoginStartRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["account/login/start"], Field(title="Account/login/startRequestMethod")
    ]
    params: LoginAccountParams


class FeedbackSaveRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["feedback/save"], Field(title="Feedback/saveRequestMethod")]
    params: FeedbackSaveParams


class CommandExecRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["command/exec"], Field(title="Command/execRequestMethod")]
    params: CommandExecParams


class CommandExecResizeRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["command/exec/resize"], Field(title="Command/exec/resizeRequestMethod")
    ]
    params: CommandExecResizeParams


class ConfigValueWriteRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["config/value/write"], Field(title="Config/value/writeRequestMethod")]
    params: ConfigValueWriteParams


class ComputerUseConfig(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    default_app_access: AllowDenyRequirement | None = None
    macos: ComputerUseMacosConfig | None = None
    windows: ComputerUseWindowsConfig | None = None


class Config(BaseModel):
    model_config = ConfigDict(
        extra="allow",
        populate_by_name=True,
    )
    analytics: AnalyticsConfig | None = None
    approval_policy: AskForApproval | None = None
    approvals_reviewer: Annotated[
        ApprovalsReviewer | None,
        Field(
            description="[UNSTABLE] Optional default for where approval requests are routed for review."
        ),
    ] = None
    browser_use: BrowserUseConfig | None = None
    compact_prompt: str | None = None
    computer_use: ComputerUseConfig | None = None
    desktop: dict[str, Any] | None = None
    developer_instructions: str | None = None
    forced_chatgpt_workspace_id: ForcedChatgptWorkspaceIds | None = None
    forced_login_method: ForcedLoginMethod | None = None
    instructions: str | None = None
    model: str | None = None
    model_auto_compact_token_limit: int | None = None
    model_auto_compact_token_limit_scope: AutoCompactTokenLimitScope | None = None
    model_context_window: int | None = None
    model_provider: str | None = None
    model_reasoning_effort: ReasoningEffort | None = None
    model_reasoning_summary: ReasoningSummary | None = None
    model_verbosity: Verbosity | None = None
    review_model: str | None = None
    sandbox_mode: SandboxMode | None = None
    sandbox_workspace_write: SandboxWorkspaceWrite | None = None
    service_tier: str | None = None
    tools: ToolsV2 | None = None
    web_search: WebSearchMode | None = None


class ConfigBatchWriteParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    edits: list[ConfigEdit]
    expected_version: Annotated[str | None, Field(alias="expectedVersion")] = None
    file_path: Annotated[
        str | None,
        Field(
            alias="filePath",
            description="Path to the config file to write; defaults to the user's `config.toml` when omitted.",
        ),
    ] = None
    reload_user_config: Annotated[
        bool | None,
        Field(
            alias="reloadUserConfig",
            description="When true, hot-reload updated runtime settings into loaded threads after writing. Session-static model, reasoning-effort, Plan-mode reasoning-effort, and service-tier defaults are not reloaded. The deprecated personality setting is also not reloaded.",
        ),
    ] = None


class ConfigReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    config: Config
    layers: list[ConfigLayer] | None = None
    origins: dict[str, ConfigLayerMetadata]


class ConfigWriteResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    file_path: Annotated[
        AbsolutePathBuf,
        Field(alias="filePath", description="Canonical path to the config file that was written."),
    ]
    overridden_metadata: Annotated[OverriddenMetadata | None, Field(alias="overriddenMetadata")] = (
        None
    )
    status: WriteStatus
    version: str


class ErrorNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    error: TurnError
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]
    will_retry: Annotated[bool, Field(alias="willRetry")]


class ExternalAgentConfigImportCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    import_id: Annotated[str, Field(alias="importId")]
    item_type_results: Annotated[
        list[ExternalAgentConfigImportTypeResult], Field(alias="itemTypeResults")
    ]


class ExternalAgentConfigImportHistory(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    completed_at_ms: Annotated[int, Field(alias="completedAtMs")]
    failures: list[ExternalAgentConfigImportItemTypeFailure]
    import_id: Annotated[str, Field(alias="importId")]
    provider_id: Annotated[str | None, Field(alias="providerId")] = None
    successes: list[ExternalAgentConfigImportItemTypeSuccess]


class ExternalAgentConfigImportHistoryRecordTypeResultParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    failures: list[ExternalAgentConfigImportItemTypeFailure]
    item_type: Annotated[ExternalAgentConfigMigrationItemType, Field(alias="itemType")]
    successes: list[ExternalAgentConfigImportHistoryRecordSuccessParams]


class ExternalAgentConfigImportProgressNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    import_id: Annotated[str, Field(alias="importId")]
    item_type_results: Annotated[
        list[ExternalAgentConfigImportTypeResult], Field(alias="itemTypeResults")
    ]


class ExternalAgentConfigMigrationItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: Annotated[
        str | None,
        Field(
            description="Null or empty means home-scoped migration; non-empty means repo-scoped migration."
        ),
    ] = None
    description: str
    details: MigrationDetails | None = None
    item_type: Annotated[ExternalAgentConfigMigrationItemType, Field(alias="itemType")]


class FileChangePatchUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    changes: list[FileUpdateChange]
    item_id: Annotated[str, Field(alias="itemId")]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class SpecialFileSystemPath(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["special"], Field(title="SpecialFileSystemPathType")]
    value: FileSystemSpecialPath


class FileSystemPath(
    RootModel[PathFileSystemPath | GlobPatternFileSystemPath | SpecialFileSystemPath]
):
    root: PathFileSystemPath | GlobPatternFileSystemPath | SpecialFileSystemPath


class FileSystemSandboxEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    access: FileSystemAccessMode
    path: FileSystemPath


class FunctionCallOutputBody(RootModel[str | list[FunctionCallOutputContentItem]]):
    root: str | list[FunctionCallOutputContentItem]


class GetAccountRateLimitsResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    account_id: Annotated[
        str | None,
        Field(
            alias="accountId",
            description="Account associated with this usage snapshot, when supplied by the backend.",
        ),
    ] = None
    ordinary_usage_allowed: Annotated[
        bool | None,
        Field(
            alias="ordinaryUsageAllowed",
            description="Backend permission for ordinary included usage, validated against the active account. Null means unavailable; clients must not infer recovery from percentages or reset times.",
        ),
    ] = None
    rate_limit_reset_credits: Annotated[
        RateLimitResetCreditsSummary | None, Field(alias="rateLimitResetCredits")
    ] = None
    rate_limit_upsell: Annotated[
        Any | None,
        Field(
            alias="rateLimitUpsell",
            description="Optional backend-owned banner from the same usage read. Its nested keys retain the backend's snake_case contract; an absent banner leaves the client's existing UI unchanged.",
        ),
    ] = None
    rate_limits: Annotated[
        RateLimitSnapshot,
        Field(
            alias="rateLimits",
            description="Backward-compatible single-bucket view; mirrors the historical payload.",
        ),
    ]
    rate_limits_by_limit_id: Annotated[
        dict[str, Any] | None,
        Field(
            alias="rateLimitsByLimitId",
            description="Multi-bucket view keyed by metered `limit_id` (for example, `codex`).",
        ),
    ] = None


class GetAccountTokenUsageResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    daily_usage_buckets: Annotated[
        list[AccountTokenUsageDailyBucket] | None, Field(alias="dailyUsageBuckets")
    ] = None
    summary: AccountTokenUsageSummary
    thread_usage: Annotated[
        ThreadUsage | None,
        Field(
            alias="threadUsage",
            description="Estimated usage when a thread was requested and its billing route is available.",
        ),
    ] = None


class GetWorkspaceMessagesResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    feature_enabled: Annotated[
        bool,
        Field(
            alias="featureEnabled",
            description="Whether the workspace-message backend route is available for this client.",
        ),
    ]
    messages: Annotated[
        list[WorkspaceMessage],
        Field(description="Active workspace messages returned by the backend."),
    ]


class HookCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    run: HookRunSummary
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str | None, Field(alias="turnId")] = None


class ListMcpServerStatusResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[McpServerStatus]
    next_cursor: Annotated[
        str | None,
        Field(
            alias="nextCursor",
            description="Opaque cursor to pass to the next call to continue after the last item. If None, there are no more items to return.",
        ),
    ] = None


class ModelsRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    new_thread: Annotated[NewThreadModelDefaults | None, Field(alias="newThread")] = None


class PluginShareContext(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    can_publish_to_workspace: Annotated[bool | None, Field(alias="canPublishToWorkspace")] = None
    creator_account_user_id: Annotated[str | None, Field(alias="creatorAccountUserId")] = None
    creator_name: Annotated[str | None, Field(alias="creatorName")] = None
    discoverability: PluginShareDiscoverability | None = None
    remote_plugin_id: Annotated[str, Field(alias="remotePluginId")]
    remote_version: Annotated[
        str | None,
        Field(
            alias="remoteVersion",
            description="Version of the remote shared plugin release when available.",
        ),
    ] = None
    share_principals: Annotated[
        list[PluginSharePrincipal] | None, Field(alias="sharePrincipals")
    ] = None
    share_url: Annotated[str | None, Field(alias="shareUrl")] = None


class PluginShareSaveParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    discoverability: PluginShareDiscoverability | None = None
    plugin_path: Annotated[AbsolutePathBuf, Field(alias="pluginPath")]
    remote_plugin_id: Annotated[str | None, Field(alias="remotePluginId")] = None
    share_targets: Annotated[list[PluginShareTarget] | None, Field(alias="shareTargets")] = None


class PluginSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    auth_policy: Annotated[PluginAuthPolicy, Field(alias="authPolicy")]
    availability: Annotated[
        PluginAvailability | None,
        Field(description="Availability state for installing and using the plugin."),
    ] = "AVAILABLE"
    disabled_reason: Annotated[
        PluginDisabledReason | None,
        Field(
            alias="disabledReason",
            description="Why the remote plugin is unavailable, when provided by plugin-service.",
        ),
    ] = None
    eligible_plan_types: Annotated[
        list[str] | None,
        Field(
            alias="eligiblePlanTypes",
            description="Raw plugin-service plan identifiers eligible to install the plugin.",
        ),
    ] = None
    enabled: bool
    id: str
    install_policy: Annotated[PluginInstallPolicy, Field(alias="installPolicy")]
    install_policy_source: Annotated[
        PluginInstallPolicySource | None, Field(alias="installPolicySource")
    ] = None
    installed: bool
    installed_at: Annotated[
        int | None,
        Field(
            alias="installedAt",
            description="Unix timestamp in seconds when the remote plugin was installed, when available.",
        ),
    ] = None
    interface: PluginInterface | None = None
    keywords: list[str] | None = []
    local_version: Annotated[
        str | None,
        Field(
            alias="localVersion",
            description="Version of the locally materialized plugin package when available.",
        ),
    ] = None
    must_show_installation_interstitial: Annotated[
        bool | None, Field(alias="mustShowInstallationInterstitial")
    ] = None
    name: str
    remote_plugin_id: Annotated[
        str | None,
        Field(
            alias="remotePluginId", description="Backend remote plugin identifier when available."
        ),
    ] = None
    share_context: Annotated[
        PluginShareContext | None,
        Field(
            alias="shareContext",
            description="Remote sharing context associated with this plugin when available.",
        ),
    ] = None
    source: PluginSource
    version: Annotated[
        str | None,
        Field(description="Version advertised by the remote marketplace backend when available."),
    ] = None


class FunctionCallOutputResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    call_id: str | None = None
    id: str | None = None
    internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
    name: str | None = None
    namespace: str | None = None
    output: FunctionCallOutputBody
    type: Annotated[
        Literal["function_call_output"], Field(title="FunctionCallOutputResponseItemType")
    ]


class CustomToolCallOutputResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    call_id: str
    id: str | None = None
    internal_chat_message_metadata_passthrough: InternalChatMessageMetadataPassthrough | None = None
    name: str | None = None
    output: FunctionCallOutputBody
    type: Annotated[
        Literal["custom_tool_call_output"], Field(title="CustomToolCallOutputResponseItemType")
    ]


class ResponseItem(
    RootModel[
        AdditionalToolsResponseItem
        | MessageResponseItem
        | AgentMessageResponseItem
        | ReasoningResponseItem
        | LocalShellCallResponseItem
        | FunctionCallResponseItem
        | ToolSearchCallResponseItem
        | FunctionCallOutputResponseItem
        | CustomToolCallResponseItem
        | CustomToolCallOutputResponseItem
        | ToolSearchOutputResponseItem
        | WebSearchCallResponseItem
        | ImageGenerationCallResponseItem
        | CompactionResponseItem
        | ConfigurationUpdateResponseItem
        | CompactionTriggerResponseItem
        | ContextCompactionResponseItem
        | OtherResponseItem
    ]
):
    root: (
        AdditionalToolsResponseItem
        | MessageResponseItem
        | AgentMessageResponseItem
        | ReasoningResponseItem
        | LocalShellCallResponseItem
        | FunctionCallResponseItem
        | ToolSearchCallResponseItem
        | FunctionCallOutputResponseItem
        | CustomToolCallResponseItem
        | CustomToolCallOutputResponseItem
        | ToolSearchOutputResponseItem
        | WebSearchCallResponseItem
        | ImageGenerationCallResponseItem
        | CompactionResponseItem
        | ConfigurationUpdateResponseItem
        | CompactionTriggerResponseItem
        | ContextCompactionResponseItem
        | OtherResponseItem
    )


class ErrorServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["error"], Field(title="ErrorNotificationMethod")]
    params: ErrorNotification


class ThreadReadStateChangedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/readState/changed"],
        Field(title="Thread/readState/changedNotificationMethod"),
    ]
    params: ThreadReadStateChangedNotification


class ThreadGoalUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/goal/updated"], Field(title="Thread/goal/updatedNotificationMethod")
    ]
    params: ThreadGoalUpdatedNotification


class ThreadSettingsUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/settings/updated"], Field(title="Thread/settings/updatedNotificationMethod")
    ]
    params: ThreadSettingsUpdatedNotification


class ThreadTokenUsageUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/tokenUsage/updated"],
        Field(title="Thread/tokenUsage/updatedNotificationMethod"),
    ]
    params: ThreadTokenUsageUpdatedNotification


class HookCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["hook/completed"], Field(title="Hook/completedNotificationMethod")]
    params: HookCompletedNotification


class TurnPlanUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["turn/plan/updated"], Field(title="Turn/plan/updatedNotificationMethod")
    ]
    params: TurnPlanUpdatedNotification


class ItemFileChangePatchUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["item/fileChange/patchUpdated"],
        Field(title="Item/fileChange/patchUpdatedNotificationMethod"),
    ]
    params: FileChangePatchUpdatedNotification


class AccountRateLimitsUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["account/rateLimits/updated"],
        Field(title="Account/rateLimits/updatedNotificationMethod"),
    ]
    params: AccountRateLimitsUpdatedNotification


class AppListUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["app/list/updated"], Field(title="App/list/updatedNotificationMethod")
    ]
    params: AppListUpdatedNotification


class ExternalAgentConfigImportProgressServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["externalAgentConfig/import/progress"],
        Field(title="ExternalAgentConfig/import/progressNotificationMethod"),
    ]
    params: ExternalAgentConfigImportProgressNotification


class ExternalAgentConfigImportCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["externalAgentConfig/import/completed"],
        Field(title="ExternalAgentConfig/import/completedNotificationMethod"),
    ]
    params: ExternalAgentConfigImportCompletedNotification


class ThreadRealtimeItemStartedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/realtime/item/started"],
        Field(title="Thread/realtime/item/startedNotificationMethod"),
    ]
    params: ThreadRealtimeItemStartedNotification


class ThreadRealtimeItemCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["thread/realtime/item/completed"],
        Field(title="Thread/realtime/item/completedNotificationMethod"),
    ]
    params: ThreadRealtimeItemCompletedNotification


class WindowsSandboxSetupCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["windowsSandbox/setupCompleted"],
        Field(title="WindowsSandbox/setupCompletedNotificationMethod"),
    ]
    params: WindowsSandboxSetupCompletedNotification


class SubAgentSessionSource(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    sub_agent: Annotated[SubAgentSource, Field(alias="subAgent")]


class SessionSource(RootModel[SessionSourceValue | CustomSessionSource | SubAgentSessionSource]):
    root: SessionSourceValue | CustomSessionSource | SubAgentSessionSource


class FunctionCallOutputThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    name: str
    namespace: str | None = None
    output: FunctionCallOutputBody
    type: Annotated[Literal["functionCallOutput"], Field(title="FunctionCallOutputThreadItemType")]


class ThreadItem(
    RootModel[
        UserMessageThreadItem
        | HookPromptThreadItem
        | AgentMessageThreadItem
        | FunctionCallOutputThreadItem
        | PlanThreadItem
        | ReasoningThreadItem
        | CommandExecutionThreadItem
        | FileChangeThreadItem
        | McpToolCallThreadItem
        | DynamicToolCallThreadItem
        | CollabAgentToolCallThreadItem
        | SubAgentActivityThreadItem
        | WebSearchThreadItem
        | ImageViewThreadItem
        | SleepThreadItem
        | FileIdThreadItem
        | ResultThreadItem
        | EnteredReviewModeThreadItem
        | ExitedReviewModeThreadItem
        | ContextCompactionThreadItem
    ]
):
    root: (
        UserMessageThreadItem
        | HookPromptThreadItem
        | AgentMessageThreadItem
        | FunctionCallOutputThreadItem
        | PlanThreadItem
        | ReasoningThreadItem
        | CommandExecutionThreadItem
        | FileChangeThreadItem
        | McpToolCallThreadItem
        | DynamicToolCallThreadItem
        | CollabAgentToolCallThreadItem
        | SubAgentActivityThreadItem
        | WebSearchThreadItem
        | ImageViewThreadItem
        | SleepThreadItem
        | FileIdThreadItem
        | ResultThreadItem
        | EnteredReviewModeThreadItem
        | ExitedReviewModeThreadItem
        | ContextCompactionThreadItem
    )


class ThreadItemEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    completed_at_ms: Annotated[
        int | None,
        Field(
            alias="completedAtMs",
            description="Unix timestamp (milliseconds) when the item completed, if recorded by the producer.",
        ),
    ] = None
    item: ThreadItem
    started_at_ms: Annotated[
        int | None,
        Field(
            alias="startedAtMs",
            description="Unix timestamp (milliseconds) when the item started, if recorded by the producer.",
        ),
    ] = None
    turn_id: Annotated[str, Field(alias="turnId", description="Turn containing this item.")]


class ThreadItemsListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    backwards_cursor: Annotated[
        str | None,
        Field(
            alias="backwardsCursor",
            description="Opaque cursor to pass as `cursor` when reversing `sortDirection`. This is only populated when the page contains at least one item.",
        ),
    ] = None
    data: list[ThreadItemEntry]
    next_cursor: Annotated[
        str | None,
        Field(
            alias="nextCursor",
            description="Opaque cursor to pass to the next call to continue after the last item. if None, there are no more items to return.",
        ),
    ] = None


class ItemThreadTimelineEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item: ThreadItem
    position: Annotated[int, Field(ge=0)]
    turn_id: Annotated[str, Field(alias="turnId")]
    type: Annotated[Literal["item"], Field(title="ItemThreadTimelineEntryType")]


class TurnCompletedThreadTimelineEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    completed_at: int | None = None
    duration_ms: int | None = None
    error: TurnError | None = None
    position: Annotated[int, Field(ge=0)]
    started_at: int | None = None
    status: TurnStatus
    turn_id: str
    type: Annotated[Literal["turnCompleted"], Field(title="TurnCompletedThreadTimelineEntryType")]


class ThreadTimelineEntry(
    RootModel[
        ItemThreadTimelineEntry
        | RealtimeThreadTimelineEntry
        | TurnStartedThreadTimelineEntry
        | TurnCompletedThreadTimelineEntry
    ]
):
    root: Annotated[
        ItemThreadTimelineEntry
        | RealtimeThreadTimelineEntry
        | TurnStartedThreadTimelineEntry
        | TurnCompletedThreadTimelineEntry,
        Field(description="EXPERIMENTAL - one item or turn boundary in canonical rollout order."),
    ]


class Turn(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    completed_at: Annotated[
        int | None,
        Field(
            alias="completedAt", description="Unix timestamp (in seconds) when the turn completed."
        ),
    ] = None
    duration_ms: Annotated[
        int | None,
        Field(
            alias="durationMs",
            description="Duration between turn start and completion in milliseconds, if known.",
        ),
    ] = None
    error: Annotated[
        TurnError | None, Field(description="Error associated with a failed or interrupted turn.")
    ] = None
    id: Annotated[
        str, Field(description="Identifier for this turn. Codex-generated turn IDs are UUIDv7.")
    ]
    items: Annotated[
        list[ThreadItem], Field(description="Thread items currently included in this turn payload.")
    ]
    items_view: Annotated[
        TurnItemsView | None,
        Field(
            alias="itemsView",
            description="Describes how much of `items` has been loaded for this turn.",
        ),
    ] = "full"
    root_turn_id: Annotated[
        str | None,
        Field(
            alias="rootTurnId",
            description="ID of the first turn in the chain of work that led to this turn. Pass this as `rootTurnId` when starting work on behalf of this turn. May be null in older history or a `review/start` response.",
        ),
    ] = None
    started_at: Annotated[
        int | None,
        Field(alias="startedAt", description="Unix timestamp (in seconds) when the turn started."),
    ] = None
    status: TurnStatus


class TurnCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]
    turn: Turn


class TurnStartResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    turn: Turn


class TurnStartedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]
    turn: Turn


class TurnToolOutput(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str
    namespace: str | None = None
    output: FunctionCallOutputBody
    retain: Annotated[
        bool | None,
        Field(description="Requests retention of this output in the thread's model history."),
    ] = None


class TurnsPage(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    backwards_cursor: Annotated[str | None, Field(alias="backwardsCursor")] = None
    data: list[Turn]
    next_cursor: Annotated[str | None, Field(alias="nextCursor")] = None


class AdditionalFileSystemPermissions(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    entries: list[FileSystemSandboxEntry] | None = None
    glob_scan_max_depth: Annotated[int | None, Field(alias="globScanMaxDepth", ge=1)] = None
    read: Annotated[
        list[LegacyAppPathString] | None,
        Field(description="This will be removed in favor of `entries`."),
    ] = None
    write: Annotated[
        list[LegacyAppPathString] | None,
        Field(description="This will be removed in favor of `entries`."),
    ] = None


class PluginShareSaveRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/share/save"], Field(title="Plugin/share/saveRequestMethod")]
    params: PluginShareSaveParams


class ConfigBatchWriteRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["config/batchWrite"], Field(title="Config/batchWriteRequestMethod")]
    params: ConfigBatchWriteParams


class ConfigRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    additional_developer_instructions: Annotated[
        str | None, Field(alias="additionalDeveloperInstructions")
    ] = None
    allow_appshots: Annotated[bool | None, Field(alias="allowAppshots")] = None
    allow_browser_and_computer_use: Annotated[
        bool | None, Field(alias="allowBrowserAndComputerUse")
    ] = None
    allow_login_shell: Annotated[bool | None, Field(alias="allowLoginShell")] = None
    allow_managed_hooks_only: Annotated[bool | None, Field(alias="allowManagedHooksOnly")] = None
    allow_remote_control: Annotated[bool | None, Field(alias="allowRemoteControl")] = None
    allowed_approval_policies: Annotated[
        list[AskForApproval] | None, Field(alias="allowedApprovalPolicies")
    ] = None
    allowed_login_methods: Annotated[
        list[ForcedLoginMethod] | None,
        Field(
            alias="allowedLoginMethods",
            description="Effective login methods after managed, forced-login, and workspace restrictions. An empty list permits no login method. Older servers may omit this field.",
        ),
    ] = None
    allowed_permission_profiles: Annotated[
        dict[str, Any] | None, Field(alias="allowedPermissionProfiles")
    ] = None
    allowed_sandbox_modes: Annotated[
        list[SandboxMode] | None, Field(alias="allowedSandboxModes")
    ] = None
    allowed_web_search_modes: Annotated[
        list[WebSearchMode] | None, Field(alias="allowedWebSearchModes")
    ] = None
    allowed_windows_sandbox_implementations: Annotated[
        list[WindowsSandboxImplementation] | None,
        Field(alias="allowedWindowsSandboxImplementations"),
    ] = None
    auto_review: Annotated[AutoReviewRequirements | None, Field(alias="autoReview")] = None
    browser_use: Annotated[BrowserUseRequirements | None, Field(alias="browserUse")] = None
    chatgpt_base_url: Annotated[str | None, Field(alias="chatgptBaseUrl")] = None
    check_for_update_on_startup: Annotated[bool | None, Field(alias="checkForUpdateOnStartup")] = (
        None
    )
    cli_auth_credentials_store: Annotated[
        CliAuthCredentialsStoreMode | None, Field(alias="cliAuthCredentialsStore")
    ] = None
    computer_use: Annotated[ComputerUseRequirements | None, Field(alias="computerUse")] = None
    default_permissions: Annotated[str | None, Field(alias="defaultPermissions")] = None
    enforce_residency: Annotated[ResidencyRequirement | None, Field(alias="enforceResidency")] = (
        None
    )
    feature_requirements: Annotated[dict[str, Any] | None, Field(alias="featureRequirements")] = (
        None
    )
    feedback: FeedbackRequirements | None = None
    in_app_browser: Annotated[InAppBrowserRequirements | None, Field(alias="inAppBrowser")] = None
    log_dir: Annotated[str | None, Field(alias="logDir")] = None
    model_catalog_json: Annotated[str | None, Field(alias="modelCatalogJson")] = None
    model_provider: Annotated[
        str | None,
        Field(
            alias="modelProvider",
            description="Exact provider selection required by managed policy.",
        ),
    ] = None
    model_providers: Annotated[
        dict[str, Any] | None,
        Field(
            alias="modelProviders",
            description="Complete required provider definitions, using config.toml field names.",
        ),
    ] = None
    models: ModelsRequirements | None = None
    sqlite_home: Annotated[str | None, Field(alias="sqliteHome")] = None


class ConfigRequirementsReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    requirements: Annotated[
        ConfigRequirements | None,
        Field(
            description="Null if no requirements are configured (e.g. no requirements.toml/MDM entries)."
        ),
    ] = None
    supports_independent_speed_modes: Annotated[
        bool | None,
        Field(
            alias="supportsIndependentSpeedModes",
            description="Whether Fast and Ultra Fast requirements are enforced independently. Older servers omit this field and use Fast mode as a shared speed gate.",
        ),
    ] = None


class ExternalAgentConfigDetectResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    connectors: Annotated[
        list[ExternalAgentDetectedConnectorCandidate] | None, Field(validate_default=True)
    ] = []
    items: list[ExternalAgentConfigMigrationItem]


class ExternalAgentConfigImportHistoriesReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    connectors: list[ExternalAgentImportedConnectorCandidate]
    data: list[ExternalAgentConfigImportHistory]


class ExternalAgentConfigImportHistoryRecordParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item_type_results: Annotated[
        list[ExternalAgentConfigImportHistoryRecordTypeResultParams],
        Field(
            alias="itemTypeResults", description="Completed results grouped by imported item type."
        ),
    ]
    provider_id: Annotated[
        str,
        Field(
            alias="providerId",
            description="Opaque provider identifier for the externally completed import.",
        ),
    ]


class ExternalAgentConfigImportParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    migration_items: Annotated[
        list[ExternalAgentConfigMigrationItem], Field(alias="migrationItems")
    ]
    migration_source: Annotated[
        str | None,
        Field(
            alias="migrationSource",
            description="Migration-source selector used to produce the migration items. Pass the same value to detection and import; missing or unrecognized values use the default source.",
        ),
    ] = None
    provider_id: Annotated[
        str | None,
        Field(
            alias="providerId",
            description="Opaque provider identifier supplied by the caller for analytics attribution and import history display. This does not select the migration source.",
        ),
    ] = None
    source: Annotated[
        str | None,
        Field(description="Optional identifier for the product that initiated the import."),
    ] = None


class ItemCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    completed_at_ms: Annotated[
        int,
        Field(
            alias="completedAtMs",
            description="Unix timestamp (in milliseconds) when this item lifecycle completed.",
        ),
    ]
    item: ThreadItem
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class ItemStartedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item: ThreadItem
    started_at_ms: Annotated[
        int,
        Field(
            alias="startedAtMs",
            description="Unix timestamp (in milliseconds) when this item lifecycle started.",
        ),
    ]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class PluginDetail(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    app_templates: Annotated[list[AppTemplateSummary], Field(alias="appTemplates")]
    apps: list[AppSummary]
    description: str | None = None
    hooks: list[PluginHookSummary]
    marketplace_name: Annotated[str, Field(alias="marketplaceName")]
    marketplace_path: Annotated[AbsolutePathBuf | None, Field(alias="marketplacePath")] = None
    mcp_servers: Annotated[list[str], Field(alias="mcpServers")]
    onboarding_skill: Annotated[
        SkillSummary | None,
        Field(
            alias="onboardingSkill",
            description="The declared onboarding skill, when the plugin and visible skill are enabled.",
        ),
    ] = None
    scheduled_tasks: Annotated[list[ScheduledTaskSummary] | None, Field(alias="scheduledTasks")] = (
        None
    )
    share_url: Annotated[str | None, Field(alias="shareUrl")] = None
    skills: list[SkillSummary]
    summary: PluginSummary


class PluginMarketplaceEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    interface: MarketplaceInterface | None = None
    name: str
    path: Annotated[
        AbsolutePathBuf | None,
        Field(
            description="Local marketplace file path when the marketplace is backed by a local file. Remote-only catalog marketplaces do not have a local path."
        ),
    ] = None
    plugins: list[PluginSummary]


class PluginReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    plugin: PluginDetail


class PluginSearchResult(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_name: Annotated[str, Field(alias="marketplaceName")]
    marketplace_path: Annotated[AbsolutePathBuf | None, Field(alias="marketplacePath")] = None
    plugin: PluginSummary


class PluginShareListItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    local_plugin_path: Annotated[AbsolutePathBuf | None, Field(alias="localPluginPath")] = None
    plugin: PluginSummary


class PluginShareListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[PluginShareListItem]


class RawResponseItemCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item: ResponseItem
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class RequestPermissionProfile(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    file_system: Annotated[AdditionalFileSystemPermissions | None, Field(alias="fileSystem")] = None
    network: AdditionalNetworkPermissions | None = None


class ReviewStartResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    review_thread_id: Annotated[
        str,
        Field(
            alias="reviewThreadId",
            description="Identifies the thread where the review runs.\n\nFor inline reviews, this is the original thread id. For detached reviews, this is the id of the new review thread.",
        ),
    ]
    turn: Turn


class TurnStartedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["turn/started"], Field(title="Turn/startedNotificationMethod")]
    params: TurnStartedNotification


class TurnCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["turn/completed"], Field(title="Turn/completedNotificationMethod")]
    params: TurnCompletedNotification


class ItemStartedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["item/started"], Field(title="Item/startedNotificationMethod")]
    params: ItemStartedNotification


class ItemCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["item/completed"], Field(title="Item/completedNotificationMethod")]
    params: ItemCompletedNotification


class Thread(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    agent_nickname: Annotated[
        str | None,
        Field(
            alias="agentNickname",
            description="Optional random unique nickname assigned to an AgentControl-spawned sub-agent.",
        ),
    ] = None
    agent_role: Annotated[
        str | None,
        Field(
            alias="agentRole",
            description="Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
        ),
    ] = None
    cli_version: Annotated[
        str, Field(alias="cliVersion", description="Version of the CLI that created the thread.")
    ]
    created_at: Annotated[
        int,
        Field(
            alias="createdAt",
            description="Unix timestamp (in seconds) when the thread was created.",
        ),
    ]
    cwd: Annotated[AbsolutePathBuf, Field(description="Working directory captured for the thread.")]
    ephemeral: Annotated[
        bool,
        Field(
            description="Whether the thread is ephemeral and should not be materialized on disk."
        ),
    ]
    forked_from_id: Annotated[
        str | None,
        Field(
            alias="forkedFromId",
            description="Source thread id when this thread was created by forking another thread.",
        ),
    ] = None
    git_info: Annotated[
        GitInfo | None,
        Field(
            alias="gitInfo",
            description="Optional Git metadata captured when the thread was created.",
        ),
    ] = None
    history_mode: Annotated[
        ThreadHistoryMode | None,
        Field(
            alias="historyMode",
            description="Persisted thread history contract selected when this thread was created.",
        ),
    ] = "legacy"
    id: Annotated[
        str, Field(description="Identifier for this thread. Codex-generated thread IDs are UUIDv7.")
    ]
    model: Annotated[
        str | None,
        Field(
            description="Current configured model when loaded, otherwise the latest persisted model. Null when unavailable. This is not per-turn execution telemetry."
        ),
    ] = None
    model_provider: Annotated[
        str,
        Field(
            alias="modelProvider",
            description="Model provider used for this thread (for example, 'openai').",
        ),
    ]
    name: Annotated[str | None, Field(description="Optional user-facing thread title.")] = None
    originator: Annotated[
        str | None,
        Field(
            description="Originator recorded when the thread was created, independent of its current client or executor. Null when the recorded originator is unavailable."
        ),
    ] = None
    parent_thread_id: Annotated[
        str | None,
        Field(
            alias="parentThreadId",
            description="The ID of the parent thread. This will only be set if this thread is a subagent.",
        ),
    ] = None
    path: Annotated[str | None, Field(description="[UNSTABLE] Path to the thread on disk.")] = None
    preview: Annotated[
        str, Field(description="Usually the first user message in the thread, if available.")
    ]
    project_id: Annotated[
        str | None,
        Field(
            alias="projectId",
            description="Canonical project assignment owned by app-server, if any.",
        ),
    ] = None
    reasoning_effort: Annotated[
        ReasoningEffort | None,
        Field(
            alias="reasoningEffort",
            description="Current configured reasoning effort when loaded, otherwise the latest persisted effort. Null when unset or unavailable. This is not per-turn execution telemetry.",
        ),
    ] = None
    recency_at: Annotated[
        int | None,
        Field(
            alias="recencyAt",
            description="Unix timestamp (in seconds) used for thread recency ordering.",
        ),
    ] = None
    section: Annotated[
        ThreadSection | None,
        Field(description="The independently persisted section selected for this thread, if any."),
    ] = None
    section_entered_at: Annotated[
        int | None,
        Field(
            alias="sectionEnteredAt",
            description="Unix timestamp in seconds when the thread entered its current section.",
        ),
    ] = None
    session_id: Annotated[
        str,
        Field(
            alias="sessionId",
            description="Session id shared by threads that belong to the same session tree.",
        ),
    ]
    source: Annotated[
        SessionSource,
        Field(
            description="Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.)."
        ),
    ]
    status: Annotated[ThreadStatus, Field(description="Current runtime status for the thread.")]
    thread_source: Annotated[
        ThreadSource | None,
        Field(
            alias="threadSource",
            description="Optional analytics source classification for this thread.",
        ),
    ] = None
    turns: Annotated[
        list[Turn],
        Field(
            description="Only populated on `thread/resume`, `thread/fork`, and `thread/read` (when `includeTurns` is true) responses. For all other responses and notifications returning a Thread, the turns field will be an empty list."
        ),
    ]
    updated_at: Annotated[
        int,
        Field(
            alias="updatedAt",
            description="Unix timestamp (in seconds) when the thread was last updated.",
        ),
    ]


class ThreadForkResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approval_policy: Annotated[AskForApproval, Field(alias="approvalPolicy")]
    approvals_reviewer: Annotated[
        ApprovalsReviewer,
        Field(
            alias="approvalsReviewer",
            description="Reviewer currently used for approval requests on this thread.",
        ),
    ]
    cwd: AbsolutePathBuf
    disabled_plugin_ids: Annotated[
        list[str] | None,
        Field(
            alias="disabledPluginIds",
            description="Saved list of disabled plugin IDs. Does not yet filter plugin capabilities.",
        ),
    ] = []
    instruction_sources: Annotated[
        list[LegacyAppPathString] | None,
        Field(
            alias="instructionSources",
            description="Environment-native paths to instruction source files currently loaded for this thread.",
            validate_default=True,
        ),
    ] = []
    model: str
    model_provider: Annotated[str, Field(alias="modelProvider")]
    reasoning_effort: Annotated[ReasoningEffort | None, Field(alias="reasoningEffort")] = None
    sandbox: Annotated[
        SandboxPolicy,
        Field(
            description="Legacy sandbox policy retained for compatibility. Experimental clients should prefer `activePermissionProfile` for profile provenance."
        ),
    ]
    service_tier: Annotated[str | None, Field(alias="serviceTier")] = None
    thread: Thread


class ThreadListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    backwards_cursor: Annotated[
        str | None,
        Field(
            alias="backwardsCursor",
            description="Opaque cursor to pass as `cursor` when reversing `sortDirection`. This is only populated when the page contains at least one thread. Use it with the opposite `sortDirection`; for timestamp sorts it anchors at the start of the page timestamp so same-second updates are not skipped.",
        ),
    ] = None
    data: list[Thread]
    next_cursor: Annotated[
        str | None,
        Field(
            alias="nextCursor",
            description="Opaque cursor to pass to the next call to continue after the last item. if None, there are no more items to return.",
        ),
    ] = None


class ThreadMetadataUpdateResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread: Thread


class ThreadReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread: Thread


class ThreadResumeResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approval_policy: Annotated[AskForApproval, Field(alias="approvalPolicy")]
    approvals_reviewer: Annotated[
        ApprovalsReviewer,
        Field(
            alias="approvalsReviewer",
            description="Reviewer currently used for approval requests on this thread.",
        ),
    ]
    collaboration_mode: Annotated[
        CollaborationMode | None,
        Field(
            alias="collaborationMode",
            description="Effective collaboration mode. Absent when resuming from an older server.",
        ),
    ] = None
    cwd: AbsolutePathBuf
    disabled_plugin_ids: Annotated[
        list[str] | None,
        Field(
            alias="disabledPluginIds",
            description="Saved list of disabled plugin IDs. Does not yet filter plugin capabilities.",
        ),
    ] = []
    instruction_sources: Annotated[
        list[LegacyAppPathString] | None,
        Field(
            alias="instructionSources",
            description="Environment-native paths to instruction source files currently loaded for this thread.",
            validate_default=True,
        ),
    ] = []
    items_backwards_cursor: Annotated[
        str | None,
        Field(
            alias="itemsBackwardsCursor",
            description='Opaque cursor for hydrating paginated items backwards.\n\nPass this as `cursor` to `thread/items/list` with `sortDirection: "desc"`. The first page includes the item identified by the cursor.',
        ),
    ] = None
    model: str
    model_provider: Annotated[str, Field(alias="modelProvider")]
    reasoning_effort: Annotated[ReasoningEffort | None, Field(alias="reasoningEffort")] = None
    sandbox: Annotated[
        SandboxPolicy,
        Field(
            description="Legacy sandbox policy retained for compatibility. Experimental clients should prefer `activePermissionProfile` for profile provenance."
        ),
    ]
    service_tier: Annotated[str | None, Field(alias="serviceTier")] = None
    thread: Thread
    turns_backwards_cursor: Annotated[
        str | None,
        Field(
            alias="turnsBackwardsCursor",
            description='Opaque cursor for hydrating paginated turns backwards.\n\nPass this as `cursor` to `thread/turns/list` with `sortDirection: "desc"`. The first page includes the turn identified by the cursor.',
        ),
    ] = None


class ThreadRevertResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    items_backwards_cursor: Annotated[
        str | None,
        Field(
            alias="itemsBackwardsCursor",
            description='Opaque cursor for hydrating paginated items backwards.\n\nPass this as `cursor` to `thread/items/list` with `sortDirection: "desc"`. The first page includes the item identified by the cursor.',
        ),
    ] = None
    thread: Annotated[
        Thread,
        Field(
            description="Updated loaded thread metadata. `turns` is always empty; hydrate retained history through `thread/turns/list`."
        ),
    ]
    turns_backwards_cursor: Annotated[
        str | None,
        Field(
            alias="turnsBackwardsCursor",
            description='Opaque cursor for hydrating paginated turns backwards.\n\nPass this as `cursor` to `thread/turns/list` with `sortDirection: "desc"`. The first page includes the turn identified by the cursor.',
        ),
    ] = None


class ThreadSearchResult(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    snippet: str
    thread: Thread


class ThreadStartResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approval_policy: Annotated[AskForApproval, Field(alias="approvalPolicy")]
    approvals_reviewer: Annotated[
        ApprovalsReviewer,
        Field(
            alias="approvalsReviewer",
            description="Reviewer currently used for approval requests on this thread.",
        ),
    ]
    cwd: AbsolutePathBuf
    disabled_plugin_ids: Annotated[
        list[str] | None,
        Field(
            alias="disabledPluginIds",
            description="Saved list of disabled plugin IDs. Does not yet filter plugin capabilities.",
        ),
    ] = []
    instruction_sources: Annotated[
        list[LegacyAppPathString] | None,
        Field(
            alias="instructionSources",
            description="Environment-native paths to instruction source files currently loaded for this thread.",
            validate_default=True,
        ),
    ] = []
    model: str
    model_provider: Annotated[str, Field(alias="modelProvider")]
    reasoning_effort: Annotated[ReasoningEffort | None, Field(alias="reasoningEffort")] = None
    sandbox: Annotated[
        SandboxPolicy,
        Field(
            description="Legacy sandbox policy retained for compatibility. Experimental clients should prefer `activePermissionProfile` for profile provenance."
        ),
    ]
    service_tier: Annotated[str | None, Field(alias="serviceTier")] = None
    thread: Thread


class ThreadStartedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread: Thread


class ThreadTurnsListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    backwards_cursor: Annotated[
        str | None,
        Field(
            alias="backwardsCursor",
            description="Opaque cursor to pass as `cursor` when reversing `sortDirection`. This is only populated when the page contains at least one turn. Use it with the opposite `sortDirection` to include the anchor turn again and catch updates to that turn.",
        ),
    ] = None
    data: list[Turn]
    next_cursor: Annotated[
        str | None,
        Field(
            alias="nextCursor",
            description="Opaque cursor to pass to the next call to continue after the last turn. if None, there are no more turns to return.",
        ),
    ] = None


class ThreadUnarchiveResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread: Thread


class TurnStartParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approval_policy: Annotated[
        AskForApproval | None,
        Field(
            alias="approvalPolicy",
            description="Override the approval policy for this turn and subsequent turns.",
        ),
    ] = None
    approvals_reviewer: Annotated[
        ApprovalsReviewer | None,
        Field(
            alias="approvalsReviewer",
            description="Override where approval requests are routed for review on this turn and subsequent turns.",
        ),
    ] = None
    client_user_message_id: Annotated[str | None, Field(alias="clientUserMessageId")] = None
    cwd: Annotated[
        str | None,
        Field(description="Override the working directory for this turn and subsequent turns."),
    ] = None
    disabled_plugin_ids: Annotated[
        list[str] | None,
        Field(
            alias="disabledPluginIds",
            description="Replace this thread's disabled plugin IDs. Omitted/null preserves the list; [] clears it.",
        ),
    ] = None
    effort: Annotated[
        ReasoningEffort | None,
        Field(description="Override the reasoning effort for this turn and subsequent turns."),
    ] = None
    input: list[UserInput]
    model: Annotated[
        str | None, Field(description="Override the model for this turn and subsequent turns.")
    ] = None
    output_schema: Annotated[
        Any | None,
        Field(
            alias="outputSchema",
            description="Optional JSON Schema used to constrain the final assistant message for this turn.",
        ),
    ] = None
    parent_turn_id: Annotated[
        str | None,
        Field(
            alias="parentTurnId",
            description="ID of the turn that caused this new turn to start.\n\nSet this when starting work on behalf of another turn, such as delegated work in a different thread. Leave unset for work started directly by the user. Ignored when this request adds input to an active turn.",
        ),
    ] = None
    personality: Annotated[
        Personality | None,
        Field(
            description="@deprecated `friendly` and `pragmatic` no longer select a style. Changing this does not rewrite the thread's existing instructions."
        ),
    ] = None
    root_turn_id: Annotated[
        str | None,
        Field(
            alias="rootTurnId",
            description="ID of the first turn in the chain of work that led to this new turn.\n\nWhen setting `parentTurnId`, set this to the parent turn's `rootTurnId` when known. This keeps descendant work attributed to the original turn. If omitted, the new turn becomes its own root. Ignored when this request adds input to an active turn.",
        ),
    ] = None
    sandbox_policy: Annotated[
        SandboxPolicy | None,
        Field(
            alias="sandboxPolicy",
            description="Override the sandbox policy for this turn and subsequent turns.",
        ),
    ] = None
    service_tier: Annotated[
        str | None,
        Field(
            alias="serviceTier",
            description="Override the service tier for this turn and subsequent turns.",
        ),
    ] = None
    service_tier_for_turn: Annotated[
        str | None,
        Field(
            alias="serviceTierForTurn",
            description="Override the service tier only when this request starts a new turn. Use \"default\" for standard speed. Omitted or null inherits the thread's tier. Does not change the thread's tier or a turn being steered.",
        ),
    ] = None
    summary: Annotated[
        ReasoningSummary | None,
        Field(description="Override the reasoning summary for this turn and subsequent turns."),
    ] = None
    thread_id: Annotated[str, Field(alias="threadId")]
    tool_output: Annotated[TurnToolOutput | None, Field(alias="toolOutput")] = None
    turn_trigger: Annotated[
        str | None,
        Field(
            alias="turnTrigger",
            description="Optional source classification for the caller that starts this turn. Ignored when this request steers an already-active turn.",
        ),
    ] = None


class TurnStartRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["turn/start"], Field(title="Turn/startRequestMethod")]
    params: TurnStartParams


class ExternalAgentConfigImportRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["externalAgentConfig/import"],
        Field(title="ExternalAgentConfig/importRequestMethod"),
    ]
    params: ExternalAgentConfigImportParams


class ExternalAgentConfigImportRecordHistoryRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["externalAgentConfig/import/recordHistory"],
        Field(title="ExternalAgentConfig/import/recordHistoryRequestMethod"),
    ]
    params: ExternalAgentConfigImportHistoryRecordParams


class ClientRequest(
    RootModel[
        InitializeRequest
        | ThreadStartRequest
        | ThreadResumeRequest
        | ThreadForkRequest
        | ThreadArchiveRequest
        | ThreadDeleteRequest
        | ThreadUnsubscribeRequest
        | ThreadNameSetRequest
        | ThreadGoalSetRequest
        | ThreadGoalGetRequest
        | ThreadGoalClearRequest
        | ThreadMetadataUpdateRequest
        | ThreadAttachmentAddRequest
        | ThreadAttachmentListRequest
        | ThreadAttachmentOwnerListRequest
        | ThreadAttachmentRemoveRequest
        | ThreadSectionMoveRequest
        | ThreadUnarchiveRequest
        | ThreadCompactStartRequest
        | ThreadShellCommandRequest
        | ThreadApproveGuardianDeniedActionRequest
        | ThreadRevertRequest
        | ThreadListRequest
        | ThreadSectionListRequest
        | ThreadSectionCreateRequest
        | ThreadSectionUpdateRequest
        | ThreadSectionDeleteRequest
        | ThreadLoadedListRequest
        | ThreadReadRequest
        | ThreadTurnsListRequest
        | ThreadItemsListRequest
        | ThreadInjectItemsRequest
        | SkillsListRequest
        | SkillsExtraRootsSetRequest
        | HooksListRequest
        | MarketplaceAddRequest
        | MarketplaceRemoveRequest
        | MarketplaceUpgradeRequest
        | PluginListRequest
        | PluginInstalledRequest
        | PluginReconcileRequest
        | PluginReadRequest
        | PluginSkillReadRequest
        | PluginShareSaveRequest
        | PluginShareUpdateTargetsRequest
        | PluginShareListRequest
        | PluginShareCheckoutRequest
        | PluginShareDeleteRequest
        | AppReadRequest
        | AppListRequest
        | AppInstalledRequest
        | FsReadFileRequest
        | FsWriteFileRequest
        | FsCreateDirectoryRequest
        | FsGetMetadataRequest
        | FsReadDirectoryRequest
        | FsRemoveRequest
        | FsCopyRequest
        | FsWatchRequest
        | FsUnwatchRequest
        | SkillsConfigWriteRequest
        | PluginInstallRequest
        | PluginUninstallRequest
        | TurnStartRequest
        | TurnSteerRequest
        | TurnInterruptRequest
        | ReviewStartRequest
        | ModelListRequest
        | AccountGatewayOAuthReadRequest
        | AccountGatewayOAuthLoginRequest
        | AccountGatewayOAuthCancelRequest
        | ModelProviderCapabilitiesReadRequest
        | ExperimentalFeatureListRequest
        | PermissionProfileListRequest
        | ExperimentalFeatureEnablementSetRequest
        | McpServerOauthLoginRequest
        | ConfigMcpServerReloadRequest
        | McpServerStatusListRequest
        | McpServerResourceReadRequest
        | McpServerToolCallRequest
        | WindowsSandboxSetupStartRequest
        | WindowsSandboxReadinessRequest
        | AccountLoginStartRequest
        | AccountLoginCancelRequest
        | AccountLogoutRequest
        | AccountRateLimitsReadRequest
        | AccountRateLimitResetCreditConsumeRequest
        | AccountUsageReadRequest
        | AccountWorkspaceMessagesReadRequest
        | AccountSendAddCreditsNudgeEmailRequest
        | FeedbackUploadRequest
        | FeedbackSaveRequest
        | CommandExecRequest
        | CommandExecWriteRequest
        | CommandExecTerminateRequest
        | CommandExecResizeRequest
        | ConfigReadRequest
        | ExternalAgentConfigDetectRequest
        | ExternalAgentConfigImportRequest
        | ExternalAgentConfigImportRecordHistoryRequest
        | ExternalAgentConfigImportReadHistoriesRequest
        | ConfigValueWriteRequest
        | ConfigBatchWriteRequest
        | ConfigRequirementsReadRequest
        | AccountReadRequest
        | FuzzyFileSearchRequest
    ]
):
    root: Annotated[
        InitializeRequest
        | ThreadStartRequest
        | ThreadResumeRequest
        | ThreadForkRequest
        | ThreadArchiveRequest
        | ThreadDeleteRequest
        | ThreadUnsubscribeRequest
        | ThreadNameSetRequest
        | ThreadGoalSetRequest
        | ThreadGoalGetRequest
        | ThreadGoalClearRequest
        | ThreadMetadataUpdateRequest
        | ThreadAttachmentAddRequest
        | ThreadAttachmentListRequest
        | ThreadAttachmentOwnerListRequest
        | ThreadAttachmentRemoveRequest
        | ThreadSectionMoveRequest
        | ThreadUnarchiveRequest
        | ThreadCompactStartRequest
        | ThreadShellCommandRequest
        | ThreadApproveGuardianDeniedActionRequest
        | ThreadRevertRequest
        | ThreadListRequest
        | ThreadSectionListRequest
        | ThreadSectionCreateRequest
        | ThreadSectionUpdateRequest
        | ThreadSectionDeleteRequest
        | ThreadLoadedListRequest
        | ThreadReadRequest
        | ThreadTurnsListRequest
        | ThreadItemsListRequest
        | ThreadInjectItemsRequest
        | SkillsListRequest
        | SkillsExtraRootsSetRequest
        | HooksListRequest
        | MarketplaceAddRequest
        | MarketplaceRemoveRequest
        | MarketplaceUpgradeRequest
        | PluginListRequest
        | PluginInstalledRequest
        | PluginReconcileRequest
        | PluginReadRequest
        | PluginSkillReadRequest
        | PluginShareSaveRequest
        | PluginShareUpdateTargetsRequest
        | PluginShareListRequest
        | PluginShareCheckoutRequest
        | PluginShareDeleteRequest
        | AppReadRequest
        | AppListRequest
        | AppInstalledRequest
        | FsReadFileRequest
        | FsWriteFileRequest
        | FsCreateDirectoryRequest
        | FsGetMetadataRequest
        | FsReadDirectoryRequest
        | FsRemoveRequest
        | FsCopyRequest
        | FsWatchRequest
        | FsUnwatchRequest
        | SkillsConfigWriteRequest
        | PluginInstallRequest
        | PluginUninstallRequest
        | TurnStartRequest
        | TurnSteerRequest
        | TurnInterruptRequest
        | ReviewStartRequest
        | ModelListRequest
        | AccountGatewayOAuthReadRequest
        | AccountGatewayOAuthLoginRequest
        | AccountGatewayOAuthCancelRequest
        | ModelProviderCapabilitiesReadRequest
        | ExperimentalFeatureListRequest
        | PermissionProfileListRequest
        | ExperimentalFeatureEnablementSetRequest
        | McpServerOauthLoginRequest
        | ConfigMcpServerReloadRequest
        | McpServerStatusListRequest
        | McpServerResourceReadRequest
        | McpServerToolCallRequest
        | WindowsSandboxSetupStartRequest
        | WindowsSandboxReadinessRequest
        | AccountLoginStartRequest
        | AccountLoginCancelRequest
        | AccountLogoutRequest
        | AccountRateLimitsReadRequest
        | AccountRateLimitResetCreditConsumeRequest
        | AccountUsageReadRequest
        | AccountWorkspaceMessagesReadRequest
        | AccountSendAddCreditsNudgeEmailRequest
        | FeedbackUploadRequest
        | FeedbackSaveRequest
        | CommandExecRequest
        | CommandExecWriteRequest
        | CommandExecTerminateRequest
        | CommandExecResizeRequest
        | ConfigReadRequest
        | ExternalAgentConfigDetectRequest
        | ExternalAgentConfigImportRequest
        | ExternalAgentConfigImportRecordHistoryRequest
        | ExternalAgentConfigImportReadHistoriesRequest
        | ConfigValueWriteRequest
        | ConfigBatchWriteRequest
        | ConfigRequirementsReadRequest
        | AccountReadRequest
        | FuzzyFileSearchRequest,
        Field(description="Request from the client to the server.", title="ClientRequest"),
    ]


class RequestPermissionsGuardianApprovalReviewAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    permissions: RequestPermissionProfile
    reason: str | None = None
    type: Annotated[
        Literal["requestPermissions"],
        Field(title="RequestPermissionsGuardianApprovalReviewActionType"),
    ]


class GuardianApprovalReviewAction(
    RootModel[
        CommandGuardianApprovalReviewAction
        | ExecveGuardianApprovalReviewAction
        | WriteStdinGuardianApprovalReviewAction
        | ApplyPatchGuardianApprovalReviewAction
        | NetworkAccessGuardianApprovalReviewAction
        | McpToolCallGuardianApprovalReviewAction
        | RequestPermissionsGuardianApprovalReviewAction
    ]
):
    root: (
        CommandGuardianApprovalReviewAction
        | ExecveGuardianApprovalReviewAction
        | WriteStdinGuardianApprovalReviewAction
        | ApplyPatchGuardianApprovalReviewAction
        | NetworkAccessGuardianApprovalReviewAction
        | McpToolCallGuardianApprovalReviewAction
        | RequestPermissionsGuardianApprovalReviewAction
    )


class ItemGuardianApprovalReviewCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    action: GuardianApprovalReviewAction
    completed_at_ms: Annotated[
        int,
        Field(
            alias="completedAtMs",
            description="Unix timestamp (in milliseconds) when this review completed.",
        ),
    ]
    decision_source: Annotated[AutoReviewDecisionSource, Field(alias="decisionSource")]
    review: GuardianApprovalReview
    review_id: Annotated[
        str, Field(alias="reviewId", description="Stable identifier for this review.")
    ]
    started_at_ms: Annotated[
        int,
        Field(
            alias="startedAtMs",
            description="Unix timestamp (in milliseconds) when this review started.",
        ),
    ]
    target_item_id: Annotated[
        str | None,
        Field(
            alias="targetItemId",
            description="Identifier for the reviewed item or tool call when one exists.\n\nIn most cases, one review maps to one target item. The exceptions are - execve reviews, where a single command may contain multiple execve calls to review (only possible when using the shell_zsh_fork feature) - stdin reviews, which refer to the existing parent command item and have a separate approval ID in the action payload - network policy reviews, where there is no target item\n\nA network call is triggered by a CommandExecution item, so having a target_item_id set to the CommandExecution item would be misleading because the review is about the network call, not the command execution. Therefore, target_item_id is set to None for network policy reviews.",
        ),
    ] = None
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class ItemGuardianApprovalReviewStartedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    action: GuardianApprovalReviewAction
    review: GuardianApprovalReview
    review_id: Annotated[
        str, Field(alias="reviewId", description="Stable identifier for this review.")
    ]
    started_at_ms: Annotated[
        int,
        Field(
            alias="startedAtMs",
            description="Unix timestamp (in milliseconds) when this review started.",
        ),
    ]
    target_item_id: Annotated[
        str | None,
        Field(
            alias="targetItemId",
            description="Identifier for the reviewed item or tool call when one exists.\n\nIn most cases, one review maps to one target item. The exceptions are - execve reviews, where a single command may contain multiple execve calls to review (only possible when using the shell_zsh_fork feature) - stdin reviews, which refer to the existing parent command item and have a separate approval ID in the action payload - network policy reviews, where there is no target item\n\nA network call is triggered by a CommandExecution item, so having a target_item_id set to the CommandExecution item would be misleading because the review is about the network call, not the command execution. Therefore, target_item_id is set to None for network policy reviews.",
        ),
    ] = None
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class PluginInstalledResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_load_errors: Annotated[
        list[MarketplaceLoadErrorInfo] | None,
        Field(alias="marketplaceLoadErrors", validate_default=True),
    ] = []
    marketplaces: list[PluginMarketplaceEntry]


class PluginListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    featured_plugin_ids: Annotated[list[str] | None, Field(alias="featuredPluginIds")] = []
    marketplace_load_errors: Annotated[
        list[MarketplaceLoadErrorInfo] | None,
        Field(alias="marketplaceLoadErrors", validate_default=True),
    ] = []
    marketplaces: list[PluginMarketplaceEntry]


class ThreadStartedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[Literal["thread/started"], Field(title="Thread/startedNotificationMethod")]
    params: ThreadStartedNotification


class ItemAutoApprovalReviewStartedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["item/autoApprovalReview/started"],
        Field(title="Item/autoApprovalReview/startedNotificationMethod"),
    ]
    params: ItemGuardianApprovalReviewStartedNotification


class ItemAutoApprovalReviewCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    emitted_at_ms: Annotated[
        int | None,
        Field(
            alias="emittedAtMs",
            description="Unix timestamp (in milliseconds) when app-server emitted this notification.",
        ),
    ] = None
    method: Annotated[
        Literal["item/autoApprovalReview/completed"],
        Field(title="Item/autoApprovalReview/completedNotificationMethod"),
    ]
    params: ItemGuardianApprovalReviewCompletedNotification


class ServerNotification(
    RootModel[
        ErrorServerNotification
        | ThreadStartedServerNotification
        | ThreadStatusChangedServerNotification
        | ThreadReadStateChangedServerNotification
        | ThreadArchivedServerNotification
        | ThreadDeletedServerNotification
        | ThreadUnarchivedServerNotification
        | ThreadClosedServerNotification
        | ThreadRevertedServerNotification
        | SkillsChangedServerNotification
        | ThreadNameUpdatedServerNotification
        | ThreadAttachmentUpdatedServerNotification
        | ThreadGoalUpdatedServerNotification
        | ThreadPredictionUpdatedServerNotification
        | ThreadGoalClearedServerNotification
        | ThreadQueueChangedServerNotification
        | ProjectChangedServerNotification
        | ThreadProjectUpdatedServerNotification
        | ThreadEnvironmentConnectedServerNotification
        | ThreadEnvironmentDisconnectedServerNotification
        | ThreadSettingsUpdatedServerNotification
        | ThreadTokenUsageUpdatedServerNotification
        | TurnStartedServerNotification
        | HookStartedServerNotification
        | TurnCompletedServerNotification
        | HookCompletedServerNotification
        | TurnDiffUpdatedServerNotification
        | TurnPlanUpdatedServerNotification
        | ItemStartedServerNotification
        | ItemAutoApprovalReviewStartedServerNotification
        | ItemAutoApprovalReviewCompletedServerNotification
        | AutoApprovalReviewStrictReviewRequiredServerNotification
        | ItemCompletedServerNotification
        | ItemAgentMessageDeltaServerNotification
        | ItemPlanDeltaServerNotification
        | CommandExecOutputDeltaServerNotification
        | ProcessOutputDeltaServerNotification
        | ProcessExitedServerNotification
        | ItemCommandExecutionOutputDeltaServerNotification
        | ItemCommandExecutionTerminalInteractionServerNotification
        | ItemFileChangeOutputDeltaServerNotification
        | ItemFileChangePatchUpdatedServerNotification
        | ServerRequestResolvedServerNotification
        | ItemMcpToolCallProgressServerNotification
        | McpServerOauthLoginCompletedServerNotification
        | McpServerStartupStatusUpdatedServerNotification
        | McpServerEventStreamNotificationServerNotification
        | AccountUpdatedServerNotification
        | AccountGatewayOAuthChangedServerNotification
        | AccountRateLimitsUpdatedServerNotification
        | AppListUpdatedServerNotification
        | RemoteControlStatusChangedServerNotification
        | ExternalAgentConfigImportProgressServerNotification
        | ExternalAgentConfigImportCompletedServerNotification
        | FsChangedServerNotification
        | ItemReasoningSummaryTextDeltaServerNotification
        | ItemReasoningSummaryPartAddedServerNotification
        | ItemReasoningTextDeltaServerNotification
        | ThreadCompactedServerNotification
        | ModelReroutedServerNotification
        | ModelVerificationServerNotification
        | ModelProviderAuthRecoveryStartedServerNotification
        | ModelProviderAuthRecoveryCompletedServerNotification
        | TurnModerationMetadataServerNotification
        | ModelSafetyBufferingUpdatedServerNotification
        | WarningServerNotification
        | GuardianWarningServerNotification
        | DeprecationNoticeServerNotification
        | ConfigWarningServerNotification
        | FuzzyFileSearchSessionUpdatedServerNotification
        | FuzzyFileSearchSessionCompletedServerNotification
        | ThreadRealtimeStartedServerNotification
        | ThreadRealtimeItemAddedServerNotification
        | ThreadRealtimeItemStartedServerNotification
        | ThreadRealtimeItemTranscriptDeltaServerNotification
        | ThreadRealtimeItemCompletedServerNotification
        | ThreadRealtimeTranscriptDeltaServerNotification
        | ThreadRealtimeTranscriptDoneServerNotification
        | ThreadRealtimeOutputAudioDeltaServerNotification
        | ThreadRealtimeSdpServerNotification
        | ThreadRealtimeErrorServerNotification
        | ThreadRealtimeClosedServerNotification
        | WindowsWorldWritableWarningServerNotification
        | WindowsSandboxSetupCompletedServerNotification
        | AccountLoginCompletedServerNotification
    ]
):
    root: Annotated[
        ErrorServerNotification
        | ThreadStartedServerNotification
        | ThreadStatusChangedServerNotification
        | ThreadReadStateChangedServerNotification
        | ThreadArchivedServerNotification
        | ThreadDeletedServerNotification
        | ThreadUnarchivedServerNotification
        | ThreadClosedServerNotification
        | ThreadRevertedServerNotification
        | SkillsChangedServerNotification
        | ThreadNameUpdatedServerNotification
        | ThreadAttachmentUpdatedServerNotification
        | ThreadGoalUpdatedServerNotification
        | ThreadPredictionUpdatedServerNotification
        | ThreadGoalClearedServerNotification
        | ThreadQueueChangedServerNotification
        | ProjectChangedServerNotification
        | ThreadProjectUpdatedServerNotification
        | ThreadEnvironmentConnectedServerNotification
        | ThreadEnvironmentDisconnectedServerNotification
        | ThreadSettingsUpdatedServerNotification
        | ThreadTokenUsageUpdatedServerNotification
        | TurnStartedServerNotification
        | HookStartedServerNotification
        | TurnCompletedServerNotification
        | HookCompletedServerNotification
        | TurnDiffUpdatedServerNotification
        | TurnPlanUpdatedServerNotification
        | ItemStartedServerNotification
        | ItemAutoApprovalReviewStartedServerNotification
        | ItemAutoApprovalReviewCompletedServerNotification
        | AutoApprovalReviewStrictReviewRequiredServerNotification
        | ItemCompletedServerNotification
        | ItemAgentMessageDeltaServerNotification
        | ItemPlanDeltaServerNotification
        | CommandExecOutputDeltaServerNotification
        | ProcessOutputDeltaServerNotification
        | ProcessExitedServerNotification
        | ItemCommandExecutionOutputDeltaServerNotification
        | ItemCommandExecutionTerminalInteractionServerNotification
        | ItemFileChangeOutputDeltaServerNotification
        | ItemFileChangePatchUpdatedServerNotification
        | ServerRequestResolvedServerNotification
        | ItemMcpToolCallProgressServerNotification
        | McpServerOauthLoginCompletedServerNotification
        | McpServerStartupStatusUpdatedServerNotification
        | McpServerEventStreamNotificationServerNotification
        | AccountUpdatedServerNotification
        | AccountGatewayOAuthChangedServerNotification
        | AccountRateLimitsUpdatedServerNotification
        | AppListUpdatedServerNotification
        | RemoteControlStatusChangedServerNotification
        | ExternalAgentConfigImportProgressServerNotification
        | ExternalAgentConfigImportCompletedServerNotification
        | FsChangedServerNotification
        | ItemReasoningSummaryTextDeltaServerNotification
        | ItemReasoningSummaryPartAddedServerNotification
        | ItemReasoningTextDeltaServerNotification
        | ThreadCompactedServerNotification
        | ModelReroutedServerNotification
        | ModelVerificationServerNotification
        | ModelProviderAuthRecoveryStartedServerNotification
        | ModelProviderAuthRecoveryCompletedServerNotification
        | TurnModerationMetadataServerNotification
        | ModelSafetyBufferingUpdatedServerNotification
        | WarningServerNotification
        | GuardianWarningServerNotification
        | DeprecationNoticeServerNotification
        | ConfigWarningServerNotification
        | FuzzyFileSearchSessionUpdatedServerNotification
        | FuzzyFileSearchSessionCompletedServerNotification
        | ThreadRealtimeStartedServerNotification
        | ThreadRealtimeItemAddedServerNotification
        | ThreadRealtimeItemStartedServerNotification
        | ThreadRealtimeItemTranscriptDeltaServerNotification
        | ThreadRealtimeItemCompletedServerNotification
        | ThreadRealtimeTranscriptDeltaServerNotification
        | ThreadRealtimeTranscriptDoneServerNotification
        | ThreadRealtimeOutputAudioDeltaServerNotification
        | ThreadRealtimeSdpServerNotification
        | ThreadRealtimeErrorServerNotification
        | ThreadRealtimeClosedServerNotification
        | WindowsWorldWritableWarningServerNotification
        | WindowsSandboxSetupCompletedServerNotification
        | AccountLoginCompletedServerNotification,
        Field(
            description="Notification sent from the server to the client.",
            title="ServerNotification",
        ),
    ]