# 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):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class AbsolutePathBuf(RootModel[str]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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 AccountLoginCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    error: str | None = None
    login_id: Annotated[str | None, Field(alias="loginId")] = None
    success: bool


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 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 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,
    )
    description: str | None = None
    id: str
    install_url: Annotated[str | None, Field(alias="installUrl")] = None
    name: str


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


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


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


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


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


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 AskForApprovalValue(Enum):
    untrusted = "untrusted"
    on_failure = "on-failure"
    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]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: AskForApprovalValue | GranularAskForApproval


class AuthMode(Enum):
    apikey = "apikey"
    chatgpt = "chatgpt"
    chatgpt_auth_tokens = "chatgptAuthTokens"


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 ClientInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str
    title: str | None = None
    version: str


class CodexErrorInfoValue(Enum):
    context_window_exceeded = "contextWindowExceeded"
    usage_limit_exceeded = "usageLimitExceeded"
    server_overloaded = "serverOverloaded"
    internal_server_error = "internalServerError"
    unauthorized = "unauthorized"
    bad_request = "badRequest"
    thread_rollback_failed = "threadRollbackFailed"
    sandbox_error = "sandboxError"
    other = "other"


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 CodexErrorInfo(
    RootModel[
        CodexErrorInfoValue
        | HttpConnectionFailedCodexErrorInfo
        | ResponseStreamConnectionFailedCodexErrorInfo
        | ResponseStreamDisconnectedCodexErrorInfo
        | ResponseTooManyFailedAttemptsCodexErrorInfo
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Annotated[
        CodexErrorInfoValue
        | HttpConnectionFailedCodexErrorInfo
        | ResponseStreamConnectionFailedCodexErrorInfo
        | ResponseStreamDisconnectedCodexErrorInfo
        | ResponseTooManyFailedAttemptsCodexErrorInfo,
        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 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"


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


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


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 CommandAction(
    RootModel[
        ReadCommandAction
        | ListFilesCommandAction
        | SearchCommandAction
        | UnknownCommandAction
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: (
        ReadCommandAction
        | ListFilesCommandAction
        | SearchCommandAction
        | UnknownCommandAction
    )


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


class CommandExecResizeResponse(BaseModel):
    pass
    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):
    pass
    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):
    pass
    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 CommandExecutionStatus(Enum):
    in_progress = "inProgress"
    completed = "completed"
    failed = "failed"
    declined = "declined"


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 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."
        ),
    ]
    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[
        MdmConfigLayerSource
        | SystemConfigLayerSource
        | UserConfigLayerSource
        | ProjectConfigLayerSource
        | SessionFlagsConfigLayerSource
        | LegacyManagedConfigTomlFromFileConfigLayerSource
        | LegacyManagedConfigTomlFromMdmConfigLayerSource
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: (
        MdmConfigLayerSource
        | SystemConfigLayerSource
        | 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")] = False


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


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


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


class ContentItem(
    RootModel[InputTextContentItem | InputImageContentItem | OutputTextContentItem]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: InputTextContentItem | InputImageContentItem | OutputTextContentItem


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 CreditsSnapshot(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    balance: str | None = None
    has_credits: Annotated[bool, Field(alias="hasCredits")]
    unlimited: bool


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 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 DynamicToolCallOutputContentItem(
    RootModel[
        InputTextDynamicToolCallOutputContentItem
        | InputImageDynamicToolCallOutputContentItem
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: (
        InputTextDynamicToolCallOutputContentItem
        | InputImageDynamicToolCallOutputContentItem
    )


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


class DynamicToolSpec(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


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


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 (~/.claude, ~/.codex, etc.).",
        ),
    ] = None


class ExternalAgentConfigImportResponse(BaseModel):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ExternalAgentConfigMigrationItemType(Enum):
    agents_md = "AGENTS_MD"
    config = "CONFIG"
    skills = "SKILLS"
    mcp_server_config = "MCP_SERVER_CONFIG"


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, Field(alias="includeLogs")]
    reason: str | None = None
    thread_id: Annotated[str | None, Field(alias="threadId")] = None


class FeedbackUploadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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 ForcedLoginMethod(Enum):
    chatgpt = "chatgpt"
    api = "api"


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):
    pass
    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):
    pass
    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 currently resolves to a directory.",
        ),
    ]
    is_file: Annotated[
        bool,
        Field(
            alias="isFile",
            description="Whether the path currently resolves to a regular file.",
        ),
    ]
    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):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


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):
    pass
    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 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]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Annotated[int, Field(ge=0)]


