# 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 AmazonBedrockAccount(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["amazonBedrock"], Field(title="AmazonBedrockAccountType")]


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 ActivePermissionProfile(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    extends: Annotated[
        str | None,
        Field(
            description="Parent profile identifier from the selected permissions profile's `extends` setting, when present."
        ),
    ] = None
    id: Annotated[
        str,
        Field(
            description="Identifier from `default_permissions` or the implicit built-in default, such as `:workspace` or a user-defined `[permissions.<id>]` profile."
        ),
    ]


class AddCreditsNudgeCreditType(Enum):
    credits = "credits"
    usage_limit = "usage_limit"


class AddCreditsNudgeEmailStatus(Enum):
    sent = "sent"
    cooldown_active = "cooldown_active"


class AdditionalContextKind(Enum):
    untrusted = "untrusted"
    application = "application"


class AdditionalNetworkPermissions(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    enabled: bool | None = None


class 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 AgentPath(RootModel[str]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: str


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
    needs_auth: Annotated[bool, Field(alias="needsAuth")]


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"
    auto_review = "auto_review"
    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"
    agent_identity = "agentIdentity"


class AutoCompactTokenLimitScope(Enum):
    total = "total"
    body_after_prefix = "body_after_prefix"


class AutoReviewDecisionSource(RootModel[Literal["agent"]]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Annotated[
        Literal["agent"],
        Field(
            description="[UNSTABLE] Source that produced a terminal approval auto-review decision."
        ),
    ]


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"
    cyber_policy = "cyberPolicy"
    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 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: AbsolutePathBuf
    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 CommandExecutionSource(Enum):
    agent = "agent"
    user_shell = "userShell"
    unified_exec_startup = "unifiedExecStartup"
    unified_exec_interaction = "unifiedExecInteraction"


class CommandExecutionStatus(Enum):
    in_progress = "inProgress"
    completed = "completed"
    failed = "failed"
    declined = "declined"


class CommandMigration(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str


class ComputerUseRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    allow_locked_computer_use: Annotated[bool | None, Field(alias="allowLockedComputerUse")] = None


class MdmConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    domain: str
    key: str
    type: Annotated[Literal["mdm"], Field(title="MdmConfigLayerSourceType")]


class SystemConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    file: Annotated[
        AbsolutePathBuf,
        Field(
            description="This is the path to the system config.toml file, though it is not guaranteed to exist."
        ),
    ]
    type: Annotated[Literal["system"], Field(title="SystemConfigLayerSourceType")]


class EnterpriseManagedConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: Annotated[str, Field(description="Stable identifier for the delivered layer.")]
    name: Annotated[
        str,
        Field(
            description="Admin-facing name for the delivered layer. This is surfaced in diagnostics so users know which cloud layer needs administrator attention."
        ),
    ]
    type: Annotated[
        Literal["enterpriseManaged"], Field(title="EnterpriseManagedConfigLayerSourceType")
    ]


class UserConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    file: Annotated[
        AbsolutePathBuf,
        Field(
            description="This is the path to the user's config.toml file, though it is not guaranteed to exist."
        ),
    ]
    profile: Annotated[
        str | None,
        Field(
            description="Name of the selected profile-v2 config layered on top of the base user config, when this layer represents one."
        ),
    ] = None
    type: Annotated[Literal["user"], Field(title="UserConfigLayerSourceType")]


class ProjectConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    dot_codex_folder: Annotated[AbsolutePathBuf, Field(alias="dotCodexFolder")]
    type: Annotated[Literal["project"], Field(title="ProjectConfigLayerSourceType")]


class SessionFlagsConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["sessionFlags"], Field(title="SessionFlagsConfigLayerSourceType")]


class LegacyManagedConfigTomlFromFileConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    file: AbsolutePathBuf
    type: Annotated[
        Literal["legacyManagedConfigTomlFromFile"],
        Field(title="LegacyManagedConfigTomlFromFileConfigLayerSourceType"),
    ]


class LegacyManagedConfigTomlFromMdmConfigLayerSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[
        Literal["legacyManagedConfigTomlFromMdm"],
        Field(title="LegacyManagedConfigTomlFromMdmConfigLayerSourceType"),
    ]


class ConfigLayerSource(
    RootModel[
        MdmConfigLayerSource
        | SystemConfigLayerSource
        | EnterpriseManagedConfigLayerSource
        | UserConfigLayerSource
        | ProjectConfigLayerSource
        | SessionFlagsConfigLayerSource
        | LegacyManagedConfigTomlFromFileConfigLayerSource
        | LegacyManagedConfigTomlFromMdmConfigLayerSource
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: (
        MdmConfigLayerSource
        | SystemConfigLayerSource
        | EnterpriseManagedConfigLayerSource
        | UserConfigLayerSource
        | ProjectConfigLayerSource
        | SessionFlagsConfigLayerSource
        | LegacyManagedConfigTomlFromFileConfigLayerSource
        | LegacyManagedConfigTomlFromMdmConfigLayerSource
    )


class ConfigReadParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: Annotated[
        str | None,
        Field(
            description="Optional working directory to resolve project config layers. If specified, return the effective config as seen from that directory (i.e., including any project layers between `cwd` and the project/repo root)."
        ),
    ] = None
    include_layers: Annotated[bool | None, Field(alias="includeLayers")] = None


class CommandConfiguredHookHandler(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    async_: Annotated[bool, Field(alias="async")]
    command: str
    command_windows: Annotated[str | None, Field(alias="commandWindows")] = None
    status_message: Annotated[str | None, Field(alias="statusMessage")] = None
    timeout_sec: Annotated[int | None, Field(alias="timeoutSec", ge=0)] = None
    type: Annotated[Literal["command"], Field(title="CommandConfiguredHookHandlerType")]


class PromptConfiguredHookHandler(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["prompt"], Field(title="PromptConfiguredHookHandlerType")]


class AgentConfiguredHookHandler(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["agent"], Field(title="AgentConfiguredHookHandlerType")]


class ConfiguredHookHandler(
    RootModel[
        CommandConfiguredHookHandler | PromptConfiguredHookHandler | AgentConfiguredHookHandler
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: CommandConfiguredHookHandler | PromptConfiguredHookHandler | AgentConfiguredHookHandler


class ConfiguredHookMatcherGroup(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    hooks: list[ConfiguredHookHandler]
    matcher: str | None = None


class InputTextContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    text: str
    type: Annotated[Literal["input_text"], Field(title="InputTextContentItemType")]


class OutputTextContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    text: str
    type: Annotated[Literal["output_text"], Field(title="OutputTextContentItemType")]


class ContextCompactedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class 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
    namespace: str | None = None


class ExperimentalFeatureEnablementSetParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    enablement: Annotated[
        dict[str, bool],
        Field(
            description="Process-wide runtime feature enablement keyed by canonical feature name.\n\nOnly named features are updated. Omitted features are left unchanged. Send an empty map for a no-op."
        ),
    ]


class ExperimentalFeatureEnablementSetResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    enablement: Annotated[
        dict[str, bool], Field(description="Feature enablement entries updated by this request.")
    ]


class ExperimentalFeatureListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cursor: Annotated[
        str | None, Field(description="Opaque pagination cursor returned by a previous call.")
    ] = None
    limit: Annotated[
        int | None,
        Field(description="Optional page size; defaults to a reasonable server-side value.", ge=0),
    ] = None
    thread_id: Annotated[
        str | None,
        Field(
            alias="threadId",
            description="Optional loaded thread id. Pass this when showing feature state for an existing thread so enablement is computed from that thread's refreshed config, including project-local config for the thread's cwd.",
        ),
    ] = None


class ExperimentalFeatureStage(Enum):
    beta = "beta"
    under_development = "underDevelopment"
    stable = "stable"
    deprecated = "deprecated"
    removed = "removed"


class ExternalAgentConfigDetectParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwds: Annotated[
        list[str] | None,
        Field(description="Zero or more working directories to include for repo-scoped detection."),
    ] = None
    include_home: Annotated[
        bool | None,
        Field(
            alias="includeHome",
            description="If true, include detection under the user's home (~/.claude, ~/.codex, etc.).",
        ),
    ] = None


class ExternalAgentConfigImportCompletedNotification(BaseModel):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ExternalAgentConfigImportResponse(BaseModel):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ExternalAgentConfigMigrationItemType(Enum):
    agents_md = "AGENTS_MD"
    config = "CONFIG"
    skills = "SKILLS"
    plugins = "PLUGINS"
    mcp_server_config = "MCP_SERVER_CONFIG"
    subagents = "SUBAGENTS"
    hooks = "HOOKS"
    commands = "COMMANDS"
    sessions = "SESSIONS"


class FeedbackUploadParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    classification: str
    extra_log_files: Annotated[list[str] | None, Field(alias="extraLogFiles")] = None
    include_logs: Annotated[bool | None, Field(alias="includeLogs")] = None
    reason: str | None = None
    tags: dict[str, Any] | None = None
    thread_id: Annotated[str | None, Field(alias="threadId")] = None


class FeedbackUploadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class FileChangeOutputDeltaNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    delta: str
    item_id: Annotated[str, Field(alias="itemId")]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class FileSystemAccessMode(Enum):
    read = "read"
    write = "write"
    deny = "deny"


class PathFileSystemPath(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: AbsolutePathBuf
    type: Annotated[Literal["path"], Field(title="PathFileSystemPathType")]


class GlobPatternFileSystemPath(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    pattern: str
    type: Annotated[Literal["glob_pattern"], Field(title="GlobPatternFileSystemPathType")]


class RootFileSystemSpecialPath(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    kind: Literal["root"]


class MinimalFileSystemSpecialPath(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    kind: Literal["minimal"]


class KindFileSystemSpecialPath(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    kind: Literal["project_roots"]
    subpath: str | None = None


class TmpdirFileSystemSpecialPath(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    kind: Literal["tmpdir"]


class SlashTmpFileSystemSpecialPath(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    kind: Literal["slash_tmp"]


class FileSystemSpecialPath1(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    kind: Literal["unknown"]
    path: str
    subpath: str | None = None


class FileSystemSpecialPath(
    RootModel[
        RootFileSystemSpecialPath
        | MinimalFileSystemSpecialPath
        | KindFileSystemSpecialPath
        | TmpdirFileSystemSpecialPath
        | SlashTmpFileSystemSpecialPath
        | FileSystemSpecialPath1
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: (
        RootFileSystemSpecialPath
        | MinimalFileSystemSpecialPath
        | KindFileSystemSpecialPath
        | TmpdirFileSystemSpecialPath
        | SlashTmpFileSystemSpecialPath
        | FileSystemSpecialPath1
    )


class ForcedChatgptWorkspaceIds(RootModel[str | list[str]]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Annotated[
        str | list[str],
        Field(
            description="Backward-compatible API shape for ChatGPT workspace login restrictions."
        ),
    ]


class ForcedLoginMethod(Enum):
    chatgpt = "chatgpt"
    api = "api"


class FsChangedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    changed_paths: Annotated[
        list[AbsolutePathBuf],
        Field(
            alias="changedPaths", description="File or directory paths associated with this event."
        ),
    ]
    watch_id: Annotated[
        str,
        Field(alias="watchId", description="Watch identifier previously provided to `fs/watch`."),
    ]


class FsCopyParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    destination_path: Annotated[
        AbsolutePathBuf, Field(alias="destinationPath", description="Absolute destination path.")
    ]
    recursive: Annotated[
        bool | None, Field(description="Required for directory copies; ignored for file copies.")
    ] = None
    source_path: Annotated[
        AbsolutePathBuf, Field(alias="sourcePath", description="Absolute source path.")
    ]


class FsCopyResponse(BaseModel):
    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 resolves to a directory.")
    ]
    is_file: Annotated[
        bool, Field(alias="isFile", description="Whether the path resolves to a regular file.")
    ]
    is_symlink: Annotated[
        bool, Field(alias="isSymlink", description="Whether the path itself is a symbolic link.")
    ]
    modified_at_ms: Annotated[
        int,
        Field(
            alias="modifiedAtMs",
            description="File modification time in Unix milliseconds when available, otherwise `0`.",
        ),
    ]


class FsReadDirectoryEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    file_name: Annotated[
        str,
        Field(
            alias="fileName",
            description="Direct child entry name only, not an absolute or relative path.",
        ),
    ]
    is_directory: Annotated[
        bool, Field(alias="isDirectory", description="Whether this entry resolves to a directory.")
    ]
    is_file: Annotated[
        bool, Field(alias="isFile", description="Whether this entry resolves to a regular file.")
    ]


class FsReadDirectoryParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: Annotated[AbsolutePathBuf, Field(description="Absolute directory path to read.")]


class FsReadDirectoryResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    entries: Annotated[
        list[FsReadDirectoryEntry],
        Field(description="Direct child entries in the requested directory."),
    ]


class FsReadFileParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: Annotated[AbsolutePathBuf, Field(description="Absolute path to read.")]


class FsReadFileResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data_base64: Annotated[
        str, Field(alias="dataBase64", description="File contents encoded as base64.")
    ]


class FsRemoveParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    force: Annotated[
        bool | None,
        Field(description="Whether missing paths should be ignored. Defaults to `true`."),
    ] = None
    path: Annotated[AbsolutePathBuf, Field(description="Absolute path to remove.")]
    recursive: Annotated[
        bool | None,
        Field(description="Whether directory removal should recurse. Defaults to `true`."),
    ] = None


class FsRemoveResponse(BaseModel):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class FsUnwatchParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    watch_id: Annotated[
        str,
        Field(alias="watchId", description="Watch identifier previously provided to `fs/watch`."),
    ]


class FsUnwatchResponse(BaseModel):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class FsWatchParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: Annotated[AbsolutePathBuf, Field(description="Absolute file or directory path to watch.")]
    watch_id: Annotated[
        str,
        Field(
            alias="watchId",
            description="Connection-scoped watch identifier used for `fs/unwatch` and `fs/changed`.",
        ),
    ]


class FsWatchResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: Annotated[
        AbsolutePathBuf, Field(description="Canonicalized path associated with the watch.")
    ]


class FsWriteFileParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data_base64: Annotated[
        str, Field(alias="dataBase64", description="File contents encoded as base64.")
    ]
    path: Annotated[AbsolutePathBuf, Field(description="Absolute path to write.")]


class FsWriteFileResponse(BaseModel):
    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 EncryptedContentFunctionCallOutputContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    encrypted_content: str
    type: Annotated[
        Literal["encrypted_content"],
        Field(title="EncryptedContentFunctionCallOutputContentItemType"),
    ]


class FuzzyFileSearchMatchType(Enum):
    file = "file"
    directory = "directory"


class FuzzyFileSearchParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cancellation_token: Annotated[str | None, Field(alias="cancellationToken")] = None
    query: str
    roots: list[str]


class Indice(RootModel[int]):
    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
    match_type: FuzzyFileSearchMatchType
    path: str
    root: str
    score: Annotated[int, Field(ge=0)]


class FuzzyFileSearchSessionCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    session_id: Annotated[str, Field(alias="sessionId")]


class FuzzyFileSearchSessionUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    files: list[FuzzyFileSearchResult]
    query: str
    session_id: Annotated[str, Field(alias="sessionId")]


class GetAccountParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    refresh_token: Annotated[
        bool | None,
        Field(
            alias="refreshToken",
            description="When `true`, requests a proactive token refresh before returning.\n\nIn managed auth mode this triggers the normal refresh-token flow. In external auth mode this flag is ignored. Clients should refresh tokens themselves and call `account/login/start` with `chatgptAuthTokens`.",
        ),
    ] = None


class GitInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    branch: str | None = None
    origin_url: Annotated[str | None, Field(alias="originUrl")] = None
    sha: str | None = None


class ApplyPatchGuardianApprovalReviewAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: AbsolutePathBuf
    files: list[AbsolutePathBuf]
    type: Annotated[
        Literal["applyPatch"], Field(title="ApplyPatchGuardianApprovalReviewActionType")
    ]


class McpToolCallGuardianApprovalReviewAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    connector_id: Annotated[str | None, Field(alias="connectorId")] = None
    connector_name: Annotated[str | None, Field(alias="connectorName")] = None
    server: str
    tool_name: Annotated[str, Field(alias="toolName")]
    tool_title: Annotated[str | None, Field(alias="toolTitle")] = None
    type: Annotated[
        Literal["mcpToolCall"], Field(title="McpToolCallGuardianApprovalReviewActionType")
    ]


class GuardianApprovalReviewStatus(Enum):
    in_progress = "inProgress"
    approved = "approved"
    denied = "denied"
    timed_out = "timedOut"
    aborted = "aborted"


class GuardianCommandSource(Enum):
    shell = "shell"
    unified_exec = "unifiedExec"


class GuardianRiskLevel(Enum):
    low = "low"
    medium = "medium"
    high = "high"
    critical = "critical"


class GuardianUserAuthorization(Enum):
    unknown = "unknown"
    low = "low"
    medium = "medium"
    high = "high"


class GuardianWarningNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message: Annotated[str, Field(description="Concise guardian warning message for the user.")]
    thread_id: Annotated[
        str, Field(alias="threadId", description="Thread target for the guardian warning.")
    ]


class HookErrorInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message: str
    path: str


class HookEventName(Enum):
    pre_tool_use = "preToolUse"
    permission_request = "permissionRequest"
    post_tool_use = "postToolUse"
    pre_compact = "preCompact"
    post_compact = "postCompact"
    session_start = "sessionStart"
    user_prompt_submit = "userPromptSubmit"
    subagent_start = "subagentStart"
    subagent_stop = "subagentStop"
    stop = "stop"


class HookExecutionMode(Enum):
    sync = "sync"
    async_ = "async"


class HookHandlerType(Enum):
    command = "command"
    prompt = "prompt"
    agent = "agent"


class HookMigration(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str


class HookOutputEntryKind(Enum):
    warning = "warning"
    stop = "stop"
    feedback = "feedback"
    context = "context"
    error = "error"


class HookPromptFragment(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    hook_run_id: Annotated[str, Field(alias="hookRunId")]
    text: str


class HookRunStatus(Enum):
    running = "running"
    completed = "completed"
    failed = "failed"
    blocked = "blocked"
    stopped = "stopped"


class HookScope(Enum):
    thread = "thread"
    turn = "turn"


class HookSource(Enum):
    system = "system"
    user = "user"
    project = "project"
    mdm = "mdm"
    session_flags = "sessionFlags"
    plugin = "plugin"
    cloud_requirements = "cloudRequirements"
    cloud_managed_config = "cloudManagedConfig"
    legacy_managed_config_file = "legacyManagedConfigFile"
    legacy_managed_config_mdm = "legacyManagedConfigMdm"
    unknown = "unknown"


class HookTrustStatus(Enum):
    managed = "managed"
    untrusted = "untrusted"
    trusted = "trusted"
    modified = "modified"


class HooksListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwds: Annotated[
        list[str] | None,
        Field(description="When empty, defaults to the current session working directory."),
    ] = None


class ImageDetail(Enum):
    auto = "auto"
    low = "low"
    high = "high"
    original = "original"


class 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
    request_attestation: Annotated[
        bool | None,
        Field(
            alias="requestAttestation",
            description="Opt into `attestation/generate` requests for upstream `x-oai-attestation`.",
        ),
    ] = False


class InitializeParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    capabilities: InitializeCapabilities | None = None
    client_info: Annotated[ClientInfo, Field(alias="clientInfo")]


class InputModality(Enum):
    text = "text"
    image = "image"


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,
    )
    codex_streamlined_login: Annotated[bool | None, Field(alias="codexStreamlinedLogin")] = None
    type: Annotated[Literal["chatgpt"], Field(title="Chatgptv2::LoginAccountParamsType")]


class ChatgptDeviceCodeLoginAccountParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[
        Literal["chatgptDeviceCode"], Field(title="ChatgptDeviceCodev2::LoginAccountParamsType")
    ]


class ChatgptAuthTokensLoginAccountParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    access_token: Annotated[
        str,
        Field(
            alias="accessToken",
            description="Access token (JWT) supplied by the client. This token is used for backend API requests and email extraction.",
        ),
    ]
    chatgpt_account_id: Annotated[
        str,
        Field(
            alias="chatgptAccountId",
            description="Workspace/account identifier supplied by the client.",
        ),
    ]
    chatgpt_plan_type: Annotated[
        str | None,
        Field(
            alias="chatgptPlanType",
            description="Optional plan type supplied by the client.\n\nWhen `null`, Codex attempts to derive the plan type from access-token claims. If unavailable, the plan defaults to `unknown`.",
        ),
    ] = None
    type: Annotated[
        Literal["chatgptAuthTokens"], Field(title="ChatgptAuthTokensv2::LoginAccountParamsType")
    ]


class LoginAccountParams(
    RootModel[
        ApiKeyLoginAccountParams
        | ChatgptLoginAccountParams
        | ChatgptDeviceCodeLoginAccountParams
        | ChatgptAuthTokensLoginAccountParams
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Annotated[
        ApiKeyLoginAccountParams
        | ChatgptLoginAccountParams
        | ChatgptDeviceCodeLoginAccountParams
        | 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 ChatgptDeviceCodeLoginAccountResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    login_id: Annotated[str, Field(alias="loginId")]
    type: Annotated[
        Literal["chatgptDeviceCode"], Field(title="ChatgptDeviceCodev2::LoginAccountResponseType")
    ]
    user_code: Annotated[
        str,
        Field(alias="userCode", description="One-time code the user must enter after signing in."),
    ]
    verification_url: Annotated[
        str,
        Field(
            alias="verificationUrl",
            description="URL the client should open in a browser to complete device code authorization.",
        ),
    ]


class ChatgptAuthTokensLoginAccountResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[
        Literal["chatgptAuthTokens"], Field(title="ChatgptAuthTokensv2::LoginAccountResponseType")
    ]


class LoginAccountResponse(
    RootModel[
        ApiKeyLoginAccountResponse
        | ChatgptLoginAccountResponse
        | ChatgptDeviceCodeLoginAccountResponse
        | ChatgptAuthTokensLoginAccountResponse
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Annotated[
        ApiKeyLoginAccountResponse
        | ChatgptLoginAccountResponse
        | ChatgptDeviceCodeLoginAccountResponse
        | ChatgptAuthTokensLoginAccountResponse,
        Field(title="LoginAccountResponse"),
    ]


class LogoutAccountResponse(BaseModel):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ManagedHooksRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    permission_request: Annotated[
        list[ConfiguredHookMatcherGroup], Field(alias="PermissionRequest")
    ]
    post_compact: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="PostCompact")]
    post_tool_use: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="PostToolUse")]
    pre_compact: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="PreCompact")]
    pre_tool_use: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="PreToolUse")]
    session_start: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="SessionStart")]
    stop: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="Stop")]
    subagent_start: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="SubagentStart")]
    subagent_stop: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="SubagentStop")]
    user_prompt_submit: Annotated[list[ConfiguredHookMatcherGroup], Field(alias="UserPromptSubmit")]
    managed_dir: Annotated[str | None, Field(alias="managedDir")] = None
    windows_managed_dir: Annotated[str | None, Field(alias="windowsManagedDir")] = None


class MarketplaceAddParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    ref_name: Annotated[str | None, Field(alias="refName")] = None
    source: str
    sparse_paths: Annotated[list[str] | None, Field(alias="sparsePaths")] = None


class MarketplaceAddResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    already_added: Annotated[bool, Field(alias="alreadyAdded")]
    installed_root: Annotated[AbsolutePathBuf, Field(alias="installedRoot")]
    marketplace_name: Annotated[str, Field(alias="marketplaceName")]


class MarketplaceInterface(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    display_name: Annotated[str | None, Field(alias="displayName")] = None


class MarketplaceLoadErrorInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_path: Annotated[AbsolutePathBuf, Field(alias="marketplacePath")]
    message: str


class MarketplaceRemoveParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_name: Annotated[str, Field(alias="marketplaceName")]


class MarketplaceRemoveResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    installed_root: Annotated[AbsolutePathBuf | None, Field(alias="installedRoot")] = None
    marketplace_name: Annotated[str, Field(alias="marketplaceName")]


class MarketplaceUpgradeErrorInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_name: Annotated[str, Field(alias="marketplaceName")]
    message: str


class MarketplaceUpgradeParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_name: Annotated[str | None, Field(alias="marketplaceName")] = None


class MarketplaceUpgradeResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    errors: list[MarketplaceUpgradeErrorInfo]
    selected_marketplaces: Annotated[list[str], Field(alias="selectedMarketplaces")]
    upgraded_roots: Annotated[list[AbsolutePathBuf], Field(alias="upgradedRoots")]


class McpAuthStatus(Enum):
    unsupported = "unsupported"
    not_logged_in = "notLoggedIn"
    bearer_token = "bearerToken"
    o_auth = "oAuth"


class McpResourceReadParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    server: str
    thread_id: Annotated[str | None, Field(alias="threadId")] = None
    uri: str


class McpServerInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    description: str | None = None
    icons: list | None = None
    name: str
    title: str | None = None
    version: str
    website_url: Annotated[str | None, Field(alias="websiteUrl")] = None


class McpServerMigration(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str


class 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 McpServerStartupState(Enum):
    starting = "starting"
    ready = "ready"
    failed = "failed"
    cancelled = "cancelled"


class McpServerStatusDetail(Enum):
    full = "full"
    tools_and_auth_only = "toolsAndAuthOnly"


class McpServerStatusUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    error: str | None = None
    name: str
    status: McpServerStartupState


class McpServerToolCallParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    field_meta: Annotated[Any | None, Field(alias="_meta")] = None
    arguments: Any | None = None
    server: str
    thread_id: Annotated[str, Field(alias="threadId")]
    tool: str


class McpServerToolCallResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    field_meta: Annotated[Any | None, Field(alias="_meta")] = None
    content: list
    is_error: Annotated[bool | None, Field(alias="isError")] = None
    structured_content: Annotated[Any | None, Field(alias="structuredContent")] = None


class McpToolCallError(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message: str


class McpToolCallProgressNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item_id: Annotated[str, Field(alias="itemId")]
    message: str
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class McpToolCallResult(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    field_meta: Annotated[Any | None, Field(alias="_meta")] = None
    content: list
    structured_content: Annotated[Any | None, Field(alias="structuredContent")] = None


class McpToolCallStatus(Enum):
    in_progress = "inProgress"
    completed = "completed"
    failed = "failed"


class MemoryCitationEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    line_end: Annotated[int, Field(alias="lineEnd", ge=0)]
    line_start: Annotated[int, Field(alias="lineStart", ge=0)]
    note: str
    path: str


class MergeStrategy(Enum):
    replace = "replace"
    upsert = "upsert"


class MessagePhase(Enum):
    commentary = "commentary"
    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 ModelProviderCapabilitiesReadParams(BaseModel):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ModelProviderCapabilitiesReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    image_generation: Annotated[bool, Field(alias="imageGeneration")]
    namespace_tools: Annotated[bool, Field(alias="namespaceTools")]
    web_search: Annotated[bool, Field(alias="webSearch")]


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 ModelServiceTier(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    description: str
    id: str
    name: str


class ModelUpgradeInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    migration_markdown: Annotated[str | None, Field(alias="migrationMarkdown")] = None
    model: str
    model_link: Annotated[str | None, Field(alias="modelLink")] = None
    upgrade_copy: Annotated[str | None, Field(alias="upgradeCopy")] = None


class ModelVerification(RootModel[Literal["trustedAccessForCyber"]]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Literal["trustedAccessForCyber"]


class ModelVerificationNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]
    verifications: list[ModelVerification]


class NetworkAccess(Enum):
    restricted = "restricted"
    enabled = "enabled"


class NetworkApprovalProtocol(Enum):
    http = "http"
    https = "https"
    socks5_tcp = "socks5Tcp"
    socks5_udp = "socks5Udp"


class NetworkDomainPermission(Enum):
    allow = "allow"
    deny = "deny"


class NetworkRequirements(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    allow_local_binding: Annotated[bool | None, Field(alias="allowLocalBinding")] = None
    allow_unix_sockets: Annotated[
        list[str] | None,
        Field(
            alias="allowUnixSockets",
            description="Legacy compatibility view derived from `unix_sockets`.",
        ),
    ] = None
    allow_upstream_proxy: Annotated[bool | None, Field(alias="allowUpstreamProxy")] = None
    allowed_domains: Annotated[
        list[str] | None,
        Field(
            alias="allowedDomains", description="Legacy compatibility view derived from `domains`."
        ),
    ] = None
    dangerously_allow_all_unix_sockets: Annotated[
        bool | None, Field(alias="dangerouslyAllowAllUnixSockets")
    ] = None
    dangerously_allow_non_loopback_proxy: Annotated[
        bool | None, Field(alias="dangerouslyAllowNonLoopbackProxy")
    ] = None
    denied_domains: Annotated[
        list[str] | None,
        Field(
            alias="deniedDomains", description="Legacy compatibility view derived from `domains`."
        ),
    ] = None
    domains: Annotated[
        dict[str, Any] | None,
        Field(description="Canonical network permission map for `experimental_network`."),
    ] = None
    enabled: bool | None = None
    http_port: Annotated[int | None, Field(alias="httpPort", ge=0)] = None
    managed_allowed_domains_only: Annotated[
        bool | None,
        Field(
            alias="managedAllowedDomainsOnly",
            description="When true, only managed allowlist entries are respected while managed network enforcement is active.",
        ),
    ] = None
    socks_port: Annotated[int | None, Field(alias="socksPort", ge=0)] = None
    unix_sockets: Annotated[
        dict[str, Any] | None,
        Field(
            alias="unixSockets",
            description="Canonical unix socket permission map for `experimental_network`.",
        ),
    ] = None


class NetworkUnixSocketPermission(Enum):
    allow = "allow"
    deny = "deny"


class NonSteerableTurnKind(Enum):
    review = "review"
    compact = "compact"


class 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 PermissionProfileListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cursor: Annotated[
        str | None, Field(description="Opaque pagination cursor returned by a previous call.")
    ] = None
    cwd: Annotated[
        str | None,
        Field(description="Optional working directory to resolve project config layers."),
    ] = None
    limit: Annotated[
        int | None, Field(description="Optional page size; defaults to the full result set.", ge=0)
    ] = None


class PermissionProfileSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    description: Annotated[
        str | None, Field(description="Optional user-facing description for display in clients.")
    ] = None
    id: Annotated[str, Field(description="Available permission profile identifier.")]


class Personality(Enum):
    none = "none"
    friendly = "friendly"
    pragmatic = "pragmatic"


class PlanDeltaNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    delta: str
    item_id: Annotated[str, Field(alias="itemId")]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class PlanType(Enum):
    free = "free"
    go = "go"
    plus = "plus"
    pro = "pro"
    prolite = "prolite"
    team = "team"
    self_serve_business_usage_based = "self_serve_business_usage_based"
    business = "business"
    enterprise_cbp_usage_based = "enterprise_cbp_usage_based"
    enterprise = "enterprise"
    edu = "edu"
    unknown = "unknown"


class PluginAuthPolicy(Enum):
    on_install = "ON_INSTALL"
    on_use = "ON_USE"


class PluginAvailability(Enum):
    disabled_by_admin = "DISABLED_BY_ADMIN"
    available = "AVAILABLE"


class PluginHookSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    event_name: Annotated[HookEventName, Field(alias="eventName")]
    key: str


class PluginInstallParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_path: Annotated[AbsolutePathBuf | None, Field(alias="marketplacePath")] = None
    plugin_name: Annotated[str, Field(alias="pluginName")]
    remote_marketplace_name: Annotated[str | None, Field(alias="remoteMarketplaceName")] = None


class PluginInstallPolicy(Enum):
    not_available = "NOT_AVAILABLE"
    available = "AVAILABLE"
    installed_by_default = "INSTALLED_BY_DEFAULT"


class PluginInstallResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    apps_needing_auth: Annotated[list[AppSummary], Field(alias="appsNeedingAuth")]
    auth_policy: Annotated[PluginAuthPolicy, Field(alias="authPolicy")]


class PluginInstalledParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwds: Annotated[
        list[AbsolutePathBuf] | None,
        Field(description="Optional working directories used to discover repo marketplaces."),
    ] = None
    install_suggestion_plugin_names: Annotated[
        list[str] | None,
        Field(
            alias="installSuggestionPluginNames",
            description="Additional uninstalled plugin names that should be returned when present locally. This is used by mention surfaces that intentionally expose install entrypoints.",
        ),
    ] = None


class PluginInterface(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    brand_color: Annotated[str | None, Field(alias="brandColor")] = None
    capabilities: list[str]
    category: str | None = None
    composer_icon: Annotated[
        AbsolutePathBuf | None,
        Field(
            alias="composerIcon",
            description="Local composer icon path, resolved from the installed plugin package.",
        ),
    ] = None
    composer_icon_url: Annotated[
        str | None,
        Field(
            alias="composerIconUrl", description="Remote composer icon URL from the plugin catalog."
        ),
    ] = None
    default_prompt: Annotated[
        list[str] | None,
        Field(
            alias="defaultPrompt",
            description="Starter prompts for the plugin. Capped at 3 entries with a maximum of 128 characters per entry.",
        ),
    ] = None
    developer_name: Annotated[str | None, Field(alias="developerName")] = None
    display_name: Annotated[str | None, Field(alias="displayName")] = None
    logo: Annotated[
        AbsolutePathBuf | None,
        Field(description="Local logo path, resolved from the installed plugin package."),
    ] = None
    logo_url: Annotated[
        str | None, Field(alias="logoUrl", description="Remote logo URL from the plugin catalog.")
    ] = None
    long_description: Annotated[str | None, Field(alias="longDescription")] = None
    privacy_policy_url: Annotated[str | None, Field(alias="privacyPolicyUrl")] = None
    screenshot_urls: Annotated[
        list[str],
        Field(
            alias="screenshotUrls", description="Remote screenshot URLs from the plugin catalog."
        ),
    ]
    screenshots: Annotated[
        list[AbsolutePathBuf],
        Field(description="Local screenshot paths, resolved from the installed plugin package."),
    ]
    short_description: Annotated[str | None, Field(alias="shortDescription")] = None
    terms_of_service_url: Annotated[str | None, Field(alias="termsOfServiceUrl")] = None
    website_url: Annotated[str | None, Field(alias="websiteUrl")] = None


class PluginListMarketplaceKind(Enum):
    local = "local"
    vertical = "vertical"
    workspace_directory = "workspace-directory"
    shared_with_me = "shared-with-me"


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
    marketplace_kinds: Annotated[
        list[PluginListMarketplaceKind] | None,
        Field(
            alias="marketplaceKinds",
            description="Optional marketplace kind filter. When omitted, only local marketplaces are queried, plus the default remote catalog when enabled by feature flag.",
        ),
    ] = None


class PluginReadParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_path: Annotated[AbsolutePathBuf | None, Field(alias="marketplacePath")] = None
    plugin_name: Annotated[str, Field(alias="pluginName")]
    remote_marketplace_name: Annotated[str | None, Field(alias="remoteMarketplaceName")] = None


class PluginShareCheckoutParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    remote_plugin_id: Annotated[str, Field(alias="remotePluginId")]


class PluginShareCheckoutResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_name: Annotated[str, Field(alias="marketplaceName")]
    marketplace_path: Annotated[AbsolutePathBuf, Field(alias="marketplacePath")]
    plugin_id: Annotated[str, Field(alias="pluginId")]
    plugin_name: Annotated[str, Field(alias="pluginName")]
    plugin_path: Annotated[AbsolutePathBuf, Field(alias="pluginPath")]
    remote_plugin_id: Annotated[str, Field(alias="remotePluginId")]
    remote_version: Annotated[str | None, Field(alias="remoteVersion")] = None


class PluginShareDeleteParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    remote_plugin_id: Annotated[str, Field(alias="remotePluginId")]


class PluginShareDeleteResponse(BaseModel):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class PluginShareDiscoverability(Enum):
    listed = "LISTED"
    unlisted = "UNLISTED"
    private = "PRIVATE"


class PluginShareListParams(BaseModel):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class PluginSharePrincipalRole(Enum):
    reader = "reader"
    editor = "editor"
    owner = "owner"


class PluginSharePrincipalType(Enum):
    user = "user"
    group = "group"
    workspace = "workspace"


class PluginShareSaveResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    remote_plugin_id: Annotated[str, Field(alias="remotePluginId")]
    share_url: Annotated[str, Field(alias="shareUrl")]


class PluginShareTargetRole(Enum):
    reader = "reader"
    editor = "editor"


class PluginShareUpdateDiscoverability(Enum):
    unlisted = "UNLISTED"
    private = "PRIVATE"


class PluginSkillReadParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    remote_marketplace_name: Annotated[str, Field(alias="remoteMarketplaceName")]
    remote_plugin_id: Annotated[str, Field(alias="remotePluginId")]
    skill_name: Annotated[str, Field(alias="skillName")]


class PluginSkillReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    contents: str | None = None


class LocalPluginSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: AbsolutePathBuf
    type: Annotated[Literal["local"], Field(title="LocalPluginSourceType")]


class GitPluginSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    path: str | None = None
    ref_name: Annotated[str | None, Field(alias="refName")] = None
    sha: str | None = None
    type: Annotated[Literal["git"], Field(title="GitPluginSourceType")]
    url: str


class RemotePluginSource(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["remote"], Field(title="RemotePluginSourceType")]


class PluginSource(RootModel[LocalPluginSource | GitPluginSource | RemotePluginSource]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: LocalPluginSource | GitPluginSource | RemotePluginSource


class PluginUninstallParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    plugin_id: Annotated[str, Field(alias="pluginId")]


class PluginUninstallResponse(BaseModel):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class PluginsMigration(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_name: Annotated[str, Field(alias="marketplaceName")]
    plugin_names: Annotated[list[str], Field(alias="pluginNames")]


class ProcessExitedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    exit_code: Annotated[int, Field(alias="exitCode", description="Process exit code.")]
    process_handle: Annotated[
        str,
        Field(
            alias="processHandle",
            description="Client-supplied, connection-scoped `processHandle` from `process/spawn`.",
        ),
    ]
    stderr: Annotated[
        str,
        Field(
            description="Buffered stderr capture.\n\nEmpty when stderr was streamed via `process/outputDelta`."
        ),
    ]
    stderr_cap_reached: Annotated[
        bool,
        Field(
            alias="stderrCapReached",
            description="Whether stderr reached `outputBytesCap`.\n\nIn streaming mode, stderr is empty and cap state is also reported on the final stderr `process/outputDelta` notification.",
        ),
    ]
    stdout: Annotated[
        str,
        Field(
            description="Buffered stdout capture.\n\nEmpty when stdout was streamed via `process/outputDelta`."
        ),
    ]
    stdout_cap_reached: Annotated[
        bool,
        Field(
            alias="stdoutCapReached",
            description="Whether stdout reached `outputBytesCap`.\n\nIn streaming mode, stdout is empty and cap state is also reported on the final stdout `process/outputDelta` notification.",
        ),
    ]


class ProcessOutputStream(Enum):
    stdout = "stdout"
    stderr = "stderr"


class ProcessTerminalSize(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cols: Annotated[int, Field(description="Terminal width in character cells.", ge=0)]
    rows: Annotated[int, Field(description="Terminal height in character cells.", ge=0)]


class RateLimitReachedType(Enum):
    rate_limit_reached = "rate_limit_reached"
    workspace_owner_credits_depleted = "workspace_owner_credits_depleted"
    workspace_member_credits_depleted = "workspace_member_credits_depleted"
    workspace_owner_usage_limit_reached = "workspace_owner_usage_limit_reached"
    workspace_member_usage_limit_reached = "workspace_member_usage_limit_reached"


class RateLimitWindow(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    resets_at: Annotated[int | None, Field(alias="resetsAt")] = None
    used_percent: Annotated[int, Field(alias="usedPercent")]
    window_duration_mins: Annotated[int | None, Field(alias="windowDurationMins")] = None


class RealtimeConversationVersion(Enum):
    v1 = "v1"
    v2 = "v2"


class RealtimeOutputModality(Enum):
    text = "text"
    audio = "audio"


class RealtimeVoice(Enum):
    alloy = "alloy"
    arbor = "arbor"
    ash = "ash"
    ballad = "ballad"
    breeze = "breeze"
    cedar = "cedar"
    coral = "coral"
    cove = "cove"
    echo = "echo"
    ember = "ember"
    juniper = "juniper"
    maple = "maple"
    marin = "marin"
    sage = "sage"
    shimmer = "shimmer"
    sol = "sol"
    spruce = "spruce"
    vale = "vale"
    verse = "verse"


class RealtimeVoicesList(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    default_v1: Annotated[RealtimeVoice, Field(alias="defaultV1")]
    default_v2: Annotated[RealtimeVoice, Field(alias="defaultV2")]
    v1: list[RealtimeVoice]
    v2: list[RealtimeVoice]


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 RemoteControlConnectionStatus(Enum):
    disabled = "disabled"
    connecting = "connecting"
    connected = "connected"
    errored = "errored"


class RemoteControlStatusChangedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    environment_id: Annotated[str | None, Field(alias="environmentId")] = None
    installation_id: Annotated[str, Field(alias="installationId")]
    server_name: Annotated[str, Field(alias="serverName")]
    status: RemoteControlConnectionStatus


class 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 ResourceContent1(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    field_meta: Annotated[Any | None, Field(alias="_meta")] = None
    mime_type: Annotated[str | None, Field(alias="mimeType")] = None
    text: str
    uri: Annotated[str, Field(description="The URI of this resource.")]


class ResourceContent2(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    field_meta: Annotated[Any | None, Field(alias="_meta")] = None
    blob: str
    mime_type: Annotated[str | None, Field(alias="mimeType")] = None
    uri: Annotated[str, Field(description="The URI of this resource.")]


class ResourceContent(RootModel[ResourceContent1 | ResourceContent2]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Annotated[
        ResourceContent1 | ResourceContent2,
        Field(description="Contents returned when reading a resource from an MCP server."),
    ]


class ResourceTemplate(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    annotations: Any | None = None
    description: str | None = None
    mime_type: Annotated[str | None, Field(alias="mimeType")] = None
    name: str
    title: str | None = None
    uri_template: Annotated[str, Field(alias="uriTemplate")]


class 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 CompactionResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    encrypted_content: str
    type: Annotated[Literal["compaction"], Field(title="CompactionResponseItemType")]


class CompactionTriggerResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["compaction_trigger"], Field(title="CompactionTriggerResponseItemType")]


class ContextCompactionResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    encrypted_content: str | None = None
    type: Annotated[Literal["context_compaction"], Field(title="ContextCompactionResponseItemType")]


class OtherResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["other"], Field(title="OtherResponseItemType")]


class 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,
    )
    network_access: Annotated[bool | None, Field(alias="networkAccess")] = False
    type: Annotated[Literal["readOnly"], Field(title="ReadOnlySandboxPolicyType")]


class ExternalSandboxSandboxPolicy(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    network_access: Annotated[NetworkAccess | None, Field(alias="networkAccess")] = "restricted"
    type: Annotated[Literal["externalSandbox"], Field(title="ExternalSandboxSandboxPolicyType")]


class WorkspaceWriteSandboxPolicy(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    exclude_slash_tmp: Annotated[bool | None, Field(alias="excludeSlashTmp")] = False
    exclude_tmpdir_env_var: Annotated[bool | None, Field(alias="excludeTmpdirEnvVar")] = False
    network_access: Annotated[bool | None, Field(alias="networkAccess")] = False
    type: Annotated[Literal["workspaceWrite"], Field(title="WorkspaceWriteSandboxPolicyType")]
    writable_roots: Annotated[list[AbsolutePathBuf] | None, Field(alias="writableRoots")] = []


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 SendAddCreditsNudgeEmailParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    credit_type: Annotated[AddCreditsNudgeCreditType, Field(alias="creditType")]


class SendAddCreditsNudgeEmailResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    status: AddCreditsNudgeEmailStatus


class 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 ProcessExitedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[Literal["process/exited"], Field(title="Process/exitedNotificationMethod")]
    params: ProcessExitedNotification


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 McpServerStartupStatusUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["mcpServer/startupStatus/updated"],
        Field(title="McpServer/startupStatus/updatedNotificationMethod"),
    ]
    params: McpServerStatusUpdatedNotification


class RemoteControlStatusChangedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["remoteControl/status/changed"],
        Field(title="RemoteControl/status/changedNotificationMethod"),
    ]
    params: RemoteControlStatusChangedNotification


class ExternalAgentConfigImportCompletedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["externalAgentConfig/import/completed"],
        Field(title="ExternalAgentConfig/import/completedNotificationMethod"),
    ]
    params: ExternalAgentConfigImportCompletedNotification


class FsChangedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[Literal["fs/changed"], Field(title="Fs/changedNotificationMethod")]
    params: FsChangedNotification


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 ModelVerificationServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["model/verification"], Field(title="Model/verificationNotificationMethod")
    ]
    params: ModelVerificationNotification


class GuardianWarningServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[Literal["guardianWarning"], Field(title="GuardianWarningNotificationMethod")]
    params: GuardianWarningNotification


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 SessionMigration(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: str
    path: str
    title: str | None = None


class SessionSourceValue(Enum):
    cli = "cli"
    vscode = "vscode"
    exec = "exec"
    app_server = "appServer"
    unknown = "unknown"


class CustomSessionSource(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    custom: str


class Settings(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    developer_instructions: str | None = None
    model: str
    reasoning_effort: ReasoningEffort | None = None


class SkillErrorInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message: str
    path: str


class SkillInterface(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    brand_color: Annotated[str | None, Field(alias="brandColor")] = None
    default_prompt: Annotated[str | None, Field(alias="defaultPrompt")] = None
    display_name: Annotated[str | None, Field(alias="displayName")] = None
    icon_large: Annotated[AbsolutePathBuf | None, Field(alias="iconLarge")] = None
    icon_small: Annotated[AbsolutePathBuf | 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
    enabled: bool
    interface: SkillInterface | None = None
    name: str
    path: AbsolutePathBuf | None = None
    short_description: Annotated[str | None, Field(alias="shortDescription")] = None


class SkillToolDependency(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    command: str | None = None
    description: str | None = None
    transport: str | None = None
    type: str
    url: str | None = None
    value: str


class SkillsChangedNotification(BaseModel):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class SkillsConfigWriteParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    enabled: bool
    name: Annotated[str | None, Field(description="Name-based selector.")] = None
    path: Annotated[AbsolutePathBuf | None, Field(description="Path-based selector.")] = None


class SkillsConfigWriteResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    effective_enabled: Annotated[bool, Field(alias="effectiveEnabled")]


class SkillsExtraRootsSetParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    extra_roots: Annotated[list[AbsolutePathBuf], Field(alias="extraRoots")]


class SkillsExtraRootsSetResponse(BaseModel):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class SkillsListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwds: Annotated[
        list[str] | None,
        Field(description="When empty, defaults to the current session working directory."),
    ] = None
    force_reload: Annotated[
        bool | None,
        Field(
            alias="forceReload",
            description="When true, bypass the skills cache and re-scan skills from disk.",
        ),
    ] = None


class SortDirection(Enum):
    asc = "asc"
    desc = "desc"


class SpendControlLimitSnapshot(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    limit: str
    remaining_percent: Annotated[int, Field(alias="remainingPercent")]
    resets_at: Annotated[int, Field(alias="resetsAt")]
    used: str


class SubAgentSourceValue(Enum):
    review = "review"
    compact = "compact"
    memory_consolidation = "memory_consolidation"


class OtherSubAgentSource(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    other: str


class SubagentMigration(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str


class TerminalInteractionNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item_id: Annotated[str, Field(alias="itemId")]
    process_id: Annotated[str, Field(alias="processId")]
    stdin: str
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class TextElement(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    byte_range: Annotated[
        ByteRange,
        Field(
            alias="byteRange",
            description="Byte range in the parent `text` buffer that this element occupies.",
        ),
    ]
    placeholder: Annotated[
        str | None,
        Field(
            description="Optional human-readable placeholder for the element, displayed in the UI."
        ),
    ] = None


class TextPosition(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    column: Annotated[
        int, Field(description="1-based column number (in Unicode scalar values).", ge=0)
    ]
    line: Annotated[int, Field(description="1-based line number.", ge=0)]


class TextRange(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    end: TextPosition
    start: TextPosition


class ThreadActiveFlag(Enum):
    waiting_on_approval = "waitingOnApproval"
    waiting_on_user_input = "waitingOnUserInput"


class ThreadApproveGuardianDeniedActionParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    event: Annotated[
        Any, Field(description="Serialized `codex_protocol::protocol::GuardianAssessmentEvent`.")
    ]
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadApproveGuardianDeniedActionResponse(BaseModel):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ThreadArchiveParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadArchiveResponse(BaseModel):
    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 ThreadGoalClearParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadGoalClearResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cleared: bool


class ThreadGoalClearedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadGoalGetParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadGoalStatus(Enum):
    active = "active"
    paused = "paused"
    blocked = "blocked"
    usage_limited = "usageLimited"
    budget_limited = "budgetLimited"
    complete = "complete"


class ThreadId(RootModel[str]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: str


class ThreadInjectItemsParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    items: Annotated[
        list,
        Field(
            description="Raw Responses API items to append to the thread's model-visible history."
        ),
    ]
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadInjectItemsResponse(BaseModel):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class HookPromptThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    fragments: list[HookPromptFragment]
    id: str
    type: Annotated[Literal["hookPrompt"], Field(title="HookPromptThreadItemType")]


class PlanThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    text: str
    type: Annotated[Literal["plan"], Field(title="PlanThreadItemType")]


class ReasoningThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    content: list[str] | None = []
    id: str
    summary: list[str] | None = []
    type: Annotated[Literal["reasoning"], Field(title="ReasoningThreadItemType")]


class 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[AbsolutePathBuf, 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
    source: CommandExecutionSource | None = "agent"
    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
    mcp_app_resource_uri: Annotated[str | None, Field(alias="mcpAppResourceUri")] = None
    plugin_id: Annotated[str | None, Field(alias="pluginId")] = None
    result: McpToolCallResult | None = None
    server: str
    status: McpToolCallStatus
    tool: str
    type: Annotated[Literal["mcpToolCall"], Field(title="McpToolCallThreadItemType")]


class DynamicToolCallThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    arguments: Any
    content_items: Annotated[
        list[DynamicToolCallOutputContentItem] | None, Field(alias="contentItems")
    ] = None
    duration_ms: Annotated[
        int | None,
        Field(
            alias="durationMs", description="The duration of the dynamic tool call in milliseconds."
        ),
    ] = None
    id: str
    namespace: str | None = None
    status: DynamicToolCallStatus
    success: bool | None = None
    tool: str
    type: Annotated[Literal["dynamicToolCall"], Field(title="DynamicToolCallThreadItemType")]


class ImageViewThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    path: AbsolutePathBuf
    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
    saved_path: Annotated[AbsolutePathBuf | None, Field(alias="savedPath")] = 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 ThreadListCwdFilter(RootModel[str | list[str]]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: str | list[str]


class ThreadLoadedListParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cursor: Annotated[
        str | None, Field(description="Opaque pagination cursor returned by a previous call.")
    ] = None
    limit: Annotated[
        int | None, Field(description="Optional page size; defaults to no limit.", ge=0)
    ] = None


class ThreadLoadedListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: Annotated[
        list[str], Field(description="Thread ids for sessions currently loaded in memory.")
    ]
    next_cursor: Annotated[
        str | None,
        Field(
            alias="nextCursor",
            description="Opaque cursor to pass to the next call to continue after the last item. if None, there are no more items to return.",
        ),
    ] = None


class ThreadMemoryMode(Enum):
    enabled = "enabled"
    disabled = "disabled"


class ThreadMetadataGitInfoUpdateParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    branch: Annotated[
        str | None,
        Field(
            description="Omit to leave the stored branch unchanged, set to `null` to clear it, or provide a non-empty string to replace it."
        ),
    ] = None
    origin_url: Annotated[
        str | None,
        Field(
            alias="originUrl",
            description="Omit to leave the stored origin URL unchanged, set to `null` to clear it, or provide a non-empty string to replace it.",
        ),
    ] = None
    sha: Annotated[
        str | None,
        Field(
            description="Omit to leave the stored commit unchanged, set to `null` to clear it, or provide a non-empty string to replace it."
        ),
    ] = None


class ThreadMetadataUpdateParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    git_info: Annotated[
        ThreadMetadataGitInfoUpdateParams | None,
        Field(
            alias="gitInfo",
            description="Patch the stored Git metadata for this thread. Omit a field to leave it unchanged, set it to `null` to clear it, or provide a string to replace the stored value.",
        ),
    ] = None
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadNameUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]
    thread_name: Annotated[str | None, Field(alias="threadName")] = None


class 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.",
        ),
    ] = None
    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 ThreadRealtimeSdpNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    sdp: str
    thread_id: Annotated[str, Field(alias="threadId")]


class WebsocketThreadRealtimeStartTransport(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["websocket"], Field(title="WebsocketThreadRealtimeStartTransportType")]


class WebrtcThreadRealtimeStartTransport(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    sdp: Annotated[
        str,
        Field(
            description="SDP offer generated by a WebRTC RTCPeerConnection after configuring audio and the realtime events data channel."
        ),
    ]
    type: Annotated[Literal["webrtc"], Field(title="WebrtcThreadRealtimeStartTransportType")]


class ThreadRealtimeStartTransport(
    RootModel[WebsocketThreadRealtimeStartTransport | WebrtcThreadRealtimeStartTransport]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Annotated[
        WebsocketThreadRealtimeStartTransport | WebrtcThreadRealtimeStartTransport,
        Field(description="EXPERIMENTAL - transport used by thread realtime."),
    ]


class ThreadRealtimeStartedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    realtime_session_id: Annotated[str | None, Field(alias="realtimeSessionId")] = None
    thread_id: Annotated[str, Field(alias="threadId")]
    version: RealtimeConversationVersion


class ThreadRealtimeTranscriptDeltaNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    delta: Annotated[str, Field(description="Live transcript delta from the realtime event.")]
    role: str
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadRealtimeTranscriptDoneNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    role: str
    text: Annotated[str, Field(description="Final complete text for the transcript part.")]
    thread_id: Annotated[str, Field(alias="threadId")]


class 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[str | 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 ThreadShellCommandParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    command: Annotated[
        str,
        Field(
            description="Shell command string evaluated by the thread's configured shell. Unlike `command/exec`, this intentionally preserves shell syntax such as pipes, redirects, and quoting. This runs unsandboxed with full access rather than inheriting the thread sandbox policy."
        ),
    ]
    thread_id: Annotated[str, Field(alias="threadId")]


class ThreadShellCommandResponse(BaseModel):
    pass
    model_config = ConfigDict(
        populate_by_name=True,
    )


class ThreadSortKey(Enum):
    created_at = "created_at"
    updated_at = "updated_at"


class ThreadSource(Enum):
    user = "user"
    subagent = "subagent"
    memory_consolidation = "memory_consolidation"


class ThreadSourceKind(Enum):
    cli = "cli"
    vscode = "vscode"
    exec = "exec"
    app_server = "appServer"
    sub_agent = "subAgent"
    sub_agent_review = "subAgentReview"
    sub_agent_compact = "subAgentCompact"
    sub_agent_thread_spawn = "subAgentThreadSpawn"
    sub_agent_other = "subAgentOther"
    unknown = "unknown"


class ThreadStartSource(Enum):
    startup = "startup"
    clear = "clear"


class NotLoadedThreadStatus(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["notLoaded"], Field(title="NotLoadedThreadStatusType")]


class IdleThreadStatus(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["idle"], Field(title="IdleThreadStatusType")]


class SystemErrorThreadStatus(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["systemError"], Field(title="SystemErrorThreadStatusType")]


class ActiveThreadStatus(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    active_flags: Annotated[list[ThreadActiveFlag], Field(alias="activeFlags")]
    type: Annotated[Literal["active"], Field(title="ActiveThreadStatusType")]


class ThreadStatus(
    RootModel[
        NotLoadedThreadStatus | IdleThreadStatus | SystemErrorThreadStatus | ActiveThreadStatus
    ]
):
    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 TurnEnvironmentParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: AbsolutePathBuf
    environment_id: Annotated[str, Field(alias="environmentId")]


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 TurnItemsView(Enum):
    not_loaded = "notLoaded"
    summary = "summary"
    full = "full"


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,
    )
    detail: ImageDetail | None = None
    type: Annotated[Literal["image"], Field(title="ImageUserInputType")]
    url: str


class LocalImageUserInput(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    detail: ImageDetail | None = None
    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 WarningNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message: Annotated[str, Field(description="Concise warning message for the user.")]
    thread_id: Annotated[
        str | None,
        Field(
            alias="threadId",
            description="Optional thread target when the warning applies to a specific thread.",
        ),
    ] = None


class SearchWebSearchAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    queries: list[str] | None = None
    query: str | None = None
    type: Annotated[Literal["search"], Field(title="SearchWebSearchActionType")]


class OpenPageWebSearchAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["openPage"], Field(title="OpenPageWebSearchActionType")]
    url: str | None = None


class FindInPageWebSearchAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    pattern: str | None = None
    type: Annotated[Literal["findInPage"], Field(title="FindInPageWebSearchActionType")]
    url: str | None = None


class OtherWebSearchAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["other"], Field(title="OtherWebSearchActionType")]


class WebSearchAction(
    RootModel[
        SearchWebSearchAction
        | OpenPageWebSearchAction
        | FindInPageWebSearchAction
        | OtherWebSearchAction
    ]
):
    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 WindowsSandboxReadiness(Enum):
    ready = "ready"
    not_configured = "notConfigured"
    update_required = "updateRequired"


class WindowsSandboxReadinessResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    status: WindowsSandboxReadiness


class WindowsSandboxSetupMode(Enum):
    elevated = "elevated"
    unelevated = "unelevated"


class WindowsSandboxSetupStartParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: AbsolutePathBuf | None = None
    mode: WindowsSandboxSetupMode


class WindowsSandboxSetupStartResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    started: bool


class WindowsWorldWritableWarningNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    extra_count: Annotated[int, Field(alias="extraCount", ge=0)]
    failed_scan: Annotated[bool, Field(alias="failedScan")]
    sample_paths: Annotated[list[str], Field(alias="samplePaths")]


class 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 | AmazonBedrockAccount]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: ApiKeyAccount | ChatgptAccount | AmazonBedrockAccount


class AccountUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    auth_mode: Annotated[AuthMode | None, Field(alias="authMode")] = None
    plan_type: Annotated[PlanType | None, Field(alias="planType")] = None


class AdditionalContextEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    kind: AdditionalContextKind
    value: str


class AppConfig(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approvals_reviewer: ApprovalsReviewer | None = None
    default_tools_approval_mode: AppToolApproval | None = None
    default_tools_enabled: bool | None = None
    destructive_enabled: bool | None = None
    enabled: bool | None = True
    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 ThreadResumeRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/resume"], Field(title="Thread/resumeRequestMethod")]
    params: ThreadResumeParams


class ThreadArchiveRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/archive"], Field(title="Thread/archiveRequestMethod")]
    params: ThreadArchiveParams


class ThreadUnsubscribeRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/unsubscribe"], Field(title="Thread/unsubscribeRequestMethod")]
    params: ThreadUnsubscribeParams


class ThreadNameSetRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/name/set"], Field(title="Thread/name/setRequestMethod")]
    params: ThreadSetNameParams


class ThreadGoalGetRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/goal/get"], Field(title="Thread/goal/getRequestMethod")]
    params: ThreadGoalGetParams


class ThreadGoalClearRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/goal/clear"], Field(title="Thread/goal/clearRequestMethod")]
    params: ThreadGoalClearParams


class 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 ThreadShellCommandRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["thread/shellCommand"], Field(title="Thread/shellCommandRequestMethod")
    ]
    params: ThreadShellCommandParams


class ThreadApproveGuardianDeniedActionRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["thread/approveGuardianDeniedAction"],
        Field(title="Thread/approveGuardianDeniedActionRequestMethod"),
    ]
    params: ThreadApproveGuardianDeniedActionParams


class 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 ThreadInjectItemsRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["thread/inject_items"], Field(title="Thread/injectItemsRequestMethod")
    ]
    params: ThreadInjectItemsParams


class SkillsListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["skills/list"], Field(title="Skills/listRequestMethod")]
    params: SkillsListParams


class SkillsExtraRootsSetRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["skills/extraRoots/set"], Field(title="Skills/extraRoots/setRequestMethod")
    ]
    params: SkillsExtraRootsSetParams


class HooksListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["hooks/list"], Field(title="Hooks/listRequestMethod")]
    params: HooksListParams


class MarketplaceAddRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["marketplace/add"], Field(title="Marketplace/addRequestMethod")]
    params: MarketplaceAddParams


class MarketplaceRemoveRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["marketplace/remove"], Field(title="Marketplace/removeRequestMethod")]
    params: MarketplaceRemoveParams


class MarketplaceUpgradeRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["marketplace/upgrade"], Field(title="Marketplace/upgradeRequestMethod")
    ]
    params: MarketplaceUpgradeParams


class PluginListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/list"], Field(title="Plugin/listRequestMethod")]
    params: PluginListParams


class PluginInstalledRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/installed"], Field(title="Plugin/installedRequestMethod")]
    params: PluginInstalledParams


class PluginReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/read"], Field(title="Plugin/readRequestMethod")]
    params: PluginReadParams


class PluginSkillReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/skill/read"], Field(title="Plugin/skill/readRequestMethod")]
    params: PluginSkillReadParams


class PluginShareListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/share/list"], Field(title="Plugin/share/listRequestMethod")]
    params: PluginShareListParams


class PluginShareCheckoutRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["plugin/share/checkout"], Field(title="Plugin/share/checkoutRequestMethod")
    ]
    params: PluginShareCheckoutParams


class PluginShareDeleteRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["plugin/share/delete"], Field(title="Plugin/share/deleteRequestMethod")
    ]
    params: PluginShareDeleteParams


class 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 FsWatchRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["fs/watch"], Field(title="Fs/watchRequestMethod")]
    params: FsWatchParams


class FsUnwatchRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["fs/unwatch"], Field(title="Fs/unwatchRequestMethod")]
    params: FsUnwatchParams


class SkillsConfigWriteRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["skills/config/write"], Field(title="Skills/config/writeRequestMethod")
    ]
    params: SkillsConfigWriteParams


class PluginInstallRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/install"], Field(title="Plugin/installRequestMethod")]
    params: PluginInstallParams


class PluginUninstallRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/uninstall"], Field(title="Plugin/uninstallRequestMethod")]
    params: PluginUninstallParams


class TurnInterruptRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["turn/interrupt"], Field(title="Turn/interruptRequestMethod")]
    params: TurnInterruptParams


class ModelListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["model/list"], Field(title="Model/listRequestMethod")]
    params: ModelListParams


class ModelProviderCapabilitiesReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["modelProvider/capabilities/read"],
        Field(title="ModelProvider/capabilities/readRequestMethod"),
    ]
    params: ModelProviderCapabilitiesReadParams


class ExperimentalFeatureListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["experimentalFeature/list"], Field(title="ExperimentalFeature/listRequestMethod")
    ]
    params: ExperimentalFeatureListParams


class PermissionProfileListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["permissionProfile/list"], Field(title="PermissionProfile/listRequestMethod")
    ]
    params: PermissionProfileListParams


class ExperimentalFeatureEnablementSetRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["experimentalFeature/enablement/set"],
        Field(title="ExperimentalFeature/enablement/setRequestMethod"),
    ]
    params: ExperimentalFeatureEnablementSetParams


class McpServerOauthLoginRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["mcpServer/oauth/login"], Field(title="McpServer/oauth/loginRequestMethod")
    ]
    params: McpServerOauthLoginParams


class ConfigMcpServerReloadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["config/mcpServer/reload"], Field(title="Config/mcpServer/reloadRequestMethod")
    ]
    params: None = None


class McpServerResourceReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["mcpServer/resource/read"], Field(title="McpServer/resource/readRequestMethod")
    ]
    params: McpResourceReadParams


class McpServerToolCallRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["mcpServer/tool/call"], Field(title="McpServer/tool/callRequestMethod")
    ]
    params: McpServerToolCallParams


class WindowsSandboxSetupStartRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["windowsSandbox/setupStart"], Field(title="WindowsSandbox/setupStartRequestMethod")
    ]
    params: WindowsSandboxSetupStartParams


class WindowsSandboxReadinessRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["windowsSandbox/readiness"], Field(title="WindowsSandbox/readinessRequestMethod")
    ]
    params: None = None


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 AccountSendAddCreditsNudgeEmailRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["account/sendAddCreditsNudgeEmail"],
        Field(title="Account/sendAddCreditsNudgeEmailRequestMethod"),
    ]
    params: SendAddCreditsNudgeEmailParams


class FeedbackUploadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["feedback/upload"], Field(title="Feedback/uploadRequestMethod")]
    params: FeedbackUploadParams


class CommandExecWriteRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["command/exec/write"], Field(title="Command/exec/writeRequestMethod")]
    params: CommandExecWriteParams


class CommandExecTerminateRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["command/exec/terminate"], Field(title="Command/exec/terminateRequestMethod")
    ]
    params: CommandExecTerminateParams


class ConfigReadRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["config/read"], Field(title="Config/readRequestMethod")]
    params: ConfigReadParams


class ExternalAgentConfigDetectRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["externalAgentConfig/detect"],
        Field(title="ExternalAgentConfig/detectRequestMethod"),
    ]
    params: ExternalAgentConfigDetectParams


class 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 ActiveTurnNotSteerable(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    turn_kind: Annotated[NonSteerableTurnKind, Field(alias="turnKind")]


class ActiveTurnNotSteerableCodexErrorInfo(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    active_turn_not_steerable: Annotated[
        ActiveTurnNotSteerable, Field(alias="activeTurnNotSteerable")
    ]


class CodexErrorInfo(
    RootModel[
        CodexErrorInfoValue
        | HttpConnectionFailedCodexErrorInfo
        | ResponseStreamConnectionFailedCodexErrorInfo
        | ResponseStreamDisconnectedCodexErrorInfo
        | ResponseTooManyFailedAttemptsCodexErrorInfo
        | ActiveTurnNotSteerableCodexErrorInfo
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Annotated[
        CodexErrorInfoValue
        | HttpConnectionFailedCodexErrorInfo
        | ResponseStreamConnectionFailedCodexErrorInfo
        | ResponseStreamDisconnectedCodexErrorInfo
        | ResponseTooManyFailedAttemptsCodexErrorInfo
        | ActiveTurnNotSteerableCodexErrorInfo,
        Field(
            description="This translation layer make sure that we expose codex error code in camel case.\n\nWhen an upstream HTTP status is available (for example, from the Responses API or a provider), it is forwarded in `httpStatusCode` on the relevant `codexErrorInfo` variant."
        ),
    ]


class CollabAgentState(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    message: str | None = None
    status: CollabAgentStatus


class CollaborationMode(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    mode: ModeKind
    settings: Settings


class CollaborationModeMask(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    mode: ModeKind | None = None
    model: str | None = None
    name: str
    reasoning_effort: ReasoningEffort | None = None


class CommandExecOutputDeltaNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cap_reached: Annotated[
        bool,
        Field(
            alias="capReached",
            description="`true` on the final streamed chunk for a stream when `outputBytesCap` truncated later output on that stream.",
        ),
    ]
    delta_base64: Annotated[
        str, Field(alias="deltaBase64", description="Base64-encoded output bytes.")
    ]
    process_id: Annotated[
        str,
        Field(
            alias="processId",
            description="Client-supplied, connection-scoped `processId` from the original `command/exec` request.",
        ),
    ]
    stream: Annotated[CommandExecOutputStream, Field(description="Output stream for this chunk.")]


class CommandExecParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    command: Annotated[
        list[str], Field(description="Command argv vector. Empty arrays are rejected.")
    ]
    cwd: Annotated[
        str | None, Field(description="Optional working directory. Defaults to the server cwd.")
    ] = None
    disable_output_cap: Annotated[
        bool | None,
        Field(
            alias="disableOutputCap",
            description="Disable stdout/stderr capture truncation for this request.\n\nCannot be combined with `outputBytesCap`.",
        ),
    ] = None
    disable_timeout: Annotated[
        bool | None,
        Field(
            alias="disableTimeout",
            description="Disable the timeout entirely for this request.\n\nCannot be combined with `timeoutMs`.",
        ),
    ] = None
    env: Annotated[
        dict[str, Any] | None,
        Field(
            description="Optional environment overrides merged into the server-computed environment.\n\nMatching names override inherited values. Set a key to `null` to unset an inherited variable."
        ),
    ] = None
    output_bytes_cap: Annotated[
        int | None,
        Field(
            alias="outputBytesCap",
            description="Optional per-stream stdout/stderr capture cap in bytes.\n\nWhen omitted, the server default applies. Cannot be combined with `disableOutputCap`.",
            ge=0,
        ),
    ] = None
    process_id: Annotated[
        str | None,
        Field(
            alias="processId",
            description="Optional client-supplied, connection-scoped process id.\n\nRequired for `tty`, `streamStdin`, `streamStdoutStderr`, and follow-up `command/exec/write`, `command/exec/resize`, and `command/exec/terminate` calls. When omitted, buffered execution gets an internal id that is not exposed to the client.",
        ),
    ] = None
    sandbox_policy: Annotated[
        SandboxPolicy | None,
        Field(
            alias="sandboxPolicy",
            description="Optional sandbox policy for this command.\n\nUses the same shape as thread/turn execution sandbox configuration and defaults to the user's configured policy when omitted. Cannot be combined with `permissionProfile`.",
        ),
    ] = None
    size: Annotated[
        CommandExecTerminalSize | None,
        Field(
            description="Optional initial PTY size in character cells. Only valid when `tty` is true."
        ),
    ] = None
    stream_stdin: Annotated[
        bool | None,
        Field(
            alias="streamStdin",
            description="Allow follow-up `command/exec/write` requests to write stdin bytes.\n\nRequires a client-supplied `processId`.",
        ),
    ] = None
    stream_stdout_stderr: Annotated[
        bool | None,
        Field(
            alias="streamStdoutStderr",
            description="Stream stdout/stderr via `command/exec/outputDelta` notifications.\n\nStreamed bytes are not duplicated into the final response and require a client-supplied `processId`.",
        ),
    ] = None
    timeout_ms: Annotated[
        int | None,
        Field(
            alias="timeoutMs",
            description="Optional timeout in milliseconds.\n\nWhen omitted, the server default applies. Cannot be combined with `disableTimeout`.",
        ),
    ] = None
    tty: Annotated[
        bool | None,
        Field(
            description="Enable PTY mode.\n\nThis implies `streamStdin` and `streamStdoutStderr`."
        ),
    ] = None


class CommandExecResizeParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    process_id: Annotated[
        str,
        Field(
            alias="processId",
            description="Client-supplied, connection-scoped `processId` from the original `command/exec` request.",
        ),
    ]
    size: Annotated[CommandExecTerminalSize, Field(description="New PTY size in character cells.")]


class 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,
    )
    allow_appshots: Annotated[bool | None, Field(alias="allowAppshots")] = None
    allow_managed_hooks_only: Annotated[bool | None, Field(alias="allowManagedHooksOnly")] = None
    allowed_approval_policies: Annotated[
        list[AskForApproval] | None, Field(alias="allowedApprovalPolicies")
    ] = None
    allowed_permissions: Annotated[list[str] | None, Field(alias="allowedPermissions")] = None
    allowed_sandbox_modes: Annotated[
        list[SandboxMode] | None, Field(alias="allowedSandboxModes")
    ] = None
    allowed_web_search_modes: Annotated[
        list[WebSearchMode] | None, Field(alias="allowedWebSearchModes")
    ] = None
    allowed_windows_sandbox_implementations: Annotated[
        list[WindowsSandboxSetupMode] | None, Field(alias="allowedWindowsSandboxImplementations")
    ] = None
    computer_use: Annotated[ComputerUseRequirements | None, Field(alias="computerUse")] = 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 InputImageContentItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    detail: ImageDetail | None = None
    image_url: str
    type: Annotated[Literal["input_image"], Field(title="InputImageContentItemType")]


class ContentItem(RootModel[InputTextContentItem | InputImageContentItem | OutputTextContentItem]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: InputTextContentItem | InputImageContentItem | OutputTextContentItem


class ExperimentalFeature(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    announcement: Annotated[
        str | None,
        Field(
            description="Announcement copy shown to users when the feature is introduced. Null when this feature is not in beta."
        ),
    ] = None
    default_enabled: Annotated[
        bool,
        Field(alias="defaultEnabled", description="Whether this feature is enabled by default."),
    ]
    description: Annotated[
        str | None,
        Field(
            description="Short summary describing what the feature does. Null when this feature is not in beta."
        ),
    ] = None
    display_name: Annotated[
        str | None,
        Field(
            alias="displayName",
            description="User-facing display name shown in the experimental features UI. Null when this feature is not in beta.",
        ),
    ] = None
    enabled: Annotated[
        bool, Field(description="Whether this feature is currently enabled in the loaded config.")
    ]
    name: Annotated[str, Field(description="Stable key used in config.toml and CLI flag toggles.")]
    stage: Annotated[
        ExperimentalFeatureStage, Field(description="Lifecycle stage of this feature flag.")
    ]


class ExperimentalFeatureListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[ExperimentalFeature]
    next_cursor: Annotated[
        str | None,
        Field(
            alias="nextCursor",
            description="Opaque cursor to pass to the next call to continue after the last item. If None, there are no more items to return.",
        ),
    ] = None


class SpecialFileSystemPath(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Annotated[Literal["special"], Field(title="SpecialFileSystemPathType")]
    value: FileSystemSpecialPath


class FileSystemPath(
    RootModel[PathFileSystemPath | GlobPatternFileSystemPath | SpecialFileSystemPath]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: PathFileSystemPath | GlobPatternFileSystemPath | SpecialFileSystemPath


class FileSystemSandboxEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    access: FileSystemAccessMode
    path: FileSystemPath


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
        | EncryptedContentFunctionCallOutputContentItem
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Annotated[
        InputTextFunctionCallOutputContentItem
        | InputImageFunctionCallOutputContentItem
        | EncryptedContentFunctionCallOutputContentItem,
        Field(
            description="Responses API compatible content items that can be returned by a tool call. This is a subset of ContentItem with the types we support as function call outputs."
        ),
    ]


class GetAccountResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    account: Account | None = None
    requires_openai_auth: Annotated[bool, Field(alias="requiresOpenaiAuth")]


class GuardianApprovalReview(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    rationale: str | None = None
    risk_level: Annotated[GuardianRiskLevel | None, Field(alias="riskLevel")] = None
    status: GuardianApprovalReviewStatus
    user_authorization: Annotated[
        GuardianUserAuthorization | None, Field(alias="userAuthorization")
    ] = None


class CommandGuardianApprovalReviewAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    command: str
    cwd: AbsolutePathBuf
    source: GuardianCommandSource
    type: Annotated[Literal["command"], Field(title="CommandGuardianApprovalReviewActionType")]


class ExecveGuardianApprovalReviewAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    argv: list[str]
    cwd: AbsolutePathBuf
    program: str
    source: GuardianCommandSource
    type: Annotated[Literal["execve"], Field(title="ExecveGuardianApprovalReviewActionType")]


class NetworkAccessGuardianApprovalReviewAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    host: str
    port: Annotated[int, Field(ge=0)]
    protocol: NetworkApprovalProtocol
    target: str
    type: Annotated[
        Literal["networkAccess"], Field(title="NetworkAccessGuardianApprovalReviewActionType")
    ]


class HookMetadata(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    command: str | None = None
    current_hash: Annotated[str, Field(alias="currentHash")]
    display_order: Annotated[int, Field(alias="displayOrder")]
    enabled: bool
    event_name: Annotated[HookEventName, Field(alias="eventName")]
    handler_type: Annotated[HookHandlerType, Field(alias="handlerType")]
    is_managed: Annotated[bool, Field(alias="isManaged")]
    key: str
    matcher: str | None = None
    plugin_id: Annotated[str | None, Field(alias="pluginId")] = None
    source: HookSource
    source_path: Annotated[AbsolutePathBuf, Field(alias="sourcePath")]
    status_message: Annotated[str | None, Field(alias="statusMessage")] = None
    timeout_sec: Annotated[int, Field(alias="timeoutSec", ge=0)]
    trust_status: Annotated[HookTrustStatus, Field(alias="trustStatus")]


class HookOutputEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    kind: HookOutputEntryKind
    text: str


class HookRunSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    completed_at: Annotated[int | None, Field(alias="completedAt")] = None
    display_order: Annotated[int, Field(alias="displayOrder")]
    duration_ms: Annotated[int | None, Field(alias="durationMs")] = None
    entries: list[HookOutputEntry]
    event_name: Annotated[HookEventName, Field(alias="eventName")]
    execution_mode: Annotated[HookExecutionMode, Field(alias="executionMode")]
    handler_type: Annotated[HookHandlerType, Field(alias="handlerType")]
    id: str
    scope: HookScope
    source: HookSource | None = "unknown"
    source_path: Annotated[AbsolutePathBuf, Field(alias="sourcePath")]
    started_at: Annotated[int, Field(alias="startedAt")]
    status: HookRunStatus
    status_message: Annotated[str | None, Field(alias="statusMessage")] = None


class HookStartedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    run: HookRunSummary
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str | None, Field(alias="turnId")] = None


class HooksListEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: str
    errors: list[HookErrorInfo]
    hooks: list[HookMetadata]
    warnings: list[str]


class HooksListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[HooksListEntry]


class ListMcpServerStatusParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cursor: Annotated[
        str | None, Field(description="Opaque pagination cursor returned by a previous call.")
    ] = None
    detail: Annotated[
        McpServerStatusDetail | None,
        Field(
            description="Controls how much MCP inventory data to fetch for each server. Defaults to `Full` when omitted."
        ),
    ] = None
    limit: Annotated[
        int | None,
        Field(description="Optional page size; defaults to a server-defined value.", ge=0),
    ] = None
    thread_id: Annotated[str | None, Field(alias="threadId")] = None


class McpResourceReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    contents: list[ResourceContent]


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]
    server_info: Annotated[McpServerInfo | None, Field(alias="serverInfo")] = None
    tools: dict[str, Tool]


class MemoryCitation(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    entries: list[MemoryCitationEntry]
    thread_ids: Annotated[list[str], Field(alias="threadIds")]


class MigrationDetails(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    commands: list[CommandMigration] | None = []
    hooks: list[HookMigration] | None = []
    mcp_servers: Annotated[list[McpServerMigration] | None, Field(alias="mcpServers")] = []
    plugins: list[PluginsMigration] | None = []
    sessions: list[SessionMigration] | None = []
    subagents: list[SubagentMigration] | None = []


class Model(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    additional_speed_tiers: Annotated[
        list[str] | None,
        Field(alias="additionalSpeedTiers", description="Deprecated: use `serviceTiers` instead."),
    ] = []
    availability_nux: Annotated[ModelAvailabilityNux | None, Field(alias="availabilityNux")] = None
    default_reasoning_effort: Annotated[ReasoningEffort, Field(alias="defaultReasoningEffort")]
    default_service_tier: Annotated[
        str | None,
        Field(
            alias="defaultServiceTier",
            description="Catalog default service tier id for this model, when one is configured.",
        ),
    ] = None
    description: str
    display_name: Annotated[str, Field(alias="displayName")]
    hidden: bool
    id: str
    input_modalities: Annotated[list[InputModality] | None, Field(alias="inputModalities")] = [
        "text",
        "image",
    ]
    is_default: Annotated[bool, Field(alias="isDefault")]
    model: str
    service_tiers: Annotated[list[ModelServiceTier] | None, Field(alias="serviceTiers")] = []
    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 PermissionProfileListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[PermissionProfileSummary]
    next_cursor: Annotated[
        str | None,
        Field(
            alias="nextCursor",
            description="Opaque cursor to pass to the next call to continue after the last item. If None, there are no more items to return.",
        ),
    ] = None


class PluginSharePrincipal(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str
    principal_id: Annotated[str, Field(alias="principalId")]
    principal_type: Annotated[PluginSharePrincipalType, Field(alias="principalType")]
    role: PluginSharePrincipalRole


class PluginShareTarget(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    principal_id: Annotated[str, Field(alias="principalId")]
    principal_type: Annotated[PluginSharePrincipalType, Field(alias="principalType")]
    role: PluginShareTargetRole


class PluginShareUpdateTargetsParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    discoverability: PluginShareUpdateDiscoverability
    remote_plugin_id: Annotated[str, Field(alias="remotePluginId")]
    share_targets: Annotated[list[PluginShareTarget], Field(alias="shareTargets")]


class PluginShareUpdateTargetsResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    discoverability: PluginShareDiscoverability
    principals: list[PluginSharePrincipal]


class ProcessOutputDeltaNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cap_reached: Annotated[
        bool,
        Field(
            alias="capReached",
            description="True on the final streamed chunk for this stream when output was truncated by `outputBytesCap`.",
        ),
    ]
    delta_base64: Annotated[
        str, Field(alias="deltaBase64", description="Base64-encoded output bytes.")
    ]
    process_handle: Annotated[
        str,
        Field(
            alias="processHandle",
            description="Client-supplied, connection-scoped `processHandle` from `process/spawn`.",
        ),
    ]
    stream: Annotated[
        ProcessOutputStream, Field(description="Output stream this chunk belongs to.")
    ]


class RateLimitSnapshot(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    credits: CreditsSnapshot | None = None
    individual_limit: Annotated[
        SpendControlLimitSnapshot | None, Field(alias="individualLimit")
    ] = None
    limit_id: Annotated[str | None, Field(alias="limitId")] = None
    limit_name: Annotated[str | None, Field(alias="limitName")] = None
    plan_type: Annotated[PlanType | None, Field(alias="planType")] = None
    primary: RateLimitWindow | None = None
    rate_limit_reached_type: Annotated[
        RateLimitReachedType | None, Field(alias="rateLimitReachedType")
    ] = None
    secondary: RateLimitWindow | None = None


class MessageResponseItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    content: list[ContentItem]
    id: str | None = None
    phase: MessagePhase | None = None
    role: str
    type: Annotated[Literal["message"], Field(title="MessageResponseItemType")]


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 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 ThreadGoalClearedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/goal/cleared"], Field(title="Thread/goal/clearedNotificationMethod")
    ]
    params: ThreadGoalClearedNotification


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 CommandExecOutputDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["command/exec/outputDelta"],
        Field(title="Command/exec/outputDeltaNotificationMethod"),
    ]
    params: CommandExecOutputDeltaNotification


class ProcessOutputDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["process/outputDelta"], Field(title="Process/outputDeltaNotificationMethod")
    ]
    params: ProcessOutputDeltaNotification


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 WarningServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[Literal["warning"], Field(title="WarningNotificationMethod")]
    params: WarningNotification


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 ThreadRealtimeTranscriptDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/realtime/transcript/delta"],
        Field(title="Thread/realtime/transcript/deltaNotificationMethod"),
    ]
    params: ThreadRealtimeTranscriptDeltaNotification


class ThreadRealtimeTranscriptDoneServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/realtime/transcript/done"],
        Field(title="Thread/realtime/transcript/doneNotificationMethod"),
    ]
    params: ThreadRealtimeTranscriptDoneNotification


class ThreadRealtimeOutputAudioDeltaServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/realtime/outputAudio/delta"],
        Field(title="Thread/realtime/outputAudio/deltaNotificationMethod"),
    ]
    params: ThreadRealtimeOutputAudioDeltaNotification


class ThreadRealtimeSdpServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/realtime/sdp"], Field(title="Thread/realtime/sdpNotificationMethod")
    ]
    params: ThreadRealtimeSdpNotification


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: AbsolutePathBuf
    scope: SkillScope
    short_description: Annotated[
        str | None,
        Field(
            alias="shortDescription",
            description="Legacy short_description from SKILL.md. Prefer SKILL.json interface.short_description.",
        ),
    ] = None


class SkillsListEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: str
    errors: list[SkillErrorInfo]
    skills: list[SkillMetadata]


class SkillsListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[SkillsListEntry]


class ThreadSpawn(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    agent_nickname: str | None = None
    agent_path: AgentPath | None = None
    agent_role: str | None = None
    depth: int
    parent_thread_id: ThreadId


class ThreadSpawnSubAgentSource(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    thread_spawn: ThreadSpawn


class SubAgentSource(
    RootModel[SubAgentSourceValue | ThreadSpawnSubAgentSource | OtherSubAgentSource]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: SubAgentSourceValue | ThreadSpawnSubAgentSource | OtherSubAgentSource


class ThreadForkParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approval_policy: Annotated[AskForApproval | None, Field(alias="approvalPolicy")] = None
    approvals_reviewer: Annotated[
        ApprovalsReviewer | None,
        Field(
            alias="approvalsReviewer",
            description="Override where approval requests are routed for review on this thread and subsequent turns.",
        ),
    ] = None
    base_instructions: Annotated[str | None, Field(alias="baseInstructions")] = None
    config: dict[str, Any] | None = None
    cwd: str | None = None
    developer_instructions: Annotated[str | None, Field(alias="developerInstructions")] = None
    ephemeral: bool | None = None
    model: Annotated[
        str | None, Field(description="Configuration overrides for the forked thread, if any.")
    ] = None
    model_provider: Annotated[str | None, Field(alias="modelProvider")] = None
    sandbox: SandboxMode | None = None
    service_tier: Annotated[str | None, Field(alias="serviceTier")] = None
    thread_id: Annotated[str, Field(alias="threadId")]
    thread_source: Annotated[
        ThreadSource | None,
        Field(
            alias="threadSource",
            description="Optional client-supplied analytics source classification for this forked thread.",
        ),
    ] = None


class ThreadGoal(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    created_at: Annotated[int, Field(alias="createdAt")]
    objective: str
    status: ThreadGoalStatus
    thread_id: Annotated[str, Field(alias="threadId")]
    time_used_seconds: Annotated[int, Field(alias="timeUsedSeconds")]
    token_budget: Annotated[int | None, Field(alias="tokenBudget")] = None
    tokens_used: Annotated[int, Field(alias="tokensUsed")]
    updated_at: Annotated[int, Field(alias="updatedAt")]


class ThreadGoalGetResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    goal: ThreadGoal | None = None


class ThreadGoalSetParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    objective: str | None = None
    status: ThreadGoalStatus | None = None
    thread_id: Annotated[str, Field(alias="threadId")]
    token_budget: Annotated[int | None, Field(alias="tokenBudget")] = None


class ThreadGoalSetResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    goal: ThreadGoal


class ThreadGoalUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    goal: ThreadGoal
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str | None, Field(alias="turnId")] = None


class UserMessageThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    client_id: Annotated[str | None, Field(alias="clientId")] = None
    content: list[UserInput]
    id: str
    type: Annotated[Literal["userMessage"], Field(title="UserMessageThreadItemType")]


class AgentMessageThreadItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: str
    memory_citation: Annotated[MemoryCitation | None, Field(alias="memoryCitation")] = None
    phase: MessagePhase | None = None
    text: str
    type: Annotated[Literal["agentMessage"], Field(title="AgentMessageThreadItemType")]


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
        | HookPromptThreadItem
        | AgentMessageThreadItem
        | PlanThreadItem
        | ReasoningThreadItem
        | CommandExecutionThreadItem
        | FileChangeThreadItem
        | McpToolCallThreadItem
        | DynamicToolCallThreadItem
        | CollabAgentToolCallThreadItem
        | WebSearchThreadItem
        | ImageViewThreadItem
        | ImageGenerationThreadItem
        | EnteredReviewModeThreadItem
        | ExitedReviewModeThreadItem
        | ContextCompactionThreadItem
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: (
        UserMessageThreadItem
        | HookPromptThreadItem
        | 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[
        ThreadListCwdFilter | None,
        Field(
            description="Optional cwd filter or filters; when set, only threads whose session cwd exactly matches one of these paths are returned."
        ),
    ] = None
    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_direction: Annotated[
        SortDirection | None,
        Field(
            alias="sortDirection",
            description="Optional sort direction; defaults to descending (newest first).",
        ),
    ] = None
    sort_key: Annotated[
        ThreadSortKey | None,
        Field(alias="sortKey", description="Optional sort key; defaults to created_at."),
    ] = None
    source_kinds: Annotated[
        list[ThreadSourceKind] | None,
        Field(
            alias="sourceKinds",
            description="Optional source filter; when set, only sessions from these source kinds are returned. When omitted or empty, defaults to interactive sources.",
        ),
    ] = None
    use_state_db_only: Annotated[
        bool | None,
        Field(
            alias="useStateDbOnly",
            description="If true, return from the state DB without scanning JSONL rollouts to repair thread metadata. Omitted or false preserves scan-and-repair behavior.",
        ),
    ] = None


class ThreadResumeInitialTurnsPageParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    items_view: Annotated[
        TurnItemsView | None,
        Field(
            alias="itemsView",
            description="How much item detail to include for each returned turn; defaults to summary.",
        ),
    ] = None
    limit: Annotated[int | None, Field(description="Optional turn page size.", ge=0)] = None
    sort_direction: Annotated[
        SortDirection | None,
        Field(
            alias="sortDirection",
            description="Optional turn pagination direction; defaults to descending.",
        ),
    ] = None


class ThreadSettings(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    active_permission_profile: Annotated[
        ActivePermissionProfile | None, Field(alias="activePermissionProfile")
    ] = None
    approval_policy: Annotated[AskForApproval, Field(alias="approvalPolicy")]
    approvals_reviewer: Annotated[ApprovalsReviewer, Field(alias="approvalsReviewer")]
    collaboration_mode: Annotated[CollaborationMode, Field(alias="collaborationMode")]
    cwd: AbsolutePathBuf
    effort: ReasoningEffort | None = None
    model: str
    model_provider: Annotated[str, Field(alias="modelProvider")]
    personality: Personality | None = None
    sandbox_policy: Annotated[SandboxPolicy, Field(alias="sandboxPolicy")]
    service_tier: Annotated[str | None, Field(alias="serviceTier")] = None
    summary: ReasoningSummary | None = None


class ThreadSettingsUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]
    thread_settings: Annotated[ThreadSettings, Field(alias="threadSettings")]


class ThreadStartParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approval_policy: Annotated[AskForApproval | None, Field(alias="approvalPolicy")] = None
    approvals_reviewer: Annotated[
        ApprovalsReviewer | None,
        Field(
            alias="approvalsReviewer",
            description="Override where approval requests are routed for review on this thread and subsequent turns.",
        ),
    ] = None
    base_instructions: Annotated[str | None, Field(alias="baseInstructions")] = None
    config: dict[str, Any] | None = None
    cwd: str | None = None
    developer_instructions: Annotated[str | None, Field(alias="developerInstructions")] = None
    ephemeral: bool | None = None
    model: str | None = None
    model_provider: Annotated[str | None, Field(alias="modelProvider")] = None
    personality: Personality | None = None
    sandbox: SandboxMode | None = None
    service_name: Annotated[str | None, Field(alias="serviceName")] = None
    service_tier: Annotated[str | None, Field(alias="serviceTier")] = None
    session_start_source: Annotated[ThreadStartSource | None, Field(alias="sessionStartSource")] = (
        None
    )
    thread_source: Annotated[
        ThreadSource | None,
        Field(
            alias="threadSource",
            description="Optional client-supplied analytics source classification for this thread.",
        ),
    ] = None


class 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,
    )
    web_search: WebSearchToolConfig | None = None


class TurnError(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    additional_details: Annotated[str | None, Field(alias="additionalDetails")] = None
    codex_error_info: Annotated[CodexErrorInfo | None, Field(alias="codexErrorInfo")] = None
    message: str


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
    client_user_message_id: Annotated[str | None, Field(alias="clientUserMessageId")] = None
    cwd: Annotated[
        str | None,
        Field(description="Override the working directory for this turn and subsequent turns."),
    ] = None
    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[
        str | 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 TurnSteerParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    client_user_message_id: Annotated[str | None, Field(alias="clientUserMessageId")] = None
    expected_turn_id: Annotated[
        str,
        Field(
            alias="expectedTurnId",
            description="Required active turn id precondition. The request fails when it does not match the currently active turn.",
        ),
    ]
    input: list[UserInput]
    thread_id: Annotated[str, Field(alias="threadId")]


class WindowsSandboxSetupCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    error: str | None = None
    mode: WindowsSandboxSetupMode
    success: bool


class AccountRateLimitsUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    rate_limits: Annotated[RateLimitSnapshot, Field(alias="rateLimits")]


class AdditionalFileSystemPermissions(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    entries: list[FileSystemSandboxEntry] | None = None
    glob_scan_max_depth: Annotated[int | None, Field(alias="globScanMaxDepth", ge=1)] = None
    read: Annotated[
        list[AbsolutePathBuf] | None,
        Field(description="This will be removed in favor of `entries`."),
    ] = None
    write: Annotated[
        list[AbsolutePathBuf] | None,
        Field(description="This will be removed in favor of `entries`."),
    ] = None


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 ThreadStartRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/start"], Field(title="Thread/startRequestMethod")]
    params: ThreadStartParams


class ThreadForkRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/fork"], Field(title="Thread/forkRequestMethod")]
    params: ThreadForkParams


class ThreadGoalSetRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/goal/set"], Field(title="Thread/goal/setRequestMethod")]
    params: ThreadGoalSetParams


class ThreadListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["thread/list"], Field(title="Thread/listRequestMethod")]
    params: ThreadListParams


class PluginShareUpdateTargetsRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["plugin/share/updateTargets"],
        Field(title="Plugin/share/updateTargetsRequestMethod"),
    ]
    params: PluginShareUpdateTargetsParams


class 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 McpServerStatusListRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[
        Literal["mcpServerStatus/list"], Field(title="McpServerStatus/listRequestMethod")
    ]
    params: ListMcpServerStatusParams


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 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
    desktop: dict[str, Any] | None = None
    developer_instructions: str | None = None
    forced_chatgpt_workspace_id: ForcedChatgptWorkspaceIds | None = None
    forced_login_method: ForcedLoginMethod | None = None
    instructions: str | None = None
    model: str | None = None
    model_auto_compact_token_limit: int | None = None
    model_auto_compact_token_limit_scope: AutoCompactTokenLimitScope | None = None
    model_context_window: int | None = None
    model_provider: str | None = None
    model_reasoning_effort: ReasoningEffort | None = None
    model_reasoning_summary: ReasoningSummary | None = None
    model_verbosity: Verbosity | None = None
    review_model: str | None = None
    sandbox_mode: SandboxMode | None = None
    sandbox_workspace_write: SandboxWorkspaceWrite | None = None
    service_tier: str | None = None
    tools: ToolsV2 | None = None
    web_search: WebSearchMode | None = None


class ConfigBatchWriteParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    edits: list[ConfigEdit]
    expected_version: Annotated[str | None, Field(alias="expectedVersion")] = None
    file_path: Annotated[
        str | None,
        Field(
            alias="filePath",
            description="Path to the config file to write; defaults to the user's `config.toml` when omitted.",
        ),
    ] = None
    reload_user_config: Annotated[
        bool | None,
        Field(
            alias="reloadUserConfig",
            description="When true, hot-reload the updated user config into all loaded threads after writing.",
        ),
    ] = None


class ConfigReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    config: Config
    layers: list[ConfigLayer] | None = None
    origins: dict[str, ConfigLayerMetadata]


class ConfigWriteResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    file_path: Annotated[
        AbsolutePathBuf,
        Field(alias="filePath", description="Canonical path to the config file that was written."),
    ]
    overridden_metadata: Annotated[OverriddenMetadata | None, Field(alias="overriddenMetadata")] = (
        None
    )
    status: WriteStatus
    version: str


class ErrorNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    error: TurnError
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]
    will_retry: Annotated[bool, Field(alias="willRetry")]


class ExternalAgentConfigMigrationItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    cwd: Annotated[
        str | None,
        Field(
            description="Null or empty means home-scoped migration; non-empty means repo-scoped migration."
        ),
    ] = None
    description: str
    details: MigrationDetails | None = None
    item_type: Annotated[ExternalAgentConfigMigrationItemType, Field(alias="itemType")]


class FileChangePatchUpdatedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    changes: list[FileUpdateChange]
    item_id: Annotated[str, Field(alias="itemId")]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class 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,
    )
    completed_at_ms: Annotated[
        int,
        Field(
            alias="completedAtMs",
            description="Unix timestamp (in milliseconds) when this item lifecycle completed.",
        ),
    ]
    item: ThreadItem
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class ItemStartedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item: ThreadItem
    started_at_ms: Annotated[
        int,
        Field(
            alias="startedAtMs",
            description="Unix timestamp (in milliseconds) when this item lifecycle started.",
        ),
    ]
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class 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 PluginShareContext(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    creator_account_user_id: Annotated[str | None, Field(alias="creatorAccountUserId")] = None
    creator_name: Annotated[str | None, Field(alias="creatorName")] = None
    discoverability: PluginShareDiscoverability | None = None
    remote_plugin_id: Annotated[str, Field(alias="remotePluginId")]
    remote_version: Annotated[
        str | None,
        Field(
            alias="remoteVersion",
            description="Version of the remote shared plugin release when available.",
        ),
    ] = None
    share_principals: Annotated[
        list[PluginSharePrincipal] | None, Field(alias="sharePrincipals")
    ] = None
    share_url: Annotated[str | None, Field(alias="shareUrl")] = None


class PluginShareSaveParams(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    discoverability: PluginShareDiscoverability | None = None
    plugin_path: Annotated[AbsolutePathBuf, Field(alias="pluginPath")]
    remote_plugin_id: Annotated[str | None, Field(alias="remotePluginId")] = None
    share_targets: Annotated[list[PluginShareTarget] | None, Field(alias="shareTargets")] = None


class PluginSummary(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    auth_policy: Annotated[PluginAuthPolicy, Field(alias="authPolicy")]
    availability: Annotated[
        PluginAvailability | None,
        Field(description="Availability state for installing and using the plugin."),
    ] = "AVAILABLE"
    enabled: bool
    id: str
    install_policy: Annotated[PluginInstallPolicy, Field(alias="installPolicy")]
    installed: bool
    interface: PluginInterface | None = None
    keywords: list[str] | None = []
    local_version: Annotated[
        str | None,
        Field(
            alias="localVersion",
            description="Version of the locally materialized plugin package when available.",
        ),
    ] = None
    name: str
    remote_plugin_id: Annotated[
        str | None,
        Field(
            alias="remotePluginId", description="Backend remote plugin identifier when available."
        ),
    ] = None
    share_context: Annotated[
        PluginShareContext | None,
        Field(
            alias="shareContext",
            description="Remote sharing context associated with this plugin when available.",
        ),
    ] = None
    source: PluginSource


class RequestPermissionProfile(BaseModel):
    model_config = ConfigDict(
        extra="forbid",
        populate_by_name=True,
    )
    file_system: Annotated[AdditionalFileSystemPermissions | None, Field(alias="fileSystem")] = None
    network: AdditionalNetworkPermissions | None = None


class 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
    name: str | None = None
    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
        | CompactionResponseItem
        | CompactionTriggerResponseItem
        | ContextCompactionResponseItem
        | OtherResponseItem
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: (
        MessageResponseItem
        | ReasoningResponseItem
        | LocalShellCallResponseItem
        | FunctionCallResponseItem
        | ToolSearchCallResponseItem
        | FunctionCallOutputResponseItem
        | CustomToolCallResponseItem
        | CustomToolCallOutputResponseItem
        | ToolSearchOutputResponseItem
        | WebSearchCallResponseItem
        | ImageGenerationCallResponseItem
        | CompactionResponseItem
        | CompactionTriggerResponseItem
        | ContextCompactionResponseItem
        | OtherResponseItem
    )


class ErrorServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[Literal["error"], Field(title="ErrorNotificationMethod")]
    params: ErrorNotification


class ThreadGoalUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/goal/updated"], Field(title="Thread/goal/updatedNotificationMethod")
    ]
    params: ThreadGoalUpdatedNotification


class ThreadSettingsUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/settings/updated"], Field(title="Thread/settings/updatedNotificationMethod")
    ]
    params: ThreadSettingsUpdatedNotification


class ThreadTokenUsageUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["thread/tokenUsage/updated"],
        Field(title="Thread/tokenUsage/updatedNotificationMethod"),
    ]
    params: ThreadTokenUsageUpdatedNotification


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 ItemFileChangePatchUpdatedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    method: Annotated[
        Literal["item/fileChange/patchUpdated"],
        Field(title="Item/fileChange/patchUpdatedNotificationMethod"),
    ]
    params: FileChangePatchUpdatedNotification


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 | CustomSessionSource | SubAgentSessionSource]):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: SessionSourceValue | CustomSessionSource | SubAgentSessionSource


class Turn(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    completed_at: Annotated[
        int | None,
        Field(
            alias="completedAt", description="Unix timestamp (in seconds) when the turn completed."
        ),
    ] = None
    duration_ms: Annotated[
        int | None,
        Field(
            alias="durationMs",
            description="Duration between turn start and completion in milliseconds, if known.",
        ),
    ] = None
    error: Annotated[
        TurnError | None, Field(description="Only populated when the Turn's status is failed.")
    ] = None
    id: str
    items: Annotated[
        list[ThreadItem], Field(description="Thread items currently included in this turn payload.")
    ]
    items_view: Annotated[
        TurnItemsView | None,
        Field(
            alias="itemsView",
            description="Describes how much of `items` has been loaded for this turn.",
        ),
    ] = "full"
    started_at: Annotated[
        int | None,
        Field(alias="startedAt", description="Unix timestamp (in seconds) when the turn started."),
    ] = None
    status: TurnStatus


class TurnCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]
    turn: Turn


class TurnStartResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    turn: Turn


class TurnStartedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread_id: Annotated[str, Field(alias="threadId")]
    turn: Turn


class TurnsPage(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    backwards_cursor: Annotated[str | None, Field(alias="backwardsCursor")] = None
    data: list[Turn]
    next_cursor: Annotated[str | None, Field(alias="nextCursor")] = None


class PluginShareSaveRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["plugin/share/save"], Field(title="Plugin/share/saveRequestMethod")]
    params: PluginShareSaveParams


class ConfigBatchWriteRequest(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    id: RequestId
    method: Annotated[Literal["config/batchWrite"], Field(title="Config/batchWriteRequestMethod")]
    params: ConfigBatchWriteParams


class 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 RequestPermissionsGuardianApprovalReviewAction(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    permissions: RequestPermissionProfile
    reason: str | None = None
    type: Annotated[
        Literal["requestPermissions"],
        Field(title="RequestPermissionsGuardianApprovalReviewActionType"),
    ]


class GuardianApprovalReviewAction(
    RootModel[
        CommandGuardianApprovalReviewAction
        | ExecveGuardianApprovalReviewAction
        | ApplyPatchGuardianApprovalReviewAction
        | NetworkAccessGuardianApprovalReviewAction
        | McpToolCallGuardianApprovalReviewAction
        | RequestPermissionsGuardianApprovalReviewAction
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: (
        CommandGuardianApprovalReviewAction
        | ExecveGuardianApprovalReviewAction
        | ApplyPatchGuardianApprovalReviewAction
        | NetworkAccessGuardianApprovalReviewAction
        | McpToolCallGuardianApprovalReviewAction
        | RequestPermissionsGuardianApprovalReviewAction
    )


class ItemGuardianApprovalReviewCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    action: GuardianApprovalReviewAction
    completed_at_ms: Annotated[
        int,
        Field(
            alias="completedAtMs",
            description="Unix timestamp (in milliseconds) when this review completed.",
        ),
    ]
    decision_source: Annotated[AutoReviewDecisionSource, Field(alias="decisionSource")]
    review: GuardianApprovalReview
    review_id: Annotated[
        str, Field(alias="reviewId", description="Stable identifier for this review.")
    ]
    started_at_ms: Annotated[
        int,
        Field(
            alias="startedAtMs",
            description="Unix timestamp (in milliseconds) when this review started.",
        ),
    ]
    target_item_id: Annotated[
        str | None,
        Field(
            alias="targetItemId",
            description="Identifier for the reviewed item or tool call when one exists.\n\nIn most cases, one review maps to one target item. The exceptions are - execve reviews, where a single command may contain multiple execve calls to review (only possible when using the shell_zsh_fork feature) - network policy reviews, where there is no target item\n\nA network call is triggered by a CommandExecution item, so having a target_item_id set to the CommandExecution item would be misleading because the review is about the network call, not the command execution. Therefore, target_item_id is set to None for network policy reviews.",
        ),
    ] = None
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class ItemGuardianApprovalReviewStartedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    action: GuardianApprovalReviewAction
    review: GuardianApprovalReview
    review_id: Annotated[
        str, Field(alias="reviewId", description="Stable identifier for this review.")
    ]
    started_at_ms: Annotated[
        int,
        Field(
            alias="startedAtMs",
            description="Unix timestamp (in milliseconds) when this review started.",
        ),
    ]
    target_item_id: Annotated[
        str | None,
        Field(
            alias="targetItemId",
            description="Identifier for the reviewed item or tool call when one exists.\n\nIn most cases, one review maps to one target item. The exceptions are - execve reviews, where a single command may contain multiple execve calls to review (only possible when using the shell_zsh_fork feature) - network policy reviews, where there is no target item\n\nA network call is triggered by a CommandExecution item, so having a target_item_id set to the CommandExecution item would be misleading because the review is about the network call, not the command execution. Therefore, target_item_id is set to None for network policy reviews.",
        ),
    ] = None
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class PluginDetail(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    apps: list[AppSummary]
    description: str | None = None
    hooks: list[PluginHookSummary]
    marketplace_name: Annotated[str, Field(alias="marketplaceName")]
    marketplace_path: Annotated[AbsolutePathBuf | None, Field(alias="marketplacePath")] = None
    mcp_servers: Annotated[list[str], Field(alias="mcpServers")]
    skills: list[SkillSummary]
    summary: PluginSummary


class PluginMarketplaceEntry(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    interface: MarketplaceInterface | None = None
    name: str
    path: Annotated[
        AbsolutePathBuf | None,
        Field(
            description="Local marketplace file path when the marketplace is backed by a local file. Remote-only catalog marketplaces do not have a local path."
        ),
    ] = None
    plugins: list[PluginSummary]


class PluginReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    plugin: PluginDetail


class PluginShareListItem(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    local_plugin_path: Annotated[AbsolutePathBuf | None, Field(alias="localPluginPath")] = None
    plugin: PluginSummary


class PluginShareListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    data: list[PluginShareListItem]


class RawResponseItemCompletedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    item: ResponseItem
    thread_id: Annotated[str, Field(alias="threadId")]
    turn_id: Annotated[str, Field(alias="turnId")]


class ReviewStartResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    review_thread_id: Annotated[
        str,
        Field(
            alias="reviewThreadId",
            description="Identifies the thread where the review runs.\n\nFor inline reviews, this is the original thread id. For detached reviews, this is the id of the new review thread.",
        ),
    ]
    turn: Turn


class TurnStartedServerNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    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 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 Thread(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    agent_nickname: Annotated[
        str | None,
        Field(
            alias="agentNickname",
            description="Optional random unique nickname assigned to an AgentControl-spawned sub-agent.",
        ),
    ] = None
    agent_role: Annotated[
        str | None,
        Field(
            alias="agentRole",
            description="Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
        ),
    ] = None
    cli_version: Annotated[
        str, Field(alias="cliVersion", description="Version of the CLI that created the thread.")
    ]
    created_at: Annotated[
        int,
        Field(
            alias="createdAt",
            description="Unix timestamp (in seconds) when the thread was created.",
        ),
    ]
    cwd: Annotated[AbsolutePathBuf, Field(description="Working directory captured for the thread.")]
    ephemeral: Annotated[
        bool,
        Field(
            description="Whether the thread is ephemeral and should not be materialized on disk."
        ),
    ]
    forked_from_id: Annotated[
        str | None,
        Field(
            alias="forkedFromId",
            description="Source thread id when this thread was created by forking another thread.",
        ),
    ] = None
    git_info: Annotated[
        GitInfo | None,
        Field(
            alias="gitInfo",
            description="Optional Git metadata captured when the thread was created.",
        ),
    ] = None
    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
    parent_thread_id: Annotated[
        str | None,
        Field(
            alias="parentThreadId",
            description="The ID of the parent thread. This will only be set if this thread is a subagent.",
        ),
    ] = None
    path: Annotated[str | None, Field(description="[UNSTABLE] Path to the thread on disk.")] = None
    preview: Annotated[
        str, Field(description="Usually the first user message in the thread, if available.")
    ]
    session_id: Annotated[
        str,
        Field(
            alias="sessionId",
            description="Session id shared by threads that belong to the same session tree.",
        ),
    ]
    source: Annotated[
        SessionSource,
        Field(
            description="Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.)."
        ),
    ]
    status: Annotated[ThreadStatus, Field(description="Current runtime status for the thread.")]
    thread_source: Annotated[
        ThreadSource | None,
        Field(
            alias="threadSource",
            description="Optional analytics source classification for this thread.",
        ),
    ] = None
    turns: Annotated[
        list[Turn],
        Field(
            description="Only populated on `thread/resume`, `thread/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: AbsolutePathBuf
    instruction_sources: Annotated[
        list[AbsolutePathBuf] | None,
        Field(
            alias="instructionSources",
            description="Instruction source files currently loaded for this thread.",
        ),
    ] = []
    model: str
    model_provider: Annotated[str, Field(alias="modelProvider")]
    reasoning_effort: Annotated[ReasoningEffort | None, Field(alias="reasoningEffort")] = None
    sandbox: Annotated[
        SandboxPolicy,
        Field(
            description="Legacy sandbox policy retained for compatibility. Experimental clients should prefer `activePermissionProfile` for profile provenance."
        ),
    ]
    service_tier: Annotated[str | None, Field(alias="serviceTier")] = None
    thread: Thread


class ThreadListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    backwards_cursor: Annotated[
        str | None,
        Field(
            alias="backwardsCursor",
            description="Opaque cursor to pass as `cursor` when reversing `sortDirection`. This is only populated when the page contains at least one thread. Use it with the opposite `sortDirection`; for timestamp sorts it anchors at the start of the page timestamp so same-second updates are not skipped.",
        ),
    ] = None
    data: list[Thread]
    next_cursor: Annotated[
        str | None,
        Field(
            alias="nextCursor",
            description="Opaque cursor to pass to the next call to continue after the last item. if None, there are no more items to return.",
        ),
    ] = None


class ThreadMetadataUpdateResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread: Thread


class ThreadReadResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread: Thread


class ThreadResumeResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approval_policy: Annotated[AskForApproval, Field(alias="approvalPolicy")]
    approvals_reviewer: Annotated[
        ApprovalsReviewer,
        Field(
            alias="approvalsReviewer",
            description="Reviewer currently used for approval requests on this thread.",
        ),
    ]
    cwd: AbsolutePathBuf
    instruction_sources: Annotated[
        list[AbsolutePathBuf] | None,
        Field(
            alias="instructionSources",
            description="Instruction source files currently loaded for this thread.",
        ),
    ] = []
    model: str
    model_provider: Annotated[str, Field(alias="modelProvider")]
    reasoning_effort: Annotated[ReasoningEffort | None, Field(alias="reasoningEffort")] = None
    sandbox: Annotated[
        SandboxPolicy,
        Field(
            description="Legacy sandbox policy retained for compatibility. Experimental clients should prefer `activePermissionProfile` for profile provenance."
        ),
    ]
    service_tier: Annotated[str | None, Field(alias="serviceTier")] = None
    thread: Thread


class 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 ThreadSearchResult(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    snippet: str
    thread: Thread


class ThreadStartResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    approval_policy: Annotated[AskForApproval, Field(alias="approvalPolicy")]
    approvals_reviewer: Annotated[
        ApprovalsReviewer,
        Field(
            alias="approvalsReviewer",
            description="Reviewer currently used for approval requests on this thread.",
        ),
    ]
    cwd: AbsolutePathBuf
    instruction_sources: Annotated[
        list[AbsolutePathBuf] | None,
        Field(
            alias="instructionSources",
            description="Instruction source files currently loaded for this thread.",
        ),
    ] = []
    model: str
    model_provider: Annotated[str, Field(alias="modelProvider")]
    reasoning_effort: Annotated[ReasoningEffort | None, Field(alias="reasoningEffort")] = None
    sandbox: Annotated[
        SandboxPolicy,
        Field(
            description="Legacy sandbox policy retained for compatibility. Experimental clients should prefer `activePermissionProfile` for profile provenance."
        ),
    ]
    service_tier: Annotated[str | None, Field(alias="serviceTier")] = None
    thread: Thread


class ThreadStartedNotification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    thread: Thread


class 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 ClientRequest(
    RootModel[
        InitializeRequest
        | ThreadStartRequest
        | ThreadResumeRequest
        | ThreadForkRequest
        | ThreadArchiveRequest
        | ThreadUnsubscribeRequest
        | ThreadNameSetRequest
        | ThreadGoalSetRequest
        | ThreadGoalGetRequest
        | ThreadGoalClearRequest
        | ThreadMetadataUpdateRequest
        | ThreadUnarchiveRequest
        | ThreadCompactStartRequest
        | ThreadShellCommandRequest
        | ThreadApproveGuardianDeniedActionRequest
        | ThreadRollbackRequest
        | ThreadListRequest
        | ThreadLoadedListRequest
        | ThreadReadRequest
        | ThreadInjectItemsRequest
        | SkillsListRequest
        | SkillsExtraRootsSetRequest
        | HooksListRequest
        | MarketplaceAddRequest
        | MarketplaceRemoveRequest
        | MarketplaceUpgradeRequest
        | PluginListRequest
        | PluginInstalledRequest
        | PluginReadRequest
        | PluginSkillReadRequest
        | PluginShareSaveRequest
        | PluginShareUpdateTargetsRequest
        | PluginShareListRequest
        | PluginShareCheckoutRequest
        | PluginShareDeleteRequest
        | AppListRequest
        | FsReadFileRequest
        | FsWriteFileRequest
        | FsCreateDirectoryRequest
        | FsGetMetadataRequest
        | FsReadDirectoryRequest
        | FsRemoveRequest
        | FsCopyRequest
        | FsWatchRequest
        | FsUnwatchRequest
        | SkillsConfigWriteRequest
        | PluginInstallRequest
        | PluginUninstallRequest
        | TurnStartRequest
        | TurnSteerRequest
        | TurnInterruptRequest
        | ReviewStartRequest
        | ModelListRequest
        | ModelProviderCapabilitiesReadRequest
        | ExperimentalFeatureListRequest
        | PermissionProfileListRequest
        | ExperimentalFeatureEnablementSetRequest
        | McpServerOauthLoginRequest
        | ConfigMcpServerReloadRequest
        | McpServerStatusListRequest
        | McpServerResourceReadRequest
        | McpServerToolCallRequest
        | WindowsSandboxSetupStartRequest
        | WindowsSandboxReadinessRequest
        | AccountLoginStartRequest
        | AccountLoginCancelRequest
        | AccountLogoutRequest
        | AccountRateLimitsReadRequest
        | AccountSendAddCreditsNudgeEmailRequest
        | 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
        | ThreadGoalSetRequest
        | ThreadGoalGetRequest
        | ThreadGoalClearRequest
        | ThreadMetadataUpdateRequest
        | ThreadUnarchiveRequest
        | ThreadCompactStartRequest
        | ThreadShellCommandRequest
        | ThreadApproveGuardianDeniedActionRequest
        | ThreadRollbackRequest
        | ThreadListRequest
        | ThreadLoadedListRequest
        | ThreadReadRequest
        | ThreadInjectItemsRequest
        | SkillsListRequest
        | SkillsExtraRootsSetRequest
        | HooksListRequest
        | MarketplaceAddRequest
        | MarketplaceRemoveRequest
        | MarketplaceUpgradeRequest
        | PluginListRequest
        | PluginInstalledRequest
        | PluginReadRequest
        | PluginSkillReadRequest
        | PluginShareSaveRequest
        | PluginShareUpdateTargetsRequest
        | PluginShareListRequest
        | PluginShareCheckoutRequest
        | PluginShareDeleteRequest
        | AppListRequest
        | FsReadFileRequest
        | FsWriteFileRequest
        | FsCreateDirectoryRequest
        | FsGetMetadataRequest
        | FsReadDirectoryRequest
        | FsRemoveRequest
        | FsCopyRequest
        | FsWatchRequest
        | FsUnwatchRequest
        | SkillsConfigWriteRequest
        | PluginInstallRequest
        | PluginUninstallRequest
        | TurnStartRequest
        | TurnSteerRequest
        | TurnInterruptRequest
        | ReviewStartRequest
        | ModelListRequest
        | ModelProviderCapabilitiesReadRequest
        | ExperimentalFeatureListRequest
        | PermissionProfileListRequest
        | ExperimentalFeatureEnablementSetRequest
        | McpServerOauthLoginRequest
        | ConfigMcpServerReloadRequest
        | McpServerStatusListRequest
        | McpServerResourceReadRequest
        | McpServerToolCallRequest
        | WindowsSandboxSetupStartRequest
        | WindowsSandboxReadinessRequest
        | AccountLoginStartRequest
        | AccountLoginCancelRequest
        | AccountLogoutRequest
        | AccountRateLimitsReadRequest
        | AccountSendAddCreditsNudgeEmailRequest
        | 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 PluginInstalledResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    marketplace_load_errors: Annotated[
        list[MarketplaceLoadErrorInfo] | None, Field(alias="marketplaceLoadErrors")
    ] = []
    marketplaces: list[PluginMarketplaceEntry]


class PluginListResponse(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    featured_plugin_ids: Annotated[list[str] | None, Field(alias="featuredPluginIds")] = []
    marketplace_load_errors: Annotated[
        list[MarketplaceLoadErrorInfo] | None, Field(alias="marketplaceLoadErrors")
    ] = []
    marketplaces: list[PluginMarketplaceEntry]


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
        | ThreadGoalUpdatedServerNotification
        | ThreadGoalClearedServerNotification
        | ThreadSettingsUpdatedServerNotification
        | ThreadTokenUsageUpdatedServerNotification
        | TurnStartedServerNotification
        | HookStartedServerNotification
        | TurnCompletedServerNotification
        | HookCompletedServerNotification
        | TurnDiffUpdatedServerNotification
        | TurnPlanUpdatedServerNotification
        | ItemStartedServerNotification
        | ItemAutoApprovalReviewStartedServerNotification
        | ItemAutoApprovalReviewCompletedServerNotification
        | ItemCompletedServerNotification
        | ItemAgentMessageDeltaServerNotification
        | ItemPlanDeltaServerNotification
        | CommandExecOutputDeltaServerNotification
        | ProcessOutputDeltaServerNotification
        | ProcessExitedServerNotification
        | ItemCommandExecutionOutputDeltaServerNotification
        | ItemCommandExecutionTerminalInteractionServerNotification
        | ItemFileChangeOutputDeltaServerNotification
        | ItemFileChangePatchUpdatedServerNotification
        | ServerRequestResolvedServerNotification
        | ItemMcpToolCallProgressServerNotification
        | McpServerOauthLoginCompletedServerNotification
        | McpServerStartupStatusUpdatedServerNotification
        | AccountUpdatedServerNotification
        | AccountRateLimitsUpdatedServerNotification
        | AppListUpdatedServerNotification
        | RemoteControlStatusChangedServerNotification
        | ExternalAgentConfigImportCompletedServerNotification
        | FsChangedServerNotification
        | ItemReasoningSummaryTextDeltaServerNotification
        | ItemReasoningSummaryPartAddedServerNotification
        | ItemReasoningTextDeltaServerNotification
        | ThreadCompactedServerNotification
        | ModelReroutedServerNotification
        | ModelVerificationServerNotification
        | WarningServerNotification
        | GuardianWarningServerNotification
        | DeprecationNoticeServerNotification
        | ConfigWarningServerNotification
        | FuzzyFileSearchSessionUpdatedServerNotification
        | FuzzyFileSearchSessionCompletedServerNotification
        | ThreadRealtimeStartedServerNotification
        | ThreadRealtimeItemAddedServerNotification
        | ThreadRealtimeTranscriptDeltaServerNotification
        | ThreadRealtimeTranscriptDoneServerNotification
        | ThreadRealtimeOutputAudioDeltaServerNotification
        | ThreadRealtimeSdpServerNotification
        | ThreadRealtimeErrorServerNotification
        | ThreadRealtimeClosedServerNotification
        | WindowsWorldWritableWarningServerNotification
        | WindowsSandboxSetupCompletedServerNotification
        | AccountLoginCompletedServerNotification
    ]
):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    root: Annotated[
        ErrorServerNotification
        | ThreadStartedServerNotification
        | ThreadStatusChangedServerNotification
        | ThreadArchivedServerNotification
        | ThreadUnarchivedServerNotification
        | ThreadClosedServerNotification
        | SkillsChangedServerNotification
        | ThreadNameUpdatedServerNotification
        | ThreadGoalUpdatedServerNotification
        | ThreadGoalClearedServerNotification
        | ThreadSettingsUpdatedServerNotification
        | ThreadTokenUsageUpdatedServerNotification
        | TurnStartedServerNotification
        | HookStartedServerNotification
        | TurnCompletedServerNotification
        | HookCompletedServerNotification
        | TurnDiffUpdatedServerNotification
        | TurnPlanUpdatedServerNotification
        | ItemStartedServerNotification
        | ItemAutoApprovalReviewStartedServerNotification
        | ItemAutoApprovalReviewCompletedServerNotification
        | ItemCompletedServerNotification
        | ItemAgentMessageDeltaServerNotification
        | ItemPlanDeltaServerNotification
        | CommandExecOutputDeltaServerNotification
        | ProcessOutputDeltaServerNotification
        | ProcessExitedServerNotification
        | ItemCommandExecutionOutputDeltaServerNotification
        | ItemCommandExecutionTerminalInteractionServerNotification
        | ItemFileChangeOutputDeltaServerNotification
        | ItemFileChangePatchUpdatedServerNotification
        | ServerRequestResolvedServerNotification
        | ItemMcpToolCallProgressServerNotification
        | McpServerOauthLoginCompletedServerNotification
        | McpServerStartupStatusUpdatedServerNotification
        | AccountUpdatedServerNotification
        | AccountRateLimitsUpdatedServerNotification
        | AppListUpdatedServerNotification
        | RemoteControlStatusChangedServerNotification
        | ExternalAgentConfigImportCompletedServerNotification
        | FsChangedServerNotification
        | ItemReasoningSummaryTextDeltaServerNotification
        | ItemReasoningSummaryPartAddedServerNotification
        | ItemReasoningTextDeltaServerNotification
        | ThreadCompactedServerNotification
        | ModelReroutedServerNotification
        | ModelVerificationServerNotification
        | WarningServerNotification
        | GuardianWarningServerNotification
        | DeprecationNoticeServerNotification
        | ConfigWarningServerNotification
        | FuzzyFileSearchSessionUpdatedServerNotification
        | FuzzyFileSearchSessionCompletedServerNotification
        | ThreadRealtimeStartedServerNotification
        | ThreadRealtimeItemAddedServerNotification
        | ThreadRealtimeTranscriptDeltaServerNotification
        | ThreadRealtimeTranscriptDoneServerNotification
        | ThreadRealtimeOutputAudioDeltaServerNotification
        | ThreadRealtimeSdpServerNotification
        | ThreadRealtimeErrorServerNotification
        | ThreadRealtimeClosedServerNotification
        | WindowsWorldWritableWarningServerNotification
        | WindowsSandboxSetupCompletedServerNotification
        | AccountLoginCompletedServerNotification,
        Field(
            description="Notification sent from the server to the client.",
            title="ServerNotification",
        ),
    ]