class FuzzyFileSearchResult(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    file_name: str
    indices: list[Indice] | None = None
    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 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`.",
        ),
    ] = False


class GhostCommit(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    parent: str | None = None
    preexisting_untracked_dirs: list[str]
    preexisting_untracked_files: list[str]


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 GuardianApprovalReviewStatus(Enum):
    in_progress = "inProgress"
    approved = "approved"
    denied = "denied"
    aborted = "aborted"


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


class HookEventName(Enum):
    session_start = "sessionStart"
    stop = "stop"


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


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


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


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


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


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


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
    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


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"


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
    limit: Annotated[
        int | None,
        Field(
            description="Optional page size; defaults to a server-defined value.", ge=0
        ),
    ] = None


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]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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 ChatgptLoginAccountParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[
        Literal["chatgpt"], Field(title="Chatgptv2::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 LoginAccountParams(
    RootModel[
        ApiKeyLoginAccountParams
        | ChatgptLoginAccountParams
        | ChatgptAuthTokensLoginAccountParams
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Annotated[
        ApiKeyLoginAccountParams
        | ChatgptLoginAccountParams
        | ChatgptAuthTokensLoginAccountParams,
        Field(title="LoginAccountParams"),
    ]


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 ChatgptAuthTokensLoginAccountResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[
        Literal["chatgptAuthTokens"],
        Field(title="ChatgptAuthTokensv2::LoginAccountResponseType"),
    ]


class LoginAccountResponse(
    RootModel[
        ApiKeyLoginAccountResponse
        | ChatgptLoginAccountResponse
        | ChatgptAuthTokensLoginAccountResponse
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Annotated[
        ApiKeyLoginAccountResponse
        | ChatgptLoginAccountResponse
        | ChatgptAuthTokensLoginAccountResponse,
        Field(title="LoginAccountResponse"),
    ]


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


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


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


class McpServerOauthLoginCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    error: str | None = None
    name: str
    success: bool


class McpServerOauthLoginParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str
    scopes: list[str] | None = 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")]


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


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,
    )
    content: list
    structured_content: Annotated[Any | None, Field(alias="structuredContent")] = None


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


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


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


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


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 ModelRerouteReason(RootModel[Literal["highRiskCyberActivity"]]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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 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
    upgrade_copy: Annotated[str | None, Field(alias="upgradeCopy")] = None


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


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")] = (
        None
    )
    allow_upstream_proxy: Annotated[bool | None, Field(alias="allowUpstreamProxy")] = (
        None
    )
    allowed_domains: Annotated[list[str] | None, Field(alias="allowedDomains")] = 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")] = None
    enabled: bool | None = None
    http_port: Annotated[int | None, Field(alias="httpPort", ge=0)] = None
    socks_port: Annotated[int | None, Field(alias="socksPort", ge=0)] = None


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]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: AddPatchChangeKind | DeletePatchChangeKind | UpdatePatchChangeKind


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(Enum):
    free = "free"
    go = "go"
    plus = "plus"
    pro = "pro"
    team = "team"
    business = "business"
    enterprise = "enterprise"
    edu = "edu"
    unknown = "unknown"


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


class PluginInstallParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    force_remote_sync: Annotated[
        bool | None,
        Field(
            alias="forceRemoteSync",
            description="When true, apply the remote plugin change before the local install flow.",
        ),
    ] = None
    marketplace_path: Annotated[AbsolutePathBuf, Field(alias="marketplacePath")]
    plugin_name: Annotated[str, Field(alias="pluginName")]


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


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 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")] = 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: AbsolutePathBuf | None = None
    long_description: Annotated[str | None, Field(alias="longDescription")] = None
    privacy_policy_url: Annotated[str | None, Field(alias="privacyPolicyUrl")] = None
    screenshots: list[AbsolutePathBuf]
    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 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_remote_sync: Annotated[
        bool | None,
        Field(
            alias="forceRemoteSync",
            description="When true, reconcile the official curated marketplace against the remote plugin state before listing marketplaces.",
        ),
    ] = None


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


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


class PluginSource(RootModel[LocalPluginSource]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: LocalPluginSource


class PluginSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    auth_policy: Annotated[PluginAuthPolicy, Field(alias="authPolicy")]
    enabled: bool
    id: str
    install_policy: Annotated[PluginInstallPolicy, Field(alias="installPolicy")]
    installed: bool
    interface: PluginInterface | None = None
    name: str
    source: PluginSource


class PluginUninstallParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    force_remote_sync: Annotated[
        bool | None,
        Field(
            alias="forceRemoteSync",
            description="When true, apply the remote plugin change before the local uninstall flow.",
        ),
    ] = None
    plugin_id: Annotated[str, Field(alias="pluginId")]


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


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 RestrictedReadOnlyAccess(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    include_platform_defaults: Annotated[
        bool | None, Field(alias="includePlatformDefaults")
    ] = True
    readable_roots: Annotated[
        list[AbsolutePathBuf] | None, Field(alias="readableRoots")
    ] = []
    type: Annotated[Literal["restricted"], Field(title="RestrictedReadOnlyAccessType")]


class FullAccessReadOnlyAccess(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["fullAccess"], Field(title="FullAccessReadOnlyAccessType")]


class ReadOnlyAccess(RootModel[RestrictedReadOnlyAccess | FullAccessReadOnlyAccess]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: RestrictedReadOnlyAccess | FullAccessReadOnlyAccess


class ReasoningEffort(Enum):
    none = "none"
    minimal = "minimal"
    low = "low"
    medium = "medium"
    high = "high"
    xhigh = "xhigh"


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]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: SummaryTextReasoningItemReasoningSummary


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


class ReasoningSummary(RootModel[ReasoningSummaryValue | Literal["none"]]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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 RequestId(RootModel[str | int]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: str | int


class ResidencyRequirement(RootModel[Literal["us"]]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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 | None = None
    mime_type: Annotated[str | None, Field(alias="mimeType")] = None
    name: str
    size: int | None = None
    title: str | None = None
    uri: str


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 MessageResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    content: list[ContentItem]
    end_turn: bool | None = None
    id: str | None = None
    phase: MessagePhase | None = None
    role: str
    type: Annotated[Literal["message"], Field(title="MessageResponseItemType")]


class ReasoningResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    content: list[ReasoningItemContent] | None = None
    encrypted_content: str | 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
    id: Annotated[
        str | None,
        Field(
            description="Legacy id field retained for compatibility with older payloads."
        ),
    ] = 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
    id: str | None = None
    name: str
    namespace: 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
    execution: str
    id: str | 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
    id: str | None = None
    input: str
    name: str
    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
    status: str
    tools: list
    type: Annotated[
        Literal["tool_search_output"], Field(title="ToolSearchOutputResponseItemType")
    ]


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


class GhostSnapshotResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    ghost_commit: GhostCommit
    type: Annotated[
        Literal["ghost_snapshot"], Field(title="GhostSnapshotResponseItemType")
    ]


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


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


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
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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,
    )
    access: Annotated[ReadOnlyAccess | None, Field()] = {"type": "fullAccess"}
    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
    read_only_access: Annotated[
        ReadOnlyAccess | None, Field(alias="readOnlyAccess")
    ] = {"type": "fullAccess"}
    type: Annotated[
        Literal["workspaceWrite"], Field(title="WorkspaceWriteSandboxPolicyType")
    ]
    writable_roots: Annotated[
        list[AbsolutePathBuf] | None, Field(alias="writableRoots")
    ] = []


class SandboxPolicy(
    RootModel[
        DangerFullAccessSandboxPolicy
        | ReadOnlySandboxPolicy
        | ExternalSandboxSandboxPolicy
        | WorkspaceWriteSandboxPolicy
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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 ItemAgentMessageDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["item/agentMessage/delta"],
        Field(title="Item/agentMessage/deltaNotificationMethod"),
    ]
    params: AgentMessageDeltaNotification


class ItemPlanDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["item/plan/delta"], Field(title="Item/plan/deltaNotificationMethod")
    ]
    params: PlanDeltaNotification


class ItemCommandExecutionOutputDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["item/commandExecution/outputDelta"],
        Field(title="Item/commandExecution/outputDeltaNotificationMethod"),
    ]
    params: CommandExecutionOutputDeltaNotification


class ItemFileChangeOutputDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["item/fileChange/outputDelta"],
        Field(title="Item/fileChange/outputDeltaNotificationMethod"),
    ]
    params: FileChangeOutputDeltaNotification


class ItemMcpToolCallProgressServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["item/mcpToolCall/progress"],
        Field(title="Item/mcpToolCall/progressNotificationMethod"),
    ]
    params: McpToolCallProgressNotification


class McpServerOauthLoginCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["mcpServer/oauthLogin/completed"],
        Field(title="McpServer/oauthLogin/completedNotificationMethod"),
    ]
    params: McpServerOauthLoginCompletedNotification


class ItemReasoningSummaryTextDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["item/reasoning/summaryTextDelta"],
        Field(title="Item/reasoning/summaryTextDeltaNotificationMethod"),
    ]
    params: ReasoningSummaryTextDeltaNotification


class ItemReasoningSummaryPartAddedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["item/reasoning/summaryPartAdded"],
        Field(title="Item/reasoning/summaryPartAddedNotificationMethod"),
    ]
    params: ReasoningSummaryPartAddedNotification


class ItemReasoningTextDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["item/reasoning/textDelta"],
        Field(title="Item/reasoning/textDeltaNotificationMethod"),
    ]
    params: ReasoningTextDeltaNotification


class ThreadCompactedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/compacted"], Field(title="Thread/compactedNotificationMethod")
    ]
    params: ContextCompactedNotification


class ModelReroutedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["model/rerouted"], Field(title="Model/reroutedNotificationMethod")
    ]
    params: ModelReroutedNotification


class DeprecationNoticeServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["deprecationNotice"], Field(title="DeprecationNoticeNotificationMethod")
    ]
    params: DeprecationNoticeNotification


class FuzzyFileSearchSessionUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["fuzzyFileSearch/sessionUpdated"],
        Field(title="FuzzyFileSearch/sessionUpdatedNotificationMethod"),
    ]
    params: FuzzyFileSearchSessionUpdatedNotification


class FuzzyFileSearchSessionCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["fuzzyFileSearch/sessionCompleted"],
        Field(title="FuzzyFileSearch/sessionCompletedNotificationMethod"),
    ]
    params: FuzzyFileSearchSessionCompletedNotification


class AccountLoginCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["account/login/completed"],
        Field(title="Account/login/completedNotificationMethod"),
    ]
    params: AccountLoginCompletedNotification


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 ServiceTier(Enum):
    fast = "fast"
    flex = "flex"


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


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[str | None, Field(alias="iconLarge")] = None
    icon_small: Annotated[str | None, Field(alias="iconSmall")] = None
    short_description: Annotated[str | None, Field(alias="shortDescription")] = None


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


class SkillSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    description: str
    interface: SkillInterface | None = None
    name: str
    path: str
    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):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class SkillsConfigWriteParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    enabled: bool
    path: str


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


class SkillsListExtraRootsForCwd(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: str
    extra_user_roots: Annotated[list[str], Field(alias="extraUserRoots")]


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
    per_cwd_extra_user_roots: Annotated[
        list[SkillsListExtraRootsForCwd] | None,
        Field(
            alias="perCwdExtraUserRoots",
            description="Optional per-cwd extra roots to scan as user-scoped skills.",
        ),
    ] = None


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 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 ThreadArchiveParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadArchiveResponse(BaseModel):
    pass
    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 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):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


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
    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[ServiceTier | None, Field(alias="serviceTier")] = None
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadId(RootModel[str]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: str


class AgentMessageThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    phase: MessagePhase | None = None
    text: str
    type: Annotated[Literal["agentMessage"], Field(title="AgentMessageThreadItemType")]


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 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[str, 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
    process_id: Annotated[
        str | None,
        Field(
            alias="processId",
            description="Identifier for the underlying PTY process (when available).",
        ),
    ] = None
    status: CommandExecutionStatus
    type: Annotated[
        Literal["commandExecution"], Field(title="CommandExecutionThreadItemType")
    ]


class McpToolCallThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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
    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
    status: DynamicToolCallStatus
    success: bool | None = None
    tool: str
    type: Annotated[
        Literal["dynamicToolCall"], Field(title="DynamicToolCallThreadItemType")
    ]


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


class ImageGenerationThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    result: str
    revised_prompt: Annotated[str | None, Field(alias="revisedPrompt")] = None
    status: str
    type: Annotated[
        Literal["imageGeneration"], Field(title="ImageGenerationThreadItemType")
    ]


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 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 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 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.",
        ),
    ] = False
    thread_id: Annotated[str, Field(alias="threadId")]


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 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 ThreadRealtimeItemAddedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item: Any
    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 ThreadRealtimeStartedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    session_id: Annotated[str | None, Field(alias="sessionId")] = None
    thread_id: Annotated[str, Field(alias="threadId")]


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
    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: Personality | None = None
    sandbox: SandboxMode | None = None
    service_tier: Annotated[ServiceTier | None, Field(alias="serviceTier")] = None
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadRollbackParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    num_turns: Annotated[
        int,
        Field(
            alias="numTurns",
            description="The number of turns to drop from the end of the thread. Must be >= 1.\n\nThis only modifies the thread's history and does not revert local file changes that have been made by the agent. Clients are responsible for reverting these changes.",
            ge=0,
        ),
    ]
    thread_id: Annotated[str, Field(alias="threadId")]


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


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


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


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 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: Personality | None = None
    sandbox: SandboxMode | None = None
    service_name: Annotated[str | None, Field(alias="serviceName")] = None
    service_tier: Annotated[ServiceTier | None, Field(alias="serviceTier")] = None


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
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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 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 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 TokenUsageBreakdown(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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 | 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 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 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


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):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


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."
        ),
    ] = []
    type: Annotated[Literal["text"], Field(title="TextUserInputType")]


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


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


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
        | LocalImageUserInput
        | SkillUserInput
        | MentionUserInput
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: (
        TextUserInput
        | ImageUserInput
        | LocalImageUserInput
        | SkillUserInput
        | MentionUserInput
    )


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


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
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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"
    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 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 WriteStatus(Enum):
    ok = "ok"
    ok_overridden = "okOverridden"


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


class Account(RootModel[ApiKeyAccount | ChatgptAccount]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: ApiKeyAccount | ChatgptAccount


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 AppConfig(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    default_tools_approval_mode: AppToolApproval | None = None
    default_tools_enabled: bool | None = None
    destructive_enabled: bool | None = None
    enabled: bool | None = True
    open_world_enabled: bool | None = None
    tools: AppToolsConfig | 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
    first_party_type: Annotated[str | None, Field(alias="firstPartyType")] = 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 AppsConfig(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    field_default: Annotated[AppsDefaultConfig | None, Field(alias="_default")] = 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 ThreadStartRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/start"], Field(title="Thread/startRequestMethod")]
    params: ThreadStartParams


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


class ThreadForkRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/fork"], Field(title="Thread/forkRequestMethod")]
    params: ThreadForkParams


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


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 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 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 ThreadRollbackRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["thread/rollback"], Field(title="Thread/rollbackRequestMethod")
    ]
    params: ThreadRollbackParams


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 SkillsListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["skills/list"], Field(title="Skills/listRequestMethod")]
    params: SkillsListParams


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


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


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


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 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 ExperimentalFeatureListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["experimentalFeature/list"],
        Field(title="ExperimentalFeature/listRequestMethod"),
    ]
    params: ExperimentalFeatureListParams


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: None = None


class McpServerStatusListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["mcpServerStatus/list"],
        Field(title="McpServerStatus/listRequestMethod"),
    ]
    params: ListMcpServerStatusParams


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


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 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: 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: None = None


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 ConfigRequirementsReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["configRequirements/read"],
        Field(title="ConfigRequirements/readRequestMethod"),
    ]
    params: 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 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 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.",
        ),
    ] = 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 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 ConfigRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    allowed_approval_policies: Annotated[
        list[AskForApproval] | None, Field(alias="allowedApprovalPolicies")
    ] = None
    allowed_sandbox_modes: Annotated[
        list[SandboxMode] | None, Field(alias="allowedSandboxModes")
    ] = None
    allowed_web_search_modes: Annotated[
        list[WebSearchMode] | None, Field(alias="allowedWebSearchModes")
    ] = None
    enforce_residency: Annotated[
        ResidencyRequirement | None, Field(alias="enforceResidency")
    ] = None
    feature_requirements: Annotated[
        dict[str, Any] | None, Field(alias="featureRequirements")
    ] = 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


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 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 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 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
    item_type: Annotated[ExternalAgentConfigMigrationItemType, Field(alias="itemType")]


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
    image_url: str
    type: Annotated[
        Literal["input_image"],
        Field(title="InputImageFunctionCallOutputContentItemType"),
    ]


class FunctionCallOutputContentItem(
    RootModel[
        InputTextFunctionCallOutputContentItem | InputImageFunctionCallOutputContentItem
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Annotated[
        InputTextFunctionCallOutputContentItem
        | InputImageFunctionCallOutputContentItem,
        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 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
    risk_score: Annotated[int | None, Field(alias="riskScore", ge=0)] = None
    status: GuardianApprovalReviewStatus


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_path: Annotated[str, 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 ItemGuardianApprovalReviewCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    action: Any | None = None
    review: GuardianApprovalReview
    target_item_id: Annotated[str, Field(alias="targetItemId")]
    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: Any | None = None
    review: GuardianApprovalReview
    target_item_id: Annotated[str, Field(alias="targetItemId")]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class McpServerStatus(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    auth_status: Annotated[McpAuthStatus, Field(alias="authStatus")]
    name: str
    resource_templates: Annotated[
        list[ResourceTemplate], Field(alias="resourceTemplates")
    ]
    resources: list[Resource]
    tools: dict[str, Tool]


class Model(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    availability_nux: Annotated[
        ModelAvailabilityNux | None, Field(alias="availabilityNux")
    ] = None
    default_reasoning_effort: Annotated[
        ReasoningEffort, Field(alias="defaultReasoningEffort")
    ]
    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
    supported_reasoning_efforts: Annotated[
        list[ReasoningEffortOption], Field(alias="supportedReasoningEfforts")
    ]
    supports_personality: Annotated[bool | None, Field(alias="supportsPersonality")] = (
        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 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 PluginDetail(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    apps: list[AppSummary]
    description: str | None = None
    marketplace_name: Annotated[str, Field(alias="marketplaceName")]
    marketplace_path: Annotated[AbsolutePathBuf, Field(alias="marketplacePath")]
    mcp_servers: Annotated[list[str], Field(alias="mcpServers")]
    skills: list[SkillSummary]
    summary: PluginSummary


class PluginMarketplaceEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    interface: MarketplaceInterface | None = None
    name: str
    path: AbsolutePathBuf
    plugins: list[PluginSummary]


class PluginReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    plugin: PluginDetail


class RateLimitSnapshot(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    credits: CreditsSnapshot | None = None
    limit_id: Annotated[str | None, Field(alias="limitId")] = None
    limit_name: Annotated[str | None, Field(alias="limitName")] = None
    plan_type: Annotated[PlanType | None, Field(alias="planType")] = None
    primary: RateLimitWindow | None = None
    secondary: RateLimitWindow | None = None


class WebSearchCallResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    action: ResponsesApiWebSearchAction | None = None
    id: str | None = None
    status: str | None = None
    type: Annotated[
        Literal["web_search_call"], Field(title="WebSearchCallResponseItemType")
    ]


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`)."
        ),
    ] = None
    target: ReviewTarget
    thread_id: Annotated[str, Field(alias="threadId")]


class ErrorServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[Literal["error"], Field(title="ErrorNotificationMethod")]
    params: ErrorNotification


class ThreadStatusChangedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/status/changed"],
        Field(title="Thread/status/changedNotificationMethod"),
    ]
    params: ThreadStatusChangedNotification


class ThreadArchivedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/archived"], Field(title="Thread/archivedNotificationMethod")
    ]
    params: ThreadArchivedNotification


class ThreadUnarchivedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/unarchived"], Field(title="Thread/unarchivedNotificationMethod")
    ]
    params: ThreadUnarchivedNotification


class ThreadClosedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/closed"], Field(title="Thread/closedNotificationMethod")
    ]
    params: ThreadClosedNotification


class SkillsChangedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["skills/changed"], Field(title="Skills/changedNotificationMethod")
    ]
    params: SkillsChangedNotification


class ThreadNameUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/name/updated"],
        Field(title="Thread/name/updatedNotificationMethod"),
    ]
    params: ThreadNameUpdatedNotification


class HookStartedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["hook/started"], Field(title="Hook/startedNotificationMethod")
    ]
    params: HookStartedNotification


class TurnDiffUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["turn/diff/updated"], Field(title="Turn/diff/updatedNotificationMethod")
    ]
    params: TurnDiffUpdatedNotification


class ItemAutoApprovalReviewStartedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["item/autoApprovalReview/started"],
        Field(title="Item/autoApprovalReview/startedNotificationMethod"),
    ]
    params: ItemGuardianApprovalReviewStartedNotification


class ItemAutoApprovalReviewCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["item/autoApprovalReview/completed"],
        Field(title="Item/autoApprovalReview/completedNotificationMethod"),
    ]
    params: ItemGuardianApprovalReviewCompletedNotification


class CommandExecOutputDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["command/exec/outputDelta"],
        Field(title="Command/exec/outputDeltaNotificationMethod"),
    ]
    params: CommandExecOutputDeltaNotification


class ItemCommandExecutionTerminalInteractionServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["item/commandExecution/terminalInteraction"],
        Field(title="Item/commandExecution/terminalInteractionNotificationMethod"),
    ]
    params: TerminalInteractionNotification


class ServerRequestResolvedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["serverRequest/resolved"],
        Field(title="ServerRequest/resolvedNotificationMethod"),
    ]
    params: ServerRequestResolvedNotification


class AccountUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["account/updated"], Field(title="Account/updatedNotificationMethod")
    ]
    params: AccountUpdatedNotification


class ConfigWarningServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["configWarning"], Field(title="ConfigWarningNotificationMethod")
    ]
    params: ConfigWarningNotification


class ThreadRealtimeStartedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/realtime/started"],
        Field(title="Thread/realtime/startedNotificationMethod"),
    ]
    params: ThreadRealtimeStartedNotification


class ThreadRealtimeItemAddedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/realtime/itemAdded"],
        Field(title="Thread/realtime/itemAddedNotificationMethod"),
    ]
    params: ThreadRealtimeItemAddedNotification


class ThreadRealtimeOutputAudioDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/realtime/outputAudio/delta"],
        Field(title="Thread/realtime/outputAudio/deltaNotificationMethod"),
    ]
    params: ThreadRealtimeOutputAudioDeltaNotification


class ThreadRealtimeErrorServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/realtime/error"],
        Field(title="Thread/realtime/errorNotificationMethod"),
    ]
    params: ThreadRealtimeErrorNotification


class ThreadRealtimeClosedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/realtime/closed"],
        Field(title="Thread/realtime/closedNotificationMethod"),
    ]
    params: ThreadRealtimeClosedNotification


class WindowsWorldWritableWarningServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["windows/worldWritableWarning"],
        Field(title="Windows/worldWritableWarningNotificationMethod"),
    ]
    params: WindowsWorldWritableWarningNotification


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: str
    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_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]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: SubAgentSourceValue | ThreadSpawnSubAgentSource | OtherSubAgentSource


class UserMessageThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    content: list[UserInput]
    id: str
    type: Annotated[Literal["userMessage"], Field(title="UserMessageThreadItemType")]


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
    type: Annotated[Literal["webSearch"], Field(title="WebSearchThreadItemType")]


class ThreadItem(
    RootModel[
        UserMessageThreadItem
        | AgentMessageThreadItem
        | PlanThreadItem
        | ReasoningThreadItem
        | CommandExecutionThreadItem
        | FileChangeThreadItem
        | McpToolCallThreadItem
        | DynamicToolCallThreadItem
        | CollabAgentToolCallThreadItem
        | WebSearchThreadItem
        | ImageViewThreadItem
        | ImageGenerationThreadItem
        | EnteredReviewModeThreadItem
        | ExitedReviewModeThreadItem
        | ContextCompactionThreadItem
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: (
        UserMessageThreadItem
        | AgentMessageThreadItem
        | PlanThreadItem
        | ReasoningThreadItem
        | CommandExecutionThreadItem
        | FileChangeThreadItem
        | McpToolCallThreadItem
        | DynamicToolCallThreadItem
        | CollabAgentToolCallThreadItem
        | WebSearchThreadItem
        | ImageViewThreadItem
        | ImageGenerationThreadItem
        | EnteredReviewModeThreadItem
        | ExitedReviewModeThreadItem
        | ContextCompactionThreadItem
    )


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[
        str | None,
        Field(
            description="Optional cwd filter; when set, only threads whose session cwd exactly matches this path are returned."
        ),
    ] = 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
    search_term: Annotated[
        str | None,
        Field(
            alias="searchTerm",
            description="Optional substring filter for the extracted thread title.",
        ),
    ] = 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


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 ThreadUnsubscribeResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    status: ThreadUnsubscribeStatus


class ToolsV2(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    view_image: bool | None = None
    web_search: WebSearchToolConfig | None = None


class Turn(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    error: Annotated[
        TurnError | None,
        Field(description="Only populated when the Turn's status is failed."),
    ] = None
    id: str
    items: Annotated[
        list[ThreadItem],
        Field(
            description="Only populated on a `thread/resume` or `thread/fork` response. For all other responses and notifications returning a Turn, the items field will be an empty list."
        ),
    ]
    status: TurnStatus


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


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 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
    cwd: Annotated[
        str | None,
        Field(
            description="Override the working directory for this turn and subsequent turns."
        ),
    ] = 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
    personality: Annotated[
        Personality | None,
        Field(
            description="Override the personality for this turn and subsequent turns."
        ),
    ] = None
    sandbox_policy: Annotated[
        SandboxPolicy | None,
        Field(
            alias="sandboxPolicy",
            description="Override the sandbox policy for this turn and subsequent turns.",
        ),
    ] = None
    service_tier: Annotated[
        ServiceTier | None,
        Field(
            alias="serviceTier",
            description="Override the service tier for this turn and subsequent turns.",
        ),
    ] = 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")]


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 TurnSteerParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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 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
    )
    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 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 ThreadListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/list"], Field(title="Thread/listRequestMethod")]
    params: ThreadListParams


class TurnStartRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["turn/start"], Field(title="Turn/startRequestMethod")]
    params: TurnStartParams


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 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 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 the updated user config into all loaded threads after writing.",
        ),
    ] = None


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 ExternalAgentConfigDetectResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    items: list[ExternalAgentConfigMigrationItem]


class ExternalAgentConfigImportParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    migration_items: Annotated[
        list[ExternalAgentConfigMigrationItem], Field(alias="migrationItems")
    ]


class FunctionCallOutputBody(RootModel[str | list[FunctionCallOutputContentItem]]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: str | list[FunctionCallOutputContentItem]


class GetAccountRateLimitsResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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 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 ItemCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


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 PluginListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplaces: list[PluginMarketplaceEntry]
    remote_sync_error: Annotated[str | None, Field(alias="remoteSyncError")] = None


class ProfileV2(BaseModel):
    model_config = ConfigDict(
        extra="allow",
        populate_by_name=True,
    )
    approval_policy: AskForApproval | None = None
    approvals_reviewer: Annotated[
        ApprovalsReviewer | None,
        Field(
            description="[UNSTABLE] Optional profile-level override for where approval requests are routed for review. If omitted, the enclosing config default is used."
        ),
    ] = None
    chatgpt_base_url: str | None = None
    model: str | None = None
    model_provider: str | None = None
    model_reasoning_effort: ReasoningEffort | None = None
    model_reasoning_summary: ReasoningSummary | None = None
    model_verbosity: Verbosity | None = None
    service_tier: ServiceTier | None = None
    tools: ToolsV2 | None = None
    web_search: WebSearchMode | None = None


class FunctionCallOutputResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    call_id: str
    output: FunctionCallOutputBody
    type: Annotated[
        Literal["function_call_output"],
        Field(title="FunctionCallOutputResponseItemType"),
    ]


class CustomToolCallOutputResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    call_id: str
    output: FunctionCallOutputBody
    type: Annotated[
        Literal["custom_tool_call_output"],
        Field(title="CustomToolCallOutputResponseItemType"),
    ]


class ResponseItem(
    RootModel[
        MessageResponseItem
        | ReasoningResponseItem
        | LocalShellCallResponseItem
        | FunctionCallResponseItem
        | ToolSearchCallResponseItem
        | FunctionCallOutputResponseItem
        | CustomToolCallResponseItem
        | CustomToolCallOutputResponseItem
        | ToolSearchOutputResponseItem
        | WebSearchCallResponseItem
        | ImageGenerationCallResponseItem
        | GhostSnapshotResponseItem
        | CompactionResponseItem
        | OtherResponseItem
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: (
        MessageResponseItem
        | ReasoningResponseItem
        | LocalShellCallResponseItem
        | FunctionCallResponseItem
        | ToolSearchCallResponseItem
        | FunctionCallOutputResponseItem
        | CustomToolCallResponseItem
        | CustomToolCallOutputResponseItem
        | ToolSearchOutputResponseItem
        | WebSearchCallResponseItem
        | ImageGenerationCallResponseItem
        | GhostSnapshotResponseItem
        | CompactionResponseItem
        | OtherResponseItem
    )


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 ThreadTokenUsageUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/tokenUsage/updated"],
        Field(title="Thread/tokenUsage/updatedNotificationMethod"),
    ]
    params: ThreadTokenUsageUpdatedNotification


class TurnStartedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["turn/started"], Field(title="Turn/startedNotificationMethod")
    ]
    params: TurnStartedNotification


class TurnCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["turn/completed"], Field(title="Turn/completedNotificationMethod")
    ]
    params: TurnCompletedNotification


class HookCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["hook/completed"], Field(title="Hook/completedNotificationMethod")
    ]
    params: HookCompletedNotification


class TurnPlanUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["turn/plan/updated"], Field(title="Turn/plan/updatedNotificationMethod")
    ]
    params: TurnPlanUpdatedNotification


class ItemStartedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["item/started"], Field(title="Item/startedNotificationMethod")
    ]
    params: ItemStartedNotification


class ItemCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["item/completed"], Field(title="Item/completedNotificationMethod")
    ]
    params: ItemCompletedNotification


class AccountRateLimitsUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["account/rateLimits/updated"],
        Field(title="Account/rateLimits/updatedNotificationMethod"),
    ]
    params: AccountRateLimitsUpdatedNotification


class AppListUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["app/list/updated"], Field(title="App/list/updatedNotificationMethod")
    ]
    params: AppListUpdatedNotification


class WindowsSandboxSetupCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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 | SubAgentSessionSource]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: SessionSourceValue | SubAgentSessionSource


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[str, 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."
        ),
    ]
    git_info: Annotated[
        GitInfo | None,
        Field(
            alias="gitInfo",
            description="Optional Git metadata captured when the thread was created.",
        ),
    ] = None
    id: str
    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
    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."
        ),
    ]
    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.")
    ]
    turns: Annotated[
        list[Turn],
        Field(
            description="Only populated on `thread/resume`, `thread/rollback`, `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: str
    model: str
    model_provider: Annotated[str, Field(alias="modelProvider")]
    reasoning_effort: Annotated[
        ReasoningEffort | None, Field(alias="reasoningEffort")
    ] = None
    sandbox: SandboxPolicy
    service_tier: Annotated[ServiceTier | None, Field(alias="serviceTier")] = None
    thread: Thread


class ThreadListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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.",
        ),
    ]
    cwd: str
    model: str
    model_provider: Annotated[str, Field(alias="modelProvider")]
    reasoning_effort: Annotated[
        ReasoningEffort | None, Field(alias="reasoningEffort")
    ] = None
    sandbox: SandboxPolicy
    service_tier: Annotated[ServiceTier | None, Field(alias="serviceTier")] = None
    thread: Thread


class ThreadRollbackResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread: Annotated[
        Thread,
        Field(
            description="The updated thread after applying the rollback, with `turns` populated.\n\nThe ThreadItems stored in each Turn are lossy since we explicitly do not persist all agent interactions, such as command executions. This is the same behavior as `thread/resume`."
        ),
    ]


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: str
    model: str
    model_provider: Annotated[str, Field(alias="modelProvider")]
    reasoning_effort: Annotated[
        ReasoningEffort | None, Field(alias="reasoningEffort")
    ] = None
    sandbox: SandboxPolicy
    service_tier: Annotated[ServiceTier | None, Field(alias="serviceTier")] = None
    thread: Thread


class ThreadStartedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread: Thread


class ThreadUnarchiveResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread: Thread


class ExternalAgentConfigImportRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["externalAgentConfig/import"],
        Field(title="ExternalAgentConfig/importRequestMethod"),
    ]
    params: ExternalAgentConfigImportParams


class ConfigBatchWriteRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["config/batchWrite"], Field(title="Config/batchWriteRequestMethod")
    ]
    params: ConfigBatchWriteParams


class ClientRequest(
    RootModel[
        InitializeRequest
        | ThreadStartRequest
        | ThreadResumeRequest
        | ThreadForkRequest
        | ThreadArchiveRequest
        | ThreadUnsubscribeRequest
        | ThreadNameSetRequest
        | ThreadMetadataUpdateRequest
        | ThreadUnarchiveRequest
        | ThreadCompactStartRequest
        | ThreadRollbackRequest
        | ThreadListRequest
        | ThreadLoadedListRequest
        | ThreadReadRequest
        | SkillsListRequest
        | PluginListRequest
        | PluginReadRequest
        | AppListRequest
        | FsReadFileRequest
        | FsWriteFileRequest
        | FsCreateDirectoryRequest
        | FsGetMetadataRequest
        | FsReadDirectoryRequest
        | FsRemoveRequest
        | FsCopyRequest
        | SkillsConfigWriteRequest
        | PluginInstallRequest
        | PluginUninstallRequest
        | TurnStartRequest
        | TurnSteerRequest
        | TurnInterruptRequest
        | ReviewStartRequest
        | ModelListRequest
        | ExperimentalFeatureListRequest
        | McpServerOauthLoginRequest
        | ConfigMcpServerReloadRequest
        | McpServerStatusListRequest
        | WindowsSandboxSetupStartRequest
        | AccountLoginStartRequest
        | AccountLoginCancelRequest
        | AccountLogoutRequest
        | AccountRateLimitsReadRequest
        | FeedbackUploadRequest
        | CommandExecRequest
        | CommandExecWriteRequest
        | CommandExecTerminateRequest
        | CommandExecResizeRequest
        | ConfigReadRequest
        | ExternalAgentConfigDetectRequest
        | ExternalAgentConfigImportRequest
        | ConfigValueWriteRequest
        | ConfigBatchWriteRequest
        | ConfigRequirementsReadRequest
        | AccountReadRequest
        | FuzzyFileSearchRequest
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Annotated[
        InitializeRequest
        | ThreadStartRequest
        | ThreadResumeRequest
        | ThreadForkRequest
        | ThreadArchiveRequest
        | ThreadUnsubscribeRequest
        | ThreadNameSetRequest
        | ThreadMetadataUpdateRequest
        | ThreadUnarchiveRequest
        | ThreadCompactStartRequest
        | ThreadRollbackRequest
        | ThreadListRequest
        | ThreadLoadedListRequest
        | ThreadReadRequest
        | SkillsListRequest
        | PluginListRequest
        | PluginReadRequest
        | AppListRequest
        | FsReadFileRequest
        | FsWriteFileRequest
        | FsCreateDirectoryRequest
        | FsGetMetadataRequest
        | FsReadDirectoryRequest
        | FsRemoveRequest
        | FsCopyRequest
        | SkillsConfigWriteRequest
        | PluginInstallRequest
        | PluginUninstallRequest
        | TurnStartRequest
        | TurnSteerRequest
        | TurnInterruptRequest
        | ReviewStartRequest
        | ModelListRequest
        | ExperimentalFeatureListRequest
        | McpServerOauthLoginRequest
        | ConfigMcpServerReloadRequest
        | McpServerStatusListRequest
        | WindowsSandboxSetupStartRequest
        | AccountLoginStartRequest
        | AccountLoginCancelRequest
        | AccountLogoutRequest
        | AccountRateLimitsReadRequest
        | FeedbackUploadRequest
        | CommandExecRequest
        | CommandExecWriteRequest
        | CommandExecTerminateRequest
        | CommandExecResizeRequest
        | ConfigReadRequest
        | ExternalAgentConfigDetectRequest
        | ExternalAgentConfigImportRequest
        | ConfigValueWriteRequest
        | ConfigBatchWriteRequest
        | ConfigRequirementsReadRequest
        | AccountReadRequest
        | FuzzyFileSearchRequest,
        Field(
            description="Request from the client to the server.", title="ClientRequest"
        ),
    ]


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
    compact_prompt: str | None = None
    developer_instructions: str | None = None
    forced_chatgpt_workspace_id: str | 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_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
    profile: str | None = None
    profiles: dict[str, ProfileV2] | None = {}
    review_model: str | None = None
    sandbox_mode: SandboxMode | None = None
    sandbox_workspace_write: SandboxWorkspaceWrite | None = None
    service_tier: ServiceTier | None = None
    tools: ToolsV2 | None = None
    web_search: WebSearchMode | None = None


class ConfigReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    config: Config
    layers: list[ConfigLayer] | None = None
    origins: dict[str, ConfigLayerMetadata]


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 ThreadStartedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/started"], Field(title="Thread/startedNotificationMethod")
    ]
    params: ThreadStartedNotification


class ServerNotification(
    RootModel[
        ErrorServerNotification
        | ThreadStartedServerNotification
        | ThreadStatusChangedServerNotification
        | ThreadArchivedServerNotification
        | ThreadUnarchivedServerNotification
        | ThreadClosedServerNotification
        | SkillsChangedServerNotification
        | ThreadNameUpdatedServerNotification
        | ThreadTokenUsageUpdatedServerNotification
        | TurnStartedServerNotification
        | HookStartedServerNotification
        | TurnCompletedServerNotification
        | HookCompletedServerNotification
        | TurnDiffUpdatedServerNotification
        | TurnPlanUpdatedServerNotification
        | ItemStartedServerNotification
        | ItemAutoApprovalReviewStartedServerNotification
        | ItemAutoApprovalReviewCompletedServerNotification
        | ItemCompletedServerNotification
        | ItemAgentMessageDeltaServerNotification
        | ItemPlanDeltaServerNotification
        | CommandExecOutputDeltaServerNotification
        | ItemCommandExecutionOutputDeltaServerNotification
        | ItemCommandExecutionTerminalInteractionServerNotification
        | ItemFileChangeOutputDeltaServerNotification
        | ServerRequestResolvedServerNotification
        | ItemMcpToolCallProgressServerNotification
        | McpServerOauthLoginCompletedServerNotification
        | AccountUpdatedServerNotification
        | AccountRateLimitsUpdatedServerNotification
        | AppListUpdatedServerNotification
        | ItemReasoningSummaryTextDeltaServerNotification
        | ItemReasoningSummaryPartAddedServerNotification
        | ItemReasoningTextDeltaServerNotification
        | ThreadCompactedServerNotification
        | ModelReroutedServerNotification
        | DeprecationNoticeServerNotification
        | ConfigWarningServerNotification
        | FuzzyFileSearchSessionUpdatedServerNotification
        | FuzzyFileSearchSessionCompletedServerNotification
        | ThreadRealtimeStartedServerNotification
        | ThreadRealtimeItemAddedServerNotification
        | ThreadRealtimeOutputAudioDeltaServerNotification
        | ThreadRealtimeErrorServerNotification
        | ThreadRealtimeClosedServerNotification
        | WindowsWorldWritableWarningServerNotification
        | WindowsSandboxSetupCompletedServerNotification
        | AccountLoginCompletedServerNotification
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Annotated[
        ErrorServerNotification
        | ThreadStartedServerNotification
        | ThreadStatusChangedServerNotification
        | ThreadArchivedServerNotification
        | ThreadUnarchivedServerNotification
        | ThreadClosedServerNotification
        | SkillsChangedServerNotification
        | ThreadNameUpdatedServerNotification
        | ThreadTokenUsageUpdatedServerNotification
        | TurnStartedServerNotification
        | HookStartedServerNotification
        | TurnCompletedServerNotification
        | HookCompletedServerNotification
        | TurnDiffUpdatedServerNotification
        | TurnPlanUpdatedServerNotification
        | ItemStartedServerNotification
        | ItemAutoApprovalReviewStartedServerNotification
        | ItemAutoApprovalReviewCompletedServerNotification
        | ItemCompletedServerNotification
        | ItemAgentMessageDeltaServerNotification
        | ItemPlanDeltaServerNotification
        | CommandExecOutputDeltaServerNotification
        | ItemCommandExecutionOutputDeltaServerNotification
        | ItemCommandExecutionTerminalInteractionServerNotification
        | ItemFileChangeOutputDeltaServerNotification
        | ServerRequestResolvedServerNotification
        | ItemMcpToolCallProgressServerNotification
        | McpServerOauthLoginCompletedServerNotification
        | AccountUpdatedServerNotification
        | AccountRateLimitsUpdatedServerNotification
        | AppListUpdatedServerNotification
        | ItemReasoningSummaryTextDeltaServerNotification
        | ItemReasoningSummaryPartAddedServerNotification
        | ItemReasoningTextDeltaServerNotification
        | ThreadCompactedServerNotification
        | ModelReroutedServerNotification
        | DeprecationNoticeServerNotification
        | ConfigWarningServerNotification
        | FuzzyFileSearchSessionUpdatedServerNotification
        | FuzzyFileSearchSessionCompletedServerNotification
        | ThreadRealtimeStartedServerNotification
        | ThreadRealtimeItemAddedServerNotification
        | ThreadRealtimeOutputAudioDeltaServerNotification
        | ThreadRealtimeErrorServerNotification
        | ThreadRealtimeClosedServerNotification
        | WindowsWorldWritableWarningServerNotification
        | WindowsSandboxSetupCompletedServerNotification
        | AccountLoginCompletedServerNotification,
        Field(
            description="Notification sent from the server to the client.",
            title="ServerNotification",
        ),
    ]
